make currentUserService loadProjects public and add it after project modification

stable
Juanfran 2015-06-23 10:04:57 +02:00
parent ccec9e79b1
commit 6d365c48e4
4 changed files with 10 additions and 9 deletions

View File

@ -104,7 +104,7 @@ module.controller("ProjectProfileController", ProjectProfileController)
## Project Profile Directive
#############################################################################
ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, projectService) ->
ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, projectService, currentUserService) ->
link = ($scope, $el, $attrs) ->
$ctrl = $el.controller()
@ -128,6 +128,7 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, proje
$ctrl.loadInitialData()
projectService.fetchProject()
currentUserService.loadProjects()
promise.then null, (data) ->
$loading.finish(submitButton)
@ -142,7 +143,7 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, proje
return {link:link}
module.directive("tgProjectProfile", ["$tgRepo", "$tgConfirm", "$tgLoading", "$tgNavUrls", "$tgLocation",
"tgProjectService", ProjectProfileDirective])
"tgProjectService", "tgCurrentUserService", ProjectProfileDirective])
#############################################################################

View File

@ -46,7 +46,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
$location.url($projectUrl.get(response))
lightboxService.close($el)
currentUserService._loadProjects()
currentUserService.loadProjects()
onErrorSubmit = (response) ->
$loading.finish(submitButton)
@ -170,7 +170,7 @@ DeleteProjectDirective = ($repo, $rootscope, $auth, $location, $navUrls, $confir
$rootscope.$broadcast("projects:reload")
$location.path($navUrls.resolve("home"))
$confirm.notify("success")
currentUserService._loadProjects()
currentUserService.loadProjects()
# FIXME: error handling?
promise.then null, ->

View File

@ -43,9 +43,9 @@ class CurrentUserService
bulkUpdateProjectsOrder: (sortData) ->
@projectsService.bulkUpdateProjectsOrder(sortData).then () =>
@._loadProjects()
@.loadProjects()
_loadProjects: () ->
loadProjects: () ->
return @projectsService.getProjectsByUserId(@._user.get("id"))
.then (projects) =>
@._projects = @._projects.set("all", projects)
@ -56,6 +56,6 @@ class CurrentUserService
return @.projects
_loadUserInfo: () ->
return @._loadProjects()
return @.loadProjects()
angular.module("taigaCommon").service("tgCurrentUserService", CurrentUserService)

View File

@ -80,12 +80,12 @@ describe "tgCurrentUserService", ->
it "bulkUpdateProjectsOrder and reload projects", (done) ->
fakeData = [{id: 1, id: 2}]
currentUserService._loadProjects = sinon.spy()
currentUserService.loadProjects = sinon.spy()
mocks.projectsService.bulkUpdateProjectsOrder.withArgs(fakeData).promise().resolve()
currentUserService.bulkUpdateProjectsOrder(fakeData).then () ->
expect(currentUserService._loadProjects).to.be.callOnce
expect(currentUserService.loadProjects).to.be.callOnce
done()