From be7acb904da81dcdfb1f3d124bcad0043e458127 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 27 Sep 2018 15:24:38 +0200 Subject: [PATCH] Unpublish dialog scaffolding --- .../components/content/edit.controller.js | 24 +++++++ .../content/overlays/unpublish.controller.js | 62 +++++++++++++++++ .../src/views/content/overlays/unpublish.html | 69 +++++++++++++++++++ .../Umbraco/config/lang/en_us.xml | 2 + 4 files changed, 157 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index b7ddc28dca..242fc58370 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -325,6 +325,29 @@ }); } + $scope.unPublish = function() { + clearNotifications($scope.content); + if (formHelper.submitForm({ scope: $scope, action: "unpublish", skipValidation: true })) { + var dialog = { + parentScope: $scope, + view: "views/content/overlays/unpublish.html", + variants: $scope.content.variants, //set a model property for the dialog + skipFormValidation: true, //when submitting the overlay form, skip any client side validation + submitButtonLabelKey: "content_unPublish", + submit: function (model) { + model.submitButtonState = "busy"; + clearNotifications($scope.content); + // TODO: do some unpublishing here + }, + close: function () { + overlayService.close(); + } + }; + overlayService.open(dialog); + } + }; + + /* $scope.unPublish = function () { //if there's any variants than we need to set the language and include the variants to publish @@ -370,6 +393,7 @@ } }; + */ $scope.sendToPublish = function () { clearNotifications($scope.content); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js new file mode 100644 index 0000000000..6b8bcb59e2 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js @@ -0,0 +1,62 @@ +(function () { + "use strict"; + + function UnpublishController($scope, localizationService) { + + var vm = this; + vm.loading = true; + + vm.changeSelection = changeSelection; + vm.publishedVariantFilter = publishedVariantFilter; + vm.unpublishedVariantFilter = unpublishedVariantFilter; + + function onInit() { + + vm.variants = $scope.model.variants; + + // set dialog title + if (!$scope.model.title) { + localizationService.localize("content_unPublish").then(function (value) { + $scope.model.title = value; + }); + } + + vm.loading = false; + + } + + function changeSelection() { + var firstSelected = _.find(vm.variants, function (v) { + return v.unpublish; + }); + $scope.model.disableSubmitButton = !firstSelected; //disable submit button if there is none selected + } + + function publishedVariantFilter(variant) { + //determine a variant is 'published' (meaning it will show up as able unpublish) + // * it has been published + // * it has been published with pending changes + return (variant.state === "Published" || variant.state === "PublishedPendingChanges"); + } + + function unpublishedVariantFilter(variant) { + //determine a variant is 'modified' (meaning it will NOT show up as able to unpublish) + // * it's editor is in a $dirty state + // * it is published with pending changes + return (variant.state !== "Published" && variant.state !== "PublishedPendingChanges"); + } + + //when this dialog is closed, reset all 'unpublish' flags + $scope.$on('$destroy', function () { + for (var i = 0; i < vm.variants.length; i++) { + vm.variants[i].unpublish = false; + } + }); + + onInit(); + + } + + angular.module("umbraco").controller("Umbraco.Overlays.UnpublishController", UnpublishController); + +})(); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html new file mode 100644 index 0000000000..5d7abe2f38 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html @@ -0,0 +1,69 @@ +
+ +
+

+
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ +
+
{{publishVariantSelectorForm.publishVariantSelector.errorMsg}}
+
+ +
+
{{notification.message}}
+
+ +
+
+ +
+
+
+
+ +
+
+

+
+ +
+
+
+ {{ variant.language.name }} + * +
+ +
+ +
+
+
+
+ +
+ \ No newline at end of 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 835bf6b884..65578cedeb 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -266,7 +266,9 @@ What languages would you like to publish? What languages would you like to save? What languages would you like to send for approval? + What languages would you like to unpublish? Published Languages + Unpublished Languages Unmodified Languages Ready to Publish? Ready to Save?