table view fixes

This commit is contained in:
Efstratios Giannopoulos 2024-04-30 17:53:00 +03:00
parent e5af155b31
commit a3c92bb087
11 changed files with 90 additions and 80 deletions

View File

@ -73,7 +73,6 @@ public final class Permission {
//Dmp
public static String BrowseDmp = "BrowseDmp";
public static String EditDmp = "EditDmp";
public static String ReviewDmp = "ReviewDmp";
public static String NewDmp = "NewDmp";
public static String DepositDmp = "DepositDmp";
public static String DeleteDmp = "DeleteDmp";

View File

@ -10,9 +10,8 @@ export enum DescriptionTemplateFieldType {
RICH_TEXT_AREA = "richTextarea",
UPLOAD = "upload",
DATE_PICKER = "datePicker",
EXTERNAL_DATASETS = "externalDatasets",
REFERENCE_TYPES = "referenceTypes",
TAGS = "tags",
REFERENCE_TYPES = "referenceTypes",
DATASET_IDENTIFIER = "datasetIdentifier",
VALIDATION = "validation"
}
}

View File

@ -99,6 +99,7 @@ export interface DescriptionFieldPersist {
textListValue: string[];
dateValue: Date;
references: ReferencePersist[];
reference: ReferencePersist;
externalIdentifier?: DescriptionExternalIdentifierPersist;
}

View File

@ -2,6 +2,9 @@ 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 { DescriptionFieldPersist } from "../model/description/description";
import { Observable, of } from "rxjs";
@Pipe({
name: 'fieldValue'
@ -11,54 +14,62 @@ export class FieldValuePipe implements PipeTransform {
constructor(private date: DatePipe) {
}
transform(controlValue: any): string | null {
let value = controlValue?.value;
let renderStyle = controlValue?.viewStyle?.renderStyle;
if (renderStyle && value) {
switch (renderStyle) {
transform(controlValue: DescriptionFieldPersist, field: DescriptionTemplateField): Observable<string> {
if (field?.data?.fieldType && controlValue) {
switch (field.data.fieldType) {
case DescriptionTemplateFieldType.BOOLEAN_DECISION:
return value == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO';
return of(controlValue.textValue == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO');
case DescriptionTemplateFieldType.CHECK_BOX:
return value ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO';
case DescriptionTemplateFieldType.RADIO_BOX:
if (value && controlValue.data.options) {
return controlValue.data.options.find(option => option.value === value).label;
return of(controlValue.textValue == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO');
case DescriptionTemplateFieldType.RADIO_BOX: {
const data = <DescriptionTemplateRadioBoxData>field.data;
if (data?.options) {
return of(data.options?.find(option => option.value === controlValue.textValue)?.label);
}
break;
}
case DescriptionTemplateFieldType.DATE_PICKER:
return this.date.transform(controlValue.value, 'dd/MM/yyyy');
return of(this.date.transform(controlValue.dateValue, 'dd/MM/yyyy'));
case DescriptionTemplateFieldType.FREE_TEXT:
return value;
case DescriptionTemplateFieldType.SELECT:
if (value && controlValue.data.options && !controlValue.data.multipleSelect) {
return controlValue.data.options.find(option => value == option.value).label;
} else if (value && controlValue.data.options && controlValue.data.multipleSelect) {
return controlValue.data.options.filter(option => value.includes(option.value)).map(option => option.label).join(',');
return of(controlValue.textValue);
case DescriptionTemplateFieldType.SELECT: {
const data = <DescriptionTemplateSelectData>field.data;
if (data?.options && !data?.multipleSelect) {
return of(data.options?.find(option => controlValue.textValue == option.value)?.label);
} else if (data?.options && data?.multipleSelect) {
return of(data?.options?.filter(option => controlValue.textListValue.includes(option.value)).map(option => option.label).join(','));
}
break;
}
case DescriptionTemplateFieldType.RICH_TEXT_AREA:
if (value) {
return value.replace(/&nbsp;/g, ' ').replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ").replace(/<[^>]*>/g, '');
if (controlValue.textValue) {
return of(controlValue.textValue.replace(/&nbsp;/g, ' ').replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ").replace(/<[^>]*>/g, ''));
}
break;
case DescriptionTemplateFieldType.TEXT_AREA:
return value;
case DescriptionTemplateFieldType.REFERENCE_TYPES:
return (value as Reference)?.label;
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
case DescriptionTemplateFieldType.TAGS:
return this.parseJson(value);
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS:
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:
return this.parseJson(value, 'label');
return of(controlValue.textValue);
case DescriptionTemplateFieldType.REFERENCE_TYPES: {
const data = <DescriptionTemplateReferenceTypeData>field.data;
if (!data?.multipleSelect && controlValue.reference) {
return of(controlValue.reference?.label);
} else if (data?.multipleSelect && controlValue.references) {
return of(controlValue.references.map(option => option.label).join(','));
}
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.DATASET_IDENTIFIER:
case DescriptionTemplateFieldType.VALIDATION:
if (value && value.identifier) {
return value.identifier;
if (controlValue.externalIdentifier?.identifier) {
return of(controlValue.externalIdentifier?.identifier);
}
break;
default:
return null;
return of(null);
}
}
return null;

View File

@ -154,7 +154,7 @@ export class EnumUtils {
case DescriptionTemplateFieldType.RICH_TEXT_AREA: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.RICH-TEXT-AREA');
case DescriptionTemplateFieldType.UPLOAD: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.UPLOAD');
case DescriptionTemplateFieldType.DATE_PICKER: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.DATE-PICKER');
case DescriptionTemplateFieldType.EXTERNAL_DATASETS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.EXTERNAL-DATASETS');
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.EXTERNAL-DATASETS');
case DescriptionTemplateFieldType.TAGS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.TAGS');
case DescriptionTemplateFieldType.REFERENCE_TYPES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.REFERENCE-TYPES');
case DescriptionTemplateFieldType.DATASET_IDENTIFIER: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.DATASET-IDENTIFIER');

View File

@ -562,15 +562,15 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
field.data = data;
break;
}
case DescriptionTemplateFieldType.EXTERNAL_DATASETS: {
const data: DescriptionTemplateExternalDatasetData = {
label: '',
multipleSelect: false,
fieldType: type
}
field.data = data;
break;
}
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS: {
// const data: DescriptionTemplateExternalDatasetData = {
// label: '',
// multipleSelect: false,
// fieldType: type
// }
// field.data = data;
// break;
// }
case DescriptionTemplateFieldType.UPLOAD: {
const data: DescriptionTemplateUploadData = {
label: '',

View File

@ -170,15 +170,15 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
field.data = data;
break;
}
case DescriptionTemplateFieldType.EXTERNAL_DATASETS: {
const data: DescriptionTemplateExternalDatasetData = {
label: '',
multipleSelect: false,
fieldType: type
}
field.data = data;
break;
}
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS: {
// const data: DescriptionTemplateExternalDatasetData = {
// label: '',
// multipleSelect: false,
// fieldType: type
// }
// field.data = data;
// break;
// }
case DescriptionTemplateFieldType.UPLOAD: {
const data: DescriptionTemplateUploadData = {
label: '',

View File

@ -802,8 +802,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DMPS:
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:
return new DescriptionTemplateLabelAndMultiplicityDataEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
return new DescriptionTemplateExternalDatasetDataEditorModel(this.validationErrorModel);
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
// return new DescriptionTemplateExternalDatasetDataEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.UPLOAD:
return new DescriptionTemplateUploadDataEditorModel(this.validationErrorModel);
}
@ -862,12 +862,12 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF
rootPath: `${rootPath}data.`,
validationErrorModel: validationErrorModel
});
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
DescriptionTemplateExternalDatasetDataEditorModel.reapplyValidators({
formGroup: formGroup?.get('data') as UntypedFormGroup,
rootPath: `${rootPath}data.`,
validationErrorModel: validationErrorModel
});
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
// DescriptionTemplateExternalDatasetDataEditorModel.reapplyValidators({
// formGroup: formGroup?.get('data') as UntypedFormGroup,
// rootPath: `${rootPath}data.`,
// validationErrorModel: validationErrorModel
// });
break;
}

View File

@ -723,9 +723,9 @@ export class DescriptionFieldIndicator {
case DescriptionTemplateFieldType.DATE_PICKER:
this.type = "dateValue";
break;
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
this.type = "";
break;
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
// this.type = "";
// break;
case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:
if (multipleSelect) this.type = "textListValue";
else this.type = "textValue"

View File

@ -52,7 +52,7 @@
<tr *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[fieldSet.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value] ?? true">
<td *ngFor="let field of fieldSet.fields;" class="text-wrap">
<ng-container *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[field.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value] ?? true">
{{fieldSetItemPropertiesControl.get('fields').get(field.id).get('value').getRawValue()}}
{{ fieldSetItemPropertiesControl.get('fields')?.get(field.id)?.getRawValue() | fieldValue: field | async }}
</ng-container>
</td>
<td class="actions">

View File

@ -130,17 +130,17 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required);
switch (this.field?.data?.fieldType) {
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
//TODO: refactor
// this.multipleReferenceAutoCompleteConfiguration = {
// filterFn: this.filterOrganisations.bind(this),
// initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
// displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } },
// titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } },
// subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } },
// valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }
// };
break;
// case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
// //TODO: refactor
// // this.multipleReferenceAutoCompleteConfiguration = {
// // filterFn: this.filterOrganisations.bind(this),
// // initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
// // displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } },
// // titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } },
// // subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } },
// // valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }
// // };
// break;
case DescriptionTemplateFieldType.TAGS:
this.tagsAutoCompleteConfiguration = {
filterFn: this.filterTags.bind(this),
@ -295,7 +295,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
this.onCallbackUploadFail(error.error);
})
}
private createFileNameDisplay(name: string, extension: string){
@ -325,7 +325,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
} else {
let fileToUpload = this.filesToUpload[0];
const data = this.field.data as DescriptionTemplateUploadData;
if (data && data.types
if (data && data.types
&& data.types.map(type => type.value).includes(fileToUpload.type)
&& data.maxFileSizeInMB
&& data.maxFileSizeInMB * 1048576 >= fileToUpload.size) {
@ -375,6 +375,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
FileSaver.saveAs(blob, filename);
});
}
}
}