DM when adding a dict request add to all dossiers
This commit is contained in:
parent
b33a5fb355
commit
500a97c286
@ -4,7 +4,7 @@
|
||||
|
||||
<div class="dialog-content redaction">
|
||||
<div class="iqser-input-group w-450">
|
||||
<label class="selected-text" [translate]="'add-annotation.dialog.content.selected-text'"></label>
|
||||
<label [translate]="'add-annotation.dialog.content.selected-text'" class="selected-text"></label>
|
||||
{{ form.get('selectedText').value }}
|
||||
</div>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<label [translate]="'add-annotation.dialog.content.type'"></label>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-select formControlName="dictionary" [placeholder]="'add-annotation.dialog.content.type-placeholder' | translate">
|
||||
<mat-select [placeholder]="'add-annotation.dialog.content.type-placeholder' | translate" formControlName="dictionary">
|
||||
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
|
||||
<mat-option
|
||||
*ngFor="let dictionary of dictionaries"
|
||||
@ -29,26 +29,25 @@
|
||||
<div class="iqser-input-group w-450">
|
||||
<label [translate]="'add-annotation.dialog.content.comment'"></label>
|
||||
<textarea
|
||||
[placeholder]="'add-annotation.dialog.content.comment-placeholder' | translate"
|
||||
formControlName="comment"
|
||||
iqserHasScrollbar
|
||||
name="comment"
|
||||
rows="4"
|
||||
type="text"
|
||||
[placeholder]="'add-annotation.dialog.content.comment-placeholder' | translate"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<iqser-icon-button
|
||||
[disabled]="disabled"
|
||||
[label]="'add-annotation.dialog.actions.save' | translate"
|
||||
[submit]="true"
|
||||
[type]="iconButtonTypes.primary"
|
||||
[disabled]="disabled"
|
||||
>
|
||||
</iqser-icon-button>
|
||||
></iqser-icon-button>
|
||||
|
||||
<div class="all-caps-label cancel" mat-dialog-close [translate]="'add-annotation.dialog.actions.cancel'"></div>
|
||||
<div [translate]="'add-annotation.dialog.actions.cancel'" class="all-caps-label cancel" mat-dialog-close></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui';
|
||||
import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain';
|
||||
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { Roles } from '@users/roles';
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui';
|
||||
import { Dictionary, IAddRedactionRequest } from '@red/domain';
|
||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
import { IqserDialogComponent } from '@iqser/common-ui';
|
||||
import { Roles } from '@users/roles';
|
||||
import { AddAnnotationData, AddAnnotationResult } from '../../../utils/dialog-types';
|
||||
|
||||
@Component({
|
||||
@ -15,25 +14,14 @@ export class AddAnnotationDialogComponent
|
||||
extends IqserDialogComponent<AddAnnotationDialogComponent, AddAnnotationData, AddAnnotationResult>
|
||||
implements OnInit
|
||||
{
|
||||
readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId);
|
||||
readonly #isRss = inject(IqserPermissionsService).has(Roles.getRss);
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
dictionaries: Dictionary[] = [];
|
||||
form!: UntypedFormGroup;
|
||||
readonly form = this.#getForm();
|
||||
|
||||
#applyToAllDossiers: boolean;
|
||||
|
||||
readonly #dossier: Dossier;
|
||||
readonly #isRss = this._iqserPermissionsService.has(Roles.getRss);
|
||||
|
||||
constructor(
|
||||
private readonly _activeDossiersService: ActiveDossiersService,
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
private readonly _iqserPermissionsService: IqserPermissionsService,
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
) {
|
||||
constructor(private readonly _dictionaryService: DictionaryService, private readonly _formBuilder: FormBuilder) {
|
||||
super();
|
||||
this.#dossier = _activeDossiersService.find(this.data.dossierId);
|
||||
this.#applyToAllDossiers = !!this.data.applyToAllDossiers;
|
||||
this.form = this.#getForm();
|
||||
}
|
||||
|
||||
get displayedDictionaryLabel() {
|
||||
@ -48,20 +36,20 @@ export class AddAnnotationDialogComponent
|
||||
return !this.#isRss || !this.form.get('dictionary').value;
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
ngOnInit() {
|
||||
this.dictionaries = this._dictionaryService.getRedactionTypes(this.#dossier.dossierTemplateId);
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
|
||||
const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry;
|
||||
this.dialogRef.close({
|
||||
this.close({
|
||||
redaction,
|
||||
dictionary: this.dictionaries.find(d => d.type === this.form.get('dictionary').value),
|
||||
});
|
||||
}
|
||||
|
||||
#getForm(): UntypedFormGroup {
|
||||
#getForm() {
|
||||
return this._formBuilder.group({
|
||||
selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value,
|
||||
comment: [null],
|
||||
@ -74,14 +62,12 @@ export class AddAnnotationDialogComponent
|
||||
|
||||
const selectedType = this.dictionaries.find(d => d.type === addRedactionRequest.type);
|
||||
addRedactionRequest.addToDictionary = !!selectedType?.hasDictionary;
|
||||
addRedactionRequest.reason ??= 'Dictionary Request';
|
||||
|
||||
if (!addRedactionRequest.reason) {
|
||||
addRedactionRequest.reason = 'Dictionary Request';
|
||||
}
|
||||
const commentValue = this.form.get('comment').value;
|
||||
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;
|
||||
addRedactionRequest.section = null;
|
||||
addRedactionRequest.value = this.form.get('selectedText').value;
|
||||
addRedactionRequest.addToAllDossiers = this.data.isApprover && addRedactionRequest.addToDictionary && this.#applyToAllDossiers;
|
||||
addRedactionRequest.addToAllDossiers = addRedactionRequest.addToDictionary || !!this.data.applyToAllDossiers;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user