Edit dossier dictionary name WIP
This commit is contained in:
parent
0308d6c88f
commit
12d2b40246
@ -1,6 +1,6 @@
|
||||
<div class="header-wrapper">
|
||||
<div class="heading">
|
||||
<div translate="edit-dossier-dialog.nav-items.dossier-dictionary"></div>
|
||||
<div>{{ dossierWrapper.type?.label || ('edit-dossier-dialog.nav-items.dossier-dictionary' | translate) }}</div>
|
||||
<div class="small-label stats-subtitle">
|
||||
<div>
|
||||
<mat-icon svgIcon="red:entries"></mat-icon>
|
||||
@ -9,18 +9,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="display-name">-->
|
||||
<!-- <div class="mr-16" translate="Display Name"></div>-->
|
||||
<!-- <iqser-editable-input-->
|
||||
<!-- (save)="field.name = $event"-->
|
||||
<!-- [buttonsType]="circleButtonTypes.dark"-->
|
||||
<!-- [cancelTooltip]="'file-attributes-csv-import.action.cancel-edit-name' | translate"-->
|
||||
<!-- [class]="'w-200'"-->
|
||||
<!-- [editTooltip]="'file-attributes-csv-import.action.edit-name' | translate"-->
|
||||
<!-- [saveTooltip]="'file-attributes-csv-import.action.save-name' | translate"-->
|
||||
<!-- [value]="field.name"-->
|
||||
<!-- ></iqser-editable-input>-->
|
||||
<!-- </div>-->
|
||||
<div class="display-name">
|
||||
<div
|
||||
[translateParams]="{ type: dossierWrapper.type?.label ? 'edit' : 'set' }"
|
||||
[translate]="'edit-dossier-dialog.dictionary.display-name.edit'"
|
||||
></div>
|
||||
<iqser-editable-input
|
||||
(save)="updateDisplayName($event)"
|
||||
[buttonsType]="circleButtonTypes.default"
|
||||
[cancelTooltip]="'edit-dossier-dialog.dictionary.display-name.cancel' | translate"
|
||||
[class]="'w-250 ml-16'"
|
||||
[placeholder]="'edit-dossier-dialog.dictionary.display-name.placeholder' | translate"
|
||||
[saveTooltip]="'edit-dossier-dialog.dictionary.display-name.save' | translate"
|
||||
[showPreview]="false"
|
||||
[value]="dossierWrapper.type?.label"
|
||||
></iqser-editable-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<redaction-dictionary-manager
|
||||
|
||||
@ -5,5 +5,10 @@
|
||||
.display-name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
|
||||
> div {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
import { EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||
@ -6,23 +6,27 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
import { DictionaryManagerComponent } from '@shared/components/dictionary-manager/dictionary-manager.component';
|
||||
import { DictionarySaveService } from '@shared/services/dictionary-save.service';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { CircleButtonTypes } from '@iqser/common-ui';
|
||||
import { Dictionary, DictionaryControllerService } from '@redaction/red-ui-http';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-dictionary',
|
||||
templateUrl: './edit-dossier-dictionary.component.html',
|
||||
styleUrls: ['./edit-dossier-dictionary.component.scss']
|
||||
})
|
||||
export class EditDossierDictionaryComponent implements EditDossierSectionInterface {
|
||||
export class EditDossierDictionaryComponent implements EditDossierSectionInterface, OnInit {
|
||||
@Input() dossierWrapper: DossierWrapper;
|
||||
@Output() updateDossier = new EventEmitter<any>();
|
||||
@Output() updateDossier: EventEmitter<any> = new EventEmitter<any>();
|
||||
canEdit = false;
|
||||
@ViewChild(DictionaryManagerComponent, { static: false })
|
||||
private _dictionaryManager: DictionaryManagerComponent;
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
|
||||
@ViewChild(DictionaryManagerComponent, { static: false }) private _dictionaryManager: DictionaryManagerComponent;
|
||||
|
||||
constructor(
|
||||
private readonly _appStateService: AppStateService,
|
||||
private readonly _dictionarySaveService: DictionarySaveService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _dictionaryControllerService: DictionaryControllerService,
|
||||
private readonly _formBuilder: FormBuilder
|
||||
) {
|
||||
this.canEdit = this._permissionsService.isDossierMember(this.dossierWrapper) || this._permissionsService.isAdmin();
|
||||
@ -36,8 +40,21 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
return !this.canEdit;
|
||||
}
|
||||
|
||||
save() {
|
||||
this._dictionarySaveService
|
||||
ngOnInit() {
|
||||
console.log(this.dossierWrapper.type ? 'has' : "doesn't have");
|
||||
}
|
||||
|
||||
async updateDisplayName(label: string) {
|
||||
const typeValue: Dictionary = { ...this.dossierWrapper.type, label };
|
||||
await this._dictionaryControllerService
|
||||
.updateType(typeValue, this.dossierWrapper.dossierTemplateId, 'dossier_redaction')
|
||||
.toPromise();
|
||||
await this._appStateService.updateDossierDictionary(this.dossierWrapper.dossierTemplateId, this.dossierWrapper.dossierId);
|
||||
this.updateDossier.emit();
|
||||
}
|
||||
|
||||
async save() {
|
||||
await this._dictionarySaveService
|
||||
.saveEntries(
|
||||
this._dictionaryManager.currentEntries,
|
||||
this._dictionaryManager.initialEntries,
|
||||
@ -46,10 +63,9 @@ export class EditDossierDictionaryComponent implements EditDossierSectionInterfa
|
||||
this.dossierWrapper.dossierId,
|
||||
false
|
||||
)
|
||||
.subscribe(async () => {
|
||||
this._appStateService.updateDossierDictionary(this.dossierWrapper.dossierTemplateId, this.dossierWrapper.dossierId);
|
||||
this.updateDossier.emit();
|
||||
});
|
||||
.toPromise();
|
||||
await this._appStateService.updateDossierDictionary(this.dossierWrapper.dossierTemplateId, this.dossierWrapper.dossierId);
|
||||
this.updateDossier.emit();
|
||||
}
|
||||
|
||||
revert() {
|
||||
|
||||
@ -269,28 +269,28 @@ export class AppStateService {
|
||||
await this._reanalysisControllerService.reanalyzeDossier(dossierId, true).toPromise();
|
||||
}
|
||||
|
||||
activateDossier(dossierId: string): void {
|
||||
async activateDossier(dossierId: string) {
|
||||
this._appState.activeFileId = null;
|
||||
this._appState.activeDossierId = dossierId;
|
||||
if (!this.activeDossier) {
|
||||
this._appState.activeDossierId = null;
|
||||
this._router.navigate(['/main/dossiers']).then();
|
||||
await this._router.navigate(['/main/dossiers']);
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateDossierDictionary(this.activeDossier.dossierTemplateId, dossierId);
|
||||
await this.updateDossierDictionary(this.activeDossier.dossierTemplateId, dossierId);
|
||||
}
|
||||
|
||||
updateDossierDictionary(dossierTemplateId: string, dossierId: string) {
|
||||
async updateDossierDictionary(dossierTemplateId: string, dossierId: string) {
|
||||
// dossier exists, load its dictionary
|
||||
this._dictionaryControllerService.getDictionaryForType(dossierTemplateId, 'dossier_redaction', dossierId).subscribe(
|
||||
typeData => {
|
||||
this.activeDossier.type = typeData;
|
||||
},
|
||||
() => {
|
||||
this.activeDossier.type = null;
|
||||
}
|
||||
);
|
||||
const dossier = this.getDossierById(dossierId);
|
||||
try {
|
||||
dossier.type = await this._dictionaryControllerService
|
||||
.getDictionaryForType(dossierTemplateId, 'dossier_redaction', dossierId)
|
||||
.toPromise();
|
||||
} catch (e) {
|
||||
dossier.type = null;
|
||||
}
|
||||
}
|
||||
|
||||
async activateFile(dossierId: string, fileId: string) {
|
||||
@ -306,14 +306,6 @@ export class AppStateService {
|
||||
this._updateLastActiveFileForDossier(dossierId, fileId);
|
||||
}
|
||||
|
||||
private async _updateLastActiveFileForDossier(dossierId: string, fileId: string) {
|
||||
this.activeDossier.files.forEach(f => {
|
||||
f.lastOpened = f.fileId === fileId;
|
||||
});
|
||||
|
||||
await this._userPreferenceService.saveLastOpenedFileForDossier(dossierId, fileId);
|
||||
}
|
||||
|
||||
activateDossierTemplate(dossierTemplateId: string) {
|
||||
this._appState.activeDossierTemplateId = dossierTemplateId;
|
||||
this._appState.activeDictionaryType = null;
|
||||
@ -660,6 +652,14 @@ export class AppStateService {
|
||||
this._dictionaryData = obj;
|
||||
}
|
||||
|
||||
private async _updateLastActiveFileForDossier(dossierId: string, fileId: string) {
|
||||
this.activeDossier.files.forEach(f => {
|
||||
f.lastOpened = f.fileId === fileId;
|
||||
});
|
||||
|
||||
await this._userPreferenceService.saveLastOpenedFileForDossier(dossierId, fileId);
|
||||
}
|
||||
|
||||
private _getExistingFiles(dossierId: string): FileStatusWrapper[] {
|
||||
const dossier = this.allDossiers.find(p => p.dossierId === dossierId);
|
||||
return dossier?.files ?? [];
|
||||
|
||||
@ -553,11 +553,6 @@
|
||||
"see-less": "See less",
|
||||
"title": "Dossier Details"
|
||||
},
|
||||
"dossier-dictionary-dialog": {
|
||||
"cancel": "cancel",
|
||||
"save-changes": "Save Changes",
|
||||
"title": "Dossier Dictionary"
|
||||
},
|
||||
"dossier-listing": {
|
||||
"add-new": "New Dossier",
|
||||
"delete": {
|
||||
@ -801,6 +796,12 @@
|
||||
}
|
||||
},
|
||||
"dictionary": {
|
||||
"display-name": {
|
||||
"cancel": "Cancel",
|
||||
"edit": "{type, select, edit{Edit} set{Set} other{}} Display Name",
|
||||
"placeholder": "Enter Display Name",
|
||||
"save": "Save Display Name"
|
||||
},
|
||||
"entries": "{length} {length, plural, one{entry} other{entries}}"
|
||||
},
|
||||
"general-info": {
|
||||
|
||||
@ -256,6 +256,10 @@ section.settings {
|
||||
margin-left: 14px;
|
||||
}
|
||||
|
||||
.ml-16 {
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.mr-24 {
|
||||
margin-right: 24px;
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 89376a65544fcdfcab1d960fba0d9f580cddc1ca
|
||||
Subproject commit 0bb0e4454f3015d1c81ccd23415c8135c89eeeff
|
||||
Loading…
x
Reference in New Issue
Block a user