extended base dialog for 'document info dialog' component and 'force annotation dialog' compoenent
This commit is contained in:
parent
a590bfc764
commit
85f3088f3a
@ -1,7 +1,7 @@
|
|||||||
<section *ngIf="!!form" class="dialog">
|
<section *ngIf="!!form" class="dialog">
|
||||||
<div class="dialog-header heading-l" translate="document-info.title"></div>
|
<div class="dialog-header heading-l" translate="document-info.title"></div>
|
||||||
|
|
||||||
<form (submit)="saveDocumentInfo()" [formGroup]="form">
|
<form (submit)="save()" [formGroup]="form">
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
<div *ngFor="let attr of attributes" class="iqser-input-group w-300">
|
<div *ngFor="let attr of attributes" class="iqser-input-group w-300">
|
||||||
<label>{{ attr.label }}</label>
|
<label>{{ attr.label }}</label>
|
||||||
@ -9,11 +9,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog-actions">
|
<div class="dialog-actions">
|
||||||
<button [disabled]="form.invalid" color="primary" mat-flat-button type="submit">
|
<button [disabled]="disabled" color="primary" mat-flat-button type="submit">
|
||||||
{{ 'document-info.save' | translate }}
|
{{ 'document-info.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<iqser-circle-button class="dialog-close" icon="iqser:close" mat-dialog-close></iqser-circle-button>
|
<iqser-circle-button class="dialog-close" icon="iqser:close" (action)="close()"></iqser-circle-button>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, Injector, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
import { Dossier, File, IFileAttributeConfig } from '@red/domain';
|
import { Dossier, File, IFileAttributeConfig } from '@red/domain';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
||||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||||
import { FilesService } from '@services/entity-services/files.service';
|
import { FilesService } from '@services/entity-services/files.service';
|
||||||
|
import { BaseDialogComponent } from '@iqser/common-ui';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './document-info-dialog.component.html',
|
templateUrl: './document-info-dialog.component.html',
|
||||||
styleUrls: ['./document-info-dialog.component.scss'],
|
styleUrls: ['./document-info-dialog.component.scss'],
|
||||||
})
|
})
|
||||||
export class DocumentInfoDialogComponent implements OnInit {
|
export class DocumentInfoDialogComponent extends BaseDialogComponent implements OnInit {
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
attributes: IFileAttributeConfig[];
|
attributes: IFileAttributeConfig[];
|
||||||
|
|
||||||
@ -21,27 +22,31 @@ export class DocumentInfoDialogComponent implements OnInit {
|
|||||||
private readonly _formBuilder: FormBuilder,
|
private readonly _formBuilder: FormBuilder,
|
||||||
private readonly _fileAttributesService: FileAttributesService,
|
private readonly _fileAttributesService: FileAttributesService,
|
||||||
private readonly _filesService: FilesService,
|
private readonly _filesService: FilesService,
|
||||||
public dialogRef: MatDialogRef<DocumentInfoDialogComponent>,
|
protected readonly _injector: Injector,
|
||||||
|
protected readonly _dialogRef: MatDialogRef<DocumentInfoDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) readonly data: File,
|
@Inject(MAT_DIALOG_DATA) readonly data: File,
|
||||||
) {
|
) {
|
||||||
|
super(_injector, _dialogRef);
|
||||||
this._dossier = this._dossiersService.find(this.data.dossierId);
|
this._dossier = this._dossiersService.find(this.data.dossierId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
super.ngOnInit();
|
||||||
this.attributes = (
|
this.attributes = (
|
||||||
await this._fileAttributesService.getFileAttributesConfig(this._dossier.dossierTemplateId).toPromise()
|
await this._fileAttributesService.getFileAttributesConfig(this._dossier.dossierTemplateId).toPromise()
|
||||||
).fileAttributeConfigs.filter(attr => attr.editable);
|
).fileAttributeConfigs.filter(attr => attr.editable);
|
||||||
this.form = this._getForm();
|
this.form = this._getForm();
|
||||||
|
this.initialFormValue = this.form.getRawValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveDocumentInfo() {
|
async save() {
|
||||||
const attributeIdToValue = {
|
const attributeIdToValue = {
|
||||||
...this.data.fileAttributes?.attributeIdToValue,
|
...this.data.fileAttributes?.attributeIdToValue,
|
||||||
...this.form.getRawValue(),
|
...this.form.getRawValue(),
|
||||||
};
|
};
|
||||||
await this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId).toPromise();
|
await this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId).toPromise();
|
||||||
this._filesService.reload(this.data.dossierId, this.data.fileId);
|
this._filesService.reload(this.data.dossierId, this.data.fileId);
|
||||||
this.dialogRef.close(true);
|
this._dialogRef.close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getForm(): FormGroup {
|
private _getForm(): FormGroup {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<section class="dialog">
|
<section class="dialog">
|
||||||
<form (submit)="handleForceAnnotation()" [formGroup]="redactionForm">
|
<form (submit)="save()" [formGroup]="form">
|
||||||
<div class="dialog-header heading-l" translate="manual-annotation.dialog.header.force-redaction" *ngIf="!isHintDialog"></div>
|
<div class="dialog-header heading-l" translate="manual-annotation.dialog.header.force-redaction" *ngIf="!isHintDialog"></div>
|
||||||
<div class="dialog-header heading-l" translate="manual-annotation.dialog.header.force-hint" *ngIf="isHintDialog"></div>
|
<div class="dialog-header heading-l" translate="manual-annotation.dialog.header.force-hint" *ngIf="isHintDialog"></div>
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<div class="iqser-input-group w-400" *ngIf="!isHintDialog">
|
<div class="iqser-input-group w-400" *ngIf="!isHintDialog">
|
||||||
<label translate="manual-annotation.dialog.content.legalBasis"></label>
|
<label translate="manual-annotation.dialog.content.legalBasis"></label>
|
||||||
<input [value]="redactionForm.get('reason').value?.legalBasis" disabled type="text" />
|
<input [value]="form.get('reason').value?.legalBasis" disabled type="text" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div [class.required]="!isDocumentAdmin" class="iqser-input-group w-300">
|
<div [class.required]="!isDocumentAdmin" class="iqser-input-group w-300">
|
||||||
@ -29,11 +29,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dialog-actions">
|
<div class="dialog-actions">
|
||||||
<button [disabled]="!redactionForm.valid" color="primary" mat-flat-button type="submit">
|
<button [disabled]="disabled" color="primary" mat-flat-button type="submit">
|
||||||
{{ 'manual-annotation.dialog.actions.save' | translate }}
|
{{ 'manual-annotation.dialog.actions.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<iqser-circle-button class="dialog-close" icon="iqser:close" mat-dialog-close></iqser-circle-button>
|
<iqser-circle-button class="dialog-close" icon="iqser:close" (action)="close()"></iqser-circle-button>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, Injector, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { Toaster } from '@iqser/common-ui';
|
import { BaseDialogComponent, Toaster } from '@iqser/common-ui';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { UserService } from '@services/user.service';
|
import { UserService } from '@services/user.service';
|
||||||
import { ManualAnnotationService } from '../../services/manual-annotation.service';
|
import { ManualAnnotationService } from '../../services/manual-annotation.service';
|
||||||
@ -21,8 +21,7 @@ export interface LegalBasisOption {
|
|||||||
templateUrl: './force-annotation-dialog.component.html',
|
templateUrl: './force-annotation-dialog.component.html',
|
||||||
styleUrls: ['./force-annotation-dialog.component.scss'],
|
styleUrls: ['./force-annotation-dialog.component.scss'],
|
||||||
})
|
})
|
||||||
export class ForceAnnotationDialogComponent implements OnInit {
|
export class ForceAnnotationDialogComponent extends BaseDialogComponent implements OnInit {
|
||||||
redactionForm: FormGroup;
|
|
||||||
isDocumentAdmin: boolean;
|
isDocumentAdmin: boolean;
|
||||||
legalOptions: LegalBasisOption[] = [];
|
legalOptions: LegalBasisOption[] = [];
|
||||||
|
|
||||||
@ -35,10 +34,13 @@ export class ForceAnnotationDialogComponent implements OnInit {
|
|||||||
private readonly _justificationsService: JustificationsService,
|
private readonly _justificationsService: JustificationsService,
|
||||||
private readonly _manualAnnotationService: ManualAnnotationService,
|
private readonly _manualAnnotationService: ManualAnnotationService,
|
||||||
private readonly _permissionsService: PermissionsService,
|
private readonly _permissionsService: PermissionsService,
|
||||||
public dialogRef: MatDialogRef<ForceAnnotationDialogComponent>,
|
protected readonly _injector: Injector,
|
||||||
|
protected readonly _dialogRef: MatDialogRef<ForceAnnotationDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) private readonly _data: { readonly dossier: Dossier; readonly hint: boolean },
|
@Inject(MAT_DIALOG_DATA) private readonly _data: { readonly dossier: Dossier; readonly hint: boolean },
|
||||||
) {
|
) {
|
||||||
this.redactionForm = this._getForm();
|
super(_injector, _dialogRef);
|
||||||
|
this.form = this._getForm();
|
||||||
|
this.initialFormValue = this.form.getRawValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
get isHintDialog() {
|
get isHintDialog() {
|
||||||
@ -55,6 +57,7 @@ export class ForceAnnotationDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
super.ngOnInit();
|
||||||
const data = await this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId).toPromise();
|
const data = await this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId).toPromise();
|
||||||
|
|
||||||
this.legalOptions = data.map(lbm => ({
|
this.legalOptions = data.map(lbm => ({
|
||||||
@ -66,17 +69,17 @@ export class ForceAnnotationDialogComponent implements OnInit {
|
|||||||
this.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
|
this.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleForceAnnotation() {
|
save() {
|
||||||
this.dialogRef.close(this._createForceRedactionRequest());
|
this._dialogRef.close(this._createForceRedactionRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createForceRedactionRequest(): ILegalBasisChangeRequest {
|
private _createForceRedactionRequest(): ILegalBasisChangeRequest {
|
||||||
const request: ILegalBasisChangeRequest = {};
|
const request: ILegalBasisChangeRequest = {};
|
||||||
|
|
||||||
const legalOption: LegalBasisOption = this.redactionForm.get('reason').value;
|
const legalOption: LegalBasisOption = this.form.get('reason').value;
|
||||||
|
|
||||||
request.legalBasis = legalOption.legalBasis;
|
request.legalBasis = legalOption.legalBasis;
|
||||||
request.comment = this.redactionForm.get('comment').value;
|
request.comment = this.form.get('comment').value;
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user