fix table view
This commit is contained in:
parent
5c4292d735
commit
fc9a4134e7
|
@ -1,17 +1,27 @@
|
|||
import { DatePipe } from "@angular/common";
|
||||
import { Pipe, PipeTransform } from "@angular/core";
|
||||
import { DescriptionTemplateFieldType } from "../common/enum/description-template-field-type";
|
||||
import { Reference } from "../model/reference/reference";
|
||||
import { DescriptionTemplateField, DescriptionTemplateRadioBoxData, DescriptionTemplateReferenceTypeData, DescriptionTemplateSelectData } from "../model/description-template/description-template";
|
||||
import { DescriptionTemplateField, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateRadioBoxData, DescriptionTemplateReferenceTypeData, DescriptionTemplateSelectData } from "../model/description-template/description-template";
|
||||
import { DescriptionFieldPersist } from "../model/description/description";
|
||||
import { Observable, of } from "rxjs";
|
||||
import { Observable, map, of } from "rxjs";
|
||||
import { TagService } from "../services/tag/tag.service";
|
||||
import { Guid } from "@common/types/guid";
|
||||
import { DmpService } from "../services/dmp/dmp.service";
|
||||
import { DescriptionService } from "../services/description/description.service";
|
||||
import { StorageFileService } from "../services/storage-file/storage-file.service";
|
||||
import { nameof } from "ts-simple-nameof";
|
||||
import { StorageFile } from "../model/storage-file/storage-file";
|
||||
|
||||
@Pipe({
|
||||
name: 'fieldValue'
|
||||
})
|
||||
export class FieldValuePipe implements PipeTransform {
|
||||
|
||||
constructor(private date: DatePipe) {
|
||||
constructor(private date: DatePipe,
|
||||
private tagService: TagService,
|
||||
private dmpService: DmpService,
|
||||
private storageFileService: StorageFileService,
|
||||
private descriptionService: DescriptionService) {
|
||||
}
|
||||
|
||||
transform(controlValue: DescriptionFieldPersist, field: DescriptionTemplateField): Observable<string> {
|
||||
|
@ -57,11 +67,37 @@ export class FieldValuePipe implements PipeTransform {
|
|||
}
|
||||
break;
|
||||
}
|
||||
// case DescriptionTemplateFieldType.TAGS:
|
||||
// return this.parseJson(value);
|
||||
// case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS:
|
||||
// case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:
|
||||
// return this.parseJson(value, 'label');
|
||||
case DescriptionTemplateFieldType.TAGS: {
|
||||
if (controlValue.textListValue && controlValue.textListValue.length > 0) {
|
||||
return this.tagService.query(this.tagService.buildAutocompleteLookup(null, null, controlValue.textListValue.map(x => Guid.parse(x)))).pipe(map(x => x.items?.map(y=> y.label).join(',')));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS: {
|
||||
const data = <DescriptionTemplateLabelAndMultiplicityData>field.data;
|
||||
if (!data?.multipleSelect && controlValue.textValue && controlValue.textValue.length > 0) {
|
||||
return this.dmpService.query(this.dmpService.buildAutocompleteLookup(null, null, [Guid.parse(controlValue.textValue)])).pipe(map(x => x.items?.map(y=> y.label).join(',')));
|
||||
} else if (data?.multipleSelect && controlValue.references && controlValue.textListValue && controlValue.textListValue.length > 0) {
|
||||
return this.dmpService.query(this.dmpService.buildAutocompleteLookup(null, null, controlValue.textListValue.map(x => Guid.parse(x)))).pipe(map(x => x.items?.map(y=> y.label).join(',')));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:
|
||||
const data = <DescriptionTemplateLabelAndMultiplicityData>field.data;
|
||||
if (!data?.multipleSelect && controlValue.textValue && controlValue.textValue.length > 0) {
|
||||
return this.descriptionService.query(this.descriptionService.buildAutocompleteLookup(null, null, [Guid.parse(controlValue.textValue)])).pipe(map(x => x.items?.map(y=> y.label).join(',')));
|
||||
} else if (data?.multipleSelect && controlValue.references && controlValue.textListValue && controlValue.textListValue.length > 0) {
|
||||
return this.descriptionService.query(this.descriptionService.buildAutocompleteLookup(null, null, controlValue.textListValue.map(x => Guid.parse(x)))).pipe(map(x => x.items?.map(y=> y.label).join(',')));
|
||||
}
|
||||
break;
|
||||
case DescriptionTemplateFieldType.UPLOAD: {
|
||||
if (controlValue.textValue && controlValue.textValue.length > 0) {
|
||||
return this.storageFileService.getSingle(Guid.parse(controlValue.textValue), [
|
||||
nameof<StorageFile>(x => x.name)
|
||||
]).pipe(map(x => x.name));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DescriptionTemplateFieldType.DATASET_IDENTIFIER:
|
||||
case DescriptionTemplateFieldType.VALIDATION:
|
||||
if (controlValue.externalIdentifier?.identifier) {
|
||||
|
@ -72,7 +108,7 @@ export class FieldValuePipe implements PipeTransform {
|
|||
return of(null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return of(null);
|
||||
}
|
||||
|
||||
public parseJson(value: any, field: string = 'name') {
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
<mat-error *ngIf="form.get('data').get('type').hasError('backendError')">{{form.get('data').get('type').getError('backendError').message}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue