Getting publish with descendants working
This commit is contained in:
@@ -392,6 +392,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
function moveNode(node, target) {
|
||||
|
||||
contentResource.move({ "parentId": target.id, "id": node.id })
|
||||
.then(function (path) {
|
||||
|
||||
// remove the node that we're working on
|
||||
if ($scope.page.menu.currentNode) {
|
||||
treeService.removeNode($scope.page.menu.currentNode);
|
||||
}
|
||||
|
||||
// sync the destination node
|
||||
if (!infiniteMode) {
|
||||
navigationService.syncTree({ tree: "content", path: path, forceReload: true, activate: false });
|
||||
}
|
||||
|
||||
$scope.page.buttonRestore = "success";
|
||||
notificationsService.success("Successfully restored " + node.name + " to " + target.name);
|
||||
|
||||
// reload the node
|
||||
loadContent();
|
||||
|
||||
}, function (err) {
|
||||
$scope.page.buttonRestore = "error";
|
||||
notificationsService.error("Cannot automatically restore this item", err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if ($scope.page.isNew) {
|
||||
|
||||
$scope.page.loading = true;
|
||||
@@ -711,7 +739,7 @@
|
||||
if (!isContentCultureVariant()) {
|
||||
//ensure the flags are set
|
||||
$scope.content.variants[0].save = true;
|
||||
//TODO: we'll prob want the publish flag(s) set here too for invariant?
|
||||
$scope.content.variants[0].publish = true;
|
||||
}
|
||||
|
||||
var dialog = {
|
||||
@@ -723,7 +751,33 @@
|
||||
submit: function (model) {
|
||||
model.submitButtonState = "busy";
|
||||
clearNotifications($scope.content);
|
||||
model.submitButtonState = "success";
|
||||
|
||||
//we need to return this promise so that the dialog can handle the result and wire up the validation response
|
||||
return performSave({
|
||||
saveMethod: function (content, create, files, showNotifications) {
|
||||
return contentResource.publishWithDescendants(content, create, model.includeUnpublished, files, showNotifications);
|
||||
},
|
||||
action: "publishDescendants",
|
||||
showNotifications: false
|
||||
}).then(function (data) {
|
||||
//show all notifications manually here since we disabled showing them automatically in the save method
|
||||
formHelper.showNotifications(data);
|
||||
clearNotifications($scope.content);
|
||||
overlayService.close();
|
||||
return $q.when(data);
|
||||
}, function (err) {
|
||||
clearDirtyState($scope.content.variants);
|
||||
//if this is invariant, show the notification errors, else they'll be shown inline with the variant
|
||||
if (!isContentCultureVariant()) {
|
||||
formHelper.showNotifications(err.data);
|
||||
}
|
||||
model.submitButtonState = "error";
|
||||
//re-map the dialog model since we've re-bound the properties
|
||||
dialog.variants = $scope.content.variants;
|
||||
//don't reject, we've handled the error
|
||||
return $q.when(err);
|
||||
});
|
||||
|
||||
},
|
||||
close: function () {
|
||||
overlayService.close();
|
||||
@@ -855,34 +909,6 @@
|
||||
createButtons($scope.content, app);
|
||||
};
|
||||
|
||||
function moveNode(node, target) {
|
||||
|
||||
contentResource.move({ "parentId": target.id, "id": node.id })
|
||||
.then(function (path) {
|
||||
|
||||
// remove the node that we're working on
|
||||
if ($scope.page.menu.currentNode) {
|
||||
treeService.removeNode($scope.page.menu.currentNode);
|
||||
}
|
||||
|
||||
// sync the destination node
|
||||
if (!infiniteMode) {
|
||||
navigationService.syncTree({ tree: "content", path: path, forceReload: true, activate: false });
|
||||
}
|
||||
|
||||
$scope.page.buttonRestore = "success";
|
||||
notificationsService.success("Successfully restored " + node.name + " to " + target.name);
|
||||
|
||||
// reload the node
|
||||
loadContent();
|
||||
|
||||
}, function (err) {
|
||||
$scope.page.buttonRestore = "error";
|
||||
notificationsService.error("Cannot automatically restore this item", err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// methods for infinite editing
|
||||
$scope.close = function () {
|
||||
if ($scope.infiniteModel.close) {
|
||||
|
||||
@@ -732,6 +732,18 @@ function contentResource($q, $http, $routeParams, umbDataFormatter, umbRequestHe
|
||||
return saveContentItem(content, "publish" + (isNew ? "New" : ""), files, endpoint, showNotifications);
|
||||
},
|
||||
|
||||
publishWithDescendants: function (content, isNew, force, files, showNotifications) {
|
||||
var endpoint = umbRequestHelper.getApiUrl(
|
||||
"contentApiBaseUrl",
|
||||
"PostSave");
|
||||
|
||||
var action = "publishWithDescendants";
|
||||
if (force === true) {
|
||||
action += "Force";
|
||||
}
|
||||
|
||||
return saveContentItem(content, action + (isNew ? "New" : ""), files, endpoint, showNotifications);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
var vm = this;
|
||||
|
||||
vm.changeSelection = changeSelection;
|
||||
vm.includeUnpublishedChanged = includeUnpublishedChanged;
|
||||
|
||||
function onInit() {
|
||||
|
||||
@@ -19,6 +20,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
_.each(vm.variants,
|
||||
function (variant) {
|
||||
variant.compositeId = (variant.language ? variant.language.culture : "inv") + "_" + (variant.segment ? variant.segment : "");
|
||||
variant.htmlId = "_content_variant_" + variant.compositeId;
|
||||
});
|
||||
|
||||
if (vm.variants.length > 1) {
|
||||
|
||||
//now sort it so that the current one is at the top
|
||||
@@ -32,9 +39,11 @@
|
||||
|
||||
if (active) {
|
||||
//ensure that the current one is selected
|
||||
active.publishDescendants = true;
|
||||
active.publish = true;
|
||||
active.save = true;
|
||||
}
|
||||
|
||||
$scope.model.disableSubmitButton = !canPublish();
|
||||
|
||||
} else {
|
||||
// localize help text for invariant content
|
||||
@@ -53,8 +62,20 @@
|
||||
var selected = [];
|
||||
for (var i = 0; i < vm.variants.length; i++) {
|
||||
var variant = vm.variants[i];
|
||||
if (variant.publishDescendants) {
|
||||
selected.push(variant.publishDescendants);
|
||||
|
||||
var published = !(variant.state === "NotCreated" || variant.state === "Draft");
|
||||
|
||||
if (variant.language.isMandatory && !published && !variant.publish) {
|
||||
//if a mandatory variant isn't published
|
||||
//and not flagged for saving
|
||||
//then we cannot continue
|
||||
|
||||
//TODO: Show a message when this occurs
|
||||
return false;
|
||||
}
|
||||
|
||||
if (variant.publish) {
|
||||
selected.push(variant.publish);
|
||||
}
|
||||
}
|
||||
return selected.length > 0;
|
||||
@@ -63,13 +84,13 @@
|
||||
function changeSelection(variant) {
|
||||
$scope.model.disableSubmitButton = !canPublish();
|
||||
//need to set the Save state to true if publish is true
|
||||
variant.save = variant.publishDescendants;
|
||||
variant.save = variant.publish;
|
||||
}
|
||||
|
||||
//when this dialog is closed, reset all 'publish' flags
|
||||
$scope.$on('$destroy', function () {
|
||||
for (var i = 0; i < vm.variants.length; i++) {
|
||||
vm.variants[i].publishDescendants = false;
|
||||
vm.variants[i].publish = false;
|
||||
vm.variants[i].save = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
ng-model="vm.includeUnpublished"
|
||||
style="margin-right: 8px;" />
|
||||
<localize key="content_includeUnpublished"></localize>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
ng-model="model.includeUnpublished"
|
||||
style="margin-right: 8px;" />
|
||||
<localize key="content_includeUnpublished"></localize>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -24,12 +23,11 @@
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
ng-model="vm.includeUnpublished"
|
||||
style="margin-right: 8px;" />
|
||||
<localize key="content_includeUnpublished"></localize>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
ng-model="model.includeUnpublished"
|
||||
style="margin-right: 8px;" />
|
||||
<localize key="content_includeUnpublished"></localize>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -43,12 +41,12 @@
|
||||
<ng-form name="publishVariantSelectorForm">
|
||||
<div class="flex">
|
||||
<input id="{{variant.htmlId}}"
|
||||
name="publishVariantSelector"
|
||||
type="checkbox"
|
||||
ng-model="variant.publishDescendants"
|
||||
ng-change="vm.changeSelection(variant)"
|
||||
style="margin-right: 8px;"
|
||||
val-server-field="{{variant.htmlId}}" />
|
||||
name="publishVariantSelector"
|
||||
type="checkbox"
|
||||
ng-model="variant.publish"
|
||||
ng-change="vm.changeSelection(variant)"
|
||||
style="margin-right: 8px;"
|
||||
val-server-field="{{variant.htmlId}}" />
|
||||
<div>
|
||||
<label for="{{variant.htmlId}}" style="margin-bottom: 0;">
|
||||
<span>{{ variant.language.name }}</span>
|
||||
|
||||
Reference in New Issue
Block a user