gets unpublish working
This commit is contained in:
@@ -177,7 +177,7 @@
|
||||
methods: {
|
||||
saveAndPublish: $scope.saveAndPublish,
|
||||
sendToPublish: $scope.sendToPublish,
|
||||
unPublish: $scope.unPublish
|
||||
unpublish: $scope.unpublish
|
||||
}
|
||||
});
|
||||
|
||||
@@ -334,7 +334,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
$scope.unPublish = function() {
|
||||
$scope.unpublish = function() {
|
||||
clearNotifications($scope.content);
|
||||
if (formHelper.submitForm({ scope: $scope, action: "unpublish", skipValidation: true })) {
|
||||
var dialog = {
|
||||
@@ -342,23 +342,18 @@
|
||||
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",
|
||||
submitButtonLabelKey: "content_unpublish",
|
||||
submit: function (model) {
|
||||
|
||||
model.submitButtonState = "busy";
|
||||
|
||||
var selectedVariants = _.filter(model.variants, function(variant) { return variant.unpublish; });
|
||||
var selectedVariants = _.filter(model.variants, function(variant) { return variant.save; });
|
||||
var culturesForUnpublishing = _.map(selectedVariants, function(variant) { return variant.language.culture; });
|
||||
|
||||
/* TODO: the end point need to handle an array of cultures
|
||||
contentResource.unPublish($scope.content.id, culture)
|
||||
contentResource.unpublish($scope.content.id, culturesForUnpublishing)
|
||||
.then(function (data) {
|
||||
formHelper.resetForm({ scope: $scope });
|
||||
contentEditingHelper.handleSuccessfulSave({
|
||||
scope: $scope,
|
||||
savedContent: data,
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data)
|
||||
});
|
||||
contentEditingHelper.reBindChangedProperties($scope.content, data);
|
||||
init($scope.content);
|
||||
syncTreeNode($scope.content, data.path);
|
||||
$scope.page.buttonGroupState = "success";
|
||||
@@ -367,7 +362,7 @@
|
||||
}, function (err) {
|
||||
$scope.page.buttonGroupState = 'error';
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
},
|
||||
close: function () {
|
||||
@@ -377,55 +372,7 @@
|
||||
overlayService.open(dialog);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
$scope.unPublish = function () {
|
||||
|
||||
//if there's any variants than we need to set the language and include the variants to publish
|
||||
var culture = null;
|
||||
if ($scope.content.variants.length > 0) {
|
||||
_.each($scope.content.variants,
|
||||
function (d) {
|
||||
//set the culture if this is active
|
||||
if (d.active === true) {
|
||||
culture = d.language.culture;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (formHelper.submitForm({ scope: $scope, skipValidation: true })) {
|
||||
|
||||
$scope.page.buttonGroupState = "busy";
|
||||
|
||||
eventsService.emit("content.unpublishing", { content: $scope.content });
|
||||
|
||||
contentResource.unPublish($scope.content.id, culture)
|
||||
.then(function (data) {
|
||||
|
||||
formHelper.resetForm({ scope: $scope });
|
||||
|
||||
contentEditingHelper.handleSuccessfulSave({
|
||||
scope: $scope,
|
||||
savedContent: data,
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data)
|
||||
});
|
||||
|
||||
init($scope.content);
|
||||
|
||||
syncTreeNode($scope.content, data.path);
|
||||
|
||||
$scope.page.buttonGroupState = "success";
|
||||
|
||||
eventsService.emit("content.unpublished", { content: $scope.content });
|
||||
|
||||
}, function (err) {
|
||||
$scope.page.buttonGroupState = 'error';
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
$scope.sendToPublish = function () {
|
||||
clearNotifications($scope.content);
|
||||
if (showSaveOrPublishDialog()) {
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
case "Publish":
|
||||
item.logTypeColor = "success";
|
||||
break;
|
||||
case "UnPublish":
|
||||
case "Unpublish":
|
||||
case "Delete":
|
||||
item.logTypeColor = "danger";
|
||||
break;
|
||||
|
||||
@@ -145,7 +145,7 @@ angular.module('umbraco.mocks').
|
||||
"content_statistics": "Statistics",
|
||||
"content_titleOptional": "Title (optional)",
|
||||
"content_type": "Type",
|
||||
"content_unPublish": "Unpublish",
|
||||
"content_unpublish": "Unpublish",
|
||||
"content_updateDate": "Last edited",
|
||||
"content_updateDateDesc": "Date/time this document was created",
|
||||
"content_uploadClear": "Remove file",
|
||||
|
||||
@@ -206,7 +206,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.resources.contentResource#unPublish
|
||||
* @name umbraco.resources.contentResource#unpublish
|
||||
* @methodOf umbraco.resources.contentResource
|
||||
*
|
||||
* @description
|
||||
@@ -214,7 +214,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
*
|
||||
* ##usage
|
||||
* <pre>
|
||||
* contentResource.unPublish(1234)
|
||||
* contentResource.unpublish(1234)
|
||||
* .then(function() {
|
||||
* alert("node was unpulished");
|
||||
* }, function(err){
|
||||
@@ -225,21 +225,20 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
* @returns {Promise} resourcePromise object.
|
||||
*
|
||||
*/
|
||||
unPublish: function (id, culture) {
|
||||
unpublish: function (id, cultures) {
|
||||
if (!id) {
|
||||
throw "id cannot be null";
|
||||
}
|
||||
|
||||
if (!culture) {
|
||||
culture = null;
|
||||
if (!cultures) {
|
||||
cultures = [];
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"contentApiBaseUrl",
|
||||
"PostUnPublish",
|
||||
{ id: id, culture: culture })),
|
||||
"PostUnpublish"), { id: id, cultures: cultures }),
|
||||
'Failed to publish content with id ' + id);
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -146,7 +146,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
if (!args.methods) {
|
||||
throw "args.methods is not defined";
|
||||
}
|
||||
if (!args.methods.saveAndPublish || !args.methods.sendToPublish || !args.methods.unPublish) {
|
||||
if (!args.methods.saveAndPublish || !args.methods.sendToPublish || !args.methods.unpublish) {
|
||||
throw "args.methods does not contain all required defined methods";
|
||||
}
|
||||
|
||||
@@ -183,8 +183,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
//unpublish
|
||||
return {
|
||||
letter: ch,
|
||||
labelKey: "content_unPublish",
|
||||
handler: args.methods.unPublish,
|
||||
labelKey: "content_unpublish",
|
||||
handler: args.methods.unpublish,
|
||||
hotKey: "ctrl+u",
|
||||
hotKeyWhenHidden: true,
|
||||
alias: "unpublish",
|
||||
@@ -403,8 +403,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
case "Z":
|
||||
return {
|
||||
letter: ch,
|
||||
labelKey: "content_unPublish",
|
||||
handler: "unPublish"
|
||||
labelKey: "content_unpublish",
|
||||
handler: "unpublish"
|
||||
};
|
||||
|
||||
default:
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
<div>
|
||||
<label for="{{variant.htmlId}}" style="margin-bottom: 2px;">
|
||||
<span>{{ variant.language.name }}</span>
|
||||
<strong ng-if="variant.language.isMandatory" class="umb-control-required">*</strong>
|
||||
</label>
|
||||
|
||||
<div ng-if="!publishVariantSelectorForm.publishVariantSelector.$invalid && !(variant.notifications && variant.notifications.length > 0)">
|
||||
<umb-variant-state class="umb-permission__description" variant="variant"></umb-variant-state>
|
||||
<umb-variant-state variant="variant"></umb-variant-state>
|
||||
<span ng-if="variant.language.isMandatory"> - <localize key="languages_mandatoryLanguage"></localize></span>
|
||||
</div>
|
||||
|
||||
<div ng-messages="publishVariantSelectorForm.publishVariantSelector.$error" show-validation-on-submit>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// set dialog title
|
||||
if (!$scope.model.title) {
|
||||
localizationService.localize("content_unPublish").then(function (value) {
|
||||
localizationService.localize("content_unpublish").then(function (value) {
|
||||
$scope.model.title = value;
|
||||
});
|
||||
}
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
if (active) {
|
||||
//ensure that the current one is selected
|
||||
active.unpublish = true;
|
||||
active.save = true;
|
||||
}
|
||||
|
||||
// autoselect other variants if needed
|
||||
@@ -47,20 +47,20 @@
|
||||
|
||||
// disable submit button if nothing is selected
|
||||
var firstSelected = _.find(vm.variants, function (v) {
|
||||
return v.unpublish;
|
||||
return v.save;
|
||||
});
|
||||
$scope.model.disableSubmitButton = !firstSelected; //disable submit button if there is none selected
|
||||
|
||||
// if a mandatory variant is selected we want to selet all other variants
|
||||
// and disable selection for the others
|
||||
if(selectedVariant.unpublish && selectedVariant.language.isMandatory) {
|
||||
if(selectedVariant.save && selectedVariant.language.isMandatory) {
|
||||
|
||||
angular.forEach(vm.variants, function(variant){
|
||||
if(!variant.unpublish && publishedVariantFilter(variant)) {
|
||||
if(!variant.save && publishedVariantFilter(variant)) {
|
||||
// keep track of the variants we automaically select
|
||||
// so we can remove the selection again
|
||||
autoSelectedVariants.push(variant.language.culture);
|
||||
variant.unpublish = true;
|
||||
variant.save = true;
|
||||
}
|
||||
variant.disabled = true;
|
||||
});
|
||||
@@ -73,13 +73,13 @@
|
||||
// if a mandatory variant is deselected we want to deselet all the variants
|
||||
// that was automatically selected so it goes back to the state before the mandatory language was selected.
|
||||
// We also want to enable all checkboxes again
|
||||
if(!selectedVariant.unpublish && selectedVariant.language.isMandatory) {
|
||||
if(!selectedVariant.save && selectedVariant.language.isMandatory) {
|
||||
|
||||
angular.forEach(vm.variants, function(variant){
|
||||
|
||||
// check if variant was auto selected, then deselect
|
||||
if(_.contains(autoSelectedVariants, variant.language.culture)) {
|
||||
variant.unpublish = false;
|
||||
variant.save = false;
|
||||
};
|
||||
|
||||
variant.disabled = false;
|
||||
@@ -106,7 +106,7 @@
|
||||
//when this dialog is closed, remove all unpublish and disabled flags
|
||||
$scope.$on('$destroy', function () {
|
||||
for (var i = 0; i < vm.variants.length; i++) {
|
||||
vm.variants[i].unpublish = false;
|
||||
vm.variants[i].save = false;
|
||||
vm.variants[i].disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<input id="{{variant.htmlId}}"
|
||||
name="unpublishVariantSelector"
|
||||
type="checkbox"
|
||||
ng-model="variant.unpublish"
|
||||
ng-model="variant.save"
|
||||
ng-change="vm.changeSelection(variant)"
|
||||
ng-disabled="variant.disabled"
|
||||
style="margin-right: 8px;"
|
||||
@@ -63,4 +63,4 @@
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -411,7 +411,7 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs
|
||||
|
||||
$scope.unpublish = function () {
|
||||
applySelected(
|
||||
function (selected, index) { return contentResource.unPublish(getIdCallback(selected[index])); },
|
||||
function (selected, index) { return contentResource.unpublish(getIdCallback(selected[index])); },
|
||||
function (count, total) {
|
||||
var key = (total === 1 ? "bulk_unpublishedItemOfItem" : "bulk_unpublishedItemOfItems");
|
||||
return localizationService.localize(key, [count, total]);
|
||||
|
||||
Reference in New Issue
Block a user