RED-2550: Merge/overwrite dictionary entries + i18n fix
This commit is contained in:
parent
1b7191abf4
commit
e838590c78
@ -46,6 +46,7 @@ import { LicenseReportService } from './services/licence-report.service';
|
||||
import { RulesService } from './services/rules.service';
|
||||
import { SmtpConfigService } from './services/smtp-config.service';
|
||||
import { WatermarkService } from './services/watermark.service';
|
||||
import { UploadDictionaryDialogComponent } from './dialogs/upload-dictionary-dialog/upload-dictionary-dialog.component';
|
||||
|
||||
const dialogs = [
|
||||
AddEditDossierTemplateDialogComponent,
|
||||
@ -58,6 +59,7 @@ const dialogs = [
|
||||
ConfirmDeleteUsersDialogComponent,
|
||||
FileAttributesCsvImportDialogComponent,
|
||||
AddEditDossierAttributeDialogComponent,
|
||||
UploadDictionaryDialogComponent,
|
||||
];
|
||||
|
||||
const screens = [
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
<section class="dialog">
|
||||
<div class="dialog-header heading-l" translate="upload-dictionary-dialog.title"></div>
|
||||
|
||||
<div class="dialog-content">
|
||||
<p translate="upload-dictionary-dialog.question"></p>
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<button
|
||||
(click)="selectOption('overwrite')"
|
||||
color="primary"
|
||||
mat-flat-button
|
||||
translate="upload-dictionary-dialog.options.overwrite"
|
||||
></button>
|
||||
<iqser-icon-button
|
||||
(action)="selectOption('merge')"
|
||||
[label]="'upload-dictionary-dialog.options.merge' | translate"
|
||||
[type]="iconButtonTypes.dark"
|
||||
></iqser-icon-button>
|
||||
<div (click)="cancel()" class="all-caps-label cancel" translate="upload-dictionary-dialog.options.cancel"></div>
|
||||
</div>
|
||||
</section>
|
||||
@ -0,0 +1,11 @@
|
||||
.dialog-header {
|
||||
color: var(--iqser-primary);
|
||||
}
|
||||
|
||||
.dialog-actions > *:not(:last-child) {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.cancel {
|
||||
margin-left: 8px;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { IconButtonTypes } from '@iqser/common-ui';
|
||||
|
||||
@Component({
|
||||
templateUrl: './upload-dictionary-dialog.component.html',
|
||||
styleUrls: ['./upload-dictionary-dialog.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class UploadDictionaryDialogComponent {
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
|
||||
constructor(private readonly _translateService: TranslateService, public dialogRef: MatDialogRef<UploadDictionaryDialogComponent>) {}
|
||||
|
||||
cancel() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
selectOption(option: 'overwrite' | 'merge') {
|
||||
this.dialogRef.close({ option });
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@
|
||||
(saveDictionary)="saveEntries($event)"
|
||||
[canEdit]="currentUser.isAdmin"
|
||||
[filterByDossierTemplate]="true"
|
||||
[initialEntries]="entries"
|
||||
[initialEntries]="initialEntries"
|
||||
></redaction-dictionary-manager>
|
||||
|
||||
<div *ngIf="!!dictionary" class="right-container">
|
||||
|
||||
@ -20,7 +20,7 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly currentUser = this._userService.currentUser;
|
||||
|
||||
entries: string[] = [];
|
||||
initialEntries: string[] = [];
|
||||
dictionary: Dictionary;
|
||||
|
||||
@ViewChild('dictionaryManager', { static: false })
|
||||
@ -98,7 +98,18 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple
|
||||
|
||||
if (file) {
|
||||
fileReader.onload = () => {
|
||||
this._dictionaryManager.editor.value = fileReader.result as string;
|
||||
const fileContent = fileReader.result as string;
|
||||
if (this._dictionaryManager.editor.value) {
|
||||
this._dialogService.openDialog('uploadDictionary', null, null, ({ option }) => {
|
||||
if (option === 'overwrite') {
|
||||
this._overwrite(fileContent);
|
||||
} else if (option === 'merge') {
|
||||
this._merge(fileContent);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this._overwrite(fileContent);
|
||||
}
|
||||
this._fileInput.nativeElement.value = null;
|
||||
};
|
||||
fileReader.readAsText(file);
|
||||
@ -107,20 +118,35 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple
|
||||
|
||||
saveEntries(entries: string[]) {
|
||||
this._loadingService.start();
|
||||
this._dictionaryService.saveEntries(entries, this.entries, this.dictionary.dossierTemplateId, this.dictionary.type, null).subscribe(
|
||||
async () => {
|
||||
await this._loadEntries();
|
||||
},
|
||||
() => {
|
||||
this._loadingService.stop();
|
||||
},
|
||||
);
|
||||
this._dictionaryService
|
||||
.saveEntries(entries, this.initialEntries, this.dictionary.dossierTemplateId, this.dictionary.type, null)
|
||||
.subscribe(
|
||||
async () => {
|
||||
await this._loadEntries();
|
||||
},
|
||||
() => {
|
||||
this._loadingService.stop();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this._appStateService.reset();
|
||||
}
|
||||
|
||||
private _overwrite(fileContent: string): void {
|
||||
this._dictionaryManager.editor.value = fileContent;
|
||||
}
|
||||
|
||||
private _merge(fileContent: string): void {
|
||||
const currentEntries = this._dictionaryManager.editor.value.split('\n');
|
||||
fileContent
|
||||
.split('\n')
|
||||
.filter(entry => !currentEntries.includes(entry))
|
||||
.forEach(entry => currentEntries.push(entry));
|
||||
this._dictionaryManager.editor.value = currentEntries.join('\n');
|
||||
}
|
||||
|
||||
private async _loadEntries() {
|
||||
this._loadingService.start();
|
||||
await this._dictionaryService
|
||||
@ -129,16 +155,18 @@ export class DictionaryOverviewScreenComponent extends ComponentHasChanges imple
|
||||
.then(
|
||||
data => {
|
||||
this._loadingService.stop();
|
||||
this.entries = [...data.entries].sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' }));
|
||||
this.initialEntries = [...data.entries].sort((str1, str2) =>
|
||||
str1.localeCompare(str2, undefined, { sensitivity: 'accent' }),
|
||||
);
|
||||
},
|
||||
() => {
|
||||
this._loadingService.stop();
|
||||
this.entries = [];
|
||||
this.initialEntries = [];
|
||||
},
|
||||
)
|
||||
.catch(() => {
|
||||
this._loadingService.stop();
|
||||
this.entries = [];
|
||||
this.initialEntries = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import { FileAttributesCsvImportDialogComponent } from '../dialogs/file-attribut
|
||||
import { AddEditDossierAttributeDialogComponent } from '../dialogs/add-edit-dossier-attribute-dialog/add-edit-dossier-attribute-dialog.component';
|
||||
import { ConfirmationDialogComponent, DialogConfig, DialogService, largeDialogConfig } from '@iqser/common-ui';
|
||||
import { AddEditJustificationDialogComponent } from '../screens/justifications/add-edit-justification-dialog/add-edit-justification-dialog.component';
|
||||
import { UploadDictionaryDialogComponent } from '../dialogs/upload-dictionary-dialog/upload-dictionary-dialog.component';
|
||||
|
||||
type DialogType =
|
||||
| 'confirm'
|
||||
@ -25,7 +26,8 @@ type DialogType =
|
||||
| 'smtpAuthConfig'
|
||||
| 'addEditDossierTemplate'
|
||||
| 'addEditDossierAttribute'
|
||||
| 'addEditJustification';
|
||||
| 'addEditJustification'
|
||||
| 'uploadDictionary';
|
||||
|
||||
@Injectable()
|
||||
export class AdminDialogService extends DialogService<DialogType> {
|
||||
@ -76,6 +78,9 @@ export class AdminDialogService extends DialogService<DialogType> {
|
||||
component: AddEditJustificationDialogComponent,
|
||||
dialogConfig: { autoFocus: true },
|
||||
},
|
||||
uploadDictionary: {
|
||||
component: UploadDictionaryDialogComponent,
|
||||
},
|
||||
};
|
||||
|
||||
constructor(protected readonly _dialog: MatDialog) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -139,15 +139,6 @@
|
||||
},
|
||||
"annotation": "Annotation",
|
||||
"annotation-actions": {
|
||||
"resize": {
|
||||
"label": "Resize"
|
||||
},
|
||||
"resize-accept": {
|
||||
"label": "Save Resize"
|
||||
},
|
||||
"resize-cancel": {
|
||||
"label": "Abort Resize"
|
||||
},
|
||||
"accept-recommendation": {
|
||||
"label": "Accept Recommendation"
|
||||
},
|
||||
@ -255,6 +246,15 @@
|
||||
"only-here": "Remove only here",
|
||||
"remove-from-dict": "Remove from dictionary"
|
||||
},
|
||||
"resize-accept": {
|
||||
"label": "Save Resize"
|
||||
},
|
||||
"resize-cancel": {
|
||||
"label": "Abort Resize"
|
||||
},
|
||||
"resize": {
|
||||
"label": "Resize"
|
||||
},
|
||||
"show": "Show",
|
||||
"undo": "Undo"
|
||||
},
|
||||
@ -264,13 +264,11 @@
|
||||
"rule": "Redaction based on rule {rule}"
|
||||
},
|
||||
"annotation-type": {
|
||||
"suggestion-resize": "Suggested Resize",
|
||||
"declined-suggestion": "Declined Suggestion",
|
||||
"hint": "Hint",
|
||||
"manual-redaction": "Manual Redaction",
|
||||
"recommendation": "Recommendation",
|
||||
"redaction": "Redaction",
|
||||
"remove-only-here": "Pending removal ( only here )",
|
||||
"skipped": "Skipped",
|
||||
"suggestion-add": "Suggested redaction",
|
||||
"suggestion-add-dictionary": "Suggested dictionary add",
|
||||
@ -278,7 +276,8 @@
|
||||
"suggestion-force-redaction": "Suggestion force redaction",
|
||||
"suggestion-recategorize-image": "Suggested recategorize image",
|
||||
"suggestion-remove": "Suggested redaction removal",
|
||||
"suggestion-remove-dictionary": "Suggested dictionary removal"
|
||||
"suggestion-remove-dictionary": "Suggested dictionary removal",
|
||||
"suggestion-resize": "Suggested Resize"
|
||||
},
|
||||
"annotations": "Annotations",
|
||||
"archived": "Archived",
|
||||
@ -348,16 +347,6 @@
|
||||
"logout": "Logout"
|
||||
},
|
||||
"by": "by",
|
||||
"resize-annotation-dialog": {
|
||||
"actions": {
|
||||
"cancel": "Cancel",
|
||||
"save": "Save Changes"
|
||||
},
|
||||
"content": {
|
||||
"comment": "Comment"
|
||||
},
|
||||
"header": "Resize Redaction"
|
||||
},
|
||||
"change-legal-basis-dialog": {
|
||||
"actions": {
|
||||
"cancel": "Cancel",
|
||||
@ -921,7 +910,6 @@
|
||||
"unsaved-changes": "You have unsaved changes. Save or revert before changing the tab."
|
||||
},
|
||||
"error": {
|
||||
"close": "Close",
|
||||
"http": {
|
||||
"generic": "Action failed with code {status}"
|
||||
},
|
||||
@ -1442,6 +1430,16 @@
|
||||
},
|
||||
"header": "Set Temporary Password for {userName}"
|
||||
},
|
||||
"resize-annotation-dialog": {
|
||||
"actions": {
|
||||
"cancel": "Cancel",
|
||||
"save": "Save Changes"
|
||||
},
|
||||
"content": {
|
||||
"comment": "Comment"
|
||||
},
|
||||
"header": "Resize Redaction"
|
||||
},
|
||||
"roles": {
|
||||
"inactive": "Inactive",
|
||||
"manager-admin": "Manager & Admin",
|
||||
@ -1550,6 +1548,15 @@
|
||||
},
|
||||
"type": "Type",
|
||||
"unknown": "Unknown",
|
||||
"upload-dictionary-dialog": {
|
||||
"options": {
|
||||
"cancel": "Cancel",
|
||||
"merge": "Merge entries",
|
||||
"overwrite": "Overwrite"
|
||||
},
|
||||
"question": "Choose how you want to proceed:",
|
||||
"title": "The dictionary already has entries!"
|
||||
},
|
||||
"upload-status": {
|
||||
"dialog": {
|
||||
"actions": {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit ca957326b3514c7bc158fd80c9f65d1967d431d0
|
||||
Subproject commit db7c3d6bec720dddcf6dfd76d731b17fb891c06c
|
||||
Loading…
x
Reference in New Issue
Block a user