RED-10498 - added the locked rules indicator; implemented the reset.
This commit is contained in:
parent
887157e588
commit
301616fb06
@ -12,6 +12,7 @@ import { DefaultColorsService } from '@services/entity-services/default-colors.s
|
|||||||
import { WatermarkService } from '@services/entity-services/watermark.service';
|
import { WatermarkService } from '@services/entity-services/watermark.service';
|
||||||
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
||||||
import { getConfig } from '@iqser/common-ui';
|
import { getConfig } from '@iqser/common-ui';
|
||||||
|
import { RulesService } from '../modules/admin/services/rules.service';
|
||||||
|
|
||||||
export function templateExistsWhenEnteringAdmin(): CanActivateFn {
|
export function templateExistsWhenEnteringAdmin(): CanActivateFn {
|
||||||
return async function (route: ActivatedRouteSnapshot): Promise<boolean> {
|
return async function (route: ActivatedRouteSnapshot): Promise<boolean> {
|
||||||
@ -21,12 +22,14 @@ export function templateExistsWhenEnteringAdmin(): CanActivateFn {
|
|||||||
const defaultColorsService = inject(DefaultColorsService);
|
const defaultColorsService = inject(DefaultColorsService);
|
||||||
const watermarksService = inject(WatermarkService);
|
const watermarksService = inject(WatermarkService);
|
||||||
const router = inject(Router);
|
const router = inject(Router);
|
||||||
|
const rulesService = inject(RulesService);
|
||||||
const isDocumine = getConfig().IS_DOCUMINE;
|
const isDocumine = getConfig().IS_DOCUMINE;
|
||||||
|
|
||||||
const dossierTemplate = inject(DossierTemplateStatsService).get(dossierTemplateId);
|
const dossierTemplate = inject(DossierTemplateStatsService).get(dossierTemplateId);
|
||||||
await firstValueFrom(fileAttributesService.loadFileAttributesConfig(dossierTemplateId));
|
await firstValueFrom(fileAttributesService.loadFileAttributesConfig(dossierTemplateId));
|
||||||
await firstValueFrom(dictionaryService.loadDictionaryDataForDossierTemplate(dossierTemplateId));
|
await firstValueFrom(dictionaryService.loadDictionaryDataForDossierTemplate(dossierTemplateId));
|
||||||
await firstValueFrom(defaultColorsService.loadForDossierTemplate(dossierTemplateId));
|
await firstValueFrom(defaultColorsService.loadForDossierTemplate(dossierTemplateId));
|
||||||
|
await firstValueFrom(rulesService.getFor(dossierTemplateId));
|
||||||
if (!isDocumine) {
|
if (!isDocumine) {
|
||||||
await firstValueFrom(watermarksService.loadForDossierTemplate(dossierTemplateId));
|
await firstValueFrom(watermarksService.loadForDossierTemplate(dossierTemplateId));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,16 @@
|
|||||||
<span [innerHTML]="'dossier-template-info-screen.created-on' | translate: { date: createdOn }"></span>
|
<span [innerHTML]="'dossier-template-info-screen.created-on' | translate: { date: createdOn }"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="areRulesLocked()">
|
||||||
|
<mat-icon
|
||||||
|
(click)="resetRules()"
|
||||||
|
[matTooltip]="'dossier-template-info-screen.rules-reset.tooltip' | translate"
|
||||||
|
svgIcon="iqser:alert-circle"
|
||||||
|
class="action-icon"
|
||||||
|
></mat-icon>
|
||||||
|
<span class="error">{{ 'dossier-template-info-screen.rules-reset.label' | translate }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<mat-icon svgIcon="red:entries"></mat-icon>
|
<mat-icon svgIcon="red:entries"></mat-icon>
|
||||||
{{ 'dossier-template-info-screen.entries' | translate: { count: ctx.stats.numberOfEntries } }}
|
{{ 'dossier-template-info-screen.entries' | translate: { count: ctx.stats.numberOfEntries } }}
|
||||||
|
|||||||
@ -18,3 +18,11 @@
|
|||||||
padding-right: 24px;
|
padding-right: 24px;
|
||||||
margin-right: 24px;
|
margin-right: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: var(--iqser-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-icon {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, computed, Input, OnInit } from '@angular/core';
|
||||||
import { ContextComponent } from '@iqser/common-ui/lib/utils';
|
import { ContextComponent } from '@iqser/common-ui/lib/utils';
|
||||||
import { type DossierTemplate, type DossierTemplateStats } from '@red/domain';
|
import { type DossierTemplate, type DossierTemplateStats } from '@red/domain';
|
||||||
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
||||||
@ -9,6 +9,11 @@ import { MatIcon } from '@angular/material/icon';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { InitialsAvatarComponent } from '@common-ui/users';
|
import { InitialsAvatarComponent } from '@common-ui/users';
|
||||||
import { DatePipe } from '@shared/pipes/date.pipe';
|
import { DatePipe } from '@shared/pipes/date.pipe';
|
||||||
|
import { RulesService } from '../../../services/rules.service';
|
||||||
|
import { Toaster } from '@iqser/common-ui';
|
||||||
|
import { MatTooltip } from '@angular/material/tooltip';
|
||||||
|
import { firstValueFrom } from 'rxjs';
|
||||||
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
readonly dossierTemplate: DossierTemplate;
|
readonly dossierTemplate: DossierTemplate;
|
||||||
@ -20,16 +25,20 @@ interface Context {
|
|||||||
templateUrl: './dossier-template-details.component.html',
|
templateUrl: './dossier-template-details.component.html',
|
||||||
styleUrls: ['./dossier-template-details.component.scss'],
|
styleUrls: ['./dossier-template-details.component.scss'],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [NgIf, AsyncPipe, MatIcon, TranslateModule, DatePipe, InitialsAvatarComponent],
|
imports: [NgIf, AsyncPipe, MatIcon, TranslateModule, DatePipe, InitialsAvatarComponent, MatTooltip],
|
||||||
})
|
})
|
||||||
export class DossierTemplateDetailsComponent extends ContextComponent<Context> implements OnInit {
|
export class DossierTemplateDetailsComponent extends ContextComponent<Context> implements OnInit {
|
||||||
readonly translations = dossierTemplateStatusTranslations;
|
readonly translations = dossierTemplateStatusTranslations;
|
||||||
|
|
||||||
@Input({ required: true }) dossierTemplateId: string;
|
@Input({ required: true }) dossierTemplateId: string;
|
||||||
|
readonly areRulesLocked = computed(() => {
|
||||||
|
return this._rulesService.currentTemplateRules().timeoutDetected;
|
||||||
|
});
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||||
private readonly _dossierTemplateStatsService: DossierTemplateStatsService,
|
private readonly _dossierTemplateStatsService: DossierTemplateStatsService,
|
||||||
|
private readonly _rulesService: RulesService,
|
||||||
|
private readonly _toaster: Toaster,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -40,4 +49,14 @@ export class DossierTemplateDetailsComponent extends ContextComponent<Context> i
|
|||||||
stats: this._dossierTemplateStatsService.watch$(this.dossierTemplateId),
|
stats: this._dossierTemplateStatsService.watch$(this.dossierTemplateId),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetRules() {
|
||||||
|
try {
|
||||||
|
await firstValueFrom(this._rulesService.reset(this.dossierTemplateId));
|
||||||
|
this._toaster.success(_('dossier-template-info-screen.rules-reset.success'));
|
||||||
|
await firstValueFrom(this._rulesService.getFor(this.dossierTemplateId));
|
||||||
|
} catch (error) {
|
||||||
|
this._toaster.rawError(error.error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,25 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { GenericService } from '@iqser/common-ui';
|
import { EntitiesService, QueryParam } from '@iqser/common-ui';
|
||||||
import { IRules } from '@red/domain';
|
import { IRules, Rules } from '@red/domain';
|
||||||
|
import { map, Observable, tap } from 'rxjs';
|
||||||
|
import { List } from '@common-ui/utils';
|
||||||
|
import { toSignal } from '@angular/core/rxjs-interop';
|
||||||
|
import { distinctUntilChanged, filter } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable({ providedIn: 'root' })
|
||||||
export class RulesService extends GenericService<IRules> {
|
export class RulesService extends EntitiesService<IRules, Rules> {
|
||||||
|
readonly currentTemplateRules = toSignal(
|
||||||
|
this.all$.pipe(
|
||||||
|
filter(all => !!all.length),
|
||||||
|
map(rules => rules[0]),
|
||||||
|
distinctUntilChanged(
|
||||||
|
(prev, curr) =>
|
||||||
|
prev.rules === curr.rules &&
|
||||||
|
prev.timeoutDetected === curr.timeoutDetected &&
|
||||||
|
prev.dossierTemplateId === curr.dossierTemplateId,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
protected readonly _defaultModelPath = 'rules';
|
protected readonly _defaultModelPath = 'rules';
|
||||||
|
|
||||||
download(dossierTemplateId: string, ruleFileType: IRules['ruleFileType'] = 'ENTITY') {
|
download(dossierTemplateId: string, ruleFileType: IRules['ruleFileType'] = 'ENTITY') {
|
||||||
@ -13,4 +29,12 @@ export class RulesService extends GenericService<IRules> {
|
|||||||
uploadRules(body: IRules) {
|
uploadRules(body: IRules) {
|
||||||
return this._post<unknown>({ ...body, ruleFileType: body.ruleFileType ?? 'ENTITY' });
|
return this._post<unknown>({ ...body, ruleFileType: body.ruleFileType ?? 'ENTITY' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFor<R = IRules>(entityId: string, queryParams?: List<QueryParam>): Observable<R> {
|
||||||
|
return super.getFor<R>(entityId, queryParams).pipe(tap(rules => this.setEntities([rules as Rules])));
|
||||||
|
}
|
||||||
|
|
||||||
|
reset(dossierTemplateId: string, ruleFileType: IRules['ruleFileType'] = 'ENTITY') {
|
||||||
|
return this._put(null, `${this._defaultModelPath}/${dossierTemplateId}/${ruleFileType}/reset`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1069,6 +1069,11 @@
|
|||||||
"entities": "{count} {count, plural, one{Entität} other{Entitäten}}",
|
"entities": "{count} {count, plural, one{Entität} other{Entitäten}}",
|
||||||
"entries": "{count} {count, plural, one{Eintrag} other{Einträge}}",
|
"entries": "{count} {count, plural, one{Eintrag} other{Einträge}}",
|
||||||
"modified-on": "Geändert am: {date}",
|
"modified-on": "Geändert am: {date}",
|
||||||
|
"rules-reset": {
|
||||||
|
"label": "Regeln gesperrt",
|
||||||
|
"success": "Die Regeln der Dossier-Vorlage wurden erfolgreich zurückgesetzt.",
|
||||||
|
"tooltip": "Klicken Sie hier, um die Regeln zurückzusetzen"
|
||||||
|
},
|
||||||
"title": "Dossier-Vorlage bearbeiten",
|
"title": "Dossier-Vorlage bearbeiten",
|
||||||
"valid-from": "Gültig ab: {date}",
|
"valid-from": "Gültig ab: {date}",
|
||||||
"valid-to": "Gültig bis: {Datum}"
|
"valid-to": "Gültig bis: {Datum}"
|
||||||
|
|||||||
@ -1069,6 +1069,11 @@
|
|||||||
"entities": "{count} {count, plural, one{entity} other{entities}}",
|
"entities": "{count} {count, plural, one{entity} other{entities}}",
|
||||||
"entries": "{count} {count, plural, one{entry} other{entries}}",
|
"entries": "{count} {count, plural, one{entry} other{entries}}",
|
||||||
"modified-on": "Modified on: {date}",
|
"modified-on": "Modified on: {date}",
|
||||||
|
"rules-reset": {
|
||||||
|
"label": "Rules locked",
|
||||||
|
"success": "Dossier template rules successfully reset.",
|
||||||
|
"tooltip": "Click to reset rules"
|
||||||
|
},
|
||||||
"title": "Edit dossier template",
|
"title": "Edit dossier template",
|
||||||
"valid-from": "Valid from: {date}",
|
"valid-from": "Valid from: {date}",
|
||||||
"valid-to": "Valid to: {date}"
|
"valid-to": "Valid to: {date}"
|
||||||
|
|||||||
@ -1064,14 +1064,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dossier-template-info-screen": {
|
"dossier-template-info-screen": {
|
||||||
"created-by": "Created by",
|
"created-by": "Ersteller",
|
||||||
"created-on": "Created on: {date}",
|
"created-on": "Erstellt am {date}",
|
||||||
"entities": "{count} {count, plural, one{entity} other{entities}}",
|
"entities": "{count} {count, plural, one{Entität} other{Entitäten}}",
|
||||||
"entries": "{count} {count, plural, one{entry} other{entries}}",
|
"entries": "{count} {count, plural, one{Eintrag} other{Einträge}}",
|
||||||
"modified-on": "Modified on: {date}",
|
"modified-on": "Geändert am {date}",
|
||||||
"title": "Edit dossier template",
|
"rules-reset": {
|
||||||
"valid-from": "Valid from: {date}",
|
"label": "Regeln gesperrt",
|
||||||
"valid-to": "Valid to: {date}"
|
"success": "Die Regeln der Dossier-Vorlage wurden erfolgreich zurückgesetzt.",
|
||||||
|
"tooltip": "Klicken Sie hier, um die Regeln zurückzusetzen"
|
||||||
|
},
|
||||||
|
"title": "Dossier-Vorlage bearbeiten",
|
||||||
|
"valid-from": "Gültig ab: {date}",
|
||||||
|
"valid-to": "Gültig bis: {date}"
|
||||||
},
|
},
|
||||||
"dossier-template-stats": {
|
"dossier-template-stats": {
|
||||||
"active-dossiers": "Active {count, plural, one{dossier} other{dossiers}}",
|
"active-dossiers": "Active {count, plural, one{dossier} other{dossiers}}",
|
||||||
|
|||||||
@ -1069,6 +1069,11 @@
|
|||||||
"entities": "{count} {count, plural, one{entity} other{entities}}",
|
"entities": "{count} {count, plural, one{entity} other{entities}}",
|
||||||
"entries": "{count} {count, plural, one{entry} other{entries}}",
|
"entries": "{count} {count, plural, one{entry} other{entries}}",
|
||||||
"modified-on": "Modified on: {date}",
|
"modified-on": "Modified on: {date}",
|
||||||
|
"rules-reset": {
|
||||||
|
"label": "Rules locked",
|
||||||
|
"success": "Dossier template rules successfully reset.",
|
||||||
|
"tooltip": "Click to reset rules"
|
||||||
|
},
|
||||||
"title": "Edit dossier template",
|
"title": "Edit dossier template",
|
||||||
"valid-from": "Valid from: {date}",
|
"valid-from": "Valid from: {date}",
|
||||||
"valid-to": "Valid to: {date}"
|
"valid-to": "Valid to: {date}"
|
||||||
|
|||||||
@ -13,3 +13,4 @@ export * from './app-config';
|
|||||||
export * from './system-preferences';
|
export * from './system-preferences';
|
||||||
export * from './component-rules';
|
export * from './component-rules';
|
||||||
export * from './editor.types';
|
export * from './editor.types';
|
||||||
|
export * from './rules.model';
|
||||||
|
|||||||
23
libs/red-domain/src/lib/shared/rules.model.ts
Normal file
23
libs/red-domain/src/lib/shared/rules.model.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { IRules } from '@red/domain';
|
||||||
|
import { Entity } from '@iqser/common-ui';
|
||||||
|
|
||||||
|
export class Rules extends Entity<IRules> implements IRules {
|
||||||
|
readonly id: string;
|
||||||
|
readonly routerLink: string;
|
||||||
|
readonly searchKey: string;
|
||||||
|
readonly dossierTemplateId: string;
|
||||||
|
readonly ruleFileType?: 'ENTITY' | 'COMPONENT';
|
||||||
|
readonly rules?: string;
|
||||||
|
readonly dryRun?: boolean;
|
||||||
|
readonly timeoutDetected?: boolean;
|
||||||
|
|
||||||
|
constructor(rules: IRules) {
|
||||||
|
super(rules);
|
||||||
|
this.id = rules.dossierTemplateId;
|
||||||
|
this.dossierTemplateId = rules.dossierTemplateId;
|
||||||
|
this.ruleFileType = rules.ruleFileType;
|
||||||
|
this.rules = rules.rules;
|
||||||
|
this.dryRun = rules.dryRun;
|
||||||
|
this.timeoutDetected = rules.timeoutDetected;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,7 +5,7 @@ export interface IRules {
|
|||||||
/**
|
/**
|
||||||
* The DossierTemplate ID for these rules
|
* The DossierTemplate ID for these rules
|
||||||
*/
|
*/
|
||||||
dossierTemplateId?: string;
|
dossierTemplateId: string;
|
||||||
/**
|
/**
|
||||||
* The file type to be retrieved/saved under, defaults to ENTITY
|
* The file type to be retrieved/saved under, defaults to ENTITY
|
||||||
*/
|
*/
|
||||||
@ -18,4 +18,8 @@ export interface IRules {
|
|||||||
* Request param for rules validation, without updating them
|
* Request param for rules validation, without updating them
|
||||||
*/
|
*/
|
||||||
dryRun?: boolean;
|
dryRun?: boolean;
|
||||||
|
/**
|
||||||
|
* Flag which indicates whether the dossier template rules have been locked due to a timeout
|
||||||
|
*/
|
||||||
|
timeoutDetected?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user