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 @@ +