RED-6453 - Value for attribute in file list cannot be set
This commit is contained in:
parent
c7a93d1a61
commit
f3cd880dac
@ -4,7 +4,7 @@
|
||||
<span class="clamp-3"> {{ fileAttributeValue ? (fileAttributeValue | date : 'd MMM yyyy') : '-' }}</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-container *ngIf="(fileAttributesService.isEditingFileAttribute$ | async) === false || isInEditMode">
|
||||
<ng-container *ngIf="((fileAttributesService.isEditingFileAttribute$ | async) === false || isInEditMode) && !file.isProcessing">
|
||||
<div *ngIf="!isInEditMode; else input" class="edit-button">
|
||||
<iqser-circle-button
|
||||
(action)="editFileAttribute()"
|
||||
|
||||
@ -16,7 +16,7 @@ import { filter, map, tap } from 'rxjs/operators';
|
||||
templateUrl: './file-attribute.component.html',
|
||||
styleUrls: ['./file-attribute.component.scss'],
|
||||
})
|
||||
export class FileAttributeComponent extends BaseFormComponent implements OnInit, OnDestroy {
|
||||
export class FileAttributeComponent extends BaseFormComponent implements OnDestroy {
|
||||
@Input() fileAttribute!: IFileAttributeConfig;
|
||||
@Input() file!: File;
|
||||
@Input() dossier!: Dossier;
|
||||
@ -53,23 +53,10 @@ export class FileAttributeComponent extends BaseFormComponent implements OnInit,
|
||||
return this.file.fileAttributes.attributeIdToValue[this.fileAttribute.id];
|
||||
}
|
||||
|
||||
get #noFileAttributes(): boolean {
|
||||
return JSON.stringify(this.file.fileAttributes.attributeIdToValue) === '{}';
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.#subscriptions.unsubscribe();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.#noFileAttributes) {
|
||||
this.#initFileAttributes();
|
||||
}
|
||||
|
||||
this.form = this.#getForm();
|
||||
this.initialFormValue = this.form.getRawValue();
|
||||
}
|
||||
|
||||
async editFileAttribute(): Promise<void> {
|
||||
this.#toggleEdit();
|
||||
}
|
||||
@ -111,7 +98,11 @@ export class FileAttributeComponent extends BaseFormComponent implements OnInit,
|
||||
|
||||
#initFileAttributes() {
|
||||
const configs = this.fileAttributesService.getFileAttributeConfig(this.file.dossierTemplateId).fileAttributeConfigs;
|
||||
configs.forEach(config => (this.file.fileAttributes.attributeIdToValue[config.id] = null));
|
||||
configs.forEach(config => {
|
||||
if (!this.file.fileAttributes.attributeIdToValue[config.id]) {
|
||||
this.file.fileAttributes.attributeIdToValue[config.id] = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#getForm(): UntypedFormGroup {
|
||||
@ -129,6 +120,12 @@ export class FileAttributeComponent extends BaseFormComponent implements OnInit,
|
||||
}
|
||||
|
||||
#toggleEdit(): void {
|
||||
if (!this.isInEditMode) {
|
||||
this.#initFileAttributes();
|
||||
this.form = this.#getForm();
|
||||
this.initialFormValue = this.form.getRawValue();
|
||||
}
|
||||
|
||||
this.isInEditMode = !this.isInEditMode;
|
||||
this.fileAttributesService.isEditingFileAttribute$.next(this.isInEditMode);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user