From 888c08b56bc56b1735506eef255545a64d3e70eb Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 1 Nov 2018 14:44:12 +0100 Subject: [PATCH] wip list view publish --- .../listview/listview.controller.js | 48 ++++++++++++++++++- .../overlays/listviewpublish.controller.js | 45 +++++++++++++++++ .../listview/overlays/listviewpublish.html | 47 ++++++++++++++++++ 3 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html 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 2f845abd27..a3d9229b12 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 @@ -1,4 +1,4 @@ -function listViewController($scope, $routeParams, $injector, $timeout, currentUserResource, notificationsService, iconHelper, editorState, localizationService, appState, mediaResource, listViewHelper, navigationService, editorService) { +function listViewController($scope, $routeParams, $injector, $timeout, currentUserResource, notificationsService, iconHelper, editorState, localizationService, appState, mediaResource, listViewHelper, navigationService, editorService, overlayService, languageResource) { //this is a quick check to see if we're in create mode, if so just exit - we cannot show children for content // that isn't created yet, if we continue this will use the parent id in the route params which isn't what @@ -397,6 +397,50 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs }; $scope.publish = function () { + + let variesByCulture = false; + + const dialog = { + view: "views/propertyeditors/listview/overlays/listviewpublish.html", + submitButtonLabel: "Publish", + submit: function (model) { + console.log(model); + //console.log(model.languages); + performPublish(); + 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 performPublish() { + console.log("perform publish"); applySelected( function (selected, index) { return contentResource.publishById(getIdCallback(selected[index])); }, function (count, total) { @@ -407,7 +451,7 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs var key = (total === 1 ? "bulk_publishedItem" : "bulk_publishedItems"); return localizationService.localize(key, [total]); }); - }; + } $scope.unpublish = function () { applySelected( diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.controller.js new file mode 100644 index 0000000000..33ffb82b5f --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.controller.js @@ -0,0 +1,45 @@ +(function () { + "use strict"; + + function ListViewPublishController($scope, localizationService) { + + var vm = this; + vm.loading = true; + + vm.changeSelection = changeSelection; + + function changeSelection(language) { + //need to set the Save state to true if publish is true + language.save = language.publish; + } + + function onInit() { + + vm.languages = $scope.model.languages; + + if (!$scope.model.title) { + localizationService.localize("content_readyToPublish").then(function (value) { + $scope.model.title = value; + }); + } + + 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].publish = false; + vm.languages[i].save = false; + } + } + }); + } + + angular.module("umbraco").controller("Umbraco.Overlays.ListViewPublishController", ListViewPublishController); + +})(); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html new file mode 100644 index 0000000000..8347aeb2a4 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html @@ -0,0 +1,47 @@ +
+ +
+ Some content here +
+ +
+ +
+

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