From fb8756e30ba948dfd5dd3ebb28e4ca3e24a55061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Wed, 22 Oct 2014 12:30:59 +0200 Subject: [PATCH] Fix bug #1445: Refactor: $confirm.ask service --- app/coffee/modules/admin/memberships.coffee | 8 +++---- app/coffee/modules/backlog/lightboxes.coffee | 4 ++-- app/coffee/modules/backlog/main.coffee | 4 ++-- app/coffee/modules/common/attachments.coffee | 6 ++--- app/coffee/modules/common/components.coffee | 12 +++++----- app/coffee/modules/common/confirm.coffee | 8 ++++--- app/coffee/modules/issues/detail.coffee | 4 ++-- app/coffee/modules/issues/list.coffee | 4 ++-- app/coffee/modules/related-tasks.coffee | 4 ++-- app/coffee/modules/tasks/detail.coffee | 4 ++-- app/coffee/modules/userstories/detail.coffee | 4 ++-- app/coffee/modules/wiki/main.coffee | 4 ++-- app/coffee/modules/wiki/nav.coffee | 4 ++-- app/index.jade | 4 ++-- .../help-notions/lightbox-generic-notion.jade | 2 +- .../views/modules/lightbox-ask-choice.jade | 4 ++-- .../modules/lightbox-confirm-delete.jade | 12 ---------- .../modules/lightbox-delete-account.jade | 4 ++-- .../modules/lightbox-delete-project.jade | 4 ++-- .../views/modules/lightbox-generic-ask.jade | 12 ++++++++++ .../views/modules/lightbox-generic-error.jade | 2 +- .../modules/lightbox-generic-success.jade | 2 +- app/styles/modules/common/lightbox.scss | 24 +++++++++---------- 23 files changed, 71 insertions(+), 69 deletions(-) delete mode 100644 app/partials/views/modules/lightbox-confirm-delete.jade create mode 100644 app/partials/views/modules/lightbox-generic-ask.jade diff --git a/app/coffee/modules/admin/memberships.coffee b/app/coffee/modules/admin/memberships.coffee index a7435ae9..849df141 100644 --- a/app/coffee/modules/admin/memberships.coffee +++ b/app/coffee/modules/admin/memberships.coffee @@ -432,18 +432,18 @@ MembershipsRowActionsDirective = ($log, $repo, $rs, $confirm) -> event.preventDefault() title = "Delete member" # TODO: i18n - subtitle = if member.user then member.full_name else "the invitation to #{member.email}" # TODO: i18n + message = if member.user then member.full_name else "the invitation to #{member.email}" # TODO: i18n - $confirm.ask(title, subtitle).then (finish) -> + $confirm.askOnDelete(title, message).then (finish) -> onSuccess = -> finish() $ctrl.loadMembers() - $confirm.notify("success", null, "We've deleted #{subtitle}.") # TODO: i18n + $confirm.notify("success", null, "We've deleted #{message}.") # TODO: i18n onError = -> finish(false) # TODO: i18in - $confirm.notify("error", null, "We have not been able to delete #{subtitle}.") + $confirm.notify("error", null, "We have not been able to delete #{message}.") $repo.remove(member).then(onSuccess, onError) diff --git a/app/coffee/modules/backlog/lightboxes.coffee b/app/coffee/modules/backlog/lightboxes.coffee index 00ba58ba..d0a31b46 100644 --- a/app/coffee/modules/backlog/lightboxes.coffee +++ b/app/coffee/modules/backlog/lightboxes.coffee @@ -86,9 +86,9 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading) remove = -> #TODO: i18n title = "Delete sprint" - subtitle = $scope.sprint.name + message = $scope.sprint.name - $confirm.ask(title, subtitle).then (finish) => + $confirm.askOnDelete(title, message).then (finish) => onSuccess = -> finish() $scope.milestonesCounter -= 1 diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 8201b4f8..8ac10ce4 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -469,9 +469,9 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F deleteUserStory: (us) -> #TODO: i18n title = "Delete User Story" - subtitle = us.subject + message = us.subject - @confirm.ask(title, subtitle).then (finish) => + @confirm.askOnDelete(title, message).then (finish) => # We modify the userstories in scope so the user doesn't see the removed US for a while @scope.userstories = _.without(@scope.userstories, us) @filterVisibleUserstories() diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee index 9832c6d8..3402a392 100644 --- a/app/coffee/modules/common/attachments.coffee +++ b/app/coffee/modules/common/attachments.coffee @@ -127,9 +127,9 @@ class AttachmentsController extends taiga.Controller # Remove one concrete attachment. removeAttachment: (attachment) -> title = "Delete attachment" #TODO: i18in - subtitle = "the attachment '#{attachment.name}'" #TODO: i18in + message = "the attachment '#{attachment.name}'" #TODO: i18in - return @confirm.ask(title, subtitle).then (finish) => + return @confirm.askOnDelete(title, message).then (finish) => onSuccess = => finish() index = @.attachments.indexOf(attachment) @@ -139,7 +139,7 @@ class AttachmentsController extends taiga.Controller onError = => finish(false) - @confirm.notify("error", null, "We have not been able to delete #{subtitle}.") + @confirm.notify("error", null, "We have not been able to delete #{message}.") return @q.reject() return @repo.remove(attachment).then(onSuccess, onError) diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index 4c429a87..30d3a35c 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -165,10 +165,10 @@ WatchersDirective = ($rootscope, $confirm) -> target = angular.element(event.currentTarget) watcherId = target.data("watcher-id") - title = "Remove watcher" - subtitle = $scope.usersById[watcherId].full_name_display + title = "Delete watcher" + message = $scope.usersById[watcherId].full_name_display - $confirm.ask(title, subtitle).then (finish) => + $confirm.askOnDelete(title, message).then (finish) => finish() watcherIds = _.clone($model.$modelValue.watchers, false) watcherIds = _.pull(watcherIds, watcherId) @@ -250,10 +250,10 @@ AssignedToDirective = ($rootscope, $confirm) -> $el.on "click", ".icon-delete", (event) -> event.preventDefault() - title = "Remove assigned to" - subtitle = "" + title = "Delete assignetion" + message = "" - $confirm.ask(title, subtitle).then (finish) => + $confirm.askOnDelete(title, message).then (finish) => finish() $model.$modelValue.assigned_to = null renderAssignedTo($model.$modelValue) diff --git a/app/coffee/modules/common/confirm.coffee b/app/coffee/modules/common/confirm.coffee index dbae0425..d52ce5d4 100644 --- a/app/coffee/modules/common/confirm.coffee +++ b/app/coffee/modules/common/confirm.coffee @@ -50,14 +50,13 @@ class ConfirmService extends taiga.Service el.off(".confirm-dialog") - ask: (title, subtitle, message=null, lightboxSelector=".lightbox-confirm-delete") -> + ask: (title, subtitle, message, lightboxSelector=".lightbox-generic-ask") -> el = angular.element(lightboxSelector) # Render content el.find("h2.title").html(title) el.find("span.subtitle").html(subtitle) - if message - el.find("span.delete-question").html(message) + el.find("span.message").html(message) defered = @q.defer() @@ -80,6 +79,9 @@ class ConfirmService extends taiga.Service return defered.promise + askOnDelete: (title, message) -> + return @.ask(title, "Are you sure you want to delete?", message) #TODO: i18n + askChoice: (title, subtitle, choices, lightboxSelector=".lightbox-ask-choice") -> el = angular.element(lightboxSelector) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index ac36f08e..7db92857 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -143,9 +143,9 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin) delete: -> # TODO: i18n title = "Delete Issue" - subtitle = @scope.issue.subject + message = @scope.issue.subject - @confirm.ask(title, subtitle).then (finish) => + @confirm.askOnDelete(title, message).then (finish) => promise = @.repo.remove(@scope.issue) promise.then => finish() diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee index b2aab722..4ddd3a41 100644 --- a/app/coffee/modules/issues/list.coffee +++ b/app/coffee/modules/issues/list.coffee @@ -642,9 +642,9 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading) -> target = angular.element(event.currentTarget) customFilterName = target.parent().data('id') title = "Delete custom filter" # TODO: i18n - subtitle = "the custom filter '#{customFilterName}'" # TODO: i18n + message = "the custom filter '#{customFilterName}'" # TODO: i18n - $confirm.ask(title, subtitle).then (finish) -> + $confirm.askOnDelete(title, message).then (finish) -> promise = $ctrl.deleteMyFilter(customFilterName) promise.then -> promise = $ctrl.loadMyFilters() diff --git a/app/coffee/modules/related-tasks.coffee b/app/coffee/modules/related-tasks.coffee index 1e142421..8b853704 100644 --- a/app/coffee/modules/related-tasks.coffee +++ b/app/coffee/modules/related-tasks.coffee @@ -139,9 +139,9 @@ RelatedTaskRowDirective = ($repo, $compile, $confirm, $rootscope, $loading) -> #TODO: i18n task = $model.$modelValue title = "Delete Task" - subtitle = task.subject + message = task.subject - $confirm.ask(title, subtitle).then (finish) -> + $confirm.askOnDelete(title, message).then (finish) -> promise = $repo.remove(task) promise.then -> finish() diff --git a/app/coffee/modules/tasks/detail.coffee b/app/coffee/modules/tasks/detail.coffee index ea532357..7778b193 100644 --- a/app/coffee/modules/tasks/detail.coffee +++ b/app/coffee/modules/tasks/detail.coffee @@ -134,9 +134,9 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin) delete: -> #TODO: i18n title = "Delete Task" - subtitle = @scope.task.subject + message = @scope.task.subject - @confirm.ask(title, subtitle).then (finish) => + @confirm.askOnDelete(title, message).then (finish) => promise = @.repo.remove(@scope.task) promise.then => finish() diff --git a/app/coffee/modules/userstories/detail.coffee b/app/coffee/modules/userstories/detail.coffee index e81f4481..aac5f273 100644 --- a/app/coffee/modules/userstories/detail.coffee +++ b/app/coffee/modules/userstories/detail.coffee @@ -146,9 +146,9 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin) delete: -> #TODO: i18n title = "Delete User Story" - subtitle = @scope.us.subject + message = @scope.us.subject - @confirm.ask(title, subtitle).then (finish) => + @confirm.askOnDelete(title, message).then (finish) => promise = @.repo.remove(@scope.us) promise.then => finish() diff --git a/app/coffee/modules/wiki/main.coffee b/app/coffee/modules/wiki/main.coffee index 7a45338e..fb7a52ee 100644 --- a/app/coffee/modules/wiki/main.coffee +++ b/app/coffee/modules/wiki/main.coffee @@ -138,9 +138,9 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin) delete: -> # TODO: i18n title = "Delete Wiki Page" - subtitle = unslugify(@scope.wiki.slug) + message = unslugify(@scope.wiki.slug) - @confirm.ask(title, subtitle).then (finish) => + @confirm.askOnDelete(title, message).then (finish) => onSuccess = => finish() ctx = {project: @scope.projectSlug} diff --git a/app/coffee/modules/wiki/nav.coffee b/app/coffee/modules/wiki/nav.coffee index 2f4530ee..4daf00bd 100644 --- a/app/coffee/modules/wiki/nav.coffee +++ b/app/coffee/modules/wiki/nav.coffee @@ -107,9 +107,9 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $l # TODO: i18n title = "Delete Wiki Link" - subtitle = $scope.wikiLinks[linkId].title + message = $scope.wikiLinks[linkId].title - $confirm.ask(title, subtitle).then (finish) => + $confirm.askOnDelete(title, message).then (finish) => promise = $tgrepo.remove($scope.wikiLinks[linkId]) promise.then -> promise = $ctrl.loadWikiLinks() diff --git a/app/index.jade b/app/index.jade index bd7e4d4f..87f42db2 100644 --- a/app/index.jade +++ b/app/index.jade @@ -21,8 +21,8 @@ html(lang="en", ng-app="taiga") div.master(ng-view) - div.hidden.lightbox.lightbox-confirm-delete - include partials/views/modules/lightbox-confirm-delete + div.hidden.lightbox.lightbox-generic-ask + include partials/views/modules/lightbox-generic-ask div.hidden.lightbox.lightbox-ask-choice include partials/views/modules/lightbox-ask-choice div.hidden.lightbox.lightbox-generic-success diff --git a/app/partials/views/modules/help-notions/lightbox-generic-notion.jade b/app/partials/views/modules/help-notions/lightbox-generic-notion.jade index 6e4222e7..00ce3a93 100644 --- a/app/partials/views/modules/help-notions/lightbox-generic-notion.jade +++ b/app/partials/views/modules/help-notions/lightbox-generic-notion.jade @@ -7,6 +7,6 @@ section block content - div.delete-options + div.options a.button.button-green(href="", title="Accept") span Accept diff --git a/app/partials/views/modules/lightbox-ask-choice.jade b/app/partials/views/modules/lightbox-ask-choice.jade index f248c246..0dcf1406 100644 --- a/app/partials/views/modules/lightbox-ask-choice.jade +++ b/app/partials/views/modules/lightbox-ask-choice.jade @@ -3,11 +3,11 @@ a.close(href="", title="close") form h2.title Delete User Story p - span.delete-question Are you sure you want to delete? + span.question Are you sure you want to delete? span.subtitle #125 Crear el perfil de usuario senior en el admin span.replacement What value do you want to use as replacement? select.choices - div.delete-options + div.options a.button.button-green(href="", title="Accept") span Accept a.button.button-red(href="", title="Delete") diff --git a/app/partials/views/modules/lightbox-confirm-delete.jade b/app/partials/views/modules/lightbox-confirm-delete.jade deleted file mode 100644 index 388a7160..00000000 --- a/app/partials/views/modules/lightbox-confirm-delete.jade +++ /dev/null @@ -1,12 +0,0 @@ -a.close(href="", title="close") - span.icon.icon-delete -form - h2.title Delete User Story - p - span.delete-question Are you sure you want to delete? - span.subtitle #125 Crear el perfil de usuario senior en el admin - div.delete-options - a.button.button-green(href="", title="Accept") - span Accept - a.button.button-red(href="", title="Delete") - span Cancel \ No newline at end of file diff --git a/app/partials/views/modules/lightbox-delete-account.jade b/app/partials/views/modules/lightbox-delete-account.jade index 0fb4ab2b..bd7c15af 100644 --- a/app/partials/views/modules/lightbox-delete-account.jade +++ b/app/partials/views/modules/lightbox-delete-account.jade @@ -3,9 +3,9 @@ a.close(href="", title="close") form h2.title Delete Taiga Account p - span.delete-question Are you sure you want to delete your Taiga account? + span.question Are you sure you want to delete your Taiga account? span.subtitle We're going to miss you! :-( - div.delete-options + div.options a.button.button-green(href="", title="Accept") span Accept a.button.button-red(href="", title="Cancel") diff --git a/app/partials/views/modules/lightbox-delete-project.jade b/app/partials/views/modules/lightbox-delete-project.jade index 63749499..b05fb346 100644 --- a/app/partials/views/modules/lightbox-delete-project.jade +++ b/app/partials/views/modules/lightbox-delete-project.jade @@ -3,9 +3,9 @@ a.close(href="", title="close") form h2.title Delete project p - span.delete-question Are you sure you want to delete this project? + span.question Are you sure you want to delete this project? span.subtitle All project data US/Tasks/Issues/Sprints/WikiPages will be lost! :-( - div.delete-options + div.options a.button.button-green(href="", title="Yes, I'm really sure") span Yes, I'm really sure a.button.button-red(href="", title="Cancel") diff --git a/app/partials/views/modules/lightbox-generic-ask.jade b/app/partials/views/modules/lightbox-generic-ask.jade new file mode 100644 index 00000000..af346d15 --- /dev/null +++ b/app/partials/views/modules/lightbox-generic-ask.jade @@ -0,0 +1,12 @@ +a.close(href="", title="close") + span.icon.icon-delete +form + h2.title + p + span.subtitle + span.message + div.options + a.button.button-green(href="", title="Accept") + span Accept + a.button.button-red(href="", title="Delete") + span Cancel diff --git a/app/partials/views/modules/lightbox-generic-error.jade b/app/partials/views/modules/lightbox-generic-error.jade index db878226..e8277d96 100644 --- a/app/partials/views/modules/lightbox-generic-error.jade +++ b/app/partials/views/modules/lightbox-generic-error.jade @@ -2,6 +2,6 @@ a.close(href="", title="close") span.icon.icon-delete section h2.title - div.delete-options + div.options a.button.button-green(href="", title="Accept") span Accept diff --git a/app/partials/views/modules/lightbox-generic-success.jade b/app/partials/views/modules/lightbox-generic-success.jade index db878226..e8277d96 100644 --- a/app/partials/views/modules/lightbox-generic-success.jade +++ b/app/partials/views/modules/lightbox-generic-success.jade @@ -2,6 +2,6 @@ a.close(href="", title="close") span.icon.icon-delete section h2.title - div.delete-options + div.options a.button.button-green(href="", title="Accept") span Accept diff --git a/app/styles/modules/common/lightbox.scss b/app/styles/modules/common/lightbox.scss index d3e57bbb..46d83ba5 100644 --- a/app/styles/modules/common/lightbox.scss +++ b/app/styles/modules/common/lightbox.scss @@ -283,12 +283,12 @@ } } -.lightbox-confirm-delete { +.lightbox-generic-ask { form { @include table-flex-child(0, 420px, 0, 420px); } - .delete-question, - .subtitle { + .subtitle, + .message { display: block; line-height: 2rem; text-align: center; @@ -297,7 +297,7 @@ @extend %large; @extend %title; } - .delete-options { + .options { @include table-flex(); a { @include table-flex-child(1, 0, 0); @@ -314,7 +314,7 @@ form { @include table-flex-child(0, 420px, 0, 420px); } - .delete-question, + .question, .subtitle { display: block; line-height: 2rem; @@ -328,7 +328,7 @@ display: block; text-align: center; } - .delete-options { + .options { @include table-flex(); a { @include table-flex-child(1, 0, 0); @@ -345,7 +345,7 @@ form { @include table-flex-child(0, 420px, 0, 420px); } - .delete-question, + .question, .subtitle { display: block; line-height: 2rem; @@ -372,7 +372,7 @@ form { @include table-flex-child(0, 420px, 0, 420px); } - .delete-question, + .question, .subtitle { display: block; line-height: 2rem; @@ -382,7 +382,7 @@ @extend %large; @extend %title; } - .newsletter-delete { + .newsletter { margin-top: 1rem; text-align: center; input { @@ -393,7 +393,7 @@ } } } - .delete-options { + .options { @include table-flex(); a { @include table-flex-child(1, 0, 0); @@ -410,7 +410,7 @@ form { @include table-flex-child(0, 420px, 0, 420px); } - .delete-question, + .question, .subtitle { display: block; line-height: 2rem; @@ -420,7 +420,7 @@ @extend %large; @extend %title; } - .delete-options { + .options { @include table-flex(); a { @include table-flex-child(1, 0, 0);