RED-6122: Don't autocomplete current date if not set for file attribute, send proper date string when doing inline edits.
This commit is contained in:
parent
ea89fc871d
commit
cc8481f080
@ -4,9 +4,11 @@ import { BaseFormComponent, Toaster } from '@iqser/common-ui';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
|
||||
import { BehaviorSubject, firstValueFrom, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
||||
import { FilesService } from '@services/files/files.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-file-attribute [fileAttribute] [file] [dossier]',
|
||||
templateUrl: './file-attribute.component.html',
|
||||
@ -74,10 +76,17 @@ export class FileAttributeComponent extends BaseFormComponent implements OnInit
|
||||
}
|
||||
|
||||
async save($event?: MouseEvent): Promise<void> {
|
||||
$event.stopPropagation();
|
||||
$event?.stopPropagation();
|
||||
|
||||
try {
|
||||
const attributeIdToValue = this.form.getRawValue();
|
||||
const rawFormValue = this.form.getRawValue();
|
||||
const fileAttributeValue = rawFormValue[this.fileAttribute.id];
|
||||
const attributeIdToValue = {
|
||||
...rawFormValue,
|
||||
[this.fileAttribute.id]: this.isDate
|
||||
? fileAttributeValue && dayjs(fileAttributeValue).format('YYYY-MM-DD')
|
||||
: fileAttributeValue,
|
||||
};
|
||||
await firstValueFrom(
|
||||
this._fileAttributesService.setFileAttributes({ attributeIdToValue }, this.file.dossierId, this.file.fileId),
|
||||
);
|
||||
|
||||
@ -53,7 +53,7 @@ export class DocumentInfoDialogComponent extends BaseDialogComponent implements
|
||||
const attrValue = this.file.fileAttributes?.attributeIdToValue[attr.id];
|
||||
return {
|
||||
...acc,
|
||||
[attr.id]: [this._isDate(attr.id) ? dayjs(attrValue).toDate() : attrValue],
|
||||
[attr.id]: [this._isDate(attr.id) ? attrValue && dayjs(attrValue).toDate() : attrValue],
|
||||
};
|
||||
}, {}),
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user