diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js index a3d9229b12..b3e6640fff 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js @@ -402,7 +402,7 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs const dialog = { view: "views/propertyeditors/listview/overlays/listviewpublish.html", - submitButtonLabel: "Publish", + submitButtonLabelKey: "actions_publish", submit: function (model) { console.log(model); //console.log(model.languages); @@ -454,6 +454,49 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs } $scope.unpublish = function () { + + let variesByCulture = false; + + const dialog = { + view: "views/propertyeditors/listview/overlays/listviewunpublish.html", + submitButtonLabelKey: "actions_unpublish", + submit: function (model) { + console.log(model); + //console.log(model.languages); + performUnpublish(); + overlayService.close(); + }, + close: function () { + overlayService.close(); + } + }; + + // check if any of the selected nodes has variants + $scope.selection.forEach(selectedItem => { + $scope.listViewResultSet.items.forEach(resultItem => { + if((selectedItem.id === resultItem.id || selectedItem.key === resultItem.key) && resultItem.variesByCulture) { + variesByCulture = true; + } + }) + }); + + // if any of the selected nodes has variants we want to + // show a dialog where the languages can be chosen + if(variesByCulture) { + languageResource.getAll() + .then(languages => { + dialog.languages = languages; + overlayService.open(dialog); + }, error => { + console.log(error); + }); + } else { + overlayService.open(dialog); + } + + }; + + function performUnpublish() { applySelected( function (selected, index) { return contentResource.unpublish(getIdCallback(selected[index])); }, function (count, total) { @@ -464,7 +507,7 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs var key = (total === 1 ? "bulk_unpublishedItem" : "bulk_unpublishedItems"); return localizationService.localize(key, [total]); }); - }; + } $scope.move = function () { var move = { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.controller.js new file mode 100644 index 0000000000..b6a236700e --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.controller.js @@ -0,0 +1,77 @@ +(function () { + "use strict"; + + function ListViewUnpublishController($scope, $routeParams, localizationService) { + + var vm = this; + vm.loading = true; + + vm.changeSelection = changeSelection; + + function changeSelection(language) { + + // disable submit button if nothing is selected + var firstSelected = _.find(vm.languages, function (language) { + return language.unpublish; + }); + + $scope.model.disableSubmitButton = !firstSelected; + + //need to set the Save state to true if publish is true + language.save = language.unpublish; + } + + function onInit() { + + vm.languages = $scope.model.languages; + + if (!$scope.model.title) { + localizationService.localize("content_unpublish").then(function (value) { + $scope.model.title = value; + }); + } + + // node has variants + if (vm.languages && vm.languages.length > 0) { + + var culture = $routeParams.cculture ? $routeParams.cculture : $routeParams.mculture; + + if(culture) { + + // sort languages so the active on is on top + vm.languages = _.sortBy(vm.languages, function (language) { + return language.culture === culture ? 0 : 1; + }); + + var active = _.find(vm.languages, function (language) { + return language.culture === culture; + }); + + if (active) { + //ensure that the current one is selected + active.unpublish = true; + } + + } + } + + vm.loading = false; + + } + + onInit(); + + //when this dialog is closed, reset all 'publish' flags + $scope.$on('$destroy', function () { + if(vm.languages && vm.languages.length > 0) { + for (var i = 0; i < vm.languages.length; i++) { + vm.languages[i].unpublish = false; + vm.languages[i].save = false; + } + } + }); + } + + angular.module("umbraco").controller("Umbraco.Overlays.ListViewUnpublishController", ListViewUnpublishController); + +})(); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html new file mode 100644 index 0000000000..4ea6edb1c0 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html @@ -0,0 +1,47 @@ +
+ + +
+

+
+ + +
+ +
+

+
+ +
+ +
+ +
+ +
+ + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ \ No newline at end of file