diff --git a/app/coffee/modules/projects/lightboxes.coffee b/app/coffee/modules/projects/lightboxes.coffee index bb595d72..03f8273a 100644 --- a/app/coffee/modules/projects/lightboxes.coffee +++ b/app/coffee/modules/projects/lightboxes.coffee @@ -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]) ############################################################################# diff --git a/app/coffee/modules/projects/main.coffee b/app/coffee/modules/projects/main.coffee index 006c4ca2..69532457 100644 --- a/app/coffee/modules/projects/main.coffee +++ b/app/coffee/modules/projects/main.coffee @@ -66,9 +66,6 @@ class ProjectsController extends taiga.Controller return projects - newProject: -> - @rootscope.$broadcast("projects:create") - logout: -> @auth.logout() @location.path(@navUrls.resolve("login")) diff --git a/app/modules/navigation-bar/dropdown-project-list/dropdown-project-list.directive.coffee b/app/modules/navigation-bar/dropdown-project-list/dropdown-project-list.directive.coffee index f04de7a3..b63656ee 100644 --- a/app/modules/navigation-bar/dropdown-project-list/dropdown-project-list.directive.coffee +++ b/app/modules/navigation-bar/dropdown-project-list/dropdown-project-list.directive.coffee @@ -2,7 +2,9 @@ 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" scope: {} diff --git a/app/modules/projects/listing/listing.directive.coffee b/app/modules/projects/listing/listing.directive.coffee index 6e73c57e..64b3b385 100644 --- a/app/modules/projects/listing/listing.directive.coffee +++ b/app/modules/projects/listing/listing.directive.coffee @@ -25,6 +25,9 @@ ProjectsListingDirective = (projectsService) -> scope.vm.projects = projectsService.projects + scope.vm.newProject = -> + projectsService.newProject() + directive = { templateUrl: "projects/listing/listing.html" scope: {} diff --git a/app/modules/projects/projects.service.coffee b/app/modules/projects/projects.service.coffee index f9b81314..676d1ec6 100644 --- a/app/modules/projects/projects.service.coffee +++ b/app/modules/projects/projects.service.coffee @@ -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() diff --git a/bower.json b/bower.json index 6ea6daad..b34f6910 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/gulpfile.js b/gulpfile.js index ddad3495..dc280afd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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",