Merge pull request #9 from taigaio/parallel-loading

Improvements on resource loading.
stable
David Barragán Merino 2014-09-04 14:04:54 +02:00
commit b75dbd4afb
9 changed files with 229 additions and 231 deletions

View File

@ -141,6 +141,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade
return promise.then null, (response) ->
if response.status == 0
$location.path($navUrls.resolve("error"))
$location.replace()
else if response.status == 401
nextPath = $location.path()
$location.url($navUrls.resolve("login")).search("next=#{nextPath}")

View File

@ -56,12 +56,17 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
promise = @.loadInitialData()
promise.then () =>
# On Success
promise.then =>
@appTitle.set("Backlog - " + @scope.project.name)
tgLoader.pageLoaded()
promise.then null, =>
console.log "FAIL"
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
@scope.$on("usform:bulk:success", @.loadUserstories)
@scope.$on("sprintform:create:success", @.loadSprints)
@ -109,8 +114,8 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
@scope.filtersQ = ""
_.forEach [selectedTags, selectedStatuses], (filterGrp) =>
_.forEach filterGrp, (item) =>
_.each [selectedTags, selectedStatuses], (filterGrp) =>
_.each filterGrp, (item) =>
filters = @scope.filters[item.type]
filter = _.find(filters, {id: taiga.toString(item.id)})
filter.selected = false
@ -119,32 +124,25 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
@.loadUserstories()
# @.filterVisibleUserstories()
# @rootscope.$broadcast("filters:loaded", @scope.filters)
loadUserstories: ->
@scope.urlFilters = @.getUrlFilters()
@scope.httpParams = {}
for name, values of @scope.urlFilters
@scope.httpParams[name] = values
@scope.httpParams = @.getUrlFilters()
@rs.userstories.storeQueryParams(@scope.projectId, @scope.httpParams)
@.refreshTagsColors().then =>
@rs.userstories.listUnassigned(@scope.projectId, @scope.httpParams).then (userstories) =>
@scope.userstories = userstories
promise = @.refreshTagsColors().then =>
return @rs.userstories.listUnassigned(@scope.projectId, @scope.httpParams)
@.generateFilters()
@.filterVisibleUserstories()
return promise.then (userstories) =>
@scope.userstories = userstories
@.generateFilters()
@.filterVisibleUserstories()
@rootscope.$broadcast("filters:loaded", @scope.filters)
# The broadcast must be executed when the DOM has been fully reloaded.
# We can't assure when this exactly happens so we need a defer
scopeDefer @scope, =>
@scope.$broadcast("userstories:loaded")
@rootscope.$broadcast("filters:loaded", @scope.filters)
# The broadcast must be executed when the DOM has been fully reloaded.
# We can't assure when this exactly happens so we need a defer
scopeDefer @scope, =>
@scope.$broadcast("userstories:loaded")
return userstories
return userstories
loadBacklog: ->
return @q.all([
@ -169,13 +167,9 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadBacklog())
return promise.then(=> @loadProject())
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadBacklog()]))
filterVisibleUserstories: ->
@scope.visibleUserstories = []

View File

@ -44,6 +44,7 @@ module.directive("tgMain", ["$rootScope", "$window", TaigaMainDirective])
urls = {
"home": "/"
"error": "/error"
"login": "/login"
"forgot-password": "/forgot-password"
"change-password": "/change-password/:token"

View File

@ -56,15 +56,20 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai
promise = @.loadInitialData()
promise.then () =>
# On Success
promise.then =>
@appTitle.set(@scope.issue.subject + " - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
@scope.$on "attachment:create", @loadHistory
@scope.$on "attachment:edit", @loadHistory
@scope.$on "attachment:delete", @loadHistory
@scope.$on("attachment:create", => @.loadHistory())
@scope.$on("attachment:edit", => @.loadHistory())
@scope.$on("attachment:delete", => @.loadHistory())
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@ -102,8 +107,8 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai
loadHistory: =>
return @rs.issues.history(@scope.issueId).then (history) =>
_.each history, (historyResult) ->
#If description was modified take only the description_html field
for historyResult in history
# If description was modified take only the description_html field
if historyResult.values_diff.description?
historyResult.values_diff.description = historyResult.values_diff.description_diff
@ -124,15 +129,11 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin, tai
@scope.issueId = data.issue
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadIssue())
.then(=> @.loadAttachments(@scope.issueId))
.then(=> @.loadHistory())
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadIssue(),
@.loadAttachments(@scope.issueId),
@.loadHistory()]))
block: ->
@rootscope.$broadcast("block", @scope.issue)

View File

@ -65,12 +65,17 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
promise = @.loadInitialData()
promise.then () =>
# On Success
promise.then =>
@appTitle.set("Issues - " + @scope.project.name)
tgLoader.pageLoaded()
promise.then null, ->
console.log "FAIL" #TODO
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
@scope.$on "issueform:new:success", =>
@.loadIssues()
@ -109,23 +114,14 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
return filters[name]
loadMyFilters: ->
deferred = @q.defer()
promise = @rs.issues.getMyFilters(@scope.projectId)
promise.then (filters) ->
result = _.map filters, (value, key) =>
obj = {
id: key,
name: key,
type: "myFilters"
}
obj.selected = false
return obj
deferred.resolve(result)
return deferred.promise
return @rs.issues.getMyFilters(@scope.projectId).then (filters) =>
return _.map filters, (value, key) =>
return {id: key, name: key, type: "myFilters", selected: false}
removeNotExistingFiltersFromUrl: ->
currentSearch = @location.search()
urlfilters = @.getUrlFilters()
for filterName, filterValue of urlfilters
if filterName == "page" or filterName == "orderBy" or filterName == "q"
continue
@ -162,64 +158,67 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
obj.selected = if isSelected(obj.type, obj.id) then true else undefined
loadFilters: ->
deferred = @q.defer()
urlfilters = @.getUrlFilters()
if urlfilters.q
@scope.filtersQ = urlfilters.q
@.loadMyFilters().then (myFilters) =>
# Load My Filters
promise = @.loadMyFilters().then (myFilters) =>
@scope.filters.myFilters = myFilters
@rs.issues.filtersData(@scope.projectId).then (data) =>
usersFiltersFormat = (users, type, unknownOption) =>
reformatedUsers = _.map users, (t) =>
return {
id: t[0],
count: t[1],
type: type
name: if t[0] then @scope.usersById[t[0]].full_name_display else unknownOption
}
unknownItem = _.remove(reformatedUsers, (u) -> not u.id)
reformatedUsers = _.sortBy(reformatedUsers, (u) -> u.name.toUpperCase())
if unknownItem.length > 0
reformatedUsers.unshift(unknownItem[0])
return reformatedUsers
return myFilters
choicesFiltersFormat = (choices, type, byIdObject) =>
_.map choices, (t) ->
return {
id: t[0],
name: byIdObject[t[0]].name,
color: byIdObject[t[0]].color,
count: t[1],
type: type}
# Load default filters data
promise = promise.then =>
return @rs.issues.filtersData(@scope.projectId)
tagsFilterFormat = (tags) =>
return _.map tags, (t) =>
return {
id: t[0],
name: t[0],
color: @scope.project.tags_colors[t[0]],
count: t[1],
type: "tags"
}
# Format filters and set them on scope
return promise.then (data) =>
usersFiltersFormat = (users, type, unknownOption) =>
reformatedUsers = _.map users, (t) =>
return {
id: t[0],
count: t[1],
type: type
name: if t[0] then @scope.usersById[t[0]].full_name_display else unknownOption
}
unknownItem = _.remove(reformatedUsers, (u) -> not u.id)
reformatedUsers = _.sortBy(reformatedUsers, (u) -> u.name.toUpperCase())
if unknownItem.length > 0
reformatedUsers.unshift(unknownItem[0])
return reformatedUsers
# Build filters data structure
@scope.filters.statuses = choicesFiltersFormat data.statuses, "statuses", @scope.issueStatusById
@scope.filters.severities = choicesFiltersFormat data.severities, "severities", @scope.severityById
@scope.filters.priorities = choicesFiltersFormat data.priorities, "priorities", @scope.priorityById
@scope.filters.assignedTo = usersFiltersFormat data.assigned_to, "assignedTo", "Unassigned"
@scope.filters.createdBy = usersFiltersFormat data.created_by, "createdBy", "Unknown"
@scope.filters.types = choicesFiltersFormat data.types, "types", @scope.issueTypeById
@scope.filters.tags = tagsFilterFormat data.tags
choicesFiltersFormat = (choices, type, byIdObject) =>
_.map choices, (t) ->
return {
id: t[0],
name: byIdObject[t[0]].name,
color: byIdObject[t[0]].color,
count: t[1],
type: type}
@.removeNotExistingFiltersFromUrl()
tagsFilterFormat = (tags) =>
return _.map tags, (t) =>
return {
id: t[0],
name: t[0],
color: @scope.project.tags_colors[t[0]],
count: t[1],
type: "tags"
}
@.markSelectedFilters(@scope.filters, urlfilters)
# Build filters data structure
@scope.filters.statuses = choicesFiltersFormat(data.statuses, "statuses", @scope.issueStatusById)
@scope.filters.severities = choicesFiltersFormat(data.severities, "severities", @scope.severityById)
@scope.filters.priorities = choicesFiltersFormat(data.priorities, "priorities", @scope.priorityById)
@scope.filters.assignedTo = usersFiltersFormat(data.assigned_to, "assignedTo", "Unassigned")
@scope.filters.createdBy = usersFiltersFormat(data.created_by, "createdBy", "Unknown")
@scope.filters.types = choicesFiltersFormat(data.types, "types", @scope.issueTypeById)
@scope.filters.tags = tagsFilterFormat(data.tags)
@rootscope.$broadcast("filters:loaded", @scope.filters)
deferred.resolve()
return deferred.promise
@.removeNotExistingFiltersFromUrl()
@.markSelectedFilters(@scope.filters, urlfilters)
@rootscope.$broadcast("filters:loaded", @scope.filters)
loadIssues: ->
@scope.urlFilters = @.getUrlFilters()
@ -247,28 +246,22 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
name = "type"
@scope.httpParams[name] = values
promise = @rs.issues.list(@scope.projectId, @scope.httpParams).then (data) =>
return @rs.issues.list(@scope.projectId, @scope.httpParams).then (data) =>
@scope.issues = data.models
@scope.page = data.current
@scope.count = data.count
@scope.paginatedBy = data.paginatedBy
return data
return promise
loadInitialData: ->
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadFilters())
.then(=> @.loadIssues())
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadFilters(),
@.loadIssues()]))
saveCurrentFiltersTo: (newFilter) ->
deferred = @q.defer()

View File

@ -50,16 +50,21 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, tgLoader) ->
_.bindAll(@)
@scope.sectionName = "Kanban"
promise = @.loadInitialData()
promise.then () =>
# On Success
promise.then =>
@appTitle.set("Kanban - " + @scope.project.name)
tgLoader.pageLoaded()
promise.then null, =>
console.log "FAIL"
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
@scope.$on("usform:new:success", @.loadUserstories)
@scope.$on("usform:bulk:success", @.loadUserstories)
@ -84,6 +89,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
onAssignedToChanged: (ctx, userid, us) ->
us.assigned_to = userid
promise = @repo.save(us)
promise.then null, ->
console.log "FAIL" # TODO
@ -107,25 +113,24 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
@scope.project.tags_colors = tags_colors
loadUserstories: ->
return @.refreshTagsColors().then =>
return @rs.userstories.listUnassigned(@scope.projectId).then (userstories) =>
@scope.userstories = userstories
return @rs.userstories.listUnassigned(@scope.projectId).then (userstories) =>
@scope.userstories = userstories
@scope.usByStatus = _.groupBy(userstories, "status")
@scope.usByStatus = _.groupBy(userstories, "status")
for status in @scope.usStatusList
if not @scope.usByStatus[status.id]?
@scope.usByStatus[status.id] = []
for status in @scope.usStatusList
if not @scope.usByStatus[status.id]?
@scope.usByStatus[status.id] = []
# The broadcast must be executed when the DOM has been fully reloaded.
# We can't assure when this exactly happens so we need a defer
scopeDefer @scope, =>
@scope.$broadcast("userstories:loaded")
# The broadcast must be executed when the DOM has been fully reloaded.
# We can't assure when this exactly happens so we need a defer
scopeDefer @scope, =>
@scope.$broadcast("userstories:loaded")
return userstories
return userstories
loadKanban: ->
return @q.all([
@.refreshTagsColors(),
@.loadProjectStats(),
@.loadUserstories()
])
@ -146,13 +151,9 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadKanban())
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadKanban()]))
.then(=> @scope.$broadcast("redraw:wip"))
prepareBulkUpdateData: (uses) ->

View File

@ -53,11 +53,16 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
promise = @.loadInitialData()
promise.then () =>
# On Success
promise.then =>
@appTitle.set("Taskboard - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
# TODO: Reload entire taskboard after create/edit tasks seems
# a big overhead. It should be optimized in near future.
@ -72,6 +77,20 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then null, ->
console.log "FAIL" # TODO
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
# Not used at this momment
@scope.pointsList = _.sortBy(project.points, "order")
# @scope.roleList = _.sortBy(project.roles, "order")
@scope.pointsById = groupBy(project.points, (e) -> e.id)
@scope.roleById = groupBy(project.roles, (e) -> e.id)
@scope.taskStatusList = _.sortBy(project.task_statuses, "order")
@scope.usStatusList = _.sortBy(project.us_statuses, "order")
@scope.usStatusById = groupBy(project.us_statuses, (e) -> e.id)
return project
loadSprintStats: ->
return @rs.sprints.stats(@scope.projectId, @scope.sprintId).then (stats) =>
totalPointsSum =_.reduce(_.values(stats.total_points), ((res, n) -> res + n), 0)
@ -100,42 +119,28 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
return sprint
loadTasks: ->
return @.refreshTagsColors().then =>
return @rs.tasks.list(@scope.projectId, @scope.sprintId).then (tasks) =>
@scope.tasks = tasks
@scope.usTasks = {}
return @rs.tasks.list(@scope.projectId, @scope.sprintId).then (tasks) =>
@scope.tasks = tasks
@scope.usTasks = {}
# Iterate over all userstories and
# null userstory for unassigned tasks
for us in _.union(@scope.userstories, [{id:null}])
@scope.usTasks[us.id] = {}
for status in @scope.taskStatusList
@scope.usTasks[us.id][status.id] = []
# Iterate over all userstories and
# null userstory for unassigned tasks
for us in _.union(@scope.userstories, [{id:null}])
@scope.usTasks[us.id] = {}
for status in @scope.taskStatusList
@scope.usTasks[us.id][status.id] = []
for task in @scope.tasks
@scope.usTasks[task.user_story][task.status].push(task)
for task in @scope.tasks
@scope.usTasks[task.user_story][task.status].push(task)
return tasks
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
# Not used at this momment
@scope.pointsList = _.sortBy(project.points, "order")
# @scope.roleList = _.sortBy(project.roles, "order")
@scope.pointsById = groupBy(project.points, (e) -> e.id)
@scope.roleById = groupBy(project.roles, (e) -> e.id)
@scope.taskStatusList = _.sortBy(project.task_statuses, "order")
@scope.usStatusList = _.sortBy(project.us_statuses, "order")
@scope.usStatusById = groupBy(project.us_statuses, (e) -> e.id)
return project
return tasks
loadTaskboard: ->
return @q.all([
@.refreshTagsColors(),
@.loadSprintStats(),
@.loadSprint()
]).then(=> @.loadTasks())
@.loadSprint().then(=> @.loadTasks())
])
loadInitialData: ->
params = {
@ -148,13 +153,9 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
@scope.sprintId = data.milestone
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadTaskboard())
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadTaskboard()]))
taskMove: (ctx, task, usId, statusId, order) ->
# Remove task from old position

View File

@ -48,21 +48,25 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin,
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @log, @appTitle, @navUrls) ->
@.attachmentsUrlName = "userstories/attachments"
@scope.issueRef = @params.issueref
@scope.sectionName = "User Story Details"
promise = @.loadInitialData()
promise.then () =>
# On Success
promise.then =>
@appTitle.set(@scope.us.subject + " - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
@scope.$on "attachment:create", @loadHistory
@scope.$on "attachment:edit", @loadHistory
@scope.$on "attachment:delete", @loadHistory
@scope.$on("attachment:create", => @loadHistory())
@scope.$on("attachment:edit", => @loadHistory())
@scope.$on("attachment:delete", => @loadHistory())
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@ -95,14 +99,17 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin,
}
@scope.nextUrl = @navUrls.resolve("project-userstories-detail", ctx)
return us
loadTasks: ->
return @rs.tasks.list(@scope.projectId, null, @scope.usId).then (tasks) =>
@scope.tasks = tasks
return tasks
loadHistory: =>
return @rs.userstories.history(@scope.usId).then (history) =>
_.each history, (historyResult) ->
#If description was modified take only the description_html field
for historyResult in history
# If description was modified take only the description_html field
if historyResult.values_diff.description?
historyResult.values_diff.description = historyResult.values_diff.description_diff
@ -117,6 +124,7 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin,
@scope.history = history
@scope.comments = _.filter(history, (historyEntry) -> historyEntry.comment != "")
return history
loadInitialData: ->
params = {
@ -129,16 +137,12 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin,
@scope.usId = data.us
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadUs())
.then(=> @.loadTasks())
.then(=> @.loadAttachments(@scope.usId))
.then(=> @.loadHistory())
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadUs(),
@.loadTasks(),
@.loadAttachments(@scope.usId),
@.loadHistory()]))
block: ->
@rootscope.$broadcast("block", @scope.us)

View File

@ -51,18 +51,22 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @filter, @log, @appTitle,
@navUrls) ->
@.attachmentsUrlName = "wiki/attachments"
@scope.projectSlug = @params.pslug
@scope.wikiSlug = @params.slug
@scope.sectionName = "Wiki"
promise = @.loadInitialData()
# On Success
promise.then () =>
@appTitle.set("Wiki - " + @scope.project.name)
promise.then null, ->
console.log "FAIL" #TODO
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path("/not-found")
@location.replace()
return @q.reject(xhr)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>
@ -71,52 +75,50 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin, taig
@scope.membersById = groupBy(project.memberships, (x) -> x.user)
return project
loadWikiSlug: ->
params = {
pslug: @params.pslug
wikipage: @params.slug
}
promise = @repo.resolve(params).then (data) =>
@scope.wikiId = data.wikipage
@scope.projectId = data.project
return data
promise.then null, =>
ctx = {
project: @params.pslug
slug: @params.slug
}
@location.path(@navUrls.resolve("project-wiki-page-edit", ctx))
loadWiki: ->
if @scope.wikiId
return @rs.wiki.get(@scope.wikiId).then (wiki) =>
@scope.wiki = wiki
else
return @scope.wiki = {
content: ""
}
return wiki
@scope.wiki = {content: ""}
return @scope.wiki
loadWikiLinks: ->
return @rs.wiki.listLinks(@scope.projectId).then (wikiLinks) =>
@scope.wikiLinks = wikiLinks
loadInitialData: ->
params = {
pslug: @params.pslug
wikipage: @params.slug
}
# Resolve project slug
promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
@scope.projectId = data.project
return data
promise.then null, =>
@location.path("/not-found")
@location.replace()
# Resolve wiki slug
# This should be done in two steps because is not same thing
# not found response for project and not found for wiki page
# and they should be hendled separately.
promise = promise.then =>
prom = @repo.resolve({wikipage: @params.slug, pslug: @params.pslug})
prom = prom.then (data) =>
@scope.wikiId = data.wikipage
return prom.then null, (xhr) =>
ctx = {project: @params.pslug, slug: @params.slug}
@location.path(@navUrls.resolve("project-wiki-page-edit", ctx))
return @q.reject()
return promise.then(=> @.loadProject())
.then(=> @.loadUsersAndRoles())
.then(=> @.loadWikiLinks())
.then(=> @.loadWikiSlug())
.then(=> @.loadWiki())
.then(=> @.loadAttachments(@scope.wikiId))
.then(=> @q.all([@.loadUsersAndRoles(),
@.loadWikiLinks(),
@.loadWiki(),
@.loadAttachments(@scope.wikiId)]))
edit: ->
ctx = {