Translation rework: annotation action messages

This commit is contained in:
Adina Țeudan 2021-07-21 18:47:09 +03:00
parent 0db16789d8
commit 486313d00a
5 changed files with 203 additions and 36 deletions

View File

@ -0,0 +1,14 @@
export type AnnotationActionMode =
| 'add'
| 'approve'
| 'remove'
| 'change-legal-basis'
| 'decline'
| 'request-remove'
| 'request-change-legal-basis'
| 'recategorize-image'
| 'request-image-recategorization'
| 'suggest'
| 'undo'
| 'force-redaction'
| 'request-force-redaction';

View File

@ -120,11 +120,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme
}
get activeViewerPage() {
const currentPage = this._instance?.docViewer?.getCurrentPage();
if (!currentPage) {
return 0;
}
return this.viewerComponent?.viewMode === 'STANDARD'
? this._instance?.docViewer?.getCurrentPage()
: this._instance?.docViewer?.getCurrentPage() % 2 === 0
? this._instance?.docViewer?.getCurrentPage() / 2
: (this._instance?.docViewer?.getCurrentPage() + 1) / 2;
? currentPage
: currentPage % 2 === 0
? currentPage / 2
: (currentPage + 1) / 2;
}
get canSwitchToRedactedView() {
@ -410,7 +414,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme
}
async annotationsChangedByReviewAction(annotation: AnnotationWrapper) {
await this._cleanupAndRedrawManualAnnotationsForEntirePage(annotation.pageNumber);
await this._cleanupAndRedrawManualAnnotationsForEntirePage(annotation?.pageNumber || this.activeViewerPage);
}
async fileActionPerformed(action: string) {

View File

@ -12,26 +12,13 @@ import { TranslateService } from '@ngx-translate/core';
import { tap } from 'rxjs/operators';
import { UserService } from '@services/user.service';
import { PermissionsService } from '@services/permissions.service';
type Mode =
| 'add'
| 'approve'
| 'remove'
| 'change-legal-basis'
| 'decline'
| 'request-remove'
| 'request-change-legal-basis'
| 'recategorize-image'
| 'request-image-recategorization'
| 'suggest'
| 'undo'
| 'force-redaction'
| 'request-force-redaction';
import { AnnotationActionMode } from '../models/annotation-action-mode.model';
import { annotationActionsTranslations } from '../translations/annotation-actions-translations';
@Injectable()
export class ManualAnnotationService {
CONFIG: {
[key in Mode]: string;
[key in AnnotationActionMode]: string;
};
constructor(
@ -60,7 +47,7 @@ export class ManualAnnotationService {
};
}
_makeRequest(mode: Mode, body: any, secondParam: any = null, modifyDictionary = false) {
_makeRequest(mode: AnnotationActionMode, body: any, secondParam: any = null, modifyDictionary = false) {
const obs = !secondParam
? this._manualRedactionControllerService[this.CONFIG[mode]](
body,
@ -123,7 +110,7 @@ export class ManualAnnotationService {
// /manualRedaction/redaction/legalBasisChange
// /manualRedaction/request/legalBasis
changeLegalBasis(annotationId: string, legalBasis: string, comment?: string) {
const mode: Mode = this._permissionsService.isApprover() ? 'change-legal-basis' : 'request-change-legal-basis';
const mode: AnnotationActionMode = this._permissionsService.isApprover() ? 'change-legal-basis' : 'request-change-legal-basis';
return this._makeRequest(mode, { annotationId, legalBasis, comment });
}
@ -131,7 +118,7 @@ export class ManualAnnotationService {
// /manualRedaction/redaction/recategorize
// /manualRedaction/request/recategorize
recategorizeImage(annotationId: string, type: string, comment: string) {
const mode: Mode = this._permissionsService.isApprover() ? 'recategorize-image' : 'request-image-recategorization';
const mode: AnnotationActionMode = this._permissionsService.isApprover() ? 'recategorize-image' : 'request-image-recategorization';
return this._makeRequest(mode, { annotationId, type, comment });
}
@ -139,7 +126,7 @@ export class ManualAnnotationService {
// /manualRedaction/redaction/add
// /manualRedaction/request/add
addAnnotation(manualRedactionEntry: AddRedactionRequest) {
const mode: Mode = this._permissionsService.isApprover() ? 'add' : 'suggest';
const mode: AnnotationActionMode = this._permissionsService.isApprover() ? 'add' : 'suggest';
return this._makeRequest(mode, manualRedactionEntry, null, manualRedactionEntry.addToDictionary);
}
@ -147,7 +134,7 @@ export class ManualAnnotationService {
// /manualRedaction/redaction/force
// /manualRedaction/request/force
forceRedaction(request: ForceRedactionRequest) {
const mode: Mode = this._permissionsService.isApprover() ? 'force-redaction' : 'request-force-redaction';
const mode: AnnotationActionMode = this._permissionsService.isApprover() ? 'force-redaction' : 'request-force-redaction';
return this._makeRequest(mode, request);
}
@ -166,7 +153,7 @@ export class ManualAnnotationService {
// /manualRedaction/decline/remove
// /manualRedaction/undo
declineOrRemoveRequest(annotationWrapper: AnnotationWrapper) {
const mode: Mode = this._permissionsService.isApprover() ? 'decline' : 'undo';
const mode: AnnotationActionMode = this._permissionsService.isApprover() ? 'decline' : 'undo';
return this._makeRequest(mode, annotationWrapper.id, null, annotationWrapper.isModifyDictionary);
}
@ -174,7 +161,7 @@ export class ManualAnnotationService {
// /manualRedaction/redaction/remove/
// /manualRedaction/request/remove/
removeOrSuggestRemoveAnnotation(annotationWrapper: AnnotationWrapper, removeFromDictionary: boolean = false) {
let mode: Mode,
let mode: AnnotationActionMode,
body: any,
removeDict = false;
@ -227,12 +214,9 @@ export class ManualAnnotationService {
}
}
private _getMessage(mode: Mode, modifyDictionary?: boolean, error: boolean = false) {
return (
'annotation-actions.message.' +
(modifyDictionary ? 'dictionary.' : 'manual-redaction.') +
mode +
(error ? '.error' : '.success')
);
private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error: boolean = false) {
const type = modifyDictionary ? 'dictionary' : 'manual-redaction';
const resultType = error ? 'error' : 'success';
return annotationActionsTranslations[type][mode][resultType];
}
}

View File

@ -0,0 +1,86 @@
import { AnnotationActionMode } from '../models/annotation-action-mode.model';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
type ActionType = { [key in AnnotationActionMode]?: { error: string; success: string } };
export const annotationActionsTranslations: {
dictionary: ActionType;
'manual-redaction': ActionType;
} = {
dictionary: {
add: {
error: _('annotation-actions.message.dictionary.add.error'),
success: _('annotation-actions.message.dictionary.add.success')
},
approve: {
error: _('annotation-actions.message.dictionary.approve.error'),
success: _('annotation-actions.message.dictionary.approve.success')
},
decline: {
error: _('annotation-actions.message.dictionary.decline.error'),
success: _('annotation-actions.message.dictionary.decline.success')
},
remove: {
error: _('annotation-actions.message.dictionary.remove.error'),
success: _('annotation-actions.message.dictionary.remove.success')
},
'request-remove': {
error: _('annotation-actions.message.dictionary.request-remove.error'),
success: _('annotation-actions.message.dictionary.request-remove.success')
},
suggest: {
error: _('annotation-actions.message.dictionary.suggest.error'),
success: _('annotation-actions.message.dictionary.suggest.success')
},
undo: {
error: _('annotation-actions.message.dictionary.undo.error'),
success: _('annotation-actions.message.dictionary.undo.success')
}
},
'manual-redaction': {
add: {
error: _('annotation-actions.message.manual-redaction.add.error'),
success: _('annotation-actions.message.manual-redaction.add.success')
},
approve: {
error: _('annotation-actions.message.manual-redaction.approve.error'),
success: _('annotation-actions.message.manual-redaction.approve.success')
},
'change-legal-basis': {
error: _('annotation-actions.message.manual-redaction.change-legal-basis.error'),
success: _('annotation-actions.message.manual-redaction.change-legal-basis.success')
},
decline: {
error: _('annotation-actions.message.manual-redaction.decline.error'),
success: _('annotation-actions.message.manual-redaction.decline.success')
},
'force-redaction': {
error: _('annotation-actions.message.manual-redaction.force-redaction.error'),
success: _('annotation-actions.message.manual-redaction.force-redaction.success')
},
'recategorize-image': {
error: _('annotation-actions.message.manual-redaction.recategorize-image.error'),
success: _('annotation-actions.message.manual-redaction.recategorize-image.success')
},
'request-change-legal-basis': {
error: _('annotation-actions.message.manual-redaction.request-change-legal-basis.error'),
success: _('annotation-actions.message.manual-redaction.request-change-legal-basis.success')
},
'request-force-redaction': {
error: _('annotation-actions.message.manual-redaction.request-force-redaction.error'),
success: _('annotation-actions.message.manual-redaction.request-force-redaction.success')
},
'request-image-recategorization': {
error: _('annotation-actions.message.manual-redaction.request-image-recategorization.error'),
success: _('annotation-actions.message.manual-redaction.request-image-recategorization.success')
},
suggest: {
error: _('annotation-actions.message.manual-redaction.suggest.error'),
success: _('annotation-actions.message.manual-redaction.suggest.success')
},
undo: {
error: _('annotation-actions.message.manual-redaction.undo.error'),
success: _('annotation-actions.message.manual-redaction.undo.success')
}
}
};

View File

@ -116,6 +116,84 @@
"label": ""
},
"hide": "",
"message": {
"dictionary": {
"add": {
"error": "",
"success": ""
},
"approve": {
"error": "",
"success": ""
},
"decline": {
"error": "",
"success": ""
},
"remove": {
"error": "",
"success": ""
},
"request-remove": {
"error": "",
"success": ""
},
"suggest": {
"error": "",
"success": ""
},
"undo": {
"error": "",
"success": ""
}
},
"manual-redaction": {
"add": {
"error": "",
"success": ""
},
"approve": {
"error": "",
"success": ""
},
"change-legal-basis": {
"error": "",
"success": ""
},
"decline": {
"error": "",
"success": ""
},
"force-redaction": {
"error": "",
"success": ""
},
"recategorize-image": {
"error": "",
"success": ""
},
"request-change-legal-basis": {
"error": "",
"success": ""
},
"request-force-redaction": {
"error": "",
"success": ""
},
"request-image-recategorization": {
"error": "",
"success": ""
},
"suggest": {
"error": "",
"success": ""
},
"undo": {
"error": "",
"success": ""
}
}
},
"recategorize-image": "",
"reject-suggestion": "",
"remove-annotation": {
@ -688,7 +766,8 @@
"disable-read-only": "",
"enable-read-only": "",
"read-only": "",
"remove-selected": ""
"remove-selected": "",
"type": ""
},
"title": ""
},