mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5231] The protected flag for properties should not be editable (#7056)
This commit is contained in:
@@ -24,4 +24,8 @@ export interface Property {
|
||||
mandatory: boolean;
|
||||
multiValued: boolean;
|
||||
editable?: boolean;
|
||||
protected?: boolean;
|
||||
enforced?: boolean;
|
||||
indexed?: boolean;
|
||||
url?: string;
|
||||
}
|
||||
|
@@ -168,6 +168,25 @@ describe('PropertyGroupTranslatorService', () => {
|
||||
const cardViewProperty: CardViewTextItemModel = <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 = <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 = <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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -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
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user