diff --git a/lib/content-services/src/lib/content-metadata/interfaces/property.interface.ts b/lib/content-services/src/lib/content-metadata/interfaces/property.interface.ts index 2d89e758d8d..a59afef4808 100644 --- a/lib/content-services/src/lib/content-metadata/interfaces/property.interface.ts +++ b/lib/content-services/src/lib/content-metadata/interfaces/property.interface.ts @@ -24,4 +24,8 @@ export interface Property { mandatory: boolean; multiValued: boolean; editable?: boolean; + protected?: boolean; + enforced?: boolean; + indexed?: boolean; + url?: string; } diff --git a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts index d3e15f4dfbf..46d7fa590de 100644 --- a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts @@ -168,6 +168,25 @@ describe('PropertyGroupTranslatorService', () => { const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0]; expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); }); + + it('should not edit the protected fields', () => { + property.name = 'FAKE:NAME'; + property.title = 'Fake Title'; + property.dataType = 'd:text'; + property.defaultValue = 'Fake value'; + property.protected = true; + propertyGroups.push({ + title: 'Fake Title', + properties: [property] + }); + + propertyValues = { 'FAKE:NAME': 'API Fake response' }; + + const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); + const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0]; + expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); + expect(cardViewProperty.editable).toBe(false); + }); }); describe('Different types attributes', () => { @@ -381,5 +400,26 @@ describe('PropertyGroupTranslatorService', () => { expect(cardViewProperty.value).toBe('default'); expect(cardViewProperty.key).toBe('properties.fk:brendonstare'); }); + + it('should not edit the protected fields', () => { + const propertyBase = { + 'id': 'fk:emperor', + 'title': 'Emperor', + 'description': 'is watching the dark emperor', + 'dataType': 'd:text', + 'isMultiValued': true, + 'isMandatory': true, + 'defaultValue': 'default', + 'isMandatoryEnforced': true, + 'isProtected': true + }; + + const cardViewProperty = service.translateProperty(propertyBase, null, true); + + expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); + expect(cardViewProperty.value).toBe('default'); + expect(cardViewProperty.key).toBe('properties.fk:emperor'); + expect(cardViewProperty.editable).toBe(false); + }); }); }); diff --git a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts index d91b4bda124..50164b62ef6 100644 --- a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts @@ -79,7 +79,7 @@ export class PropertyGroupTranslatorService { value: startValue ? startValue : property.defaultValue, key: `${prefix}${property.id}`, default: property.defaultValue, - editable: !!allowEditing ? allowEditing : false, + editable: property.isProtected ? false : allowEditing, constraints: property?.constraints }; @@ -107,7 +107,7 @@ export class PropertyGroupTranslatorService { value: propertyValue, key: `${prefix}${property.name}`, default: property.defaultValue, - editable: property.editable !== undefined ? property.editable : true, + editable: property.protected ? false : property.editable !== undefined ? property.editable : true, constraints: constraints };