Merge remote-tracking branch 'origin/v8/feature/AB4550-segments-clientcode' into v8/feature/AB6057-segment-feature
This commit is contained in:
@@ -159,9 +159,16 @@ function formHelper(angularHelper, serverValidationManager, notificationsService
|
||||
//the alias in model state can be in dot notation which indicates
|
||||
// * the first part is the content property alias
|
||||
// * the second part is the field to which the valiation msg is associated with
|
||||
//There will always be at least 3 parts for content properties since all model errors for properties are prefixed with "_Properties"
|
||||
//There will always be at least 4 parts for content properties since all model errors for properties are prefixed with "_Properties"
|
||||
//If it is not prefixed with "_Properties" that means the error is for a field of the object directly.
|
||||
|
||||
// Example: "_Properties.headerImage.en-US.mySegment.myField"
|
||||
// * it's for a property since it has a _Properties prefix
|
||||
// * it's for the headerImage property type
|
||||
// * it's for the en-US culture
|
||||
// * it's for the mySegment segment
|
||||
// * it's for the myField html field (optional)
|
||||
|
||||
var parts = e.split(".");
|
||||
|
||||
//Check if this is for content properties - specific to content/media/member editors because those are special
|
||||
@@ -179,21 +186,20 @@ function formHelper(angularHelper, serverValidationManager, notificationsService
|
||||
}
|
||||
}
|
||||
|
||||
var htmlFieldReference = "";
|
||||
if (parts.length > 3) {
|
||||
htmlFieldReference = parts[3] || "";
|
||||
}
|
||||
|
||||
// SEGMENTS_TODO: Need to investigate wether we have updated validation to handle segments, plus could it be the third parameter, so we leave the HTML Field ref as optional and last?
|
||||
var segment = null;
|
||||
if (parts.length > 4) {
|
||||
segment = parts[4];
|
||||
if (parts.length > 3) {
|
||||
segment = parts[3];
|
||||
//special check in case the string is formatted this way
|
||||
if (segment === "null") {
|
||||
segment = null;
|
||||
}
|
||||
}
|
||||
|
||||
var htmlFieldReference = "";
|
||||
if (parts.length > 4) {
|
||||
htmlFieldReference = parts[4] || "";
|
||||
}
|
||||
|
||||
// add a generic error for the property
|
||||
serverValidationManager.addPropertyError(propertyAlias, culture, segment, htmlFieldReference, modelState[e][0]);
|
||||
|
||||
|
||||
@@ -121,13 +121,15 @@ describe('contentEditingHelper tests', function () {
|
||||
|
||||
//act
|
||||
//note the null, that's because culture is null
|
||||
formHelper.handleServerValidation({ "_Properties.bodyText.null.value": ["Required"] });
|
||||
formHelper.handleServerValidation({ "_Properties.bodyText.null.null.value": ["Required"] });
|
||||
|
||||
//assert
|
||||
expect(serverValidationManager.items.length).toBe(1);
|
||||
expect(serverValidationManager.items[0].fieldName).toBe("value");
|
||||
expect(serverValidationManager.items[0].errorMsg).toBe("Required");
|
||||
expect(serverValidationManager.items[0].propertyAlias).toBe("bodyText");
|
||||
expect(serverValidationManager.items[0].culture).toBe("invariant");
|
||||
expect(serverValidationManager.items[0].segment).toBeNull();
|
||||
});
|
||||
|
||||
it('adds a multiple property and field level server validation errors when they are invalid', function () {
|
||||
@@ -142,7 +144,7 @@ describe('contentEditingHelper tests', function () {
|
||||
"Name": ["Required"],
|
||||
"UpdateDate": ["Invalid date"],
|
||||
//note the null, that's because culture is null
|
||||
"_Properties.bodyText.null.value": ["Required field"],
|
||||
"_Properties.bodyText.en-US.mySegment.value": ["Required field"],
|
||||
"_Properties.textarea": ["Invalid format"]
|
||||
});
|
||||
|
||||
@@ -157,6 +159,8 @@ describe('contentEditingHelper tests', function () {
|
||||
expect(serverValidationManager.items[2].fieldName).toBe("value");
|
||||
expect(serverValidationManager.items[2].errorMsg).toBe("Required field");
|
||||
expect(serverValidationManager.items[2].propertyAlias).toBe("bodyText");
|
||||
expect(serverValidationManager.items[2].culture).toBe("en-US");
|
||||
expect(serverValidationManager.items[2].segment).toBe("mySegment");
|
||||
expect(serverValidationManager.items[3].fieldName).toBe("");
|
||||
expect(serverValidationManager.items[3].errorMsg).toBe("Invalid format");
|
||||
expect(serverValidationManager.items[3].propertyAlias).toBe("textarea");
|
||||
|
||||
Reference in New Issue
Block a user