|
|
|
|
import { $t } from 'platform-core';
|
|
|
|
|
import { Processor } from '../Processor';
|
|
|
|
|
|
|
|
|
|
class SingleRule extends Processor {
|
|
|
|
|
constructor(targetType: string, context?: any) {
|
|
|
|
|
super(targetType, context);
|
|
|
|
|
this.PROCESSOR_TYPE = 'SINGLE_RULE';
|
|
|
|
|
this.EDITOR_DIALOG_WIDTH = 800;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getToolbarAction(): any {
|
|
|
|
|
return {
|
|
|
|
|
extend: 'add',
|
|
|
|
|
name: 'singleRule',
|
|
|
|
|
label: $t('io.sc.engine.rule.core.enums.ProcessorType.' + this.PROCESSOR_TYPE),
|
|
|
|
|
icon: 'bi-noise-reduction',
|
|
|
|
|
enableIf: (args: any) => {
|
|
|
|
|
const type = this.context.target.type;
|
|
|
|
|
return type !== 'RULE_RESULT' && type !== 'SINGLE_RULE_RESULT';
|
|
|
|
|
},
|
|
|
|
|
afterClick: (args: any) => {
|
|
|
|
|
args.grid.getEditorForm().setFieldValue('type', this.PROCESSOR_TYPE);
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public format(row: any): any {
|
|
|
|
|
return row.singleRule;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getEditorFields(): any {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getViewerFields(): any {
|
|
|
|
|
return [{ name: 'singleRule', label: $t('re.processor.grid.entity.singleRule') }];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public beforeEditorDataSubmit(args: any): void {}
|
|
|
|
|
|
|
|
|
|
public afterEditorOpen(args: any): void {
|
|
|
|
|
args.grid.getEditorDialog().setWidth(this.EDITOR_DIALOG_WIDTH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { SingleRule };
|