Refactoring create project broadcast
parent
71f8ab18e0
commit
abff53c5c5
|
@ -26,7 +26,7 @@ debounce = @.taiga.debounce
|
|||
|
||||
module = angular.module("taigaProject")
|
||||
|
||||
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, $loading, lightboxService, $cacheFactory, $translate) ->
|
||||
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, $loading, lightboxService, $cacheFactory, $translate, projects) ->
|
||||
link = ($scope, $el, attrs) ->
|
||||
$scope.data = {}
|
||||
$scope.templates = []
|
||||
|
@ -46,6 +46,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
|
|||
|
||||
$location.url($projectUrl.get(response))
|
||||
lightboxService.close($el)
|
||||
projects.fetchProjects()
|
||||
|
||||
onErrorSubmit = (response) ->
|
||||
$loading.finish(submitButton)
|
||||
|
@ -69,7 +70,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
|
|||
promise = $repo.create("projects", $scope.data)
|
||||
promise.then(onSuccessSubmit, onErrorSubmit)
|
||||
|
||||
$scope.$on "projects:create", ->
|
||||
createProjectCallback = ->
|
||||
$scope.data = {
|
||||
total_story_points: 100
|
||||
total_milestones: 5
|
||||
|
@ -89,6 +90,8 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
|
|||
timeout 600, ->
|
||||
$el.find(".progress-bar").addClass('step1')
|
||||
|
||||
projects.emiter.on 'create', createProjectCallback
|
||||
|
||||
$el.on "click", ".button-next", (event) ->
|
||||
event.preventDefault()
|
||||
|
||||
|
@ -125,6 +128,9 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
|
|||
event.preventDefault()
|
||||
lightboxService.close($el)
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
emitter.off(projects.emiter, createProjectCallback)
|
||||
$el.off()
|
||||
|
||||
directive = {
|
||||
link: link,
|
||||
|
@ -135,8 +141,9 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
|
|||
return directive
|
||||
|
||||
|
||||
module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$location", "$tgNavUrls",
|
||||
"$tgResources", "$projectUrl", "$tgLoading", "lightboxService", "$cacheFactory", "$translate", CreateProject])
|
||||
module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm",
|
||||
"$location", "$tgNavUrls", "$tgResources", "$projectUrl", "$tgLoading",
|
||||
"lightboxService", "$cacheFactory", "$translate", "tgProjects", CreateProject])
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
|
@ -66,9 +66,6 @@ class ProjectsController extends taiga.Controller
|
|||
|
||||
return projects
|
||||
|
||||
newProject: ->
|
||||
@rootscope.$broadcast("projects:create")
|
||||
|
||||
logout: ->
|
||||
@auth.logout()
|
||||
@location.path(@navUrls.resolve("login"))
|
||||
|
|
|
@ -2,6 +2,8 @@ DropdownProjectListDirective = (projectsService) ->
|
|||
link = (scope, el, attrs, ctrl) ->
|
||||
scope.vm = {}
|
||||
scope.vm.projects = projectsService.projects
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
||||
directive = {
|
||||
templateUrl: "navigation-bar/dropdown-project-list/dropdown-project-list.html"
|
||||
|
|
|
@ -25,6 +25,9 @@ ProjectsListingDirective = (projectsService) ->
|
|||
|
||||
scope.vm.projects = projectsService.projects
|
||||
|
||||
scope.vm.newProject = ->
|
||||
projectsService.newProject()
|
||||
|
||||
directive = {
|
||||
templateUrl: "projects/listing/listing.html"
|
||||
scope: {}
|
||||
|
|
|
@ -6,9 +6,9 @@ class ProjectsService extends taiga.Service
|
|||
@.inProgress = false
|
||||
@.projectsPromise = null
|
||||
@.fetchProjects()
|
||||
@.emiter = new EventEmitter2()
|
||||
|
||||
fetchProjects: ->
|
||||
console.log "fetchProjects", @.inProgress
|
||||
if not @.inProgress
|
||||
@.inProgress = true
|
||||
@.projectsPromise = @rs.projects.listByMember(@rootScope.user?.id).then (projects) =>
|
||||
|
@ -25,6 +25,9 @@ class ProjectsService extends taiga.Service
|
|||
|
||||
return @.projectsPromise
|
||||
|
||||
newProject: ->
|
||||
@.emiter.emit("create")
|
||||
|
||||
bulkUpdateProjectsOrder: (sortData) ->
|
||||
@rs.projects.bulkUpdateOrder(sortData).then =>
|
||||
@.fetchProjects()
|
||||
|
|
|
@ -77,7 +77,8 @@
|
|||
"angular-translate": "~2.6.1",
|
||||
"angular-translate-loader-static-files": "~2.6.1",
|
||||
"angular-translate-interpolation-messageformat": "~2.6.1",
|
||||
"ngInfiniteScroll": "1.0.0"
|
||||
"ngInfiniteScroll": "1.0.0",
|
||||
"eventemitter2": "~0.4.14"
|
||||
},
|
||||
"resolutions": {
|
||||
"lodash": "~2.4.1",
|
||||
|
|
|
@ -143,6 +143,7 @@ paths.libs = [
|
|||
paths.vendor + "l.js/l.js",
|
||||
paths.vendor + "messageformat/locale/*.js",
|
||||
paths.vendor + "ngInfiniteScroll/build/ng-infinite-scroll.js",
|
||||
paths.vendor + "eventemitter2/lib/eventemitter2.js",
|
||||
paths.app + "js/jquery.ui.git-custom.js",
|
||||
paths.app + "js/jquery-ui.drag-multiple-custom.js",
|
||||
paths.app + "js/jquery.ui.touch-punch.min.js",
|
||||
|
|
Loading…
Reference in New Issue