Merge branch 'RED-10264' into 'master'

RED-10264: remove includeUnprocessed from all manual change calls

Closes RED-10264

See merge request redactmanager/red-ui!645
This commit is contained in:
Adina Teudan 2024-10-28 12:38:44 +01:00
commit a8534a8b13
2 changed files with 9 additions and 46 deletions

View File

@ -114,7 +114,6 @@ export class AnnotationActionsService {
async editRedaction(annotations: AnnotationWrapper[]) {
const { dossierId, file } = this._state;
const allFileAnnotations = this._fileDataService.annotations();
const includeUnprocessed = annotations.every(annotation => this.#includeUnprocessed(annotation, true));
const data = {
annotations,
allFileAnnotations,
@ -170,7 +169,6 @@ export class AnnotationActionsService {
dossierId,
file().id,
this.#getChangedFields(annotations, result),
includeUnprocessed,
result.option === RedactOrHintOptions.IN_DOCUMENT || !!result.pageNumbers.length,
)
.pipe(log()),
@ -269,7 +267,6 @@ export class AnnotationActionsService {
async acceptResize(annotation: AnnotationWrapper, permissions: AnnotationPermissions): Promise<void> {
const textAndPositions = await this.#extractTextAndPositions(annotation.id);
const includeUnprocessed = this.#includeUnprocessed(annotation);
if (annotation.isRecommendation) {
const recommendation = {
...annotation,
@ -320,7 +317,7 @@ export class AnnotationActionsService {
await this.cancelResize(annotation);
const { fileId, dossierId } = this._state;
const request = this._manualRedactionService.resize([resizeRequest], dossierId, fileId, includeUnprocessed);
const request = this._manualRedactionService.resize([resizeRequest], dossierId, fileId);
return this.#processObsAndEmit(request);
}
@ -477,7 +474,6 @@ export class AnnotationActionsService {
#removeRedaction(redactions: AnnotationWrapper[], dialogResult: RemoveRedactionResult) {
const removeFromDictionary = dialogResult.option.value === RemoveRedactionOptions.IN_DOSSIER;
const includeUnprocessed = redactions.every(redaction => this.#includeUnprocessed(redaction, true));
const body = this.#getRemoveRedactionBody(redactions, dialogResult);
// todo: might not be correct, probably shouldn't get to this point if they are not all the same
const isHint = redactions.every(r => r.isHint);
@ -505,7 +501,6 @@ export class AnnotationActionsService {
fileId,
removeFromDictionary,
isHint,
includeUnprocessed,
dialogResult.bulkLocal,
),
),
@ -521,7 +516,6 @@ export class AnnotationActionsService {
fileId,
removeFromDictionary,
isHint,
includeUnprocessed,
dialogResult.bulkLocal || !!dialogResult.pageNumbers.length,
),
).then();
@ -580,20 +574,6 @@ export class AnnotationActionsService {
return { changes: changedFields.join(', ') };
}
//TODO this is temporary, based on RED-8950. Should be removed when a better solution will be found
#includeUnprocessed(annotation: AnnotationWrapper, isRemoveOrRecategorize = false) {
const processed = annotation.entry.manualChanges.at(-1)?.processed;
if (!processed) {
const autoAnalysisDisabled = this._state.file().excludedFromAutomaticAnalysis;
const addedLocallyWhileDisabled = annotation.manual;
if (autoAnalysisDisabled) {
return addedLocallyWhileDisabled;
}
return isRemoveOrRecategorize && addedLocallyWhileDisabled;
}
return false;
}
#getRemoveRedactionBody(
redactions: AnnotationWrapper[],
dialogResult: RemoveRedactionResult,

View File

@ -75,13 +75,10 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
body: List<IRecategorizationRequest> | IBulkRecategorizationRequest,
dossierId: string,
fileId: string,
successMessageParameters?: {
[key: string]: string;
},
includeUnprocessed = false,
successMessageParameters?: { [p: string]: string },
bulkLocal = false,
) {
return this.#recategorize(body, dossierId, fileId, includeUnprocessed, bulkLocal).pipe(
return this.#recategorize(body, dossierId, fileId, bulkLocal).pipe(
this.#showToast('recategorize-annotation', false, successMessageParameters),
);
}
@ -117,10 +114,9 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
fileId: string,
removeFromDictionary = false,
isHint = false,
includeUnprocessed = false,
bulkLocal = false,
) {
return this.#remove(body, dossierId, fileId, includeUnprocessed, bulkLocal).pipe(
return this.#remove(body, dossierId, fileId, bulkLocal).pipe(
this.#showToast(!isHint ? 'remove' : 'remove-hint', removeFromDictionary),
);
}
@ -154,36 +150,23 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
return this._post(body, `${this.#bulkRedaction}/force/${dossierId}/${fileId}`).pipe(this.#log('Force redaction', body));
}
resize(body: List<IResizeRequest>, dossierId: string, fileId: string, includeUnprocessed = false) {
return this._post(body, `${this.#bulkRedaction}/resize/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe(
this.#log('Resize', body),
);
resize(body: List<IResizeRequest>, dossierId: string, fileId: string) {
return this._post(body, `${this.#bulkRedaction}/resize/${dossierId}/${fileId}`).pipe(this.#log('Resize', body));
}
#recategorize(
body: List<IRecategorizationRequest> | IBulkRecategorizationRequest,
dossierId: string,
fileId: string,
includeUnprocessed = false,
bulkLocal = false,
) {
const bulkPath = bulkLocal ? this.#bulkLocal : this.#bulkRedaction;
return this._post(body, `${bulkPath}/recategorize/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe(
this.#log('Recategorize', body),
);
return this._post(body, `${bulkPath}/recategorize/${dossierId}/${fileId}`).pipe(this.#log('Recategorize', body));
}
#remove(
body: List<IRemoveRedactionRequest> | IBulkLocalRemoveRequest,
dossierId: string,
fileId: string,
includeUnprocessed = false,
bulkLocal = false,
) {
#remove(body: List<IRemoveRedactionRequest> | IBulkLocalRemoveRequest, dossierId: string, fileId: string, bulkLocal = false) {
const bulkPath = bulkLocal ? this.#bulkLocal : this.#bulkRedaction;
return this._post(body, `${bulkPath}/remove/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe(
this.#log('Remove', body),
);
return this._post(body, `${bulkPath}/remove/${dossierId}/${fileId}`).pipe(this.#log('Remove', body));
}
#log(action: string, body: unknown) {