diff --git a/projects/aca-folder-rules/assets/i18n/en.json b/projects/aca-folder-rules/assets/i18n/en.json
index 9ead4a3eb..18b93d403 100644
--- a/projects/aca-folder-rules/assets/i18n/en.json
+++ b/projects/aca-folder-rules/assets/i18n/en.json
@@ -93,6 +93,7 @@
},
"ACTIONS": {
"CREATE_RULE": "Create rule",
+ "LINK_RULES": "Link rules",
"EDIT_RULE": "Edit",
"SEE_IN_FOLDER": "See in folder"
}
@@ -106,6 +107,10 @@
"DELETE_RULE": {
"TITLE": "Delete rule",
"MESSAGE": "Are you sure you want to delete this rule?"
+ },
+ "DELETE_RULE_SET_LINK": {
+ "TITLE": "Delete rule set link",
+ "MESSAGE": "Are you sure you want to delete the link to this rule set?"
}
},
"RULE_LIST": {
@@ -116,6 +121,22 @@
"LOAD_MORE_RULES": "Load more rules",
"LOADING_RULES": "Loading rules",
"INHERITED_RULES_WILL_BE_RUN_FIRST": "Inherited rules will be run first"
+ },
+ "LINK_RULES_DIALOG": {
+ "TITLE": "Select a folder to link rules from",
+ "CANCEL": "Cancel",
+ "SUBMIT": "Select folder",
+ "EMPTY_RULES_LIST": {
+ "TITLE": "No owned rules",
+ "SUBTITLE": "The selected folder doesn't have any rules of its own."
+ },
+ "LIST_OF_RULES_TO_LINK": "List of rules that will be linked",
+ "ERRORS": {
+ "REQUEST_FAILED": "Error while trying to create a link to a rule set"
+ }
+ },
+ "ERRORS": {
+ "DELETE_RULE_SET_LINK_FAILED": "Error while trying to delete a link from a rule set"
}
}
}
diff --git a/projects/aca-folder-rules/src/lib/folder-rules.module.ts b/projects/aca-folder-rules/src/lib/folder-rules.module.ts
index 5b1537504..feea68c8d 100644
--- a/projects/aca-folder-rules/src/lib/folder-rules.module.ts
+++ b/projects/aca-folder-rules/src/lib/folder-rules.module.ts
@@ -35,7 +35,7 @@ import { RuleCompositeConditionUiComponent } from './rule-details/conditions/rul
import { RuleDetailsUiComponent } from './rule-details/rule-details.ui-component';
import { RuleSimpleConditionUiComponent } from './rule-details/conditions/rule-simple-condition.ui-component';
import { GenericErrorModule, PageLayoutModule } from '@alfresco/aca-shared';
-import { BreadcrumbModule, DocumentListModule } from '@alfresco/adf-content-services';
+import { BreadcrumbModule, ContentNodeSelectorModule, DocumentListModule } from '@alfresco/adf-content-services';
import { RuleListItemUiComponent } from './rule-list/rule-list-item/rule-list-item.ui-component';
import { RuleListGroupingUiComponent } from './rule-list/rule-list-grouping/rule-list-grouping.ui-component';
import { RuleTriggersUiComponent } from './rule-details/triggers/rule-triggers.ui-component';
@@ -43,6 +43,7 @@ import { RuleOptionsUiComponent } from './rule-details/options/rule-options.ui-c
import { RuleActionListUiComponent } from './rule-details/actions/rule-action-list.ui-component';
import { RuleActionUiComponent } from './rule-details/actions/rule-action.ui-component';
import { RuleListUiComponent } from './rule-list/rule-list/rule-list.ui-component';
+import { RuleSetPickerSmartComponent } from './rule-set-picker/rule-set-picker.smart-component';
const routes: Routes = [
{
@@ -61,7 +62,8 @@ const routes: Routes = [
BreadcrumbModule,
DocumentListModule,
ExtensionsModule,
- GenericErrorModule
+ GenericErrorModule,
+ ContentNodeSelectorModule
],
declarations: [
EditRuleDialogSmartComponent,
@@ -73,6 +75,7 @@ const routes: Routes = [
RuleListGroupingUiComponent,
RuleListItemUiComponent,
RuleListUiComponent,
+ RuleSetPickerSmartComponent,
RuleSimpleConditionUiComponent,
RuleTriggersUiComponent,
RuleOptionsUiComponent
diff --git a/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.html b/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.html
index f4936bd32..9c8607b62 100644
--- a/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.html
+++ b/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.html
@@ -26,13 +26,22 @@
class="aca-manage-rules__actions-bar__title__breadcrumb">
-
+
+
+
+
+
@@ -48,7 +57,9 @@
(loadMoreRuleSets)="onLoadMoreRuleSets()"
(loadMoreRules)="onLoadMoreRules($event)"
(selectRule)="onSelectRule($event)"
- (ruleEnabledChanged)="onRuleEnabledToggle($event[0], $event[1])">
+ (ruleEnabledChanged)="onRuleEnabledToggle($event[0], $event[1])"
+ (ruleSetEditLinkClicked)="openLinkRulesDialog($event)"
+ (ruleSetUnlinkClicked)="onRuleSetUnlinkClicked($event)">
diff --git a/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.scss b/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.scss
index 5f8e1f209..f50d24ff3 100644
--- a/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.scss
+++ b/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.scss
@@ -13,6 +13,12 @@
margin-left: 18px;
}
}
+
+ &__buttons {
+ display: flex;
+ align-items: stretch;
+ gap: 4px;
+ }
}
&__container {
diff --git a/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.ts b/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.ts
index f6822e14a..04abdc58f 100644
--- a/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.ts
+++ b/projects/aca-folder-rules/src/lib/manage-rules/manage-rules.smart-component.ts
@@ -39,6 +39,7 @@ import { ActionDefinitionTransformed } from '../model/rule-action.model';
import { ActionsService } from '../services/actions.service';
import { FolderRuleSetsService } from '../services/folder-rule-sets.service';
import { RuleSet } from '../model/rule-set.model';
+import { RuleSetPickerSmartComponent } from '../rule-set-picker/rule-set-picker.smart-component';
@Component({
selector: 'aca-manage-rules',
@@ -184,4 +185,45 @@ export class ManageRulesSmartComponent implements OnInit, OnDestroy {
canEditRule(ruleSet: RuleSet): boolean {
return !ruleSet || FolderRuleSetsService.isOwnedRuleSet(ruleSet, this.nodeId);
}
+
+ openLinkRulesDialog(existingRuleSet?: RuleSet) {
+ this.matDialogService
+ .open(RuleSetPickerSmartComponent, {
+ width: '90%',
+ panelClass: 'aca-rule-set-picker-container',
+ data: {
+ nodeId: this.nodeId,
+ defaultNodeId: this.nodeId,
+ existingRuleSet
+ }
+ })
+ .afterClosed()
+ .subscribe((result) => {
+ if (result) {
+ this.folderRuleSetsService.refreshMainRuleSet();
+ }
+ });
+ }
+
+ onRuleSetUnlinkClicked(linkedRuleSet: RuleSet) {
+ this.matDialogService
+ .open(ConfirmDialogComponent, {
+ data: {
+ title: 'ACA_FOLDER_RULES.CONFIRMATION_DIALOG.DELETE_RULE_SET_LINK.TITLE',
+ message: 'ACA_FOLDER_RULES.CONFIRMATION_DIALOG.DELETE_RULE_SET_LINK.MESSAGE'
+ },
+ minWidth: '346px'
+ })
+ .afterClosed()
+ .subscribe(async (result) => {
+ if (result) {
+ try {
+ await this.folderRuleSetsService.deleteRuleSetLink(this.nodeId, linkedRuleSet.id);
+ this.folderRuleSetsService.refreshMainRuleSet();
+ } catch (error) {
+ this.notificationService.showError('ACA_FOLDER_RULES.ERRORS.DELETE_RULE_SET_LINK_FAILED');
+ }
+ }
+ });
+ }
}
diff --git a/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.spec.ts b/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.spec.ts
index 28457ca00..16bc57439 100644
--- a/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.spec.ts
+++ b/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.spec.ts
@@ -39,7 +39,6 @@ import { timer } from 'rxjs';
describe('EditRuleDialogSmartComponent', () => {
let fixture: ComponentFixture;
- let actionsService: ActionsService;
const dialogRef = {
close: jasmine.createSpy('close'),
@@ -64,9 +63,8 @@ describe('EditRuleDialogSmartComponent', () => {
]
});
- actionsService = TestBed.inject(ActionsService);
- spyOn(actionsService, 'loadActionDefinitions').and.stub();
- spyOn(actionsService, 'getParameterConstraints').and.stub();
+ spyOn(ActionsService.prototype, 'loadActionDefinitions').and.stub();
+ spyOn(ActionsService.prototype, 'getParameterConstraints').and.stub();
fixture = TestBed.createComponent(EditRuleDialogSmartComponent);
fixture.detectChanges();
diff --git a/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.ts b/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.ts
index ffe5db6a3..eda6a2adc 100644
--- a/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.ts
+++ b/projects/aca-folder-rules/src/lib/rule-details/edit-rule-dialog.smart-component.ts
@@ -38,7 +38,8 @@ export interface EditRuleDialogOptions {
templateUrl: './edit-rule-dialog.smart-component.html',
styleUrls: ['./edit-rule-dialog.smart-component.scss'],
encapsulation: ViewEncapsulation.None,
- host: { class: 'aca-edit-rule-dialog' }
+ host: { class: 'aca-edit-rule-dialog' },
+ providers: [{ provide: ActionsService, useClass: ActionsService }]
})
export class EditRuleDialogSmartComponent implements OnInit, OnDestroy {
formValid = false;
diff --git a/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.html b/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.html
index 0f2a6beba..263750e71 100644
--- a/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.html
+++ b/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.html
@@ -6,6 +6,7 @@
tabindex="0"
[rule]="item.rule"
[isSelected]="isSelected(item.rule)"
+ [showEnabledToggle]="showEnabledToggles"
(click)="onRuleClicked(item.rule)"
(enabledChanged)="onEnabledChanged(item.rule, $event)">
diff --git a/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.spec.ts b/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.spec.ts
index e3dd30c14..37a839c53 100644
--- a/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.spec.ts
+++ b/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.spec.ts
@@ -62,10 +62,8 @@ describe('RuleListGroupingUiComponent', () => {
const rule = debugElement.query(By.css('.aca-rule-list-item:first-child'));
const name = rule.query(By.css('.aca-rule-list-item__header__name'));
const description = rule.query(By.css('.aca-rule-list-item__description'));
- const toggleBtn = rule.query(By.css('mat-slide-toggle'));
expect(name.nativeElement.textContent).toBe(rulesMock[0].name);
- expect(toggleBtn).toBeTruthy();
expect(description.nativeElement.textContent).toBe(rulesMock[0].description);
});
});
diff --git a/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.ts b/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.ts
index d5820feb6..da79035a7 100644
--- a/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.ts
+++ b/projects/aca-folder-rules/src/lib/rule-list/rule-list-grouping/rule-list-grouping.ui-component.ts
@@ -40,6 +40,8 @@ export class RuleListGroupingUiComponent {
items: RuleGroupingItem[] = [];
@Input()
selectedRule: Rule = null;
+ @Input()
+ showEnabledToggles = false;
@Output()
selectRule = new EventEmitter();
diff --git a/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.html b/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.html
index 01fd0064a..68317598a 100644
--- a/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.html
+++ b/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.html
@@ -3,6 +3,7 @@
diff --git a/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.ts b/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.ts
index 49f7cc679..c59b27872 100644
--- a/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.ts
+++ b/projects/aca-folder-rules/src/lib/rule-list/rule-list-item/rule-list-item.ui-component.ts
@@ -39,6 +39,8 @@ export class RuleListItemUiComponent {
@Input()
@HostBinding('class.selected')
isSelected: boolean;
+ @Input()
+ showEnabledToggle = false;
@Output()
enabledChanged = new EventEmitter();
diff --git a/projects/aca-folder-rules/src/lib/rule-list/rule-list/rule-list.ui-component.html b/projects/aca-folder-rules/src/lib/rule-list/rule-list/rule-list.ui-component.html
index 0b88f4069..0bcdb0bf0 100644
--- a/projects/aca-folder-rules/src/lib/rule-list/rule-list/rule-list.ui-component.html
+++ b/projects/aca-folder-rules/src/lib/rule-list/rule-list/rule-list.ui-component.html
@@ -4,26 +4,22 @@
data-automation-id="rule-list-item"
[ngClass]="{ expanded: inheritedRuleSetsExpanded }">
-