From 0a486de6a2dbdfeec5acc4e29b445aa2f6807448 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Thu, 14 Feb 2019 15:10:28 +0100 Subject: [PATCH] v8: Redirects confirm overlay (#4378) --- .../dashboard/content/overlays/delete.html | 11 ++ .../dashboard/content/overlays/disable.html | 5 + .../content/redirecturls.controller.js | 142 ++++++++++++------ .../views/dashboard/content/redirecturls.html | 15 +- src/Umbraco.Web.UI/Umbraco/config/lang/da.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 2 +- .../Umbraco/config/lang/en_us.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/es.xml | 3 +- src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml | 1 - src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml | 1 - src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml | 1 - src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml | 1 - src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml | 1 - .../Umbraco/config/lang/zh_tw.xml | 1 - 14 files changed, 121 insertions(+), 67 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/delete.html create mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/disable.html diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/delete.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/delete.html new file mode 100644 index 0000000000..0a5de2b9e7 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/delete.html @@ -0,0 +1,11 @@ +
+ +
+ This will remove the redirect

+ Original URL: {{model.redirect.originalUrl}}
+ Redirected To: {{model.redirect.destinationUrl}} +
+ + ? + +
diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/disable.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/disable.html new file mode 100644 index 0000000000..678fcd6e9a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/overlays/disable.html @@ -0,0 +1,5 @@ +
+ + Are you sure you want to disable the URL tracker? + +
diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.controller.js index 8206d0a114..32b772c2f2 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.controller.js @@ -1,7 +1,7 @@ (function() { "use strict"; - function RedirectUrlsController($scope, redirectUrlsResource, notificationsService, localizationService, $q) { + function RedirectUrlsController($scope, $q, redirectUrlsResource, notificationsService, localizationService, eventsService, overlayService) { // TODO: search by url or url part // TODO: search by domain // TODO: display domain in dashboard results? @@ -76,68 +76,113 @@ }); } - function removeRedirect(redirectToDelete) { - localizationService.localize("redirectUrls_confirmRemove", [redirectToDelete.originalUrl, redirectToDelete.destinationUrl]).then(function (value) { - var toggleConfirm = confirm(value); + function disableUrlTracker(event) { - if (toggleConfirm) { - redirectUrlsResource.deleteRedirectUrl(redirectToDelete.redirectId).then(function () { - - var index = vm.redirectUrls.indexOf(redirectToDelete); - vm.redirectUrls.splice(index, 1); - - localizationService.localize("redirectUrls_redirectRemoved").then(function(value){ - notificationsService.success(value); - }); - - // check if new redirects needs to be loaded - if (vm.redirectUrls.length === 0 && vm.pagination.totalPages > 1) { - - // if we are not on the first page - get records from the previous - if (vm.pagination.pageIndex > 0) { - vm.pagination.pageIndex = vm.pagination.pageIndex - 1; - vm.pagination.pageNumber = vm.pagination.pageNumber - 1; - } - - search(); - } - }, function (error) { - localizationService.localize("redirectUrls_redirectRemoveError").then(function(value){ - notificationsService.error(value); - }); - }); + const dialog = { + view: "views/dashboard/content/overlays/disable.html", + submitButtonLabel: "Disable", + submitButtonLabelKey: "actions_disable", + submit: function (model) { + performDisable(); + overlayService.close(); + }, + close: function () { + overlayService.close(); } + }; + + localizationService.localize("redirectUrls_disableUrlTracker").then(value => { + dialog.title = value; + overlayService.open(dialog); + }); + + event.preventDefault() + event.stopPropagation(); + } + + function removeRedirect(redirect, event) { + + const dialog = { + view: "views/dashboard/content/overlays/delete.html", + redirect: redirect, + submitButtonLabelKey: "contentTypeEditor_yesDelete", + submit: function (model) { + performDelete(model.redirect); + overlayService.close(); + }, + close: function () { + overlayService.close(); + } + }; + + localizationService.localize("general_delete").then(value => { + dialog.title = value; + overlayService.open(dialog); + }); + + event.preventDefault() + event.stopPropagation(); + } + + function performDisable() { + + redirectUrlsResource.toggleUrlTracker(true).then(function () { + activate(); + localizationService.localize("redirectUrls_disabledConfirm").then(function (value) { + notificationsService.success(value); + }); + }, function (error) { + localizationService.localize("redirectUrls_disableError").then(function (value) { + notificationsService.warning(value); + }); }); } - function disableUrlTracker() { - localizationService.localize("redirectUrls_confirmDisable").then(function(value) { - var toggleConfirm = confirm(value); - if (toggleConfirm) { + function performDelete(redirect) { + redirect.deleteButtonState = "busy"; - redirectUrlsResource.toggleUrlTracker(true).then(function () { - activate(); - localizationService.localize("redirectUrls_disabledConfirm").then(function(value){ - notificationsService.success(value); - }); - }, function (error) { - localizationService.localize("redirectUrls_disableError").then(function(value){ - notificationsService.warning(value); - }); - }); + redirectUrlsResource.deleteRedirectUrl(redirect.redirectId).then(function () { + // emit event + var args = { redirect: redirect }; + eventsService.emit("editors.redirects.redirectDeleted", args); + + // remove from list + var index = vm.redirectUrls.indexOf(redirect); + vm.redirectUrls.splice(index, 1); + + localizationService.localize("redirectUrls_redirectRemoved").then(function (value) { + notificationsService.success(value); + }); + + // check if new redirects needs to be loaded + if (vm.redirectUrls.length === 0 && vm.pagination.totalPages > 1) { + + // if we are not on the first page - get records from the previous + if (vm.pagination.pageIndex > 0) { + vm.pagination.pageIndex = vm.pagination.pageIndex - 1; + vm.pagination.pageNumber = vm.pagination.pageNumber - 1; + } + + search(); } + }, function (error) { + redirect.deleteButtonState = "error"; + + localizationService.localize("redirectUrls_redirectRemoveError").then(function (value) { + notificationsService.error(value); + }); }); } function enableUrlTracker() { - redirectUrlsResource.toggleUrlTracker(false).then(function() { + redirectUrlsResource.toggleUrlTracker(false).then(function () { activate(); - localizationService.localize("redirectUrls_enabledConfirm").then(function(value){ + localizationService.localize("redirectUrls_enabledConfirm").then(function (value) { notificationsService.success(value); }); - }, function(error) { - localizationService.localize("redirectUrls_enableError").then(function(value){ + }, function (error) { + localizationService.localize("redirectUrls_enableError").then(function (value) { notificationsService.warning(value); }); }); @@ -167,7 +212,6 @@ } activate(); - } angular.module("umbraco").controller("Umbraco.Dashboard.RedirectUrlsController", RedirectUrlsController); diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.html index a06984f31e..98a8294e80 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.html +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/content/redirecturls.html @@ -12,7 +12,7 @@ ng-if="vm.dashboard.urlTrackerDisabled === false" type="button" size="s" - action="vm.disableUrlTracker()" + action="vm.disableUrlTracker($event)" label-key="redirectUrls_disableUrlTracker"> @@ -63,13 +63,13 @@
-
+
- {{redirectUrl.culture ||'*'}} + {{redirect.culture ||'*'}}
@@ -78,14 +78,15 @@
+ state="redirect.deleteButtonState" + action="vm.removeRedirect(redirect, $event)" + label-key="general_remove">
diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml index d7b02f0052..efbb0a896c 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml @@ -1496,10 +1496,10 @@ Mange hilsner fra Umbraco robotten Viderestillet til Der er ikke lavet nogen viderestillinger Når en udgivet side bliver omdøbt eller flyttet, vil en viderestilling automatisk blive lavet til den nye side. - Fjern Er du sikker på at du vil fjerne viderestillingen fra '%0%' til '%1%'? Viderestillings URL fjernet. Fejl under fjernelse af viderestillings URL. + Dette vil fjerne viderestillingen Er du sikker på at du vil slå URL trackeren fra? URL tracker er nu slået fra. Der opstod en fejl under forsøget på at slå URL trackeren fra, der findes mere information i logfilen. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index b67c669615..d129e5de78 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -2008,10 +2008,10 @@ To manage your website, simply open the Umbraco back office and start adding con The following URLs redirect to this content item: No redirects have been made When a published page gets renamed or moved a redirect will automatically be made to the new page. - Remove Are you sure you want to remove the redirect from '%0%' to '%1%'? Redirect URL removed. Error removing redirect URL. + This will remove the redirect Are you sure you want to disable the URL tracker? URL tracker has now been disabled. Error disabling the URL tracker, more information can be found in your log file. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index 49d5ca3527..a18573fef7 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -2022,10 +2022,10 @@ To manage your website, simply open the Umbraco back office and start adding con The following URLs redirect to this content item: No redirects have been made When a published page gets renamed or moved a redirect will automatically be made to the new page. - Remove Are you sure you want to remove the redirect from '%0%' to '%1%'? Redirect URL removed. Error removing redirect URL. + This will remove the redirect Are you sure you want to disable the URL tracker? URL tracker has now been disabled. Error disabling the URL tracker, more information can be found in your log file. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml index 7755a79d23..8492d9167b 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/es.xml @@ -1643,10 +1643,9 @@ Redirigido a To No se ha creado ninguna redirección Cuando una página es renombrada o movida, una redirección a la nueva página es automáticamente creada. - Eliminar ¿Estás seguro que quieres eliminar la redirección de '%0%' a '%1%'? Redirección URL eliminada. - Error borrando la redirección URL. + Error borrando la redirección URL. ¿Seguro que quieres desactivar URL tracker? URL tracker ha sido desactivado. Error desactivando URL tracker, más información se puede encontrar en los logs. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml index 7f9de665a2..db80b8f082 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml @@ -1850,7 +1850,6 @@ Pour gérer votre site, ouvrez simplement le backoffice Umbraco et commencez à Redirigé Vers Aucune redirection n'a été créée Lorsqu'une page publiée est renommée ou déplacée, une redirection sera automatiquement créée vers la nouvelle page. - Supprimer Etes-vous certain(e) de vouloir supprimer la redirection de '%0%' vers '%1%'? Redirection d'URL supprimée. Erreur lors de la suppression de la redirection d'URL. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml index 7f61d49af8..20ded48452 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/nl.xml @@ -1397,7 +1397,6 @@ Echter, Runway biedt een gemakkelijke basis om je snel op weg te helpen. Als je Doorgestuurd naar Er zijn geen redirects Er wordt automatisch een redirect aangemaakt als een gepubliceerde pagina hernoemd of verplaatst wordt. - Verwijder Weet je zeker dat je de redirect van '%0%' naar '%1%' wilt verwijderen? Redirect URL verwijderd. Fout bij verwijderen redirect URL. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml index 8a1212a34a..f4b859a60d 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/pl.xml @@ -1477,7 +1477,6 @@ Naciśnij przycisk instaluj, aby zainstalować bazę danych Umb Przekierowane do Nie stworzono żadnych przekierowań Kiedy nazwa opublikowanej strony zostanie zmieniona lub zostanie ona przeniesiona, zostanie stworzone automatyczne przekierowanie na nową stronę. - Usuń Czy jesteś pewien, że chcesz usunąć przekierowanie z '%0%' do '%1%'? Przekierowanie URL zostało usunięte. Wystąpił błąd podczas usuwania przekierowania URL. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml index c3723df509..22c791c9a3 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml @@ -1286,7 +1286,6 @@ Перенаправлен в На данный момент нет ни одного перенаправления Если опубликованный документ переименовывается или меняет свое расположение в дереве, а следовательно, меняется адрес (URL), автоматически создается перенаправление на новое местоположение этого документа. - Удалить Вы уверены, что хотите удалить перенаправление с '%0%' на '%1%'? Перенаправление удалено. Ошибка удаления перенаправления. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml index 8d9d09fe2d..105eee662e 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/zh.xml @@ -1262,7 +1262,6 @@ 已重定向至 未进行重定向 当已发布的页重命名或移动时, 将自动对新页进行重定向。 - 删除 确实要删除 "%0%" 到 "%1%" 的重定向吗? 重定向URL已删除。 删除重定向 url 时出错. diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml index ab638d153a..62a3480d92 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml @@ -1241,7 +1241,6 @@ 轉址成 沒有任何轉址 當發佈後的頁面改名或移動時,會自動轉址至新網頁。 - 移除 您確定要移除從 %0% 到 %1% 的轉址嗎? 轉址已移除。 移除轉址錯誤。