RED-6774 - updated redact/remove endpoints and permissions for users that are not approvers
This commit is contained in:
parent
97fa06ef7e
commit
79daeb9178
@ -28,6 +28,7 @@ interface RedactTextData {
|
|||||||
dossierId: string;
|
dossierId: string;
|
||||||
file: File;
|
file: File;
|
||||||
applyToAllDossiers: boolean;
|
applyToAllDossiers: boolean;
|
||||||
|
isApprover: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DialogResult {
|
interface DialogResult {
|
||||||
@ -202,7 +203,7 @@ export class RedactTextDialogComponent
|
|||||||
addRedactionRequest.value = addRedactionRequest.rectangle
|
addRedactionRequest.value = addRedactionRequest.rectangle
|
||||||
? this.form.get('classification').value
|
? this.form.get('classification').value
|
||||||
: this.form.get('selectedText').value;
|
: this.form.get('selectedText').value;
|
||||||
addRedactionRequest.addToAllDossiers = this.dictionaryRequest && this.#applyToAllDossiers;
|
addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
#options() {
|
#options() {
|
||||||
@ -224,6 +225,7 @@ export class RedactTextDialogComponent
|
|||||||
extraOption: {
|
extraOption: {
|
||||||
label: this.#translations[this.type].inDossier.extraOptionLabel,
|
label: this.#translations[this.type].inDossier.extraOptionLabel,
|
||||||
checked: this.data.applyToAllDossiers ?? true,
|
checked: this.data.applyToAllDossiers ?? true,
|
||||||
|
hidden: !this.data.isApprover,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ export interface RemoveRedactionData {
|
|||||||
falsePositiveContext: string;
|
falsePositiveContext: string;
|
||||||
permissions: RemoveRedactionPermissions;
|
permissions: RemoveRedactionPermissions;
|
||||||
applyToAllDossiers: boolean;
|
applyToAllDossiers: boolean;
|
||||||
|
isApprover: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RemoveRedactionResult {
|
export interface RemoveRedactionResult {
|
||||||
@ -109,6 +110,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
|
|||||||
extraOption: {
|
extraOption: {
|
||||||
label: this.#translations.IN_DOSSIER.extraOptionLabel,
|
label: this.#translations.IN_DOSSIER.extraOptionLabel,
|
||||||
checked: this.data.applyToAllDossiers ?? true,
|
checked: this.data.applyToAllDossiers ?? true,
|
||||||
|
hidden: !this.data.isApprover,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -122,6 +124,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
|
|||||||
extraOption: {
|
extraOption: {
|
||||||
label: this.#translations.FALSE_POSITIVE.extraOptionLabel,
|
label: this.#translations.FALSE_POSITIVE.extraOptionLabel,
|
||||||
checked: this.data.applyToAllDossiers ?? true,
|
checked: this.data.applyToAllDossiers ?? true,
|
||||||
|
hidden: !this.data.isApprover,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -354,12 +354,14 @@ export class FilePreviewScreenComponent
|
|||||||
async openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
|
async openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
|
||||||
const file = this.state.file();
|
const file = this.state.file();
|
||||||
const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId);
|
const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId);
|
||||||
|
const isApprover = this.permissionsService.isApprover(this.state.dossier());
|
||||||
const ref = this._iqserDialog.openDefault(RedactTextDialogComponent, {
|
const ref = this._iqserDialog.openDefault(RedactTextDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
manualRedactionEntryWrapper,
|
manualRedactionEntryWrapper,
|
||||||
dossierId: this.dossierId,
|
dossierId: this.dossierId,
|
||||||
file,
|
file,
|
||||||
applyToAllDossiers: dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault,
|
applyToAllDossiers: isApprover ? dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault : false,
|
||||||
|
isApprover,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -370,7 +372,7 @@ export class FilePreviewScreenComponent
|
|||||||
|
|
||||||
const add$ = this._manualRedactionService.addAnnotation([result.redaction], this.dossierId, this.fileId, result.dictionary?.label);
|
const add$ = this._manualRedactionService.addAnnotation([result.redaction], this.dossierId, this.fileId, result.dictionary?.label);
|
||||||
|
|
||||||
if (result.applyToAllDossiers !== null) {
|
if (isApprover && result.applyToAllDossiers !== null) {
|
||||||
const { ...body } = dossierTemplate;
|
const { ...body } = dossierTemplate;
|
||||||
body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers;
|
body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers;
|
||||||
await this._dossierTemplatesService.createOrUpdate(body);
|
await this._dossierTemplatesService.createOrUpdate(body);
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import { RemoveRedactionOptions } from '../dialogs/remove-redaction-dialog/remov
|
|||||||
import { IqserDialog } from '../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog.service';
|
import { IqserDialog } from '../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog.service';
|
||||||
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
||||||
import { isJustOne, List } from '@iqser/common-ui/lib/utils';
|
import { isJustOne, List } from '@iqser/common-ui/lib/utils';
|
||||||
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AnnotationActionsService {
|
export class AnnotationActionsService {
|
||||||
@ -54,6 +55,7 @@ export class AnnotationActionsService {
|
|||||||
private readonly _fileDataService: FileDataService,
|
private readonly _fileDataService: FileDataService,
|
||||||
private readonly _skippedService: SkippedService,
|
private readonly _skippedService: SkippedService,
|
||||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||||
|
private readonly _permissionsService: PermissionsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
acceptSuggestion(annotations: AnnotationWrapper[]) {
|
acceptSuggestion(annotations: AnnotationWrapper[]) {
|
||||||
@ -126,6 +128,7 @@ export class AnnotationActionsService {
|
|||||||
canMarkAsFalsePositive: permissions.canMarkAsFalsePositive,
|
canMarkAsFalsePositive: permissions.canMarkAsFalsePositive,
|
||||||
};
|
};
|
||||||
const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId);
|
const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId);
|
||||||
|
const isApprover = this._permissionsService.isApprover(this._state.dossier());
|
||||||
|
|
||||||
const result: RemoveRedactionResult = await this._iqserDialog
|
const result: RemoveRedactionResult = await this._iqserDialog
|
||||||
.openDefault(RemoveRedactionDialogComponent, {
|
.openDefault(RemoveRedactionDialogComponent, {
|
||||||
@ -134,7 +137,8 @@ export class AnnotationActionsService {
|
|||||||
dossier: this._state.dossier(),
|
dossier: this._state.dossier(),
|
||||||
falsePositiveContext: this._getFalsePositiveText(redaction),
|
falsePositiveContext: this._getFalsePositiveText(redaction),
|
||||||
permissions: removePermissions,
|
permissions: removePermissions,
|
||||||
applyToAllDossiers: dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault,
|
applyToAllDossiers: isApprover ? dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault : false,
|
||||||
|
isApprover,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.result();
|
.result();
|
||||||
@ -146,7 +150,7 @@ export class AnnotationActionsService {
|
|||||||
this.#removeRedaction(redaction, result);
|
this.#removeRedaction(redaction, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.option.extraOption) {
|
if (isApprover && result.option.extraOption) {
|
||||||
const { ...body } = dossierTemplate;
|
const { ...body } = dossierTemplate;
|
||||||
body.applyDictionaryUpdatesToAllDossiersByDefault = result.option.extraOption.checked;
|
body.applyDictionaryUpdatesToAllDossiersByDefault = result.option.extraOption.checked;
|
||||||
await this._dossierTemplatesService.createOrUpdate(body);
|
await this._dossierTemplatesService.createOrUpdate(body);
|
||||||
@ -409,7 +413,7 @@ export class AnnotationActionsService {
|
|||||||
};
|
};
|
||||||
const { dossierId, fileId } = this._state;
|
const { dossierId, fileId } = this._state;
|
||||||
this.#processObsAndEmit(
|
this.#processObsAndEmit(
|
||||||
this._manualRedactionService.removeOrSuggestRemove([body], dossierId, fileId, removeFromDictionary, redaction.isHint),
|
this._manualRedactionService.removeRedaction([body], dossierId, fileId, removeFromDictionary, redaction.isHint),
|
||||||
).then();
|
).then();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,15 +97,10 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
|
|||||||
addAnnotation(requests: List<IAddRedactionRequest>, dossierId: string, fileId: string, dictionaryLabel?: string) {
|
addAnnotation(requests: List<IAddRedactionRequest>, dossierId: string, fileId: string, dictionaryLabel?: string) {
|
||||||
const toast = requests[0].addToDictionary ? this.#showAddToDictionaryToast(requests, dictionaryLabel) : this.#showToast('add');
|
const toast = requests[0].addToDictionary ? this.#showAddToDictionaryToast(requests, dictionaryLabel) : this.#showToast('add');
|
||||||
const canAddRedaction = this._iqaerPermissionsService.has(Roles.redactions.write);
|
const canAddRedaction = this._iqaerPermissionsService.has(Roles.redactions.write);
|
||||||
if (canAddRedaction && this._permissionsService.isApprover(this.#dossier(dossierId))) {
|
if (canAddRedaction) {
|
||||||
return this.add(requests, dossierId, fileId).pipe(toast);
|
return this.add(requests, dossierId, fileId).pipe(toast);
|
||||||
}
|
}
|
||||||
|
|
||||||
const canRequestRedaction = this._iqaerPermissionsService.has(Roles.redactions.request);
|
|
||||||
if (canRequestRedaction) {
|
|
||||||
return this.requestAdd(requests, dossierId, fileId).pipe(toast);
|
|
||||||
}
|
|
||||||
|
|
||||||
return of(undefined);
|
return of(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,20 +136,8 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
|
|||||||
return this.requestResize(requests, dossierId, fileId);
|
return this.requestResize(requests, dossierId, fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeOrSuggestRemove(
|
removeRedaction(body: List<IRemoveRedactionRequest>, dossierId: string, fileId: string, removeFromDictionary = false, isHint = false) {
|
||||||
body: List<IRemoveRedactionRequest>,
|
return this.remove(body, dossierId, fileId).pipe(this.#showToast(!isHint ? 'remove' : 'remove-hint', removeFromDictionary));
|
||||||
dossierId: string,
|
|
||||||
fileId: string,
|
|
||||||
removeFromDictionary = false,
|
|
||||||
isHint = false,
|
|
||||||
) {
|
|
||||||
if (this._permissionsService.isApprover(this.#dossier(dossierId))) {
|
|
||||||
return this.remove(body, dossierId, fileId).pipe(this.#showToast(!isHint ? 'remove' : 'remove-hint', removeFromDictionary));
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.requestRemoveRedaction(body, dossierId, fileId).pipe(
|
|
||||||
this.#showToast(!isHint ? 'request-remove' : 'request-remove-hint', removeFromDictionary),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getTitle(type: ManualRedactionEntryType) {
|
getTitle(type: ManualRedactionEntryType) {
|
||||||
@ -194,10 +177,6 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestRemoveRedaction(body: List<IRemoveRedactionRequest>, dossierId: string, fileId: string) {
|
|
||||||
return this._post(body, `${this.#bulkRequest}/remove/${dossierId}/${fileId}`).pipe(this.#log('Request remove', body));
|
|
||||||
}
|
|
||||||
|
|
||||||
approve(annotationIds: List, dossierId: string, fileId: string) {
|
approve(annotationIds: List, dossierId: string, fileId: string) {
|
||||||
return this._post(annotationIds, `${this._defaultModelPath}/bulk/approve/${dossierId}/${fileId}`).pipe(
|
return this._post(annotationIds, `${this._defaultModelPath}/bulk/approve/${dossierId}/${fileId}`).pipe(
|
||||||
this.#log('Approve', annotationIds),
|
this.#log('Approve', annotationIds),
|
||||||
@ -220,10 +199,6 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
|
|||||||
return this._post(body, `${this.#bulkRedaction}/remove/${dossierId}/${fileId}`).pipe(this.#log('Remove', body));
|
return this._post(body, `${this.#bulkRedaction}/remove/${dossierId}/${fileId}`).pipe(this.#log('Remove', body));
|
||||||
}
|
}
|
||||||
|
|
||||||
requestAdd(body: List<IAddRedactionRequest>, dossierId: string, fileId: string) {
|
|
||||||
return this._post(body, `${this.#bulkRequest}/add/${dossierId}/${fileId}`).pipe(this.#log('Request add', body));
|
|
||||||
}
|
|
||||||
|
|
||||||
forceRedaction(body: List<ILegalBasisChangeRequest>, dossierId: string, fileId: string) {
|
forceRedaction(body: List<ILegalBasisChangeRequest>, dossierId: string, fileId: string) {
|
||||||
return this._post(body, `${this.#bulkRedaction}/force/${dossierId}/${fileId}`).pipe(this.#log('Force redaction', body));
|
return this._post(body, `${this.#bulkRedaction}/force/${dossierId}/${fileId}`).pipe(this.#log('Force redaction', body));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,8 +178,7 @@ export class PdfProxyService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const isApprover = this._permissionsService.isApprover(this._state.dossier());
|
if (this._iqserPermissionsService.has(Roles.redactions.write)) {
|
||||||
if (this._iqserPermissionsService.has(Roles.redactions.write) && isApprover) {
|
|
||||||
popups.push({
|
popups.push({
|
||||||
type: 'actionButton',
|
type: 'actionButton',
|
||||||
dataElement: TextPopups.REDACT_TEXT,
|
dataElement: TextPopups.REDACT_TEXT,
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit 137a62338ce5c890fe337ab8da8bbe9279463730
|
Subproject commit a4e425d3739d6145325a8fe347d9fcae1e12a662
|
||||||
Loading…
x
Reference in New Issue
Block a user