Merge branch 'VM/RED-10339' into 'master'

RED-10339 - Secondary Save button in redaction dialogs to store selected option as default

Closes RED-10339

See merge request redactmanager/red-ui!687
This commit is contained in:
Nicoleta Panaghiu 2024-11-11 14:52:12 +01:00
commit 1b0fe9d352
10 changed files with 117 additions and 18 deletions

View File

@ -104,6 +104,14 @@
>
</iqser-icon-button>
<iqser-icon-button
(action)="saveAndRemember()"
[disabled]="disabled"
[label]="'add-hint.dialog.actions.save-and-remember' | translate"
[submit]="true"
[type]="iconButtonTypes.dark"
/>
<div class="all-caps-label cancel" mat-dialog-close [translate]="'add-hint.dialog.actions.cancel'"></div>
</div>
</form>

View File

@ -130,7 +130,7 @@ export class AddHintDialogComponent extends IqserDialogComponent<AddHintDialogCo
get applyToAll() {
return this.isSystemDefault || this._userPreferences.getAddHintDefaultExtraOption() === 'undefined'
? this.data.applyToAllDossiers ?? true
? (this.data.applyToAllDossiers ?? true)
: stringToBoolean(this._userPreferences.getAddHintDefaultExtraOption());
}
@ -189,6 +189,15 @@ export class AddHintDialogComponent extends IqserDialogComponent<AddHintDialogCo
});
}
async saveAndRemember() {
const option = this.form.controls.option?.value;
await this._userPreferences.saveAddHintDefaultOption(option?.value ?? SystemDefaults.ADD_HINT_DEFAULT);
if (option?.additionalCheck) {
await this._userPreferences.saveAddHintDefaultExtraOption(option.additionalCheck.checked);
}
this.save();
}
#setDictionaries() {
this.dictionaries = this._dictionaryService.getAddHintDictionaries(
this.#dossier.dossierId,

View File

@ -126,6 +126,13 @@
[type]="iconButtonTypes.primary"
/>
<iqser-icon-button
(action)="saveAndRemember()"
[disabled]="!form.valid"
[label]="'redact-text.dialog.actions.save-and-remember' | translate"
[type]="iconButtonTypes.dark"
/>
<div [translate]="'redact-text.dialog.actions.cancel'" class="all-caps-label cancel" mat-dialog-close></div>
</div>
</form>

View File

@ -138,7 +138,7 @@ export class RedactTextDialogComponent
get applyToAll() {
return this.isSystemDefault || this._userPreferences.getAddRedactionDefaultExtraOption() === 'undefined'
? this.data.applyToAllDossiers ?? true
? (this.data.applyToAllDossiers ?? true)
: stringToBoolean(this._userPreferences.getAddRedactionDefaultExtraOption());
}
@ -190,6 +190,15 @@ export class RedactTextDialogComponent
});
}
async saveAndRemember() {
const option = this.form.controls.option?.value;
await this._userPreferences.saveAddRedactionDefaultOption(option?.value ?? SystemDefaults.ADD_REDACTION_DEFAULT);
if (option?.additionalCheck) {
await this._userPreferences.saveAddRedactionDefaultExtraOption(option.additionalCheck.checked);
}
this.save();
}
toggleEditingSelectedText() {
this.isEditingSelectedText = !this.isEditingSelectedText;
if (this.isEditingSelectedText) {

View File

@ -42,6 +42,16 @@
>
</iqser-icon-button>
@if (!allRectangles) {
<iqser-icon-button
(action)="saveAndRemember()"
[disabled]="disabled"
[label]="'remove-redaction.dialog.actions.save-and-remember' | translate"
[submit]="true"
[type]="iconButtonTypes.dark"
/>
}
<div [translate]="'remove-redaction.dialog.actions.cancel'" class="all-caps-label cancel" mat-dialog-close></div>
<iqser-help-button *deny="roles.getRss"></iqser-help-button>

View File

@ -38,6 +38,12 @@ import { isJustOne } from '@common-ui/utils';
import { validatePageRange } from '../../utils/form-validators';
import { parseRectanglePosition, parseSelectedPageNumbers, prefillPageRange } from '../../utils/enhance-manual-redaction-request.utils';
const ANNOTATION_TYPES = {
REDACTION: 'redaction',
HINT: 'hint',
RECOMMENDATION: 'recommendation',
};
@Component({
templateUrl: './remove-redaction-dialog.component.html',
styleUrls: ['./remove-redaction-dialog.component.scss'],
@ -65,7 +71,11 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
readonly iconButtonTypes = IconButtonTypes;
readonly recommendation = this.data.redactions.every(redaction => redaction.isRecommendation);
readonly hint = this.data.redactions.every(redaction => redaction.isHint);
readonly annotationsType = this.hint ? 'hint' : this.recommendation ? 'recommendation' : 'redaction';
readonly annotationsType = this.hint
? ANNOTATION_TYPES.HINT
: this.recommendation
? ANNOTATION_TYPES.RECOMMENDATION
: ANNOTATION_TYPES.REDACTION;
readonly optionByType = {
recommendation: {
main: this._userPreferences.getRemoveRecommendationDefaultOption(),
@ -94,7 +104,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
extra: false,
},
};
readonly #allRectangles = this.data.redactions.reduce((acc, a) => acc && a.AREA, true);
readonly allRectangles = this.data.redactions.reduce((acc, a) => acc && a.AREA, true);
readonly #applyToAllDossiers = this.systemDefaultByType[this.annotationsType].extra;
readonly isSystemDefault = this.optionByType[this.annotationsType].main === SystemDefaultOption.SYSTEM_DEFAULT;
readonly isExtraOptionSystemDefault = this.optionByType[this.annotationsType].extra === 'undefined';
@ -102,7 +112,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
? this.systemDefaultByType[this.annotationsType].main
: this.optionByType[this.annotationsType].main;
readonly extraOptionPreference = stringToBoolean(this.optionByType[this.annotationsType].extra);
readonly options: DetailsRadioOption<RectangleRedactOption | RemoveRedactionOption>[] = this.#allRectangles
readonly options: DetailsRadioOption<RectangleRedactOption | RemoveRedactionOption>[] = this.allRectangles
? getRectangleRedactOptions('remove')
: getRemoveRedactionOptions(
this.data,
@ -141,7 +151,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
) {
super();
if (this.#allRectangles) {
if (this.allRectangles) {
prefillPageRange(
this.data.redactions[0],
this.data.allFileRedactions,
@ -198,6 +208,40 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
});
}
async saveAndRemember() {
const option = this.form.controls.option?.value;
switch (this.annotationsType) {
case ANNOTATION_TYPES.REDACTION:
await this._userPreferences.saveRemoveRedactionDefaultOption(option?.value ?? SystemDefaults.REMOVE_REDACTION_DEFAULT);
break;
case ANNOTATION_TYPES.HINT:
await this._userPreferences.saveRemoveHintDefaultOption(option?.value ?? SystemDefaults.REMOVE_HINT_DEFAULT);
break;
case ANNOTATION_TYPES.RECOMMENDATION:
await this._userPreferences.saveRemoveRecommendationDefaultOption(
option?.value ?? SystemDefaults.REMOVE_RECOMMENDATION_DEFAULT,
);
break;
}
if (option?.additionalCheck) {
switch (this.annotationsType) {
case ANNOTATION_TYPES.REDACTION:
await this._userPreferences.saveRemoveRedactionDefaultExtraOption(option.additionalCheck.checked);
break;
case ANNOTATION_TYPES.HINT:
await this._userPreferences.saveRemoveHintDefaultExtraOption(option.additionalCheck.checked);
break;
case ANNOTATION_TYPES.RECOMMENDATION:
await this._userPreferences.saveRemoveRecommendationDefaultExtraOption(option.additionalCheck.checked);
break;
}
}
this.save();
}
#getOption(option: RemoveRedactionOption): DetailsRadioOption<RectangleRedactOption | RemoveRedactionOption> {
return this.options.find(o => o.value === option);
}

View File

@ -224,7 +224,8 @@
"dialog": {
"actions": {
"cancel": "Abbrechen",
"save": "Speichern"
"save": "Speichern",
"save-and-remember": ""
},
"content": {
"comment": "Kommentar",
@ -2106,7 +2107,8 @@
"dialog": {
"actions": {
"cancel": "Abbrechen",
"save": "Speichern"
"save": "Speichern",
"save-and-remember": ""
},
"content": {
"comment": "Kommentar",
@ -2202,7 +2204,8 @@
"dialog": {
"actions": {
"cancel": "Abbrechen",
"save": "Speichern"
"save": "Speichern",
"save-and-remember": ""
},
"content": {
"comment": "Kommentar",

View File

@ -224,7 +224,8 @@
"dialog": {
"actions": {
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"save-and-remember": "Save and remember my choice"
},
"content": {
"comment": "Comment",
@ -2106,7 +2107,8 @@
"dialog": {
"actions": {
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"save-and-remember": "Save and remember my choice"
},
"content": {
"comment": "Comment",
@ -2202,7 +2204,8 @@
"dialog": {
"actions": {
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"save-and-remember": "Save and remember my choice"
},
"content": {
"comment": "Comment",

View File

@ -224,7 +224,8 @@
"dialog": {
"actions": {
"cancel": "Abbrechen",
"save": "Speichern"
"save": "Speichern",
"save-and-remember": ""
},
"content": {
"comment": "Kommentar",
@ -2106,7 +2107,8 @@
"dialog": {
"actions": {
"cancel": "Abbrechen",
"save": "Speichern"
"save": "Speichern",
"save-and-remember": ""
},
"content": {
"comment": "Kommentar",
@ -2202,7 +2204,8 @@
"dialog": {
"actions": {
"cancel": "Abbrechen",
"save": "Speichern"
"save": "Speichern",
"save-and-remember": ""
},
"content": {
"comment": "Kommentar",

View File

@ -224,7 +224,8 @@
"dialog": {
"actions": {
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"save-and-remember": "Save and remember my choice"
},
"content": {
"comment": "Comment",
@ -2106,7 +2107,8 @@
"dialog": {
"actions": {
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"save-and-remember": "Save and remember my choice"
},
"content": {
"comment": "Comment",
@ -2202,7 +2204,8 @@
"dialog": {
"actions": {
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"save-and-remember": "Save and remember my choice"
},
"content": {
"comment": "Comment",