mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
improved settings api (#1408)
This commit is contained in:
parent
3ee61c3d29
commit
785b7abb8a
@ -627,6 +627,16 @@
|
||||
"type": "array",
|
||||
"items": { "$ref": "#/definitions/settingsGroupParameterRef" },
|
||||
"minItems": 1
|
||||
},
|
||||
"rules": {
|
||||
"description": "Element rules",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"visible": {
|
||||
"description": "Rule to evaluate the visibility state",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["id", "name", "parameters"]
|
||||
|
@ -65,7 +65,7 @@ export class SettingsComponent implements OnInit {
|
||||
headerColor$: Observable<string>;
|
||||
|
||||
get settingGroups(): SettingsGroupRef[] {
|
||||
return this.appExtensions.settingGroups;
|
||||
return this.appExtensions.getSettingsGroups();
|
||||
}
|
||||
|
||||
constructor(
|
||||
@ -136,7 +136,9 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
setParamValue(param: SettingsParameterRef, value: any) {
|
||||
if (param.value !== value) {
|
||||
const currentValue = this.getStringParamValue(param);
|
||||
|
||||
if (currentValue !== value.toString()) {
|
||||
param.value = value;
|
||||
this.saveToStorage(param);
|
||||
}
|
||||
|
@ -507,6 +507,10 @@ export class AppExtensionService implements RuleContext {
|
||||
.sort(sortByOrder);
|
||||
}
|
||||
|
||||
getSettingsGroups(): Array<SettingsGroupRef> {
|
||||
return this.settingGroups.filter(group => this.filterVisible(group));
|
||||
}
|
||||
|
||||
copyAction(action: ContentActionRef): ContentActionRef {
|
||||
return {
|
||||
...action,
|
||||
@ -514,7 +518,7 @@ export class AppExtensionService implements RuleContext {
|
||||
};
|
||||
}
|
||||
|
||||
filterVisible(action: ContentActionRef): boolean {
|
||||
filterVisible(action: ContentActionRef | SettingsGroupRef): boolean {
|
||||
if (action && action.rules && action.rules.visible) {
|
||||
return this.extensions.evaluateRule(action.rules.visible, this);
|
||||
}
|
||||
|
@ -27,6 +27,10 @@ export interface SettingsGroupRef {
|
||||
id: string;
|
||||
name: string;
|
||||
parameters: Array<SettingsParameterRef>;
|
||||
rules?: {
|
||||
visible?: string;
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SettingsParameterRef {
|
||||
|
@ -32,7 +32,10 @@
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"visible": "user.isAdmin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extensions.ps.settings",
|
||||
@ -44,7 +47,10 @@
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"visible": "user.isAdmin"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user