Merge branch 'VM/RED-8045' into 'master'
RED-8045 - Dossier template selection/filter at dossier dictionary comparison Closes RED-8045 See merge request redactmanager/red-ui!251
This commit is contained in:
commit
394be2b2dd
@ -6,7 +6,6 @@
|
||||
[entityType]="entityType"
|
||||
[initialEntries]="initialEntries$ | async"
|
||||
[isLeavingPage]="isLeavingPage"
|
||||
[currentDossierTemplateId]="dossierTemplateId"
|
||||
[selectedDictionaryType]="entityType"
|
||||
[type]="type"
|
||||
></redaction-dictionary-manager>
|
||||
|
||||
@ -46,12 +46,17 @@
|
||||
<mat-form-field>
|
||||
<mat-select
|
||||
[(ngModel)]="selectedDossierTemplate"
|
||||
[disabled]="!compare"
|
||||
[placeholder]="compare ? selectedDossierTemplate.name : (selectDossierTemplate.name | translate)"
|
||||
[disabled]="!compare || dossierTemplates.length === 1"
|
||||
[placeholder]="
|
||||
selectedDossierTemplate.id ? selectedDossierTemplate.name : (selectedDossierTemplate.name | translate)
|
||||
"
|
||||
>
|
||||
<ng-container *ngFor="let dossierTemplate of dossierTemplates">
|
||||
<mat-option [value]="dossierTemplate" *ngIf="dossierTemplate?.id !== selectedDossierTemplate.id">
|
||||
{{ dossierTemplate.name }}
|
||||
<mat-option
|
||||
[value]="dossierTemplate"
|
||||
*ngIf="!currentDossierTemplateId || dossierTemplate?.id !== selectedDossierTemplate.id"
|
||||
>
|
||||
{{ dossierTemplate.id ? dossierTemplate.name : (dossierTemplate.name | translate) }}
|
||||
</mat-option>
|
||||
</ng-container>
|
||||
</mat-select>
|
||||
@ -59,17 +64,14 @@
|
||||
</div>
|
||||
|
||||
<div class="iqser-input-group w-200 mt-0">
|
||||
<mat-form-field>
|
||||
<mat-form-field *ngIf="initialDossierTemplateId">
|
||||
<mat-select
|
||||
[(ngModel)]="selectedDossier"
|
||||
[disabled]="!compare"
|
||||
[disabled]="!compare || (dossiers.length === 1 && !optionNotSelected)"
|
||||
[placeholder]="selectedDossier.dossierId ? selectedDossier.dossierName : (selectDictionary.label | translate)"
|
||||
>
|
||||
<ng-container *ngFor="let dossier of dossiers; let index = index">
|
||||
<mat-option
|
||||
*ngIf="dossier.dossierId !== selectedDossier.dossierId && dossier.dossierId !== currentDossierId"
|
||||
[value]="dossier"
|
||||
>
|
||||
<mat-option *ngIf="dossier.dossierId !== selectedDossier.dossierId" [value]="dossier">
|
||||
{{ dossier.dossierName }}
|
||||
</mat-option>
|
||||
<mat-divider
|
||||
@ -78,6 +80,20 @@
|
||||
</ng-container>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="!initialDossierTemplateId">
|
||||
<mat-select
|
||||
[(ngModel)]="selectedDictionary"
|
||||
[disabled]="!compare || !templateSelected"
|
||||
[placeholder]="selectedDictionary.id ? selectedDictionary.label : (selectDictionary.label | translate)"
|
||||
>
|
||||
<ng-container *ngFor="let dictionary of dictionaries; let index = index">
|
||||
<mat-option [value]="dictionary">
|
||||
{{ dictionary.id ? dictionary.label : (dictionary.label | translate) }}
|
||||
</mat-option>
|
||||
</ng-container>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
@ -32,7 +32,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
@Input() type: DictionaryType = 'dictionary';
|
||||
@Input() entityType?: string;
|
||||
@Input() currentDossierId: string;
|
||||
@Input({ required: true }) currentDossierTemplateId!: string;
|
||||
@Input() currentDossierTemplateId: string;
|
||||
@Input() withFloatingActions = true;
|
||||
@Input() initialEntries: List;
|
||||
@Input() canEdit = false;
|
||||
@ -46,7 +46,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
@ViewChild(EditorComponent) readonly editor: EditorComponent;
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
dossiers: Dossier[];
|
||||
dossierTemplates: DossierTemplate[];
|
||||
dossierTemplates: DossierTemplate[] = this.dossierTemplatesService.all;
|
||||
currentMatch = 0;
|
||||
findMatches: FindMatch[] = [];
|
||||
diffEditorText = '';
|
||||
@ -61,18 +61,20 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
dictionaries: List<Dictionary> = this.#dictionaries;
|
||||
#dossierTemplate = this.dossierTemplatesService.all[0];
|
||||
#dossier = this.selectDossier;
|
||||
#initialDossierTemplateId: string;
|
||||
#dictionary = this.selectDictionary;
|
||||
protected initialDossierTemplateId: string;
|
||||
|
||||
constructor(
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
protected readonly _loadingService: LoadingService,
|
||||
private readonly _activeDossiersService: ActiveDossiersService,
|
||||
private readonly _changeRef: ChangeDetectorRef,
|
||||
protected readonly _loadingService: LoadingService,
|
||||
readonly dossierTemplatesService: DossierTemplatesService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.#initialDossierTemplateId = this.currentDossierTemplateId;
|
||||
this.initialDossierTemplateId = this.currentDossierTemplateId;
|
||||
this.#updateDropdownsOptions();
|
||||
}
|
||||
|
||||
@ -82,7 +84,9 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
|
||||
set selectedDossierTemplate(value: DossierTemplate) {
|
||||
if (!value) {
|
||||
value = this.dossierTemplates.find(t => t.id === this.#initialDossierTemplateId);
|
||||
value = this.initialDossierTemplateId
|
||||
? this.dossierTemplates.find(t => t.id === this.initialDossierTemplateId)
|
||||
: this.selectDossierTemplate;
|
||||
}
|
||||
this.#dossierTemplate = value;
|
||||
this.currentDossierTemplateId = value.dossierTemplateId;
|
||||
@ -90,6 +94,10 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
this.dictionaries = this.#dictionaries;
|
||||
this.#disableDiffEditor();
|
||||
|
||||
if (!this.initialDossierTemplateId && !this.currentDossierId) {
|
||||
this.selectedDictionary = this.selectDictionary;
|
||||
}
|
||||
|
||||
this.#updateDropdownsOptions(false);
|
||||
}
|
||||
|
||||
@ -105,16 +113,28 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#onDossierChanged(dossier.dossierTemplateId, dossier.id).then(entries => {
|
||||
if (!entries.startsWith(COMPARE_ENTRIES_ERROR)) {
|
||||
this.diffEditorText = entries;
|
||||
this.showDiffEditor = true;
|
||||
}
|
||||
});
|
||||
this.#onDossierChanged(dossier.dossierTemplateId, dossier.id).then(entries => this.#updateDiffEditorText(entries));
|
||||
}
|
||||
|
||||
get selectedDictionary() {
|
||||
return this.#dictionary;
|
||||
}
|
||||
|
||||
set selectedDictionary(dictionary: Dictionary) {
|
||||
this.selectedDictionaryType = dictionary.type;
|
||||
this.#dictionary = dictionary;
|
||||
this.#onDossierChanged(this.#dossier.dossierTemplateId).then(entries => this.#updateDiffEditorText(entries));
|
||||
}
|
||||
|
||||
get optionNotSelected() {
|
||||
return this.selectedDossier.dossierName === this.selectDossier.dossierName;
|
||||
if (this.initialDossierTemplateId) {
|
||||
return this.selectedDossier.dossierName === this.selectDossier.dossierName;
|
||||
}
|
||||
return this.selectedDictionary.label === this.selectDictionary.label;
|
||||
}
|
||||
|
||||
get templateSelected() {
|
||||
return this.selectDossierTemplate.name !== this.selectedDossierTemplate.name;
|
||||
}
|
||||
|
||||
get helpModeKey(): string {
|
||||
@ -125,7 +145,10 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
if (!this.#dossierTemplate || this.#dossierTemplate.name === this.selectDossierTemplate.name) {
|
||||
return;
|
||||
}
|
||||
return this._dictionariesMapService.get(this.selectedDossierTemplate?.dossierTemplateId).filter(dict => !dict.virtual);
|
||||
return [
|
||||
this.selectDictionary,
|
||||
...this._dictionariesMapService.get(this.selectedDossierTemplate?.dossierTemplateId).filter(dict => !dict.virtual),
|
||||
];
|
||||
}
|
||||
|
||||
get #templatesWithCurrentEntityType() {
|
||||
@ -184,12 +207,9 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.activeEntryType && this.#dossier?.dossierTemplateId && this.selectedDossier?.dossierId) {
|
||||
this.#onDossierChanged(this.#dossier.dossierTemplateId, this.#dossier.dossierId).then(entries => {
|
||||
if (!entries.startsWith(COMPARE_ENTRIES_ERROR)) {
|
||||
this.diffEditorText = entries;
|
||||
this.showDiffEditor = true;
|
||||
}
|
||||
});
|
||||
this.#onDossierChanged(this.#dossier.dossierTemplateId, this.#dossier.dossierId).then(entries =>
|
||||
this.#updateDiffEditorText(entries),
|
||||
);
|
||||
}
|
||||
|
||||
if (changes.selectedDictionaryType) {
|
||||
@ -227,14 +247,21 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
if (dossierId === 'template') {
|
||||
dictionary = await this._dictionaryService.getForType(dossierTemplateId, this.selectedDictionaryType);
|
||||
} else {
|
||||
dictionary = (
|
||||
await firstValueFrom(
|
||||
this._dictionaryService.loadDictionaryEntriesByType([this.selectedDictionaryType], dossierTemplateId, dossierId),
|
||||
).catch(() => {
|
||||
return [{ entries: [COMPARE_ENTRIES_ERROR], type: '' }];
|
||||
})
|
||||
)[0];
|
||||
if (dossierId) {
|
||||
dictionary = (
|
||||
await firstValueFrom(
|
||||
this._dictionaryService.loadDictionaryEntriesByType([this.selectedDictionaryType], dossierTemplateId, dossierId),
|
||||
).catch(() => {
|
||||
return [{ entries: [COMPARE_ENTRIES_ERROR], type: '' }];
|
||||
})
|
||||
)[0];
|
||||
} else {
|
||||
dictionary = this.selectedDictionaryType
|
||||
? await this._dictionaryService.getForType(this.currentDossierTemplateId, this.selectedDictionaryType)
|
||||
: { entries: [COMPARE_ENTRIES_ERROR], type: '' };
|
||||
}
|
||||
}
|
||||
|
||||
const activeEntries =
|
||||
this.activeEntryType === DictionaryEntryTypes.ENTRY || this.hint
|
||||
? [...dictionary.entries]
|
||||
@ -246,11 +273,16 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
|
||||
#updateDropdownsOptions(updateSelectedDossierTemplate = true) {
|
||||
if (updateSelectedDossierTemplate) {
|
||||
this.currentDossierTemplateId = this.#initialDossierTemplateId ?? this.currentDossierTemplateId;
|
||||
this.dossierTemplates = this.#templatesWithCurrentEntityType;
|
||||
this.currentDossierTemplateId = this.initialDossierTemplateId ?? this.currentDossierTemplateId;
|
||||
this.dossierTemplates = this.currentDossierTemplateId ? this.#templatesWithCurrentEntityType : this.dossierTemplatesService.all;
|
||||
if (!this.currentDossierTemplateId) {
|
||||
this.dossierTemplates = [this.selectDossierTemplate, ...this.dossierTemplates];
|
||||
}
|
||||
this.selectedDossierTemplate = this.dossierTemplates.find(t => t.id === this.currentDossierTemplateId);
|
||||
}
|
||||
this.dossiers = this._activeDossiersService.all.filter(d => d.dossierTemplateId === this.currentDossierTemplateId);
|
||||
this.dossiers = this._activeDossiersService.all.filter(
|
||||
d => d.dossierTemplateId === this.currentDossierTemplateId && d.id !== this.currentDossierId,
|
||||
);
|
||||
const templateDictionary = {
|
||||
id: 'template',
|
||||
dossierId: 'template',
|
||||
@ -264,4 +296,12 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
this.showDiffEditor = false;
|
||||
this.diffEditorText = '';
|
||||
}
|
||||
|
||||
#updateDiffEditorText(entries: string) {
|
||||
if (!entries.startsWith(COMPARE_ENTRIES_ERROR)) {
|
||||
this.diffEditorText = entries;
|
||||
this.showDiffEditor = true;
|
||||
this._changeRef.markForCheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user