[ACS-3359] Rename boolean fields in rule API. (#2672)

* [ACS-3359] Rename boolean fields in rule API.

* renamed some other fields

Co-authored-by: Tom Page <thomas.page@alfresco.com>
This commit is contained in:
Nikita Maliarchuk 2022-09-28 16:51:46 +02:00 committed by GitHub
parent f49e57f474
commit 4a6725133d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 61 deletions

View File

@ -33,8 +33,8 @@
"OUTBOUND": "Items are deleted or leave this folder" "OUTBOUND": "Items are deleted or leave this folder"
}, },
"OPTIONS": { "OPTIONS": {
"CASCADE": "Rule applies to subfolders", "IS_INHERITABLE": "Rule applies to subfolders",
"ASYNCHRONOUS": "Run rule in the background", "IS_ASYNCHRONOUS": "Run rule in the background",
"DISABLE_RULE": "Disable rule", "DISABLE_RULE": "Disable rule",
"ERROR_SCRIPT": "If errors occur run script", "ERROR_SCRIPT": "If errors occur run script",
"SELECT_ACTION": "Select action" "SELECT_ACTION": "Select action"

View File

@ -38,8 +38,8 @@ export const dummyResponse = {
{ {
entry: { entry: {
isShared: false, isShared: false,
cascade: false, isInheritable: false,
asynchronous: false, isAsynchronous: false,
name: 'rule1', name: 'rule1',
id: 'd388ed54-a522-410f-a158-6dbf5a833731', id: 'd388ed54-a522-410f-a158-6dbf5a833731',
triggers: ['inbound'], triggers: ['inbound'],
@ -53,14 +53,14 @@ export const dummyResponse = {
} }
} }
], ],
enabled: true isEnabled: true
} }
}, },
{ {
entry: { entry: {
isShared: false, isShared: false,
cascade: false, isInheritable: false,
asynchronous: false, isAsynchronous: false,
name: 'rule2', name: 'rule2',
id: 'e0e645ca-e6c0-47d4-9936-1a8872a6c30b', id: 'e0e645ca-e6c0-47d4-9936-1a8872a6c30b',
triggers: ['inbound'], triggers: ['inbound'],
@ -73,7 +73,7 @@ export const dummyResponse = {
} }
} }
], ],
enabled: true isEnabled: true
} }
} }
] ]
@ -85,9 +85,9 @@ export const dummyRules: Rule[] = [
id: 'd388ed54-a522-410f-a158-6dbf5a833731', id: 'd388ed54-a522-410f-a158-6dbf5a833731',
name: 'rule1', name: 'rule1',
description: '', description: '',
enabled: true, isEnabled: true,
cascade: false, isInheritable: false,
asynchronous: false, isAsynchronous: false,
errorScript: '', errorScript: '',
isShared: false, isShared: false,
triggers: ['inbound'], triggers: ['inbound'],
@ -112,9 +112,9 @@ export const dummyRules: Rule[] = [
id: 'e0e645ca-e6c0-47d4-9936-1a8872a6c30b', id: 'e0e645ca-e6c0-47d4-9936-1a8872a6c30b',
name: 'rule2', name: 'rule2',
description: '', description: '',
enabled: true, isEnabled: true,
cascade: false, isInheritable: false,
asynchronous: false, isAsynchronous: false,
errorScript: '', errorScript: '',
isShared: false, isShared: false,
triggers: ['inbound'], triggers: ['inbound'],

View File

@ -32,9 +32,9 @@ export interface Rule {
id: string; id: string;
name: string; name: string;
description: string; description: string;
enabled: boolean; isEnabled: boolean;
cascade: boolean; isInheritable: boolean;
asynchronous: boolean; isAsynchronous: boolean;
errorScript: string; errorScript: string;
isShared: boolean; isShared: boolean;
triggers: RuleTrigger[]; triggers: RuleTrigger[];

View File

@ -1,10 +1,10 @@
<div class="options-list" [formGroup]="form"> <div class="options-list" [formGroup]="form">
<div class="options-list__asynchronous"> <div class="options-list__asynchronous">
<mat-checkbox <mat-checkbox
formControlName="asynchronous" formControlName="isAsynchronous"
(change)="toggleScriptSelector()" (change)="toggleScriptSelector()"
[attr.data-automation-id]="'rule-option-checkbox-asynchronous'"> [attr.data-automation-id]="'rule-option-checkbox-asynchronous'">
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.ASYNCHRONOUS' | translate }} {{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.IS_ASYNCHRONOUS' | translate }}
</mat-checkbox> </mat-checkbox>
<div class="select-action" *ngIf="!preview"> <div class="select-action" *ngIf="!preview">
<span>{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.ERROR_SCRIPT' | translate}}:</span> <span>{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.ERROR_SCRIPT' | translate}}:</span>
@ -19,14 +19,14 @@
</div> </div>
<div class="options-list__rest"> <div class="options-list__rest">
<mat-checkbox <mat-checkbox
formControlName="cascade" formControlName="isInheritable"
[attr.data-automation-id]="'rule-option-checkbox-cascade'"> [attr.data-automation-id]="'rule-option-checkbox-inheritable'">
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.CASCADE' | translate }} {{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.IS_INHERITABLE' | translate }}
</mat-checkbox> </mat-checkbox>
<mat-checkbox <mat-checkbox
[attr.data-automation-id]="'rule-option-checkbox-enabled'" [attr.data-automation-id]="'rule-option-checkbox-enabled'"
[checked]="!form.value.enabled" *ngIf="!preview" [checked]="!form.value.isEnabled" *ngIf="!preview"
(change)="form.get('enabled').setValue(!$event.checked)"> (change)="form.get('isEnabled').setValue(!$event.checked)">
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.DISABLE_RULE' | translate }} {{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.DISABLE_RULE' | translate }}
</mat-checkbox> </mat-checkbox>
</div> </div>

View File

@ -56,9 +56,9 @@ describe('RuleOptionsUiComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
component.form = fb.group({ component.form = fb.group({
asynchronous: [false], isAsynchronous: [false],
cascade: [false], isInheritable: [false],
enabled: [true], isEnabled: [true],
errorScript: [''] errorScript: ['']
}); });
fixture.detectChanges(); fixture.detectChanges();
@ -68,7 +68,7 @@ describe('RuleOptionsUiComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
expect(getByDataAutomationId('rule-option-checkbox-asynchronous').componentInstance.checked).toBeFalsy(); expect(getByDataAutomationId('rule-option-checkbox-asynchronous').componentInstance.checked).toBeFalsy();
expect(getByDataAutomationId('rule-option-checkbox-cascade').componentInstance.checked).toBeFalsy(); expect(getByDataAutomationId('rule-option-checkbox-inheritable').componentInstance.checked).toBeFalsy();
expect(getByDataAutomationId('rule-option-checkbox-enabled').componentInstance.checked).toBeFalsy(); expect(getByDataAutomationId('rule-option-checkbox-enabled').componentInstance.checked).toBeFalsy();
expect(getByDataAutomationId('rule-option-select-errorScript').componentInstance.disabled).toBeTruthy(); expect(getByDataAutomationId('rule-option-select-errorScript').componentInstance.disabled).toBeTruthy();
}); });
@ -87,7 +87,7 @@ describe('RuleOptionsUiComponent', () => {
expect(getByDataAutomationId('rule-option-checkbox-asynchronous')).toBeTruthy(); expect(getByDataAutomationId('rule-option-checkbox-asynchronous')).toBeTruthy();
expect(getByDataAutomationId('rule-option-checkbox-asynchronous')).toBeTruthy(); expect(getByDataAutomationId('rule-option-checkbox-asynchronous')).toBeTruthy();
expect(getByDataAutomationId('rule-option-checkbox-cascade')).toBeTruthy(); expect(getByDataAutomationId('rule-option-checkbox-inheritable')).toBeTruthy();
expect(getByDataAutomationId('rule-option-checkbox-enabled')).toBeFalsy(); expect(getByDataAutomationId('rule-option-checkbox-enabled')).toBeFalsy();
expect(getByDataAutomationId('rule-option-select-errorScript')).toBeFalsy(); expect(getByDataAutomationId('rule-option-select-errorScript')).toBeFalsy();
}); });

View File

@ -42,9 +42,9 @@ describe('RuleDetailsUiComponent', () => {
name: 'Rule name', name: 'Rule name',
description: 'This is the description of the rule', description: 'This is the description of the rule',
triggers: ['update', 'outbound'], triggers: ['update', 'outbound'],
asynchronous: true, isAsynchronous: true,
cascade: true, isInheritable: true,
enabled: true isEnabled: true
}; };
const getHtmlElement = <T>(dataAutomationId: string) => const getHtmlElement = <T>(dataAutomationId: string) =>
@ -71,15 +71,15 @@ describe('RuleDetailsUiComponent', () => {
const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea'); const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea');
const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component'); const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component');
const ruleOptionAsynchronous = getComponentInstance<MatCheckbox>('rule-option-checkbox-asynchronous'); const ruleOptionAsynchronous = getComponentInstance<MatCheckbox>('rule-option-checkbox-asynchronous');
const ruleOptionCascade = getComponentInstance<MatCheckbox>('rule-option-checkbox-cascade'); const ruleOptionInheritable = getComponentInstance<MatCheckbox>('rule-option-checkbox-inheritable');
const ruleOptionDisabled = getComponentInstance<MatCheckbox>('rule-option-checkbox-enabled'); const ruleOptionDisabled = getComponentInstance<MatCheckbox>('rule-option-checkbox-enabled');
expect(nameInput.value).toBe(testValue.name); expect(nameInput.value).toBe(testValue.name);
expect(descriptionTextarea.value).toBe(testValue.description); expect(descriptionTextarea.value).toBe(testValue.description);
expect(ruleTriggersComponent.value).toEqual(testValue.triggers); expect(ruleTriggersComponent.value).toEqual(testValue.triggers);
expect(ruleOptionAsynchronous.checked).toBe(testValue.asynchronous); expect(ruleOptionAsynchronous.checked).toBe(testValue.isAsynchronous);
expect(ruleOptionCascade.checked).toBe(testValue.cascade); expect(ruleOptionInheritable.checked).toBe(testValue.isInheritable);
expect(ruleOptionDisabled.checked).toBe(!testValue.enabled); expect(ruleOptionDisabled.checked).toBe(!testValue.isEnabled);
}); });
it('should modify the form if the value input property is modified', () => { it('should modify the form if the value input property is modified', () => {
@ -107,14 +107,14 @@ describe('RuleDetailsUiComponent', () => {
const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea'); const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea');
const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component'); const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component');
const ruleOptionAsynchronous = getComponentInstance<MatCheckbox>('rule-option-checkbox-asynchronous'); const ruleOptionAsynchronous = getComponentInstance<MatCheckbox>('rule-option-checkbox-asynchronous');
const ruleOptionCascade = getComponentInstance<MatCheckbox>('rule-option-checkbox-cascade'); const ruleOptionInheritable = getComponentInstance<MatCheckbox>('rule-option-checkbox-inheritable');
const ruleOptionDisabled = getComponentInstance<MatCheckbox>('rule-option-checkbox-enabled'); const ruleOptionDisabled = getComponentInstance<MatCheckbox>('rule-option-checkbox-enabled');
expect(nameInput.disabled).toBeFalsy(); expect(nameInput.disabled).toBeFalsy();
expect(descriptionTextarea.disabled).toBeFalsy(); expect(descriptionTextarea.disabled).toBeFalsy();
expect(ruleTriggersComponent.readOnly).toBeFalsy(); expect(ruleTriggersComponent.readOnly).toBeFalsy();
expect(ruleOptionAsynchronous.disabled).toBeFalsy(); expect(ruleOptionAsynchronous.disabled).toBeFalsy();
expect(ruleOptionCascade.disabled).toBeFalsy(); expect(ruleOptionInheritable.disabled).toBeFalsy();
expect(ruleOptionDisabled.disabled).toBeFalsy(); expect(ruleOptionDisabled.disabled).toBeFalsy();
}); });
@ -126,12 +126,12 @@ describe('RuleDetailsUiComponent', () => {
const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea'); const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea');
const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component'); const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component');
const ruleOptionAsynchronous = getComponentInstance<MatCheckbox>('rule-option-checkbox-asynchronous'); const ruleOptionAsynchronous = getComponentInstance<MatCheckbox>('rule-option-checkbox-asynchronous');
const ruleOptionCascade = getComponentInstance<MatCheckbox>('rule-option-checkbox-cascade'); const ruleOptionInheritable = getComponentInstance<MatCheckbox>('rule-option-checkbox-inheritable');
expect(nameInput.disabled).toBeTruthy(); expect(nameInput.disabled).toBeTruthy();
expect(descriptionTextarea.disabled).toBeTruthy(); expect(descriptionTextarea.disabled).toBeTruthy();
expect(ruleTriggersComponent.readOnly).toBeTruthy(); expect(ruleTriggersComponent.readOnly).toBeTruthy();
expect(ruleOptionAsynchronous.disabled).toBeTruthy(); expect(ruleOptionAsynchronous.disabled).toBeTruthy();
expect(ruleOptionCascade.disabled).toBeTruthy(); expect(ruleOptionInheritable.disabled).toBeTruthy();
}); });
}); });

View File

@ -65,10 +65,10 @@ export class RuleDetailsUiComponent implements OnInit, OnDestroy {
description: newValue.description || FolderRulesService.emptyRule.description, description: newValue.description || FolderRulesService.emptyRule.description,
triggers: newValue.triggers || FolderRulesService.emptyRule.triggers, triggers: newValue.triggers || FolderRulesService.emptyRule.triggers,
conditions: newValue.conditions || FolderRulesService.emptyRule.conditions, conditions: newValue.conditions || FolderRulesService.emptyRule.conditions,
asynchronous: newValue.asynchronous || FolderRulesService.emptyRule.asynchronous, isAsynchronous: newValue.isAsynchronous || FolderRulesService.emptyRule.isAsynchronous,
errorScript: newValue.errorScript || FolderRulesService.emptyRule.errorScript, errorScript: newValue.errorScript || FolderRulesService.emptyRule.errorScript,
cascade: newValue.cascade || FolderRulesService.emptyRule.cascade, isInheritable: newValue.isInheritable || FolderRulesService.emptyRule.isInheritable,
enabled: newValue.enabled || FolderRulesService.emptyRule.enabled isEnabled: newValue.isEnabled || FolderRulesService.emptyRule.isEnabled
}; };
if (this.form) { if (this.form) {
this.form.setValue(newValue); this.form.setValue(newValue);
@ -99,17 +99,17 @@ export class RuleDetailsUiComponent implements OnInit, OnDestroy {
get conditions(): UntypedFormControl { get conditions(): UntypedFormControl {
return this.form.get('conditions') as UntypedFormControl; return this.form.get('conditions') as UntypedFormControl;
} }
get asynchronous(): UntypedFormControl { get isAsynchronous(): UntypedFormControl {
return this.form.get('asynchronous') as UntypedFormControl; return this.form.get('isAsynchronous') as UntypedFormControl;
} }
get errorScript(): UntypedFormControl { get errorScript(): UntypedFormControl {
return this.form.get('errorScript') as UntypedFormControl; return this.form.get('errorScript') as UntypedFormControl;
} }
get cascade(): UntypedFormControl { get isInheritable(): UntypedFormControl {
return this.form.get('cascade') as UntypedFormControl; return this.form.get('isInheritable') as UntypedFormControl;
} }
get enabled(): UntypedFormControl { get isEnabled(): UntypedFormControl {
return this.form.get('enabled') as UntypedFormControl; return this.form.get('isEnabled') as UntypedFormControl;
} }
ngOnInit() { ngOnInit() {
@ -126,10 +126,10 @@ export class RuleDetailsUiComponent implements OnInit, OnDestroy {
}, },
ruleCompositeConditionValidator() ruleCompositeConditionValidator()
), ),
asynchronous: new UntypedFormControl(this.value.asynchronous), isAsynchronous: new UntypedFormControl(this.value.isAsynchronous),
errorScript: new UntypedFormControl(this.value.errorScript), errorScript: new UntypedFormControl(this.value.errorScript),
cascade: new UntypedFormControl(this.value.cascade), isInheritable: new UntypedFormControl(this.value.isInheritable),
enabled: new UntypedFormControl(this.value.enabled) isEnabled: new UntypedFormControl(this.value.isEnabled)
}); });
this.readOnly = this._readOnly; this.readOnly = this._readOnly;

View File

@ -2,7 +2,7 @@
<div class="rule-info"> <div class="rule-info">
<div class="rule-info__header"> <div class="rule-info__header">
<span class="rule-info__header__title">{{rule.name}}</span> <span class="rule-info__header__title">{{rule.name}}</span>
<mat-slide-toggle [(ngModel)]="rule.enabled" (click)="onToggleClick(!rule.enabled)"></mat-slide-toggle> <mat-slide-toggle [(ngModel)]="rule.isEnabled" (click)="onToggleClick(!rule.isEnabled)"></mat-slide-toggle>
</div> </div>
<p>{{rule.description}}</p> <p>{{rule.description}}</p>
</div> </div>

View File

@ -39,7 +39,7 @@ export class RuleListItemUiComponent {
constructor(private folderRulesService: FolderRulesService) {} constructor(private folderRulesService: FolderRulesService) {}
onToggleClick(enabled: boolean) { onToggleClick(isEnabled: boolean) {
this.folderRulesService.toggleRule(this.nodeId, this.rule.id, { ...this.rule, enabled }); this.folderRulesService.toggleRule(this.nodeId, this.rule.id, { ...this.rule, isEnabled });
} }
} }

View File

@ -52,9 +52,9 @@ export class FolderRulesService {
id: '', id: '',
name: '', name: '',
description: '', description: '',
enabled: true, isEnabled: true,
cascade: false, isInheritable: false,
asynchronous: false, isAsynchronous: false,
errorScript: '', errorScript: '',
isShared: false, isShared: false,
triggers: ['inbound'], triggers: ['inbound'],
@ -170,9 +170,9 @@ export class FolderRulesService {
id: obj.id, id: obj.id,
name: obj.name ?? FolderRulesService.emptyRule.name, name: obj.name ?? FolderRulesService.emptyRule.name,
description: obj.description ?? FolderRulesService.emptyRule.description, description: obj.description ?? FolderRulesService.emptyRule.description,
enabled: obj.enabled ?? FolderRulesService.emptyRule.enabled, isEnabled: obj.isEnabled ?? FolderRulesService.emptyRule.isEnabled,
cascade: obj.cascade ?? FolderRulesService.emptyRule.cascade, isInheritable: obj.isInheritable ?? FolderRulesService.emptyRule.isInheritable,
asynchronous: obj.asynchronous ?? FolderRulesService.emptyRule.asynchronous, isAsynchronous: obj.isAsynchronous ?? FolderRulesService.emptyRule.isAsynchronous,
errorScript: obj.errorScript ?? FolderRulesService.emptyRule.errorScript, errorScript: obj.errorScript ?? FolderRulesService.emptyRule.errorScript,
isShared: obj.isShared ?? FolderRulesService.emptyRule.isShared, isShared: obj.isShared ?? FolderRulesService.emptyRule.isShared,
triggers: obj.triggers ?? FolderRulesService.emptyRule.triggers, triggers: obj.triggers ?? FolderRulesService.emptyRule.triggers,