mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-3575] Update FolderRulesService to provide a list of available aspects (#2669)
* first commit * [ACS-3575] Update FolderRulesService to provide a list of available aspects * rebase
This commit is contained in:
parent
8f37a69fb6
commit
aaa1914263
@ -35,7 +35,7 @@
|
||||
"OPTIONS": {
|
||||
"CASCADE": "Rule applies to subfolders",
|
||||
"ASYNCHRONOUS": "Run rule in the background",
|
||||
"ENABLED": "Disable rule",
|
||||
"DISABLE_RULE": "Disable rule",
|
||||
"ERROR_SCRIPT": "If errors occur run script",
|
||||
"SELECT_ACTION": "Select action"
|
||||
},
|
||||
|
40
projects/aca-folder-rules/src/lib/model/aspect.model.ts
Normal file
40
projects/aca-folder-rules/src/lib/model/aspect.model.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface AspectModel {
|
||||
id: string;
|
||||
description: string;
|
||||
namespaceUri: string;
|
||||
namespacePrefix: string;
|
||||
}
|
||||
|
||||
export interface Aspect {
|
||||
includedInSupertypeQuery: boolean;
|
||||
isContainer: boolean;
|
||||
model: AspectModel;
|
||||
id: string;
|
||||
title: string;
|
||||
parentId: string;
|
||||
}
|
@ -27,7 +27,7 @@
|
||||
[attr.data-automation-id]="'rule-option-checkbox-enabled'"
|
||||
[checked]="!form.value.enabled" *ngIf="!preview"
|
||||
(change)="form.get('enabled').setValue(!$event.checked)">
|
||||
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.ENABLED' | translate }}
|
||||
{{ 'ACA_FOLDER_RULES.RULE_DETAILS.OPTIONS.DISABLE_RULE' | translate }}
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -125,4 +125,17 @@ describe('FolderRulesService', () => {
|
||||
expect(apiCallSpy).toHaveBeenCalledWith(`/nodes/${nodeId}/rule-sets/${ruleSetId}/rules/${ruleId}`, 'PUT', paramsWithBody);
|
||||
});
|
||||
});
|
||||
|
||||
describe('loadAspects', () => {
|
||||
beforeEach(async () => {
|
||||
apiCallSpy = spyOn<any>(folderRulesService, 'apiCall').withArgs(`/aspects`, 'GET', params).and.returnValue([]);
|
||||
|
||||
folderRulesService.loadAspects();
|
||||
});
|
||||
|
||||
it('should send correct GET request', async () => {
|
||||
expect(apiCallSpy).toHaveBeenCalled();
|
||||
expect(apiCallSpy).toHaveBeenCalledWith(`/aspects`, 'GET', params);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -32,6 +32,7 @@ import { ContentApiService } from '@alfresco/aca-shared';
|
||||
import { NodeInfo } from '@alfresco/aca-shared/store';
|
||||
import { RuleCompositeCondition } from '../model/rule-composite-condition.model';
|
||||
import { RuleSimpleCondition } from '../model/rule-simple-condition.model';
|
||||
import { Aspect, AspectModel } from '../model/aspect.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -70,6 +71,8 @@ export class FolderRulesService {
|
||||
loading$ = this.loadingSource.asObservable();
|
||||
private deletedRuleIdSource = new BehaviorSubject<string>(null);
|
||||
deletedRuleId$: Observable<string> = this.deletedRuleIdSource.asObservable();
|
||||
private aspectsSource = new BehaviorSubject<Aspect[]>([]);
|
||||
aspects$: Observable<Aspect[]> = this.aspectsSource.asObservable();
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private contentApi: ContentApiService) {}
|
||||
|
||||
@ -146,6 +149,14 @@ export class FolderRulesService {
|
||||
).subscribe({ error: (error) => console.error(error) });
|
||||
}
|
||||
|
||||
loadAspects(): void {
|
||||
from(this.apiCall('/aspects', 'GET', [{}, {}, {}, {}, {}, ['application/json'], ['application/json']]))
|
||||
.pipe(map((res) => res.list.entries.map((entry) => this.formatAspect(entry.entry))))
|
||||
.subscribe((res) => {
|
||||
this.aspectsSource.next(res);
|
||||
});
|
||||
}
|
||||
|
||||
private apiCall(path: string, httpMethod: string, params?: any[]): Promise<any> {
|
||||
return this.apiService.getInstance().contentClient.callApi(path, httpMethod, ...params);
|
||||
}
|
||||
@ -197,4 +208,24 @@ export class FolderRulesService {
|
||||
parameter: obj.parameter || ''
|
||||
};
|
||||
}
|
||||
|
||||
private formatAspect(obj): Aspect {
|
||||
return {
|
||||
includedInSupertypeQuery: obj.includedInSupertypeQuery ?? false,
|
||||
isContainer: obj.isContainer ?? false,
|
||||
model: this.formatAspectModel(obj.model),
|
||||
id: obj.id ?? '',
|
||||
title: obj.title ?? '',
|
||||
parentId: obj.parentId ?? ''
|
||||
};
|
||||
}
|
||||
|
||||
private formatAspectModel(obj): AspectModel {
|
||||
return {
|
||||
id: obj.id ?? '',
|
||||
description: obj.description ?? '',
|
||||
namespaceUri: obj.namespaceUri ?? '',
|
||||
namespacePrefix: obj.namespacePrefix ?? ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user