Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to configure Segmentation #7973

Merged
merged 119 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
10bf55d
Backoffice support for viewing segments
PerplexDaniel Aug 29, 2019
9e60654
Support for saving edited segment values
PerplexDaniel Oct 11, 2019
318a511
Improve support for invariant properties in combination with segments
PerplexDaniel Aug 30, 2019
73ddba5
Show segment name in switcher.
PerplexDaniel Aug 30, 2019
f11f4c0
Show segment name in Publish dialog
PerplexDaniel Aug 30, 2019
5fcfaac
Added variantHelper for methods used in various places
PerplexDaniel Aug 30, 2019
99d8d3f
Fixes current variant display name
PerplexDaniel Aug 30, 2019
6f78e87
Segment display name nu capitalized versie van alias
PerplexDaniel Aug 30, 2019
1889aef
Merge branch 'v8/dev' of https://github.com/umbraco/Umbraco-CMS into …
PerplexDaniel Nov 22, 2019
5246e53
Merge remote-tracking branch 'PerplexDaniel/feature/backoffice-segmen…
nielslyngsoe Jan 22, 2020
686e1be
Apply segments for validation, client side.
nielslyngsoe Jan 22, 2020
5acca8c
adding missing segment argument
nielslyngsoe Jan 22, 2020
4a028ed
renaming getCultureCallbacks to getVariantCallbacks, for segment supp…
nielslyngsoe Jan 22, 2020
109d9e1
implement segment support
nielslyngsoe Jan 23, 2020
30be926
Refactorying of umb-editor, splitview, variants
nielslyngsoe Jan 23, 2020
58adb42
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Jan 23, 2020
f302b37
basic tests for segments validation
nielslyngsoe Jan 23, 2020
d4d7425
Refactoring part 2 of umb-editor, splitview, variants.
nielslyngsoe Jan 23, 2020
2f2fc72
correct binding
nielslyngsoe Jan 23, 2020
9215575
remove comment
nielslyngsoe Jan 23, 2020
3672048
clean up
nielslyngsoe Jan 23, 2020
535b762
reverting these lines from refactoring process
nielslyngsoe Jan 23, 2020
e02624b
remove spaces
nielslyngsoe Jan 23, 2020
03b05a0
clean up
nielslyngsoe Jan 23, 2020
133bec9
remove space
nielslyngsoe Jan 23, 2020
f2edd96
Remove this part until we see the need for this
nielslyngsoe Jan 23, 2020
ba6c5a4
rename variantHelper to contentVariantUtilities
nielslyngsoe Jan 23, 2020
b8ded53
revert to content
nielslyngsoe Jan 23, 2020
0b8cffa
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Jan 24, 2020
0180b9d
fixing broken style
nielslyngsoe Jan 24, 2020
6ab0548
use umb-outline for focus outline
nielslyngsoe Jan 24, 2020
abd8b3a
one way binding
nielslyngsoe Jan 24, 2020
b2ef64c
still have a copy of apps for each variant, but just create it when i…
nielslyngsoe Jan 24, 2020
8efa973
sync active app in variants
nielslyngsoe Jan 27, 2020
9df2711
enforce the content content-app in split view mode.
nielslyngsoe Jan 27, 2020
7fcd598
restructure data for variant picker
nielslyngsoe Jan 29, 2020
0c08613
display segments in variant picker
nielslyngsoe Jan 29, 2020
3152b35
removed .umb-variant-switcher from editor.less into its own file.
nielslyngsoe Jan 29, 2020
f1eab70
adding colors: pinkExtraLight + gray-12 + @gray-13
nielslyngsoe Jan 29, 2020
039025f
Merge branch 'v8/feature/UI-even-more-light-pink' into v8/feature/AB4…
nielslyngsoe Jan 29, 2020
555be8d
first part of enabling allow segments
nielslyngsoe Feb 6, 2020
60b46e4
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Feb 7, 2020
a49af7a
convert to hex color code
nielslyngsoe Feb 7, 2020
aed0a09
indentation of border for variant that are in not-created state
nielslyngsoe Feb 7, 2020
c9621ca
comment change
nielslyngsoe Feb 7, 2020
61ed880
ups
nielslyngsoe Feb 10, 2020
21ea8e3
show split-view on focus
nielslyngsoe Feb 10, 2020
124bc27
V8/feature/ab4550 segments ui variant picker (#7614)
PerplexDaniel Feb 10, 2020
1f2b293
focus styling
nielslyngsoe Feb 10, 2020
87b9642
Merge branch 'v8/feature/AB4550-segments-clientcode' into v8/feature/…
nielslyngsoe Feb 10, 2020
0b73096
get and set AllowSegmentVariant
nielslyngsoe Feb 10, 2020
de11eba
adjusted color slightly
nielslyngsoe Feb 10, 2020
0265b54
Merge remote-tracking branch 'origin/v8/feature/UI-even-more-light-pi…
nielslyngsoe Feb 10, 2020
5acf6b2
event handler for requesting a splitview
nielslyngsoe Feb 13, 2020
b83ef4d
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Feb 13, 2020
cac07aa
option to require umbVariantContentEditors and do a requestSplitView
nielslyngsoe Feb 13, 2020
1a4e6e5
Review Perplex change for Segments (#7659)
PerplexDaniel Feb 14, 2020
5a5291d
V8/feature/ab4550 segments ui variant picker (#7676)
PerplexDaniel Feb 18, 2020
12bb2a4
ContentVariantDisplay: add DisplayName property and use in Umbr… (#7677)
PerplexDaniel Feb 18, 2020
cac745f
segment before language in GetDisplayName
nielslyngsoe Feb 18, 2020
2cd5082
adjustments of Save and publish dialog
nielslyngsoe Feb 19, 2020
6e22b03
Merge remote-tracking branch 'origin/v8/feature/umb-form-check-transc…
nielslyngsoe Feb 19, 2020
490ce08
Save & publish dialog change for a simpler experience accommodating s…
nielslyngsoe Feb 19, 2020
4e68785
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Feb 19, 2020
99ad8ea
apply search params instead of overwritting them.
nielslyngsoe Feb 19, 2020
1855241
Merge remote-tracking branch 'origin/v8/feature/AB4550-segments-clien…
nielslyngsoe Feb 19, 2020
602ee33
use "and" instead of &
nielslyngsoe Feb 19, 2020
27b239c
making variant dialogs up to date with Segments.
nielslyngsoe Feb 19, 2020
dcdeae9
only pure language variants can be mandatory
nielslyngsoe Feb 19, 2020
510ecf5
update save dialogs
nielslyngsoe Feb 20, 2020
3e402f9
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Feb 20, 2020
92aabf6
use right ids
nielslyngsoe Feb 20, 2020
d4dae19
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Mar 11, 2020
57e9a90
ServerVariable for showAllowSegmentationForDocumentTypes
nielslyngsoe Mar 11, 2020
0e8591c
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Apr 16, 2020
90b4d55
Adds a segment level validation key + updates tests
Shazwazza Apr 17, 2020
291d516
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB4550-s…
nielslyngsoe Apr 17, 2020
1a69d5a
Merge remote-tracking branch 'origin/v8/feature/AB4550-segments-clien…
nielslyngsoe Apr 17, 2020
678ceba
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB6057-s…
nielslyngsoe Apr 27, 2020
0b2785b
use right variable with null correction
nielslyngsoe Apr 27, 2020
a501ef1
spelling mistake corrected
nielslyngsoe Apr 28, 2020
af10bd7
default variant would never have segment. And if we work only with se…
nielslyngsoe Apr 28, 2020
92f0de3
use displayName instead of language name
nielslyngsoe Apr 28, 2020
a8f2acd
more robust variant-picker
nielslyngsoe Apr 28, 2020
2c5456a
Merge branch 'v8/feature/AB6057-segment-feature-corrections' into v8/…
nielslyngsoe Apr 28, 2020
f689bea
revert removing methods
nielslyngsoe Apr 28, 2020
96dd7e4
avoid breaking change of serverValidationManager.subscribe()
nielslyngsoe Apr 28, 2020
ab0b091
avoid breaking change of serverValidationManager.unsubscribe()
nielslyngsoe Apr 28, 2020
d39827a
avoid breaking change of serverValidationManager.getPropertyCallbacks
nielslyngsoe Apr 28, 2020
4b8f29a
avoid breaking change of serverValidationManager.addPropertyError
nielslyngsoe Apr 28, 2020
6a5a338
avoid breaking change of serverValidationManager.addPropertyError and…
nielslyngsoe Apr 28, 2020
370981e
avoid breaking change of serverValidationManager.getPropertyError()
nielslyngsoe Apr 28, 2020
a8bcf28
avoid breaking change of serverValidationManager.hasPropertyError()
nielslyngsoe Apr 28, 2020
7f42974
reworked ensuring activeApp
nielslyngsoe Apr 28, 2020
ea2f8fe
fixes sort of variants problem
nielslyngsoe Apr 29, 2020
03fc9ca
use Utilities for copy
nielslyngsoe Apr 29, 2020
42f9466
replace angular.forEach with native forEach
nielslyngsoe Apr 29, 2020
97f7ff5
ups, removes ,
nielslyngsoe Apr 29, 2020
329b9fe
Have compositId and htmlId available always for content
nielslyngsoe Apr 29, 2020
50ef099
remove console.log
nielslyngsoe Apr 29, 2020
01c8102
parse allowSegmentVariant on
nielslyngsoe Apr 29, 2020
87a22bd
pick tabs from variant content, not the node content model.
nielslyngsoe Apr 29, 2020
9bce66c
Adds AllowSegmentVariation on the Doctype to be peristed
Apr 29, 2020
9b7afd7
Merge branch 'v8/feature/AB6057-segment-feature' of https://github.co…
Apr 29, 2020
d9f25d0
do not showAllowSegmentationForDocumentTypes pr default
nielslyngsoe Apr 29, 2020
0bb6564
should use _ to align with server feedback in modelState
nielslyngsoe Apr 30, 2020
641332d
Merge remote-tracking branch 'origin/v8/dev' into v8/feature/AB6057-s…
nielslyngsoe May 1, 2020
2b5f3ee
correcting test to parse segment attribute
nielslyngsoe May 1, 2020
871e50e
variant validation error test
nielslyngsoe May 1, 2020
b992830
correct spelling mistake
nielslyngsoe May 1, 2020
0ef7bdd
if varaints, only show URLs that are equal to the current viewing cul…
nielslyngsoe May 1, 2020
c060cd3
rename variantNodeModel to contentNodeModel
nielslyngsoe May 1, 2020
138f38d
added some description to bindings
nielslyngsoe May 1, 2020
ef56d9c
revert change title
nielslyngsoe May 1, 2020
3e65d21
always have the empty fallback function
nielslyngsoe May 1, 2020
eec4000
make sure that validation indication in variant-picker only stays as …
nielslyngsoe May 5, 2020
d761658
remove console.log
nielslyngsoe May 5, 2020
a2fe48d
Merge pull request #8064 from umbraco/v8/bugfix/7964-fix-validation-i…
May 5, 2020
1320191
remove console.error
nielslyngsoe May 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ public static IEnumerable<PropertyDataDto> BuildDtos(ContentVariation contentVar
// publishing = deal with edit and published values
foreach (var propertyValue in property.Values)
{
var isInvariantValue = propertyValue.Culture == null;
var isCultureValue = propertyValue.Culture != null && propertyValue.Segment == null;
var isInvariantValue = propertyValue.Culture == null && propertyValue.Segment == null;
var isCultureValue = propertyValue.Culture != null;
var isSegmentValue = propertyValue.Segment != null;

// deal with published value
if (propertyValue.PublishedValue != null && publishedVersionId > 0)
if ((propertyValue.PublishedValue != null || isSegmentValue) && publishedVersionId > 0)
propertyDataDtos.Add(BuildDto(publishedVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.PublishedValue));

// deal with edit value
if (propertyValue.EditedValue != null)
if (propertyValue.EditedValue != null || isSegmentValue)
propertyDataDtos.Add(BuildDto(currentVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.EditedValue));

// property.Values will contain ALL of it's values, both variant and invariant which will be populated if the
Expand Down
54 changes: 51 additions & 3 deletions src/Umbraco.Tests/Web/ModelStateExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Add_Invariant_Property_Error()

ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", null); //invariant property

Assert.AreEqual("_Properties.headerImage.invariant", ms.Keys.First());
Assert.AreEqual("_Properties.headerImage.invariant.null", ms.Keys.First());
}

[Test]
Expand All @@ -73,9 +73,57 @@ public void Add_Variant_Property_Error()
var localizationService = new Mock<ILocalizationService>();
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");

ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", "en-US"); //invariant property
ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", "en-US"); //variant property

Assert.AreEqual("_Properties.headerImage.en-US", ms.Keys.First());
Assert.AreEqual("_Properties.headerImage.en-US.null", ms.Keys.First());
}

[Test]
public void Add_Invariant_Segment_Property_Error()
{
var ms = new ModelStateDictionary();
var localizationService = new Mock<ILocalizationService>();
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");

ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", null, "mySegment"); //invariant/segment property

Assert.AreEqual("_Properties.headerImage.invariant.mySegment", ms.Keys.First());
}

[Test]
public void Add_Variant_Segment_Property_Error()
{
var ms = new ModelStateDictionary();
var localizationService = new Mock<ILocalizationService>();
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");

ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", "en-US", "mySegment"); //variant/segment property

Assert.AreEqual("_Properties.headerImage.en-US.mySegment", ms.Keys.First());
}

[Test]
public void Add_Invariant_Segment_Field_Property_Error()
{
var ms = new ModelStateDictionary();
var localizationService = new Mock<ILocalizationService>();
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");

ms.AddPropertyError(new ValidationResult("no header image", new[] { "myField" }), "headerImage", null, "mySegment"); //invariant/segment property

Assert.AreEqual("_Properties.headerImage.invariant.mySegment.myField", ms.Keys.First());
}

[Test]
public void Add_Variant_Segment_Field_Property_Error()
{
var ms = new ModelStateDictionary();
var localizationService = new Mock<ILocalizationService>();
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");

ms.AddPropertyError(new ValidationResult("no header image", new[] { "myField" }), "headerImage", "en-US", "mySegment"); //variant/segment property

Assert.AreEqual("_Properties.headerImage.en-US.mySegment.myField", ms.Keys.First());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$scope.page.hideActionsMenu = infiniteMode ? true : false;
$scope.page.hideChangeVariant = false;
$scope.allowOpen = true;
$scope.app = null;
$scope.activeApp = null;

//initializes any watches
function startWatches(content) {
Expand Down Expand Up @@ -74,31 +74,23 @@
var isAppPresent = false;

// on first init, we dont have any apps. but if we are re-initializing, we do, but ...
if ($scope.app) {
if ($scope.activeApp) {

// lets check if it still exists as part of our apps array. (if not we have made a change to our docType, even just a re-save of the docType it will turn into new Apps.)
_.forEach(content.apps, function (app) {
if (app === $scope.app) {
if (app.alias === $scope.activeApp.alias) {
isAppPresent = true;
$scope.appChanged(app);
}
});

// if we did reload our DocType, but still have the same app we will try to find it by the alias.
if (isAppPresent === false) {
_.forEach(content.apps, function (app) {
if (app.alias === $scope.app.alias) {
isAppPresent = true;
app.active = true;
$scope.appChanged(app);
}
});
// active app does not exist anymore.
$scope.activeApp = null;
}

}

// if we still dont have a app, lets show the first one:
if (isAppPresent === false && content.apps.length) {
content.apps[0].active = true;
if ($scope.activeApp === null && content.apps.length) {
$scope.appChanged(content.apps[0]);
}
// otherwise make sure the save options are up to date with the current content state
Expand Down Expand Up @@ -151,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() {
Expand Down Expand Up @@ -215,6 +207,13 @@
}));
}

function appendRuntimeData() {
$scope.content.variants.forEach((variant) => {
variant.compositeId = contentEditingHelper.buildCompositeVariantId(variant);
variant.htmlId = "_content_variant_" + variant.compositeId;
});
}

/**
* This does the content loading and initializes everything, called on first load
*/
Expand All @@ -226,6 +225,7 @@

$scope.content = data;

appendRuntimeData();
init();

syncTreeNode($scope.content, $scope.content.path, true);
Expand All @@ -251,6 +251,7 @@

$scope.content = data;

appendRuntimeData();
init();
startWatches($scope.content);

Expand All @@ -274,7 +275,7 @@
$scope.page.saveButtonStyle = content.trashed || content.isElement || content.isBlueprint ? "primary" : "info";
// only create the save/publish/preview buttons if the
// content app is "Conent"
if ($scope.app && $scope.app.alias !== "umbContent" && $scope.app.alias !== "umbInfo" && $scope.app.alias !== "umbListView") {
if ($scope.activeApp && $scope.activeApp.alias !== "umbContent" && $scope.activeApp.alias !== "umbInfo" && $scope.activeApp.alias !== "umbListView") {
$scope.defaultButton = null;
$scope.subButtons = null;
$scope.page.showSaveButton = false;
Expand Down Expand Up @@ -589,7 +590,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" })) {

Expand Down Expand Up @@ -649,7 +650,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 = {
Expand Down Expand Up @@ -711,7 +712,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" })) {

Expand Down Expand Up @@ -776,7 +777,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;
}
Expand Down Expand Up @@ -813,7 +814,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";
Expand All @@ -840,7 +841,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;
Expand Down Expand Up @@ -873,7 +874,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";
Expand Down Expand Up @@ -963,11 +964,18 @@
* Call back when a content app changes
* @param {any} app
*/
$scope.appChanged = function (app) {

$scope.app = app;
$scope.appChanged = function (activeApp) {

$scope.activeApp = activeApp;

_.forEach($scope.content.apps, function (app) {
app.active = false;
if (app.alias === $scope.activeApp.alias) {
app.active = true;
}
});

$scope.$broadcast("editors.apps.appChanged", { app: app });
$scope.$broadcast("editors.apps.appChanged", { app: activeApp });

createButtons($scope.content);

Expand Down Expand Up @@ -1029,6 +1037,7 @@
getMethod: "&",
getScaffoldMethod: "&?",
culture: "=?",
segment: "=?",
infiniteModel: "=?"
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
// find the urls for the currently selected language
if (scope.node.variants.length > 1) {
// nodes with variants
scope.currentUrls = _.filter(scope.node.urls, (url) => scope.currentVariant.language.culture === url.culture);
scope.currentUrls = _.filter(scope.node.urls, (url) => (scope.currentVariant.language && scope.currentVariant.language.culture === url.culture));
} else {
// invariant nodes
scope.currentUrls = scope.node.urls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** This directive is used to render out the current variant tabs and properties and exposes an API for other directives to consume */
function tabbedContentDirective($timeout) {

function link($scope, $element, $attrs) {
function link($scope, $element) {

var appRootNode = $element[0];

Expand Down Expand Up @@ -115,21 +115,18 @@

}

function controller($scope, $element, $attrs) {

function controller($scope) {

//expose the property/methods for other directives to use
this.content = $scope.content;
this.activeVariant = _.find(this.content.variants, variant => {
return variant.active;
});

$scope.activeVariant = this.activeVariant;

$scope.defaultVariant = _.find(this.content.variants, variant => {
return variant.language.isDefault;
});


if($scope.contentNodeModel) {
$scope.defaultVariant = _.find($scope.contentNodeModel.variants, variant => {
// defaultVariant will never have segment. Wether it has a language or not depends on the setup.
return !variant.segment && ((variant.language && variant.language.isDefault) || (!variant.language));
});
}

$scope.unlockInvariantValue = function(property) {
property.unlockInvariantValue = !property.unlockInvariantValue;
};
Expand All @@ -141,6 +138,24 @@
}
}
);

$scope.propertyEditorDisabled = function (property) {
if (property.unlockInvariantValue) {
return false;
}

var contentLanguage = $scope.content.language;

var canEditCulture = !contentLanguage ||
// If the property culture equals the content culture it can be edited
property.culture === contentLanguage.culture ||
// A culture-invariant property can only be edited by the default language variant
(property.culture == null && contentLanguage.isDefault);

var canEditSegment = property.segment === $scope.content.segment;

return !canEditCulture || !canEditSegment;
}
}

var directive = {
Expand All @@ -150,7 +165,8 @@
controller: controller,
link: link,
scope: {
content: "="
content: "=", // in this context the content is the variant model.
contentNodeModel: "=?" //contentNodeModel is the content model for the node,
}
};

Expand Down
Loading