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