renamed forms to "form"
This commit is contained in:
parent
35385db948
commit
195cb571f6
@ -39,14 +39,10 @@ export class NotificationsComponent extends AutoUnsubscribe implements OnInit {
|
|||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.notifications$ = this._notifications$.asObservable().pipe(shareLast());
|
this.notifications$ = this._notifications$.asObservable().pipe(shareLast());
|
||||||
this.groupedNotifications$ = this._groupedNotifications$;
|
this.groupedNotifications$ = this.notifications$.pipe(map(notifications => this._groupNotifications(notifications)));
|
||||||
this.hasUnreadNotifications$ = this._hasUnreadNotifications$;
|
this.hasUnreadNotifications$ = this._hasUnreadNotifications$;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
|
||||||
await this._loadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
await this._loadData();
|
await this._loadData();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<section class="dialog">
|
<section class="dialog">
|
||||||
<form (submit)="saveDossier()" [formGroup]="dossierForm">
|
<form (submit)="saveDossier()" [formGroup]="form">
|
||||||
<div class="dialog-header heading-l" translate="add-dossier-dialog.header-new"></div>
|
<div class="dialog-header heading-l" translate="add-dossier-dialog.header-new"></div>
|
||||||
|
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { ReportTemplateService } from '@services/report-template.service';
|
|||||||
export class AddDossierDialogComponent {
|
export class AddDossierDialogComponent {
|
||||||
readonly iconButtonTypes = IconButtonTypes;
|
readonly iconButtonTypes = IconButtonTypes;
|
||||||
|
|
||||||
readonly dossierForm: FormGroup;
|
readonly form: FormGroup;
|
||||||
hasDueDate = false;
|
hasDueDate = false;
|
||||||
downloadTypes: { key: DownloadFileType; label: string }[] = ['ORIGINAL', 'PREVIEW', 'REDACTED'].map((type: DownloadFileType) => ({
|
downloadTypes: { key: DownloadFileType; label: string }[] = ['ORIGINAL', 'PREVIEW', 'REDACTED'].map((type: DownloadFileType) => ({
|
||||||
key: type,
|
key: type,
|
||||||
@ -33,7 +33,7 @@ export class AddDossierDialogComponent {
|
|||||||
readonly dialogRef: MatDialogRef<AddDossierDialogComponent>,
|
readonly dialogRef: MatDialogRef<AddDossierDialogComponent>,
|
||||||
) {
|
) {
|
||||||
this._getDossierTemplates();
|
this._getDossierTemplates();
|
||||||
this.dossierForm = this._getForm();
|
this.form = this._getForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getForm(): FormGroup {
|
private _getForm(): FormGroup {
|
||||||
@ -58,19 +58,19 @@ export class AddDossierDialogComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get reportTemplateIdsLength() {
|
get reportTemplateIdsLength() {
|
||||||
return this.dossierForm.controls['reportTemplateIds']?.value?.length || 0;
|
return this.form.controls['reportTemplateIds']?.value?.length || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
get downloadFileTypesLength() {
|
get downloadFileTypesLength() {
|
||||||
return this.dossierForm.controls['downloadFileTypes']?.value?.length || 0;
|
return this.form.controls['downloadFileTypes']?.value?.length || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
get disabled() {
|
get disabled() {
|
||||||
if (this.hasDueDate && this.dossierForm.get('dueDate').value === null) {
|
if (this.hasDueDate && this.form.get('dueDate').value === null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.dossierForm.invalid;
|
return this.form.invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId;
|
reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId;
|
||||||
@ -90,7 +90,7 @@ export class AddDossierDialogComponent {
|
|||||||
this.availableReportTypes =
|
this.availableReportTypes =
|
||||||
(await this._reportTemplateController.getAvailableReportTemplates(dossierTemplate.dossierTemplateId).toPromise()) || [];
|
(await this._reportTemplateController.getAvailableReportTemplates(dossierTemplate.dossierTemplateId).toPromise()) || [];
|
||||||
// update dropdown values
|
// update dropdown values
|
||||||
this.dossierForm.patchValue(
|
this.form.patchValue(
|
||||||
{
|
{
|
||||||
downloadFileTypes: dossierTemplate.downloadFileTypes,
|
downloadFileTypes: dossierTemplate.downloadFileTypes,
|
||||||
reportTemplateIds: [], // TODO DEFAULT
|
reportTemplateIds: [], // TODO DEFAULT
|
||||||
@ -99,7 +99,7 @@ export class AddDossierDialogComponent {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.availableReportTypes = [];
|
this.availableReportTypes = [];
|
||||||
this.dossierForm.patchValue(
|
this.form.patchValue(
|
||||||
{
|
{
|
||||||
downloadFileTypes: [],
|
downloadFileTypes: [],
|
||||||
reportTemplateIds: [],
|
reportTemplateIds: [],
|
||||||
@ -121,14 +121,14 @@ export class AddDossierDialogComponent {
|
|||||||
|
|
||||||
private _formToObject(): IDossierRequest {
|
private _formToObject(): IDossierRequest {
|
||||||
return {
|
return {
|
||||||
dossierName: this.dossierForm.get('dossierName').value,
|
dossierName: this.form.get('dossierName').value,
|
||||||
description: this.dossierForm.get('description').value,
|
description: this.form.get('description').value,
|
||||||
dueDate: this.hasDueDate ? this.dossierForm.get('dueDate').value : undefined,
|
dueDate: this.hasDueDate ? this.form.get('dueDate').value : undefined,
|
||||||
dossierTemplateId: this.dossierForm.get('dossierTemplateId').value,
|
dossierTemplateId: this.form.get('dossierTemplateId').value,
|
||||||
downloadFileTypes: this.dossierForm.get('downloadFileTypes').value,
|
downloadFileTypes: this.form.get('downloadFileTypes').value,
|
||||||
reportTemplateIds: this.dossierForm.get('reportTemplateIds').value,
|
reportTemplateIds: this.form.get('reportTemplateIds').value,
|
||||||
watermarkEnabled: this.dossierForm.get('watermarkEnabled').value,
|
watermarkEnabled: this.form.get('watermarkEnabled').value,
|
||||||
watermarkPreviewEnabled: this.dossierForm.get('watermarkPreviewEnabled').value,
|
watermarkPreviewEnabled: this.form.get('watermarkPreviewEnabled').value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class DialogData {
|
|||||||
styleUrls: ['./assign-reviewer-approver-dialog.component.scss'],
|
styleUrls: ['./assign-reviewer-approver-dialog.component.scss'],
|
||||||
})
|
})
|
||||||
export class AssignReviewerApproverDialogComponent {
|
export class AssignReviewerApproverDialogComponent {
|
||||||
form: FormGroup;
|
readonly form: FormGroup;
|
||||||
dossier: Dossier;
|
dossier: Dossier;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -36,7 +36,7 @@ export class AssignReviewerApproverDialogComponent {
|
|||||||
@Inject(MAT_DIALOG_DATA) readonly data: DialogData,
|
@Inject(MAT_DIALOG_DATA) readonly data: DialogData,
|
||||||
) {
|
) {
|
||||||
this.dossier = this._dossiersService.find(this.data.files[0].dossierId);
|
this.dossier = this._dossiersService.find(this.data.files[0].dossierId);
|
||||||
this._loadData();
|
this.form = this._getForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
get selectedUser(): string {
|
get selectedUser(): string {
|
||||||
@ -102,20 +102,27 @@ export class AssignReviewerApproverDialogComponent {
|
|||||||
* the id of the current reviewer of the files list if there is only one reviewer for all of them;
|
* the id of the current reviewer of the files list if there is only one reviewer for all of them;
|
||||||
* or the id of the current user
|
* or the id of the current user
|
||||||
**/
|
**/
|
||||||
private _loadData() {
|
|
||||||
|
private get _uniqueReviewers(): Set<string> {
|
||||||
const uniqueReviewers = new Set<string>();
|
const uniqueReviewers = new Set<string>();
|
||||||
for (const file of this.data.files) {
|
for (const file of this.data.files) {
|
||||||
if (file.currentReviewer) {
|
if (file.currentReviewer) {
|
||||||
uniqueReviewers.add(file.currentReviewer);
|
uniqueReviewers.add(file.currentReviewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let user: string = uniqueReviewers.size === 1 ? uniqueReviewers.values().next().value : this.userService.currentUser.id;
|
return uniqueReviewers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private get _user(): string {
|
||||||
|
let user: string = this._uniqueReviewers.size === 1 ? this._uniqueReviewers.values().next().value : this.userService.currentUser.id;
|
||||||
user = this.userOptions.indexOf(user) >= 0 ? user : this.userOptions[0];
|
user = this.userOptions.indexOf(user) >= 0 ? user : this.userOptions[0];
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
this.form = this._formBuilder.group({
|
private _getForm(): FormGroup {
|
||||||
|
return this._formBuilder.group({
|
||||||
// Allow a null reviewer if a previous reviewer exists (= it's not the first assignment) & current user is allowed to unassign
|
// Allow a null reviewer if a previous reviewer exists (= it's not the first assignment) & current user is allowed to unassign
|
||||||
user: [user, this._canUnassignFiles && !user ? Validators.required : null],
|
user: [this._user, this._canUnassignFiles && !this._user ? Validators.required : null],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<section class="dialog">
|
<section class="dialog">
|
||||||
<form (submit)="save()" [formGroup]="legalBasisForm">
|
<form (submit)="save()" [formGroup]="form">
|
||||||
<div class="dialog-header heading-l" translate="change-legal-basis-dialog.header"></div>
|
<div class="dialog-header heading-l" translate="change-legal-basis-dialog.header"></div>
|
||||||
|
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<div class="iqser-input-group w-400">
|
<div class="iqser-input-group w-400">
|
||||||
<label translate="change-legal-basis-dialog.content.legalBasis"></label>
|
<label translate="change-legal-basis-dialog.content.legalBasis"></label>
|
||||||
<input [value]="legalBasisForm.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">
|
||||||
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dialog-actions">
|
<div class="dialog-actions">
|
||||||
<button [disabled]="!legalBasisForm.valid || !changed" color="primary" mat-flat-button type="submit">
|
<button [disabled]="!form.valid || !changed" color="primary" mat-flat-button type="submit">
|
||||||
{{ 'change-legal-basis-dialog.actions.save' | translate }}
|
{{ 'change-legal-basis-dialog.actions.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<div class="all-caps-label cancel" mat-dialog-close translate="change-legal-basis-dialog.actions.cancel"></div>
|
<div class="all-caps-label cancel" mat-dialog-close translate="change-legal-basis-dialog.actions.cancel"></div>
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export interface LegalBasisOption {
|
|||||||
templateUrl: './change-legal-basis-dialog.component.html',
|
templateUrl: './change-legal-basis-dialog.component.html',
|
||||||
})
|
})
|
||||||
export class ChangeLegalBasisDialogComponent implements OnInit {
|
export class ChangeLegalBasisDialogComponent implements OnInit {
|
||||||
legalBasisForm: FormGroup;
|
form: FormGroup = this._getForm();
|
||||||
isDocumentAdmin: boolean;
|
isDocumentAdmin: boolean;
|
||||||
legalOptions: LegalBasisOption[] = [];
|
legalOptions: LegalBasisOption[] = [];
|
||||||
|
|
||||||
@ -31,17 +31,10 @@ export class ChangeLegalBasisDialogComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
get changed(): boolean {
|
get changed(): boolean {
|
||||||
return this.legalBasisForm.get('reason').value.legalBasis !== this._data.annotations[0].legalBasis;
|
return this.form.get('reason').value.legalBasis !== this._data.annotations[0].legalBasis;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
|
||||||
|
|
||||||
this.legalBasisForm = this._formBuilder.group({
|
|
||||||
reason: [null, Validators.required],
|
|
||||||
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
|
||||||
});
|
|
||||||
|
|
||||||
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
|
this.legalOptions = data
|
||||||
@ -52,13 +45,13 @@ export class ChangeLegalBasisDialogComponent implements OnInit {
|
|||||||
}))
|
}))
|
||||||
.sort((a, b) => a.label.localeCompare(b.label));
|
.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
|
|
||||||
this.legalBasisForm.patchValue({
|
this.form.patchValue({
|
||||||
reason: this.legalOptions.find(option => option.legalBasis === this._data.annotations[0].legalBasis),
|
reason: this.legalOptions.find(option => option.legalBasis === this._data.annotations[0].legalBasis),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getForm(): FormGroup {
|
private _getForm(): FormGroup {
|
||||||
this.isDocumentAdmin = this._permissionsService.isApprover();
|
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
||||||
return this._formBuilder.group({
|
return this._formBuilder.group({
|
||||||
reason: [null, Validators.required],
|
reason: [null, Validators.required],
|
||||||
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
||||||
@ -67,8 +60,8 @@ export class ChangeLegalBasisDialogComponent implements OnInit {
|
|||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.dialogRef.close({
|
this.dialogRef.close({
|
||||||
legalBasis: this.legalBasisForm.get('reason').value.legalBasis,
|
legalBasis: this.form.get('reason').value.legalBasis,
|
||||||
comment: this.legalBasisForm.get('comment').value,
|
comment: this.form.get('comment').value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<section *ngIf="!!documentInfoForm" 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]="documentInfoForm">
|
<form (submit)="saveDocumentInfo()" [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,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog-actions">
|
<div class="dialog-actions">
|
||||||
<button [disabled]="documentInfoForm.invalid" color="primary" mat-flat-button type="submit">
|
<button [disabled]="form.invalid" color="primary" mat-flat-button type="submit">
|
||||||
{{ 'document-info.save' | translate }}
|
{{ 'document-info.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -11,8 +11,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
|
|||||||
styleUrls: ['./document-info-dialog.component.scss'],
|
styleUrls: ['./document-info-dialog.component.scss'],
|
||||||
})
|
})
|
||||||
export class DocumentInfoDialogComponent implements OnInit {
|
export class DocumentInfoDialogComponent implements OnInit {
|
||||||
documentInfoForm: FormGroup;
|
form: FormGroup;
|
||||||
file: IFile;
|
|
||||||
attributes: IFileAttributeConfig[];
|
attributes: IFileAttributeConfig[];
|
||||||
|
|
||||||
private readonly _dossier: Dossier;
|
private readonly _dossier: Dossier;
|
||||||
@ -25,31 +24,35 @@ export class DocumentInfoDialogComponent implements OnInit {
|
|||||||
public dialogRef: MatDialogRef<DocumentInfoDialogComponent>,
|
public dialogRef: MatDialogRef<DocumentInfoDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: IFile,
|
@Inject(MAT_DIALOG_DATA) public data: IFile,
|
||||||
) {
|
) {
|
||||||
this.file = this.data;
|
this._dossier = this._dossiersService.find(this.data.dossierId);
|
||||||
this._dossier = this._dossiersService.find(this.file.dossierId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async 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);
|
||||||
const formConfig = this.attributes.reduce(
|
this.form = this._getForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
|
return this._formBuilder.group(
|
||||||
|
this.attributes.reduce(
|
||||||
(acc, attr) => ({
|
(acc, attr) => ({
|
||||||
...acc,
|
...acc,
|
||||||
[attr.id]: [this.file.fileAttributes?.attributeIdToValue[attr.id]],
|
[attr.id]: [this.data.fileAttributes?.attributeIdToValue[attr.id]],
|
||||||
}),
|
}),
|
||||||
{},
|
{},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
this.documentInfoForm = this._formBuilder.group(formConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveDocumentInfo() {
|
async saveDocumentInfo() {
|
||||||
const attributeIdToValue = {
|
const attributeIdToValue = {
|
||||||
...this.file.fileAttributes?.attributeIdToValue,
|
...this.data.fileAttributes?.attributeIdToValue,
|
||||||
...this.documentInfoForm.getRawValue(),
|
...this.form.getRawValue(),
|
||||||
};
|
};
|
||||||
await this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.file.dossierId, this.file.fileId).toPromise();
|
await this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.data.dossierId, this.data.fileId).toPromise();
|
||||||
this.file.fileAttributes = { attributeIdToValue };
|
this.data.fileAttributes = { attributeIdToValue };
|
||||||
this.dialogRef.close(true);
|
this.dialogRef.close(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,8 +62,8 @@ export class ManualAnnotationDialogComponent implements OnInit {
|
|||||||
private get _redactionDictionaries(): Dictionary[] {
|
private get _redactionDictionaries(): Dictionary[] {
|
||||||
const redactionDictionaries: Dictionary[] = [];
|
const redactionDictionaries: Dictionary[] = [];
|
||||||
|
|
||||||
for (const key of Object.keys(this._appStateService.dictionaryData[data.dossier.dossierTemplateId])) {
|
for (const key of Object.keys(this._appStateService.dictionaryData[this.data.dossier.dossierTemplateId])) {
|
||||||
const dictionaryData = this._appStateService.getDictionary(key, data.dossier.dossierTemplateId);
|
const dictionaryData = this._appStateService.getDictionary(key, this.data.dossier.dossierTemplateId);
|
||||||
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
|
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
|
||||||
redactionDictionaries.push(dictionaryData);
|
redactionDictionaries.push(dictionaryData);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user