mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-6150] Folder rules - add category selector for link category action (#3701)
* [ACS-6150] folder rules - add category selector for link category action * [ACS-6150] unit tests
This commit is contained in:
committed by
GitHub
parent
76f83da505
commit
965f68c0ac
@@ -30,6 +30,7 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { dummyCategoriesConstraints, dummyConstraints, dummyTagsConstraints } from '../../mock/action-parameter-constraints.mock';
|
import { dummyCategoriesConstraints, dummyConstraints, dummyTagsConstraints } from '../../mock/action-parameter-constraints.mock';
|
||||||
import { CategoryService, TagService } from '@alfresco/adf-content-services';
|
import { CategoryService, TagService } from '@alfresco/adf-content-services';
|
||||||
import { MatSelect } from '@angular/material/select';
|
import { MatSelect } from '@angular/material/select';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
|
||||||
describe('RuleActionUiComponent', () => {
|
describe('RuleActionUiComponent', () => {
|
||||||
let fixture: ComponentFixture<RuleActionUiComponent>;
|
let fixture: ComponentFixture<RuleActionUiComponent>;
|
||||||
@@ -124,11 +125,25 @@ describe('RuleActionUiComponent', () => {
|
|||||||
const cardView = getPropertiesCardView();
|
const cardView = getPropertiesCardView();
|
||||||
|
|
||||||
expect(cardView.properties.length).toBe(1);
|
expect(cardView.properties.length).toBe(1);
|
||||||
expect(cardView.properties[0].icon).toBeFalsy();
|
expect(cardView.properties[0].icon).toBe('library_add');
|
||||||
expect(cardView.properties[0].value).toBeFalsy();
|
expect(cardView.properties[0].value).toBeFalsy();
|
||||||
expect(cardView.properties[0]).toBeInstanceOf(CardViewTextItemModel);
|
expect(cardView.properties[0]).toBeInstanceOf(CardViewTextItemModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should open category selector dialog on category-value action parameter clicked', () => {
|
||||||
|
const dialog = fixture.debugElement.injector.get(MatDialog);
|
||||||
|
component.actionDefinitions = [actionLinkToCategoryTransformedMock];
|
||||||
|
component.parameterConstraints = dummyConstraints;
|
||||||
|
spyOn(dialog, 'open');
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
changeMatSelectValue('mock-action-3-definition');
|
||||||
|
fixture.debugElement.query(By.css('.adf-textitem-action')).nativeElement.click();
|
||||||
|
|
||||||
|
expect(dialog.open).toHaveBeenCalledTimes(1);
|
||||||
|
expect(dialog.open['calls'].argsFor(0)[0].name).toBe('CategorySelectorDialogComponent');
|
||||||
|
});
|
||||||
|
|
||||||
describe('Select options', () => {
|
describe('Select options', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.actionDefinitions = actionsTransformedListMock;
|
component.actionDefinitions = actionsTransformedListMock;
|
||||||
|
@@ -35,7 +35,7 @@ import {
|
|||||||
CardViewUpdateService,
|
CardViewUpdateService,
|
||||||
UpdateNotification
|
UpdateNotification
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ActionParameterDefinition, Node } from '@alfresco/js-api';
|
import { ActionParameterDefinition, Category, Node } from '@alfresco/js-api';
|
||||||
import { of, Subject } from 'rxjs';
|
import { of, Subject } from 'rxjs';
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
import { ActionParameterConstraint, ConstraintValue } from '../../model/action-parameter-constraint.model';
|
import { ActionParameterConstraint, ConstraintValue } from '../../model/action-parameter-constraint.model';
|
||||||
@@ -44,7 +44,9 @@ import {
|
|||||||
ContentNodeSelectorComponent,
|
ContentNodeSelectorComponent,
|
||||||
ContentNodeSelectorComponentData,
|
ContentNodeSelectorComponentData,
|
||||||
NodeAction,
|
NodeAction,
|
||||||
TagService
|
TagService,
|
||||||
|
CategorySelectorDialogComponent,
|
||||||
|
CategorySelectorDialogOptions
|
||||||
} from '@alfresco/adf-content-services';
|
} from '@alfresco/adf-content-services';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||||
@@ -220,6 +222,15 @@ export class RuleActionUiComponent implements ControlValueAccessor, OnInit, OnCh
|
|||||||
clickCallBack: this.openSelectorDialog.bind(this, paramDef.name),
|
clickCallBack: this.openSelectorDialog.bind(this, paramDef.name),
|
||||||
value: this.parameters[paramDef.name]
|
value: this.parameters[paramDef.name]
|
||||||
});
|
});
|
||||||
|
} else if (paramDef.name === 'category-value' && !this.readOnly) {
|
||||||
|
return new CardViewTextItemModel({
|
||||||
|
...cardViewPropertiesModel,
|
||||||
|
icon: 'library_add',
|
||||||
|
default: '',
|
||||||
|
clickable: true,
|
||||||
|
clickCallBack: this.openCatDialog.bind(this, paramDef.name),
|
||||||
|
value: this.parameters[paramDef.name]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// falls through
|
// falls through
|
||||||
default:
|
default:
|
||||||
@@ -288,6 +299,35 @@ export class RuleActionUiComponent implements ControlValueAccessor, OnInit, OnCh
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private openCatDialog(paramDefName) {
|
||||||
|
const data: CategorySelectorDialogOptions = {
|
||||||
|
select: new Subject<Category[]>(),
|
||||||
|
multiSelect: false
|
||||||
|
};
|
||||||
|
|
||||||
|
this.dialog.open(CategorySelectorDialogComponent, {
|
||||||
|
data,
|
||||||
|
width: '630px'
|
||||||
|
});
|
||||||
|
|
||||||
|
data.select.pipe(takeUntil(this.onDestroy$)).subscribe((selections: Category[]) => {
|
||||||
|
if (selections[0].id) {
|
||||||
|
this.writeValue({
|
||||||
|
actionDefinitionId: this.selectedActionDefinitionId,
|
||||||
|
params: {
|
||||||
|
...this.parameters,
|
||||||
|
[paramDefName]: selections[0].id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.onChange({
|
||||||
|
actionDefinitionId: this.selectedActionDefinitionId,
|
||||||
|
params: this.parameters
|
||||||
|
});
|
||||||
|
this.onTouch();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setDefaultParameters() {
|
setDefaultParameters() {
|
||||||
this.parameters = {};
|
this.parameters = {};
|
||||||
(this.selectedActionDefinition?.parameterDefinitions ?? []).forEach((paramDef: ActionParameterDefinition) => {
|
(this.selectedActionDefinition?.parameterDefinitions ?? []).forEach((paramDef: ActionParameterDefinition) => {
|
||||||
|
Reference in New Issue
Block a user