Refactoring services
parent
c34bf099eb
commit
e69a266c92
|
@ -22,4 +22,10 @@ DutyDirective = (navurls, projectsService, $translate) ->
|
|||
|
||||
return directive
|
||||
|
||||
angular.module("taigaHome").directive("tgDuty", ["$tgNavUrls", "tgProjectsService", "$translate", DutyDirective])
|
||||
DutyDirective.$inject = [
|
||||
"$tgNavUrls",
|
||||
"tgProjectsService",
|
||||
"$translate"
|
||||
]
|
||||
|
||||
angular.module("taigaHome").directive("tgDuty", DutyDirective)
|
||||
|
|
|
@ -17,8 +17,9 @@ class HomeService extends taiga.Service
|
|||
project: project.slug
|
||||
ref: duty.ref
|
||||
}
|
||||
Object.defineProperty(duty, "url", {get: () => @navurls.resolve("project-#{duty._name}-detail", ctx)})
|
||||
Object.defineProperty(duty, "projectName", {get: () => project.name})
|
||||
duty.url = @navurls.resolve("project-#{duty._name}-detail", ctx)
|
||||
duty.projectName = project.name
|
||||
return duty
|
||||
|
||||
@._workInProgress = Immutable.fromJS({
|
||||
assignedTo: {
|
||||
|
|
|
@ -132,3 +132,52 @@ describe "tgHome", ->
|
|||
expect(homeService._inProgress).to.be.true
|
||||
timeout.flush()
|
||||
expect(homeService._inProgress).to.be.false
|
||||
|
||||
it "project info filled", () ->
|
||||
duty = {
|
||||
id: 66
|
||||
_name: "userstories"
|
||||
ref: 123
|
||||
project: 1
|
||||
}
|
||||
mocks.thenStubAssignedToUserstories.callArg(0, [duty])
|
||||
mocks.thenStubAssignedToTasks.callArg(0)
|
||||
mocks.thenStubAssignedToIssues.callArg(0)
|
||||
mocks.thenStubWatchingUserstories.callArg(0)
|
||||
mocks.thenStubWatchingTasks.callArg(0)
|
||||
mocks.thenStubWatchingIssues.callArg(0)
|
||||
timeout.flush()
|
||||
|
||||
projectsById = {
|
||||
get: () -> {
|
||||
name: "Testing project"
|
||||
slug: "testing-project"
|
||||
}
|
||||
}
|
||||
|
||||
mocks.tgNavUrls.resolve
|
||||
.withArgs("project-userstories-detail", {project: "testing-project", ref: 123})
|
||||
.returns("/testing-project/us/123")
|
||||
|
||||
homeService.attachProjectInfoToWorkInProgress(projectsById)
|
||||
expect(homeService.workInProgress.toJS()).to.be.eql({
|
||||
assignedTo: {
|
||||
userStories: [
|
||||
{
|
||||
id: 66
|
||||
_name: "userstories"
|
||||
ref: 123
|
||||
project: 1
|
||||
url: "/testing-project/us/123"
|
||||
projectName: "Testing project"
|
||||
}
|
||||
]
|
||||
tasks: []
|
||||
issues: []
|
||||
}
|
||||
watching: {
|
||||
userStories: []
|
||||
tasks: []
|
||||
issues: []
|
||||
}
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ describe "homeProjectListDirective", () ->
|
|||
_mockTgProjectsService = () ->
|
||||
mockTgProjectsService = {
|
||||
newProject: sinon.stub()
|
||||
projects: {
|
||||
currentUserProjects: {
|
||||
get: sinon.stub()
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ describe "homeProjectListDirective", () ->
|
|||
])
|
||||
|
||||
it "home project list directive scope content", () ->
|
||||
mockTgProjectsService.projects.get
|
||||
mockTgProjectsService.currentUserProjects.get
|
||||
.withArgs("recents")
|
||||
.returns(recents)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ HomeProjectListDirective = (projectsService) ->
|
|||
link = (scope, el, attrs, ctrl) ->
|
||||
scope.vm = {}
|
||||
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.projects.get("recents"))
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.currentUserProjects.get("recents"))
|
||||
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
@ -15,4 +15,6 @@ HomeProjectListDirective = (projectsService) ->
|
|||
|
||||
return directive
|
||||
|
||||
angular.module("taigaHome").directive("tgHomeProjectList", ["tgProjectsService", HomeProjectListDirective])
|
||||
HomeProjectListDirective.$inject = ["tgProjectsService"]
|
||||
|
||||
angular.module("taigaHome").directive("tgHomeProjectList", HomeProjectListDirective)
|
||||
|
|
|
@ -2,7 +2,7 @@ DropdownProjectListDirective = (projectsService) ->
|
|||
link = (scope, el, attrs, ctrl) ->
|
||||
scope.vm = {}
|
||||
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.projects.get("recents"))
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.currentUserProjects.get("recents"))
|
||||
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
@ -15,6 +15,8 @@ DropdownProjectListDirective = (projectsService) ->
|
|||
|
||||
return directive
|
||||
|
||||
DropdownProjectListDirective.$inject = [
|
||||
"tgProjectsService"
|
||||
]
|
||||
|
||||
angular.module("taigaNavigationBar").directive("tgDropdownProjectList",
|
||||
["tgProjectsService", DropdownProjectListDirective])
|
||||
angular.module("taigaNavigationBar").directive("tgDropdownProjectList", DropdownProjectListDirective)
|
||||
|
|
|
@ -11,7 +11,7 @@ describe "dropdownProjectListDirective", () ->
|
|||
_mockTgProjectsService = () ->
|
||||
mockTgProjectsService = {
|
||||
newProject: sinon.stub()
|
||||
projects: {
|
||||
currentUserProjects: {
|
||||
get: sinon.stub()
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ describe "dropdownProjectListDirective", () ->
|
|||
])
|
||||
|
||||
it "dropdown project list directive scope content", () ->
|
||||
mockTgProjectsService.projects.get
|
||||
mockTgProjectsService.currentUserProjects.get
|
||||
.withArgs("recents")
|
||||
.returns(recents)
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ DropdownUserDirective = (authService, configService, locationService,
|
|||
|
||||
return directive
|
||||
|
||||
angular.module("taigaNavigationBar").directive("tgDropdownUser",
|
||||
["$tgAuth", "$tgConfig", "$tgLocation", "$tgNavUrls", "tgFeedbackService",
|
||||
DropdownUserDirective])
|
||||
DropdownUserDirective.$inject = [
|
||||
"$tgAuth",
|
||||
"$tgConfig",
|
||||
"$tgLocation",
|
||||
"$tgNavUrls",
|
||||
"tgFeedbackService"
|
||||
]
|
||||
|
||||
angular.module("taigaNavigationBar").directive("tgDropdownUser", DropdownUserDirective)
|
||||
|
|
|
@ -2,7 +2,7 @@ NavigationBarDirective = (projectsService) ->
|
|||
link = (scope, el, attrs, ctrl) ->
|
||||
scope.vm = {}
|
||||
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.projects.get("recents"))
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.currentUserProjects.get("recents"))
|
||||
|
||||
directive = {
|
||||
templateUrl: "navigation-bar/navigation-bar.html"
|
||||
|
@ -12,6 +12,8 @@ NavigationBarDirective = (projectsService) ->
|
|||
|
||||
return directive
|
||||
|
||||
NavigationBarDirective.$inject = [
|
||||
"tgProjectsService"
|
||||
]
|
||||
|
||||
angular.module("taigaNavigationBar").directive("tgNavigationBar",
|
||||
["tgProjectsService", NavigationBarDirective])
|
||||
angular.module("taigaNavigationBar").directive("tgNavigationBar", NavigationBarDirective)
|
||||
|
|
|
@ -11,7 +11,7 @@ describe "navigationBarDirective", () ->
|
|||
_mockTgProjectsService = () ->
|
||||
mockTgProjectsService = {
|
||||
newProject: sinon.stub()
|
||||
projects: {
|
||||
currentUserProjects: {
|
||||
get: sinon.stub()
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ describe "navigationBarDirective", () ->
|
|||
])
|
||||
|
||||
it "navigation bar directive scope content", () ->
|
||||
mockTgProjectsService.projects.get
|
||||
mockTgProjectsService.currentUserProjects.get
|
||||
.withArgs("recents")
|
||||
.returns(recents)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ProfileProjectsDirective = (projectsService) ->
|
||||
link = (scope, el, attrs, ctrl) ->
|
||||
scope.vm = {}
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.projects.get("all"))
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.currentUserProjects.get("all"))
|
||||
|
||||
directive = {
|
||||
templateUrl: "profile/profile-projects/profile-projects.html"
|
||||
|
|
|
@ -26,7 +26,7 @@ ProjectsListingDirective = (projectsService) ->
|
|||
|
||||
projectsService.bulkUpdateProjectsOrder(sortData)
|
||||
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.projects.get("all"))
|
||||
taiga.defineImmutableProperty(scope.vm, "projects", () -> projectsService.currentUserProjects.get("all"))
|
||||
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
|
Loading…
Reference in New Issue