From 80096e9164974d531fe038b713cfadeb90609298 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Fri, 9 Feb 2024 13:24:23 +0200 Subject: [PATCH 1/2] Refactoring public api dependencies from 'to be deleted' data and queryable modules --- .../dao/criteria/DatasetPublicCriteria.java | 69 ------------------- .../dataset/DatasetPublicTableRequest.java | 58 ---------------- .../eu/eudat/types/grant/GrantStateType.java | 29 -------- .../controllers/publicapi}/QueryableList.java | 7 +- .../publicapi}/collector/Collector.java | 5 +- .../publicapi}/collector/ProjectionField.java | 3 +- .../publicapi}/criteria/Criteria.java | 2 +- .../dataset/DatasetPublicCriteria.java | 2 +- .../dmp/DataManagementPlanPublicCriteria.java | 2 +- .../exceptions/NotSingleResultException.java | 2 +- .../QueryableHibernateList.java | 14 ++-- .../jpa/predicates/EntitySelectPredicate.java | 3 +- .../jpa/predicates/GroupByPredicate.java | 2 +- .../NestedQuerySinglePredicate.java | 2 +- .../jpa/predicates/OrderByPredicate.java | 2 +- .../jpa/predicates/QueryablePredicate.java | 2 +- .../jpa/predicates/SelectPredicate.java | 2 +- .../jpa/predicates/SinglePredicate.java | 2 +- .../publicapi}/query/PaginationService.java | 10 +-- .../query/definition/Collector.java | 4 +- .../query/definition/CriteriaQuery.java | 6 +- .../publicapi}/query/definition/Query.java | 6 +- .../query/definition/TableCriteriaQuery.java | 6 +- .../query/definition/TableQuery.java | 10 +-- .../definition/helpers/ColumnOrderings.java | 2 +- .../query/definition/helpers/Ordering.java | 2 +- .../definition/helpers/SelectionFields.java | 2 +- .../dataset/DatasetPublicTableRequest.java | 8 +-- .../DataManagmentPlanPublicTableRequest.java | 10 +-- .../publicapi}/types/FieldSelectionType.java | 2 +- .../publicapi}/types/SelectionField.java | 2 +- 31 files changed, 60 insertions(+), 218 deletions(-) delete mode 100644 dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java delete mode 100644 dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java delete mode 100644 dmp-backend/data/src/main/java/eu/eudat/types/grant/GrantStateType.java rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/QueryableList.java (94%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/collector/Collector.java (93%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/collector/ProjectionField.java (98%) rename dmp-backend/{data/src/main/java/eu/eudat/data/dao => web/src/main/java/eu/eudat/controllers/publicapi}/criteria/Criteria.java (88%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/exceptions/NotSingleResultException.java (88%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/hibernatequeryablelist/QueryableHibernateList.java (98%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/EntitySelectPredicate.java (73%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/GroupByPredicate.java (82%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/NestedQuerySinglePredicate.java (85%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/OrderByPredicate.java (81%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/QueryablePredicate.java (61%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/SelectPredicate.java (57%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/jpa/predicates/SinglePredicate.java (86%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/PaginationService.java (89%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/Collector.java (64%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/CriteriaQuery.java (50%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/Query.java (91%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/TableCriteriaQuery.java (54%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/TableQuery.java (81%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/helpers/ColumnOrderings.java (96%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/helpers/Ordering.java (94%) rename dmp-backend/{data/src/main/java/eu/eudat/data => web/src/main/java/eu/eudat/controllers/publicapi}/query/definition/helpers/SelectionFields.java (84%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/types/FieldSelectionType.java (72%) rename dmp-backend/{queryable/src/main/java/eu/eudat/queryable => web/src/main/java/eu/eudat/controllers/publicapi}/types/SelectionField.java (93%) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java deleted file mode 100644 index 10b5bd3c9..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java +++ /dev/null @@ -1,69 +0,0 @@ -package eu.eudat.data.dao.criteria; - -import eu.eudat.data.DescriptionEntity; -import eu.eudat.types.grant.GrantStateType; - -import java.util.List; -import java.util.UUID; - -/** - * Created by ikalyvas on 10/2/2018. - */ -public class DatasetPublicCriteria extends Criteria{ - private GrantStateType grantStatus; - private List grants; - private List datasetProfile; - private List dmpOrganisations; -// private List tags; TODO: - private List dmpIds; - private Integer role; - - public GrantStateType getGrantStatus() { - return grantStatus; - } - public void setGrantStatus(GrantStateType grantStatus) { - this.grantStatus = grantStatus; - } - - public List getGrants() { - return grants; - } - public void setGrants(List grants) { - this.grants = grants; - } - - public List getDatasetProfile() { - return datasetProfile; - } - public void setDatasetProfile(List datasetProfile) { - this.datasetProfile = datasetProfile; - } - - public List getDmpOrganisations() { - return dmpOrganisations; - } - public void setDmpOrganisations(List dmpOrganisations) { - this.dmpOrganisations = dmpOrganisations; - } - -// public List getTags() { -// return tags; -// } -// public void setTags(List tags) { -// this.tags = tags; -// } - - public List getDmpIds() { - return dmpIds; - } - public void setDmpIds(List dmpIds) { - this.dmpIds = dmpIds; - } - - public Integer getRole() { - return role; - } - public void setRole(Integer role) { - this.role = role; - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java deleted file mode 100644 index 879abf9a7..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java +++ /dev/null @@ -1,58 +0,0 @@ -package eu.eudat.data.query.items.table.dataset; - -import eu.eudat.commons.enums.DescriptionStatus; -import eu.eudat.commons.enums.IsActive; -import eu.eudat.data.dao.criteria.DatasetPublicCriteria; -import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.queryable.QueryableList; -import eu.eudat.queryable.types.FieldSelectionType; -import eu.eudat.queryable.types.SelectionField; -import eu.eudat.types.grant.GrantStateType; - -import java.util.Arrays; -import java.util.Date; -import java.util.UUID; - -/** - * Created by ikalyvas on 10/2/2018. - */ -public class DatasetPublicTableRequest extends TableQuery { - @Override - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); - query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true)); - query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized.getValue())); - query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), - query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), - Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class))); - if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) - query.where((builder, root) -> builder.or( - builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), - builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%"))); - if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty()) - query.where(((builder, root) -> root.get("dmp").get("grant").get("id").in(this.getCriteria().getGrants()))); - if (this.getCriteria().getGrantStatus() != null) { - if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue())) - query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date())); - if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue())) - query.where((builder, root) -> - builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date()) - , builder.isNull(root.get("dmp").get("grant").get("enddate")))); - } - if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty()) { - query.where(((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds()))); - } - if (this.getCriteria().getDatasetProfile() != null && !this.getCriteria().getDatasetProfile().isEmpty()) query - .where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().getDatasetProfile()))); - if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query - .where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations()))); - query.where((builder, root) -> builder.notEqual(root.get(DescriptionEntity._isActive), IsActive.Inactive)); - return query; - } - - @Override - public QueryableList applyPaging(QueryableList items) { - return null; - } -} diff --git a/dmp-backend/data/src/main/java/eu/eudat/types/grant/GrantStateType.java b/dmp-backend/data/src/main/java/eu/eudat/types/grant/GrantStateType.java deleted file mode 100644 index 3522d1a90..000000000 --- a/dmp-backend/data/src/main/java/eu/eudat/types/grant/GrantStateType.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.eudat.types.grant; - -/** - * Created by ikalyvas on 8/24/2018. - */ -public enum GrantStateType { - ONGOING(0), FINISHED(1); - - private Integer value; - - private GrantStateType(Integer value) { - this.value = value; - } - - public Integer getValue() { - return value; - } - - public static GrantStateType fromInteger(Integer value) { - switch (value) { - case 0: - return ONGOING; - case 1: - return FINISHED; - default: - throw new RuntimeException("Unsupported Grant State Type"); - } - } -} diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/QueryableList.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/QueryableList.java similarity index 94% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/QueryableList.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/QueryableList.java index 628c574b2..39af79f64 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/QueryableList.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/QueryableList.java @@ -1,8 +1,7 @@ -package eu.eudat.queryable; - -import eu.eudat.queryable.jpa.predicates.*; -import eu.eudat.queryable.types.SelectionField; +package eu.eudat.controllers.publicapi; +import eu.eudat.controllers.publicapi.jpa.predicates.*; +import eu.eudat.controllers.publicapi.types.SelectionField; import jakarta.persistence.criteria.Join; import jakarta.persistence.criteria.JoinType; import jakarta.persistence.criteria.Subquery; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/collector/Collector.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/collector/Collector.java similarity index 93% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/collector/Collector.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/collector/Collector.java index e3b654418..9a30d9731 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/collector/Collector.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/collector/Collector.java @@ -1,8 +1,7 @@ -package eu.eudat.queryable.collector; - -import com.fasterxml.jackson.databind.ObjectMapper; +package eu.eudat.controllers.publicapi.collector; import jakarta.persistence.Tuple; + import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/collector/ProjectionField.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/collector/ProjectionField.java similarity index 98% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/collector/ProjectionField.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/collector/ProjectionField.java index 31e5bd1fd..4baaa22b8 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/collector/ProjectionField.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/collector/ProjectionField.java @@ -1,6 +1,7 @@ -package eu.eudat.queryable.collector; +package eu.eudat.controllers.publicapi.collector; import jakarta.persistence.Tuple; + import java.util.*; import java.util.stream.Collectors; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/Criteria.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/Criteria.java similarity index 88% rename from dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/Criteria.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/Criteria.java index 42b693035..7debd0720 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/Criteria.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/Criteria.java @@ -1,4 +1,4 @@ -package eu.eudat.data.dao.criteria; +package eu.eudat.controllers.publicapi.criteria; import io.swagger.annotations.ApiModelProperty; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dataset/DatasetPublicCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dataset/DatasetPublicCriteria.java index 76e58a9ec..e98c333b0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dataset/DatasetPublicCriteria.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dataset/DatasetPublicCriteria.java @@ -1,6 +1,6 @@ package eu.eudat.controllers.publicapi.criteria.dataset; -import eu.eudat.data.dao.criteria.Criteria; +import eu.eudat.controllers.publicapi.criteria.Criteria; import eu.eudat.data.DescriptionEntity; import io.swagger.annotations.ApiModelProperty; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java index 0f9c27c7a..b64eeac31 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/criteria/dmp/DataManagementPlanPublicCriteria.java @@ -1,7 +1,7 @@ package eu.eudat.controllers.publicapi.criteria.dmp; +import eu.eudat.controllers.publicapi.criteria.Criteria; import eu.eudat.data.DmpEntity; -import eu.eudat.data.dao.criteria.Criteria; import io.swagger.annotations.ApiModelProperty; import java.util.Date; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/exceptions/NotSingleResultException.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/exceptions/NotSingleResultException.java similarity index 88% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/exceptions/NotSingleResultException.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/exceptions/NotSingleResultException.java index 2ed8bbbcf..0f84cbd9c 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/exceptions/NotSingleResultException.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/exceptions/NotSingleResultException.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.exceptions; +package eu.eudat.controllers.publicapi.exceptions; public class NotSingleResultException extends RuntimeException { diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/hibernatequeryablelist/QueryableHibernateList.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/hibernatequeryablelist/QueryableHibernateList.java similarity index 98% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/hibernatequeryablelist/QueryableHibernateList.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/hibernatequeryablelist/QueryableHibernateList.java index 176ffafed..720dd3570 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/hibernatequeryablelist/QueryableHibernateList.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/hibernatequeryablelist/QueryableHibernateList.java @@ -1,12 +1,12 @@ -package eu.eudat.queryable.jpa.hibernatequeryablelist; +package eu.eudat.controllers.publicapi.jpa.hibernatequeryablelist; import com.fasterxml.jackson.databind.ObjectMapper; -import eu.eudat.queryable.QueryableList; -import eu.eudat.queryable.collector.Collector; -import eu.eudat.queryable.exceptions.NotSingleResultException; -import eu.eudat.queryable.jpa.predicates.*; -import eu.eudat.queryable.types.FieldSelectionType; -import eu.eudat.queryable.types.SelectionField; +import eu.eudat.controllers.publicapi.QueryableList; +import eu.eudat.controllers.publicapi.collector.Collector; +import eu.eudat.controllers.publicapi.exceptions.NotSingleResultException; +import eu.eudat.controllers.publicapi.jpa.predicates.*; +import eu.eudat.controllers.publicapi.types.FieldSelectionType; +import eu.eudat.controllers.publicapi.types.SelectionField; import jakarta.persistence.EntityManager; import jakarta.persistence.Tuple; import jakarta.persistence.TypedQuery; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/EntitySelectPredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/EntitySelectPredicate.java similarity index 73% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/EntitySelectPredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/EntitySelectPredicate.java index 88ea75067..abd061352 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/EntitySelectPredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/EntitySelectPredicate.java @@ -1,8 +1,7 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; import jakarta.persistence.criteria.Path; import jakarta.persistence.criteria.Root; -import java.util.function.Predicate; /** * Created by ikalyvas on 10/10/2018. diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/GroupByPredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/GroupByPredicate.java similarity index 82% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/GroupByPredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/GroupByPredicate.java index 870a17a40..a56ed50ba 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/GroupByPredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/GroupByPredicate.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Expression; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/NestedQuerySinglePredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/NestedQuerySinglePredicate.java similarity index 85% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/NestedQuerySinglePredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/NestedQuerySinglePredicate.java index e2b8813c1..ef482da1b 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/NestedQuerySinglePredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/NestedQuerySinglePredicate.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/OrderByPredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/OrderByPredicate.java similarity index 81% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/OrderByPredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/OrderByPredicate.java index 8b236fdcf..a76cefc08 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/OrderByPredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/OrderByPredicate.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Order; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/QueryablePredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/QueryablePredicate.java similarity index 61% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/QueryablePredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/QueryablePredicate.java index 288f4d5d5..118b81c46 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/QueryablePredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/QueryablePredicate.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; /** * Created by ikalyvas on 2/7/2018. diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/SelectPredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/SelectPredicate.java similarity index 57% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/SelectPredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/SelectPredicate.java index 4b7b60980..238972d3d 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/SelectPredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/SelectPredicate.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; public interface SelectPredicate { R applySelection(T item); diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/SinglePredicate.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/SinglePredicate.java similarity index 86% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/SinglePredicate.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/SinglePredicate.java index fbbcb8dbc..fa666b00c 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/predicates/SinglePredicate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/jpa/predicates/SinglePredicate.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.jpa.predicates; +package eu.eudat.controllers.publicapi.jpa.predicates; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/PaginationService.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/PaginationService.java similarity index 89% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/PaginationService.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/PaginationService.java index 044a77dfa..3767aa3a7 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/PaginationService.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/PaginationService.java @@ -1,9 +1,9 @@ -package eu.eudat.data.query; +package eu.eudat.controllers.publicapi.query; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.data.query.definition.helpers.ColumnOrderings; -import eu.eudat.data.query.definition.helpers.Ordering; -import eu.eudat.queryable.QueryableList; +import eu.eudat.controllers.publicapi.QueryableList; +import eu.eudat.controllers.publicapi.query.definition.TableQuery; +import eu.eudat.controllers.publicapi.query.definition.helpers.ColumnOrderings; +import eu.eudat.controllers.publicapi.query.definition.helpers.Ordering; import java.util.Arrays; import java.util.Collection; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/Collector.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/Collector.java similarity index 64% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/Collector.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/Collector.java index bedd0c8c2..c47bea7e9 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/Collector.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/Collector.java @@ -1,6 +1,6 @@ -package eu.eudat.data.query.definition; +package eu.eudat.controllers.publicapi.query.definition; -import eu.eudat.queryable.QueryableList; +import eu.eudat.controllers.publicapi.QueryableList; /** * Created by ikalyvas on 3/21/2018. diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/CriteriaQuery.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/CriteriaQuery.java similarity index 50% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/CriteriaQuery.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/CriteriaQuery.java index 7fbcda3a9..193b7f3cc 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/CriteriaQuery.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/CriteriaQuery.java @@ -1,7 +1,7 @@ -package eu.eudat.data.query.definition; +package eu.eudat.controllers.publicapi.query.definition; -import eu.eudat.data.dao.criteria.Criteria; -import eu.eudat.queryable.QueryableList; +import eu.eudat.controllers.publicapi.QueryableList; +import eu.eudat.controllers.publicapi.criteria.Criteria; /** * Created by ikalyvas on 3/21/2018. diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/Query.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/Query.java similarity index 91% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/Query.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/Query.java index 3b9d8c423..52b9e68d9 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/Query.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/Query.java @@ -1,7 +1,7 @@ -package eu.eudat.data.query.definition; +package eu.eudat.controllers.publicapi.query.definition; -import eu.eudat.data.dao.criteria.Criteria; -import eu.eudat.queryable.QueryableList; +import eu.eudat.controllers.publicapi.QueryableList; +import eu.eudat.controllers.publicapi.criteria.Criteria; import io.swagger.annotations.ApiModelProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/TableCriteriaQuery.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/TableCriteriaQuery.java similarity index 54% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/TableCriteriaQuery.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/TableCriteriaQuery.java index 6ae6400c6..9a61ee975 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/TableCriteriaQuery.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/TableCriteriaQuery.java @@ -1,7 +1,7 @@ -package eu.eudat.data.query.definition; +package eu.eudat.controllers.publicapi.query.definition; -import eu.eudat.data.dao.criteria.Criteria; -import eu.eudat.queryable.QueryableList; +import eu.eudat.controllers.publicapi.QueryableList; +import eu.eudat.controllers.publicapi.criteria.Criteria; /** * Created by ikalyvas on 3/21/2018. diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/TableQuery.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/TableQuery.java similarity index 81% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/TableQuery.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/TableQuery.java index 9eb755d8a..888b3ba3f 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/TableQuery.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/TableQuery.java @@ -1,9 +1,9 @@ -package eu.eudat.data.query.definition; +package eu.eudat.controllers.publicapi.query.definition; -import eu.eudat.data.dao.criteria.Criteria; -import eu.eudat.data.query.definition.helpers.ColumnOrderings; -import eu.eudat.data.query.definition.helpers.SelectionFields; -import eu.eudat.queryable.QueryableList; +import eu.eudat.controllers.publicapi.QueryableList; +import eu.eudat.controllers.publicapi.criteria.Criteria; +import eu.eudat.controllers.publicapi.query.definition.helpers.ColumnOrderings; +import eu.eudat.controllers.publicapi.query.definition.helpers.SelectionFields; import io.swagger.annotations.ApiModelProperty; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/ColumnOrderings.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/ColumnOrderings.java similarity index 96% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/ColumnOrderings.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/ColumnOrderings.java index c5587a126..b94aabf47 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/ColumnOrderings.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/ColumnOrderings.java @@ -1,4 +1,4 @@ -package eu.eudat.data.query.definition.helpers; +package eu.eudat.controllers.publicapi.query.definition.helpers; import io.swagger.annotations.ApiModelProperty; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/Ordering.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/Ordering.java similarity index 94% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/Ordering.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/Ordering.java index 2054f2eb1..2d9a64579 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/Ordering.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/Ordering.java @@ -1,4 +1,4 @@ -package eu.eudat.data.query.definition.helpers; +package eu.eudat.controllers.publicapi.query.definition.helpers; public class Ordering { diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/SelectionFields.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/SelectionFields.java similarity index 84% rename from dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/SelectionFields.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/SelectionFields.java index ec41027ec..4445f4c4d 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/definition/helpers/SelectionFields.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/query/definition/helpers/SelectionFields.java @@ -1,4 +1,4 @@ -package eu.eudat.data.query.definition.helpers; +package eu.eudat.controllers.publicapi.query.definition.helpers; import io.swagger.annotations.ApiModelProperty; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dataset/DatasetPublicTableRequest.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dataset/DatasetPublicTableRequest.java index c11b12cf0..979b24fa3 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dataset/DatasetPublicTableRequest.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dataset/DatasetPublicTableRequest.java @@ -2,12 +2,12 @@ package eu.eudat.controllers.publicapi.request.dataset; import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.IsActive; +import eu.eudat.controllers.publicapi.QueryableList; import eu.eudat.controllers.publicapi.criteria.dataset.DatasetPublicCriteria; +import eu.eudat.controllers.publicapi.query.definition.TableQuery; +import eu.eudat.controllers.publicapi.types.FieldSelectionType; +import eu.eudat.controllers.publicapi.types.SelectionField; import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.queryable.QueryableList; -import eu.eudat.queryable.types.FieldSelectionType; -import eu.eudat.queryable.types.SelectionField; import java.util.Arrays; import java.util.Date; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java index c37848f2d..cd9c4e9f5 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/request/dmp/DataManagmentPlanPublicTableRequest.java @@ -1,13 +1,13 @@ package eu.eudat.controllers.publicapi.request.dmp; import eu.eudat.commons.enums.IsActive; +import eu.eudat.controllers.publicapi.QueryableList; import eu.eudat.controllers.publicapi.criteria.dmp.DataManagementPlanPublicCriteria; +import eu.eudat.controllers.publicapi.query.PaginationService; +import eu.eudat.controllers.publicapi.query.definition.TableQuery; +import eu.eudat.controllers.publicapi.types.FieldSelectionType; +import eu.eudat.controllers.publicapi.types.SelectionField; import eu.eudat.data.DmpEntity; -import eu.eudat.data.query.PaginationService; -import eu.eudat.data.query.definition.TableQuery; -import eu.eudat.queryable.QueryableList; -import eu.eudat.queryable.types.FieldSelectionType; -import eu.eudat.queryable.types.SelectionField; import jakarta.persistence.criteria.Predicate; import java.util.*; diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/types/FieldSelectionType.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/types/FieldSelectionType.java similarity index 72% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/types/FieldSelectionType.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/types/FieldSelectionType.java index cf4039d75..6b0d5b5cb 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/types/FieldSelectionType.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/types/FieldSelectionType.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.types; +package eu.eudat.controllers.publicapi.types; /** * Created by ikalyvas on 2/7/2018. diff --git a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/types/SelectionField.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/types/SelectionField.java similarity index 93% rename from dmp-backend/queryable/src/main/java/eu/eudat/queryable/types/SelectionField.java rename to dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/types/SelectionField.java index 7cef18e0d..3be5f8f06 100644 --- a/dmp-backend/queryable/src/main/java/eu/eudat/queryable/types/SelectionField.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/types/SelectionField.java @@ -1,4 +1,4 @@ -package eu.eudat.queryable.types; +package eu.eudat.controllers.publicapi.types; /** * Created by ikalyvas on 2/7/2018. From 9f5002802bc2b2713901ff300d523c9fc3d4feb6 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Fri, 9 Feb 2024 22:46:05 +0200 Subject: [PATCH 2/2] some frontend changes for reference type refactor --- .../controllers/v2/ReferenceController.java | 2 +- .../enum/description-template-field-type.ts | 28 +- .../enum/dmp-blueprint-field-category.ts | 5 + .../dmp-blueprint-section-field-category.ts | 4 - .../enum/dmp-blueprint-system-field-type.ts | 22 +- .../app/core/common/enum/reference-type.ts | 16 - .../description-template-persist.ts | 31 +- .../description-template.ts | 26 +- .../core/model/dmp-blueprint/dmp-blueprint.ts | 35 +- .../src/app/core/model/reference/reference.ts | 5 +- .../src/app/core/pipes/field-value.pipe.ts | 15 +- .../recent-activity-item-lookup.lookup.ts | 1 - .../app/core/query/reference-search.lookup.ts | 7 +- .../src/app/core/query/reference.lookup.ts | 5 +- .../reference-type/reference-type.service.ts | 8 + .../services/reference/reference.service.ts | 67 ++-- .../services/utilities/enum-utils.service.ts | 61 +--- .../description-template.module.ts | 4 +- ...late-editor-composite-field.component.html | 49 +-- ...mplate-editor-composite-field.component.ts | 30 +- ...-editor-external-select-field.component.ts | 1 - ...editor-reference-type-field.component.html | 23 ++ ...editor-reference-type-field.component.scss | 3 + ...e-editor-reference-type-field.component.ts | 20 ++ ...ption-template-editor-field.component.html | 74 +--- ...ription-template-editor-field.component.ts | 26 +- .../description-template-editor.component.ts | 16 +- .../description-template-editor.model.ts | 339 ++---------------- .../description-template-editor.resolver.ts | 17 +- .../dmp-blueprint-editor.component.html | 68 ++-- .../editor/dmp-blueprint-editor.component.ts | 143 +++----- .../editor/dmp-blueprint-editor.model.ts | 60 ++-- .../editor/dmp-blueprint-editor.resolver.ts | 10 +- .../editor/reference-editor.component.html | 37 +- .../editor/reference-editor.component.ts | 17 +- .../editor/reference-editor.model.ts | 18 +- .../editor/reference-editor.resolver.ts | 3 +- .../reference-listing-filters.component.html | 7 +- .../reference-listing-filters.component.ts | 17 +- .../listing/reference-listing.component.html | 2 +- .../listing/reference-listing.component.ts | 4 +- .../editor/description-editor.component.ts | 8 +- .../editor/description-editor.model.ts | 8 +- .../form-field/form-field.component.html | 205 +---------- .../form-field/form-field.component.ts | 279 +------------- .../description-listing-item.component.html | 2 +- .../description-listing-item.component.ts | 4 +- .../description-overview.component.html | 4 +- .../description-overview.component.ts | 10 +- .../dmp-editor.component.html | 39 +- .../dmp-editor.component.ts | 41 +-- .../dmp-editor-blueprint/dmp-editor.model.ts | 5 +- .../dmp-editor.resolver.ts | 12 +- .../dmp-listing-item.component.html | 2 +- .../dmp-listing-item.component.ts | 12 +- .../dmp/overview/dmp-overview.component.html | 4 +- .../ui/dmp/overview/dmp-overview.component.ts | 16 +- .../reference-field.component.html | 4 +- .../reference-field.component.ts | 7 +- dmp-frontend/src/assets/i18n/en.json | 28 +- .../formatting/common-formatting.module.ts | 12 +- .../formatting/pipes/reference-type.pipe.ts | 11 - 62 files changed, 542 insertions(+), 1497 deletions(-) create mode 100644 dmp-frontend/src/app/core/common/enum/dmp-blueprint-field-category.ts delete mode 100644 dmp-frontend/src/app/core/common/enum/dmp-blueprint-section-field-category.ts delete mode 100644 dmp-frontend/src/app/core/common/enum/reference-type.ts create mode 100644 dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.html create mode 100644 dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.scss create mode 100644 dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.ts delete mode 100644 dmp-frontend/src/common/formatting/pipes/reference-type.pipe.ts diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ReferenceController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ReferenceController.java index f9bde0744..0b3e45fd7 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ReferenceController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/ReferenceController.java @@ -95,7 +95,7 @@ public class ReferenceController { @PostMapping("search") - public List searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { + public List search(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { logger.debug("search with db definition {}", Reference.class.getSimpleName()); this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null); diff --git a/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts b/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts index 6bc550ca7..dca669bb4 100644 --- a/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts +++ b/dmp-frontend/src/app/core/common/enum/description-template-field-type.ts @@ -1,10 +1,7 @@ export enum DescriptionTemplateFieldType { - EXTERNAL_SELECT = "externalSelect", SELECT = "select", BOOLEAN_DECISION = "booleanDecision", RADIO_BOX = "radiobox", - INTERNAL_DMP_ENTRIES = "internalDmpEntities", //Delete - INTERNAL_DMP_ENTRIES_RESEARCHERS = "internalDmpResearchers", INTERNAL_DMP_ENTRIES_DMPS = "internalDmpDmps", INTERNAL_ENTRIES_DESCRIPTIONS = "internalDmpDescriptions", CHECK_BOX = "checkBox", @@ -14,18 +11,23 @@ export enum DescriptionTemplateFieldType { UPLOAD = "upload", DATE_PICKER = "datePicker", EXTERNAL_DATASETS = "externalDatasets", - DATA_REPOSITORIES = "dataRepositories", - JOURNAL_REPOSITORIES = "journalRepositories", - PUB_REPOSITORIES = "pubRepositories", - LICENSES = "licenses", - TAXONOMIES = "taxonomies", - PUBLICATIONS = "publications", - REGISTRIES = "registries", - SERVICES = "services", + REFERENCE_TYPES = "referenceTypes", TAGS = "tags", - RESEARCHERS = "researchers", - ORGANIZATIONS = "organizations", DATASET_IDENTIFIER = "datasetIdentifier", CURRENCY = "currency", VALIDATION = "validation" + + //EXTERNAL_SELECT = "externalSelect", + // INTERNAL_DMP_ENTRIES_RESEARCHERS = "internalDmpResearchers", + // DATA_REPOSITORIES = "dataRepositories", + // JOURNAL_REPOSITORIES = "journalRepositories", + // PUB_REPOSITORIES = "pubRepositories", + // LICENSES = "licenses", + // TAXONOMIES = "taxonomies", + // PUBLICATIONS = "publications", + // REGISTRIES = "registries", + // SERVICES = "services", + + // RESEARCHERS = "researchers", + // ORGANIZATIONS = "organizations", } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/dmp-blueprint-field-category.ts b/dmp-frontend/src/app/core/common/enum/dmp-blueprint-field-category.ts new file mode 100644 index 000000000..de6927973 --- /dev/null +++ b/dmp-frontend/src/app/core/common/enum/dmp-blueprint-field-category.ts @@ -0,0 +1,5 @@ +export enum DmpBlueprintFieldCategory { + System = 0, + Extra = 1, + ReferenceType = 2 +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/dmp-blueprint-section-field-category.ts b/dmp-frontend/src/app/core/common/enum/dmp-blueprint-section-field-category.ts deleted file mode 100644 index 3907fd2d6..000000000 --- a/dmp-frontend/src/app/core/common/enum/dmp-blueprint-section-field-category.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum DmpBlueprintSectionFieldCategory { - SYSTEM = 0, - EXTRA = 1 -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/dmp-blueprint-system-field-type.ts b/dmp-frontend/src/app/core/common/enum/dmp-blueprint-system-field-type.ts index 654df49d9..52d993bca 100644 --- a/dmp-frontend/src/app/core/common/enum/dmp-blueprint-system-field-type.ts +++ b/dmp-frontend/src/app/core/common/enum/dmp-blueprint-system-field-type.ts @@ -1,13 +1,13 @@ export enum DmpBlueprintSystemFieldType { - TEXT = 0, - HTML_TEXT = 1, - RESEARCHERS = 2, - ORGANIZATIONS = 3, - LANGUAGE = 4, - CONTACT = 5, - FUNDER = 6, - GRANT = 7, - PROJECT = 8, - LICENSE = 9, - ACCESS_RIGHTS = 10 + Title = 0, + Description = 1, + // RESEARCHERS = 2, + // ORGANIZATIONS = 3, + Language = 2, + Contact = 3, + // FUNDER = 6, + // GRANT = 7, + // PROJECT = 8, + // LICENSE = 9, + AccessRights = 4 } diff --git a/dmp-frontend/src/app/core/common/enum/reference-type.ts b/dmp-frontend/src/app/core/common/enum/reference-type.ts deleted file mode 100644 index 0c5c48d9b..000000000 --- a/dmp-frontend/src/app/core/common/enum/reference-type.ts +++ /dev/null @@ -1,16 +0,0 @@ -export enum ReferenceType { - Taxonomies = 0, - Licenses = 1, - Publications = 2, - Journals = 3, - PubRepositories = 4, - DataRepositories = 5, - Registries = 6, - Services = 7, - Project = 8, - Funder = 9, - Datasets = 10, - Organizations = 11, - Grants = 12, - Researcher = 13 -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts index 22b780f64..7f4950ea2 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts @@ -101,12 +101,12 @@ export interface DescriptionTemplateBaseFieldDataPersist { // Field Types // -export interface DescriptionTemplateExternalDatasetDataPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist { - type: DescriptionTemplateFieldDataExternalDatasetType; +export interface DescriptionTemplateReferenceTypeFieldPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist { + referenceTypeId: Guid; } -export interface DescriptionTemplateExternalSelectDataPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist { - sources: DescriptionTemplateExternalSelectSourcePersist[]; +export interface DescriptionTemplateExternalDatasetDataPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist { + type: DescriptionTemplateFieldDataExternalDatasetType; } export interface DescriptionTemplateLabelAndMultiplicityDataPersist extends DescriptionTemplateBaseFieldDataPersist { @@ -132,34 +132,11 @@ export interface DescriptionTemplateUploadDataPersist extends DescriptionTemplat // // Others // -export interface DescriptionTemplateExternalSelectSourcePersist { - url: string; - method: string; - optionsRoot: string; - sourceBinding: DescriptionTemplateExternalSelectSourceBindingPersist; - hasAuth: boolean; - auth: DescriptionTemplateExternalSelectAuthDataPersist -} - -export interface DescriptionTemplateExternalSelectAuthDataPersist { - url: string; - method: string; - body: string; - path: string; - type: string; -} - export interface DescriptionTemplateSelectOptionPersist { label: string; value: string; } -export interface DescriptionTemplateExternalSelectSourceBindingPersist { - label: string; - value: string; - source: string; -} - export interface DescriptionTemplateRadioBoxOptionPersist { label: string; value: string; diff --git a/dmp-frontend/src/app/core/model/description-template/description-template.ts b/dmp-frontend/src/app/core/model/description-template/description-template.ts index fc81139eb..dae11eead 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template.ts @@ -107,8 +107,8 @@ export interface DescriptionTemplateExternalDatasetData extends DescriptionTempl type?: DescriptionTemplateFieldDataExternalDatasetType; } -export interface DescriptionTemplateExternalSelectData extends DescriptionTemplateLabelAndMultiplicityData { - sources: DescriptionTemplateExternalSelectSource[]; +export interface DescriptionTemplateReferenceTypeData extends DescriptionTemplateLabelAndMultiplicityData { + referenceTypeId?: Guid; } export interface DescriptionTemplateRadioBoxData extends DescriptionTemplateBaseFieldData { @@ -128,28 +128,6 @@ export interface DescriptionTemplateUploadData extends DescriptionTemplateBaseFi // // Others // -export interface DescriptionTemplateExternalSelectSource { - url: string; - method: string; - optionsRoot: string; - sourceBinding: DescriptionTemplateExternalSelectSourceBinding; - hasAuth: boolean; - auth: DescriptionTemplateExternalSelectAuthData -} - -export interface DescriptionTemplateExternalSelectAuthData { - url: string; - method: string; - body: string; - path: string; - type: string; -} - -export interface DescriptionTemplateExternalSelectSourceBinding { - label: string; - value: string; - source: string; -} export interface DescriptionTemplateSelectOption { label: string; diff --git a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts index 2fd5249f2..30ace1679 100644 --- a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts +++ b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts @@ -1,9 +1,10 @@ +import { DmpBlueprintFieldCategory } from "@app/core/common/enum/dmp-blueprint-field-category"; import { DmpBlueprintExtraFieldDataType } from "@app/core/common/enum/dmp-blueprint-field-type"; -import { DmpBlueprintSectionFieldCategory } from "@app/core/common/enum/dmp-blueprint-section-field-category"; import { DmpBlueprintStatus } from "@app/core/common/enum/dmp-blueprint-status"; import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint-system-field-type"; import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; import { Guid } from "@common/types/guid"; +import { ReferenceType } from "../reference-type/reference-type"; export interface DmpBlueprint extends BaseEntity { @@ -38,9 +39,7 @@ export interface DescriptionTemplatesInSection { export interface FieldInSection { id: Guid; - category: DmpBlueprintSectionFieldCategory; - dataType: DmpBlueprintExtraFieldDataType; - systemFieldType: DmpBlueprintSystemFieldType; + category: DmpBlueprintFieldCategory; label: string; placeholder: string; description: string; @@ -48,6 +47,18 @@ export interface FieldInSection { ordinal: number; } +export interface SystemFieldInSection extends FieldInSection { + systemFieldType: DmpBlueprintSystemFieldType; +} + +export interface ExtraFieldInSection extends FieldInSection { + dataType: DmpBlueprintExtraFieldDataType; +} + +export interface ReferenceTypeFieldInSection extends FieldInSection { + referenceType: ReferenceType; +} + // // Persist // @@ -86,12 +97,22 @@ export interface DescriptionTemplatesInSectionPersist { export interface FieldInSectionPersist { id: Guid; - category: DmpBlueprintSectionFieldCategory; - dataType: DmpBlueprintExtraFieldDataType; - systemFieldType: DmpBlueprintSystemFieldType; + category: DmpBlueprintFieldCategory; label: string; placeholder: string; description: string; required: boolean; ordinal: number; +} + +export interface SystemFieldInSectionPersist extends FieldInSectionPersist { + systemFieldType: DmpBlueprintSystemFieldType; +} + +export interface ExtraFieldInSectionPersist extends FieldInSectionPersist { + dataType: DmpBlueprintExtraFieldDataType; +} + +export interface ReferenceTypeFieldInSectionPersist extends FieldInSectionPersist { + referenceTypeId: Guid; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/reference/reference.ts b/dmp-frontend/src/app/core/model/reference/reference.ts index e5a19a695..5b53cf413 100644 --- a/dmp-frontend/src/app/core/model/reference/reference.ts +++ b/dmp-frontend/src/app/core/model/reference/reference.ts @@ -1,7 +1,8 @@ import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type"; import { ReferenceSourceType } from "@app/core/common/enum/reference-source-type"; -import { ReferenceType } from "@app/core/common/enum/reference-type"; import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; +import { ReferenceType } from "../reference-type/reference-type"; +import { Guid } from "@common/types/guid"; export interface Reference extends BaseEntity { label: string; @@ -47,7 +48,7 @@ export interface FetcherReference { export interface ReferencePersist extends BaseEntityPersist { label: string; - type: ReferenceType; + typeId: Guid; description: string; definition: DefinitionPersist; reference: string; diff --git a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts index d8a5f41e6..68e25404e 100644 --- a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts +++ b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts @@ -1,6 +1,7 @@ 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"; @Pipe({ name: 'fieldValue' @@ -33,7 +34,6 @@ export class FieldValuePipe implements PipeTransform { return this.date.transform(controlValue.value, 'dd/MM/yyyy'); case DescriptionTemplateFieldType.FREE_TEXT: return value; - case DescriptionTemplateFieldType.EXTERNAL_SELECT: case DescriptionTemplateFieldType.SELECT: if (value && controlValue.data.options && !controlValue.data.multipleSelect) { return controlValue.data.options.find(option => value == option.value).label; @@ -48,20 +48,11 @@ export class FieldValuePipe implements PipeTransform { break; case DescriptionTemplateFieldType.TEXT_AREA: return value; - case DescriptionTemplateFieldType.REGISTRIES: - case DescriptionTemplateFieldType.SERVICES: - case DescriptionTemplateFieldType.RESEARCHERS: - case DescriptionTemplateFieldType.ORGANIZATIONS: + case DescriptionTemplateFieldType.REFERENCE_TYPES: + return (value as Reference)?.label; case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - case DescriptionTemplateFieldType.DATA_REPOSITORIES: - case DescriptionTemplateFieldType.PUB_REPOSITORIES: - case DescriptionTemplateFieldType.JOURNAL_REPOSITORIES: - case DescriptionTemplateFieldType.TAXONOMIES: - case DescriptionTemplateFieldType.LICENSES: - case DescriptionTemplateFieldType.PUBLICATIONS: case DescriptionTemplateFieldType.TAGS: return this.parseJson(value); - case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: return this.parseJson(value, 'label'); diff --git a/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts b/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts index b22f8fdde..fa6e7331f 100644 --- a/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts +++ b/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts @@ -1,6 +1,5 @@ import { Lookup } from "@common/model/lookup"; import { RecentActivityOrder } from "../common/enum/recent-activity-order"; -import { ReferenceType } from "../common/enum/reference-type"; export class RecentActivityItemLookup implements RecentActivityItemFilter { like: string; diff --git a/dmp-frontend/src/app/core/query/reference-search.lookup.ts b/dmp-frontend/src/app/core/query/reference-search.lookup.ts index 16e8e7bbd..f536eb3a6 100644 --- a/dmp-frontend/src/app/core/query/reference-search.lookup.ts +++ b/dmp-frontend/src/app/core/query/reference-search.lookup.ts @@ -1,10 +1,9 @@ import { Lookup } from "@common/model/lookup"; -import { ReferenceType } from "../common/enum/reference-type"; import { Guid } from "@common/types/guid"; -export class ReferenceSearchLookup extends Lookup{ +export class ReferenceSearchLookup extends Lookup { like: string; - type: ReferenceType; + referenceTypeId: Guid; key: string; constructor() { @@ -13,7 +12,7 @@ export class ReferenceSearchLookup extends Lookup{ } -export class ReferenceSearchDefinitionLookup extends Lookup{ +export class ReferenceSearchDefinitionLookup extends Lookup { like: string; referenceTypeId: Guid; key: string; diff --git a/dmp-frontend/src/app/core/query/reference.lookup.ts b/dmp-frontend/src/app/core/query/reference.lookup.ts index 36d30aef8..f78da6047 100644 --- a/dmp-frontend/src/app/core/query/reference.lookup.ts +++ b/dmp-frontend/src/app/core/query/reference.lookup.ts @@ -2,7 +2,6 @@ import { Lookup } from '@common/model/lookup'; import { Guid } from '@common/types/guid'; import { IsActive } from '../common/enum/is-active.enum'; import { ReferenceSourceType } from '../common/enum/reference-source-type'; -import { ReferenceType } from '../common/enum/reference-type'; export class ReferenceLookup extends Lookup implements ReferenceFilter { ids: Guid[]; @@ -10,7 +9,7 @@ export class ReferenceLookup extends Lookup implements ReferenceFilter { like: string; isActive: IsActive[]; sourceTypes: ReferenceSourceType[]; - types: ReferenceType[]; + typeIds: Guid[]; constructor() { super(); @@ -23,5 +22,5 @@ export interface ReferenceFilter { like: string; isActive: IsActive[]; sourceTypes: ReferenceSourceType[]; - types: ReferenceType[]; + typeIds: Guid[]; } diff --git a/dmp-frontend/src/app/core/services/reference-type/reference-type.service.ts b/dmp-frontend/src/app/core/services/reference-type/reference-type.service.ts index 185ed3652..25cc90232 100644 --- a/dmp-frontend/src/app/core/services/reference-type/reference-type.service.ts +++ b/dmp-frontend/src/app/core/services/reference-type/reference-type.service.ts @@ -129,4 +129,12 @@ export class ReferenceTypeService { return fields; } + + public getResearcherReferenceType(): Guid { + return null; + } + + public getGrantReferenceType(): Guid { + return null; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/reference/reference.service.ts b/dmp-frontend/src/app/core/services/reference/reference.service.ts index 8f1012b9a..fb273bc21 100644 --- a/dmp-frontend/src/app/core/services/reference/reference.service.ts +++ b/dmp-frontend/src/app/core/services/reference/reference.service.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { DmpReference } from '@app/core/model/dmp/dmp-reference'; import { Definition, Field, Reference, ReferencePersist } from '@app/core/model/reference/reference'; import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; @@ -36,13 +35,13 @@ export class ReferenceService { return this.http.post>(url, q).pipe(catchError((error: any) => throwError(error))); } - search(q: ReferenceSearchLookup): Observable { - const url = `${this.apiBase}/search`; - return this.http.post(url, q).pipe(catchError((error: any) => throwError(error))); - } + // search(q: ReferenceSearchLookup): Observable { + // const url = `${this.apiBase}/search`; + // return this.http.post(url, q).pipe(catchError((error: any) => throwError(error))); + // } searchWithDefinition(q: ReferenceSearchDefinitionLookup): Observable { - const url = `${this.apiBase}/search-with-db-definition`; + const url = `${this.apiBase}/search`; return this.http.post(url, q).pipe(catchError((error: any) => throwError(error))); } @@ -74,29 +73,29 @@ export class ReferenceService { // // Autocomplete Commons - Query // - public getSingleAutocompleteQueryConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration { + public getSingleAutocompleteQueryConfiguration(referenceTypeIds?: Guid[], sourceTypes?: ReferenceSourceType[]): SingleAutoCompleteConfiguration { return { - initialItems: (data?: any) => this.query(this.buildAutocompleteQueryLookup(types, sourceTypes)).pipe(map(x => x.items)), - filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteQueryLookup(types, sourceTypes, searchQuery)).pipe(map(x => x.items)), - getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteQueryLookup(types, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])), + initialItems: (data?: any) => this.query(this.buildAutocompleteQueryLookup(referenceTypeIds, sourceTypes)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteQueryLookup(referenceTypeIds, sourceTypes, searchQuery)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteQueryLookup(referenceTypeIds, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])), displayFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label, valueAssign: (item: Reference) => item.id, }; }; - public getMultipleAutoCompleteQueryConfiguration(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration { + public getMultipleAutoCompleteQueryConfiguration(referenceTypeIds?: Guid[], sourceTypes?: ReferenceSourceType[]): MultipleAutoCompleteConfiguration { return { - initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteQueryLookup(types, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), - filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteQueryLookup(types, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)), - getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteQueryLookup(types, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)), + initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteQueryLookup(referenceTypeIds, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteQueryLookup(referenceTypeIds, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteQueryLookup(referenceTypeIds, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)), displayFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label, valueAssign: (item: Reference) => item.id, }; } - private buildAutocompleteQueryLookup(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { + private buildAutocompleteQueryLookup(referenceTypeIds?: Guid[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { const lookup: ReferenceLookup = new ReferenceLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } @@ -108,7 +107,7 @@ export class ReferenceService { nameof(x => x.label), ] }; - if (types && types.length > 0) { lookup.types = types; } + if (referenceTypeIds && referenceTypeIds.length > 0) { lookup.typeIds = referenceTypeIds; } if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; } lookup.order = { items: [nameof(x => x.label)] }; if (like) { lookup.like = this.filterService.transformLike(like); } @@ -118,22 +117,22 @@ export class ReferenceService { // // Autocomplete Commons - Search // - public getSingleAutocompleteSearchConfiguration(type: ReferenceType): SingleAutoCompleteConfiguration { + public getSingleAutocompleteSearchConfiguration(typeId: Guid): SingleAutoCompleteConfiguration { return { - initialItems: (data?: any) => this.search(this.buildAutocompleteSearchLookup(type)).pipe(map(x => x)), - filterFn: (searchQuery: string, data?: any) => this.search(this.buildAutocompleteSearchLookup(type, searchQuery)).pipe(map(x => x)), - getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteSearchSelectedItemsLookup([type], null, null, null, [selectedItem])).pipe(map(x => x.items[0])), + initialItems: (data?: any) => this.searchWithDefinition(this.buildAutocompleteSearchLookup(typeId)).pipe(map(x => x)), + filterFn: (searchQuery: string, data?: any) => this.searchWithDefinition(this.buildAutocompleteSearchLookup(typeId, searchQuery)).pipe(map(x => x)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteSearchSelectedItemsLookup([typeId], null, null, null, [selectedItem])).pipe(map(x => x.items[0])), displayFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label, valueAssign: (item: Reference) => item.id, }; }; - public getMultipleAutoCompleteSearchConfiguration(type: ReferenceType): MultipleAutoCompleteConfiguration { + public getMultipleAutoCompleteSearchConfiguration(typeId: Guid): MultipleAutoCompleteConfiguration { return { - initialItems: (excludedItems: any[], data?: any) => this.search(this.buildAutocompleteSearchLookup(type, null)).pipe(map(x => x)), - filterFn: (searchQuery: string, excludedItems: any[]) => this.search(this.buildAutocompleteSearchLookup(type, searchQuery)).pipe(map(x => x)), - getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteSearchSelectedItemsLookup([type], null, null, null, selectedItems?.map(x => x.id))).pipe(map(x => x.items)), + initialItems: (excludedItems: any[], data?: any) => this.searchWithDefinition(this.buildAutocompleteSearchLookup(typeId, null)).pipe(map(x => x)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.searchWithDefinition(this.buildAutocompleteSearchLookup(typeId, searchQuery)).pipe(map(x => x)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteSearchSelectedItemsLookup([typeId], null, null, null, selectedItems?.map(x => x.id))).pipe(map(x => x.items)), displayFn: (item: Reference) => item.label, titleFn: (item: Reference) => item.label, subtitleFn: (item: Reference) => item?.sourceType === ReferenceSourceType.External ? this.language.instant('REFERENCE-FIELD-COMPONENT.EXTERNAL-SOURCE') + ': ' + item.source : this.language.instant('REFERENCE-FIELD-COMPONENT.INTERNAL-SOURCE'), @@ -142,7 +141,7 @@ export class ReferenceService { }; } - private buildAutocompleteSearchLookup(type: ReferenceType, like?: string): ReferenceSearchLookup { + private buildAutocompleteSearchLookup(typeId: Guid, like?: string): ReferenceSearchLookup { const lookup: ReferenceSearchLookup = new ReferenceSearchLookup(); lookup.page = { size: 100, offset: 0 }; lookup.project = { @@ -161,13 +160,13 @@ export class ReferenceService { nameof(x => x.sourceType), ] }; - lookup.type = type; + lookup.referenceTypeId = typeId; lookup.order = { items: [nameof(x => x.label)] }; if (like) { lookup.like = this.filterService.transformLike(like); } return lookup; } - private buildAutocompleteSearchSelectedItemsLookup(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { + private buildAutocompleteSearchSelectedItemsLookup(referenceTypeIds?: Guid[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { const lookup: ReferenceLookup = new ReferenceLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } @@ -188,7 +187,7 @@ export class ReferenceService { nameof(x => x.sourceType), ] }; - if (types && types.length > 0) { lookup.types = types; } + if (referenceTypeIds && referenceTypeIds.length > 0) { lookup.typeIds = referenceTypeIds; } if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; } lookup.order = { items: [nameof(x => x.label)] }; if (like) { lookup.like = this.filterService.transformLike(like); } @@ -202,16 +201,16 @@ export class ReferenceService { // // - hasRerefenceOfTypes(dmpReferences: DmpReference[], referenceTypes: ReferenceType[]): boolean { - return this.getReferencesForTypes(dmpReferences, referenceTypes)?.length > 0; + hasRerefenceOfTypes(dmpReferences: DmpReference[], referenceTypeIds?: Guid[]): boolean { + return this.getReferencesForTypes(dmpReferences, referenceTypeIds)?.length > 0; } - getReferencesForTypes(dmpReferences: DmpReference[], referenceTypes: ReferenceType[]): DmpReference[] { - return dmpReferences?.filter(x => referenceTypes?.includes(x?.reference?.type)); + getReferencesForTypes(dmpReferences: DmpReference[], referenceTypeIds?: Guid[]): DmpReference[] { + return dmpReferences?.filter(x => referenceTypeIds?.includes(x?.reference?.type?.id)); } - getReferencesForTypesFirstSafe(dmpReferences: DmpReference[], referenceTypes: ReferenceType[]): DmpReference { - return this.getReferencesForTypes(dmpReferences, referenceTypes)?.find(Boolean); + getReferencesForTypesFirstSafe(dmpReferences: DmpReference[], referenceTypeIds?: Guid[]): DmpReference { + return this.getReferencesForTypes(dmpReferences, referenceTypeIds)?.find(Boolean); } } diff --git a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts index a66409751..59078df05 100644 --- a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts +++ b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts @@ -24,7 +24,6 @@ import { NotificationType } from '@app/core/common/enum/notification-type'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type'; import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type'; import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type'; import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; @@ -37,6 +36,7 @@ import { DmpBlueprintType } from '../../common/enum/dmp-blueprint-type'; import { DmpStatus } from '../../common/enum/dmp-status'; import { ValidationType } from '../../common/enum/validation-type'; import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type'; +import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category'; @Injectable() export class EnumUtils { @@ -133,17 +133,11 @@ export class EnumUtils { toDmpBlueprintSystemFieldTypeString(status: DmpBlueprintSystemFieldType): string { switch (status) { - case DmpBlueprintSystemFieldType.TEXT: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.TEXT'); - case DmpBlueprintSystemFieldType.HTML_TEXT: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.HTML_TEXT'); - case DmpBlueprintSystemFieldType.RESEARCHERS: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.RESEARCHERS'); - case DmpBlueprintSystemFieldType.ORGANIZATIONS: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.ORGANIZATIONS'); - case DmpBlueprintSystemFieldType.LANGUAGE: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.LANGUAGE'); - case DmpBlueprintSystemFieldType.CONTACT: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.CONTACT'); - case DmpBlueprintSystemFieldType.FUNDER: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.FUNDER'); - case DmpBlueprintSystemFieldType.GRANT: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.GRANT'); - case DmpBlueprintSystemFieldType.PROJECT: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.PROJECT'); - case DmpBlueprintSystemFieldType.LICENSE: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.LICENSE'); - case DmpBlueprintSystemFieldType.ACCESS_RIGHTS: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.ACCESS_RIGHTS'); + case DmpBlueprintSystemFieldType.Title: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.TITLE'); + case DmpBlueprintSystemFieldType.Description: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.DESCRIPTION'); + case DmpBlueprintSystemFieldType.Language: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.LANGUAGE'); + case DmpBlueprintSystemFieldType.Contact: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.CONTACT'); + case DmpBlueprintSystemFieldType.AccessRights: return this.language.instant('TYPES.DMP-BLUEPRINT-SYSTEM-FIELD-TYPE.ACCESS_RIGHTS'); } } @@ -158,11 +152,9 @@ export class EnumUtils { toDescriptionTemplateFieldTypeString(status: DescriptionTemplateFieldType): string { switch (status) { - case DescriptionTemplateFieldType.EXTERNAL_SELECT: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.EXTERNAL-SELECT'); case DescriptionTemplateFieldType.SELECT: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.SELECT'); case DescriptionTemplateFieldType.BOOLEAN_DECISION: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.BOOLEAN-DECISION'); case DescriptionTemplateFieldType.RADIO_BOX: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.RADIO-BOX'); - case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.INTERNAL-DMP-ENTITIES-RESEARCHERS'); case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.INTERNAL-DMP-ENTITIES-DMPS'); case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.INTERNAL-DMP-ENTITIES-DATASETS'); case DescriptionTemplateFieldType.CHECK_BOX: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.CHECKBOX'); @@ -172,17 +164,8 @@ export class EnumUtils { 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.DATA_REPOSITORIES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.DATA-REPOSITORIES'); - case DescriptionTemplateFieldType.JOURNAL_REPOSITORIES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.JOURNALS-REPOSITORIES'); - case DescriptionTemplateFieldType.PUB_REPOSITORIES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.PUB-REPOSITORIES'); - case DescriptionTemplateFieldType.LICENSES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.LICENSES'); - case DescriptionTemplateFieldType.TAXONOMIES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.TAXONOMIES'); - case DescriptionTemplateFieldType.PUBLICATIONS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.PUBLICATIONS'); - case DescriptionTemplateFieldType.REGISTRIES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.REGISTRIES'); - case DescriptionTemplateFieldType.SERVICES: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.SERVICES'); case DescriptionTemplateFieldType.TAGS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.TAGS'); - case DescriptionTemplateFieldType.RESEARCHERS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.RESEARCHERS'); - case DescriptionTemplateFieldType.ORGANIZATIONS: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.ORGANIZATIONS'); + 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'); case DescriptionTemplateFieldType.CURRENCY: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.CURRENCY'); case DescriptionTemplateFieldType.VALIDATION: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-TYPE.VALIDATION'); @@ -218,26 +201,6 @@ export class EnumUtils { } } - toReferenceTypeString(status: ReferenceType): string { - switch (status) { - case ReferenceType.Taxonomies: return this.language.instant('TYPES.REFERENCE-TYPE.TAXONOMY'); - case ReferenceType.Licenses: return this.language.instant('TYPES.REFERENCE-TYPE.LICENCE'); - case ReferenceType.Publications: return this.language.instant('TYPES.REFERENCE-TYPE.PUBLICATION'); - case ReferenceType.Journals: return this.language.instant('TYPES.REFERENCE-TYPE.JOURNAL'); - case ReferenceType.PubRepositories: return this.language.instant('TYPES.REFERENCE-TYPE.PUB-REPOSITORY'); - case ReferenceType.DataRepositories: return this.language.instant('TYPES.REFERENCE-TYPE.DATA-REPOSITORY'); - case ReferenceType.Registries: return this.language.instant('TYPES.REFERENCE-TYPE.REGISTRY'); - case ReferenceType.Services: return this.language.instant('TYPES.REFERENCE-TYPE.SERVICE'); - case ReferenceType.Project: return this.language.instant('TYPES.REFERENCE-TYPE.PROJECT'); - case ReferenceType.Funder: return this.language.instant('TYPES.REFERENCE-TYPE.FUNDER'); - case ReferenceType.Datasets: return this.language.instant('TYPES.REFERENCE-TYPE.DATASET'); - case ReferenceType.Organizations: return this.language.instant('TYPES.REFERENCE-TYPE.ORGANISATION'); - case ReferenceType.Grants: return this.language.instant('TYPES.REFERENCE-TYPE.GRANT'); - case ReferenceType.Researcher: return this.language.instant('TYPES.REFERENCE-TYPE.RESEARCHER'); - - } - } - toReferenceSourceTypeString(status: ReferenceSourceType): string { switch (status) { case ReferenceSourceType.Internal: return this.language.instant('TYPES.REFERENCE-SOURCE-TYPE.INTERNAL'); @@ -415,4 +378,14 @@ export class EnumUtils { case DescriptionTemplateExternalSelectAuthType.BEARER: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-EXTERNAL-SELECT-AUTH-TYPE.BEARER'); } } + + public toDmpBlueprintFieldCategoryString(value: DmpBlueprintFieldCategory): string { + switch (value) { + case DmpBlueprintFieldCategory.System: return this.language.instant('TYPES.DMP-BLUEPRINT-FIELD-CATEGORY.SYSTEM'); + case DmpBlueprintFieldCategory.Extra: return this.language.instant('TYPES.DMP-BLUEPRINT-FIELD-CATEGORY.EXTRA'); + case DmpBlueprintFieldCategory.ReferenceType: return this.language.instant('TYPES.DMP-BLUEPRINT-FIELD-CATEGORY.REFERENCE-TYPE'); + } + } + + } diff --git a/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts b/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts index 40a4ee124..2cce04d94 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts @@ -14,7 +14,6 @@ import { DescriptionTemplateRoutingModule } from './description-template.routing import { DescriptionTemplateEditorCompositeFieldComponent } from './editor/components/composite-field/description-template-editor-composite-field.component'; import { DescriptionTemplateEditorDefaultValueComponent } from './editor/components/default-value/description-template-editor-default-value.component'; import { DescriptionTemplateEditorExternalDatasetsFieldComponent } from './editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component'; -import { DescriptionTemplateEditorExternalSelectFieldComponent } from './editor/components/field-type/external-select/description-template-editor-external-select-field.component'; import { DescriptionTemplateEditorLabelAndMultiplicityFieldComponent } from './editor/components/field-type/label-and-multiplicity-field/description-template-editor-label-and-multiplicity-field.component'; import { DescriptionTemplateEditorLabelFieldComponent } from './editor/components/field-type/label-field/description-template-editor-label-field.component'; import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/components/field-type/radio-box/description-template-editor-radio-box-field.component'; @@ -30,6 +29,7 @@ import { DescriptionTemplateTableOfContentsInternalSection } from './editor/tabl import { DescriptionTemplateListingComponent } from './listing/description-template-listing.component'; import { DescriptionTemplateListingFiltersComponent } from "./listing/filters/description-template-listing-filters.component"; import { ImportDescriptionTemplateDialogComponent } from './listing/import-description-template/import-description-template.dialog.component'; +import { DescriptionTemplateEditorReferenceTypeFieldComponent } from './editor/components/field-type/reference-type/description-template-editor-reference-type-field.component'; @NgModule({ imports: [ @@ -68,7 +68,7 @@ import { ImportDescriptionTemplateDialogComponent } from './listing/import-descr DescriptionTemplateEditorDefaultValueComponent, DescriptionTemplateEditorRuleComponent, - DescriptionTemplateEditorExternalSelectFieldComponent, + DescriptionTemplateEditorReferenceTypeFieldComponent, DescriptionTemplateEditorSelectFieldComponent, DescriptionTemplateEditorLabelFieldComponent, DescriptionTemplateEditorLabelAndMultiplicityFieldComponent, diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html index a9c4c74e5..9a3a9bde9 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html @@ -65,8 +65,7 @@
- +
  • @@ -190,54 +189,14 @@ APIs - - - - - - - - - - - diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts index 782407c90..c0727b36f 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts @@ -5,7 +5,6 @@ import { MatDialog } from '@angular/material/dialog'; import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; import { ValidationType } from '@app/core/common/enum/validation-type'; import { - DescriptionTemplateExternalSelectData, DescriptionTemplateSelectOption, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, @@ -13,7 +12,8 @@ import { DescriptionTemplateUploadData, DescriptionTemplateSelectData, DescriptionTemplateLabelData, - DescriptionTemplateLabelAndMultiplicityData + DescriptionTemplateLabelAndMultiplicityData, + DescriptionTemplateReferenceTypeData } from '@app/core/model/description-template/description-template'; import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; @@ -483,11 +483,10 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon } as DescriptionTemplateField; switch (type) { - case DescriptionTemplateFieldType.EXTERNAL_SELECT: { - const data: DescriptionTemplateExternalSelectData = { - sources: [], - multipleSelect: false, + case DescriptionTemplateFieldType.REFERENCE_TYPES: { + const data: DescriptionTemplateReferenceTypeData = { label: '', + multipleSelect: false, fieldType: type } field.data = data; @@ -531,19 +530,12 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon break; } - case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: { + //TODO: refactor + break; + } case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: - case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: - case DescriptionTemplateFieldType.DATA_REPOSITORIES: - case DescriptionTemplateFieldType.JOURNAL_REPOSITORIES: - case DescriptionTemplateFieldType.PUB_REPOSITORIES: - case DescriptionTemplateFieldType.LICENSES: - case DescriptionTemplateFieldType.TAXONOMIES: - case DescriptionTemplateFieldType.PUBLICATIONS: - case DescriptionTemplateFieldType.REGISTRIES: - case DescriptionTemplateFieldType.SERVICES: - case DescriptionTemplateFieldType.RESEARCHERS: - case DescriptionTemplateFieldType.ORGANIZATIONS: { + case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: { const data: DescriptionTemplateLabelAndMultiplicityData = { label: '', multipleSelect: false, @@ -573,7 +565,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon } } - (this.form.get('fields')).push(new DescriptionTemplateFieldEditorModel(this.validationErrorModel).fromModel(field).buildForm({rootPath: this.validationRootPath + '.fields[' + this.fieldsArray.length + ']'})); + (this.form.get('fields')).push(new DescriptionTemplateFieldEditorModel(this.validationErrorModel).fromModel(field).buildForm({ rootPath: this.validationRootPath + '.fields[' + this.fieldsArray.length + ']' })); this.inputs.init(); // fieldForm.get('viewStyle').get('renderStyle').updateValueAndValidity(); // fieldForm.get('data').updateValueAndValidity(); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts index c1d412f01..04f201e1c 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts @@ -1,6 +1,5 @@ import { Component, Input, OnInit } from '@angular/core'; import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { DescriptionTemplateExternalSelectDataEditorModel, DescriptionTemplateExternalSelectSourceEditorModel } from '../../../description-template-editor.model'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { DescriptionTemplateExternalSelectHttpMethodType } from '@app/core/common/enum/description-template-external-select-http-method-type'; import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type'; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.html new file mode 100644 index 000000000..03d349164 --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.html @@ -0,0 +1,23 @@ +
    +
    {{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.REFERENCE-TYPE-TITLE' + | translate}}
    + + {{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.MULTIPLE-SELECT' | translate}} + + +
    + + {{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.LABEL' | translate}} + + {{form.get('data').get('label').getError('backendError').message}} + +
    +
    + + {{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}} + + {{form.get('data').get('referenceTypeId').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
    +
    \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.scss b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.scss new file mode 100644 index 000000000..3db0dee74 --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.scss @@ -0,0 +1,3 @@ +.full-width { + width: 100%; +} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.ts new file mode 100644 index 000000000..c321e7698 --- /dev/null +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/reference-type/description-template-editor-reference-type-field.component.ts @@ -0,0 +1,20 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; + +@Component({ + selector: 'app-description-template-editor-reference-type-field-component', + styleUrls: ['./description-template-editor-reference-type-field.component.scss'], + templateUrl: './description-template-editor-reference-type-field.component.html' +}) +export class DescriptionTemplateEditorReferenceTypeFieldComponent implements OnInit { + + @Input() form: UntypedFormGroup; + constructor( + public referenceTypeService: ReferenceTypeService + ) { } + + ngOnInit() { + + } +} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html index 00e7960ab..2d41acbfc 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html @@ -88,54 +88,14 @@ - + Registries icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.REGISTRIES)}} - - - Services icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.SERVICES)}} - - - Researchers icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.RESEARCHERS)}} - - - Organizations icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.ORGANIZATIONS)}} + {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.REFERENCE_TYPES)}} ExternalDatasets icon {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.EXTERNAL_DATASETS)}} - - DataRepositories icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.DATA_REPOSITORIES)}} - - - PubRepositories icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.PUB_REPOSITORIES)}} - - - Journal Repositories icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.JOURNAL_REPOSITORIES)}} - - - Taxonomies icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.TAXONOMIES)}} - - - licenses icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.LICENSES)}} - - - Publications icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.PUBLICATIONS)}} - - - Other icon - {{enumUtils.toDescriptionTemplateFieldTypeString(descriptionTemplateFieldTypeEnum.EXTERNAL_SELECT)}} - @@ -168,7 +128,7 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} - {{form.get('data').get('fieldType').getError('backendError').message}} + {{form.get('data').get('fieldType').getError('backendError').message}} @@ -178,16 +138,15 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.SEMANTICS' | translate}} - {{form.get('schematics').getError('backendError').message}} + {{form.get('schematics').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXPORT' | translate}} - {{form.get('includeInExport').getError('backendError').message}} + {{form.get('includeInExport').getError('backendError').message}} - +
    @@ -208,12 +167,12 @@
    -->
-
+
- - - - + + + + @@ -228,19 +187,8 @@ - - - - - - - - - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts index efa628322..67877419a 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts @@ -8,10 +8,10 @@ import { DescriptionTemplateFieldType } from '@app/core/common/enum/description- import { ValidationType } from '@app/core/common/enum/validation-type'; import { DescriptionTemplateExternalDatasetData, - DescriptionTemplateExternalSelectData, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateLabelData, DescriptionTemplateRadioBoxData, + DescriptionTemplateReferenceTypeData, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData @@ -107,7 +107,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple case DescriptionTemplateFieldType.BOOLEAN_DECISION: case DescriptionTemplateFieldType.RADIO_BOX: case DescriptionTemplateFieldType.SELECT: - case DescriptionTemplateFieldType.EXTERNAL_SELECT: case DescriptionTemplateFieldType.CHECK_BOX: case DescriptionTemplateFieldType.DATE_PICKER: return true; @@ -126,10 +125,8 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple } switch (type) { - case DescriptionTemplateFieldType.EXTERNAL_SELECT: { - const data: DescriptionTemplateExternalSelectData = { - sources: [], - multipleSelect: false, + case DescriptionTemplateFieldType.REFERENCE_TYPES: { + const data: DescriptionTemplateLabelData = { label: '', fieldType: type } @@ -174,19 +171,12 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple break; } - case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: { + //TODO: refactor + break; + } case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: - case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: - case DescriptionTemplateFieldType.DATA_REPOSITORIES: - case DescriptionTemplateFieldType.JOURNAL_REPOSITORIES: - case DescriptionTemplateFieldType.PUB_REPOSITORIES: - case DescriptionTemplateFieldType.LICENSES: - case DescriptionTemplateFieldType.TAXONOMIES: - case DescriptionTemplateFieldType.PUBLICATIONS: - case DescriptionTemplateFieldType.REGISTRIES: - case DescriptionTemplateFieldType.SERVICES: - case DescriptionTemplateFieldType.RESEARCHERS: - case DescriptionTemplateFieldType.ORGANIZATIONS: { + case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS:{ const data: DescriptionTemplateLabelAndMultiplicityData = { label: '', multipleSelect: false, diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index 2ccb3b3e6..2452d61a4 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -1254,7 +1254,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor { - // if ((field.get('category').value == FieldCategory.SYSTEM || field.get('category').value == DescriptionTemplateSectionFieldCategory.SYSTEM)) { + // if ((field.get('category').value == FieldCategory.System || field.get('category').value == DescriptionTemplateSectionFieldCategory.System)) { // systemFieldsInSection.push(this.fieldList.find(f => f.type == field.get('type').value).type); // } // }) @@ -1471,7 +1471,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor section.fields.some(field => (field.category === DescriptionTemplateSectionFieldCategory.SYSTEM || field.category as unknown === DescriptionTemplateSectionFieldCategory.SYSTEM) && field.systemFieldType === DescriptionTemplateSystemFieldType.TEXT)); + // return descriptionTemplate.definition.sections.some(section => section.fields.some(field => (field.category === DescriptionTemplateSectionFieldCategory.System || field.category as unknown === DescriptionTemplateSectionFieldCategory.System) && field.systemFieldType === DescriptionTemplateSystemFieldType.TEXT)); // } // hasDescription(): boolean { // const descriptionTemplate: DescriptionTemplatePersist = this.formGroup.value; - // return descriptionTemplate.definition.sections.some(section => section.fields.some(field => (field.category === DescriptionTemplateSectionFieldCategory.SYSTEM || field.category as unknown === DescriptionTemplateSectionFieldCategory.SYSTEM) && field.systemFieldType === DescriptionTemplateSystemFieldType.HTML_TEXT)); + // return descriptionTemplate.definition.sections.some(section => section.fields.some(field => (field.category === DescriptionTemplateSectionFieldCategory.System || field.category as unknown === DescriptionTemplateSectionFieldCategory.System) && field.systemFieldType === DescriptionTemplateSystemFieldType.Description)); // } // hasDescriptionTemplates(): boolean { diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts index cd7bfc8f8..b7c80e5f0 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts @@ -4,8 +4,8 @@ import { DescriptionTemplateFieldType } from "@app/core/common/enum/description- import { DescriptionTemplateFieldValidationType } from "@app/core/common/enum/description-template-field-validation-type"; import { DescriptionTemplateStatus } from "@app/core/common/enum/description-template-status"; import { UserDescriptionTemplateRole } from "@app/core/common/enum/user-description-template-role"; -import { DescriptionTemplate, DescriptionTemplateDefinition, DescriptionTemplateExternalSelectSourceBinding, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelData, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from "@app/core/model/description-template/description-template"; -import { DescriptionTemplateDefinitionPersist, DescriptionTemplateExternalDatasetDataPersist, DescriptionTemplateExternalSelectAuthDataPersist, DescriptionTemplateExternalSelectDataPersist, DescriptionTemplateExternalSelectSourceBindingPersist, DescriptionTemplateExternalSelectSourcePersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateLabelAndMultiplicityDataPersist, DescriptionTemplateLabelDataPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplateRadioBoxDataPersist, DescriptionTemplateRadioBoxOptionPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist, DescriptionTemplateSelectDataPersist, DescriptionTemplateSelectOptionPersist, DescriptionTemplateUploadDataPersist, DescriptionTemplateUploadOptionPersist, UserDescriptionTemplatePersist } from "@app/core/model/description-template/description-template-persist"; +import { DescriptionTemplate, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelData, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection } from "@app/core/model/description-template/description-template"; +import { DescriptionTemplateDefinitionPersist, DescriptionTemplateExternalDatasetDataPersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateLabelAndMultiplicityDataPersist, DescriptionTemplateLabelDataPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplateRadioBoxDataPersist, DescriptionTemplateRadioBoxOptionPersist, DescriptionTemplateReferenceTypeFieldPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist, DescriptionTemplateSelectDataPersist, DescriptionTemplateSelectOptionPersist, DescriptionTemplateUploadDataPersist, DescriptionTemplateUploadOptionPersist, UserDescriptionTemplatePersist } from "@app/core/model/description-template/description-template-persist"; import { BaseEditorModel } from "@common/base/base-form-editor-model"; import { BackendErrorValidator } from "@common/forms/validation/custom-validator"; import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model"; @@ -229,7 +229,7 @@ export class DescriptionTemplateDefinitionEditorModel implements DescriptionTemp this.validationErrorModel ).fromModel(item).buildForm({ rootPath: `${rootPath}pages[${index}].` - }) + }) ), context.getValidation('pages').validators ), }); @@ -802,8 +802,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF private getFieldEditorModel(fieldType: DescriptionTemplateFieldType): DescriptionTemplateLabelDataEditorModel { switch (fieldType) { - case DescriptionTemplateFieldType.EXTERNAL_SELECT: - return new DescriptionTemplateExternalSelectDataEditorModel(this.validationErrorModel); + case DescriptionTemplateFieldType.REFERENCE_TYPES: + return new DescriptionTemplateReferenceTypeDataEditorModel(this.validationErrorModel); case DescriptionTemplateFieldType.RADIO_BOX: return new DescriptionTemplateRadioBoxDataEditorModel(this.validationErrorModel); case DescriptionTemplateFieldType.SELECT: @@ -819,19 +819,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF case DescriptionTemplateFieldType.CURRENCY: case DescriptionTemplateFieldType.VALIDATION: return new DescriptionTemplateLabelDataEditorModel(this.validationErrorModel); - case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: - case DescriptionTemplateFieldType.DATA_REPOSITORIES: - case DescriptionTemplateFieldType.JOURNAL_REPOSITORIES: - case DescriptionTemplateFieldType.PUB_REPOSITORIES: - case DescriptionTemplateFieldType.LICENSES: - case DescriptionTemplateFieldType.TAXONOMIES: - case DescriptionTemplateFieldType.PUBLICATIONS: - case DescriptionTemplateFieldType.REGISTRIES: - case DescriptionTemplateFieldType.SERVICES: - case DescriptionTemplateFieldType.RESEARCHERS: - case DescriptionTemplateFieldType.ORGANIZATIONS: return new DescriptionTemplateLabelAndMultiplicityDataEditorModel(this.validationErrorModel); case DescriptionTemplateFieldType.EXTERNAL_DATASETS: return new DescriptionTemplateExternalDatasetDataEditorModel(this.validationErrorModel); @@ -864,7 +853,7 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF validationErrorModel: validationErrorModel }); - if(formGroup?.get('data').get('fieldType').value != undefined){ + if (formGroup?.get('data').get('fieldType').value != undefined) { switch (formGroup?.get('data').get('fieldType').value) { case DescriptionTemplateFieldType.UPLOAD: DescriptionTemplateUploadDataEditorModel.reapplyUploadDataValidators({ @@ -887,8 +876,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF validationErrorModel: validationErrorModel }); break; - case DescriptionTemplateFieldType.EXTERNAL_SELECT: - DescriptionTemplateExternalSelectDataEditorModel.reapplyValidators({ + case DescriptionTemplateFieldType.REFERENCE_TYPES: + DescriptionTemplateReferenceTypeDataEditorModel.reapplyValidators({ formGroup: formGroup?.get('data') as UntypedFormGroup, rootPath: `${rootPath}data.`, validationErrorModel: validationErrorModel @@ -900,7 +889,7 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF validationErrorModel: validationErrorModel }); break; - + } } @@ -1190,26 +1179,23 @@ export class DescriptionTemplateExternalDatasetDataEditorModel extends Descripti } } - // // -// External Select Field +// Reference Types // // -export class DescriptionTemplateExternalSelectDataEditorModel extends DescriptionTemplateLabelDataEditorModel implements DescriptionTemplateExternalSelectDataPersist { - multipleSelect: boolean = false; - sources: DescriptionTemplateExternalSelectSourceEditorModel[] = []; +export class DescriptionTemplateReferenceTypeDataEditorModel extends DescriptionTemplateLabelAndMultiplicityDataEditorModel implements DescriptionTemplateReferenceTypeFieldPersist { + referenceTypeId: Guid; protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); constructor( public validationErrorModel: ValidationErrorModel = new ValidationErrorModel() ) { super(validationErrorModel); } - fromModel(item: DescriptionTemplateExternalSelectDataPersist): DescriptionTemplateExternalSelectDataEditorModel { + fromModel(item: DescriptionTemplateReferenceTypeData): DescriptionTemplateReferenceTypeDataEditorModel { if (item) { super.fromModel(item); - this.multipleSelect = item.multipleSelect ?? false; - if (item.sources) { item.sources.map(x => this.sources.push(new DescriptionTemplateExternalSelectSourceEditorModel(this.validationErrorModel).fromModel(x))); } + this.referenceTypeId = item.referenceTypeId; } return this; } @@ -1221,21 +1207,14 @@ export class DescriptionTemplateExternalSelectDataEditorModel extends Descriptio }): UntypedFormGroup { let { context = null, disabled = false, rootPath } = params ?? {} if (context == null) { - context = DescriptionTemplateExternalSelectDataEditorModel.createValidationContext({ + context = DescriptionTemplateReferenceTypeDataEditorModel.createValidationContext({ validationErrorModel: this.validationErrorModel, rootPath }); } const formGroup = super.buildForm({ context, disabled, rootPath }); - formGroup.setControl('multipleSelect', new FormControl({ value: this.multipleSelect, disabled: disabled }, context.getValidation('multipleSelect').validators)); - formGroup.setControl('sources', this.formBuilder.array( - (this.sources ?? []).map( - (item, index) => item.buildForm({ - rootPath: `${rootPath}sources[${index}].` - }) - ), context.getValidation('sources').validators - )); + formGroup.setControl('referenceTypeId', new FormControl({ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators)); return formGroup; } @@ -1245,8 +1224,7 @@ export class DescriptionTemplateExternalSelectDataEditorModel extends Descriptio }): ValidationContext { const { rootPath = '', validationErrorModel } = params; const baseContext: ValidationContext = super.createValidationContext({ rootPath, validationErrorModel }); - baseContext.validation.push({ key: 'multipleSelect', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}multipleSelect`)] }); - baseContext.validation.push({ key: 'sources', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sources`)] }); + baseContext.validation.push({ key: 'referenceTypeId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] }); return baseContext; } @@ -1257,285 +1235,12 @@ export class DescriptionTemplateExternalSelectDataEditorModel extends Descriptio }): void { const { formGroup, rootPath, validationErrorModel } = params; - const context = DescriptionTemplateExternalSelectDataEditorModel.createValidationContext({ + const context = DescriptionTemplateReferenceTypeDataEditorModel.createValidationContext({ rootPath, validationErrorModel }); - ['multipleSelect'].forEach(keyField => { - const control = formGroup?.get(keyField); - control?.clearValidators(); - control?.addValidators(context.getValidation(keyField).validators); - }); - - (formGroup.get('sources') as FormArray).controls?.forEach( - (control, index) => DescriptionTemplateExternalSelectSourceEditorModel.reapplyValidators({ - formGroup: control as UntypedFormGroup, - rootPath: `${rootPath}sources[${index}].`, - validationErrorModel: validationErrorModel - } - ) - ); - } -} - -export class DescriptionTemplateExternalSelectSourceEditorModel implements DescriptionTemplateExternalSelectSourcePersist { - url: string; - method: string; - optionsRoot: string; - sourceBinding: DescriptionTemplateExternalSelectSourceBindingEditorModel = new DescriptionTemplateExternalSelectSourceBindingEditorModel(this.validationErrorModel); - hasAuth: boolean; - auth: DescriptionTemplateExternalSelectAuthDataEditorModel = new DescriptionTemplateExternalSelectAuthDataEditorModel(this.validationErrorModel); - protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); - - constructor( - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel() - ) { } - - fromModel(item: DescriptionTemplateExternalSelectSourcePersist): DescriptionTemplateExternalSelectSourceEditorModel { - if (item) { - this.url = item.url; - this.sourceBinding = new DescriptionTemplateExternalSelectSourceBindingEditorModel(this.validationErrorModel).fromModel(item.sourceBinding); - this.optionsRoot = item.optionsRoot; - this.hasAuth = item.hasAuth; - this.auth = new DescriptionTemplateExternalSelectAuthDataEditorModel(this.validationErrorModel).fromModel(item.auth); - this.method = item.method; - } - return this; - } - - buildForm(params?: { - context?: ValidationContext, - disabled?: boolean, - rootPath?: string - }): UntypedFormGroup { - let { context = null, disabled = false, rootPath } = params ?? {} - if (context == null) { - context = DescriptionTemplateExternalSelectSourceEditorModel.createValidationContext({ - validationErrorModel: this.validationErrorModel, - rootPath - }); - } - - return this.formBuilder.group({ - url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators], - optionsRoot: [{ value: this.optionsRoot, disabled: disabled }, context.getValidation('optionsRoot').validators], - hasAuth: [{ value: this.hasAuth, disabled: disabled }, context.getValidation('hasAuth').validators], - method: [{ value: this.method, disabled: disabled }, context.getValidation('method').validators], - sourceBinding: this.sourceBinding.buildForm({ - rootPath: `${rootPath}sourceBinding.` - }), - auth: this.auth.buildForm({ - rootPath: `${rootPath}auth.` - }), - }); - } - - static createValidationContext(params: { - rootPath?: string, - validationErrorModel: ValidationErrorModel - }): ValidationContext { - const { rootPath = '', validationErrorModel } = params; - - const baseContext: ValidationContext = new ValidationContext(); - const baseValidationArray: Validation[] = new Array(); - baseValidationArray.push({ key: 'url', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}url`)] }); - baseValidationArray.push({ key: 'optionsRoot', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}optionsRoot`)] }); - baseValidationArray.push({ key: 'hasAuth', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasAuth`)] }); - baseValidationArray.push({ key: 'method', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}method`)] }); - baseValidationArray.push({ key: 'extendedDescription', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}extendedDescription`)] }); - baseValidationArray.push({ key: 'additionalInformation', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}additionalInformation`)] }); - baseValidationArray.push({ key: 'hasCommentField', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasCommentField`)] }); - baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] }); - - baseContext.validation = baseValidationArray; - return baseContext; - } - - static reapplyValidators(params: { - formGroup: UntypedFormGroup, - validationErrorModel: ValidationErrorModel, - rootPath: string - }): void { - - const { formGroup, rootPath, validationErrorModel } = params; - const context = DescriptionTemplateExternalSelectSourceEditorModel.createValidationContext({ - rootPath, - validationErrorModel - }); - - ['url', 'optionsRoot', 'hasAuth', 'method'].forEach(keyField => { - const control = formGroup?.get(keyField); - control?.clearValidators(); - control?.addValidators(context.getValidation(keyField).validators); - }); - - DescriptionTemplateExternalSelectSourceBindingEditorModel.reapplyValidators({ - formGroup: formGroup?.get('sourceBinding') as UntypedFormGroup, - rootPath: `${rootPath}sourceBinding.`, - validationErrorModel: validationErrorModel - }); - - DescriptionTemplateExternalSelectAuthDataEditorModel.reapplyValidators({ - formGroup: formGroup?.get('auth') as UntypedFormGroup, - rootPath: `${rootPath}auth.`, - validationErrorModel: validationErrorModel - }); - - } -} - -export class DescriptionTemplateExternalSelectSourceBindingEditorModel implements DescriptionTemplateExternalSelectSourceBindingPersist { - label: string; - value: string; - source: string; - protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); - - constructor( - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel() - ) { } - - fromModel(item: DescriptionTemplateExternalSelectSourceBinding): DescriptionTemplateExternalSelectSourceBindingEditorModel { - if (item) { - this.label = item.label; - this.value = item.value; - this.source = item.source; - } - return this; - } - - buildForm(params?: { - context?: ValidationContext, - disabled?: boolean, - rootPath?: string - }): UntypedFormGroup { - let { context = null, disabled = false, rootPath } = params ?? {} - if (context == null) { - context = DescriptionTemplateExternalSelectSourceBindingEditorModel.createValidationContext({ - validationErrorModel: this.validationErrorModel, - rootPath - }); - } - - return this.formBuilder.group({ - label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], - value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators], - source: [{ value: this.source, disabled: disabled }, context.getValidation('source').validators], - }); - } - - static createValidationContext(params: { - rootPath?: string, - validationErrorModel: ValidationErrorModel - }): ValidationContext { - const { rootPath = '', validationErrorModel } = params; - - const baseContext: ValidationContext = new ValidationContext(); - const baseValidationArray: Validation[] = new Array(); - baseValidationArray.push({ key: 'label', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); - baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] }); - baseValidationArray.push({ key: 'source', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}source`)] }); - - baseContext.validation = baseValidationArray; - return baseContext; - } - - static reapplyValidators(params: { - formGroup: UntypedFormGroup, - validationErrorModel: ValidationErrorModel, - rootPath: string - }): void { - - const { formGroup, rootPath, validationErrorModel } = params; - const context = DescriptionTemplateExternalSelectSourceBindingEditorModel.createValidationContext({ - rootPath, - validationErrorModel - }); - - ['label', 'value', 'source'].forEach(keyField => { - const control = formGroup?.get(keyField); - control?.clearValidators(); - control?.addValidators(context.getValidation(keyField).validators); - }) - } -} - -export class DescriptionTemplateExternalSelectAuthDataEditorModel implements DescriptionTemplateExternalSelectAuthDataPersist { - url: string; - method: string; - body: string; - path: string; - type: string; - protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); - - constructor( - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel() - ) { } - - fromModel(item: DescriptionTemplateExternalSelectAuthDataPersist): DescriptionTemplateExternalSelectAuthDataEditorModel { - if (item) { - this.url = item.url; - this.method = item.method; - this.body = item.body; - this.path = item.path; - this.type = item.type; - } - return this; - } - - buildForm(params?: { - context?: ValidationContext, - disabled?: boolean, - rootPath?: string - }): UntypedFormGroup { - let { context = null, disabled = false, rootPath } = params ?? {} - if (context == null) { - context = DescriptionTemplateExternalSelectAuthDataEditorModel.createValidationContext({ - validationErrorModel: this.validationErrorModel, - rootPath - }); - } - - return this.formBuilder.group({ - url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators], - method: [{ value: this.method, disabled: disabled }, context.getValidation('method').validators], - body: [{ value: this.body, disabled: disabled }, context.getValidation('body').validators], - path: [{ value: this.path, disabled: disabled }, context.getValidation('path').validators], - type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators], - }); - } - - static createValidationContext(params: { - rootPath?: string, - validationErrorModel: ValidationErrorModel - }): ValidationContext { - const { rootPath = '', validationErrorModel } = params; - - const baseContext: ValidationContext = new ValidationContext(); - const baseValidationArray: Validation[] = new Array(); - baseValidationArray.push({ key: 'url', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}url`)] }); - baseValidationArray.push({ key: 'method', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}method`)] }); - baseValidationArray.push({ key: 'body', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}body`)] }); - baseValidationArray.push({ key: 'path', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}path`)] }); - baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] }); - - baseContext.validation = baseValidationArray; - return baseContext; - } - - static reapplyValidators(params: { - formGroup: UntypedFormGroup, - validationErrorModel: ValidationErrorModel, - rootPath: string - }): void { - - const { formGroup, rootPath, validationErrorModel } = params; - const context = DescriptionTemplateExternalSelectAuthDataEditorModel.createValidationContext({ - rootPath, - validationErrorModel - }); - - ['url', 'method', 'body', 'path', 'type'].forEach(keyField => { + ['referenceTypeId'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); @@ -1586,7 +1291,7 @@ export class DescriptionTemplateRadioBoxDataEditorModel extends DescriptionTempl rootPath: `${rootPath}options[${index}].` }) ), context.getValidation('options').validators - )); + )); return formGroup; } @@ -1733,7 +1438,7 @@ export class DescriptionTemplateSelectDataEditorModel extends DescriptionTemplat rootPath: `${rootPath}options[${index}].` }) ), context.getValidation('options').validators - )); + )); return formGroup; } @@ -1894,7 +1599,7 @@ export class DescriptionTemplateUploadDataEditorModel extends DescriptionTemplat rootPath: `${rootPath}types[${index}].` }) ), context.getValidation('types').validators - )); + )); return formGroup; } diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index b89976b71..11b59922d 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type'; -import { DescriptionTemplate, DescriptionTemplateExternalSelectData, DescriptionTemplateBaseFieldData, DescriptionTemplateSelectOption, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateExternalDatasetData, DescriptionTemplateExternalSelectSource, DescriptionTemplateExternalSelectAuthData, DescriptionTemplateExternalSelectSourceBinding, DescriptionTemplateUploadData, DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; +import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData, DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; @@ -70,20 +70,9 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.multipleSelect)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.options), nameof(x => x.label)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.options), nameof(x => x.value)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.multipleSelect)].join('.'), + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.multipleSelect)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.type)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.url)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.method)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.optionsRoot)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.sourceBinding), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.sourceBinding), nameof(x => x.value)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.sourceBinding), nameof(x => x.source)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.hasAuth)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.auth), nameof(x => x.url)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.auth), nameof(x => x.method)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.auth), nameof(x => x.body)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.auth), nameof(x => x.path)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.sources), nameof(x => x.auth), nameof(x => x.type)].join('.'), + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.referenceTypeId)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.maxFileSizeInMB)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.types), nameof(x => x.label)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.types), nameof(x => x.value)].join('.'), diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html index 7fd040978..1358c0f37 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html @@ -85,19 +85,10 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
- - {{'DMP-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELDS' | translate}} - - {{enumUtils.toDmpBlueprintSystemFieldTypeString(systemFieldType)}} - - -
- +
-
@@ -105,17 +96,27 @@ {{fieldIndex + 1}}
drag_indicator
-
+
- {{'DMP-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD' | translate}} - - {{field.get('dataType').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{'DMP-BLUEPRINT-EDITOR.FIELDS.CATEGORY' | translate}} + + {{enumUtils.toDmpBlueprintFieldCategoryString(fieldCategory)}} +
-
+
- {{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-DATA-TYPE' | translate}} + {{'DMP-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}} + + {{enumUtils.toDmpBlueprintSystemFieldTypeString(systemFieldType)}} + + {{field.get('systemFieldType').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+ + {{'DMP-BLUEPRINT-EDITOR.FIELDS.DATA-TYPE' | translate}} {{enumUtils.toDmpBlueprintExtraFieldDataTypeString(extraFieldDataType)}} @@ -125,7 +126,15 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
+
+ + {{'DMP-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}} + + {{field.get('referenceTypeId').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}} @@ -133,7 +142,7 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
+
{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-PLACEHOLDER' | translate}} @@ -141,7 +150,7 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
+
{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-DESCRIPTION' | translate}} @@ -149,18 +158,13 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
- {{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}} +
+ {{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}} {{field.get('systemFieldType').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
- -
-
-
@@ -174,7 +178,7 @@
- + {{'DMP-BLUEPRINT-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}} {{section.get('hasTemplates').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -185,7 +189,7 @@
- +
@@ -229,7 +233,7 @@ delete
-
+
{{section.get('descriptionTemplates').getError('backendError').message}}
diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts index 18de7bda0..d7571f922 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts @@ -9,18 +9,23 @@ import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { DatePipe } from '@angular/common'; +import { MatCheckboxChange } from '@angular/material/checkbox'; +import { MatSelectChange } from '@angular/material/select'; +import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category'; import { DmpBlueprintExtraFieldDataType } from '@app/core/common/enum/dmp-blueprint-field-type'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status'; import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; -import { DmpBlueprint, DmpBlueprintPersist, NewVersionDmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { DmpBlueprint, DmpBlueprintPersist, NewVersionDmpBlueprintPersist, SystemFieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { AuthService } from '@app/core/services/auth/auth.service'; +import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { LoggingService } from '@app/core/services/logging/logging-service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { BaseEditor } from '@common/base/base-editor'; import { FormService } from '@common/forms/form-service'; import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; @@ -31,15 +36,11 @@ import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; import * as FileSaver from 'file-saver'; import { map, takeUntil } from 'rxjs/operators'; -import { DescriptionTemplatesInSectionEditorModel, DmpBlueprintDefinitionSectionEditorModel, DmpBlueprintEditorModel, FieldInSectionEditorModel } from './dmp-blueprint-editor.model'; +import { DescriptionTemplatePreviewDialogComponent } from '../../description-template/description-template-preview/description-template-preview-dialog.component'; +import { DmpBlueprintEditorModel } from './dmp-blueprint-editor.model'; import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver'; import { DmpBlueprintEditorService } from './dmp-blueprint-editor.service'; -import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; -import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; -import { MatSelectChange } from '@angular/material/select'; -import { DescriptionTemplatePreviewDialogComponent } from '../../description-template/description-template-preview/description-template-preview-dialog.component'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { MatCheckboxChange } from '@angular/material/checkbox'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; @Component({ @@ -56,15 +57,16 @@ export class DmpBlueprintEditorComponent extends BaseEditor = []; - dmpBlueprintSectionFieldCategory = DmpBlueprintSectionFieldCategory; + + dmpBlueprintSectionFieldCategory = DmpBlueprintFieldCategory; dmpBlueprintSystemFieldType = DmpBlueprintSystemFieldType; public dmpBlueprintSystemFieldTypeEnum = this.enumUtils.getEnumValues(DmpBlueprintSystemFieldType); dmpBlueprintExtraFieldDataType = DmpBlueprintExtraFieldDataType; public dmpBlueprintExtraFieldDataTypeEnum = this.enumUtils.getEnumValues(DmpBlueprintExtraFieldDataType); + public dmpBlueprintFieldCategoryEnum = this.enumUtils.getEnumValues(DmpBlueprintFieldCategory); descriptionTempalteGroupSingleAutocompleteConfiguration: SingleAutoCompleteConfiguration = { initialItems: (data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(null, null, null, this.getUsedDescriptionTemplateGroupIds())).pipe(map(x => x.items)), - filterFn: (searchQuery: string, data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(searchQuery, null, null, this.getUsedDescriptionTemplateGroupIds() ? this.getUsedDescriptionTemplateGroupIds(): null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(searchQuery, null, null, this.getUsedDescriptionTemplateGroupIds() ? this.getUsedDescriptionTemplateGroupIds() : null)).pipe(map(x => x.items)), getSelectedItem: (selectedItem: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), displayFn: (item: DescriptionTemplate) => item.label, titleFn: (item: DescriptionTemplate) => item.label, @@ -119,7 +121,8 @@ export class DmpBlueprintEditorComponent extends BaseEditor void): void { - if (this.isNew && !this.isClone && !this.isNewVersion){ + if (this.isNew && !this.isClone && !this.isNewVersion) { const formData = this.formService.getValue(this.formGroup.value) as DmpBlueprintPersist; this.dmpBlueprintService.persist(formData) @@ -303,81 +305,13 @@ export class DmpBlueprintEditorComponent extends BaseEditor (x.get('fields') as FormArray).controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === systemField)); - // for (let section in (this.formGroup.get('definition').get('sections')as FormArray)?.controls) { - // if (i != sectionIndex) { - // for (let f of this.fieldsArray(i).controls) { - // if ((f.get('category').value == FieldCategory.SYSTEM || f.get('category').value == DmpBlueprintSectionFieldCategory.SYSTEM) && f.get('type').value == systemField) { - // return true; - // } - // } - // } - // i++; - // } - // return false; - } - selectedSystemFieldDisabled(): Array { - return (this.formGroup.get('definition').get('sections') as FormArray)?.controls.flatMap(x => (x.get('fields') as FormArray).controls.map(y => (y as UntypedFormGroup).get('systemFieldType')?.value as DmpBlueprintSystemFieldType)); - } - - addSystemField(sectionIndex: number, matSelect: MatSelectChange): void { - let systemFieldTypes = matSelect.value as number[]; - let sectionsFormArray: FormArray = this.formGroup.get('definition').get('sections') as FormArray; - let sectionFieldsFormArray: FormArray = sectionsFormArray.at(sectionIndex).get('fields') as FormArray; - const fieldSize = sectionFieldsFormArray.length; - systemFieldTypes = systemFieldTypes.filter(field => !sectionsFormArray.controls.some(x => (x.get('fields') as FormArray).controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === field))); - for (let systemFieldType of systemFieldTypes) { - sectionFieldsFormArray.push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType)); - // const fieldSize = sectionFieldsFormArray.length; - // if (fieldSize == 0) { - // sectionFieldsFormArray.push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType)); - // return; - // } else { - // if (!sectionFieldsFormArray.controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === systemFieldType)) { - // sectionFieldsFormArray.push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType)); - // return; - // } - // } - } - } - - removeSystemField(sectionIndex: number, fieldIndex: number): void { - const fieldsArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray; - const systemFieldType = fieldsArray.at(fieldIndex).get('systemFieldType').value - if(systemFieldType > -1) { - if (this.selectedSystemFields.length == 1){ - this.selectedSystemFields = []; - }else{ - const index = this.selectedSystemFields.indexOf(systemFieldType); - if (index > -1) { - this.selectedSystemFields.splice(index, 1); - this.selectedSystemFields = [...this.selectedSystemFields]; - } - } - } - fieldsArray.removeAt(fieldIndex); - fieldsArray.controls.forEach((section, index) => { - section.get('ordinal').setValue(index + 1); - }); - - DmpBlueprintEditorModel.reApplySectionValidators( - { - formGroup: this.formGroup, - validationErrorModel: this.editorModel.validationErrorModel - } - ); - fieldsArray.markAsDirty(); - } - - addExtraField(sectionIndex: number): void { + addField(sectionIndex: number) { ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray) - .push(this.editorModel.createChildExtraField(sectionIndex, ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray).length)); - + .push(this.editorModel.createChildField(sectionIndex, ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray).length)); } - removeExtraField(sectionIndex: number, fieldIndex: number): void { + removeField(sectionIndex: number, fieldIndex: number): void { const formArray = ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray); formArray.removeAt(fieldIndex); formArray.controls.forEach((section, index) => { @@ -394,6 +328,21 @@ export class DmpBlueprintEditorComponent extends BaseEditor (x.get('fields') as FormArray).controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === systemField)); + } + + fieldCategoryChanged(sectionIndex: number, fieldIndex: number) { + //Reapply validators + DmpBlueprintEditorModel.reApplySectionValidators( + { + formGroup: this.formGroup, + validationErrorModel: this.editorModel.validationErrorModel + } + ); + (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields').markAsDirty(); + } + dropFields(event: CdkDragDrop, sectionIndex: number) { const fieldsFormArray = ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray); @@ -414,34 +363,34 @@ export class DmpBlueprintEditorComponent extends BaseEditor { const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(index).get('descriptionTemplates') as FormArray; - if (descriptionTempaltesArray.length > 1){ + if (descriptionTempaltesArray.length > 1) { descriptionTempaltesArray.controls.forEach((template, index) => { - if(template.get('descriptionTemplateGroupId').value != undefined) excludedGroupIds.push(template.get('descriptionTemplateGroupId').value as Guid); + if (template.get('descriptionTemplateGroupId').value != undefined) excludedGroupIds.push(template.get('descriptionTemplateGroupId').value as Guid); }) } }); - + return excludedGroupIds; } removeDescriptionTemplate(sectionIndex: number, descriptionTemplateIndex: number): void { - const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray; + const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray; descriptionTempaltesArray.removeAt(descriptionTemplateIndex); DmpBlueprintEditorModel.reApplySectionValidators( @@ -523,12 +472,12 @@ export class DmpBlueprintEditorComponent extends BaseEditor section.fields.some(field => (field.category === DmpBlueprintSectionFieldCategory.SYSTEM || field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM) && field.systemFieldType === DmpBlueprintSystemFieldType.TEXT)); + return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category == DmpBlueprintFieldCategory.System) && (field as SystemFieldInSection).systemFieldType === DmpBlueprintSystemFieldType.Title)); } hasDescription(): boolean { const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value; - return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === DmpBlueprintSectionFieldCategory.SYSTEM || field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM) && field.systemFieldType === DmpBlueprintSystemFieldType.HTML_TEXT)); + return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category == DmpBlueprintFieldCategory.System) && (field as SystemFieldInSection).systemFieldType === DmpBlueprintSystemFieldType.Description)); } hasDescriptionTemplates(): boolean { diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts index 5cfe3ccd9..8a15d2641 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts @@ -1,9 +1,9 @@ import { FormArray, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; +import { DmpBlueprintFieldCategory } from "@app/core/common/enum/dmp-blueprint-field-category"; import { DmpBlueprintExtraFieldDataType } from "@app/core/common/enum/dmp-blueprint-field-type"; -import { DmpBlueprintSectionFieldCategory } from "@app/core/common/enum/dmp-blueprint-section-field-category"; import { DmpBlueprintStatus } from "@app/core/common/enum/dmp-blueprint-status"; import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint-system-field-type"; -import { DescriptionTemplatesInSection, DescriptionTemplatesInSectionPersist, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionPersist, DmpBlueprintDefinitionSection, DmpBlueprintDefinitionSectionPersist, DmpBlueprintPersist, FieldInSection, FieldInSectionPersist } from "@app/core/model/dmp-blueprint/dmp-blueprint"; +import { DescriptionTemplatesInSection, DescriptionTemplatesInSectionPersist, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionPersist, DmpBlueprintDefinitionSection, DmpBlueprintDefinitionSectionPersist, DmpBlueprintPersist, ExtraFieldInSection, FieldInSection, FieldInSectionPersist, ReferenceTypeFieldInSection, SystemFieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint"; import { BaseEditorModel } from "@common/base/base-form-editor-model"; import { BackendErrorValidator } from "@common/forms/validation/custom-validator"; import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model"; @@ -67,22 +67,10 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep return section.buildForm({ rootPath: 'definition.sections[' + index + '].' }); } - createChildSystemField(sectionIndex: number, index: number, systemFieldType: DmpBlueprintSystemFieldType): UntypedFormGroup { - console.log(sectionIndex, index, systemFieldType.toString()); + createChildField(sectionIndex: number, index: number): UntypedFormGroup { const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel); field.id = Guid.create(); field.ordinal = index + 1; - field.category = DmpBlueprintSectionFieldCategory.SYSTEM; - field.systemFieldType = systemFieldType; - field.required = (systemFieldType == DmpBlueprintSystemFieldType.TEXT || systemFieldType == DmpBlueprintSystemFieldType.HTML_TEXT) ? true : false; - return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' }); - } - - createChildExtraField(sectionIndex: number, index: number): UntypedFormGroup { - const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel); - field.id = Guid.create(); - field.ordinal = index + 1; - field.category = DmpBlueprintSectionFieldCategory.EXTRA; return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' }); } @@ -311,14 +299,15 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef export class FieldInSectionEditorModel implements FieldInSectionPersist { public id: Guid; - public category: DmpBlueprintSectionFieldCategory; - public dataType: DmpBlueprintExtraFieldDataType; - public systemFieldType: DmpBlueprintSystemFieldType; + public category: DmpBlueprintFieldCategory; public label: string; public placeholder: string; public description: string; public required: boolean = false; public ordinal: number; + public dataType: DmpBlueprintExtraFieldDataType; + public systemFieldType: DmpBlueprintSystemFieldType; + public referenceTypeId: Guid; protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); @@ -329,13 +318,20 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { fromModel(item: FieldInSection): FieldInSectionEditorModel { this.id = item.id; this.category = item.category; - this.dataType = item.dataType; - this.systemFieldType = item.systemFieldType; this.label = item.label; this.placeholder = item.placeholder; this.description = item.description; this.required = item.required; this.ordinal = item.ordinal; + + if (this.category == DmpBlueprintFieldCategory.System) { + this.systemFieldType = (item as SystemFieldInSection).systemFieldType; + } else if (this.category == DmpBlueprintFieldCategory.Extra) { + this.dataType = (item as ExtraFieldInSection).dataType; + } else if (this.category == DmpBlueprintFieldCategory.ReferenceType) { + this.referenceTypeId = (item as ReferenceTypeFieldInSection).referenceType?.id; + } + return this; } @@ -356,14 +352,14 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators], - dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators], - systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators], - label: [{ value: this.label, disabled: disabled }, this.category === DmpBlueprintSectionFieldCategory.SYSTEM ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators], + label: [{ value: this.label, disabled: disabled }, this.category === DmpBlueprintFieldCategory.System ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators], placeholder: [{ value: this.placeholder, disabled: disabled }, context.getValidation('placeholder').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], required: [{ value: this.required, disabled: disabled }, context.getValidation('required').validators], ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators], - + dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators], + systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators], + referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators], }); } @@ -378,14 +374,15 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); baseValidationArray.push({ key: 'category', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}category`)] }); - baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] }); - baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] }); baseValidationArray.push({ key: 'label-system', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'label-extra', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] }); baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] }); baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] }); + baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] }); + baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] }); + baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] }); baseContext.validation = baseValidationArray; return baseContext; @@ -403,11 +400,20 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { validationErrorModel }); - ['id', 'category', 'dataType', 'systemFieldType', , 'label', 'placeholder', 'description', 'required', 'ordinal'].forEach(keyField => { + ['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'label', 'placeholder', 'description', 'required', 'ordinal'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); if (keyField == 'label') { control?.addValidators(context.has('label-system') ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators); + } else if (keyField == 'referenceTypeId') { + if (formGroup.get('category').value == DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]); + else control?.addValidators([...context.getValidation('referenceTypeId').validators]); + } else if (keyField == 'systemFieldType') { + if (formGroup.get('category').value == DmpBlueprintFieldCategory.System) control?.addValidators([Validators.required, ...context.getValidation('systemFieldType').validators]); + else control?.addValidators([...context.getValidation('systemFieldType').validators]); + } else if (keyField == 'dataType') { + if (formGroup.get('category').value == DmpBlueprintFieldCategory.Extra) control?.addValidators([Validators.required, ...context.getValidation('dataType').validators]); + else control?.addValidators([...context.getValidation('dataType').validators]); } else { control?.addValidators(context.getValidation(keyField).validators); } diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts index da0131a13..c9d62e2ce 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, ExtraFieldInSection, FieldInSection, ReferenceTypeFieldInSection, SystemFieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; @@ -29,13 +30,16 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.referenceType), nameof(x => x.id)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.referenceType), nameof(x => x.name)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.referenceType), nameof(x => x.code)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), diff --git a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html index 73b029153..6023a9d09 100644 --- a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html @@ -40,13 +40,10 @@
{{'REFERENCE-EDITOR.FIELDS.TYPE' | translate}} - - - {{enumUtils.toReferenceTypeString(type)}} - - - {{formGroup.get('type').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + {{formGroup.get('type').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -55,7 +52,7 @@
- {{formGroup.get('description').getError('backendError').message}} + {{formGroup.get('description').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED'| translate}}
@@ -64,7 +61,7 @@ {{'REFERENCE-EDITOR.FIELDS.SOURCE' | translate}} - {{formGroup.get('source').getError('backendError').message}} + {{formGroup.get('source').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -75,8 +72,8 @@ {{enumUtils.toReferenceSourceTypeString(sourceType)}} - - {{formGroup.get('sourceType').getError('backendError').message}} + + {{formGroup.get('sourceType').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -84,7 +81,7 @@ {{'REFERENCE-EDITOR.FIELDS.REFERENCE' | translate}} - {{formGroup.get('reference').getError('backendError').message}} + {{formGroup.get('reference').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -92,16 +89,16 @@ {{'REFERENCE-EDITOR.FIELDS.ABBREVIATION' | translate}} - {{formGroup.get('abbreviation').getError('backendError').message}} + {{formGroup.get('abbreviation').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
- +

{{'REFERENCE-EDITOR.FIELDS.FIELDS' | translate}} - +

@@ -115,12 +112,12 @@
-
+
{{'REFERENCE-EDITOR.FIELDS.CODE' | translate}} - {{field.get('code').getError('backendError').message}} + {{field.get('code').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -131,8 +128,8 @@ {{enumUtils.toReferenceFieldDataTypeString(dataType)}} - - {{field.get('dataType').getError('backendError').message}} + + {{field.get('dataType').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -140,7 +137,7 @@ {{'REFERENCE-EDITOR.FIELDS.VALUE' | translate}} - {{field.get('value').getError('backendError').message}} + {{field.get('value').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
diff --git a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.ts b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.ts index a5741084e..7917784f0 100644 --- a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.ts @@ -3,20 +3,22 @@ import { Component, OnInit } from '@angular/core'; import { FormArray, UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; -import { ReferenceService } from '@app/core/services/reference/reference.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { DatePipe } from '@angular/common'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; +import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type'; +import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; import { Reference, ReferencePersist } from '@app/core/model/reference/reference'; import { AuthService } from '@app/core/services/auth/auth.service'; import { LoggingService } from '@app/core/services/logging/logging-service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { BaseEditor } from '@common/base/base-editor'; import { FormService } from '@common/forms/form-service'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; @@ -25,12 +27,9 @@ import { FilterService } from '@common/modules/text-filter/filter-service'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; import { map, takeUntil } from 'rxjs/operators'; +import { ReferenceEditorModel } from './reference-editor.model'; import { ReferenceEditorResolver } from './reference-editor.resolver'; import { ReferenceEditorService } from './reference-editor.service'; -import { FieldEditorModel, ReferenceEditorModel } from './reference-editor.model'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; -import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type'; @Component({ @@ -45,7 +44,6 @@ export class ReferenceEditorComponent extends BaseEditor(); baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); - baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'type')] }); + baseValidationArray.push({ key: 'typeId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'typeId')] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); baseValidationArray.push({ key: 'reference', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'reference')] }); baseValidationArray.push({ key: 'abbreviation', validators: [BackendErrorValidator(this.validationErrorModel, 'abbreviation')] }); @@ -98,7 +98,7 @@ export class ReferenceEditorModel extends BaseEditorModel implements ReferencePe } export class DefinitionEditorModel implements DefinitionPersist { - fields: FieldEditorModel[]= []; + fields: FieldEditorModel[] = []; protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); diff --git a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.resolver.ts index 87b7ba78e..0c8f4560f 100644 --- a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.resolver.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { Definition, Field, Reference } from '@app/core/model/reference/reference'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; @@ -20,7 +21,7 @@ export class ReferenceEditorResolver extends BaseEditorResolver { ...BaseEditorResolver.lookupFields(), nameof(x => x.id), nameof(x => x.label), - nameof(x => x.type), + [nameof(x => x.type), nameof(x => x.id)].join('.'), nameof(x => x.description), nameof(x => x.reference), nameof(x => x.abbreviation), diff --git a/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.html b/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.html index 1c4b04b95..12a0dd0da 100644 --- a/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.html +++ b/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.html @@ -22,9 +22,8 @@
{{'REFERENCE-LISTING.FILTER.TYPE' | translate}} - - {{enumUtils.toReferenceTypeString(referenceType)}} - + +
@@ -49,4 +48,4 @@ -
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.ts b/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.ts index 425ffbedc..4d1e7d2f0 100644 --- a/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference/listing/filters/reference-listing-filters.component.ts @@ -1,10 +1,11 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { ReferenceFilter } from '@app/core/query/reference.lookup'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { BaseComponent } from '@common/base/base.component'; +import { Guid } from '@common/types/guid'; import { nameof } from 'ts-simple-nameof'; @Component({ @@ -18,7 +19,6 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O @Output() filterChange = new EventEmitter(); referenceSourceTypeEnumValues = this.enumUtils.getEnumValues(ReferenceSourceType) - referenceTypeEnumValues = this.enumUtils.getEnumValues(ReferenceType); // * State internalFilters: ReferenceListingFilters = this._getEmptyFilters(); @@ -26,6 +26,7 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O protected appliedFilterCount: number = 0; constructor( public enumUtils: EnumUtils, + public referenceTypeService: ReferenceTypeService ) { super(); } ngOnInit() { @@ -50,12 +51,12 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O } protected applyFilters(): void { - const { isActive, like, types, sourceTypes } = this.internalFilters ?? {} + const { isActive, like, typeIds, sourceTypes } = this.internalFilters ?? {} this.filterChange.emit({ ...this.filter, like, isActive: isActive ? [IsActive.Active] : [IsActive.Inactive], - types, + typeIds, sourceTypes }) } @@ -66,12 +67,12 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O return this._getEmptyFilters(); } - let { excludedIds, ids, isActive, like, types, sourceTypes } = inputFilter; + let { excludedIds, ids, isActive, like, typeIds, sourceTypes } = inputFilter; return { isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length, like: like, - types: types, + typeIds: typeIds, sourceTypes: sourceTypes } @@ -81,7 +82,7 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O return { isActive: true, like: null, - types: null, + typeIds: null, sourceTypes: null } } @@ -102,6 +103,6 @@ export class ReferenceListingFiltersComponent extends BaseComponent implements O interface ReferenceListingFilters { isActive: boolean; like: string; - types: ReferenceType[]; + typeIds: Guid[]; sourceTypes: ReferenceSourceType[]; } diff --git a/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.html b/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.html index 6f349fd72..5cfb20b66 100644 --- a/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.html @@ -69,7 +69,7 @@ {{'REFERENCE-LISTING.FIELDS.TYPE' | translate}}: - {{enumUtils.toReferenceTypeString(item.type) | nullifyValue}} + {{item?.type?.name | nullifyValue}}
diff --git a/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts b/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts index dc6ed1de6..90b09195c 100644 --- a/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts @@ -22,8 +22,8 @@ import { Observable } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe'; -import { ReferenceTypePipe } from '@common/formatting/pipes/reference-type.pipe'; import { ReferenceSourceTypePipe } from '@common/formatting/pipes/reference-source-type.pipe'; +import { ReferenceType } from '@app/core/model/reference-type/reference-type'; @Component({ templateUrl: './REFERENCE-LISTING.component.html', @@ -110,7 +110,7 @@ export class ReferenceListingComponent extends BaseListingComponent(x => x.type), sortable: true, languageName: 'REFERENCE-LISTING.FIELDS.TYPE', - pipe: this.pipeService.getPipe(ReferenceTypePipe) + valueFunction: (item: Reference) => (item?.type?.name) }, { prop: nameof(x => x.createdAt), diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 12fe1f764..0366aafbb 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -845,7 +845,7 @@ export class DescriptionEditorComponent extends BaseEditor x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => x.reference); - this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference; + //TODO: refactor reference type + //this.references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => x.reference); + //this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference; this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier); } return this; @@ -559,7 +560,8 @@ export class DescriptionReferenceEditorModel implements DescriptionReferencePers fromModel(item: DescriptionReference): DescriptionReferenceEditorModel { this.id = item.id; - this.reference = item.reference; + //TODO: refactor reference type + //this.reference = item.reference; this.hash = item.hash; return this; diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html index 8c1d20051..c4c459ecc 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -15,8 +15,8 @@ {{'GENERAL.VALIDATION.URL.MESSAGE' | translate}} -
-
+
+
@@ -56,25 +56,6 @@
-
-
- - - - - {{propertiesFormGroup?.get(field.id).get('textListValue').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
@@ -204,148 +185,6 @@
-
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
-
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
-
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - \ - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
-
@@ -355,44 +194,6 @@
-
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
-
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts index 8c97dbdb9..032f2df9e 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts @@ -5,10 +5,8 @@ import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { MatDialog } from "@angular/material/dialog"; import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { DescriptionTemplateExternalSelectData, DescriptionTemplateExternalSelectSource, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template'; -import { FetcherReference, Reference } from '@app/core/model/reference/reference'; -import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; +import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template'; +import { FetcherReference } from '@app/core/model/reference/reference'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService } from "@app/core/services/notification/ui-notification-service"; import { ReferenceService } from '@app/core/services/reference/reference.service'; @@ -16,7 +14,6 @@ import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; @@ -41,7 +38,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn // @Input() form: UntypedFormGroup; @Input() datasetProfileId: any; @Input() isChild: Boolean = false; - autocompleteOptions: DescriptionTemplateExternalSelectSource[]; visible: boolean = true; @@ -54,20 +50,10 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn public singleAutoCompleteConfiguration: SingleAutoCompleteConfiguration; public multipleAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - - externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - pubRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - journalRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - taxonomiesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - licensesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - publicationsAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; tagsAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; currencyAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + multipleReferenceAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + readonly separatorKeysCodes: number[] = [ENTER, COMMA]; @@ -154,123 +140,17 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn // } // } - // Setup autocomplete configuration if needed - if (this.field?.data?.fieldType === DescriptionTemplateFieldType.EXTERNAL_SELECT) { - if (!((this.field.data as DescriptionTemplateExternalSelectData).multipleSelect)) { - this.singleAutoCompleteConfiguration = { - filterFn: this.searchFromAutocomplete.bind(this), - initialItems: () => this.searchFromAutocomplete(''), - displayFn: (item) => { try { return (item != null && item.length > 1) ? JSON.parse(item).label : item['label'] } catch { return '' } }, - titleFn: (item) => { try { return item['label'] } catch { return '' } }, - valueAssign: (item) => { try { return JSON.stringify(item) } catch { return '' } }, - subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } } - }; - } - else { - this.multipleAutoCompleteConfiguration = { - filterFn: this.searchFromAutocomplete.bind(this), - initialItems: () => this.searchFromAutocomplete(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label'] } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label'] } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }, - subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } } - } - } - if (isNullOrUndefined(this.datasetProfileId)) { - this.autocompleteOptions = (this.field.data as DescriptionTemplateExternalSelectData).sources; - } - } - switch (this.field?.data?.fieldType) { case DescriptionTemplateFieldType.EXTERNAL_DATASETS: - this.externalDatasetAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDatasets.bind(this), - initialItems: () => this.searchDatasetExternalDatasets(''),//.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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.DATA_REPOSITORIES: - this.dataRepositoriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDataRepositories.bind(this), - initialItems: () => this.searchDatasetExternalDataRepositories(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.PUB_REPOSITORIES: - this.pubRepositoriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalPubRepositories.bind(this), - initialItems: () => this.searchDatasetExternalPubRepositories(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.JOURNAL_REPOSITORIES: - this.journalRepositoriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalJournalRepositories.bind(this), - initialItems: () => this.searchDatasetExternalJournalRepositories(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.TAXONOMIES: - this.taxonomiesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalTaxonomies.bind(this), - initialItems: () => this.searchDatasetExternalTaxonomies(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.LICENSES: - this.licensesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalLicences.bind(this), - initialItems: () => this.searchDatasetExternalLicences(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.PUBLICATIONS: - this.publicationsAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalPublications.bind(this), - initialItems: () => this.searchDatasetExternalPublications(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.REGISTRIES: - this.registriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalRegistries.bind(this), - initialItems: () => this.searchDatasetExternalRegistries(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : 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.SERVICES: - this.servicesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalServices.bind(this), - initialItems: () => this.searchDatasetExternalServices(''), - 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.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; + //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 = { @@ -282,26 +162,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn }; this.parseTags(); break; - case DescriptionTemplateFieldType.RESEARCHERS: - this.researchersAutoCompleteConfiguration = { - filterFn: this.filterResearchers.bind(this), - initialItems: (excludedItems: any[]) => this.filterResearchers('').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.ORGANIZATIONS: - this.organisationsAutoCompleteConfiguration = { - 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.DATASET_IDENTIFIER: // const value = this.propertiesFormGroup.get(this.field.id).get('value').value; // const disabled = this.propertiesFormGroup.get(this.field.id).disabled; @@ -332,9 +193,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn // this.form.disable(); // } break; - case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: - this.makeAutocompleteConfiguration(this.searchResearchers.bind(this), "name", "tag"); - break; case DescriptionTemplateFieldType.INTERNAL_ENTRIES_DESCRIPTIONS: this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label"); break; @@ -344,7 +202,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn } // this.form = this.visibilityRulesService.getFormGroup(this.field.id); - + //TODO: refactor // this.propertiesFormGroup.get(this.field.id).get('value').valueChanges // .pipe( @@ -441,7 +299,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn } makeAutocompleteConfiguration(myfunc: Function, title: string, subtitle?: string): void { - if (!((this.field.data as DescriptionTemplateExternalSelectData).multipleSelect)) { + if (!((this.field.data as DescriptionTemplateLabelAndMultiplicityData).multipleSelect)) { this.singleAutoCompleteConfiguration = { filterFn: myfunc.bind(this), initialItems: (extraData) => myfunc(''), @@ -463,91 +321,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn } } - searchDatasetExternalDatasets(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new ExternalDatasetCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // //return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); - // return this.externalSourcesService.listExternal(ReferenceType.Datasets, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Datasets; - return this.referenceService.search(lookup); - } - - searchDatasetExternalDataRepositories(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.DataRepositories, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.DataRepositories; - return this.referenceService.search(lookup); - } - searchDatasetExternalPubRepositories(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.PubRepositories, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.PubRepositories; - return this.referenceService.search(lookup); - } - searchDatasetExternalJournalRepositories(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.Journals, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Journals; - return this.referenceService.search(lookup); - } - searchDatasetExternalTaxonomies(query: string): Observable { - //TODO refactor - return null; - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new TaxonomyCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.Taxonomies, requestItem.criteria.like, requestItem.criteria.type); - } - searchDatasetExternalLicences(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new LicenseCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.Licenses, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Licenses; - return this.referenceService.search(lookup); - } - searchDatasetExternalPublications(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new PublicationCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - //return this.externalSourcesService.listExternal(ReferenceType.Publications, requestItem.criteria.like, requestItem.criteria.type); - - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Publications; - return this.referenceService.search(lookup); - } - searchDatasetExternalRegistries(query: string): Observable { //TODO refactor return null; @@ -631,26 +404,6 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn // } } - filterOrganisations(value: string): Observable { - //return this.externalSourcesService.searchDMPOrganizations(value); - //return this.externalSourcesService.listExternal(ReferenceType.Organizations, value, ''); - const lookup = new ReferenceSearchLookup(); - lookup.like = value; - lookup.key = ''; - lookup.type = ReferenceType.Organizations; - return this.referenceService.search(lookup); - } - - filterResearchers(value: string): Observable { - //return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }); - //return this.externalSourcesService.listExternal(ReferenceType.Researcher, value, ''); - const lookup = new ReferenceSearchLookup(); - lookup.like = value; - lookup.key = ''; - lookup.type = ReferenceType.Researcher; - return this.referenceService.search(lookup); - } - getDatasetIdControl(name: string): UntypedFormControl { return this.propertiesFormGroup.get(this.field.id).get(name) as UntypedFormControl; } diff --git a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html index cd0b57a03..2bc4c1997 100644 --- a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html +++ b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html @@ -14,7 +14,7 @@ done{{ enumUtils.toDescriptionStatusString(description.status) }} create{{ enumUtils.toDescriptionStatusString(description.status) }} . - {{'DESCRIPTION-LISTING.GRANT' | translate}}: {{referenceService.getReferencesForTypesFirstSafe(description?.dmp?.dmpReferences, [referenceTypeEnum.Grants])?.reference?.label}} + {{'DESCRIPTION-LISTING.GRANT' | translate}}: {{referenceService.getReferencesForTypesFirstSafe(description?.dmp?.dmpReferences, [this.referenceTypeService.getGrantReferenceType()])?.reference?.label}}
{{'DESCRIPTION-LISTING.PART-OF' | translate}} diff --git a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts index f4c5e3bc9..241ed11db 100644 --- a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts @@ -5,7 +5,6 @@ import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { Description } from '@app/core/model/description/description'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DescriptionService } from '@app/core/services/description/description.service'; @@ -14,6 +13,7 @@ import { FileTransformerService } from '@app/core/services/file-transformer/file import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; @@ -44,7 +44,6 @@ export class DescriptionListingItemComponent extends BaseComponent implements On isUserOwner: boolean; descriptionStatusEnum = DescriptionStatus; dmpAccessTypeEnum = DmpAccessType; - referenceTypeEnum = ReferenceType; constructor( @@ -61,6 +60,7 @@ export class DescriptionListingItemComponent extends BaseComponent implements On private fileUtils: FileUtils, public dmpService: DmpService, public referenceService: ReferenceService, + public referenceTypeService: ReferenceTypeService, public fileTransformerService: FileTransformerService ) { super(); diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html index c2d51c832..a72ea117e 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html @@ -59,9 +59,9 @@
-
+
{{'DESCRIPTION-OVERVIEW.GRANT' | translate}}
-
{{referenceService.getReferencesForTypesFirstSafe(description?.dmp?.dmpReferences, [referenceTypeEnum.Grants])?.reference?.label}}
+
{{referenceService.getReferencesForTypesFirstSafe(description?.dmp?.dmpReferences, [this.referenceTypeService.getGrantReferenceType()])?.reference?.label}}
{{'DESCRIPTION-OVERVIEW.RESEARCHERS' | translate}}
diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts index 6e23e99fb..5fc270e5a 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts @@ -9,7 +9,6 @@ import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description, DescriptionStatusPersist } from '@app/core/model/description/description'; import { Dmp, DmpUser, DmpUserRemovePersist } from '@app/core/model/dmp/dmp'; @@ -22,6 +21,7 @@ import { DmpService } from '@app/core/services/dmp/dmp.service'; import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; @@ -53,7 +53,6 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni lockStatus: Boolean; descriptionStatusEnum = DescriptionStatus; dmpAccessTypeEnum = DmpAccessType; - referenceTypeEnum = ReferenceType; dmpStatusEnum = DmpStatus; dmpUserRoleEnum = DmpUserRole; @@ -72,7 +71,8 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni public enumUtils: EnumUtils, private matomoService: MatomoService, private fileUtils: FileUtils, - public fileTransformerService: FileTransformerService + public fileTransformerService: FileTransformerService, + private referenceTypeService: ReferenceTypeService ) { super(); } @@ -92,7 +92,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.description = data; - this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [ReferenceType.Researcher]); + this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); // this.users = this.description.dmp.users; this.checkLockStatus(this.description.id); this.setIsUserOwner(); @@ -117,7 +117,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.description = data; - this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [ReferenceType.Researcher]); + this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); // this.users = this.description.dmp.users; // const breadCrumbs = []; // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" }); diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html index ed45c212a..508c48e5b 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html @@ -132,12 +132,12 @@
-
{{i + 1}}.{{j + 1}} {{enumUtils.toDmpBlueprintSystemFieldTypeString(field.systemFieldType)}}*
+
{{i + 1}}.{{j + 1}} {{enumUtils.toDmpBlueprintSystemFieldTypeString(field.systemFieldType)}}*
{{i + 1}}.{{j + 1}} {{field.label}}*
{{field.description}}
-
-
+
+
@@ -146,29 +146,11 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
+
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
+
@@ -179,7 +161,7 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
-
+
@@ -248,7 +230,7 @@
-
+
@@ -260,7 +242,12 @@
-
+
+
+ +
+
+
{{field.label}} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts index 80c327600..cef5087c4 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts @@ -1,25 +1,36 @@ +import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; +import { FormArray, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; +import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; +import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category'; import { DmpBlueprintExtraFieldDataType } from '@app/core/common/enum/dmp-blueprint-field-type'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; +import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status'; import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; +import { DmpContactType } from '@app/core/common/enum/dmp-contact-type'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { DmpBlueprint } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpPersist } from '@app/core/model/dmp/dmp'; +import { LanguageInfo } from '@app/core/model/language-info'; import { AuthService } from '@app/core/services/auth/auth.service'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; +import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; +import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { LoggingService } from '@app/core/services/logging/logging-service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { UserService } from '@app/core/services/user/user.service'; +import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseEditor } from '@common/base/base-editor'; @@ -33,21 +44,6 @@ import { map, takeUntil } from 'rxjs/operators'; import { DmpEditorModel } from './dmp-editor.model'; import { DmpEditorResolver } from './dmp-editor.resolver'; import { DmpEditorService } from './dmp-editor.service'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { LanguageInfo } from '@app/core/model/language-info'; -import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; -import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FormArray, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; -import { LockPersist } from '@app/core/model/lock/lock.model'; -import { LockTargetType } from '@app/core/common/enum/lock-target-type'; -import { UserService } from '@app/core/services/user/user.service'; -import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; -import { DmpContactType } from '@app/core/common/enum/dmp-contact-type'; -import { MatButtonToggleChange } from '@angular/material/button-toggle'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status'; @Component({ selector: 'app-dmp-editor', @@ -64,10 +60,9 @@ export class DmpEditorComponent extends BaseEditor implemen lockStatus: Boolean = false; step: number = 0; descriptionStatusEnum = DescriptionStatus; - dmpBlueprintSectionFieldCategoryEnum = DmpBlueprintSectionFieldCategory; + dmpBlueprintSectionFieldCategoryEnum = DmpBlueprintFieldCategory; dmpBlueprintSystemFieldTypeEnum = DmpBlueprintSystemFieldType; dmpBlueprintExtraFieldDataTypeEnum = DmpBlueprintExtraFieldDataType; - referenceTypeEnum = ReferenceType; dmpAccessTypeEnum = DmpAccessType; dmpAccessTypeEnumValues = this.enumUtils.getEnumValues(DmpAccessType); dmpContactTypeEnum = DmpContactType; @@ -580,7 +575,7 @@ export class DmpEditorComponent extends BaseEditor implemen - // dmpBlueprintSectionFieldCategory = DmpBlueprintSectionFieldCategory; + // dmpBlueprintSectionFieldCategory = DmpBlueprintFieldCategory; // dmpBlueprintSystemFieldType = DmpBlueprintSystemFieldType; // //public dmpBlueprintSystemFieldTypeEnum = this.enumUtils.getEnumValues(DmpBlueprintSystemFieldType); // dmpBlueprintExtraFieldDataType = DmpBlueprintExtraFieldDataType; @@ -1353,7 +1348,7 @@ export class DmpEditorComponent extends BaseEditor implemen // private buildExtraFields(): void { // const extraFields = new Array(); // this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach(field => { - // if (field.category as unknown == DmpBlueprintSectionFieldCategory.EXTRA) { + // if (field.category as unknown == DmpBlueprintFieldCategory.Extra) { // let extraField = new DmpExtraFieldEditorModel(); // extraField.id = field.id.toString(); // if (!isNullOrUndefined(this.dmp.extraFields)) { @@ -1382,7 +1377,7 @@ export class DmpEditorComponent extends BaseEditor implemen // let hasGrant = false; // this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach( // field => { - // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { + // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { // hasGrant = true; // } // } @@ -1396,7 +1391,7 @@ export class DmpEditorComponent extends BaseEditor implemen // let hasFunder = false; // this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach( // field => { - // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { + // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { // hasFunder = true; // } // } @@ -1410,7 +1405,7 @@ export class DmpEditorComponent extends BaseEditor implemen // let hasProject = false; // this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach( // field => { - // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { + // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { // hasProject = true; // } // } diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts index e50816b13..d6d4d1a00 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts @@ -269,7 +269,8 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist { fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[]): DmpBlueprintValueEditorModel { this.fieldId = item.fieldId; this.fieldValue = item.fieldValue; - this.references = dmpReferences?.filter(x => x.data?.blueprintFieldId === this.fieldId) || []; + //TODO: refactor reference type + // this.references = dmpReferences?.filter(x => x.data?.blueprintFieldId === this.fieldId) || []; return this; } @@ -428,7 +429,7 @@ export class DmpReferenceEditorModel implements DmpReferencePersist { fromModel(item: DmpReference): DmpReferenceEditorModel { this.id = item.id; - this.reference = item.reference; + // this.reference = item.reference; //TODO: refactor reference type this.data = item.data; this.hash = item.hash; diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts index 32b7caedc..baac027e3 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts @@ -1,9 +1,10 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Description } from '@app/core/model/description/description'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, ExtraFieldInSection, FieldInSection, ReferenceTypeFieldInSection, SystemFieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpBlueprintValue, DmpContact, DmpDescriptionTemplate, DmpProperties } from '@app/core/model/dmp/dmp'; import { DmpReference, DmpReferenceData } from '@app/core/model/dmp/dmp-reference'; +import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { Reference } from '@app/core/model/reference/reference'; import { DmpAssociatedUser, User } from '@app/core/model/user/user'; import { DmpService } from '@app/core/services/dmp/dmp.service'; @@ -93,13 +94,16 @@ export class DmpEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.') + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.referenceType), nameof(x => x.id)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.referenceType), nameof(x => x.name)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.referenceType), nameof(x => x.code)].join('.'), ] } diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index 44d3a0bfb..c5fd6000a 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -15,7 +15,7 @@ . {{'DMP-LISTING.VERSION' | translate}} {{dmp.version}} . - {{ 'DMP-LISTING.GRANT' | translate }}: {{referenceService.getReferencesForTypesFirstSafe(dmp?.dmpReferences, [referenceTypeEnum.Grants])?.reference?.label}} + {{ 'DMP-LISTING.GRANT' | translate }}: {{referenceService.getReferencesForTypesFirstSafe(dmp?.dmpReferences, [this.referenceTypeService.getGrantReferenceType()])?.reference?.label}}
{{'DMP-LISTING.CONTAINED-DESCRIPTIONS' | translate}}: ({{ dmp.descriptions?.length }})
diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index 9cc02a874..4f07834e2 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -5,13 +5,14 @@ import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { CloneDmpPersist, Dmp } from '@app/core/model/dmp/dmp'; +import { Dmp } from '@app/core/model/dmp/dmp'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; @@ -22,12 +23,9 @@ import { TranslateService } from '@ngx-translate/core'; import { takeUntil } from 'rxjs/operators'; import { DmpStatus } from '../../../../core/common/enum/dmp-status'; import { AuthService } from '../../../../core/services/auth/auth.service'; -import * as FileSaver from 'file-saver'; -import { FileFormat } from '@app/core/model/file/file-format.model'; -import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { CloneDmpDialogComponent } from '../../clone-dialog/dmp-clone-dialog.component'; -import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-version-dialog.component'; import { DmpInvitationDialogComponent } from '../../invitation/dialog/dmp-invitation-dialog.component'; +import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-version-dialog.component'; @Component({ selector: 'app-dmp-listing-item-component', @@ -45,7 +43,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { isFinalized: boolean; isPublished: boolean; dmpStatusEnum = DmpStatus; - referenceTypeEnum = ReferenceType; constructor( private router: Router, @@ -61,6 +58,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { private httpClient: HttpClient, private matomoService: MatomoService, public referenceService: ReferenceService, + public referenceTypeService: ReferenceTypeService, public fileTransformerService: FileTransformerService, private fileUtils: FileUtils) { super(); diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index ce029b58d..5f4741056 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -54,9 +54,9 @@ delete
-
+
{{'DMP-OVERVIEW.GRANT' | translate}}
-
{{referenceService.getReferencesForTypesFirstSafe(dmp?.dmpReferences, [referenceTypeEnum.Grants])?.reference?.label}}
+
{{referenceService.getReferencesForTypesFirstSafe(dmp?.dmpReferences, [this.referenceTypeService.getGrantReferenceType()])?.reference?.label}}
{{'DESCRIPTION-OVERVIEW.RESEARCHERS' | translate}}
diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index bb0b23b4b..27c4101c7 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -14,7 +14,6 @@ import { Location } from '@angular/common'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { DepositConfiguration } from '@app/core/model/deposit/deposit-configuration'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser, DmpUserRemovePersist } from '@app/core/model/dmp/dmp'; @@ -38,6 +37,7 @@ import * as FileSaver from 'file-saver'; import { takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { DmpInvitationDialogComponent } from '../invitation/dialog/dmp-invitation-dialog.component'; +import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; @Component({ selector: 'app-dmp-overview', @@ -66,7 +66,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { descriptionStatusEnum = DescriptionStatus; dmpAccessTypeEnum = DmpAccessType; - referenceTypeEnum = ReferenceType; dmpStatusEnum = DmpStatus; dmpUserRoleEnum = DmpUserRole; @@ -88,7 +87,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { private fileUtils: FileUtils, public referenceService: ReferenceService, public enumUtils: EnumUtils, - public fileTransformerService: FileTransformerService + public fileTransformerService: FileTransformerService, + private referenceTypeService: ReferenceTypeService ) { super(); } @@ -108,7 +108,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = data; - this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [ReferenceType.Researcher]); + this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); if (!this.hasDoi()) { this.selectedModel = this.dmp.entityDois[0]; } @@ -136,7 +136,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = data; - this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [ReferenceType.Researcher]); + this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); if (!this.hasDoi()) { this.selectedModel = this.dmp.entityDois[0]; } @@ -226,7 +226,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { // let hasGrant = false; // blueprint.sections.forEach(section => section.fields.forEach( // field => { - // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { + // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { // hasGrant = true; // } // } @@ -240,7 +240,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { // let hasFunder = false; // blueprint.sections.forEach(section => section.fields.forEach( // field => { - // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { + // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { // hasFunder = true; // } // } @@ -254,7 +254,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { // let hasProject = false; // blueprint.sections.forEach(section => section.fields.forEach( // field => { - // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { + // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { // hasProject = true; // } // } diff --git a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html index 6f85c7994..2d40b0a0a 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html @@ -1,6 +1,6 @@ - {{label ?? enumUtils.toReferenceTypeString(referenceType)}} - + {{label ?? referenceType?.name}} + {{form.getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts index ce35d8dae..fe9bf2eac 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts @@ -1,10 +1,11 @@ import { Component, Input, OnInit } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; +import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; +import { Guid } from '@common/types/guid'; @Component({ selector: 'app-reference-field-component', @@ -16,7 +17,7 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit { @Input() referenceType: ReferenceType = null; @Input() form: UntypedFormGroup = null; @Input() label: string = null; - @Input() placeholder: string = "Enter text"; + @Input() placeholder: string; multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration; @@ -26,7 +27,7 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit { ) { super(); } ngOnInit() { - this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType); + this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType.id); } addReference() { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 2d4d2d305..2d850c3e9 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1604,13 +1604,13 @@ "SECTION-PREFIX": "Section", "SECTION-NAME": "Section Name", "SECTION-DESCRIPTION": "Section Description", - "SYSTEM-FIELDS": "System Fields", - "SYSTEM-FIELD": "System Field", - "FIELD-TYPE": "Field Type", + "REFERENCE-TYPE": "Reference Type", + "SYSTEM-FIELD-TYPE": "System Field", "FIELD-LABEL": "Label", "FIELD-PLACEHOLDER": "Placeholder", "FIELD-DESCRIPTION": "Description", - "FIELD-DATA-TYPE": "Data Type", + "DATA-TYPE": "Data Type", + "CATEGORY": "Field Type", "FIELD-REQUIRED": "Required", "DESCRIPTION-TEMPLATES": "Description Templates", "DESCRIPTION-TEMPLATE": "Description Template", @@ -1628,9 +1628,8 @@ } }, "ACTIONS": { - "ADD-EXTRA-FIELD": "Add Extra Field", - "REMOVE-SYSTEM-FIELD": "Delete", - "REMOVE-EXTRA-FIELD": "Delete", + "ADD-FIELD": "Add Field", + "REMOVE-FIELD": "Delete", "REMOVE-SECTION": "Remove Section", "ADD-DESCRIPTION-TEMPLATE": "Add Description Template", "REMOVE-DESCRIPTION-TEMPLATE": "Remove Description Template", @@ -2296,16 +2295,10 @@ "DRAFT": "Draft" }, "DMP-BLUEPRINT-SYSTEM-FIELD-TYPE": { - "TEXT": "Title", - "HTML_TEXT": "Description", - "RESEARCHERS": "Researchers", - "ORGANIZATIONS": "Organizations", + "TITLE": "Title", + "DESCRIPTION": "Description", "LANGUAGE": "Language", "CONTACT": "Contact", - "FUNDER": "Funder", - "GRANT": "Grant", - "PROJECT": "Project", - "LICENSE": "License", "ACCESS_RIGHTS": "Access" }, "DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE": { @@ -2433,6 +2426,11 @@ "DMP-CONTACT-TYPE": { "INTERNAL": "Internal", "EXTERNAL": "External" + }, + "DMP-BLUEPRINT-FIELD-CATEGORY": { + "SYSTEM": "System", + "EXTRA": "Custom", + "REFERENCE-TYPE": "External Reference" } }, "ADDRESEARCHERS-EDITOR": { diff --git a/dmp-frontend/src/common/formatting/common-formatting.module.ts b/dmp-frontend/src/common/formatting/common-formatting.module.ts index 788a33ee9..7f85e399c 100644 --- a/dmp-frontend/src/common/formatting/common-formatting.module.ts +++ b/dmp-frontend/src/common/formatting/common-formatting.module.ts @@ -5,15 +5,14 @@ import { DataTableDateOnlyFormatPipe, DateOnlyPipe } from '@common/formatting/pi import { DataTableDateTimeFormatPipe, DateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe'; import { LowercaseFirstLetterPipe } from '@common/formatting/pipes/lowercase-first-letter.pipe'; import { IsActiveTypePipe } from './pipes/is-active-type.pipe'; -import { ReferenceTypePipe } from './pipes/reference-type.pipe'; -import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe'; -import { NotificationTemplateChannelPipe } from './pipes/notification-template-channel.pipe'; -import { NotificationTemplateKindPipe } from './pipes/notification-template-kind.pipe'; -import { NotificationTypePipe } from './pipes/notification-type.pipe'; import { NotificationContactTypePipe } from './pipes/notification-contact-type.pipe'; import { NotificationNotifyStatePipe } from './pipes/notification-notify-state.pipe'; +import { NotificationTemplateChannelPipe } from './pipes/notification-template-channel.pipe'; +import { NotificationTemplateKindPipe } from './pipes/notification-template-kind.pipe'; import { NotificationTrackingProcessPipe } from './pipes/notification-tracking-process.pipe'; import { NotificationTrackingStatePipe } from './pipes/notification-tracking-state.pipe'; +import { NotificationTypePipe } from './pipes/notification-type.pipe'; +import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe'; // // @@ -31,7 +30,6 @@ import { NotificationTrackingStatePipe } from './pipes/notification-tracking-sta DateOnlyPipe, DataTableDateOnlyFormatPipe, IsActiveTypePipe, - ReferenceTypePipe, ReferenceSourceTypePipe, NotificationTemplateChannelPipe, NotificationTemplateKindPipe, @@ -51,7 +49,6 @@ import { NotificationTrackingStatePipe } from './pipes/notification-tracking-sta DateOnlyPipe, DataTableDateOnlyFormatPipe, IsActiveTypePipe, - ReferenceTypePipe, ReferenceSourceTypePipe, NotificationTemplateChannelPipe, NotificationTemplateKindPipe, @@ -71,7 +68,6 @@ import { NotificationTrackingStatePipe } from './pipes/notification-tracking-sta DateOnlyPipe, DataTableDateOnlyFormatPipe, IsActiveTypePipe, - ReferenceTypePipe, ReferenceSourceTypePipe, NotificationTemplateChannelPipe, NotificationTemplateKindPipe, diff --git a/dmp-frontend/src/common/formatting/pipes/reference-type.pipe.ts b/dmp-frontend/src/common/formatting/pipes/reference-type.pipe.ts deleted file mode 100644 index d5276b3e5..000000000 --- a/dmp-frontend/src/common/formatting/pipes/reference-type.pipe.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; - -@Pipe({ name: 'ReferenceTypeFormat' }) -export class ReferenceTypePipe implements PipeTransform { - constructor(private enumUtils: EnumUtils) { } - - public transform(value): any { - return this.enumUtils.toReferenceTypeString(value); - } -}