From 4b67893e795ff2ed9d1a75da98d9daa8dcf5ac66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 12 Sep 2018 12:44:46 +0200 Subject: [PATCH] Allow to delete a project csv uuid --- .../modules/admin/project-profile.coffee | 22 +++++++++++++++++++ app/coffee/modules/resources/projects.coffee | 16 ++++++++++++++ app/locales/taiga/locale-en.json | 8 +++++-- app/partials/admin/project-csv.jade | 4 ++++ app/styles/modules/admin/project-csv.scss | 4 ++-- 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/coffee/modules/admin/project-profile.coffee b/app/coffee/modules/admin/project-profile.coffee index 7ea0fa98..e20228d2 100644 --- a/app/coffee/modules/admin/project-profile.coffee +++ b/app/coffee/modules/admin/project-profile.coffee @@ -438,6 +438,19 @@ class CsvExporterController extends taiga.Controller response.finish() if response return promise + _deleteUuid: (response=null) => + promise = @rs.projects["delete_#{@.type}_csv_uuid"](@scope.projectId) + + promise.then (data) => + @scope.csvUuid = data.data?.uuid + + promise.then null, => + @confirm.notify("error") + + promise.finally -> + response.finish() if response + return promise + regenerateUuid: -> if @scope.csvUuid title = @translate.instant("ADMIN.REPORTS.REGENERATE_TITLE") @@ -447,6 +460,15 @@ class CsvExporterController extends taiga.Controller else @._generateUuid() + deleteUuid: -> + if @scope.csvUuid + title = @translate.instant("ADMIN.REPORTS.DELETE_TITLE") + subtitle = @translate.instant("ADMIN.REPORTS.DELETE_SUBTITLE") + + @confirm.ask(title, subtitle).then @._deleteUuid + else + @._deleteUuid() + class CsvExporterEpicsController extends CsvExporterController type: "epics" diff --git a/app/coffee/modules/resources/projects.coffee b/app/coffee/modules/resources/projects.coffee index 6da6095c..6787bf95 100644 --- a/app/coffee/modules/resources/projects.coffee +++ b/app/coffee/modules/resources/projects.coffee @@ -79,6 +79,22 @@ resourceProvider = ($config, $repo, $http, $urls, $auth, $q, $translate) -> url = "#{$urls.resolve("projects")}/#{projectId}/regenerate_issues_csv_uuid" return $http.post(url) + service.delete_epics_csv_uuid = (projectId) -> + url = "#{$urls.resolve("projects")}/#{projectId}/delete_epics_csv_uuid" + return $http.post(url) + + service.delete_userstories_csv_uuid = (projectId) -> + url = "#{$urls.resolve("projects")}/#{projectId}/delete_userstories_csv_uuid" + return $http.post(url) + + service.delete_tasks_csv_uuid = (projectId) -> + url = "#{$urls.resolve("projects")}/#{projectId}/delete_tasks_csv_uuid" + return $http.post(url) + + service.delete_issues_csv_uuid = (projectId) -> + url = "#{$urls.resolve("projects")}/#{projectId}/delete_issues_csv_uuid" + return $http.post(url) + service.leave = (projectId) -> url = "#{$urls.resolve("projects")}/#{projectId}/leave" return $http.post(url) diff --git a/app/locales/taiga/locale-en.json b/app/locales/taiga/locale-en.json index 01cc7f17..549a24de 100644 --- a/app/locales/taiga/locale-en.json +++ b/app/locales/taiga/locale-en.json @@ -537,7 +537,9 @@ "DESCRIPTION": "Download a CSV file or copy the generated URL and open it in your favourite text editor or spreadsheet to make your own project data reports. You will be able to visualize and analyze all your data easily.", "HELP": "How to use this on my own spreadsheet?", "REGENERATE_TITLE": "Change URL", - "REGENERATE_SUBTITLE": "You going to change the CSV data access url. The previous url will be disabled. Are you sure?" + "REGENERATE_SUBTITLE": "You are going to change the CSV data access url. The previous url will be disabled. Are you sure?", + "DELETE_TITLE": "Delete URL", + "DELETE_SUBTITLE": "You are going to delete the current CSV data access url. Are you sure?" }, "CSV": { "SECTION_TITLE_EPIC": "epics reports", @@ -548,7 +550,9 @@ "URL_FIELD_PLACEHOLDER": "Please regenerate CSV url", "TITLE_REGENERATE_URL": "Regenerate CSV url", "ACTION_GENERATE_URL": "Generate Url", - "ACTION_REGENERATE": "Regenerate" + "ACTION_REGENERATE": "Regenerate", + "TITLE_DELETE_URL": "Delete CSV url", + "ACTION_DELETE_URL": "Delete" }, "CUSTOM_FIELDS": { "TITLE": "Custom Fields", diff --git a/app/partials/admin/project-csv.jade b/app/partials/admin/project-csv.jade index 632c164c..e4190e70 100644 --- a/app/partials/admin/project-csv.jade +++ b/app/partials/admin/project-csv.jade @@ -18,3 +18,7 @@ section.project-csv(tg-select-input-text) tg-svg(svg-icon="icon-reload", ng-show="csvUrl") span(ng-Show="csvUrl", translate="ADMIN.CSV.ACTION_REGENERATE") + + a(href="", ng-show="csvUrl" title="{{'ADMIN.CSV.TITLE_DELETE_URL' | translate}}", ng-click="ctrl.deleteUuid()") + tg-svg(svg-icon="icon-trash", ng-show="csvUrl") + span(ng-Show="csvUrl", translate="ADMIN.CSV.ACTION_DELETE_URL") diff --git a/app/styles/modules/admin/project-csv.scss b/app/styles/modules/admin/project-csv.scss index ac253f49..421c9cbd 100644 --- a/app/styles/modules/admin/project-csv.scss +++ b/app/styles/modules/admin/project-csv.scss @@ -11,7 +11,8 @@ margin-bottom: 1rem; a { @include font-size(small); - min-width: 110px; + margin-left: 1em; + white-space: nowrap; } .icon:not(.icon-clipboard) { fill: currentColor; @@ -23,7 +24,6 @@ } .field-with-options { display: flex; - margin-right: 1rem; width: 100%; input { flex-grow: 1;