[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"
},
"OPTIONS": {
"CASCADE": "Rule applies to subfolders",
"ASYNCHRONOUS": "Run rule in the background",
"IS_INHERITABLE": "Rule applies to subfolders",
"IS_ASYNCHRONOUS": "Run rule in the background",
"DISABLE_RULE": "Disable rule",
"ERROR_SCRIPT": "If errors occur run script",
"SELECT_ACTION": "Select action"

View File

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

View File

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

View File

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

View File

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

View File

@ -42,9 +42,9 @@ describe('RuleDetailsUiComponent', () => {
name: 'Rule name',
description: 'This is the description of the rule',
triggers: ['update', 'outbound'],
asynchronous: true,
cascade: true,
enabled: true
isAsynchronous: true,
isInheritable: true,
isEnabled: true
};
const getHtmlElement = <T>(dataAutomationId: string) =>
@ -71,15 +71,15 @@ describe('RuleDetailsUiComponent', () => {
const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea');
const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component');
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');
expect(nameInput.value).toBe(testValue.name);
expect(descriptionTextarea.value).toBe(testValue.description);
expect(ruleTriggersComponent.value).toEqual(testValue.triggers);
expect(ruleOptionAsynchronous.checked).toBe(testValue.asynchronous);
expect(ruleOptionCascade.checked).toBe(testValue.cascade);
expect(ruleOptionDisabled.checked).toBe(!testValue.enabled);
expect(ruleOptionAsynchronous.checked).toBe(testValue.isAsynchronous);
expect(ruleOptionInheritable.checked).toBe(testValue.isInheritable);
expect(ruleOptionDisabled.checked).toBe(!testValue.isEnabled);
});
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 ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component');
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');
expect(nameInput.disabled).toBeFalsy();
expect(descriptionTextarea.disabled).toBeFalsy();
expect(ruleTriggersComponent.readOnly).toBeFalsy();
expect(ruleOptionAsynchronous.disabled).toBeFalsy();
expect(ruleOptionCascade.disabled).toBeFalsy();
expect(ruleOptionInheritable.disabled).toBeFalsy();
expect(ruleOptionDisabled.disabled).toBeFalsy();
});
@ -126,12 +126,12 @@ describe('RuleDetailsUiComponent', () => {
const descriptionTextarea = getHtmlElement<HTMLTextAreaElement>('rule-details-description-textarea');
const ruleTriggersComponent = getComponentInstance<RuleTriggersUiComponent>('rule-details-triggers-component');
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(descriptionTextarea.disabled).toBeTruthy();
expect(ruleTriggersComponent.readOnly).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,
triggers: newValue.triggers || FolderRulesService.emptyRule.triggers,
conditions: newValue.conditions || FolderRulesService.emptyRule.conditions,
asynchronous: newValue.asynchronous || FolderRulesService.emptyRule.asynchronous,
isAsynchronous: newValue.isAsynchronous || FolderRulesService.emptyRule.isAsynchronous,
errorScript: newValue.errorScript || FolderRulesService.emptyRule.errorScript,
cascade: newValue.cascade || FolderRulesService.emptyRule.cascade,
enabled: newValue.enabled || FolderRulesService.emptyRule.enabled
isInheritable: newValue.isInheritable || FolderRulesService.emptyRule.isInheritable,
isEnabled: newValue.isEnabled || FolderRulesService.emptyRule.isEnabled
};
if (this.form) {
this.form.setValue(newValue);
@ -99,17 +99,17 @@ export class RuleDetailsUiComponent implements OnInit, OnDestroy {
get conditions(): UntypedFormControl {
return this.form.get('conditions') as UntypedFormControl;
}
get asynchronous(): UntypedFormControl {
return this.form.get('asynchronous') as UntypedFormControl;
get isAsynchronous(): UntypedFormControl {
return this.form.get('isAsynchronous') as UntypedFormControl;
}
get errorScript(): UntypedFormControl {
return this.form.get('errorScript') as UntypedFormControl;
}
get cascade(): UntypedFormControl {
return this.form.get('cascade') as UntypedFormControl;
get isInheritable(): UntypedFormControl {
return this.form.get('isInheritable') as UntypedFormControl;
}
get enabled(): UntypedFormControl {
return this.form.get('enabled') as UntypedFormControl;
get isEnabled(): UntypedFormControl {
return this.form.get('isEnabled') as UntypedFormControl;
}
ngOnInit() {
@ -126,10 +126,10 @@ export class RuleDetailsUiComponent implements OnInit, OnDestroy {
},
ruleCompositeConditionValidator()
),
asynchronous: new UntypedFormControl(this.value.asynchronous),
isAsynchronous: new UntypedFormControl(this.value.isAsynchronous),
errorScript: new UntypedFormControl(this.value.errorScript),
cascade: new UntypedFormControl(this.value.cascade),
enabled: new UntypedFormControl(this.value.enabled)
isInheritable: new UntypedFormControl(this.value.isInheritable),
isEnabled: new UntypedFormControl(this.value.isEnabled)
});
this.readOnly = this._readOnly;

View File

@ -2,7 +2,7 @@
<div class="rule-info">
<div class="rule-info__header">
<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>
<p>{{rule.description}}</p>
</div>

View File

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

View File

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