wip list view publish
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,47 @@
|
||||
<div ng-controller="Umbraco.Overlays.ListViewPublishController as vm">
|
||||
|
||||
<div ng-if="!vm.languages">
|
||||
Some content here
|
||||
</div>
|
||||
|
||||
<div ng-if="vm.languages.length > 1">
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<p><localize key="content_languagesToPublish"></localize></p>
|
||||
</div>
|
||||
|
||||
<div ng-if="vm.loading" style="min-height: 50px; position: relative;">
|
||||
<umb-load-indicator></umb-load-indicator>
|
||||
</div>
|
||||
|
||||
<div class="umb-list umb-list--condensed" ng-if="!vm.loading">
|
||||
|
||||
<div class="umb-list-item" ng-repeat="language in vm.languages">
|
||||
<ng-form name="publishVariantSelectorForm">
|
||||
<div class="flex">
|
||||
<input
|
||||
name="publishLanguageSelector"
|
||||
type="checkbox"
|
||||
ng-model="language.publish"
|
||||
ng-change="vm.changeSelection(language)"
|
||||
style="margin-right: 8px;" />
|
||||
<div>
|
||||
<label style="margin-bottom: 2px;">
|
||||
<span ng-class="{'bold': language.isDefault}">{{ language.name }}</span>
|
||||
</label>
|
||||
|
||||
<div class="umb-permission__description">
|
||||
<span ng-if="language.isMandatory"><localize key="languages_mandatoryLanguage"></localize></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user