Merge branch 'DM-424-1' into 'master'

DM-424, add component rules screen, update title for entity rule screen, adapt...

Closes DM-424

See merge request redactmanager/red-ui!83
This commit is contained in:
Dan Percic 2023-09-15 13:09:34 +02:00
commit ccacad4caf
18 changed files with 89 additions and 101 deletions

View File

@ -49,7 +49,7 @@ const dossierTemplateIdRoutes: IqserRoutes = [
],
},
{
path: 'rules',
path: 'entity-rules',
component: BaseDossierTemplateScreenComponent,
canActivate: [CompositeRouteGuard, IqserPermissionsGuard],
data: {
@ -59,7 +59,7 @@ const dossierTemplateIdRoutes: IqserRoutes = [
redirectTo: 'info',
},
},
loadChildren: () => import('./screens/rules/rules.module').then(m => m.RulesModule),
loadChildren: () => import('./screens/rules/entity-rules.module').then(m => m.EntityRulesModule),
},
{
path: 'component-rules',

View File

@ -57,7 +57,6 @@ import { DossierTemplateActionsComponent } from './shared/components/dossier-tem
import { IqserUsersModule } from '@iqser/common-ui/lib/users';
import { TenantPipe } from '@iqser/common-ui/lib/tenants';
import { SelectComponent } from '@shared/components/select/select.component';
import { ComponentRulesService } from './services/component-rules.service';
const dialogs = [
AddEditCloneDossierTemplateDialogComponent,
@ -98,7 +97,7 @@ const components = [
@NgModule({
declarations: [...components],
providers: [AdminDialogService, AuditService, DigitalSignatureService, RulesService, ComponentRulesService, SmtpConfigService],
providers: [AdminDialogService, AuditService, DigitalSignatureService, RulesService, SmtpConfigService],
imports: [
CommonModule,
SharedModule,

View File

@ -8,7 +8,7 @@ import { DOSSIER_TEMPLATE_ID } from '@red/domain';
import { EditorThemeService } from '@services/editor-theme.service';
import { ComponentCanDeactivate } from '@guards/can-deactivate.guard';
import { Debounce, getParam } from '@iqser/common-ui/lib/utils';
import { ComponentRulesService } from '../../../services/component-rules.service';
import { RulesService } from '../../../services/rules.service';
import ICodeEditor = monaco.editor.ICodeEditor;
import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration;
import IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions;
@ -46,7 +46,7 @@ export class ComponentRulesScreenComponent implements OnInit, ComponentCanDeacti
constructor(
readonly permissionsService: PermissionsService,
private readonly _componentRulesService: ComponentRulesService,
private readonly _rulesService: RulesService,
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _toaster: Toaster,
private readonly _loadingService: LoadingService,
@ -99,9 +99,10 @@ export class ComponentRulesScreenComponent implements OnInit, ComponentCanDeacti
this._loadingService.start();
this._removeErrorMarkers();
await firstValueFrom(
this._componentRulesService.uploadRules({
this._rulesService.uploadRules({
rules: this._codeEditor.getModel().getValue(),
dossierTemplateId: this.#dossierTemplateId,
ruleFileType: 'COMPONENT',
}),
).then(
async () => {
@ -205,7 +206,7 @@ export class ComponentRulesScreenComponent implements OnInit, ComponentCanDeacti
private async _initialize() {
this._loadingService.start();
await firstValueFrom(this._componentRulesService.download(this.#dossierTemplateId)).then(
await firstValueFrom(this._rulesService.download(this.#dossierTemplateId, 'COMPONENT')).then(
rules => {
this.currentLines = this.initialLines = rules.rules.split('\n');
this.revert();

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { ComponentRulesScreenComponent } from './rules-screen/component-rules-screen.component';
import { ComponentRulesScreenComponent } from './component-rules-screen/component-rules-screen.component';
import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
import { TranslateModule } from '@ngx-translate/core';

View File

@ -1,6 +1,6 @@
<div class="header-container">
<div [translate]="'rules-screen.title'" class="heading-l"></div>
<div [translate]="'rules-screen.warning-text'" class="error"></div>
<div [translate]="'entity-rules-screen.title'" class="heading-l"></div>
<div [translate]="'entity-rules-screen.warning-text'" class="error"></div>
</div>
<ngx-monaco-editor (init)="onCodeEditorInit($event)" [(ngModel)]="codeEditorText" [options]="editorOptions"></ngx-monaco-editor>
@ -9,18 +9,18 @@
<div (click)="goToErrors()" *ngIf="numberOfErrors()" class="errors">
<span>
<mat-icon [svgIcon]="'iqser:alert-circle'" class="icon"></mat-icon>
<span [translateParams]="{ errors: numberOfErrors() }" [translate]="'rules-screen.errors-found'"></span>
<span [translateParams]="{ errors: numberOfErrors() }" [translate]="'entity-rules-screen.errors-found'"></span>
</span>
<mat-icon [svgIcon]="'iqser:expand'" class="icon face-up"></mat-icon>
</div>
<div class="actions">
<iqser-icon-button
(action)="save()"
[label]="'rules-screen.save-changes' | translate"
[label]="'entity-rules-screen.save-changes' | translate"
[type]="iconButtonTypes.primary"
icon="iqser:check"
></iqser-icon-button>
<div (click)="revert()" [translate]="'rules-screen.revert-changes'" class="all-caps-label cancel"></div>
<div (click)="revert()" [translate]="'entity-rules-screen.revert-changes'" class="all-caps-label cancel"></div>
</div>
</div>

View File

@ -20,11 +20,11 @@ interface SyntaxError {
}
@Component({
templateUrl: './rules-screen.component.html',
styleUrls: ['./rules-screen.component.scss'],
templateUrl: './entity-rules-screen.component.html',
styleUrls: ['./entity-rules-screen.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
export class EntityRulesScreenComponent implements OnInit, ComponentCanDeactivate {
readonly iconButtonTypes = IconButtonTypes;
readonly editorOptions: IStandaloneEditorConstructionOptions = {
theme: 'vs',
@ -106,13 +106,13 @@ export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
).then(
async () => {
await this._initialize();
this._toaster.success(_('rules-screen.success.generic'));
this._toaster.success(_('entity-rules-screen.success.generic'));
},
error => {
const errors = error.error as SyntaxError[] | undefined;
this._drawErrorMarkers(errors);
this._loadingService.stop();
this._toaster.error(_('rules-screen.error.generic'));
this._toaster.error(_('entity-rules-screen.error.generic'));
},
);
}

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { RulesScreenComponent } from './rules-screen/rules-screen.component';
import { EntityRulesScreenComponent } from './entity-rules-screen/entity-rules-screen.component';
import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
import { TranslateModule } from '@ngx-translate/core';
@ -9,10 +9,10 @@ import { IconButtonComponent } from '@iqser/common-ui';
import { FormsModule } from '@angular/forms';
import { MatIconModule } from '@angular/material/icon';
const routes = [{ path: '', component: RulesScreenComponent, canDeactivate: [PendingChangesGuard] }];
const routes = [{ path: '', component: EntityRulesScreenComponent, canDeactivate: [PendingChangesGuard] }];
@NgModule({
declarations: [RulesScreenComponent],
declarations: [EntityRulesScreenComponent],
imports: [
RouterModule.forChild(routes),
CommonModule,
@ -23,4 +23,4 @@ const routes = [{ path: '', component: RulesScreenComponent, canDeactivate: [Pen
MatIconModule,
],
})
export class RulesModule {}
export class EntityRulesModule {}

View File

@ -1,16 +0,0 @@
import { Injectable } from '@angular/core';
import { GenericService } from '@iqser/common-ui';
import { IComponentRules } from '@red/domain';
@Injectable()
export class ComponentRulesService extends GenericService<IComponentRules> {
protected readonly _defaultModelPath = 'rules';
download(dossierTemplateId: string) {
return this._getOne([dossierTemplateId]);
}
uploadRules(body: IComponentRules) {
return this._post<unknown>(body);
}
}

View File

@ -6,11 +6,11 @@ import { IRules } from '@red/domain';
export class RulesService extends GenericService<IRules> {
protected readonly _defaultModelPath = 'rules';
download(dossierTemplateId: string) {
return this._getOne([dossierTemplateId]);
download(dossierTemplateId: string, ruleFileType: IRules['ruleFileType'] = 'ENTITY') {
return this._getOne([dossierTemplateId], this._defaultModelPath, [{ key: 'ruleFileType', value: ruleFileType }]);
}
uploadRules(body: IRules) {
return this._post<unknown>(body);
return this._post<unknown>({ ...body, ruleFileType: body.ruleFileType ?? 'ENTITY' });
}
}

View File

@ -95,8 +95,8 @@ export class AdminSideNavComponent implements OnInit {
show: true,
},
{
screen: 'rules',
label: _('admin-side-nav.rule-editor'),
screen: 'entity-rules',
label: _('admin-side-nav.entity-rule-editor'),
show: (this.isIqserDevMode || this.canAccessRulesInDocumine) && this._permissionsService.has(Roles.rules.read),
},
{

View File

@ -245,13 +245,13 @@
"dossier-templates": "Dossier-Vorlage",
"entities": "Entities",
"entity-info": "Info",
"entity-rule-editor": "Entity Rule Editor",
"false-positive": "False Positive",
"false-recommendations": "False Recommendations",
"file-attributes": "File Attributes",
"justifications": "Justifications",
"license-information": "License Information",
"reports": "Reports",
"rule-editor": "Rule Editor",
"settings": "Einstellungen",
"user-management": "User Management",
"watermarks": "Watermarks"
@ -1293,6 +1293,19 @@
"heading": "Edit Entity"
}
},
"entity-rules-screen": {
"error": {
"generic": "Something went wrong... Entity rules update failed!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Entity rules updated!"
},
"title": "Entity Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"error": {
"deleted-entity": {
"dossier": {
@ -2239,19 +2252,6 @@
},
"title": "Structured Component Management"
},
"rules-screen": {
"error": {
"generic": "Es ist ein Fehler aufgetreten ... Die Regeln konnten nicht aktualisiert werden!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Anmeldedaten speichern",
"save-changes": "Änderungen speichern",
"success": {
"generic": "Die Regeln wurden aktualisiert!"
},
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"search": {
"active-dossiers": "ganze Plattform",
"all-dossiers": "all documents",

View File

@ -245,13 +245,13 @@
"dossier-templates": "Dossier Templates",
"entities": "Entities",
"entity-info": "Info",
"entity-rule-editor": "Entity Rule Editor",
"false-positive": "False Positive",
"false-recommendations": "False Recommendations",
"file-attributes": "File Attributes",
"justifications": "Justifications",
"license-information": "License Information",
"reports": "Reports",
"rule-editor": "Rule Editor",
"settings": "Settings",
"user-management": "User Management",
"watermarks": "Watermarks"
@ -1284,6 +1284,19 @@
"title": "{length} {length, plural, one{entity} other{entities}}"
}
},
"entity-rules-screen": {
"error": {
"generic": "Something went wrong... Entity rules update failed!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Entity rules updated!"
},
"title": "Entity Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"entity": {
"info": {
"actions": {
@ -2239,19 +2252,6 @@
},
"title": "Structured Component Management"
},
"rules-screen": {
"error": {
"generic": "Something went wrong... Rules update failed!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Rules updated!"
},
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"search-screen": {
"cols": {
"assignee": "Assignee",

View File

@ -245,13 +245,13 @@
"dossier-templates": "Dossier-Vorlage",
"entities": "",
"entity-info": "",
"entity-rule-editor": "",
"false-positive": "",
"false-recommendations": "",
"file-attributes": "",
"justifications": "",
"license-information": "",
"reports": "",
"rule-editor": "",
"settings": "Einstellungen",
"user-management": "",
"watermarks": ""
@ -1284,6 +1284,19 @@
"title": "{length} {length, plural, one{Wörterbuch} other{Wörterbücher}}"
}
},
"entity-rules-screen": {
"error": {
"generic": ""
},
"errors-found": "",
"revert-changes": "",
"save-changes": "",
"success": {
"generic": ""
},
"title": "",
"warning-text": ""
},
"entity": {
"info": {
"actions": {
@ -2239,19 +2252,6 @@
},
"title": ""
},
"rules-screen": {
"error": {
"generic": "Es ist ein Fehler aufgetreten ... Die Regeln konnten nicht aktualisiert werden!"
},
"errors-found": "",
"revert-changes": "Anmeldedaten speichern",
"save-changes": "Änderungen speichern",
"success": {
"generic": "Die Regeln wurden aktualisiert!"
},
"title": "",
"warning-text": ""
},
"search-screen": {
"cols": {
"assignee": "Bevollmächtigter",

View File

@ -245,13 +245,13 @@
"dossier-templates": "Dossier Templates",
"entities": "Entities",
"entity-info": "Info",
"entity-rule-editor": "Entity Rule Editor",
"false-positive": "False Positive",
"false-recommendations": "False Recommendations",
"file-attributes": "File Attributes",
"justifications": "Justifications",
"license-information": "License Information",
"reports": "Reports",
"rule-editor": "Rule Editor",
"settings": "Settings",
"user-management": "User Management",
"watermarks": "Watermarks"
@ -1284,6 +1284,19 @@
"title": "{length} {length, plural, one{entity} other{entities}}"
}
},
"entity-rules-screen": {
"error": {
"generic": "Something went wrong... Entity rules update failed!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Entity rules updated!"
},
"title": "Entity Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"entity": {
"info": {
"actions": {
@ -2239,19 +2252,6 @@
},
"title": "Component View"
},
"rules-screen": {
"error": {
"generic": "Something went wrong... Rules update failed!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Rules updated!"
},
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"search-screen": {
"cols": {
"assignee": "Assignee",

View File

@ -3,9 +3,13 @@
*/
export interface IRules {
/**
* The DossierTemplate Id for these rules
* The DossierTemplate ID for these rules
*/
dossierTemplateId?: string;
/**
* The file type to be retrieved/saved under, defaults to ENTITY
*/
ruleFileType?: 'ENTITY' | 'COMPONENT';
/**
* The actual string of rules.
*/