From de8500d515cfc4eadf07603400a52efb5cb4e3c1 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Mon, 3 Aug 2015 10:19:31 +0200 Subject: [PATCH] Removing descriptions from list API --- app/coffee/modules/admin/lightboxes.coffee | 8 +- .../modules/admin/project-profile.coffee | 26 +++--- app/coffee/modules/admin/third-parties.coffee | 24 +++--- app/coffee/modules/backlog/lightboxes.coffee | 8 +- app/coffee/modules/backlog/main.coffee | 20 ++++- app/coffee/modules/backlog/sprints.coffee | 8 +- app/coffee/modules/common/components.coffee | 28 ++++--- app/coffee/modules/common/confirm.coffee | 13 ++- app/coffee/modules/common/history.coffee | 11 ++- app/coffee/modules/common/lightboxes.coffee | 22 ++++-- app/coffee/modules/common/loading.coffee | 79 +++++++++++++++---- app/coffee/modules/feedback.coffee | 8 +- app/coffee/modules/issues/detail.coffee | 38 +++++---- app/coffee/modules/issues/lightboxes.coffee | 17 ++-- app/coffee/modules/issues/list.coffee | 10 ++- app/coffee/modules/kanban/main.coffee | 18 ++++- app/coffee/modules/projects/lightboxes.coffee | 9 ++- app/coffee/modules/related-tasks.coffee | 17 ++-- .../modules/taskboard/lightboxes.coffee | 14 ++-- app/coffee/modules/taskboard/main.coffee | 17 +++- app/coffee/modules/tasks/detail.coffee | 24 +++--- .../user-settings/change-password.coffee | 8 +- app/coffee/modules/userstories/detail.coffee | 50 ++++++------ app/coffee/modules/wiki/main.coffee | 9 ++- app/coffee/modules/wiki/nav.coffee | 10 ++- app/partials/common/history/history-base.jade | 2 +- .../includes/components/backlog-row.jade | 2 +- app/styles/components/kanban-task.scss | 5 ++ app/styles/components/taskboard-task.scss | 7 +- 29 files changed, 343 insertions(+), 169 deletions(-) diff --git a/app/coffee/modules/admin/lightboxes.coffee b/app/coffee/modules/admin/lightboxes.coffee index 8ba5fb77..5167fa8c 100644 --- a/app/coffee/modules/admin/lightboxes.coffee +++ b/app/coffee/modules/admin/lightboxes.coffee @@ -109,16 +109,18 @@ CreateMembersDirective = ($rs, $rootScope, $confirm, $loading, lightboxService, submit = debounce 2000, (event) => event.preventDefault() - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() onSuccess = (data) -> - $loading.finish(submitButton) + currentLoading.finish() lightboxService.close($el) $confirm.notify("success") $rootScope.$broadcast("membersform:new:success") onError = (data) -> - $loading.finish(submitButton) + currentLoading.finish() lightboxService.close($el) $confirm.notify("error") $rootScope.$broadcast("membersform:new:error") diff --git a/app/coffee/modules/admin/project-profile.coffee b/app/coffee/modules/admin/project-profile.coffee index 97e9d1ac..4705fb45 100644 --- a/app/coffee/modules/admin/project-profile.coffee +++ b/app/coffee/modules/admin/project-profile.coffee @@ -114,11 +114,13 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, proje return if not form.validate() - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.save($scope.project) promise.then -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("success") newUrl = $navurls.resolve("project-admin-project-profile-details", { project: $scope.project.slug @@ -131,7 +133,7 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, proje currentUserService.loadProjects() promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) @@ -158,15 +160,17 @@ ProjectDefaultValuesDirective = ($repo, $confirm, $loading) -> return if not form.validate() - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.save($scope.project) promise.then -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("success") promise.then null, (data) -> - $loading.finish(target) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) @@ -193,19 +197,21 @@ ProjectModulesDirective = ($repo, $confirm, $loading, projectService) -> form = $el.find("form").checksley() return if not form.validate() - target = angular.element(".admin-functionalities a.button-green") - $loading.start(target) + target = angular.element(".admin-functionalities .submit-button") + currentLoading = $loading() + .target(target) + .start() promise = $repo.save($scope.project) promise.then -> - $loading.finish(target) + currentLoading.finish() $confirm.notify("success") $scope.$emit("project:loaded", $scope.project) projectService.fetchProject() promise.then null, (data) -> - $loading.finish(target) + currentLoading.finish() $confirm.notify("error", data._error_message) $el.on "submit", "form", (event) -> diff --git a/app/coffee/modules/admin/third-parties.coffee b/app/coffee/modules/admin/third-parties.coffee index 737a8144..7d36fc4c 100644 --- a/app/coffee/modules/admin/third-parties.coffee +++ b/app/coffee/modules/admin/third-parties.coffee @@ -454,15 +454,17 @@ GithubWebhooksDirective = ($repo, $confirm, $loading) -> return if not form.validate() - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.saveAttribute($scope.github, "github") promise.then -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("success") promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) @@ -488,16 +490,18 @@ GitlabWebhooksDirective = ($repo, $confirm, $loading) -> return if not form.validate() - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.saveAttribute($scope.gitlab, "gitlab") promise.then -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("success") $scope.$emit("project:modules:reload") promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) @@ -523,16 +527,18 @@ BitbucketWebhooksDirective = ($repo, $confirm, $loading) -> return if not form.validate() - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.saveAttribute($scope.bitbucket, "bitbucket") promise.then -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("success") $scope.$emit("project:modules:reload") promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) diff --git a/app/coffee/modules/backlog/lightboxes.coffee b/app/coffee/modules/backlog/lightboxes.coffee index cf952c4e..2915e19d 100644 --- a/app/coffee/modules/backlog/lightboxes.coffee +++ b/app/coffee/modules/backlog/lightboxes.coffee @@ -71,17 +71,19 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading, promise = $repo.save(newSprint) broadcastEvent = "sprintform:edit:success" - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise.then (data) -> - $loading.finish(submitButton) + currentLoading.finish() $scope.sprintsCounter += 1 if createSprint $rootscope.$broadcast(broadcastEvent, data) lightboxService.close($el) promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 56c139f2..8cd5d696 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -50,11 +50,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F "$tgNavUrls", "$tgEvents", "$tgAnalytics", - "$translate" + "$translate", + "$tgLoading" ] constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, - @location, @appMetaService, @navUrls, @events, @analytics, @translate) -> + @location, @appMetaService, @navUrls, @events, @analytics, @translate, @loading) -> bindMethods(@) @scope.sectionName = @translate.instant("BACKLOG.SECTION_NAME") @@ -488,8 +489,19 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F @rootscope.$broadcast("filters:update") @.loadProjectStats() - editUserStory: (us) -> - @rootscope.$broadcast("usform:edit", us) + editUserStory: (projectId, ref, $event) -> + target = $($event.target) + + currentLoading = @loading() + .target(target) + .removeClasses("icon-edit") + .timeout(200) + .start() + + @rs.userstories.getByRef(projectId, ref).then (us) => + @rootscope.$broadcast("usform:edit", us) + + currentLoading.finish() deleteUserStory: (us) -> title = @translate.instant("US.TITLE_DELETE_ACTION") diff --git a/app/coffee/modules/backlog/sprints.coffee b/app/coffee/modules/backlog/sprints.coffee index 09127a7d..4db13c68 100644 --- a/app/coffee/modules/backlog/sprints.coffee +++ b/app/coffee/modules/backlog/sprints.coffee @@ -153,12 +153,16 @@ ToggleExcludeClosedSprintsVisualization = ($rootscope, $loading, $translate) -> loadingElm = $("
") $el.after(loadingElm) + currentLoading = null + # Event Handlers $el.on "click", (event) -> event.preventDefault() excludeClosedSprints = not excludeClosedSprints - $loading.start(loadingElm) + currentLoading = $loading() + .target(loadingElm) + .start() if excludeClosedSprints $rootscope.$broadcast("backlog:unload-closed-sprints") @@ -169,7 +173,7 @@ ToggleExcludeClosedSprintsVisualization = ($rootscope, $loading, $translate) -> $el.off() $scope.$on "closed-sprints:reloaded", (ctx, sprints) => - $loading.finish(loadingElm) + currentLoading.finish() if sprints.length > 0 key = "BACKLOG.SPRINTS.ACTION_HIDE_CLOSED_SPRINTS" diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index a57a5972..bf9e1517 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -316,18 +316,20 @@ AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template save = $qqueue.bindAdd (userId) => $model.$modelValue.assigned_to = userId - $loading.start($el) + currentLoading = $loading() + .target($el) + .start() promise = $repo.save($model.$modelValue) promise.then -> - $loading.finish($el) + currentLoading.finish() $confirm.notify("success") renderAssignedTo($model.$modelValue) $rootscope.$broadcast("object:updated") promise.then null, -> $model.$modelValue.revert() $confirm.notify("error") - $loading.finish($el) + currentLoading.finish() return promise @@ -408,9 +410,12 @@ BlockButtonDirective = ($rootscope, $loading, $template) -> $el.on "click", ".item-unblock", (event) -> event.preventDefault() - $loading.start($el.find(".item-unblock")) + currentLoading = $loading() + .target($el.find(".item-unblock")) + .start() + finish = -> - $loading.finish($el.find(".item-unblock")) + currentLoading.finish() $rootscope.$broadcast("unblock", $model.$modelValue, finish) @@ -486,7 +491,9 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $tem save = $qqueue.bindAdd (subject) => $model.$modelValue.subject = subject - $loading.start($el.find('.save-container')) + currentLoading = $loading() + .target($el.find('.save-container')) + .start() promise = $repo.save($model.$modelValue) promise.then -> @@ -497,7 +504,7 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $tem promise.then null, -> $confirm.notify("error") promise.finally -> - $loading.finish($el.find('.save-container')) + currentLoading.finish() return promise @@ -571,7 +578,10 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, save = $qqueue.bindAdd (description) => $model.$modelValue.description = description - $loading.start($el.find('.save-container')) + currentLoading = $loading() + .target($el.find('.save-container')) + .start() + promise = $repo.save($model.$modelValue) promise.then -> $confirm.notify("success") @@ -581,7 +591,7 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, promise.then null, -> $confirm.notify("error") promise.finally -> - $loading.finish($el.find('.save-container')) + currentLoading.finish() $el.on "mouseup", ".view-description", (event) -> # We want to dettect the a inside the div so we use the target and diff --git a/app/coffee/modules/common/confirm.coffee b/app/coffee/modules/common/confirm.coffee index fd877c4b..28851121 100644 --- a/app/coffee/modules/common/confirm.coffee +++ b/app/coffee/modules/common/confirm.coffee @@ -64,9 +64,12 @@ class ConfirmService extends taiga.Service el.on "click.confirm-dialog", "a.button-green", debounce 2000, (event) => event.preventDefault() target = angular.element(event.currentTarget) - @loading.start(target) + currentLoading = @loading() + .target(target) + .start() + defered.resolve (ok=true) => - @loading.finish(target) + currentLoading.finish() if ok @.hide(el) @@ -110,11 +113,13 @@ class ConfirmService extends taiga.Service el.on "click.confirm-dialog", "a.button-green", debounce 2000, (event) => event.preventDefault() target = angular.element(event.currentTarget) - @loading.start(target) + currentLoading = @loading() + .target(target) + .start() defered.resolve { selected: choicesField.val() finish: => - @loading.finish(target) + currentLoading.finish() @.hide(el) } diff --git a/app/coffee/modules/common/history.coffee b/app/coffee/modules/common/history.coffee index d056cc6c..ec2a438c 100644 --- a/app/coffee/modules/common/history.coffee +++ b/app/coffee/modules/common/history.coffee @@ -347,18 +347,21 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c $el.find(".comment-list").addClass("activeanimation") + currentLoading = $loading() + .target(target) + .start() + onSuccess = -> $rootScope.$broadcast("comment:new") $ctrl.loadHistory(type, objectId).finally -> - $loading.finish(target) + currentLoading.finish() onError = -> - $loading.finish(target) + currentLoading.finish() $confirm.notify("error") model = $scope.$eval($attrs.ngModel) - $loading.start(target) $ctrl.repo.save(model).then(onSuccess, onError) @@ -371,7 +374,7 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c # Events - $el.on "click", ".add-comment input.button-green", debounce 2000, (event) -> + $el.on "click", ".add-comment button.button-green", debounce 2000, (event) -> event.preventDefault() target = angular.element(event.currentTarget) diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index 5756f2be..c92c176b 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -179,7 +179,9 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi block = $qqueue.bindAdd (item) => $model.$setViewValue(item) - $loading.start($el.find(".button-green")) + currentLoading = $loading() + .target($el.find(".button-green")) + .start() promise = $tgrepo.save($model.$modelValue) promise.then -> @@ -192,7 +194,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi $model.$setViewValue(item) promise.finally -> - $loading.finish($el.find(".button-green")) + currentLoading.finish() lightboxService.close($el) $scope.$on "block", -> @@ -324,7 +326,9 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService, if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() if $scope.isNew promise = $repo.create("userstories", $scope.us) @@ -334,12 +338,12 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService, broadcastEvent = "usform:edit:success" promise.then (data) -> - $loading.finish(submitButton) + currentLoading.finish() lightboxService.close($el) $rootScope.$broadcast(broadcastEvent, data) promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) @@ -399,16 +403,18 @@ CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope, lightboxService, $load if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $rs.userstories.bulkCreate($scope.new.projectId, $scope.new.statusId, $scope.new.bulk) promise.then (result) -> - $loading.finish(submitButton) + currentLoading.finish() $rootscope.$broadcast("usform:bulk:success", result) lightboxService.close($el) promise.then null, (data) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(data) if data._error_message $confirm.notify("error", data._error_message) diff --git a/app/coffee/modules/common/loading.coffee b/app/coffee/modules/common/loading.coffee index bb92f178..e2c0de6e 100644 --- a/app/coffee/modules/common/loading.coffee +++ b/app/coffee/modules/common/loading.coffee @@ -21,29 +21,78 @@ module = angular.module("taigaCommon") -class TgLoadingService extends taiga.Service - start: (target) -> - if not target.hasClass('loading') - target.data('loading-old-content', target.html()) - target.addClass('loading') - target.html("loading...") +TgLoadingService = -> + spinner = "loading..." - finish: (target) -> - if target.hasClass('loading') - oldContent = target.data('loading-old-content') - target.data('loading-old-content', null) - target.html(oldContent) - target.removeClass('loading') + return () -> + service = { + settings: { + target: null, + classes: [] + timeout: 0 + }, + target: (target) -> + service.settings.target = target -module.service("$tgLoading", TgLoadingService) + return service + removeClasses: (classess...) -> + service.settings.classes = classess + + return service + timeout: (timeout) -> + service.settings.timeout = timeout + + return service + + start: -> + target = service.settings.target + service.settings.classes.map (className) -> target.removeClass(className) + + # The loader is shown after that quantity of milliseconds + timeoutId = setTimeout (-> + if not target.hasClass('loading') + service.settings.oldContent = target.html() + + target.addClass('loading') + target.html(spinner) + ), service.settings.timeout + + service.settings.timeoutId = timeoutId + + return service + + finish: -> + target = service.settings.target + timeoutId = service.settings.timeoutId + + if timeoutId + clearTimeout(timeoutId) + + removeClasses = service.settings.classes + removeClasses.map (className) -> service.settings.target.addClass(className) + + target.html(service.settings.oldContent) + target.removeClass('loading') + + return service + } + + return service + +module.factory("$tgLoading", TgLoadingService) LoadingDirective = ($loading) -> link = ($scope, $el, attr) -> + currentLoading = null + $scope.$watch attr.tgLoading, (showLoading) => + if showLoading - $loading.start($el) + currentLoading = $loading() + .target($el) + .start() else - $loading.finish($el) + currentLoading.finish() return { link:link diff --git a/app/coffee/modules/feedback.coffee b/app/coffee/modules/feedback.coffee index 247db488..d121c889 100644 --- a/app/coffee/modules/feedback.coffee +++ b/app/coffee/modules/feedback.coffee @@ -39,17 +39,19 @@ FeedbackDirective = ($lightboxService, $repo, $confirm, $loading, feedbackServic if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.create("feedback", $scope.feedback) promise.then (data) -> - $loading.finish(submitButton) + currentLoading.finish() $lightboxService.close($el) $confirm.notify("success", "\\o/ we'll be happy to read your") promise.then null, -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("error") submitButton = $el.find(".submit-button") diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index 6dda40b4..1cadbb05 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -239,18 +239,21 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $t issue = $model.$modelValue.clone() issue.status = statusId + currentLoading = $loading() + .target($el.find(".level-name")) + .start() + onSuccess = -> $confirm.notify("success") $model.$setViewValue(issue) $rootScope.$broadcast("object:updated") - $loading.finish($el.find(".level-name")) + currentLoading.finish() onError = -> $confirm.notify("error") issue.revert() $model.$setViewValue(issue) - $loading.finish($el.find(".level-name")) + currentLoading.finish() - $loading.start($el.find(".level-name")) $repo.save(issue).then(onSuccess, onError) @@ -323,18 +326,21 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $tem issue = $model.$modelValue.clone() issue.type = type + currentLoading = $loading() + .target($el.find(".level-name")) + .start() + onSuccess = -> $confirm.notify("success") $model.$setViewValue(issue) $rootScope.$broadcast("object:updated") - $loading.finish($el.find(".level-name")) + currentLoading.finish() onError = -> $confirm.notify("error") issue.revert() $model.$setViewValue(issue) - $loading.finish($el.find(".level-name")) - $loading.start($el.find(".level-name")) + currentLoading.finish() $repo.save(issue).then(onSuccess, onError) @@ -409,18 +415,20 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, issue = $model.$modelValue.clone() issue.severity = severity + currentLoading = $loading() + .target($el.find(".level-name")) + .start() + onSuccess = -> $confirm.notify("success") $model.$setViewValue(issue) $rootScope.$broadcast("object:updated") - $loading.finish($el.find(".level-name")) + currentLoading.finish() onError = -> $confirm.notify("error") issue.revert() $model.$setViewValue(issue) - $loading.finish($el.find(".level-name")) - - $loading.start($el.find(".level-name")) + currentLoading.finish() $repo.save(issue).then(onSuccess, onError) @@ -496,18 +504,20 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, issue = $model.$modelValue.clone() issue.priority = priority + currentLoading = $loading() + .target($el.find(".level-name")) + .start() + onSuccess = -> $confirm.notify("success") $model.$setViewValue(issue) $rootScope.$broadcast("object:updated") - $loading.finish($el.find(".level-name")) + currentLoading.finish() onError = -> $confirm.notify("error") issue.revert() $model.$setViewValue(issue) - $loading.finish($el.find(".level-name")) - - $loading.start($el.find(".level-name")) + currentLoading.finish() $repo.save(issue).then(onSuccess, onError) diff --git a/app/coffee/modules/issues/lightboxes.coffee b/app/coffee/modules/issues/lightboxes.coffee index f05f2caf..29052e8f 100644 --- a/app/coffee/modules/issues/lightboxes.coffee +++ b/app/coffee/modules/issues/lightboxes.coffee @@ -58,17 +58,20 @@ CreateIssueDirective = ($repo, $confirm, $rootscope, lightboxService, $loading) if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() + promise = $repo.create("issues", $scope.issue) promise.then (data) -> - $loading.finish(submitButton) + currentLoading.finish() $rootscope.$broadcast("issueform:new:success", data) lightboxService.close($el) $confirm.notify("success") promise.then null, -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("error") @@ -103,20 +106,22 @@ CreateBulkIssuesDirective = ($repo, $rs, $confirm, $rootscope, $loading, lightbo if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() data = $scope.new.bulk projectId = $scope.new.projectId promise = $rs.issues.bulkCreate(projectId, data) promise.then (result) -> - $loading.finish(submitButton) + currentLoading.finish() $rootscope.$broadcast("issueform:new:success", result) lightboxService.close($el) $confirm.notify("success") promise.then null, -> - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify("error") submitButton = $el.find(".submit-button") diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee index 0435e870..65642aa4 100644 --- a/app/coffee/modules/issues/list.coffee +++ b/app/coffee/modules/issues/list.coffee @@ -649,12 +649,14 @@ IssuesFiltersDirective = ($q, $log, $location, $rs, $confirm, $loading, $templat if event.keyCode == 13 target = angular.element(event.currentTarget) newFilter = target.val() - $loading.start($el.find(".new")) + currentLoading = $loading() + .target($el.find(".new")) + .start() promise = $ctrl.saveCurrentFiltersTo(newFilter) promise.then -> loadPromise = $ctrl.loadMyFilters() loadPromise.then (filters) -> - $loading.finish($el.find(".new")) + currentLoading.finish() $scope.filters.myFilters = filters currentfilterstype = $el.find("h2 a.subfilter span.title").prop('data-type') @@ -665,11 +667,11 @@ IssuesFiltersDirective = ($q, $log, $location, $rs, $confirm, $loading, $templat $el.find('.save-filters').show() loadPromise.then null, -> - $loading.finish($el.find(".new")) + currentLoading.finish() $confirm.notify("error", "Error loading custom filters") promise.then null, -> - $loading.finish($el.find(".new")) + currentLoading.finish() $el.find(".my-filter-name").val(newFilter).focus().select() $confirm.notify("error", "Filter not saved") diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index 66935eb8..988f693a 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -404,7 +404,7 @@ module.directive("tgKanbanArchivedStatusIntro", ["$translate", KanbanArchivedSta ## Kanban User Story Directive ############################################################################# -KanbanUserstoryDirective = ($rootscope) -> +KanbanUserstoryDirective = ($rootscope, $loading, $rs) -> link = ($scope, $el, $attrs, $model) -> $el.disableSelection() @@ -418,8 +418,18 @@ KanbanUserstoryDirective = ($rootscope) -> if $el.find(".icon-edit").hasClass("noclick") return - $scope.$apply -> - $rootscope.$broadcast("usform:edit", $model.$modelValue) + target = $(event.target) + + currentLoading = $loading() + .target(target) + .timeout(200) + .removeClasses("icon-edit") + .start() + + us = $model.$modelValue + $rs.userstories.getByRef(us.project, us.ref).then (editingUserStory) => + $rootscope.$broadcast("usform:edit", editingUserStory) + currentLoading.finish() $scope.$on "$destroy", -> $el.off() @@ -430,7 +440,7 @@ KanbanUserstoryDirective = ($rootscope) -> require: "ngModel" } -module.directive("tgKanbanUserstory", ["$rootScope", KanbanUserstoryDirective]) +module.directive("tgKanbanUserstory", ["$rootScope", "$tgLoading", "$tgResources", KanbanUserstoryDirective]) ############################################################################# ## Kanban Squish Column Directive diff --git a/app/coffee/modules/projects/lightboxes.coffee b/app/coffee/modules/projects/lightboxes.coffee index b027f58c..d5a482ea 100644 --- a/app/coffee/modules/projects/lightboxes.coffee +++ b/app/coffee/modules/projects/lightboxes.coffee @@ -30,6 +30,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project link = ($scope, $el, attrs) -> $scope.data = {} $scope.templates = [] + currentLoading = null form = $el.find("form").checksley({"onlyOneErrorElement": true}) @@ -39,7 +40,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project # than another deleted in the same session $cacheFactory.get('$http').removeAll() - $loading.finish(submitButton) + currentLoading.finish() $rootscope.$broadcast("projects:reload") $confirm.notify("success", $translate.instant("COMMON.SAVE")) @@ -49,7 +50,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project currentUserService.loadProjects() onErrorSubmit = (response) -> - $loading.finish(submitButton) + currentLoading.finish() form.setErrors(response) selectors = [] for error_field in _.keys(response) @@ -65,7 +66,9 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $repo.create("projects", $scope.data) promise.then(onSuccessSubmit, onErrorSubmit) diff --git a/app/coffee/modules/related-tasks.coffee b/app/coffee/modules/related-tasks.coffee index 4817d976..81eda43b 100644 --- a/app/coffee/modules/related-tasks.coffee +++ b/app/coffee/modules/related-tasks.coffee @@ -33,16 +33,18 @@ RelatedTaskRowDirective = ($repo, $compile, $confirm, $rootscope, $loading, $tem saveTask = debounce 2000, (task) -> task.subject = $el.find('input').val() - $loading.start($el.find('.task-name')) + currentLoading = $loading() + .target($el.find('.task-name')) + .start() promise = $repo.save(task) promise.then => - $loading.finish($el.find('.task-name')) + currentLoading.finish() $confirm.notify("success") $rootscope.$broadcast("related-tasks:update") promise.then null, => - $loading.finish($el.find('.task-name')) + currentLoading.finish() $el.find('input').val(task.subject) $confirm.notify("error") return promise @@ -126,17 +128,20 @@ RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading, $scope.newTask.status = $scope.project.default_task_status $scope.newTask.assigned_to = null - $loading.start($el.find('.task-name')) + currentLoading = $loading() + .target($el.find('.task-name')) + .start() + promise = $repo.create("tasks", task) promise.then -> $analytics.trackEvent("task", "create", "create task on userstory", 1) - $loading.finish($el.find('.task-name')) + currentLoading.finish() $scope.$emit("related-tasks:add") $confirm.notify("success") promise.then null, -> $el.find('input').val(task.subject) - $loading.finish($el.find('.task-name')) + currentLoading.finish() $confirm.notify("error") return promise diff --git a/app/coffee/modules/taskboard/lightboxes.coffee b/app/coffee/modules/taskboard/lightboxes.coffee index c57e67eb..dbb97bd1 100644 --- a/app/coffee/modules/taskboard/lightboxes.coffee +++ b/app/coffee/modules/taskboard/lightboxes.coffee @@ -80,11 +80,13 @@ CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxSer promise = $repo.save($scope.task) broadcastEvent = "taskform:edit:success" - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() # FIXME: error handling? promise.then (data) -> - $loading.finish(submitButton) + currentLoading.finish() lightboxService.close($el) $rootscope.$broadcast(broadcastEvent, data) @@ -107,7 +109,9 @@ CreateBulkTasksDirective = ($repo, $rs, $rootscope, $loading, lightboxService) - if not form.validate() return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() data = $scope.form.data projectId = $scope.projectId @@ -116,13 +120,13 @@ CreateBulkTasksDirective = ($repo, $rs, $rootscope, $loading, lightboxService) - promise = $rs.tasks.bulkCreate(projectId, sprintId, usId, data) promise.then (result) -> - $loading.finish(submitButton) + currentLoading.finish() $rootscope.$broadcast("taskform:bulk:success", result) lightboxService.close($el) # TODO: error handling promise.then null, -> - $loading.finish(submitButton) + currentLoading.finish() console.log "FAIL" $scope.$on "taskform:bulk", (ctx, sprintId, usId)-> diff --git a/app/coffee/modules/taskboard/main.coffee b/app/coffee/modules/taskboard/main.coffee index b8a17671..a6ecad42 100644 --- a/app/coffee/modules/taskboard/main.coffee +++ b/app/coffee/modules/taskboard/main.coffee @@ -295,7 +295,7 @@ module.directive("tgTaskboard", ["$rootScope", TaskboardDirective]) ## Taskboard Task Directive ############################################################################# -TaskboardTaskDirective = ($rootscope) -> +TaskboardTaskDirective = ($rootscope, $loading, $rs) -> link = ($scope, $el, $attrs, $model) -> $el.disableSelection() @@ -309,12 +309,23 @@ TaskboardTaskDirective = ($rootscope) -> if $el.find('.icon-edit').hasClass('noclick') return $scope.$apply -> - $rootscope.$broadcast("taskform:edit", $scope.task) + target = $(event.target) + + currentLoading = $loading() + .target(target) + .timeout(200) + .removeClasses("icon-edit") + .start() + + task = $scope.task + $rs.tasks.getByRef(task.project, task.ref).then (editingTask) => + $rootscope.$broadcast("taskform:edit", editingTask) + currentLoading.finish() return {link:link} -module.directive("tgTaskboardTask", ["$rootScope", TaskboardTaskDirective]) +module.directive("tgTaskboardTask", ["$rootScope", "$tgLoading", "$tgResources", TaskboardTaskDirective]) ############################################################################# ## Taskboard Squish Column Directive diff --git a/app/coffee/modules/tasks/detail.coffee b/app/coffee/modules/tasks/detail.coffee index d9864bbf..a6f67ee1 100644 --- a/app/coffee/modules/tasks/detail.coffee +++ b/app/coffee/modules/tasks/detail.coffee @@ -246,21 +246,21 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co task = $model.$modelValue.clone() task.status = status - $model.$setViewValue(task) + currentLoading = $loading() + .target($el.find(".level-name")) + .start() onSuccess = -> + $model.$setViewValue(task) $confirm.notify("success") $rootScope.$broadcast("object:updated") - $loading.finish($el.find(".level-name")) + currentLoading.finish() onError = -> $confirm.notify("error") - task.revert() - $model.$setViewValue(task) - $loading.finish($el.find(".level-name")) + currentLoading.finish() - $loading.start($el.find(".level-name")) - $repo.save($model.$modelValue).then(onSuccess, onError) + $repo.save(task).then(onSuccess, onError) $el.on "click", ".status-data", (event) -> event.preventDefault() @@ -328,22 +328,22 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue task = $model.$modelValue.clone() task.is_iocaine = is_iocaine - $model.$setViewValue(task) - $loading.start($el.find('label')) + currentLoading = $loading() + .target($el.find('label')) + .start() promise = $tgrepo.save(task) promise.then -> + $model.$setViewValue(task) $confirm.notify("success") $rootscope.$broadcast("object:updated") promise.then null, -> - task.revert() - $model.$setViewValue(task) $confirm.notify("error") promise.finally -> - $loading.finish($el.find('label')) + currentLoading.finish() $el.on "click", ".is-iocaine", (event) -> return if not isEditable() diff --git a/app/coffee/modules/user-settings/change-password.coffee b/app/coffee/modules/user-settings/change-password.coffee index ba1d19d0..c978bdec 100644 --- a/app/coffee/modules/user-settings/change-password.coffee +++ b/app/coffee/modules/user-settings/change-password.coffee @@ -67,15 +67,17 @@ UserChangePasswordDirective = ($rs, $confirm, $loading, $translate) -> $confirm.notify('error', $translate.instant("CHANGE_PASSWORD.ERROR_PASSWORD_MATCH")) return - $loading.start(submitButton) + currentLoading = $loading() + .target(submitButton) + .start() promise = $rs.userSettings.changePassword($scope.currentPassword, $scope.newPassword1) promise.then => - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify('success') promise.then null, (response) => - $loading.finish(submitButton) + currentLoading.finish() $confirm.notify('error', response.data._error_message) submitButton = $el.find(".submit-button") diff --git a/app/coffee/modules/userstories/detail.coffee b/app/coffee/modules/userstories/detail.coffee index 814dab5b..d819a947 100644 --- a/app/coffee/modules/userstories/detail.coffee +++ b/app/coffee/modules/userstories/detail.coffee @@ -304,8 +304,8 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp statuses: $scope.statusList editable: isEditable() }) - $el.html(html) + $el.html(html) save = $qqueue.bindAdd (status) => us = $model.$modelValue.clone() @@ -314,22 +314,21 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp $.fn.popover().closeAll() - $model.$setViewValue(us) + currentLoading = $loading() + .target($el.find(".level-name")) + .start() onSuccess = -> $confirm.notify("success") + $model.$setViewValue(us) $rootScope.$broadcast("object:updated") - $loading.finish($el.find(".level-name")) + currentLoading.finish() onError = -> $confirm.notify("error") - us.revert() - $model.$setViewValue(us) - $loading.finish($el.find(".level-name")) + currentLoading.finish() - $loading.start($el.find(".level-name")) - - $repo.save($model.$modelValue).then(onSuccess, onError) + $repo.save(us).then(onSuccess, onError) $el.on "click", ".status-data", (event) -> event.preventDefault() @@ -393,20 +392,19 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qq us = $model.$modelValue.clone() us.team_requirement = team_requirement - $model.$setViewValue(us) + currentLoading = $loading() + .target($el.find("label")) + .start() - $loading.start($el.find("label")) - - promise = $tgrepo.save($model.$modelValue) + promise = $tgrepo.save(us) promise.then => - $loading.finish($el.find("label")) + $model.$setViewValue(us) + currentLoading.finish() $rootscope.$broadcast("object:updated") promise.then null, -> - $loading.finish($el.find("label")) + currentLoading.finish() $confirm.notify("error") - us.revert() - $model.$setViewValue(us) $el.on "click", ".team-requirement", (event) -> return if not canEdit() @@ -456,18 +454,18 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $ us = $model.$modelValue.clone() us.client_requirement = client_requirement - $model.$setViewValue(us) + currentLoading = $loading() + .target($el.find("label")) + .start() - $loading.start($el.find("label")) - promise = $tgrepo.save($model.$modelValue) + promise = $tgrepo.save(us) promise.then => - $loading.finish($el.find("label")) - $rootscope.$broadcast("object:updated") - promise.then null, -> - $loading.finish($el.find("label")) - $confirm.notify("error") - us.revert() $model.$setViewValue(us) + currentLoading.finish() + $rootscope.$broadcast("object:updated") + + promise.then null, -> + $confirm.notify("error") $el.on "click", ".client-requirement", (event) -> return if not canEdit() diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee index 4a2b87d4..68c3b27f 100644 --- a/app/coffee/modules/wiki/main.coffee +++ b/app/coffee/modules/wiki/main.coffee @@ -233,7 +233,12 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $ onError = -> $confirm.notify("error") - $loading.start($el.find('.save-container')) + console.log $el.find('.save-container') + + currentLoading = $loading() + .removeClasses("icon-floppy") + .target($el.find('.icon-floppy')) + .start() if wiki.id? promise = $repo.save(wiki).then(onSuccess, onError) @@ -241,7 +246,7 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $ promise = $repo.create("wiki", wiki).then(onSuccess, onError) promise.finally -> - $loading.finish($el.find('.save-container')) + currentLoading.finish() $el.on "click", "a", (event) -> target = angular.element(event.target) diff --git a/app/coffee/modules/wiki/nav.coffee b/app/coffee/modules/wiki/nav.coffee index 558ff820..e0aa2c1b 100644 --- a/app/coffee/modules/wiki/nav.coffee +++ b/app/coffee/modules/wiki/nav.coffee @@ -104,27 +104,29 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $l target = angular.element(event.currentTarget) newLink = target.val() - $loading.start($el.find(".new")) + currentLoading = $loading() + .target($el.find(".new")) + .start() promise = $tgrepo.create("wiki-links", {project: $scope.projectId, title: newLink, href: slugify(newLink)}) promise.then -> $analytics.trackEvent("wikilink", "create", "create wiki link", 1) loadPromise = $ctrl.loadWikiLinks() loadPromise.then -> - $loading.finish($el.find(".new")) + currentLoading.finish() $el.find(".new").addClass("hidden") $el.find(".new input").val('') $el.find(".add-button").show() render($scope.wikiLinks) loadPromise.then null, -> - $loading.finish($el.find(".new")) + currentLoading.finish() $el.find(".new").addClass("hidden") $el.find(".new input").val('') $el.find(".add-button").show() $confirm.notify("error", "Error loading wiki links") promise.then null, (error) -> - $loading.finish($el.find(".new")) + currentLoading.finish() $el.find(".new input").val(newLink) $el.find(".new input").focus().select() if error?.__all__?[0]? diff --git a/app/partials/common/history/history-base.jade b/app/partials/common/history/history-base.jade index f9450728..4ca4a9af 100644 --- a/app/partials/common/history/history-base.jade +++ b/app/partials/common/history/history-base.jade @@ -16,7 +16,7 @@ section.history a(class="help-markdown", href="https://taiga.io/support/taiga-markdown-syntax/", target="_blank", title="{{'COMMON.WYSIWYG.MARKDOWN_HELP' | translate}}") span.icon.icon-help span(translate="COMMON.WYSIWYG.MARKDOWN_HELP") - input(type="button", ng-disabled!="!<%- ngmodel %>.comment.length" title="{{'COMMENTS.COMMENT' | translate}}", value="{{'COMMENTS.COMMENT' | translate}}", class="button button-green save-comment") + button(type="button", ng-disabled!="!<%- ngmodel %>.comment.length" title="{{'COMMENTS.COMMENT' | translate}}", translate="COMMENTS.COMMENT", class="button button-green save-comment") <% } %> section.history-activity.hidden .changes-list diff --git a/app/partials/includes/components/backlog-row.jade b/app/partials/includes/components/backlog-row.jade index f375076b..e91e4156 100644 --- a/app/partials/includes/components/backlog-row.jade +++ b/app/partials/includes/components/backlog-row.jade @@ -10,7 +10,7 @@ div.row.us-item-row(ng-repeat="us in userstories track by us.id", tg-bind-scope, span(ng-bind="us.subject") div.us-settings a.icon.icon-edit(tg-check-permission="modify_us", href="", - ng-click="ctrl.editUserStory(us)", title="{{'COMMON.EDIT' | translate}}") + ng-click="ctrl.editUserStory(us.project, us.ref, $event)", title="{{'COMMON.EDIT' | translate}}") a.icon.icon-delete(tg-check-permission="delete_us", href="", ng-click="ctrl.deleteUserStory(us)", title="{{'COMMON.DELETE' | translate}}") diff --git a/app/styles/components/kanban-task.scss b/app/styles/components/kanban-task.scss index 2aa34c30..401c45a0 100644 --- a/app/styles/components/kanban-task.scss +++ b/app/styles/components/kanban-task.scss @@ -87,6 +87,10 @@ .task-name { @extend %bold; } + .loading { + bottom: .5rem; + position: absolute; + } .icon-edit, .icon-drag-h { @extend %large; @@ -132,6 +136,7 @@ .task-name { word-wrap: break-word; } + .loading, .icon-edit { bottom: .2rem; right: .5rem; diff --git a/app/styles/components/taskboard-task.scss b/app/styles/components/taskboard-task.scss index 8e94caab..a8d58830 100644 --- a/app/styles/components/taskboard-task.scss +++ b/app/styles/components/taskboard-task.scss @@ -109,6 +109,10 @@ .icon { transition: color .3s linear, opacity .3s linear; } + .loading { + bottom: .5rem; + position: absolute; + } .icon-edit, .icon-drag-h { @extend %large; @@ -120,7 +124,8 @@ color: $card-dark; } } - .icon-edit { + .icon-edit, + .loading { right: 1rem; } .icon-drag-h {