diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
index 5e8b0447cb..1e0eb1ee1a 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
@@ -143,8 +143,8 @@
}
/** Returns true if the content item varies by culture */
- function isContentCultureVariant() {
- return $scope.content.variants.length > 1;
+ function hasVariants(content) {
+ return content.variants.length > 1;
}
function reload() {
@@ -216,6 +216,11 @@
return $scope.getMethod()($scope.contentId)
.then(function (data) {
+ data.variants.forEach((variant) => {
+ variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
+ variant.htmlId = "_content_variant_" + variant.compositeId;
+ });
+
$scope.content = data;
init();
@@ -581,7 +586,7 @@
$scope.sendToPublish = function () {
clearNotifications($scope.content);
- if (isContentCultureVariant()) {
+ if (hasVariants($scope.content)) {
//before we launch the dialog we want to execute all client side validations first
if (formHelper.submitForm({ scope: $scope, action: "publish" })) {
@@ -641,7 +646,7 @@
$scope.saveAndPublish = function () {
clearNotifications($scope.content);
- if (isContentCultureVariant()) {
+ if (hasVariants($scope.content)) {
//before we launch the dialog we want to execute all client side validations first
if (formHelper.submitForm({ scope: $scope, action: "publish" })) {
var dialog = {
@@ -703,7 +708,7 @@
$scope.save = function () {
clearNotifications($scope.content);
// TODO: Add "..." to save button label if there are more than one variant to publish - currently it just adds the elipses if there's more than 1 variant
- if (isContentCultureVariant()) {
+ if (hasVariants($scope.content)) {
//before we launch the dialog we want to execute all client side validations first
if (formHelper.submitForm({ scope: $scope, action: "openSaveDialog" })) {
@@ -768,7 +773,7 @@
clearNotifications($scope.content);
//before we launch the dialog we want to execute all client side validations first
if (formHelper.submitForm({ scope: $scope, action: "schedule" })) {
- if (!isContentCultureVariant()) {
+ if (!hasVariants($scope.content)) {
//ensure the flags are set
$scope.content.variants[0].save = true;
}
@@ -805,7 +810,7 @@
}, 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()) {
+ if (!hasVariants($scope.content)) {
formHelper.showNotifications(err.data);
}
model.submitButtonState = "error";
@@ -832,7 +837,7 @@
//before we launch the dialog we want to execute all client side validations first
if (formHelper.submitForm({ scope: $scope, action: "publishDescendants" })) {
- if (!isContentCultureVariant()) {
+ if (!hasVariants($scope.content)) {
//ensure the flags are set
$scope.content.variants[0].save = true;
$scope.content.variants[0].publish = true;
@@ -865,7 +870,7 @@
}, 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()) {
+ if (!hasVariants($scope.content)) {
formHelper.showNotifications(err.data);
}
model.submitButtonState = "error";
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js
index b9d83ae597..3e701f0c79 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js
@@ -20,7 +20,7 @@
controller: umbVariantContentEditorsController
};
- function umbVariantContentEditorsController($scope, $location) {
+ function umbVariantContentEditorsController($scope, $location, contentEditingHelper) {
var prevContentDateUpdated = null;
@@ -59,8 +59,7 @@
if (changes.culture && !changes.culture.isFirstChange() && changes.culture.currentValue !== changes.culture.previousValue) {
setActiveVariant();
- }
- if (changes.segment && !changes.segment.isFirstChange() && changes.segment.currentValue !== changes.segment.previousValue) {
+ } else if (changes.segment && !changes.segment.isFirstChange() && changes.segment.currentValue !== changes.segment.previousValue) {
setActiveVariant();
}
}
@@ -86,7 +85,7 @@
// set the active variant
var activeVariant = null;
_.each(vm.content.variants, function (v) {
- if ((!v.language || v.language.culture === vm.culture) && v.segment === vm.segment) {
+ if ((vm.culture === "invariant" || v.language && v.language.culture === vm.culture) && v.segment === vm.segment) {
activeVariant = v;
}
});
@@ -119,6 +118,10 @@
function insertVariantEditor(index, variant) {
if (vm.editors[index]) {
+ if (vm.editors[index].content === variant) {
+ console.error("This editor is already in this place.");
+ return;
+ }
vm.editors[index].content.active = false;
}
variant.active = true;
@@ -126,28 +129,27 @@
var variantCulture = variant.language ? variant.language.culture : "invariant";
var variantSegment = variant.segment;
- //check if the culture at the index is the same, if it's null an editor will be added
- var currentCulture = vm.editors.length === 0 || vm.editors.length <= index ? null : vm.editors[index].culture;
- //check if the segment at the index is the same, if it's null an editor will be added
- var currentSegment = vm.editors.length === 0 || vm.editors.length <= index ? null : vm.editors[index].segment;
-
+ var currentCulture = index < vm.editors.length ? vm.editors[index].culture : null;
+ var currentSegment = index < vm.editors.length ? vm.editors[index].segment : null;
- if (currentCulture !== variantCulture || currentSegment !== variantSegment) {
+ // if index not already exists or if the culture or segment isnt identical then we do a replacement.
+ if (index >= vm.editors.length || currentCulture !== variantCulture || currentSegment !== variantSegment) {
- //Not the current culture which means we need to modify the array.
+ //Not the current culture or segment which means we need to modify the array.
//NOTE: It is not good enough to just replace the `content` object at a given index in the array
// since that would mean that directives are not re-initialized.
vm.editors.splice(index, 1, {
+ compositeId: variant.compositeId,
content: variant,
- //used for "track-by" ng-repeat
culture: variantCulture,
segment: variantSegment
});
}
else {
- //replace the editor for the same culture
+ //replace the content of the editor, since the cultura and segment is the same.
vm.editors[index].content = variant;
}
+
}
/**
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js
index 8f2aa1d22b..8cbca33436 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js
@@ -330,7 +330,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
* Returns a id for the variant that is unique between all variants on the content
*/
buildCompositeVariantId: function (variant) {
- return (variant.language ? variant.language.culture : "invariant") + "_" + (variant.segment ? variant.segment : "");
+ return (variant.language ? variant.language.culture : "invariant") + "." + (variant.segment ? variant.segment : "");
},
diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html
index 61860f1855..247453c604 100644
--- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html
+++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content-editors.html
@@ -1,6 +1,6 @@
+ ng-repeat="editor in vm.editors track by editor.compositeId">
{
- variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
- variant.htmlId = "_content_variant_" + variant.compositeId;
// if this is a new node and we have data on this variant.
if(vm.isNew === true && hasAnyDataFilter(variant)) {
@@ -133,7 +131,7 @@
});
if (vm.availableVariants.length !== 0) {
- vm.availableVariants = vm.availableVariants.sort(function (a, b) {
+ vm.availableVariants.sort(function (a, b) {
if (a.language && b.language) {
if (a.language.name > b.language.name) {
return -1;
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.controller.js
index a13ab56e62..095c4f3fe1 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.controller.js
@@ -14,6 +14,7 @@
function onInit() {
vm.variants = $scope.model.variants;
+ vm.displayVariants = vm.variants.slice(0);// shallow copy, we dont want to share the array-object(because we will be performing a sort method) but each entry should be shared (because we need validation and notifications).
vm.labels = {};
if (!$scope.model.title) {
@@ -23,15 +24,12 @@
}
_.each(vm.variants, function (variant) {
- variant.compositeId = (variant.language ? variant.language.culture : "inv") + "_" + (variant.segment ? variant.segment : "");
- variant.htmlId = "_content_variant_" + variant.compositeId;
-
variant.isMandatory = isMandatoryFilter(variant);
});
if (vm.variants.length > 1) {
- vm.variants = vm.variants.sort(function (a, b) {
+ vm.displayVariants.sort(function (a, b) {
if (a.language && b.language) {
if (a.language.name > b.language.name) {
return -1;
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html
index 03ff9f9825..92373d00ff 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html
@@ -1,6 +1,6 @@
-
+
-
+
@@ -33,7 +33,7 @@
-
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js
index 2d5c679815..2d40005618 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js
@@ -9,7 +9,6 @@
vm.isNew = true;
vm.changeSelection = changeSelection;
- vm.dirtyVariantFilter = dirtyVariantFilter;
function changeSelection(variant) {
var firstSelected = _.find(vm.variants, function (v) {
@@ -18,7 +17,7 @@
$scope.model.disableSubmitButton = !firstSelected; //disable submit button if there is none selected
}
- function dirtyVariantFilter(variant) {
+ function saveableVariantFilter(variant) {
//determine a variant is 'dirty' (meaning it will show up as save-able) if it's
// * the active one
// * it's editor is in a $dirty state
@@ -58,6 +57,7 @@
function onInit() {
vm.variants = $scope.model.variants;
+ vm.availableVariants = vm.variants.filter(saveableVariantFilter);
if(!$scope.model.title) {
localizationService.localize("content_readyToSave").then(function(value){
@@ -81,17 +81,21 @@
_.each(vm.variants,
function (variant) {
- variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
- variant.htmlId = "_content_variant_" + variant.compositeId;
-
if(vm.isNew && hasAnyData(variant)){
variant.save = true;
}
});
if (vm.variants.length !== 0) {
-
- vm.variants = vm.variants.sort(function (a, b) {
+
+ _.find(vm.variants, function (v) {
+ if(v.active) {
+ //ensure that the current one is selected
+ v.save = true;
+ }
+ });
+
+ vm.availableVariants.sort(function (a, b) {
if (a.language && b.language) {
if (a.language.name > b.language.name) {
return -1;
@@ -111,13 +115,6 @@
return 0;
});
- _.find(vm.variants, function (v) {
- if(v.active) {
- //ensure that the current one is selected
- v.save = true;
- }
- });
-
} else {
//disable save button if we have nothing to save
$scope.model.disableSubmitButton = true;
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html
index 72aa6b9430..dd6e96df95 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html
@@ -14,7 +14,7 @@
+ ng-repeat="variant in vm.availableVariants track by variant.compositeId">
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.controller.js
index 5e2955950b..e7f31ac707 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.controller.js
@@ -23,6 +23,7 @@
function onInit() {
vm.variants = $scope.model.variants;
+ vm.displayVariants = vm.variants.slice(0);// shallow copy, we dont want to share the array-object(because we will be performing a sort method) but each entry should be shared (because we need validation and notifications).
for (let i = 0; i < vm.variants.length; i++) {
origDates.push({
@@ -38,9 +39,6 @@
}
_.each(vm.variants, function (variant) {
- variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
- variant.htmlId = "_content_variant_" + variant.compositeId;
-
variant.isMandatory = isMandatoryFilter(variant);
});
@@ -49,7 +47,7 @@
// so we have to check for length > 1
if (vm.variants.length > 1) {
- vm.variants = vm.variants.sort(function (a, b) {
+ vm.displayVariants.sort(function (a, b) {
if (a.language && b.language) {
if (a.language.name > b.language.name) {
return -1;
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html
index 8f59c79718..8f515a10e4 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html
@@ -84,7 +84,7 @@
-
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.controller.js
index e11b651c23..f425dce4a3 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.controller.js
@@ -20,9 +20,6 @@
}
_.each(vm.variants, function (variant) {
- variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
- variant.htmlId = "_content_variant_" + variant.compositeId;
-
variant.isMandatory = isMandatoryFilter(variant);
});
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html
index 1c5667ed5b..91fa1799fc 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html
@@ -10,7 +10,7 @@
-
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js
index 1349880ba4..81762d45e9 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.controller.js
@@ -7,11 +7,11 @@
var autoSelectedVariants = [];
vm.changeSelection = changeSelection;
- vm.publishedVariantFilter = publishedVariantFilter;
function onInit() {
vm.variants = $scope.model.variants;
+ vm.unpublishableVariants = vm.variants.filter(publishedVariantFilter)
// set dialog title
if (!$scope.model.title) {
@@ -21,16 +21,13 @@
}
_.each(vm.variants, function (variant) {
- variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
- variant.htmlId = "_content_variant_" + variant.compositeId;
-
variant.isMandatory = isMandatoryFilter(variant);
});
// node has variants
if (vm.variants.length !== 1) {
- vm.variants = vm.variants.sort(function (a, b) {
+ vm.unpublishableVariants.sort(function (a, b) {
if (a.language && b.language) {
if (a.language.name > b.language.name) {
return -1;
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html
index a02ad5b659..94dd9fdac5 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html
@@ -13,7 +13,7 @@