RED-6801 - Effective dossier dictionary in Dossier Settings
This commit is contained in:
parent
fb0214bec0
commit
4aa8f90df9
@ -2,9 +2,13 @@
|
||||
<iqser-circle-button
|
||||
(action)="openEditDossierDialog(dossier.id)"
|
||||
*allow="roles.dossiers.read; if: currentUser.isUser"
|
||||
[icon]="(iqserPermissionsService.has$(roles.dossiers.edit) | async) && currentUser.isManager ? 'iqser:edit' : 'red:info'"
|
||||
[icon]="
|
||||
((iqserPermissionsService.has$(roles.dossiers.edit) | async) && currentUser.isManager) || canEditDossierDictionary
|
||||
? 'iqser:edit'
|
||||
: 'red:info'
|
||||
"
|
||||
[tooltip]="
|
||||
((iqserPermissionsService.has$(roles.dossiers.edit) | async) && currentUser.isManager
|
||||
(((iqserPermissionsService.has$(roles.dossiers.edit) | async) && currentUser.isManager) || canEditDossierDictionary
|
||||
? 'dossier-listing.edit.action'
|
||||
: 'dossier-listing.dossier-info.action'
|
||||
) | translate
|
||||
|
||||
@ -46,6 +46,10 @@ export class DossiersListingActionsComponent implements OnChanges {
|
||||
this.analysisForced = !$event.touchEnd && this._userPreferenceService.areDevFeaturesEnabled;
|
||||
}
|
||||
|
||||
get canEditDossierDictionary() {
|
||||
return this.permissionsService.canEditDossierDictionary(this.dossier);
|
||||
}
|
||||
|
||||
openEditDossierDialog(dossierId: string): void {
|
||||
this._dialogService.openDialog('editDossier', { dossierId });
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-right flex">
|
||||
<div class="header-right flex" [class.read-only]="!canEdit">
|
||||
<iqser-icon-button
|
||||
[label]="'edit-dossier-dialog.dictionary.to-redact' | translate"
|
||||
[active]="activeEntryType === entryTypes.ENTRY"
|
||||
|
||||
@ -54,6 +54,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.read-only {
|
||||
padding-right: 100px;
|
||||
}
|
||||
|
||||
.display-name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { Dictionary, DictionaryEntryType, DictionaryEntryTypes, Dossier } from '@red/domain';
|
||||
import { EditDossierSaveResult, EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||
import { EditDossierSaveResult } from '../edit-dossier-section.interface';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { DictionaryManagerComponent } from '@shared/components/dictionary-manager/dictionary-manager.component';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
@ -14,7 +14,7 @@ import { List } from '@iqser/common-ui/lib/utils';
|
||||
templateUrl: './edit-dossier-dictionary.component.html',
|
||||
styleUrls: ['./edit-dossier-dictionary.component.scss'],
|
||||
})
|
||||
export class EditDossierDictionaryComponent implements EditDossierSectionInterface, OnInit {
|
||||
export class EditDossierDictionaryComponent implements OnInit {
|
||||
@Input() dossier: Dossier;
|
||||
|
||||
canEdit = false;
|
||||
@ -76,15 +76,15 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
this._dictionaryManager.revert();
|
||||
}
|
||||
|
||||
selectDictionary(dictionary: Dictionary, entryType: DictionaryEntryType = DictionaryEntryTypes.ENTRY) {
|
||||
selectDictionary(dictionary: Dictionary, entryType?: DictionaryEntryType) {
|
||||
this.selectedDictionary = dictionary;
|
||||
this.selectEntryType(entryType);
|
||||
}
|
||||
|
||||
selectEntryType(selectedEntryType: DictionaryEntryType) {
|
||||
this.activeEntryType = selectedEntryType;
|
||||
this.activeEntryType = selectedEntryType ?? this.activeEntryType;
|
||||
|
||||
switch (selectedEntryType) {
|
||||
switch (this.activeEntryType) {
|
||||
case DictionaryEntryTypes.ENTRY: {
|
||||
this.entriesToDisplay = this.selectedDictionary.entries;
|
||||
break;
|
||||
@ -98,6 +98,8 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.entriesToDisplay = this.#toString([...this.entriesToDisplay]);
|
||||
}
|
||||
|
||||
async #updateDossierDictionary() {
|
||||
@ -108,9 +110,11 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
);
|
||||
//TODO remove this when backend will send also the type
|
||||
this.#setType(dictionaryTypes);
|
||||
if (!this.selectedDictionary) {
|
||||
this.selectDictionary(this.dictionaries[0], this.activeEntryType);
|
||||
let dictionaryToSelect = this.dictionaries[0];
|
||||
if (this.selectedDictionary) {
|
||||
dictionaryToSelect = this.dictionaries.find(d => d.type === this.selectedDictionary.type);
|
||||
}
|
||||
this.selectDictionary(dictionaryToSelect, this.activeEntryType);
|
||||
}
|
||||
|
||||
//TODO remove this when backend will send also the type
|
||||
@ -121,4 +125,8 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
this.dictionaries[i] = dictionaryWithType as Dictionary;
|
||||
}
|
||||
}
|
||||
|
||||
#toString(entries: string[]) {
|
||||
return entries.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'accent' }));
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,6 +95,7 @@ export class EditDossierDialogComponent extends BaseDialogComponent implements A
|
||||
|
||||
get showActionButtons(): boolean {
|
||||
return (
|
||||
(['dossierDictionary'].includes(this.activeNav) && this._permissionsService.canEditDossierDictionary(this._dossier)) ||
|
||||
(['members'].includes(this.activeNav) &&
|
||||
this.#currentUser.isManager &&
|
||||
this.iqserPermissionsService.has(Roles.dossiers.edit)) ||
|
||||
|
||||
@ -205,9 +205,6 @@ export class DictionaryManagerComponent implements OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (!changes.isLeavingPage) {
|
||||
this.revert();
|
||||
}
|
||||
if ((changes.selectedDictionaryType || changes.activeEntryType) && this._dossier?.dossierTemplateId && this.dossier?.dossierId) {
|
||||
this.#onDossierChanged(this._dossier.dossierTemplateId, this._dossier.dossierId).then(entries => {
|
||||
this.diffEditorText = entries;
|
||||
|
||||
@ -7,10 +7,4 @@
|
||||
[options]="editorOptions"
|
||||
></ngx-monaco-editor>
|
||||
|
||||
<ngx-monaco-diff-editor
|
||||
(init)="onDiffEditorInit($event)"
|
||||
*ngIf="showDiffEditor"
|
||||
[modified]="diffValue"
|
||||
[options]="editorOptions"
|
||||
[original]="diffEditorText"
|
||||
></ngx-monaco-diff-editor>
|
||||
<ngx-monaco-diff-editor (init)="onDiffEditorInit($event)" *ngIf="showDiffEditor" [options]="editorOptions"></ngx-monaco-diff-editor>
|
||||
|
||||
@ -84,6 +84,7 @@ export class EditorComponent implements OnInit, OnChanges {
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes.diffEditorText) {
|
||||
this.revert();
|
||||
this._diffEditor?.getOriginalEditor().setValue(this.diffEditorText);
|
||||
}
|
||||
}
|
||||
@ -105,6 +106,8 @@ export class EditorComponent implements OnInit, OnChanges {
|
||||
this._diffEditor = editor;
|
||||
this.codeEditor = editor.getModifiedEditor();
|
||||
this.#addMarginButtons();
|
||||
this._diffEditor?.getOriginalEditor().setValue(this.diffEditorText);
|
||||
this._diffEditor?.getModifiedEditor().setValue(this.diffValue);
|
||||
this._diffEditor.getOriginalEditor().onMouseDown(event => this.#handleMarginButtonClick(event));
|
||||
this._diffEditor.getModifiedEditor().onDidChangeModelContent(() => {
|
||||
this.value = this._diffEditor.getModel().modified.getValue();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user