WIP on VM/RED-10332
RED-10332 - Dossier Template not changeable when comparing dossier dictionaries in Edit dossier modal
This commit is contained in:
parent
82e31fffd8
commit
f0b6cf9712
@ -54,8 +54,8 @@
|
|||||||
[currentDossierTemplateId]="dossier.dossierTemplateId"
|
[currentDossierTemplateId]="dossier.dossierTemplateId"
|
||||||
[hint]="selectedDictionary.hint"
|
[hint]="selectedDictionary.hint"
|
||||||
[initialEntries]="entriesToDisplay || []"
|
[initialEntries]="entriesToDisplay || []"
|
||||||
[selectedDictionaryTypeLabel]="selectedDictionary.label"
|
|
||||||
[selectedDictionaryType]="selectedDictionary.type"
|
[selectedDictionaryType]="selectedDictionary.type"
|
||||||
|
[activeDictionary]="selectedDictionary"
|
||||||
[withFloatingActions]="false"
|
[withFloatingActions]="false"
|
||||||
>
|
>
|
||||||
<ng-container slot="typeSwitch">
|
<ng-container slot="typeSwitch">
|
||||||
|
|||||||
@ -83,7 +83,7 @@ export class EditDossierDictionaryComponent implements OnInit {
|
|||||||
try {
|
try {
|
||||||
await this._dictionaryService.saveEntries(
|
await this._dictionaryService.saveEntries(
|
||||||
this._dictionaryManager.editor.currentEntries,
|
this._dictionaryManager.editor.currentEntries,
|
||||||
this._dictionaryManager.initialEntries,
|
this._dictionaryManager.initialEntries(),
|
||||||
this.dossier.dossierTemplateId,
|
this.dossier.dossierTemplateId,
|
||||||
this.selectedDictionary.type,
|
this.selectedDictionary.type,
|
||||||
this.dossier.id,
|
this.dossier.id,
|
||||||
|
|||||||
@ -24,8 +24,8 @@ export class FileDownloadBtnComponent implements OnChanges {
|
|||||||
readonly tooltipPosition = input<'above' | 'below' | 'before' | 'after'>('above');
|
readonly tooltipPosition = input<'above' | 'below' | 'before' | 'after'>('above');
|
||||||
readonly type = input<CircleButtonType>(CircleButtonTypes.default);
|
readonly type = input<CircleButtonType>(CircleButtonTypes.default);
|
||||||
readonly tooltipClass = input<string>();
|
readonly tooltipClass = input<string>();
|
||||||
readonly disabled = input<boolean>(false);
|
readonly disabled = input(false, { transform: booleanAttribute });
|
||||||
readonly singleFileDownload = input<boolean>(false);
|
readonly singleFileDownload = input(false, { transform: booleanAttribute });
|
||||||
readonly dossierDownload = input(false, { transform: booleanAttribute });
|
readonly dossierDownload = input(false, { transform: booleanAttribute });
|
||||||
readonly dropdownButton = computed(() => this.isDocumine && (this.dossierDownload() || this.singleFileDownload()));
|
readonly dropdownButton = computed(() => this.isDocumine && (this.dossierDownload() || this.singleFileDownload()));
|
||||||
tooltip: string;
|
tooltip: string;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<iqser-circle-button
|
<iqser-circle-button
|
||||||
(action)="download()"
|
(action)="download()"
|
||||||
*ngIf="canDownload"
|
*ngIf="canDownload()"
|
||||||
[attr.help-mode-key]="helpModeKey"
|
[attr.help-mode-key]="helpModeKey"
|
||||||
[matTooltip]="'dictionary-overview.download' | translate"
|
[matTooltip]="'dictionary-overview.download' | translate"
|
||||||
class="ml-8"
|
class="ml-8"
|
||||||
@ -63,11 +63,17 @@
|
|||||||
>
|
>
|
||||||
@for (dossier of dossiers; track dossier; let index = $index) {
|
@for (dossier of dossiers; track dossier; let index = $index) {
|
||||||
@if (dossier.dossierId !== selectedDossier.dossierId) {
|
@if (dossier.dossierId !== selectedDossier.dossierId) {
|
||||||
<mat-option [class.mat-mdc-option-active]="false" [value]="dossier">
|
@if (!activeDictionary().dossierDictionaryOnly) {
|
||||||
{{ dossier.dossierName }}
|
<mat-option [class.mat-mdc-option-active]="false" [value]="dossier">
|
||||||
</mat-option>
|
{{ dossier.dossierName }}
|
||||||
@if (index === dossiers.length - 2 && !selectedDossier.dossierId?.includes('template')) {
|
</mat-option>
|
||||||
<mat-divider></mat-divider>
|
@if (index === dossiers.length - 2 && !selectedDossier.dossierId?.includes('template')) {
|
||||||
|
<mat-divider></mat-divider>
|
||||||
|
}
|
||||||
|
} @else if (!dossier.dossierId?.includes('template')) {
|
||||||
|
<mat-option [class.mat-mdc-option-active]="false" [value]="dossier">
|
||||||
|
{{ dossier.dossierName }}
|
||||||
|
</mat-option>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,9 +104,9 @@
|
|||||||
<div class="editor-container">
|
<div class="editor-container">
|
||||||
<redaction-editor
|
<redaction-editor
|
||||||
[(isSearchOpen)]="_isSearchOpen"
|
[(isSearchOpen)]="_isSearchOpen"
|
||||||
[canEdit]="canEdit"
|
[canEdit]="canEdit()"
|
||||||
[diffEditorText]="diffEditorText"
|
[diffEditorText]="diffEditorText"
|
||||||
[initialEntries]="initialEntries"
|
[initialEntries]="initialEntries()"
|
||||||
[showDiffEditor]="compare && showDiffEditor"
|
[showDiffEditor]="compare && showDiffEditor"
|
||||||
></redaction-editor>
|
></redaction-editor>
|
||||||
|
|
||||||
@ -112,7 +118,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (withFloatingActions && !!editor?.hasChanges && canEdit && !isLeavingPage) {
|
@if (withFloatingActions() && !!editor?.hasChanges && canEdit() && !isLeavingPage()) {
|
||||||
<div [class.offset]="compare" class="changes-box">
|
<div [class.offset]="compare" class="changes-box">
|
||||||
<iqser-icon-button
|
<iqser-icon-button
|
||||||
(action)="saveDictionary.emit()"
|
(action)="saveDictionary.emit()"
|
||||||
|
|||||||
@ -1,10 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
|
booleanAttribute,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
|
effect,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
|
input,
|
||||||
Input,
|
Input,
|
||||||
|
model,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
output,
|
||||||
Output,
|
Output,
|
||||||
signal,
|
signal,
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
@ -60,21 +65,21 @@ const HELP_MODE_KEYS = {
|
|||||||
EditorComponent,
|
EditorComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class DictionaryManagerComponent implements OnChanges, OnInit {
|
export class DictionaryManagerComponent implements OnInit {
|
||||||
@Input() type: DictionaryType = 'dictionary';
|
readonly type = input<DictionaryType>('dictionary');
|
||||||
@Input() entityType?: string;
|
readonly entityType = input<string>();
|
||||||
@Input() currentDossierId: string;
|
readonly currentDossierId = input<string>();
|
||||||
@Input() currentDossierTemplateId: string;
|
readonly currentDossierTemplateId = model<string>();
|
||||||
@Input() withFloatingActions = true;
|
readonly withFloatingActions = input(true, { transform: booleanAttribute });
|
||||||
@Input() initialEntries: List;
|
readonly initialEntries = input.required<List>();
|
||||||
@Input() canEdit = false;
|
readonly canEdit = input(false, { transform: booleanAttribute });
|
||||||
@Input() canDownload = false;
|
readonly canDownload = input(false, { transform: booleanAttribute });
|
||||||
@Input() isLeavingPage = false;
|
readonly isLeavingPage = input(false, { transform: booleanAttribute });
|
||||||
@Input() hint = false;
|
readonly hint = input(false, { transform: booleanAttribute });
|
||||||
@Input() selectedDictionaryType = 'dossier_redaction';
|
readonly activeDictionary = input<Dictionary>();
|
||||||
@Input() selectedDictionaryTypeLabel: string;
|
readonly selectedDictionaryType = model<string>('dossier_redaction');
|
||||||
@Input() activeEntryType: DictionaryEntryType = DictionaryEntryTypes.ENTRY;
|
readonly activeEntryType = input<DictionaryEntryType>(DictionaryEntryTypes.ENTRY);
|
||||||
@Output() readonly saveDictionary = new EventEmitter<string[]>();
|
readonly saveDictionary = output();
|
||||||
@ViewChild(EditorComponent) readonly editor: EditorComponent;
|
@ViewChild(EditorComponent) readonly editor: EditorComponent;
|
||||||
readonly iconButtonTypes = IconButtonTypes;
|
readonly iconButtonTypes = IconButtonTypes;
|
||||||
dossiers: Dossier[];
|
dossiers: Dossier[];
|
||||||
@ -102,7 +107,24 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
private readonly _changeRef: ChangeDetectorRef,
|
private readonly _changeRef: ChangeDetectorRef,
|
||||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||||
protected readonly _loadingService: LoadingService,
|
protected readonly _loadingService: LoadingService,
|
||||||
) {}
|
) {
|
||||||
|
effect(() => {
|
||||||
|
if (this.activeEntryType() && this.#dossier?.dossierTemplateId && this.selectedDossier?.dossierId) {
|
||||||
|
this.#onDossierChanged(this.#dossier.dossierTemplateId, this.#dossier.dossierId).then(entries =>
|
||||||
|
this.#updateDiffEditorText(entries),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
effect(
|
||||||
|
() => {
|
||||||
|
if (this.selectedDictionaryType()) {
|
||||||
|
this.#disableDiffEditor();
|
||||||
|
this.#updateDropdownsOptions();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ allowSignalWrites: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
get selectedDossierTemplate() {
|
get selectedDossierTemplate() {
|
||||||
return this.#dossierTemplate;
|
return this.#dossierTemplate;
|
||||||
@ -115,12 +137,12 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
: this.selectDossierTemplate;
|
: this.selectDossierTemplate;
|
||||||
}
|
}
|
||||||
this.#dossierTemplate = value;
|
this.#dossierTemplate = value;
|
||||||
this.currentDossierTemplateId = value.dossierTemplateId;
|
this.currentDossierTemplateId.set(value.dossierTemplateId);
|
||||||
this.#dossier = this.selectDossier;
|
this.#dossier = this.selectDossier;
|
||||||
this.dictionaries = this.#dictionaries;
|
this.dictionaries = this.#dictionaries;
|
||||||
this.#disableDiffEditor();
|
this.#disableDiffEditor();
|
||||||
|
|
||||||
if (!this.initialDossierTemplateId && !this.currentDossierId) {
|
if (!this.initialDossierTemplateId && !this.currentDossierId()) {
|
||||||
this.selectedDictionary = this.selectDictionary;
|
this.selectedDictionary = this.selectDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +170,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
set selectedDictionary(dictionary: Dictionary) {
|
set selectedDictionary(dictionary: Dictionary) {
|
||||||
if (dictionary.type) {
|
if (dictionary.type) {
|
||||||
this.selectedDictionaryType = dictionary.type;
|
this.selectedDictionaryType.set(dictionary.type);
|
||||||
this.#dictionary = dictionary;
|
this.#dictionary = dictionary;
|
||||||
this.#onDossierChanged(this.#dossier.dossierTemplateId).then(entries => this.#updateDiffEditorText(entries));
|
this.#onDossierChanged(this.#dossier.dossierTemplateId).then(entries => this.#updateDiffEditorText(entries));
|
||||||
}
|
}
|
||||||
@ -181,7 +203,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
get #templatesWithCurrentEntityType() {
|
get #templatesWithCurrentEntityType() {
|
||||||
return this._dossierTemplatesService.all.filter(t =>
|
return this._dossierTemplatesService.all.filter(t =>
|
||||||
this._dictionaryService.hasType(t.dossierTemplateId, this.selectedDictionaryType),
|
this._dictionaryService.hasType(t.dossierTemplateId, this.selectedDictionaryType()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +212,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
this.dossierTemplates = this._dossierTemplatesService.all;
|
this.dossierTemplates = this._dossierTemplatesService.all;
|
||||||
await firstValueFrom(this._dictionaryService.loadDictionaryDataForDossierTemplates(this.dossierTemplates.map(t => t.id)));
|
await firstValueFrom(this._dictionaryService.loadDictionaryDataForDossierTemplates(this.dossierTemplates.map(t => t.id)));
|
||||||
this.#dossierTemplate = this._dossierTemplatesService.all[0];
|
this.#dossierTemplate = this._dossierTemplatesService.all[0];
|
||||||
this.initialDossierTemplateId = this.currentDossierTemplateId;
|
this.initialDossierTemplateId = this.currentDossierTemplateId();
|
||||||
this.#updateDropdownsOptions();
|
this.#updateDropdownsOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +221,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
const blob = new Blob([content], {
|
const blob = new Blob([content], {
|
||||||
type: 'text/plain;charset=utf-8',
|
type: 'text/plain;charset=utf-8',
|
||||||
});
|
});
|
||||||
saveAs(blob, `${this.entityType}-${this.type}.txt`);
|
saveAs(blob, `${this.entityType()}-${this.type()}.txt`);
|
||||||
}
|
}
|
||||||
|
|
||||||
revert() {
|
revert() {
|
||||||
@ -213,43 +235,30 @@ 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 =>
|
|
||||||
this.#updateDiffEditorText(entries),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changes.selectedDictionaryType) {
|
|
||||||
this.#disableDiffEditor();
|
|
||||||
this.#updateDropdownsOptions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async #onDossierChanged(dossierTemplateId: string, dossierId?: string) {
|
async #onDossierChanged(dossierTemplateId: string, dossierId?: string) {
|
||||||
let dictionary: IDictionary;
|
let dictionary: IDictionary;
|
||||||
if (dossierId === 'template') {
|
if (dossierId === 'template') {
|
||||||
dictionary = await this._dictionaryService.getForType(dossierTemplateId, this.selectedDictionaryType);
|
dictionary = await this._dictionaryService.getForType(dossierTemplateId, this.selectedDictionaryType());
|
||||||
} else {
|
} else {
|
||||||
if (dossierId) {
|
if (dossierId) {
|
||||||
dictionary = (
|
dictionary = (
|
||||||
await firstValueFrom(
|
await firstValueFrom(
|
||||||
this._dictionaryService.loadDictionaryEntriesByType([this.selectedDictionaryType], dossierTemplateId, dossierId),
|
this._dictionaryService.loadDictionaryEntriesByType([this.selectedDictionaryType()], dossierTemplateId, dossierId),
|
||||||
).catch(() => {
|
).catch(() => {
|
||||||
return [{ entries: [COMPARE_ENTRIES_ERROR], type: '' }];
|
return [{ entries: [COMPARE_ENTRIES_ERROR], type: '' }];
|
||||||
})
|
})
|
||||||
)[0];
|
)[0];
|
||||||
} else {
|
} else {
|
||||||
dictionary = this.selectedDictionaryType
|
dictionary = this.selectedDictionaryType()
|
||||||
? await this._dictionaryService.getForType(this.currentDossierTemplateId, this.selectedDictionaryType)
|
? await this._dictionaryService.getForType(this.currentDossierTemplateId(), this.selectedDictionaryType())
|
||||||
: { entries: [COMPARE_ENTRIES_ERROR], type: '' };
|
: { entries: [COMPARE_ENTRIES_ERROR], type: '' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeEntries =
|
const activeEntries =
|
||||||
this.activeEntryType === DictionaryEntryTypes.ENTRY || this.hint
|
this.activeEntryType() === DictionaryEntryTypes.ENTRY || this.hint()
|
||||||
? [...dictionary.entries]
|
? [...dictionary.entries]
|
||||||
: this.activeEntryType === DictionaryEntryTypes.FALSE_POSITIVE
|
: this.activeEntryType() === DictionaryEntryTypes.FALSE_POSITIVE
|
||||||
? [...dictionary.falsePositiveEntries]
|
? [...dictionary.falsePositiveEntries]
|
||||||
: [...dictionary.falseRecommendationEntries];
|
: [...dictionary.falseRecommendationEntries];
|
||||||
return activeEntries.join('\n');
|
return activeEntries.join('\n');
|
||||||
@ -257,23 +266,23 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
|||||||
|
|
||||||
#updateDropdownsOptions(updateSelectedDossierTemplate = true) {
|
#updateDropdownsOptions(updateSelectedDossierTemplate = true) {
|
||||||
if (updateSelectedDossierTemplate) {
|
if (updateSelectedDossierTemplate) {
|
||||||
this.currentDossierTemplateId = this.initialDossierTemplateId ?? this.currentDossierTemplateId;
|
this.currentDossierTemplateId.set(this.initialDossierTemplateId ?? this.currentDossierTemplateId());
|
||||||
this.dossierTemplates = this.currentDossierTemplateId
|
this.dossierTemplates = this.currentDossierTemplateId
|
||||||
? this.#templatesWithCurrentEntityType
|
? this.#templatesWithCurrentEntityType
|
||||||
: this._dossierTemplatesService.all;
|
: this._dossierTemplatesService.all;
|
||||||
if (!this.currentDossierTemplateId) {
|
if (!this.currentDossierTemplateId) {
|
||||||
this.dossierTemplates = [this.selectDossierTemplate, ...this.dossierTemplates];
|
this.dossierTemplates = [this.selectDossierTemplate, ...this.dossierTemplates];
|
||||||
}
|
}
|
||||||
this.selectedDossierTemplate = this.dossierTemplates.find(t => t.id === this.currentDossierTemplateId);
|
this.selectedDossierTemplate = this.dossierTemplates.find(t => t.id === this.currentDossierTemplateId());
|
||||||
}
|
}
|
||||||
this.dossiers = this._activeDossiersService.all.filter(
|
this.dossiers = this._activeDossiersService.all.filter(
|
||||||
d => d.dossierTemplateId === this.currentDossierTemplateId && d.id !== this.currentDossierId,
|
d => d.dossierTemplateId === this.currentDossierTemplateId() && d.id !== this.currentDossierId(),
|
||||||
);
|
);
|
||||||
const templateDictionary = {
|
const templateDictionary = {
|
||||||
id: 'template',
|
id: 'template',
|
||||||
dossierId: 'template',
|
dossierId: 'template',
|
||||||
dossierName: 'Template Dictionary',
|
dossierName: 'Template Dictionary',
|
||||||
dossierTemplateId: this.currentDossierTemplateId,
|
dossierTemplateId: this.currentDossierTemplateId(),
|
||||||
} as Dossier;
|
} as Dossier;
|
||||||
this.dossiers.push(templateDictionary);
|
this.dossiers.push(templateDictionary);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user