dmp blueprint reference add multiple
This commit is contained in:
parent
7daafdae2e
commit
eb38e1d948
|
@ -12,6 +12,8 @@ public class ReferenceTypeFieldEntity extends FieldEntity {
|
||||||
@XmlAttribute(name="referenceTypeId")
|
@XmlAttribute(name="referenceTypeId")
|
||||||
private UUID referenceTypeId;
|
private UUID referenceTypeId;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "multipleSelect")
|
||||||
|
private Boolean multipleSelect;
|
||||||
public UUID getReferenceTypeId() {
|
public UUID getReferenceTypeId() {
|
||||||
return referenceTypeId;
|
return referenceTypeId;
|
||||||
}
|
}
|
||||||
|
@ -19,4 +21,12 @@ public class ReferenceTypeFieldEntity extends FieldEntity {
|
||||||
public void setReferenceTypeId(UUID referenceTypeId) {
|
public void setReferenceTypeId(UUID referenceTypeId) {
|
||||||
this.referenceTypeId = referenceTypeId;
|
this.referenceTypeId = referenceTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getMultipleSelect() {
|
||||||
|
return multipleSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultipleSelect(Boolean multipleSelect) {
|
||||||
|
this.multipleSelect = multipleSelect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ public class ReferenceTypeFieldImportExport {
|
||||||
@XmlAttribute(name = "required")
|
@XmlAttribute(name = "required")
|
||||||
private boolean required;
|
private boolean required;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "multipleSelect")
|
||||||
|
private Boolean multipleSelect;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -80,5 +83,11 @@ public class ReferenceTypeFieldImportExport {
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getMultipleSelect() {
|
||||||
|
return multipleSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultipleSelect(Boolean multipleSelect) {
|
||||||
|
this.multipleSelect = multipleSelect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.commonmodels.models.dmpblueprint.ReferenceTypeFieldModel;
|
||||||
import eu.eudat.commons.types.dmpblueprint.ReferenceTypeFieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.ReferenceTypeFieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.ReferenceTypeCommonModelBuilder;
|
||||||
|
import eu.eudat.model.dmpblueprintdefinition.ReferenceTypeField;
|
||||||
import eu.eudat.query.ReferenceTypeQuery;
|
import eu.eudat.query.ReferenceTypeQuery;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
@ -31,6 +32,7 @@ public class ReferenceTypeFieldCommonModelBuilder extends FieldCommonModelBuilde
|
||||||
|
|
||||||
protected ReferenceTypeFieldModel buildChild(ReferenceTypeFieldEntity data, ReferenceTypeFieldModel model) {
|
protected ReferenceTypeFieldModel buildChild(ReferenceTypeFieldEntity data, ReferenceTypeFieldModel model) {
|
||||||
if (data.getReferenceTypeId() != null ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
|
if (data.getReferenceTypeId() != null ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeCommonModelBuilder.class).build(this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
|
||||||
|
//model.setMultipleSelect(data.getMultipleSelect()); //TODO: add to common model
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class ReferenceFieldBuilder extends FieldBuilder<ReferenceTypeField, Refe
|
||||||
FieldSet referenceTypeFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeField._referenceType));
|
FieldSet referenceTypeFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeField._referenceType));
|
||||||
|
|
||||||
if (data.getReferenceTypeId() != null && !referenceTypeFields.isEmpty() ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeBuilder.class).build(referenceTypeFields, this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
|
if (data.getReferenceTypeId() != null && !referenceTypeFields.isEmpty() ) model.setReferenceType(this.builderFactory.builder(ReferenceTypeBuilder.class).build(referenceTypeFields, this.queryFactory.query(ReferenceTypeQuery.class).ids(data.getReferenceTypeId()).first())); //TODO: Optimize
|
||||||
|
if (fields.hasField(this.asIndexer(ReferenceTypeField._multipleSelect))) model.setMultipleSelect(data.getMultipleSelect());
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@ public class ReferenceTypeField extends Field {
|
||||||
public final static String _referenceType = "referenceType";
|
public final static String _referenceType = "referenceType";
|
||||||
private ReferenceType referenceType;
|
private ReferenceType referenceType;
|
||||||
|
|
||||||
|
public final static String _multipleSelect = "multipleSelect";
|
||||||
|
private Boolean multipleSelect;
|
||||||
|
|
||||||
public ReferenceType getReferenceType() {
|
public ReferenceType getReferenceType() {
|
||||||
return referenceType;
|
return referenceType;
|
||||||
}
|
}
|
||||||
|
@ -16,4 +19,12 @@ public class ReferenceTypeField extends Field {
|
||||||
public void setReferenceType(ReferenceType referenceType) {
|
public void setReferenceType(ReferenceType referenceType) {
|
||||||
this.referenceType = referenceType;
|
this.referenceType = referenceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getMultipleSelect() {
|
||||||
|
return multipleSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultipleSelect(Boolean multipleSelect) {
|
||||||
|
this.multipleSelect = multipleSelect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -18,6 +19,11 @@ public class ReferenceTypeFieldPersist extends FieldPersist {
|
||||||
|
|
||||||
public static final String _referenceTypeId = "referenceTypeId";
|
public static final String _referenceTypeId = "referenceTypeId";
|
||||||
|
|
||||||
|
private Boolean multipleSelect;
|
||||||
|
|
||||||
|
public static final String _multipleSelect = "multipleSelect";
|
||||||
|
|
||||||
|
|
||||||
public UUID getReferenceTypeId() {
|
public UUID getReferenceTypeId() {
|
||||||
return referenceTypeId;
|
return referenceTypeId;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +32,14 @@ public class ReferenceTypeFieldPersist extends FieldPersist {
|
||||||
this.referenceTypeId = referenceTypeId;
|
this.referenceTypeId = referenceTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getMultipleSelect() {
|
||||||
|
return multipleSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultipleSelect(Boolean multipleSelect) {
|
||||||
|
this.multipleSelect = multipleSelect;
|
||||||
|
}
|
||||||
|
|
||||||
@Component(ReferenceFieldPersistPersistValidator.ValidatorName)
|
@Component(ReferenceFieldPersistPersistValidator.ValidatorName)
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public static class ReferenceFieldPersistPersistValidator extends BaseFieldPersistValidator<ReferenceTypeFieldPersist> {
|
public static class ReferenceFieldPersistPersistValidator extends BaseFieldPersistValidator<ReferenceTypeFieldPersist> {
|
||||||
|
@ -44,10 +58,14 @@ public class ReferenceTypeFieldPersist extends FieldPersist {
|
||||||
@Override
|
@Override
|
||||||
protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
|
protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
|
||||||
List<Specification> specifications = getBaseSpecifications(item);
|
List<Specification> specifications = getBaseSpecifications(item);
|
||||||
specifications.add(
|
specifications.addAll(Arrays.asList(
|
||||||
this.spec()
|
this.spec()
|
||||||
.must(() -> !this.isNull(item.getReferenceTypeId()))
|
.must(() -> !this.isNull(item.getReferenceTypeId()))
|
||||||
.failOn(ReferenceTypeFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale()))
|
.failOn(ReferenceTypeFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale())),
|
||||||
|
this.spec()
|
||||||
|
.must(() -> !this.isNull(item.getMultipleSelect()))
|
||||||
|
.failOn(ReferenceTypeFieldPersist._multipleSelect).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeFieldPersist._multipleSelect}, LocaleContextHolder.getLocale())))
|
||||||
|
|
||||||
);
|
);
|
||||||
return specifications;
|
return specifications;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ public class DmpBlueprintValuePersist {
|
||||||
public static final String _fieldValue = "fieldValue";
|
public static final String _fieldValue = "fieldValue";
|
||||||
private List<ReferencePersist> references;
|
private List<ReferencePersist> references;
|
||||||
public static final String _references = "references";
|
public static final String _references = "references";
|
||||||
|
private ReferencePersist reference;
|
||||||
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
public UUID getFieldId() {
|
public UUID getFieldId() {
|
||||||
return fieldId;
|
return fieldId;
|
||||||
|
@ -58,6 +60,14 @@ public class DmpBlueprintValuePersist {
|
||||||
this.references = references;
|
this.references = references;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReferencePersist getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(ReferencePersist reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
@Component(DmpBlueprintValuePersistValidator.ValidatorName)
|
@Component(DmpBlueprintValuePersistValidator.ValidatorName)
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public static class DmpBlueprintValuePersistValidator extends BaseValidator<DmpBlueprintValuePersist> {
|
public static class DmpBlueprintValuePersistValidator extends BaseValidator<DmpBlueprintValuePersist> {
|
||||||
|
@ -97,16 +107,27 @@ public class DmpBlueprintValuePersist {
|
||||||
.must(() -> !this.isEmpty(item.getFieldValue()))
|
.must(() -> !this.isEmpty(item.getFieldValue()))
|
||||||
.failOn(DmpBlueprintValuePersist._fieldValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{fieldEntity.getLabel()}, LocaleContextHolder.getLocale())),
|
.failOn(DmpBlueprintValuePersist._fieldValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{fieldEntity.getLabel()}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && required)
|
.iff(() -> fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && ((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect() && required)
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getReferences()))
|
.must(() -> !this.isListNullOrEmpty(item.getReferences()))
|
||||||
// TODO: Cast Exception
|
// TODO: Cast Exception
|
||||||
// .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())),
|
// .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())),
|
||||||
.failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : DmpBlueprintValuePersist._references}, LocaleContextHolder.getLocale())),
|
.failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : DmpBlueprintValuePersist._references}, LocaleContextHolder.getLocale())),
|
||||||
|
this.spec()
|
||||||
|
.iff(() -> fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType) && this.isEmpty(item.getFieldValue()) && !((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect() && required)
|
||||||
|
.must(() -> !this.isNull(item.getReference()))
|
||||||
|
// TODO: Cast Exception
|
||||||
|
// .failOn(DmpBlueprintValuePersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : this.getReferenceTypeName(fieldEntity)}, LocaleContextHolder.getLocale())),
|
||||||
|
.failOn(DmpBlueprintValuePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{!this.isEmpty(fieldEntity.getLabel()) ? fieldEntity.getLabel() : DmpBlueprintValuePersist._reference}, LocaleContextHolder.getLocale())),
|
||||||
this.navSpec()
|
this.navSpec()
|
||||||
.iff(() -> !this.isListNullOrEmpty(item.getReferences()))
|
.iff(() -> !this.isListNullOrEmpty(item.getReferences()))
|
||||||
.on(DmpBlueprintValuePersist._references)
|
.on(DmpBlueprintValuePersist._references)
|
||||||
.over(item.getReferences())
|
.over(item.getReferences())
|
||||||
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class))
|
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class)),
|
||||||
|
this.refSpec()
|
||||||
|
.iff(() -> !this.isNull(item.getReference()))
|
||||||
|
.on(DmpBlueprintValuePersist._reference)
|
||||||
|
.over(item.getReferences())
|
||||||
|
.using(() -> this.validatorFactory.validator(ReferencePersist.ReferenceWithoutTypePersistValidator.class))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -750,6 +750,10 @@ public class DmpServiceImpl implements DmpService {
|
||||||
List<DmpReferencePersist> dmpReferencePersists = new ArrayList<>();
|
List<DmpReferencePersist> dmpReferencePersists = new ArrayList<>();
|
||||||
if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){
|
if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){
|
||||||
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) {
|
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) {
|
||||||
|
if (fieldValuePersist.getReference() != null) {
|
||||||
|
if (fieldValuePersist.getReferences() == null) fieldValuePersist.setReferences(new ArrayList<>());
|
||||||
|
fieldValuePersist.getReferences().add(fieldValuePersist.getReference());
|
||||||
|
}
|
||||||
if (this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) && !this.conventionService.isListNullOrEmpty( fieldValuePersist.getReferences())) {
|
if (this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) && !this.conventionService.isListNullOrEmpty( fieldValuePersist.getReferences())) {
|
||||||
for (ReferencePersist referencePersist : fieldValuePersist.getReferences()) {
|
for (ReferencePersist referencePersist : fieldValuePersist.getReferences()) {
|
||||||
DmpReferencePersist dmpReferencePersist = new DmpReferencePersist();
|
DmpReferencePersist dmpReferencePersist = new DmpReferencePersist();
|
||||||
|
|
|
@ -265,6 +265,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
case ReferenceType -> {
|
case ReferenceType -> {
|
||||||
ReferenceTypeFieldEntity dataTyped = new ReferenceTypeFieldEntity();
|
ReferenceTypeFieldEntity dataTyped = new ReferenceTypeFieldEntity();
|
||||||
dataTyped.setReferenceTypeId(((ReferenceTypeFieldPersist) persist).getReferenceTypeId());
|
dataTyped.setReferenceTypeId(((ReferenceTypeFieldPersist) persist).getReferenceTypeId());
|
||||||
|
dataTyped.setMultipleSelect(((ReferenceTypeFieldPersist) persist).getMultipleSelect());
|
||||||
data = dataTyped;
|
data = dataTyped;
|
||||||
}
|
}
|
||||||
default -> throw new InternalError("unknown type: " + persist.getCategory());
|
default -> throw new InternalError("unknown type: " + persist.getCategory());
|
||||||
|
@ -540,6 +541,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
xml.setDescription(entity.getDescription());
|
xml.setDescription(entity.getDescription());
|
||||||
xml.setOrdinal(entity.getOrdinal());
|
xml.setOrdinal(entity.getOrdinal());
|
||||||
xml.setRequired(entity.isRequired());
|
xml.setRequired(entity.isRequired());
|
||||||
|
xml.setMultipleSelect(entity.getMultipleSelect());
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,6 +672,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
persist.setDescription(importXml.getDescription());
|
persist.setDescription(importXml.getDescription());
|
||||||
persist.setOrdinal(importXml.getOrdinal());
|
persist.setOrdinal(importXml.getOrdinal());
|
||||||
persist.setRequired(importXml.isRequired());
|
persist.setRequired(importXml.isRequired());
|
||||||
|
persist.setMultipleSelect(importXml.getMultipleSelect());
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ export interface ExtraFieldInSection extends FieldInSection {
|
||||||
|
|
||||||
export interface ReferenceTypeFieldInSection extends FieldInSection {
|
export interface ReferenceTypeFieldInSection extends FieldInSection {
|
||||||
referenceType: ReferenceType;
|
referenceType: ReferenceType;
|
||||||
|
multipleSelect: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -120,4 +121,5 @@ export interface ExtraFieldInSectionPersist extends FieldInSectionPersist {
|
||||||
|
|
||||||
export interface ReferenceTypeFieldInSectionPersist extends FieldInSectionPersist {
|
export interface ReferenceTypeFieldInSectionPersist extends FieldInSectionPersist {
|
||||||
referenceTypeId: Guid;
|
referenceTypeId: Guid;
|
||||||
|
multipleSelect: boolean;
|
||||||
}
|
}
|
|
@ -95,6 +95,7 @@ export interface DmpBlueprintValuePersist {
|
||||||
fieldId: Guid;
|
fieldId: Guid;
|
||||||
fieldValue: string;
|
fieldValue: string;
|
||||||
references: DmpReferencePersist[];
|
references: DmpReferencePersist[];
|
||||||
|
reference: DmpReferencePersist;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DmpContactPersist {
|
export interface DmpContactPersist {
|
||||||
|
|
|
@ -178,6 +178,12 @@
|
||||||
<mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-auto section-field" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.ReferenceType">
|
||||||
|
<mat-checkbox [disabled]="formGroup.disabled" [checked]="field.get('multipleSelect').value" (change)="field.get('multipleSelect').setValue($event.checked)"><span>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-MULTIPLE-SELECT' | translate}}</span></mat-checkbox>
|
||||||
|
<mat-error *ngIf="field.get('multipleSelect')?.hasError('backendError')">{{field.get('multipleSelect')?.getError('backendError').message}}</mat-error>
|
||||||
|
<mat-error *ngIf="field.get('multipleSelect')?.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-xl-auto">
|
<div class="col-12 col-xl-auto">
|
||||||
|
|
|
@ -71,6 +71,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
||||||
const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel);
|
const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel);
|
||||||
field.id = Guid.create();
|
field.id = Guid.create();
|
||||||
field.ordinal = index + 1;
|
field.ordinal = index + 1;
|
||||||
|
field.multipleSelect = false;
|
||||||
return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' });
|
return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +309,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
public dataType: DmpBlueprintExtraFieldDataType;
|
public dataType: DmpBlueprintExtraFieldDataType;
|
||||||
public systemFieldType: DmpBlueprintSystemFieldType;
|
public systemFieldType: DmpBlueprintSystemFieldType;
|
||||||
public referenceTypeId: Guid;
|
public referenceTypeId: Guid;
|
||||||
|
public multipleSelect: boolean;
|
||||||
|
|
||||||
static get alwaysRequiredSystemFieldTypes(): DmpBlueprintSystemFieldType[] {
|
static get alwaysRequiredSystemFieldTypes(): DmpBlueprintSystemFieldType[] {
|
||||||
return [DmpBlueprintSystemFieldType.Title, DmpBlueprintSystemFieldType.Description, DmpBlueprintSystemFieldType.Language, DmpBlueprintSystemFieldType.AccessRights];
|
return [DmpBlueprintSystemFieldType.Title, DmpBlueprintSystemFieldType.Description, DmpBlueprintSystemFieldType.Language, DmpBlueprintSystemFieldType.AccessRights];
|
||||||
|
@ -338,6 +340,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
this.dataType = (item as ExtraFieldInSection).dataType;
|
this.dataType = (item as ExtraFieldInSection).dataType;
|
||||||
} else if (this.category == DmpBlueprintFieldCategory.ReferenceType) {
|
} else if (this.category == DmpBlueprintFieldCategory.ReferenceType) {
|
||||||
this.referenceTypeId = (item as ReferenceTypeFieldInSection).referenceType?.id;
|
this.referenceTypeId = (item as ReferenceTypeFieldInSection).referenceType?.id;
|
||||||
|
this.multipleSelect= (item as ReferenceTypeFieldInSection).multipleSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -369,6 +372,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators],
|
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators],
|
||||||
systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators],
|
systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators],
|
||||||
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
||||||
|
multipleSelect: [{ value: this.multipleSelect, disabled: disabled }, context.getValidation('multipleSelect').validators],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +398,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
||||||
baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] });
|
baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] });
|
||||||
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
|
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
|
||||||
|
baseValidationArray.push({ key: 'multipleSelect', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}multipleSelect`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -411,7 +416,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
validationErrorModel
|
validationErrorModel
|
||||||
});
|
});
|
||||||
|
|
||||||
['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'label', 'placeholder', 'description', 'semantics', 'required', 'ordinal'].forEach(keyField => {
|
['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'multipleSelect', 'label', 'placeholder', 'description', 'semantics', 'required', 'ordinal'].forEach(keyField => {
|
||||||
const control = formGroup?.get(keyField);
|
const control = formGroup?.get(keyField);
|
||||||
control?.clearValidators();
|
control?.clearValidators();
|
||||||
if (keyField == 'label') {
|
if (keyField == 'label') {
|
||||||
|
@ -419,7 +424,10 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
} else if (keyField == 'referenceTypeId') {
|
} else if (keyField == 'referenceTypeId') {
|
||||||
if (formGroup.get('category').value === DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
|
if (formGroup.get('category').value === DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
|
||||||
else control?.addValidators([...context.getValidation('referenceTypeId').validators]);
|
else control?.addValidators([...context.getValidation('referenceTypeId').validators]);
|
||||||
} else if (keyField == 'systemFieldType') {
|
} else if (keyField == 'multipleSelect') {
|
||||||
|
if (formGroup.get('category').value === DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('multipleSelect').validators]);
|
||||||
|
else control?.addValidators([...context.getValidation('multipleSelect').validators]);
|
||||||
|
}else if (keyField == 'systemFieldType') {
|
||||||
if (formGroup.get('category').value === DmpBlueprintFieldCategory.System) control?.addValidators([Validators.required, ...context.getValidation('systemFieldType').validators]);
|
if (formGroup.get('category').value === DmpBlueprintFieldCategory.System) control?.addValidators([Validators.required, ...context.getValidation('systemFieldType').validators]);
|
||||||
else control?.addValidators([...context.getValidation('systemFieldType').validators]);
|
else control?.addValidators([...context.getValidation('systemFieldType').validators]);
|
||||||
} else if (keyField == 'dataType') {
|
} else if (keyField == 'dataType') {
|
||||||
|
|
|
@ -42,6 +42,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.id)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.id)].join('.'),
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.name)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.name)].join('.'),
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.code)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.code)].join('.'),
|
||||||
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.multipleSelect)].join('.'),
|
||||||
|
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
|
|
|
@ -249,9 +249,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.ReferenceType">
|
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.ReferenceType">
|
||||||
<div>
|
<ng-container *ngIf="field.multipleSelect">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [dependencies]="formGroup.get('properties').get('dmpBlueprintValues')" [label]= "field.label" [placeholder]="field.placeholder ?? field.label" [referenceType]="field.referenceType"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [dependencies]="formGroup.get('properties').get('dmpBlueprintValues')" [label]= "field.label" [placeholder]="field.placeholder ?? field.label" [referenceType]="field.referenceType" [multiple]="true"></app-reference-field-component>
|
||||||
</div>
|
</ng-container>
|
||||||
|
<ng-container *ngIf="!(field.multipleSelect)">
|
||||||
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('reference')" [dependencies]="formGroup.get('properties').get('dmpBlueprintValues')" [label]= "field.label" [placeholder]="field.placeholder ?? field.label" [referenceType]="field.referenceType" [multiple]="false"></app-reference-field-component>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.Extra">
|
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.Extra">
|
||||||
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.Text">
|
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.Text">
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { DmpStatus } from "@app/core/common/enum/dmp-status";
|
||||||
import { DmpUserRole } from "@app/core/common/enum/dmp-user-role";
|
import { DmpUserRole } from "@app/core/common/enum/dmp-user-role";
|
||||||
import { DmpUserType } from "@app/core/common/enum/dmp-user-type";
|
import { DmpUserType } from "@app/core/common/enum/dmp-user-type";
|
||||||
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
||||||
import { DmpBlueprint, FieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
import { DmpBlueprint, FieldInSection, ReferenceTypeFieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
||||||
import { Dmp, DmpBlueprintValue, DmpBlueprintValuePersist, DmpContact, DmpContactPersist, DmpDescriptionTemplate, DmpDescriptionTemplatePersist, DmpPersist, DmpProperties, DmpPropertiesPersist, DmpReferenceDataPersist, DmpReferencePersist, DmpUser, DmpUserPersist } from "@app/core/model/dmp/dmp";
|
import { Dmp, DmpBlueprintValue, DmpBlueprintValuePersist, DmpContact, DmpContactPersist, DmpDescriptionTemplate, DmpDescriptionTemplatePersist, DmpPersist, DmpProperties, DmpPropertiesPersist, DmpReferenceDataPersist, DmpReferencePersist, DmpUser, DmpUserPersist } from "@app/core/model/dmp/dmp";
|
||||||
import { DmpReference } from "@app/core/model/dmp/dmp-reference";
|
import { DmpReference } from "@app/core/model/dmp/dmp-reference";
|
||||||
import { ReferencePersist } from "@app/core/model/reference/reference";
|
import { ReferencePersist } from "@app/core/model/reference/reference";
|
||||||
|
@ -291,7 +291,8 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
||||||
formGroup: control as UntypedFormGroup,
|
formGroup: control as UntypedFormGroup,
|
||||||
rootPath: `${rootPath}dmpBlueprintValues[${key}].`,
|
rootPath: `${rootPath}dmpBlueprintValues[${key}].`,
|
||||||
validationErrorModel: validationErrorModel,
|
validationErrorModel: validationErrorModel,
|
||||||
isRequired: params.blueprint.definition.sections.flatMap(x => x.fields).find(x => x.id.toString() == key).required
|
isRequired: params.blueprint.definition.sections.flatMap(x => x.fields).find(x => x.id.toString() == key).required,
|
||||||
|
multipleSelect: (params.blueprint.definition.sections.flatMap(x => x.fields).find(x => x.id.toString() == key) as ReferenceTypeFieldInSection).multipleSelect
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -309,7 +310,9 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
fieldId: Guid;
|
fieldId: Guid;
|
||||||
fieldValue: string;
|
fieldValue: string;
|
||||||
references: DmpReferencePersist[] = [];
|
references: DmpReferencePersist[] = [];
|
||||||
|
reference: DmpReferencePersist;
|
||||||
isRequired: boolean = false;
|
isRequired: boolean = false;
|
||||||
|
multipleSelect: boolean = false;
|
||||||
category: DmpBlueprintFieldCategory;
|
category: DmpBlueprintFieldCategory;
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
@ -321,7 +324,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[], field: FieldInSection): DmpBlueprintValueEditorModel {
|
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[], field: FieldInSection): DmpBlueprintValueEditorModel {
|
||||||
this.fieldId = item.fieldId;
|
this.fieldId = item.fieldId;
|
||||||
this.fieldValue = item.fieldValue;
|
this.fieldValue = item.fieldValue;
|
||||||
this.references = dmpReferences?.filter(x => x.data.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
|
const references = dmpReferences?.filter(x => x.data.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
|
||||||
return {
|
return {
|
||||||
data: x.data,
|
data: x.data,
|
||||||
reference: {
|
reference: {
|
||||||
|
@ -337,7 +340,18 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if ((field as ReferenceTypeFieldInSection).multipleSelect) {
|
||||||
|
this.references = references;
|
||||||
|
this.multipleSelect = true;
|
||||||
|
} else {
|
||||||
|
if (references?.length == 1) this.reference = references[0];
|
||||||
|
if (references?.length > 1) {
|
||||||
|
console.error("multiple references on single reference field: " + references);
|
||||||
|
this.reference = references[0];
|
||||||
|
}
|
||||||
|
this.multipleSelect = false;
|
||||||
|
|
||||||
|
}
|
||||||
this.isRequired = field.required;
|
this.isRequired = field.required;
|
||||||
if (this.isRequired) console.log(field);
|
if (this.isRequired) console.log(field);
|
||||||
this.category = field.category;
|
this.category = field.category;
|
||||||
|
@ -355,7 +369,8 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
context = DmpBlueprintValueEditorModel.createValidationContext({
|
context = DmpBlueprintValueEditorModel.createValidationContext({
|
||||||
validationErrorModel: this.validationErrorModel,
|
validationErrorModel: this.validationErrorModel,
|
||||||
rootPath,
|
rootPath,
|
||||||
isRequired: this.isRequired
|
isRequired: this.isRequired,
|
||||||
|
multipleSelect: this.multipleSelect
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +380,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
switch (this.category) {
|
switch (this.category) {
|
||||||
case DmpBlueprintFieldCategory.ReferenceType:
|
case DmpBlueprintFieldCategory.ReferenceType:
|
||||||
formGroup.addControl('references', new FormControl({ value: this.references?.map(x => x.reference), disabled: disabled }, context.getValidation('references').validators));
|
formGroup.addControl('references', new FormControl({ value: this.references?.map(x => x.reference), disabled: disabled }, context.getValidation('references').validators));
|
||||||
|
formGroup.addControl('reference', new FormControl({ value: this.reference?.reference, disabled: disabled }, context.getValidation('reference').validators));
|
||||||
break;
|
break;
|
||||||
case DmpBlueprintFieldCategory.System:
|
case DmpBlueprintFieldCategory.System:
|
||||||
case DmpBlueprintFieldCategory.Extra:
|
case DmpBlueprintFieldCategory.Extra:
|
||||||
|
@ -378,6 +394,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
static createValidationContext(params: {
|
static createValidationContext(params: {
|
||||||
rootPath?: string,
|
rootPath?: string,
|
||||||
validationErrorModel: ValidationErrorModel,
|
validationErrorModel: ValidationErrorModel,
|
||||||
|
multipleSelect: boolean,
|
||||||
isRequired: boolean,
|
isRequired: boolean,
|
||||||
}): ValidationContext {
|
}): ValidationContext {
|
||||||
const { rootPath = '', validationErrorModel } = params;
|
const { rootPath = '', validationErrorModel } = params;
|
||||||
|
@ -386,7 +403,8 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'fieldId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldId`)] });
|
baseValidationArray.push({ key: 'fieldId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldId`)] });
|
||||||
baseValidationArray.push({ key: 'fieldValue', validators: params.isRequired ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fieldValue`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}fieldValue`)] });
|
baseValidationArray.push({ key: 'fieldValue', validators: params.isRequired ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fieldValue`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}fieldValue`)] });
|
||||||
baseValidationArray.push({ key: 'references', validators: params.isRequired ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}references`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}references`)] });
|
baseValidationArray.push({ key: 'references', validators: params.isRequired && params.multipleSelect ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}references`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}references`)] });
|
||||||
|
baseValidationArray.push({ key: 'reference', validators: params.isRequired && !params.multipleSelect ? [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}reference`)] : [BackendErrorValidator(validationErrorModel, `${rootPath}reference`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -397,13 +415,15 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
validationErrorModel: ValidationErrorModel,
|
validationErrorModel: ValidationErrorModel,
|
||||||
rootPath: string,
|
rootPath: string,
|
||||||
isRequired: boolean
|
isRequired: boolean
|
||||||
|
multipleSelect: boolean
|
||||||
}): void {
|
}): void {
|
||||||
|
|
||||||
const { formGroup, rootPath, validationErrorModel } = params;
|
const { formGroup, rootPath, validationErrorModel } = params;
|
||||||
const context = DmpBlueprintValueEditorModel.createValidationContext({
|
const context = DmpBlueprintValueEditorModel.createValidationContext({
|
||||||
rootPath,
|
rootPath,
|
||||||
validationErrorModel,
|
validationErrorModel,
|
||||||
isRequired: params.isRequired
|
isRequired: params.isRequired,
|
||||||
|
multipleSelect: params.multipleSelect
|
||||||
});
|
});
|
||||||
|
|
||||||
['fieldId', 'fieldValue', 'references'].forEach(keyField => {
|
['fieldId', 'fieldValue', 'references'].forEach(keyField => {
|
||||||
|
|
|
@ -121,6 +121,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
|
||||||
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.id)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.id)].join('.'),
|
||||||
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.name)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.name)].join('.'),
|
||||||
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.code)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.code)].join('.'),
|
||||||
|
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.multipleSelect)].join('.'),
|
||||||
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x=> x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x=> x.referenceTypeDependencies) , nameof<ReferenceType>(x => x.id)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<ReferenceTypeFieldInSection>(x => x.referenceType), nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x=> x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x=> x.referenceTypeDependencies) , nameof<ReferenceType>(x => x.id)].join('.'),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||||
import { Guid } from '@common/types/guid';
|
import { Guid } from '@common/types/guid';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
import { FormService } from '@common/forms/form-service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reference-field-component',
|
selector: 'app-reference-field-component',
|
||||||
|
@ -42,6 +43,7 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit, On
|
||||||
constructor(
|
constructor(
|
||||||
private referenceService: ReferenceService,
|
private referenceService: ReferenceService,
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
|
public formService: FormService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
) { super(); }
|
) { super(); }
|
||||||
|
|
||||||
|
@ -75,7 +77,9 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit, On
|
||||||
const referenceToUse : Reference[]= [];
|
const referenceToUse : Reference[]= [];
|
||||||
Object.keys(this.dependencies.controls).forEach(controlName => {
|
Object.keys(this.dependencies.controls).forEach(controlName => {
|
||||||
// (this.dependencies.get(controlName).get('references').value as Reference[]).filter(x=> sourcesWithDependencies.some(y => y.referenceTypeDependencies) x.type.id == this.referenceType.id &&)
|
// (this.dependencies.get(controlName).get('references').value as Reference[]).filter(x=> sourcesWithDependencies.some(y => y.referenceTypeDependencies) x.type.id == this.referenceType.id &&)
|
||||||
const foudReferences: any[] = this.dependencies.get(controlName).get('references')?.value;
|
const ctrlValue = this.formService.getValue(this.dependencies.get(controlName).value);
|
||||||
|
const foudReferences: any[] = ctrlValue?.references || [];
|
||||||
|
if (ctrlValue?.reference) foudReferences.push(ctrlValue?.reference);
|
||||||
if (foudReferences != null) {
|
if (foudReferences != null) {
|
||||||
for (let i = 0; i < foudReferences.length; i++) {
|
for (let i = 0; i < foudReferences.length; i++) {
|
||||||
const foudReference = foudReferences[i];
|
const foudReference = foudReferences[i];
|
||||||
|
@ -106,7 +110,7 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit, On
|
||||||
if (!isInitial && (!referenceToUse.map(x => x.reference).every(x => this.referenceToUse.map(y => y.reference).includes(x)) ||
|
if (!isInitial && (!referenceToUse.map(x => x.reference).every(x => this.referenceToUse.map(y => y.reference).includes(x)) ||
|
||||||
!this.referenceToUse.map(x => x.reference).every(x => referenceToUse.map(y => y.reference).includes(x)))) {
|
!this.referenceToUse.map(x => x.reference).every(x => referenceToUse.map(y => y.reference).includes(x)))) {
|
||||||
this.referenceToUse = referenceToUse;
|
this.referenceToUse = referenceToUse;
|
||||||
this.form.setValue([]);
|
this.form.setValue(this.multiple ? [] : null);
|
||||||
this.form.updateValueAndValidity();
|
this.form.updateValueAndValidity();
|
||||||
} else {
|
} else {
|
||||||
this.referenceToUse = referenceToUse;
|
this.referenceToUse = referenceToUse;
|
||||||
|
@ -145,10 +149,14 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit, On
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(newResult => {
|
.subscribe(newResult => {
|
||||||
if (!newResult) { return; }
|
if (!newResult) { return; }
|
||||||
|
if (this.multiple) {
|
||||||
let results = this.form.value as ReferencePersist[];
|
let results = this.form.value as ReferencePersist[];
|
||||||
if (results == undefined) results = [];
|
if (results == undefined) results = [];
|
||||||
results.push(newResult);
|
results.push(newResult);
|
||||||
this.form.setValue(results);
|
this.form.setValue(results);
|
||||||
|
} else {
|
||||||
|
this.form.setValue(newResult);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Type",
|
"TYPE": "Type",
|
||||||
"DATATYPE": "Data Type",
|
"DATATYPE": "Data Type",
|
||||||
"REQUIRED": "Pflichtfeld",
|
"REQUIRED": "Pflichtfeld",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Autocomplete Data",
|
"TITLE": "Autocomplete Data",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete",
|
"MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete",
|
||||||
|
|
|
@ -1355,6 +1355,7 @@
|
||||||
"DATA-TYPE": "Data Type",
|
"DATA-TYPE": "Data Type",
|
||||||
"CATEGORY": "Field Type",
|
"CATEGORY": "Field Type",
|
||||||
"FIELD-REQUIRED": "Required",
|
"FIELD-REQUIRED": "Required",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"SEMANTICS": "Semantics",
|
"SEMANTICS": "Semantics",
|
||||||
"DESCRIPTION-TEMPLATES": "Description Templates",
|
"DESCRIPTION-TEMPLATES": "Description Templates",
|
||||||
"DESCRIPTION-TEMPLATE": "Description Template",
|
"DESCRIPTION-TEMPLATE": "Description Template",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Tipo",
|
"TYPE": "Tipo",
|
||||||
"DATATYPE": "Tipo de datos",
|
"DATATYPE": "Tipo de datos",
|
||||||
"REQUIRED": "Obligatorio",
|
"REQUIRED": "Obligatorio",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Datos autocompletados",
|
"TITLE": "Datos autocompletados",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete",
|
"MULTIPLE-AUTOCOMPLETE": "Multiple Autocomplete",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Τύπος",
|
"TYPE": "Τύπος",
|
||||||
"DATATYPE": "Τύπος Δεδομένων",
|
"DATATYPE": "Τύπος Δεδομένων",
|
||||||
"REQUIRED": "Υποχρεωτικά",
|
"REQUIRED": "Υποχρεωτικά",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Πολλαπλό",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Αυτόματη Συμπλήρωση Δεδομένων",
|
"TITLE": "Αυτόματη Συμπλήρωση Δεδομένων",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Πολλαπλή Αυτόματη Συμπλήρωση",
|
"MULTIPLE-AUTOCOMPLETE": "Πολλαπλή Αυτόματη Συμπλήρωση",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Vrsta",
|
"TYPE": "Vrsta",
|
||||||
"DATATYPE": "Tip podataka",
|
"DATATYPE": "Tip podataka",
|
||||||
"REQUIRED": "Obavezno",
|
"REQUIRED": "Obavezno",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Automatski unos podataka",
|
"TITLE": "Automatski unos podataka",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Višestruki automatski unos",
|
"MULTIPLE-AUTOCOMPLETE": "Višestruki automatski unos",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Typ",
|
"TYPE": "Typ",
|
||||||
"DATATYPE": "Typ danych",
|
"DATATYPE": "Typ danych",
|
||||||
"REQUIRED": "Wymagane",
|
"REQUIRED": "Wymagane",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Autouzupełnanie danych",
|
"TITLE": "Autouzupełnanie danych",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Wielokrotne autouzupełnianie",
|
"MULTIPLE-AUTOCOMPLETE": "Wielokrotne autouzupełnianie",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Tipo",
|
"TYPE": "Tipo",
|
||||||
"DATATYPE": "Tipo de Dados",
|
"DATATYPE": "Tipo de Dados",
|
||||||
"REQUIRED": "Obrigatório",
|
"REQUIRED": "Obrigatório",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Autocompletar Dados",
|
"TITLE": "Autocompletar Dados",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Autopreenchimento Múltiplo",
|
"MULTIPLE-AUTOCOMPLETE": "Autopreenchimento Múltiplo",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Typ",
|
"TYPE": "Typ",
|
||||||
"DATATYPE": "Typ dát",
|
"DATATYPE": "Typ dát",
|
||||||
"REQUIRED": "Povinné",
|
"REQUIRED": "Povinné",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Automatické dopĺňanie údajov",
|
"TITLE": "Automatické dopĺňanie údajov",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Viacnásobné automatické dokončenie",
|
"MULTIPLE-AUTOCOMPLETE": "Viacnásobné automatické dokončenie",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Tip",
|
"TYPE": "Tip",
|
||||||
"DATATYPE": "Tip podataka",
|
"DATATYPE": "Tip podataka",
|
||||||
"REQUIRED": "Obavezno",
|
"REQUIRED": "Obavezno",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Automatski unos podataka",
|
"TITLE": "Automatski unos podataka",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Višestruki automatski unos",
|
"MULTIPLE-AUTOCOMPLETE": "Višestruki automatski unos",
|
||||||
|
|
|
@ -1020,6 +1020,7 @@
|
||||||
"TYPE": "Tip",
|
"TYPE": "Tip",
|
||||||
"DATATYPE": "Veri Tipi",
|
"DATATYPE": "Veri Tipi",
|
||||||
"REQUIRED": "Gerekli",
|
"REQUIRED": "Gerekli",
|
||||||
|
"FIELD-MULTIPLE-SELECT": "Multiple",
|
||||||
"EXTERNAL-AUTOCOMPLETE": {
|
"EXTERNAL-AUTOCOMPLETE": {
|
||||||
"TITLE": "Verileri Otomatik Tamamla",
|
"TITLE": "Verileri Otomatik Tamamla",
|
||||||
"MULTIPLE-AUTOCOMPLETE": "Çoklu Otomatik Tamamlama",
|
"MULTIPLE-AUTOCOMPLETE": "Çoklu Otomatik Tamamlama",
|
||||||
|
|
|
@ -183,12 +183,30 @@ public class DmpBlueprintXmlMigrationService {
|
||||||
case ACCESS_RIGHTS -> dataTyped.setType(DmpBlueprintSystemFieldType.AccessRights);
|
case ACCESS_RIGHTS -> dataTyped.setType(DmpBlueprintSystemFieldType.AccessRights);
|
||||||
case CONTACT -> dataTyped.setType(DmpBlueprintSystemFieldType.Contact);
|
case CONTACT -> dataTyped.setType(DmpBlueprintSystemFieldType.Contact);
|
||||||
case LANGUAGE -> dataTyped.setType(DmpBlueprintSystemFieldType.Language);
|
case LANGUAGE -> dataTyped.setType(DmpBlueprintSystemFieldType.Language);
|
||||||
case FUNDER -> referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Funder);
|
case FUNDER -> {
|
||||||
case GRANT -> referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Grants);
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Funder);
|
||||||
case LICENSE -> referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.License);
|
referenceTypeFieldEntity.setMultipleSelect(false);
|
||||||
case ORGANIZATIONS -> referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Organizations);
|
}
|
||||||
case PROJECT -> referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Project);
|
case GRANT -> {
|
||||||
case RESEARCHERS -> referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Researcher);
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Grants);
|
||||||
|
referenceTypeFieldEntity.setMultipleSelect(false);
|
||||||
|
}
|
||||||
|
case LICENSE -> {
|
||||||
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.License);
|
||||||
|
referenceTypeFieldEntity.setMultipleSelect(true);
|
||||||
|
}
|
||||||
|
case ORGANIZATIONS -> {
|
||||||
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Organizations);
|
||||||
|
referenceTypeFieldEntity.setMultipleSelect(true);
|
||||||
|
}
|
||||||
|
case PROJECT -> {
|
||||||
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Project);
|
||||||
|
referenceTypeFieldEntity.setMultipleSelect(false);
|
||||||
|
}
|
||||||
|
case RESEARCHERS -> {
|
||||||
|
referenceTypeFieldEntity.setReferenceTypeId(ReferenceTypeIds.Researcher);
|
||||||
|
referenceTypeFieldEntity.setMultipleSelect(true);
|
||||||
|
}
|
||||||
default -> throw new MyApplicationException("Type not found " + systemField.getType());
|
default -> throw new MyApplicationException("Type not found " + systemField.getType());
|
||||||
}
|
}
|
||||||
if (systemField.getType().equals(SystemFieldType.TEXT) || systemField.getType().equals(SystemFieldType.HTML_TEXT) ||
|
if (systemField.getType().equals(SystemFieldType.TEXT) || systemField.getType().equals(SystemFieldType.HTML_TEXT) ||
|
||||||
|
|
Loading…
Reference in New Issue