Merge branch 'feature/RED-10115' into 'master'

RED-10115: Refactoring of justifications

Closes RED-10115

See merge request redactmanager/red-ui!703
This commit is contained in:
Maverick Studer 2024-11-20 10:38:28 +01:00
commit 6f77cef2ab
12 changed files with 23 additions and 16 deletions

View File

@ -378,7 +378,7 @@ export class AnnotationWrapper implements IListable {
static #getShortContent(annotationWrapper: AnnotationWrapper, legalBasisList: ILegalBasis[]) {
if (annotationWrapper.legalBasis) {
const lb = legalBasisList.find(lbm => lbm.reason?.toLowerCase().includes(annotationWrapper.legalBasis.toLowerCase()));
const lb = legalBasisList.find(lbm => lbm.technicalName?.toLowerCase().includes(annotationWrapper.legalBasis.toLowerCase()));
if (lb) {
return lb.name;
}

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());
}

View File

@ -53,6 +53,7 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
this.legalOptions = data
.map<LegalBasisOption>(lbm => ({
technicalName: lbm.technicalName,
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,
@ -60,14 +61,14 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
.sort((a, b) => a.label.localeCompare(b.label));
this.form.patchValue({
reason: this.legalOptions.find(option => option.legalBasis === this._data.annotations[0].legalBasis),
reason: this.legalOptions.find(option => option.technicalName === this._data.annotations[0].legalBasis),
});
this.initialFormValue = this.form.getRawValue();
}
save() {
this._dialogRef.close({
legalBasis: this.form.get('reason').value.legalBasis,
legalBasis: this.form.get('reason').value.technicalName,
section: this.form.get('section').value,
comment: this.form.get('comment').value,
value: this.form.get('classification').value,

View File

@ -177,13 +177,14 @@ export class EditRedactionDialogComponent
this.#setTypes();
const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
technicalName: lbm.technicalName,
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,
}));
const reason = this.legalOptions.find(o => o.legalBasis === this.annotations[0].legalBasis);
const sameLegalBasis = this.annotations.every(annotation => annotation.legalBasis === reason?.legalBasis);
const reason = this.legalOptions.find(o => o.technicalName === this.annotations[0].legalBasis);
const sameLegalBasis = this.annotations.every(annotation => annotation.legalBasis === reason?.technicalName);
this.form.patchValue({
reason: sameLegalBasis ? reason : null,
});
@ -213,12 +214,12 @@ export class EditRedactionDialogComponent
save() {
const value = this.form.value;
const initialReason: LegalBasisOption = this.initialFormValue.reason;
const initialLegalBasis = initialReason?.legalBasis ?? '';
const initialLegalBasis = initialReason?.technicalName ?? '';
const pageNumbers = parseSelectedPageNumbers(this.form.get('option').value?.additionalInput?.value, this.data.file);
const position = parseRectanglePosition(this.annotations[0]);
this.close({
legalBasis: value.reason?.legalBasis ?? (this.isImage ? initialLegalBasis : ''),
legalBasis: value.reason?.technicalName ?? (this.isImage ? initialLegalBasis : ''),
section: value.section,
comment: value.comment,
type: value.type,

View File

@ -110,6 +110,7 @@ export class ForceAnnotationDialogComponent
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.data.dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
technicalName: lbm.technicalName,
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,
@ -118,7 +119,7 @@ export class ForceAnnotationDialogComponent
this.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
// Set pre-existing reason if it exists
const existingReason = this.legalOptions.find(option => option.legalBasis === this.data.annotations[0].legalBasis);
const existingReason = this.legalOptions.find(option => option.technicalName === this.data.annotations[0].legalBasis);
if (!this.data.hint && existingReason) {
this.form.patchValue({ reason: existingReason }, { emitEvent: false });
}
@ -141,7 +142,7 @@ export class ForceAnnotationDialogComponent
#createForceRedactionRequest(): ILegalBasisChangeRequest {
const request: ILegalBasisChangeRequest = {};
request.legalBasis = !this.isDocumine ? this.form.get('reason').value.legalBasis : DOCUMINE_LEGAL_BASIS;
request.legalBasis = !this.isDocumine ? this.form.get('reason').value.technicalName : DOCUMINE_LEGAL_BASIS;
request.comment = this.form.get('comment').value;
request.reason = this.form.get('reason').value.description;
request.option = this.form.get('option').value?.value;

View File

@ -100,6 +100,7 @@ export class RectangleAnnotationDialog
async ngOnInit() {
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
technicalName: lbm.technicalName,
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,
@ -139,7 +140,7 @@ export class RectangleAnnotationDialog
addRedactionRequest.type = SuperTypes.ManualRedaction;
if (legalOption) {
addRedactionRequest.reason = legalOption.description;
addRedactionRequest.legalBasis = legalOption.legalBasis;
addRedactionRequest.legalBasis = legalOption.technicalName;
}
addRedactionRequest.addToDictionary = false;

View File

@ -122,6 +122,7 @@ export class RedactRecommendationDialogComponent
this.#setDictionaries();
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
technicalName: lbm.technicalName,
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,

View File

@ -138,13 +138,14 @@ export class RedactTextDialogComponent
get applyToAll() {
return this.isSystemDefault || this._userPreferences.getAddRedactionDefaultExtraOption() === 'undefined'
? (this.data.applyToAllDossiers ?? true)
? this.data.applyToAllDossiers ?? true
: stringToBoolean(this._userPreferences.getAddRedactionDefaultExtraOption());
}
async ngOnInit(): Promise<void> {
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
technicalName: lbm.technicalName,
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,

View File

@ -51,6 +51,7 @@ export interface LegalBasisOption {
label?: string;
legalBasis?: string;
description?: string;
technicalName?: string;
}
export interface RedactTextData {

View File

@ -30,7 +30,7 @@ export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedaction
const legalOption: LegalBasisOption = data.reason;
if (legalOption) {
addRedactionRequest.reason = legalOption.description;
addRedactionRequest.legalBasis = legalOption.legalBasis;
addRedactionRequest.legalBasis = legalOption.technicalName;
}
const selectedType = data.dictionaries.find(d => d.type === addRedactionRequest.type);

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://dan1.iqser.cloud",
"API_URL": "https://maverick2.iqser.cloud",
"APP_NAME": "RedactManager",
"IS_DOCUMINE": false,
"RULE_EDITOR_DEV_ONLY": false,
@ -13,7 +13,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dan1.iqser.cloud/auth",
"OAUTH_URL": "https://maverick2.iqser.cloud/auth",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",

View File

@ -124,7 +124,7 @@ export class File extends Entity<IFile> implements IFile {
this.workflowStatus = file.workflowStatus;
this.isError = this.processingStatus === ProcessingFileStatuses.ERROR;
this.isUnprocessed = this.processingStatus === ProcessingFileStatuses.UNPROCESSED;
this.numberOfPages = this.isError ? 0 : (file.numberOfPages ?? 0);
this.numberOfPages = this.isError ? 0 : file.numberOfPages ?? 0;
this.rulesVersion = file.rulesVersion;
this.uploader = file.uploader;
this.excludedPages = file.excludedPages || [];