diff --git a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java index 25fe23812..00e8e4829 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java +++ b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java @@ -114,4 +114,13 @@ public class AuditableAction { public static final EventId Deposit_GetAccessToken = new EventId(18001, "Deposit_GetAccessToken"); public static final EventId Deposit_Deposit = new EventId(18002, "Deposit_Deposit"); public static final EventId Deposit_GetLogo = new EventId(18003, "Deposit_GetLogo"); + + public static final EventId Tag_Query = new EventId(19000, "Tag_Query"); + public static final EventId Tag_Lookup = new EventId(19001, "Tag_Lookup"); + public static final EventId Tag_Persist = new EventId(19002, "Tag_Persist"); + public static final EventId Tag_Delete = new EventId(19003, "Tag_Delete"); + + public static final EventId FileTransformer_GetAvailableConfigurations = new EventId(20000, "FileTransformer_GetAvailableConfigurations"); + + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java b/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java index 75ffc150d..62cc50830 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java +++ b/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java @@ -50,4 +50,8 @@ public class EventBroker { this.applicationEventPublisher.publishEvent(event); } + public void emit(TagTouchedEvent event) { + this.applicationEventPublisher.publishEvent(event); + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java b/dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java new file mode 100644 index 000000000..5d6047f80 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java @@ -0,0 +1,24 @@ +package eu.eudat.event; + +import java.util.UUID; + +public class TagTouchedEvent { + + public TagTouchedEvent() { + } + + public TagTouchedEvent(UUID id) { + this.id = id; + } + + private UUID id; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java b/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java index f815edd2e..0874d3a99 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java @@ -12,95 +12,75 @@ import java.util.UUID; public class Dmp { private UUID id; - public static final String _id = "id"; private String label; - public static final String _label = "label"; private Short version; - public static final String _version = "version"; private DmpStatus status; - public static final String _status = "status"; private DmpVersionStatus versionStatus; - public static final String _versionStatus = "versionStatus"; private String properties; - public static final String _properties = "properties"; private UUID groupId; - public static final String _groupId = "groupId"; private String description; - public static final String _description = "description"; private Instant createdAt; - public static final String _createdAt = "createdAt"; private Instant updatedAt; - public static final String _updatedAt = "updatedAt"; private IsActive isActive; - public static final String _isActive = "isActive"; private Instant finalizedAt; - public static final String _finalizedAt = "finalizedAt"; private Instant publishedAt; - public static final String _publishedAt = "publishedAt"; private User creator; - public static final String _creator = "creator"; private DmpAccessType accessType; - public static final String _accessType = "accessType"; private DmpBlueprint blueprint; - public static final String _blueprint = "blueprint"; private String language; - public static final String _language = "language"; private Instant publicAfter; - public static final String _publicAfter = "publicAfter"; private String hash; - public static final String _hash = "hash"; private List dmpReferences; - public static final String _dmpReferences = "dmpReferences"; private List dmpUsers; - public static final String _dmpUsers = "dmpUsers"; private List descriptions; - public static final String _descriptions = "descriptions"; - private List entityDois; + private List dmpDescriptionTemplates; + public static final String _dmpDescriptionTemplates = "dmpDescriptionTemplates"; + private List entityDois; public static final String _entityDois = "entityDois"; public UUID getId() { @@ -279,6 +259,14 @@ public class Dmp { this.descriptions = descriptions; } + public List getDmpDescriptionTemplates() { + return dmpDescriptionTemplates; + } + + public void setDmpDescriptionTemplates(List dmpDescriptionTemplates) { + this.dmpDescriptionTemplates = dmpDescriptionTemplates; + } + public List getEntityDois() { return entityDois; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java index 061843e29..8db8c2596 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java @@ -3,6 +3,7 @@ package eu.eudat.model.builder; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.enums.EntityType; import eu.eudat.convention.ConventionService; +import eu.eudat.data.DmpDescriptionTemplateEntity; import eu.eudat.data.DmpEntity; import eu.eudat.model.*; import eu.eudat.query.*; @@ -73,6 +74,9 @@ public class DmpBuilder extends BaseBuilder { FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(Dmp._descriptions)); Map> descriptionsMap = this.collectDmpDescriptions(descriptionsFields, data); + FieldSet dmpDescriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpDescriptionTemplates)); + Map> dmpDescriptionTemplatesMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplatesFields, data); + for (DmpEntity d : data) { Dmp m = new Dmp(); if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId()); @@ -97,6 +101,7 @@ public class DmpBuilder extends BaseBuilder { if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId())); if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId())); if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); + if (dmpDescriptionTemplatesMap != null && !dmpDescriptionTemplatesMap.isEmpty() && dmpDescriptionTemplatesMap.containsKey(d.getId())) m.setDmpDescriptionTemplates(dmpDescriptionTemplatesMap.get(d.getId())); models.add(m); } @@ -110,7 +115,7 @@ public class DmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, Dmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, DmpReference._id)); DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); @@ -207,7 +212,7 @@ public class DmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", DmpUser.class.getSimpleName()); Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, Dmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, DmpUser._id)); DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); @@ -225,7 +230,7 @@ public class DmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", Description.class.getSimpleName()); Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Dmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Description._id)); DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); @@ -238,4 +243,22 @@ public class DmpBuilder extends BaseBuilder { return itemMap; } + private Map> collectDmpDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", Description.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpDescriptionTemplate._dmp, DmpDescriptionTemplate._id)); + DmpDescriptionTemplateQuery query = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); + + if (!fields.hasField(this.asIndexer(DmpDescriptionTemplate._dmp, Dmp._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> { + x.getDmp().setId(null); + }); + } + + return itemMap; + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java index 391d15023..eaab7cb1f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java @@ -8,8 +8,6 @@ import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java index a9d623447..361918915 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java @@ -1,28 +1,34 @@ package eu.eudat.model.persist; import eu.eudat.commons.enums.DescriptionStatus; -import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet; -import eu.eudat.commons.validation.old.ValidEnum; -import eu.eudat.commons.validation.old.ValidId; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; +import java.util.List; import java.util.UUID; -@FieldNotNullIfOtherSet(message = "{validation.hashempty}") public class DescriptionStatusPersist { - @NotNull(message = "{validation.empty}") - @ValidId(message = "{validation.invalidid}") private UUID id; - @ValidEnum(message = "{validation.empty}") + public static final String _id = "id"; + private DescriptionStatus status; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _status = "status"; + private String hash; + public static final String _hash = "hash"; + public UUID getId() { return id; } @@ -46,4 +52,40 @@ public class DescriptionStatusPersist { public void setHash(String hash) { this.hash = hash; } + + @Component(DescriptionStatusPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DescriptionStatusPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionStatusPersistValidator"; + + private final MessageSource messageSource; + + protected DescriptionStatusPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return DescriptionStatusPersist.class; + } + + @Override + protected List specifications(DescriptionStatusPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isValidGuid(item.getId())) + .failOn(DescriptionStatusPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> this.isValidGuid(item.getId())) + .must(() -> this.isValidHash(item.getHash())) + .failOn(DescriptionStatusPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._hash}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getStatus())) + .failOn(DescriptionStatusPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._status}, LocaleContextHolder.getLocale())) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java index cde3040b5..2d159f9d1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java @@ -1,55 +1,65 @@ package eu.eudat.model.persist; - import eu.eudat.commons.enums.DescriptionTemplateStatus; -import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet; -import eu.eudat.commons.validation.old.ValidEnum; -import eu.eudat.commons.validation.old.ValidId; -import eu.eudat.data.DescriptionTemplateEntity; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.model.persist.descriptiontemplatedefinition.DefinitionPersist; import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; import java.util.UUID; -@FieldNotNullIfOtherSet(message = "{validation.hashempty}") public class DescriptionTemplatePersist { - @ValidId(message = "{validation.invalidid}") private UUID id; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - @Size(max = DescriptionTemplateEntity._labelLength, message = "{validation.largerthanmax}") private String label = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _label = "label"; + + public static final int _labelLength = 250; + private String description = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _description = "description"; + private String language = null; - @NotNull(message = "{validation.empty}") - @ValidId(message = "{validation.invalidid}") + public static final String _language = "language"; + private UUID type = null; - @ValidEnum(message = "{validation.empty}") + public static final String _type = "type"; + private DescriptionTemplateStatus status; + public static final String _status = "status"; + @NotNull(message = "{validation.empty}") @Valid private DefinitionPersist definition = null; + public static final String _definition = "definition"; + @Valid private List users = null; + public static final String _users = "users"; + private String hash; + public static final String _hash = "hash"; + public UUID getId() { return id; } @@ -121,6 +131,79 @@ public class DescriptionTemplatePersist { public void setUsers(List users) { this.users = users; } + + @Component(DescriptionTemplatePersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DescriptionTemplatePersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplatePersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected DescriptionTemplatePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return DescriptionTemplatePersist.class; + } + + @Override + protected List specifications(DescriptionTemplatePersist item) { + return Arrays.asList( + this.spec() + .iff(() -> this.isValidGuid(item.getId())) + .must(() -> this.isValidHash(item.getHash())) + .failOn(DescriptionTemplatePersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._hash}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isValidGuid(item.getId())) + .must(() -> !this.isValidHash(item.getHash())) + .failOn(DescriptionTemplatePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getLabel())) + .must(() -> this.lessEqual(item.getLabel(), DescriptionTemplatePersist._labelLength)) + .failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getDescription())) + .failOn(DescriptionTemplatePersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._description}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getLanguage())) + .failOn(DescriptionTemplatePersist._language).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._language}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> this.isValidGuid(item.getType())) + .failOn(DescriptionTemplatePersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._type}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getStatus())) + .failOn(DescriptionTemplatePersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._status}, LocaleContextHolder.getLocale())), + + this.spec() + .must(() -> !this.isNull(item.getDefinition())) + .failOn(DescriptionTemplatePersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._definition}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getDefinition())) + .on(DescriptionTemplatePersist._definition) + .over(item.getDefinition()) + .using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)), + this.spec() + .must(() -> !this.isNull(item.getUsers())) + .failOn(DescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getUsers())) + .on(DescriptionTemplatePersist._users) + .over(item.getUsers()) + .using(() -> null) //TODO (thgiannos) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java new file mode 100644 index 000000000..b085a074b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java @@ -0,0 +1,97 @@ +package eu.eudat.model.persist; + + +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.data.TagEntity; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +public class TagPersist { + + private UUID id; + + public final static String _id = "id"; + + private String label = null; + + public final static String _label = "label"; + + private String hash; + + public final static String _hash = "hash"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + @Component(TagPersistValidator.ValidatorName) + @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class TagPersistValidator extends BaseValidator { + public static final String ValidatorName = "TagPersistValidator"; + + private final MessageSource messageSource; + + public TagPersistValidator(MessageSource messageSource, ConventionService conventionService, ErrorThesaurusProperties errors) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return TagPersist.class; + } + + @Override + protected List specifications(TagPersist item) { + return Arrays.asList( + this.spec() + .iff(() -> this.isValidGuid(item.getId())) + .must(() -> this.isValidHash(item.getHash())) + .failOn(TagPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{TagPersist._hash}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isValidGuid(item.getId())) + .must(() -> !this.isValidHash(item.getHash())) + .failOn(TagPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(TagPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{TagPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getLabel())) + .must(() -> this.lessEqual(item.getLabel(), TagEntity._labelLength)) + .failOn(TagPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{TagPersist._label}, LocaleContextHolder.getLocale())) + ); + } + } + +} + diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java index b1fb3aa68..d9896f9c7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java @@ -1,33 +1,87 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class DefinitionPersist { - @NotNull(message = "{validation.empty}") - @Valid - private List sections = null; + private List sections = null; - @NotNull(message = "{validation.empty}") - @Valid - private List pages = null; + public static final String _sections = "sections"; - public List getSections() { - return sections; - } + private List pages = null; - public void setSections(List sections) { - this.sections = sections; - } + public static final String _pages = "pages"; - public List getPages() { - return pages; - } + public List getSections() { + return sections; + } + + public void setSections(List sections) { + this.sections = sections; + } + + public List getPages() { + return pages; + } + + public void setPages(List pages) { + this.pages = pages; + } + + @Component(DefinitionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DefinitionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.DefinitionPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + public DefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return DefinitionPersist.class; + } + + @Override + protected List specifications(DefinitionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getSections())) + .failOn(DefinitionPersist._sections).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._sections}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getSections())) + .on(DefinitionPersist._sections) + .over(item.getSections()) + .using(() -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)), + this.spec() + .must(() -> !this.isNull(item.getPages())) + .failOn(DefinitionPersist._pages).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._pages}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getPages())) + .on(DefinitionPersist._pages) + .over(item.getPages()) + .using(() -> this.validatorFactory.validator(PagePersist.PagePersistValidator.class)) + ); + } + } - public void setPages(List pages) { - this.pages = pages; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java index be84fb58c..bf8fdaef1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java @@ -1,99 +1,215 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; +import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.enums.FieldValidationType; -import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class FieldPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; + private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + public static final String _id = "id"; - private List schematics; + private Integer ordinal = null; - private String defaultValue; + public static final String _ordinal = "ordinal"; - @Valid - private List visibilityRules; + private List schematics; - private List validations; + private String defaultValue; - @NotNull(message = "{validation.empty}") - private Boolean includeInExport = null; + private List visibilityRules; - @NotNull(message = "{validation.empty}") - @Valid - private BaseFieldDataPersist data = null; + public static final String _visibilityRules = "visibilityRules"; - public String getId() { - return id; - } + private List validations; - public void setId(String id) { - this.id = id; - } + private Boolean includeInExport = null; - public Integer getOrdinal() { - return ordinal; - } + public static final String _includeInExport = "includeInExport"; - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } + private BaseFieldDataPersist data = null; - public List getSchematics() { - return schematics; - } + public static final String _data = "data"; - public void setSchematics(List schematics) { - this.schematics = schematics; - } + public String getId() { + return id; + } - public String getDefaultValue() { - return defaultValue; - } + public void setId(String id) { + this.id = id; + } - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } + public Integer getOrdinal() { + return ordinal; + } - public List getVisibilityRules() { - return visibilityRules; - } + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } - public void setVisibilityRules(List visibilityRules) { - this.visibilityRules = visibilityRules; - } + public List getSchematics() { + return schematics; + } - public List getValidations() { - return validations; - } + public void setSchematics(List schematics) { + this.schematics = schematics; + } - public void setValidations(List validations) { - this.validations = validations; - } + public String getDefaultValue() { + return defaultValue; + } - public Boolean getIncludeInExport() { - return includeInExport; - } + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } - public void setIncludeInExport(Boolean includeInExport) { - this.includeInExport = includeInExport; - } + public List getVisibilityRules() { + return visibilityRules; + } - public BaseFieldDataPersist getData() { - return data; - } + public void setVisibilityRules(List visibilityRules) { + this.visibilityRules = visibilityRules; + } + + public List getValidations() { + return validations; + } + + public void setValidations(List validations) { + this.validations = validations; + } + + public Boolean getIncludeInExport() { + return includeInExport; + } + + public void setIncludeInExport(Boolean includeInExport) { + this.includeInExport = includeInExport; + } + + public BaseFieldDataPersist getData() { + return data; + } + + public void setData(BaseFieldDataPersist data) { + this.data = data; + } + + @Component(FieldPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FieldPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.FieldPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected FieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return FieldPersist.class; + } + + @Override + protected List specifications(FieldPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(FieldPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(FieldPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getIncludeInExport())) + .failOn(FieldPersist._includeInExport).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._includeInExport}, LocaleContextHolder.getLocale())), + + this.navSpec() + .iff(() -> !this.isNull(item.getVisibilityRules())) + .on(FieldPersist._visibilityRules) + .over(item.getVisibilityRules()) + .using(() -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.AUTO_COMPLETE) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(AutoCompleteDataPersist.AutoCompleteDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.BOOLEAN_DECISION) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(BooleanDecisionDataPersist.BooleanDecisionPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.INTERNAL_DMP_ENTRIES_DATASETS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(DatasetAutoCompleteDataPersist.DatasetAutoCompleteDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.INTERNAL_DMP_ENTRIES_DMPS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(DmpAutoCompleteDataPersist.DmpAutoCompleteDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.CHECK_BOX) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(CheckBoxDataPersist.CheckBoxDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.DATE_PICKER) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(DatePickerDataPersist.DatePickerDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.EXTERNAL_DATASETS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(ExternalDatasetDataPersist.ExternalDatasetDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.FREE_TEXT) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(FreeTextDataPersist.FreeTextDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.LICENSES) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(LicenseDataPersist.LicenseDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.ORGANIZATIONS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(OrganizationDataPersist.OrganizationDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.PUBLICATIONS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(PublicationDataPersist.PublicationDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.RADIO_BOX) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(RadioBoxDataPersist.RadioBoxDataPersistValidator.class)) + ); + } + } - public void setData(BaseFieldDataPersist data) { - this.data = data; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java index 1cf21610d..fedd67717 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java @@ -1,127 +1,187 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class FieldSetPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; + private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + public static final String _id = "id"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String numbering = null; + private Integer ordinal = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String title = null; + public static final String _ordinal = "ordinal"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String description = null; + private String numbering = null; -// @NotNull(message = "{validation.empty}") -// @NotEmpty(message = "{validation.empty}") - private String extendedDescription = null; - -// @NotNull(message = "{validation.empty}") -// @NotEmpty(message = "{validation.empty}") - private String additionalInformation = null; + public static final String _numbering = "numbering"; - @Valid - private MultiplicityPersist multiplicity= null; + private String title = null; + public static final String _title = "title"; - private Boolean hasCommentField = null; + private String description = null; - @NotNull(message = "{validation.empty}") - @Valid - private List fields = null; + public static final String _description = "description"; - public String getId() { - return id; - } + private String extendedDescription = null; - public void setId(String id) { - this.id = id; - } + private String additionalInformation = null; - public Integer getOrdinal() { - return ordinal; - } + private MultiplicityPersist multiplicity = null; - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } + public static final String _multiplicity = "multiplicity"; - public String getNumbering() { - return numbering; - } + private Boolean hasCommentField = null; - public void setNumbering(String numbering) { - this.numbering = numbering; - } + private List fields = null; - public String getTitle() { - return title; - } + public static final String _fields = "fields"; - public void setTitle(String title) { - this.title = title; - } + public String getId() { + return id; + } - public String getDescription() { - return description; - } + public void setId(String id) { + this.id = id; + } - public void setDescription(String description) { - this.description = description; - } + public Integer getOrdinal() { + return ordinal; + } - public String getExtendedDescription() { - return extendedDescription; - } + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } - public void setExtendedDescription(String extendedDescription) { - this.extendedDescription = extendedDescription; - } + public String getNumbering() { + return numbering; + } - public String getAdditionalInformation() { - return additionalInformation; - } + public void setNumbering(String numbering) { + this.numbering = numbering; + } - public void setAdditionalInformation(String additionalInformation) { - this.additionalInformation = additionalInformation; - } + public String getTitle() { + return title; + } - public MultiplicityPersist getMultiplicity() { - return multiplicity; - } + public void setTitle(String title) { + this.title = title; + } - public void setMultiplicity(MultiplicityPersist multiplicity) { - this.multiplicity = multiplicity; - } + public String getDescription() { + return description; + } - public Boolean getHasCommentField() { - return hasCommentField; - } + public void setDescription(String description) { + this.description = description; + } - public void setHasCommentField(Boolean hasCommentField) { - this.hasCommentField = hasCommentField; - } + public String getExtendedDescription() { + return extendedDescription; + } - public List getFields() { - return fields; - } + public void setExtendedDescription(String extendedDescription) { + this.extendedDescription = extendedDescription; + } + + public String getAdditionalInformation() { + return additionalInformation; + } + + public void setAdditionalInformation(String additionalInformation) { + this.additionalInformation = additionalInformation; + } + + public MultiplicityPersist getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(MultiplicityPersist multiplicity) { + this.multiplicity = multiplicity; + } + + public Boolean getHasCommentField() { + return hasCommentField; + } + + public void setHasCommentField(Boolean hasCommentField) { + this.hasCommentField = hasCommentField; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + @Component(FieldSetPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FieldSetPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.FieldSetPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected FieldSetPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return FieldSetPersist.class; + } + + @Override + protected List specifications(FieldSetPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(FieldSetPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(FieldSetPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getNumbering())) + .failOn(FieldSetPersist._numbering).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._numbering}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTitle())) + .failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getDescription())) + .failOn(FieldSetPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._description}, LocaleContextHolder.getLocale())), + + this.refSpec() + .iff(() -> !this.isNull(item.getMultiplicity())) + .on(FieldSetPersist._multiplicity) + .over(item.getMultiplicity()) + .using(() -> this.validatorFactory.validator(MultiplicityPersist.MultiplicityValidator.class)), + this.navSpec() + .iff(() -> !this.isNull(item.getFields())) + .on(FieldSetPersist._fields) + .over(item.getFields()) + .using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) + ); + } + } - public void setFields(List fields) { - this.fields = fields; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java index d68fe2170..ac6b63ca3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java @@ -1,47 +1,77 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.apache.commons.compress.utils.Lists; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; public class MultiplicityPersist { - private Integer min = null; + private Integer min = null; - private Integer max = null; + private Integer max = null; - private String placeholder = null; + private String placeholder = null; - private Boolean tableView = null; + private Boolean tableView = null; - public Integer getMin() { - return min; - } + public Integer getMin() { + return min; + } - public void setMin(Integer min) { - this.min = min; - } + public void setMin(Integer min) { + this.min = min; + } - public Integer getMax() { - return max; - } + public Integer getMax() { + return max; + } - public void setMax(Integer max) { - this.max = max; - } + public void setMax(Integer max) { + this.max = max; + } - public String getPlaceholder() { - return placeholder; - } + public String getPlaceholder() { + return placeholder; + } - public void setPlaceholder(String placeholder) { - this.placeholder = placeholder; - } + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } - public Boolean getTableView() { - return tableView; - } + public Boolean getTableView() { + return tableView; + } + + public void setTableView(Boolean tableView) { + this.tableView = tableView; + } + + @Component(MultiplicityValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class MultiplicityValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.MultiplicityValidator"; + + protected MultiplicityValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { + super(conventionService, errors); + } + + @Override + protected Class modelClass() { + return MultiplicityPersist.class; + } + + @Override + protected List specifications(MultiplicityPersist item) { + return Lists.newArrayList(); + } + } - public void setTableView(Boolean tableView) { - this.tableView = tableView; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java index a7e14e565..802395039 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java @@ -1,44 +1,90 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import java.util.Arrays; +import java.util.List; public class PagePersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + private String id = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String title = null; + public static final String _id = "id"; - public String getId() { - return id; - } + private Integer ordinal = null; - public void setId(String id) { - this.id = id; - } + public static final String _ordinal = "ordinal"; - public int getOrdinal() { - return ordinal; - } + private String title = null; - public void setOrdinal(int ordinal) { - this.ordinal = ordinal; - } + public static final String _title = "title"; - public String getTitle() { - return title; - } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Component(PagePersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PagePersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.PagePersistValidator"; + + private final MessageSource messageSource; + + protected PagePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return PagePersist.class; + } + + @Override + protected List specifications(PagePersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(PagePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{PagePersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(PagePersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{PagePersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTitle())) + .failOn(PagePersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{PagePersist._title}, LocaleContextHolder.getLocale())) + ); + } + } - public void setTitle(String title) { - this.title = title; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java index 127786f65..a9738f83c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java @@ -1,33 +1,73 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class RulePersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String target = null; + private String target = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String value= null; + public static final String _target = "target"; + private String value = null; - public String getTarget() { - return target; - } + public static final String _value = "value"; - public void setTarget(String target) { - this.target = target; - } + public String getTarget() { + return target; + } - public String getValue() { - return value; - } + public void setTarget(String target) { + this.target = target; + } - public void setValue(String value) { - this.value = value; - } + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Component(RulePersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class RulePersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.RulePersistValidator"; + + private final MessageSource messageSource; + + protected RulePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return RulePersist.class; + } + + @Override + protected List specifications(RulePersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getTarget())) + .failOn(RulePersist._target).failWith(messageSource.getMessage("Validation_Required", new Object[]{RulePersist._target}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(RulePersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{RulePersist._value}, LocaleContextHolder.getLocale())) + ); + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java index 688a8b653..9fae38779 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java @@ -1,118 +1,194 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.ActionConfirmationPersist; +import eu.eudat.model.persist.actionconfirmation.DmpInvitationPersist; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - +import java.util.Arrays; import java.util.List; public class SectionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; + private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + public static final String _id = "id"; - @NotNull(message = "{validation.empty}") - private Boolean defaultVisibility = null; + private Integer ordinal = null; - @NotNull(message = "{validation.empty}") - private Boolean multiplicity = null; + public static final String _ordinal = "ordinal"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String page = null; + private Boolean defaultVisibility = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String title = null; + public static final String _defaultVisibility = "defaultVisibility"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String description = null; + private Boolean multiplicity = null; - @NotNull(message = "{validation.empty}") - @Valid - private List sections = null; - - @NotNull(message = "{validation.empty}") - @Valid - private List fieldSets = null; + public static final String _multiplicity = "multiplicity"; - public String getId() { - return id; - } + private String page = null; - public void setId(String id) { - this.id = id; - } + public static final String _page = "page"; - public int getOrdinal() { - return ordinal; - } + private String title = null; - public void setOrdinal(int ordinal) { - this.ordinal = ordinal; - } + public static final String _title = "title"; - public Boolean getDefaultVisibility() { - return defaultVisibility; - } + private String description = null; - public void setDefaultVisibility(Boolean defaultVisibility) { - this.defaultVisibility = defaultVisibility; - } + public static final String _description = "description"; - public Boolean getMultiplicity() { - return multiplicity; - } + private List sections = null; - public void setMultiplicity(Boolean multiplicity) { - this.multiplicity = multiplicity; - } + public static final String _sections = "sections"; - public String getPage() { - return page; - } + private List fieldSets = null; - public void setPage(String page) { - this.page = page; - } + public static final String _fieldSets = "fieldSets"; - public String getTitle() { - return title; - } + public String getId() { + return id; + } - public void setTitle(String title) { - this.title = title; - } + public void setId(String id) { + this.id = id; + } - public String getDescription() { - return description; - } + public int getOrdinal() { + return ordinal; + } - public void setDescription(String description) { - this.description = description; - } + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } - public List getSections() { - return sections; - } + public Boolean getDefaultVisibility() { + return defaultVisibility; + } - public void setSections(List sections) { - this.sections = sections; - } + public void setDefaultVisibility(Boolean defaultVisibility) { + this.defaultVisibility = defaultVisibility; + } - public List getFieldSets() { - return fieldSets; - } + public Boolean getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(Boolean multiplicity) { + this.multiplicity = multiplicity; + } + + public String getPage() { + return page; + } + + public void setPage(String page) { + this.page = page; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getSections() { + return sections; + } + + public void setSections(List sections) { + this.sections = sections; + } + + public List getFieldSets() { + return fieldSets; + } + + public void setFieldSets(List fieldSets) { + this.fieldSets = fieldSets; + } + + @Component(SectionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class SectionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.SectionPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected SectionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return SectionPersist.class; + } + + @Override + protected List specifications(SectionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(SectionPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(SectionPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getDefaultVisibility())) + .failOn(SectionPersist._defaultVisibility).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._defaultVisibility}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getMultiplicity())) + .failOn(SectionPersist._multiplicity).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._multiplicity}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getPage())) + .failOn(SectionPersist._page).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._page}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTitle())) + .failOn(SectionPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._title}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getDescription())) + .failOn(SectionPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._description}, LocaleContextHolder.getLocale())), + + this.navSpec() + .iff(() -> !this.isNull(item.getSections())) + .on(SectionPersist._sections) + .over(item.getSections()) + .using(() -> this.validatorFactory.validator(SectionPersistValidator.class)), + this.spec() + .must(() -> !this.isNull(item.getFieldSets())) + .failOn(SectionPersist._fieldSets).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._fieldSets}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getFieldSets())) + .on(SectionPersist._fieldSets) + .over(item.getFieldSets()) + .using(() -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class)) + ); + } + } - public void setFieldSets(List fieldSets) { - this.fieldSets = fieldSets; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java index f075bc094..3185f4d68 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java @@ -1,66 +1,113 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +import java.util.Arrays; +import java.util.List; public class AuthAutoCompleteDataPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String url = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String method = null; + private String url = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String body = null; + public static final String _uri = "uri"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String path = null; + private String method = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String type = null; + public static final String _method = "method"; - public String getUrl() { - return url; - } + private String body = null; - public void setUrl(String url) { - this.url = url; - } + public static final String _body = "body"; - public String getMethod() { - return method; - } + private String path = null; - public void setMethod(String method) { - this.method = method; - } + public static final String _path = "path"; - public String getBody() { - return body; - } + private String type = null; - public void setBody(String body) { - this.body = body; - } + public static final String _type = "type"; - public String getPath() { - return path; - } + public String getUrl() { + return url; + } - public void setPath(String path) { - this.path = path; - } + public void setUrl(String url) { + this.url = url; + } - public String getType() { - return type; - } + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class AuthAutoCompleteDataPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.AuthAutoCompleteDataPersistValidator"; + + private final MessageSource messageSource; + + protected AuthAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return AuthAutoCompleteDataPersist.class; + } + + @Override + protected List specifications(AuthAutoCompleteDataPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getUrl())) + .failOn(AuthAutoCompleteDataPersist._uri).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._uri}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getMethod())) + .failOn(AuthAutoCompleteDataPersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._method}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getBody())) + .failOn(AuthAutoCompleteDataPersist._body).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._body}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getPath())) + .failOn(AuthAutoCompleteDataPersist._path).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._path}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getType())) + .failOn(AuthAutoCompleteDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._type}, LocaleContextHolder.getLocale())) + ); + } + } - public void setType(String type) { - this.type = type; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java index 1ccdc7c1c..4c5e1a065 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java @@ -1,20 +1,35 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class AutoCompleteDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; - @NotNull(message = "{validation.empty}") - @Valid + public static final String _multiAutoComplete = "multiAutoComplete"; + private List autoCompleteSingleDataList = null; - public Boolean getMultiAutoComplete() { return multiAutoComplete; } - public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; } + public static final String _autoCompleteSingleDataList = "autoCompleteSingleDataList"; + + public Boolean getMultiAutoComplete() { + return multiAutoComplete; + } + + public void setMultiAutoComplete(Boolean multiAutoComplete) { + this.multiAutoComplete = multiAutoComplete; + } public List getAutoCompleteSingleDataList() { return autoCompleteSingleDataList; @@ -23,5 +38,40 @@ public class AutoCompleteDataPersist extends BaseFieldDataPersist { public void setAutoCompleteSingleDataList(List autoCompleteSingleDataList) { this.autoCompleteSingleDataList = autoCompleteSingleDataList; } + + @Component(AutoCompleteDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class AutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.AutoCompleteDataPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected AutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return AutoCompleteDataPersist.class; + } + + @Override + protected List specifications(AutoCompleteDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.addAll(Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(AutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getAutoCompleteSingleDataList())) + .on(AutoCompleteDataPersist._autoCompleteSingleDataList) + .over(item.getAutoCompleteSingleDataList()) + .using(() -> this.validatorFactory.validator(AutoCompleteSingleDataPersist.AutoCompleteSingleDataPersistValidator.class)) + )); + return specifications; + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java index c300150cc..3671b83c5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java @@ -1,88 +1,157 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class AutoCompleteSingleDataPersist { - @ValidEnum(message = "{validation.empty}") - private AutoCompleteDataEntity.AutocompleteType autocompleteType; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String url = null; - - @Valid - private ComboBoxOptionPersist autoCompleteOptions; - - private String optionsRoot; + private AutoCompleteDataEntity.AutocompleteType autocompleteType; + public static final String _autocompleteType = "autocompleteType"; - @NotNull(message = "{validation.empty}") - private Boolean hasAuth = null; + private String url = null; - @Valid - private AuthAutoCompleteDataPersist auth; + public static final String _url = "url"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String method = null; + private ComboBoxOptionPersist autoCompleteOptions; - public AutoCompleteDataEntity.AutocompleteType getAutocompleteType() { - return autocompleteType; - } + public static final String _autoCompleteOptions = "autoCompleteOptions"; - public void setAutocompleteType(AutoCompleteDataEntity.AutocompleteType autocompleteType) { - this.autocompleteType = autocompleteType; - } + private String optionsRoot; - public String getOptionsRoot() { - return optionsRoot; - } + private Boolean hasAuth = null; - public void setOptionsRoot(String optionsRoot) { - this.optionsRoot = optionsRoot; - } + public static final String _hasAuth = "hasAuth"; - public String getUrl() { - return url; - } + private AuthAutoCompleteDataPersist auth; - public void setUrl(String url) { - this.url = url; - } + public static final String _auth = "auth"; - public Boolean getHasAuth() { - return hasAuth; - } + private String method = null; - public void setHasAuth(Boolean hasAuth) { - this.hasAuth = hasAuth; - } + public static final String _method = "method"; - public AuthAutoCompleteDataPersist getAuth() { - return auth; - } + public AutoCompleteDataEntity.AutocompleteType getAutocompleteType() { + return autocompleteType; + } - public void setAuth(AuthAutoCompleteDataPersist auth) { - this.auth = auth; - } + public void setAutocompleteType(AutoCompleteDataEntity.AutocompleteType autocompleteType) { + this.autocompleteType = autocompleteType; + } - public ComboBoxOptionPersist getAutoCompleteOptions() { - return autoCompleteOptions; - } + public String getOptionsRoot() { + return optionsRoot; + } - public void setAutoCompleteOptions(ComboBoxOptionPersist autoCompleteOptions) { - this.autoCompleteOptions = autoCompleteOptions; - } + public void setOptionsRoot(String optionsRoot) { + this.optionsRoot = optionsRoot; + } - public String getMethod() { - return method; - } + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Boolean getHasAuth() { + return hasAuth; + } + + public void setHasAuth(Boolean hasAuth) { + this.hasAuth = hasAuth; + } + + public AuthAutoCompleteDataPersist getAuth() { + return auth; + } + + public void setAuth(AuthAutoCompleteDataPersist auth) { + this.auth = auth; + } + + public ComboBoxOptionPersist getAutoCompleteOptions() { + return autoCompleteOptions; + } + + public void setAutoCompleteOptions(ComboBoxOptionPersist autoCompleteOptions) { + this.autoCompleteOptions = autoCompleteOptions; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + @Component(AutoCompleteSingleDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class AutoCompleteSingleDataPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.AutoCompleteSingleDataPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected AutoCompleteSingleDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return AutoCompleteSingleDataPersist.class; + } + + @Override + protected List specifications(AutoCompleteSingleDataPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getAutocompleteType())) + .failOn(AutoCompleteSingleDataPersist._autocompleteType).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._autocompleteType}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getUrl())) + .failOn(AutoCompleteSingleDataPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._url}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getHasAuth())) + .failOn(AutoCompleteSingleDataPersist._hasAuth).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._hasAuth}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getMethod())) + .failOn(AutoCompleteSingleDataPersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._method}, LocaleContextHolder.getLocale())), + + this.refSpec() + .iff(() -> !this.isNull(item.getAutoCompleteOptions())) + .on(AutoCompleteSingleDataPersist._autoCompleteOptions) + .over(item.getAutoCompleteOptions()) + .using(() -> this.validatorFactory.validator(ComboBoxOptionPersist.ComboBoxOptionPersistValidator.class)), + this.spec() + .iff(() -> !this.isNull(item.getHasAuth()) && item.getHasAuth()) + .must(() -> !this.isNull(item.getAuth())) + .failOn(AutoCompleteSingleDataPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._auth}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getAuth())) + .on(AutoCompleteSingleDataPersist._auth) + .over(item.getAuth()) + .using(() -> this.validatorFactory.validator(AuthAutoCompleteDataPersist.AuthAutoCompleteDataPersistValidator.class)) + ); + } + } - public void setMethod(String method) { - this.method = method; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java index f64f5eaee..6fe490360 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java @@ -3,67 +3,97 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import eu.eudat.commons.enums.FieldType; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +import java.util.Arrays; +import java.util.List; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - property = "fieldType", - visible = true) + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "fieldType", + visible = true) @JsonSubTypes({ - @JsonSubTypes.Type(value = AutoCompleteDataPersist.class, name = FieldType.Names.Autocomplete), - @JsonSubTypes.Type(value = BooleanDecisionDataPersist.class, name = FieldType.Names.BooleanDecision), - @JsonSubTypes.Type(value = DatasetAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDatasets), - @JsonSubTypes.Type(value = DmpAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDmps), - @JsonSubTypes.Type(value = CheckBoxDataPersist.class, name = FieldType.Names.CheckBox), - @JsonSubTypes.Type(value = DatePickerDataPersist.class, name = FieldType.Names.DatePicker), - @JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets), - @JsonSubTypes.Type(value = FreeTextDataPersist.class, name = FieldType.Names.FreeText), - @JsonSubTypes.Type(value = LicenseDataPersist.class, name = FieldType.Names.Licenses), - @JsonSubTypes.Type(value = OrganizationDataPersist.class, name = FieldType.Names.Organizations), - @JsonSubTypes.Type(value = PublicationDataPersist.class, name = FieldType.Names.Publications), - @JsonSubTypes.Type(value = RadioBoxDataPersist.class, name = FieldType.Names.RadioBox), - @JsonSubTypes.Type(value = RegistryDataPersist.class, name = FieldType.Names.Registries), - @JsonSubTypes.Type(value = ResearcherAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpResearchers), - @JsonSubTypes.Type(value = ResearcherDataPersist.class, name = FieldType.Names.Researchers), - @JsonSubTypes.Type(value = RichTextAreaDataPersist.class, name = FieldType.Names.RichTextarea), - @JsonSubTypes.Type(value = ServiceDataPersist.class, name = FieldType.Names.Services), - @JsonSubTypes.Type(value = TagDataPersist.class, name = FieldType.Names.Tags), - @JsonSubTypes.Type(value = TaxonomyDataPersist.class, name = FieldType.Names.Taxonomies), - @JsonSubTypes.Type(value = TextAreaDataPersist.class, name = FieldType.Names.TextArea), - @JsonSubTypes.Type(value = UploadDataPersist.class, name = FieldType.Names.Upload), - @JsonSubTypes.Type(value = ValidationDataPersist.class, name = FieldType.Names.Validation), - @JsonSubTypes.Type(value = DatasetIdentifierDataPersist.class, name = FieldType.Names.DatasetIdentifier), - @JsonSubTypes.Type(value = CurrencyDataPersist.class, name = FieldType.Names.Currency), - @JsonSubTypes.Type(value = WordListDataPersist.class, name = FieldType.Names.Wordlist), - @JsonSubTypes.Type(value = DataRepositoryDataPersist.class, name = FieldType.Names.DataRepositories), - @JsonSubTypes.Type(value = JournalRepositoryDataPersist.class, name = FieldType.Names.JournalRepositories), - @JsonSubTypes.Type(value = PublicationRepositoryDataPersist.class, name = FieldType.Names.Publications), + @JsonSubTypes.Type(value = AutoCompleteDataPersist.class, name = FieldType.Names.Autocomplete), + @JsonSubTypes.Type(value = BooleanDecisionDataPersist.class, name = FieldType.Names.BooleanDecision), + @JsonSubTypes.Type(value = DatasetAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDatasets), + @JsonSubTypes.Type(value = DmpAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDmps), + @JsonSubTypes.Type(value = CheckBoxDataPersist.class, name = FieldType.Names.CheckBox), + @JsonSubTypes.Type(value = DatePickerDataPersist.class, name = FieldType.Names.DatePicker), + @JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets), + @JsonSubTypes.Type(value = FreeTextDataPersist.class, name = FieldType.Names.FreeText), + @JsonSubTypes.Type(value = LicenseDataPersist.class, name = FieldType.Names.Licenses), + @JsonSubTypes.Type(value = OrganizationDataPersist.class, name = FieldType.Names.Organizations), + @JsonSubTypes.Type(value = PublicationDataPersist.class, name = FieldType.Names.Publications), + @JsonSubTypes.Type(value = RadioBoxDataPersist.class, name = FieldType.Names.RadioBox), + @JsonSubTypes.Type(value = RegistryDataPersist.class, name = FieldType.Names.Registries), + @JsonSubTypes.Type(value = ResearcherAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpResearchers), + @JsonSubTypes.Type(value = ResearcherDataPersist.class, name = FieldType.Names.Researchers), + @JsonSubTypes.Type(value = RichTextAreaDataPersist.class, name = FieldType.Names.RichTextarea), + @JsonSubTypes.Type(value = ServiceDataPersist.class, name = FieldType.Names.Services), + @JsonSubTypes.Type(value = TagDataPersist.class, name = FieldType.Names.Tags), + @JsonSubTypes.Type(value = TaxonomyDataPersist.class, name = FieldType.Names.Taxonomies), + @JsonSubTypes.Type(value = TextAreaDataPersist.class, name = FieldType.Names.TextArea), + @JsonSubTypes.Type(value = UploadDataPersist.class, name = FieldType.Names.Upload), + @JsonSubTypes.Type(value = ValidationDataPersist.class, name = FieldType.Names.Validation), + @JsonSubTypes.Type(value = DatasetIdentifierDataPersist.class, name = FieldType.Names.DatasetIdentifier), + @JsonSubTypes.Type(value = CurrencyDataPersist.class, name = FieldType.Names.Currency), + @JsonSubTypes.Type(value = WordListDataPersist.class, name = FieldType.Names.Wordlist), + @JsonSubTypes.Type(value = DataRepositoryDataPersist.class, name = FieldType.Names.DataRepositories), + @JsonSubTypes.Type(value = JournalRepositoryDataPersist.class, name = FieldType.Names.JournalRepositories), + @JsonSubTypes.Type(value = PublicationRepositoryDataPersist.class, name = FieldType.Names.Publications), }) public abstract class BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String label = null; + private String label = null; - @ValidEnum(message = "{validation.empty}") - private FieldType fieldType; + public static final String _label = "label"; - public String getLabel() { - return label; - } + private FieldType fieldType; - public void setLabel(String label) { - this.label = label; - } + public static final String _fieldType = "fieldType"; - public FieldType getFieldType() { - return fieldType; - } + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public FieldType getFieldType() { + return fieldType; + } + + public void setFieldType(FieldType fieldType) { + this.fieldType = fieldType; + } + + public abstract static class BaseFieldDataPersistValidator extends BaseValidator { + + protected final MessageSource messageSource; + + protected BaseFieldDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + protected List getBaseSpecifications(T item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(BaseFieldDataPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getFieldType())) + .failOn(BaseFieldDataPersist._fieldType).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._fieldType}, LocaleContextHolder.getLocale())) + ); + } + + } - public void setFieldType(FieldType fieldType) { - this.fieldType = fieldType; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java index 2815510f5..13f8d515d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java @@ -1,5 +1,40 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class BooleanDecisionDataPersist extends BaseFieldDataPersist { + @Component(BooleanDecisionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class BooleanDecisionPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.BooleanDecisionPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected BooleanDecisionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return BooleanDecisionDataPersist.class; + } + + @Override + protected List specifications(BooleanDecisionDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java index 81885a3c3..7fe287582 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java @@ -1,6 +1,37 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class CheckBoxDataPersist extends BaseFieldDataPersist { - + @Component(CheckBoxDataPersist.CheckBoxDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class CheckBoxDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.CheckBoxDataPersistValidator"; + + protected CheckBoxDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return CheckBoxDataPersist.class; + } + + @Override + protected List specifications(CheckBoxDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java index c4b358a2e..113e4b04b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java @@ -1,53 +1,103 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class ComboBoxOptionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String label = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String value = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String source = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String uri = null; - public String getLabel() { - return label; - } + private String label = null; - public void setLabel(String label) { - this.label = label; - } + public static final String _label = "label"; - public String getValue() { - return value; - } + private String value = null; - public void setValue(String value) { - this.value = value; - } + public static final String _value = "value"; - public String getSource() { - return source; - } + private String source = null; - public void setSource(String source) { - this.source = source; - } + public static final String _source = "source"; - public String getUri() { - return uri; - } + private String uri = null; - public void setUri(String uri) { - this.uri = uri; - } + public static final String _uri = "uri"; + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + @Component(ComboBoxOptionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ComboBoxOptionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.ComboBoxOptionPersistValidator"; + + private final MessageSource messageSource; + + protected ComboBoxOptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return ComboBoxOptionPersist.class; + } + + @Override + protected List specifications(ComboBoxOptionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(ComboBoxOptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(ComboBoxOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._value}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getSource())) + .failOn(ComboBoxOptionPersist._source).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._source}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getUri())) + .failOn(ComboBoxOptionPersist._uri).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._uri}, LocaleContextHolder.getLocale())) + ); + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java index 13003c3c9..e47c47812 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java @@ -1,15 +1,55 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class DatasetAutoCompleteDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - private Boolean multiAutoComplete = null; - public Boolean getMultiAutoComplete() { - return multiAutoComplete; - } - public void setMultiAutoComplete(Boolean multiAutoComplete) { - this.multiAutoComplete = multiAutoComplete; - } + private Boolean multiAutoComplete = null; + + public static final String _multiAutoComplete = "multiAutoComplete"; + + public Boolean getMultiAutoComplete() { + return multiAutoComplete; + } + + public void setMultiAutoComplete(Boolean multiAutoComplete) { + this.multiAutoComplete = multiAutoComplete; + } + + @Component(DatasetAutoCompleteDataPersist.DatasetAutoCompleteDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DatasetAutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.DatasetAutoCompleteDataPersistValidator"; + + protected DatasetAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return DatasetAutoCompleteDataPersist.class; + } + + @Override + protected List specifications(DatasetAutoCompleteDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(DatasetAutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{DatasetAutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java index 1e3b4ddfb..4e38e4d54 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java @@ -1,4 +1,40 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class DatePickerDataPersist extends BaseFieldDataPersist { + + @Component(DatePickerDataPersist.DatePickerDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DatePickerDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.DatePickerDataPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected DatePickerDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return DatePickerDataPersist.class; + } + + @Override + protected List specifications(DatePickerDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java index c7cec3ea4..ca19f633a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java @@ -1,16 +1,55 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class DmpAutoCompleteDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - private Boolean multiAutoComplete = null; + private Boolean multiAutoComplete = null; + + public static final String _multiAutoComplete = "multiAutoComplete"; + + public Boolean getMultiAutoComplete() { + return multiAutoComplete; + } + + public void setMultiAutoComplete(Boolean multiAutoComplete) { + this.multiAutoComplete = multiAutoComplete; + } + + @Component(DmpAutoCompleteDataPersist.DmpAutoCompleteDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DmpAutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.DmpAutoCompleteDataPersistValidator"; + + protected DmpAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return DmpAutoCompleteDataPersist.class; + } + + @Override + protected List specifications(DmpAutoCompleteDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(DmpAutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpAutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } - public Boolean getMultiAutoComplete() { - return multiAutoComplete; - } - public void setMultiAutoComplete(Boolean multiAutoComplete) { - this.multiAutoComplete = multiAutoComplete; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java index 6ade782c9..001686c1d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java @@ -1,16 +1,28 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; - import eu.eudat.commons.enums.FieldDataExternalDatasetType; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class ExternalDatasetDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; - @ValidEnum(message = "{validation.empty}") + + public static final String _multiAutoComplete = "multiAutoComplete"; + private FieldDataExternalDatasetType type; + public static final String _type = "type"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -26,4 +38,36 @@ public class ExternalDatasetDataPersist extends BaseFieldDataPersist { public void setType(FieldDataExternalDatasetType type) { this.type = type; } + + @Component(ExternalDatasetDataPersist.ExternalDatasetDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ExternalDatasetDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.ExternalDatasetDataPersistValidator"; + + protected ExternalDatasetDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return ExternalDatasetDataPersist.class; + } + + @Override + protected List specifications(ExternalDatasetDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.addAll(Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(ExternalDatasetDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getType())) + .failOn(ExternalDatasetDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._type}, LocaleContextHolder.getLocale())) + + )); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java index caf84f8af..31896b639 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java @@ -1,4 +1,36 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class FreeTextDataPersist extends BaseFieldDataPersist { + + @Component(FreeTextDataPersist.FreeTextDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FreeTextDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.FreeTextDataPersistValidator"; + + protected FreeTextDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return FreeTextDataPersist.class; + } + + @Override + protected List specifications(FreeTextDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java index 2d33a5f18..954d45e15 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java @@ -1,11 +1,22 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class LicenseDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; + public static final String _multiAutoComplete = "multiAutoComplete"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -14,4 +25,31 @@ public class LicenseDataPersist extends BaseFieldDataPersist { this.multiAutoComplete = multiAutoComplete; } + @Component(LicenseDataPersist.LicenseDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class LicenseDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.LicenseDataPersistValidator"; + + protected LicenseDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return LicenseDataPersist.class; + } + + @Override + protected List specifications(LicenseDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(LicenseDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{LicenseDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java index fc5cde675..6055bff29 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java @@ -1,11 +1,22 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class OrganizationDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; + public static final String _multiAutoComplete = "multiAutoComplete"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -14,4 +25,31 @@ public class OrganizationDataPersist extends BaseFieldDataPersist { this.multiAutoComplete = multiAutoComplete; } + @Component(OrganizationDataPersist.OrganizationDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class OrganizationDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.OrganizationDataPersistValidator"; + + protected OrganizationDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return OrganizationDataPersist.class; + } + + @Override + protected List specifications(OrganizationDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(OrganizationDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{OrganizationDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java index db1854960..9ea264215 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java @@ -1,12 +1,22 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.constraints.NotNull; +import java.util.List; public class PublicationDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete; + public static final String _multiAutoComplete = "multiAutoComplete"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -15,4 +25,31 @@ public class PublicationDataPersist extends BaseFieldDataPersist { this.multiAutoComplete = multiAutoComplete; } + @Component(PublicationDataPersist.PublicationDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PublicationDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.PublicationDataPersistValidator"; + + protected PublicationDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return PublicationDataPersist.class; + } + + @Override + protected List specifications(PublicationDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(PublicationDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{PublicationDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java index c50714189..63e48a63e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java @@ -1,16 +1,24 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; - +import java.util.Arrays; import java.util.List; public class RadioBoxDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - @Valid + private List options = null; + public static final String _options = "options"; + public List getOptions() { return options; } @@ -18,4 +26,38 @@ public class RadioBoxDataPersist extends BaseFieldDataPersist { public void setOptions(List options) { this.options = options; } + + @Component(RadioBoxDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class RadioBoxDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.RadioBoxDataPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected RadioBoxDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return RadioBoxDataPersist.class; + } + + @Override + protected List specifications(RadioBoxDataPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getOptions())) + .failOn(RadioBoxDataPersist._options).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxDataPersist._options}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getOptions())) + .on(RadioBoxDataPersist._options) + .over(item.getOptions()) + .using(() -> this.validatorFactory.validator(RadioBoxOptionPersist.RadioBoxOptionPersistValidator.class)) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java index 5fcd6fd47..fc70ea54d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java @@ -1,29 +1,73 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class RadioBoxOptionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String label = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String value = null; - public String getLabel() { - return label; - } + private String label = null; - public void setLabel(String label) { - this.label = label; - } + public static final String _label = "label"; - public String getValue() { - return value; - } + private String value = null; + + public static final String _value = "value"; + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Component(RadioBoxOptionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class RadioBoxOptionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.RadioBoxOptionPersistValidator"; + + private final MessageSource messageSource; + + protected RadioBoxOptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return RadioBoxOptionPersist.class; + } + + @Override + protected List specifications(RadioBoxOptionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(RadioBoxOptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxOptionPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(RadioBoxOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxOptionPersist._value}, LocaleContextHolder.getLocale())) + ); + } + } - public void setValue(String value) { - this.value = value; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java index 8d9b9ff51..e5a48e32a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java @@ -5,7 +5,6 @@ import eu.eudat.commons.validation.ValidatorFactory; import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; -import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -19,54 +18,54 @@ import java.util.List; public class DefinitionPersist { - @NotNull(message = "{validation.empty}") - @Valid - private List fields = null; + @NotNull(message = "{validation.empty}") + @Valid + private List fields = null; - public static final String _fields = "fields"; + public static final String _fields = "fields"; - public List getFields() { - return fields; - } + public List getFields() { + return fields; + } - public void setFields(List fields) { - this.fields = fields; - } + public void setFields(List fields) { + this.fields = fields; + } - @Component(DefinitionPersistValidator.ValidatorName) - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DefinitionPersistValidator extends BaseValidator { + @Component(DefinitionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DefinitionPersistValidator extends BaseValidator { - public static final String ValidatorName = "Reference.DefinitionPersistValidator"; + public static final String ValidatorName = "Reference.DefinitionPersistValidator"; - private final MessageSource messageSource; + private final MessageSource messageSource; - private final ValidatorFactory validatorFactory; + private final ValidatorFactory validatorFactory; - protected DefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { - super(conventionService, errors); + protected DefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } - @Override - protected Class modelClass() { - return DefinitionPersist.class; - } + @Override + protected Class modelClass() { + return DefinitionPersist.class; + } - @Override - protected List specifications(DefinitionPersist item) { - return Arrays.asList( - this.spec() - .must(() -> !this.isNull(item.getFields())) - .failOn(DefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._fields}, LocaleContextHolder.getLocale())), - this.navSpec() - .iff(() -> !this.isNull(item.getFields())) - .on(DefinitionPersist._fields) - .over(item.getFields()) - .using(() -> null) //TODO - ); - } - } + @Override + protected List specifications(DefinitionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getFields())) + .failOn(DefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._fields}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getFields())) + .on(DefinitionPersist._fields) + .over(item.getFields()) + .using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) + ); + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java index 5acd9eb51..655bf5a79 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java @@ -1,24 +1,38 @@ package eu.eudat.model.persist.referencedefinition; import eu.eudat.commons.enums.ReferenceFieldDataType; +import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.old.ValidEnum; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.DescriptionTemplateTypePersist; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class FieldPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String code = null; - @ValidEnum(message = "{validation.empty}") + public static final String _code = "code"; + private ReferenceFieldDataType dataType; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _dataType = "dataType"; + private String value = null; + public static final String _value = "value"; + public String getCode() { return code; } @@ -42,6 +56,41 @@ public class FieldPersist { public void setValue(String value) { this.value = value; } + + @Component(FieldPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FieldPersistValidator extends BaseValidator { + + public static final String ValidatorName = "Reference.FieldPersistValidator"; + + private final MessageSource messageSource; + + protected FieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return FieldPersist.class; + } + + @Override + protected List specifications(FieldPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getCode())) + .failOn(FieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._code}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getDataType())) + .failOn(FieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dataType}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(FieldPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._value}, LocaleContextHolder.getLocale())) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java new file mode 100644 index 000000000..649e24e92 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java @@ -0,0 +1,20 @@ +package eu.eudat.service.tag; + +import eu.eudat.model.Tag; +import eu.eudat.model.persist.TagPersist; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.FieldSet; + +import javax.management.InvalidApplicationException; +import java.util.UUID; + +public interface TagService { + + Tag persist(TagPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException; + + void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java new file mode 100644 index 000000000..d88ecc8a4 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java @@ -0,0 +1,127 @@ +package eu.eudat.service.tag; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.authorization.Permission; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.scope.user.UserScope; +import eu.eudat.convention.ConventionService; +import eu.eudat.data.TagEntity; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.event.EventBroker; +import eu.eudat.event.TagTouchedEvent; +import eu.eudat.model.Tag; +import eu.eudat.model.builder.TagBuilder; +import eu.eudat.model.deleter.TagDeleter; +import eu.eudat.model.persist.TagPersist; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import jakarta.persistence.EntityManager; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Service; + +import javax.management.InvalidApplicationException; +import java.time.Instant; +import java.util.List; +import java.util.UUID; + +@Service +public class TagServiceImpl implements TagService { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagServiceImpl.class)); + + private final EntityManager entityManager; + + private final AuthorizationService authorizationService; + + private final DeleterFactory deleterFactory; + + private final BuilderFactory builderFactory; + + private final ConventionService conventionService; + + private final ErrorThesaurusProperties errors; + + private final MessageSource messageSource; + + private final EventBroker eventBroker; + + private final UserScope userScope; + + + @Autowired + public TagServiceImpl( + EntityManager entityManager, + AuthorizationService authorizationService, + DeleterFactory deleterFactory, + BuilderFactory builderFactory, + ConventionService conventionService, + ErrorThesaurusProperties errors, + MessageSource messageSource, + UserScope userScope, + EventBroker eventBroker) { + this.entityManager = entityManager; + this.authorizationService = authorizationService; + this.deleterFactory = deleterFactory; + this.builderFactory = builderFactory; + this.conventionService = conventionService; + this.errors = errors; + this.messageSource = messageSource; + this.eventBroker = eventBroker; + this.userScope = userScope; + } + + public Tag persist(TagPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException { + logger.debug(new MapLogEntry("persisting data tag").And("model", model).And("fields", fields)); + + this.authorizationService.authorizeForce(Permission.EditTag); + + Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); + + TagEntity data; + if (isUpdate) { + data = this.entityManager.find(TagEntity.class, model.getId()); + if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); + } else { + data = new TagEntity(); + data.setId(UUID.randomUUID()); + data.setIsActive(IsActive.Active); + data.setCreatedAt(Instant.now()); + data.setCreatedById(userScope.getUserId()); + } + + data.setLabel(model.getLabel()); + data.setUpdatedAt(Instant.now()); + if (isUpdate) + this.entityManager.merge(data); + else + this.entityManager.persist(data); + + this.entityManager.flush(); + + this.eventBroker.emit(new TagTouchedEvent(data.getId())); + return this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Tag._id), data); + } + + public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { + logger.debug("deleting tag: {}", id); + + this.authorizationService.authorizeForce(Permission.DeleteTag); + + this.deleterFactory.deleter(TagDeleter.class).deleteAndSaveByIds(List.of(id)); + } + +} + diff --git a/dmp-backend/core/target/maven-archiver/pom.properties b/dmp-backend/core/target/maven-archiver/pom.properties new file mode 100644 index 000000000..bc6d378ce --- /dev/null +++ b/dmp-backend/core/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=core +groupId=eu.eudat +version=1.0.0-SNAPSHOT diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java index 9946d880e..f30bfef5f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java @@ -169,6 +169,7 @@ public class DescriptionController { @PostMapping("persist-status") @Transactional + @ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model") public Description persistStatus(@MyValidate @RequestBody DescriptionStatusPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException { logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); Description persisted = this.descriptionService.persistStatus(model, fieldSet); @@ -197,10 +198,4 @@ public class DescriptionController { return this.descriptionService.export(id, exportType); } - - @GetMapping("/export/formats") - public List getAvailableExportFormats() { - return this.fileTransformerService.getAvailableConfigurations(); - } - } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java index 316cd4678..e2d21174f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java @@ -213,11 +213,6 @@ public class DmpController { return this.dmpService.export(id, exportType); } - @GetMapping("/export/formats") - public List getAvailableExportFormats() { - return this.fileTransformerService.getAvailableConfigurations(); - } - @PostMapping("{id}/invite-users") @Transactional public ResponseEntity inviteUsers(@PathVariable("id") UUID id, @MyValidate @RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException { @@ -234,7 +229,7 @@ public class DmpController { @GetMapping("{id}/token/{token}/invite-accept") @Transactional - public ResponseEntity inviteUsers(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException { + public ResponseEntity acceptInvitation(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException { logger.debug(new MapLogEntry("inviting users to dmp").And("id", id)); this.dmpService.dmpInvitationAccept(token); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/FileTransformerController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/FileTransformerController.java new file mode 100644 index 000000000..2352cd94d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/FileTransformerController.java @@ -0,0 +1,50 @@ +package eu.eudat.controllers.v2; + +import eu.eudat.audit.AuditableAction; +import eu.eudat.controllers.BaseController; +import eu.eudat.file.transformer.model.file.FileFormat; +import eu.eudat.logic.services.ApiContext; +import eu.eudat.service.transformer.FileTransformerService; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.auditing.AuditService; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@CrossOrigin +@RequestMapping(value = {"/api/file-transformer/"}) +public class FileTransformerController extends BaseController { + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerController.class)); + + + private final AuthorizationService authorizationService; + private final FileTransformerService depositService; + private final CensorFactory censorFactory; + private final AuditService auditService; + + @Autowired + public FileTransformerController(ApiContext apiContext, AuthorizationService authorizationService, FileTransformerService depositService, CensorFactory censorFactory, AuditService auditService){ + super(apiContext); + this.authorizationService = authorizationService; + this.depositService = depositService; + this.censorFactory = censorFactory; + this.auditService = auditService; + } + + @GetMapping("/available") + public List getAvailableConfigurations() { + logger.debug(new MapLogEntry("getAvailableConfigurations")); + + List model = this.depositService.getAvailableConfigurations(); + this.auditService.track(AuditableAction.FileTransformer_GetAvailableConfigurations); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + + return model; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java new file mode 100644 index 000000000..dd5a2ba96 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java @@ -0,0 +1,133 @@ +package eu.eudat.controllers.v2; + +import eu.eudat.audit.AuditableAction; +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.validation.ValidationFilterAnnotation; +import eu.eudat.data.TagEntity; +import eu.eudat.logic.services.ApiContext; +import eu.eudat.model.Tag; +import eu.eudat.model.builder.TagBuilder; +import eu.eudat.model.censorship.TagCensor; +import eu.eudat.model.persist.TagPersist; +import eu.eudat.model.result.QueryResult; +import eu.eudat.query.TagQuery; +import eu.eudat.query.lookup.TagLookup; +import eu.eudat.service.tag.TagService; +import gr.cite.tools.auditing.AuditService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import javax.management.InvalidApplicationException; +import java.util.*; + +@RestController +@RequestMapping(path = "api/tag") +public class TagController { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagController.class)); + @Autowired + private ApiContext apiContext; + + private final BuilderFactory builderFactory; + private final AuditService auditService; + + private final TagService tagService; + + private final CensorFactory censorFactory; + + private final QueryFactory queryFactory; + + private final MessageSource messageSource; + + public TagController( + BuilderFactory builderFactory, + AuditService auditService, + TagService tagService, + CensorFactory censorFactory, + QueryFactory queryFactory, + MessageSource messageSource) { + this.builderFactory = builderFactory; + this.auditService = auditService; + this.tagService = tagService; + this.censorFactory = censorFactory; + this.queryFactory = queryFactory; + this.messageSource = messageSource; + } + + @PostMapping("query") + public QueryResult Query(@RequestBody TagLookup lookup) throws MyApplicationException, MyForbiddenException { + logger.debug("querying {}", Tag.class.getSimpleName()); + + this.censorFactory.censor(TagCensor.class).censor(lookup.getProject(), null); + + TagQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic); + + List data = query.collectAs(lookup.getProject()); + List models = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data); + long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size(); + + this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + + return new QueryResult<>(models, count); + } + + @GetMapping("{id}") + public Tag Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + logger.debug(new MapLogEntry("retrieving" + Tag.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + + this.censorFactory.censor(TagCensor.class).censor(fieldSet, null); + + TagQuery query = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id); + Tag model = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet)); + if (model == null) + throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + this.auditService.track(AuditableAction.Tag_Lookup, Map.ofEntries( + new AbstractMap.SimpleEntry("id", id), + new AbstractMap.SimpleEntry("fields", fieldSet) + )); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + + return model; + } + + @PostMapping("persist") + @Transactional + @ValidationFilterAnnotation(validator = TagPersist.TagPersistValidator.ValidatorName, argumentName ="model") + public Tag Persist(@RequestBody TagPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { + logger.debug(new MapLogEntry("persisting" + Tag.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); + Tag persisted = this.tagService.persist(model, fieldSet); + + this.auditService.track(AuditableAction.Tag_Persist, Map.ofEntries( + new AbstractMap.SimpleEntry("model", model), + new AbstractMap.SimpleEntry("fields", fieldSet) + )); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + return persisted; + } + + @DeleteMapping("{id}") + @Transactional + public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException { + logger.debug(new MapLogEntry("retrieving" + Tag.class.getSimpleName()).And("id", id)); + + this.tagService.deleteAndSave(id); + + this.auditService.track(AuditableAction.Tag_Delete, "id", id); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + } +} diff --git a/dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql b/dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql new file mode 100644 index 000000000..d9587bc09 --- /dev/null +++ b/dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql @@ -0,0 +1,17 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.042'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + ALTER TABLE IF EXISTS public."EntityDoi" DROP COLUMN IF EXISTS entity_type; + +ALTER TABLE IF EXISTS public."EntityDoi" + ADD COLUMN entity_type smallint NOT NULL DEFAULT 0; + +ALTER TABLE IF EXISTS public."EntityDoi" + ALTER COLUMN entity_type DROP DEFAULT; + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.042', '2023-12-27 12:00:00.000000+02', now(), 'Change Entity Type To Enum at Entity DOI table'); + +END$$; \ No newline at end of file diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index 6a6f50247..9857bb448 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { ReloadHelperComponent } from '@app/ui/misc/reload-helper/reload-helper.component'; import { Oauth2DialogComponent } from './ui/misc/oauth2-dialog/oauth2-dialog.component'; import { AppComponent } from './app.component'; import { AppPermission } from './core/common/enum/permission.enum'; import { BreadcrumbService } from './ui/misc/breadcrumb/breadcrumb.service'; +import { ReloadHelperComponent } from './ui/misc/reload-helper/reload-helper.component'; const appRoutes: Routes = [ { @@ -71,16 +71,6 @@ const appRoutes: Routes = [ } }, - - - { - path: 'datasetcreatewizard', - loadChildren: () => import('./ui/dataset-create-wizard/dataset-create-wizard.module').then(m => m.DatasetCreateWizardModule), - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASETCREATEWIZARD' - } - }, { path: 'about', @@ -100,22 +90,7 @@ const appRoutes: Routes = [ // } // }, - { - path: 'quick-wizard', - loadChildren: () => import('./ui/quick-wizard/quick-wizard.module').then(m => m.OuickWizardModule), - data: { - breadcrumb: true, - title: "GENERAL.TITLES.QUICK-WIZARD" - } - }, - { - path: 'dataset-profiles', - loadChildren: () => import('./ui/admin/dataset-profile/dataset-profile.module').then(m => m.DatasetProfileModule), - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-PROFILES' - } - }, + { path: 'description-templates', loadChildren: () => import('./ui/admin/description-template/description-template.module').then(m => m.DescriptionTemplateModule), diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index c99d555bd..ab4bfef83 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -1,5 +1,5 @@ import { OverlayModule } from '@angular/cdk/overlay'; -import { HttpClient, HttpClientModule } from '@angular/common/http'; +import { HttpClientModule } from '@angular/common/http'; import { APP_INITIALIZER, LOCALE_ID, NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MAT_MOMENT_DATE_FORMATS, MatMomentDateModule } from '@angular/material-moment-adapter'; @@ -12,10 +12,7 @@ import { AppComponent } from '@app/app.component'; import { CoreServiceModule } from '@app/core/core-service.module'; import { NotificationModule } from '@app/library/notification/notification.module'; import { LoginModule } from '@app/ui/auth/login/login.module'; -import { DatasetCreateWizardModule } from '@app/ui/dataset-create-wizard/dataset-create-wizard.module'; // import { BreadcrumbModule } from '@app/ui/misc/breadcrumb/breadcrumb.module'; -import { HelpContentModule } from '@app/ui/misc/help-content/help-content.module'; -import { NavigationModule } from '@app/ui/misc/navigation/navigation.module'; import { ReloadHelperComponent } from '@app/ui/misc/reload-helper/reload-helper.component'; import { NavbarModule } from '@app/ui/navbar/navbar.module'; import { SidebarModule } from '@app/ui/sidebar/sidebar.module'; @@ -138,12 +135,9 @@ export function InstallationConfigurationFactory(appConfig: ConfigurationService LoginModule, //Ui NotificationModule, - NavigationModule, // BreadcrumbModule, - HelpContentModule, ReactiveFormsModule, FormsModule, - DatasetCreateWizardModule, NavbarModule, SidebarModule, NgcCookieConsentModule.forRoot(cookieConfig), diff --git a/dmp-frontend/src/app/core/common/enum/api-message-code.ts b/dmp-frontend/src/app/core/common/enum/api-message-code.ts deleted file mode 100644 index 1d8c31779..000000000 --- a/dmp-frontend/src/app/core/common/enum/api-message-code.ts +++ /dev/null @@ -1,8 +0,0 @@ -export enum ApiMessageCode { - NO_MESSAGE = 0, - SUCCESS_MESSAGE = 200, - WARN_MESSAGE = 300, - ERROR_MESSAGE = 400, - DEFAULT_ERROR_MESSAGE = 444, - VALIDATION_MESSAGE = 445 -} diff --git a/dmp-frontend/src/app/core/common/enum/auth-provider.ts b/dmp-frontend/src/app/core/common/enum/auth-provider.ts deleted file mode 100644 index 11c36b2a9..000000000 --- a/dmp-frontend/src/app/core/common/enum/auth-provider.ts +++ /dev/null @@ -1,12 +0,0 @@ -export enum AuthProvider { - Google = 1, - Facebook = 2, - Twitter = 3, - LinkedIn = 4, - //NativeLogin=5, - B2Access = 6, - ORCID = 7, - OpenAire = 8, - Configurable = 9, - Zenodo = 10 -} diff --git a/dmp-frontend/src/app/core/common/enum/configurable-provider-type.ts b/dmp-frontend/src/app/core/common/enum/configurable-provider-type.ts deleted file mode 100644 index 8f1a01e8b..000000000 --- a/dmp-frontend/src/app/core/common/enum/configurable-provider-type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ConfigurableProviderType { - Oauth2 = "oauth2", - Saml2 = "saml2" -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/dataset-profile-combo-box-type.ts b/dmp-frontend/src/app/core/common/enum/dataset-profile-combo-box-type.ts deleted file mode 100644 index ba4b9afe2..000000000 --- a/dmp-frontend/src/app/core/common/enum/dataset-profile-combo-box-type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum DatasetProfileComboBoxType { - Autocomplete = "autocomplete", - WordList = "wordlist" -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts b/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts deleted file mode 100644 index f0ed4c47f..000000000 --- a/dmp-frontend/src/app/core/common/enum/dataset-profile-field-view-style.ts +++ /dev/null @@ -1,28 +0,0 @@ -export enum DatasetProfileFieldViewStyle { - TextArea = "textarea", - RichTextArea = "richTextarea", - Table = "table", - Upload = "upload", - BooleanDecision = "booleanDecision", - ComboBox = "combobox", - CheckBox = "checkBox", - FreeText = "freetext", - RadioBox = "radiobox", - DatePicker = "datePicker", - InternalDmpEntities = "internalDmpEntities", - ExternalDatasets = "externalDatasets", - DataRepositories = "dataRepositories", - PubRepositories = "pubRepositories", - JournalRepositories = "journalRepositories", - Taxonomies = "taxonomies", - Licenses = "licenses", - Publications = "publications", - Registries = "registries", - Services = "services", - Tags = "tags", - Researchers = "researchers", - Organizations = "organizations", - DatasetIdentifier = "datasetIdentifier", - Currency = "currency", - Validation = 'validation' -} diff --git a/dmp-frontend/src/app/core/common/enum/dataset-profile-internal-dmp-entities-type.ts b/dmp-frontend/src/app/core/common/enum/dataset-profile-internal-dmp-entities-type.ts deleted file mode 100644 index 22fa64ca5..000000000 --- a/dmp-frontend/src/app/core/common/enum/dataset-profile-internal-dmp-entities-type.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum DatasetProfileInternalDmpEntitiesType { - Researchers = "researchers", - Dmps = "dmps", - Datasets = "datasets" -} diff --git a/dmp-frontend/src/app/core/common/enum/dataset-profile.ts b/dmp-frontend/src/app/core/common/enum/dataset-profile.ts deleted file mode 100644 index fcf5d9224..000000000 --- a/dmp-frontend/src/app/core/common/enum/dataset-profile.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum DatasetProfileEnum { - SAVED = 0, - FINALIZED = 1, - DELETED = 99 -} diff --git a/dmp-frontend/src/app/core/common/enum/dataset-status.ts b/dmp-frontend/src/app/core/common/enum/dataset-status.ts deleted file mode 100644 index adb9461bf..000000000 --- a/dmp-frontend/src/app/core/common/enum/dataset-status.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum DatasetStatus { - Draft = 0, - Finalized = 1, - Canceled = 2, - Deleted = 99 -} diff --git a/dmp-frontend/src/app/core/common/enum/external-dataset-type-enum.ts b/dmp-frontend/src/app/core/common/enum/external-dataset-type-enum.ts deleted file mode 100644 index 241b00ab1..000000000 --- a/dmp-frontend/src/app/core/common/enum/external-dataset-type-enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum ExternalDatasetTypeEnum{ - ReusedDataset = "reused_dataset", - ProducedDataset = "produced_dataset", - Other = "other" -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/external-dataset-type.ts b/dmp-frontend/src/app/core/common/enum/external-dataset-type.ts deleted file mode 100644 index 5d990dda2..000000000 --- a/dmp-frontend/src/app/core/common/enum/external-dataset-type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ExternalDatasetType { - Source = 0, - Output = 1 -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/grant-state-type.ts b/dmp-frontend/src/app/core/common/enum/grant-state-type.ts deleted file mode 100644 index 0f2a392f7..000000000 --- a/dmp-frontend/src/app/core/common/enum/grant-state-type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum GrantStateType { - OnGoing = 0, - Finished = 1 -} diff --git a/dmp-frontend/src/app/core/common/enum/grant-type.ts b/dmp-frontend/src/app/core/common/enum/grant-type.ts deleted file mode 100644 index a61bb1d61..000000000 --- a/dmp-frontend/src/app/core/common/enum/grant-type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum GrantType { - External = 0, - Internal = 1 -} diff --git a/dmp-frontend/src/app/core/common/enum/permission.enum.ts b/dmp-frontend/src/app/core/common/enum/permission.enum.ts index cd71ed394..205ec77ca 100644 --- a/dmp-frontend/src/app/core/common/enum/permission.enum.ts +++ b/dmp-frontend/src/app/core/common/enum/permission.enum.ts @@ -9,11 +9,16 @@ export enum AppPermission { EditDmpBlueprint = "EditDmpBlueprint", DeleteDmpBlueprint = "DeleteDmpBlueprint", - //DmpBlueprint + //Description BrowseDescription = "BrowseDescription", EditDescription = "EditDescription", DeleteDescription= "DeleteDescription", + //Dmp + BrowseDmp = "BrowseDmp", + EditDmp = "EditDmp", + DeleteDmp= "DeleteDmp", + //DescriptionTemplateType BrowseDescriptionTemplate = "BrowseDescriptionTemplate", EditDescriptionTemplate = "EditDescriptionTemplate", diff --git a/dmp-frontend/src/app/core/common/enum/project-type.ts b/dmp-frontend/src/app/core/common/enum/project-type.ts deleted file mode 100644 index 3355f80ed..000000000 --- a/dmp-frontend/src/app/core/common/enum/project-type.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ProjectType { - External = 0, - Internal = 1 -} diff --git a/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts b/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts index 7956e8ee5..461d88ae2 100644 --- a/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts +++ b/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts @@ -1,14 +1,5 @@ export enum RecentActivityOrder { UpdatedAt = 0, Label = 1, - Status = 2, - - //TODO: delete them since these are from the prerefactor model - LABEL = "label", - CREATED = "created", - MODIFIED = "modified", - FINALIZED = "finalizedAt", - PUBLISHED = "publishedAt", - DATASETPUBLISHED = "dmp:publishedAt|join|", - STATUS = "status" + Status = 2 } diff --git a/dmp-frontend/src/app/core/common/enum/role.ts b/dmp-frontend/src/app/core/common/enum/role.ts deleted file mode 100644 index a11abaf81..000000000 --- a/dmp-frontend/src/app/core/common/enum/role.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum Role { - Owner = 0, - Member = 1 -} diff --git a/dmp-frontend/src/app/core/common/enum/save-type.ts b/dmp-frontend/src/app/core/common/enum/save-type.ts deleted file mode 100644 index 855a3109a..000000000 --- a/dmp-frontend/src/app/core/common/enum/save-type.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum SaveType { - close = 0, - addNew = 1, - finalize = 2 -} diff --git a/dmp-frontend/src/app/core/common/enum/status.ts b/dmp-frontend/src/app/core/common/enum/status.ts deleted file mode 100644 index 536a52ec8..000000000 --- a/dmp-frontend/src/app/core/common/enum/status.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum Status { - Active = 0, - Inactive = 1 -} diff --git a/dmp-frontend/src/app/core/common/enum/validation-type.ts b/dmp-frontend/src/app/core/common/enum/validation-type.ts index d6a206e28..68429b707 100644 --- a/dmp-frontend/src/app/core/common/enum/validation-type.ts +++ b/dmp-frontend/src/app/core/common/enum/validation-type.ts @@ -6,6 +6,7 @@ export enum ValidationType { URL = 2 } +//TODO: move this export class ValidatorURL { public static regex = 'https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' + diff --git a/dmp-frontend/src/app/core/core-service.module.ts b/dmp-frontend/src/app/core/core-service.module.ts index 9e6ae0795..ae5601e81 100644 --- a/dmp-frontend/src/app/core/core-service.module.ts +++ b/dmp-frontend/src/app/core/core-service.module.ts @@ -7,64 +7,43 @@ import { AuthService } from './services/auth/auth.service'; import { ContactSupportService } from './services/contact-support/contact-support.service'; import { CultureService } from './services/culture/culture-service'; import { LanguageInfoService } from './services/culture/language-info-service'; -import { CurrencyService } from './services/currency/currency.service'; import { DashboardService } from './services/dashboard/dashboard.service'; -import { DatasetProfileService } from './services/dataset-profile/dataset-profile.service'; -import { DatasetWizardService } from './services/dataset-wizard/dataset-wizard.service'; -import { DatasetExternalAutocompleteService } from './services/dataset/dataset-external-autocomplete.service'; -import { DatasetService } from './services/dataset/dataset.service'; -import { DepositRepositoriesService } from './services/deposit-repositories/deposit-repositories.service'; +import { DepositService } from './services/deposit/deposit.service'; import { DescriptionTemplateTypeService } from './services/description-template-type/description-template-type.service'; import { DmpBlueprintService } from './services/dmp/dmp-blueprint.service'; -import { DmpInvitationService } from './services/dmp/dmp-invitation.service'; -import { DmpService, DmpServiceNew } from './services/dmp/dmp.service'; -import { EmailConfirmationService } from './services/email-confirmation/email-confirmation.service'; -import { ExternalDataRepositoryService } from './services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDatasetService } from './services/external-sources/dataset/external-dataset.service'; -import { ExternalSourcesConfigurationService } from './services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from './services/external-sources/external-sources.service'; -import { ExternalRegistryService } from './services/external-sources/registry/external-registry.service'; -import { ExternalResearcherService } from './services/external-sources/researcher/external-researcher.service'; -import { ExternalServiceService } from './services/external-sources/service/external-service.service'; -import { FunderService } from './services/funder/funder.service'; -import { GrantFileUploadService } from './services/grant/grant-file-upload.service'; -import { GrantService } from './services/grant/grant.service'; +import { DmpService } from './services/dmp/dmp.service'; import { BaseHttpV2Service } from './services/http/base-http-v2.service'; -import { BaseHttpService } from './services/http/base-http.service'; import { LanguageService } from './services/language/language.service'; import { LockService } from './services/lock/lock.service'; import { LoggingService } from './services/logging/logging-service'; -import { MergeEmailConfirmationService } from './services/merge-email-confirmation/merge-email-confirmation.service'; import { UiNotificationService } from './services/notification/ui-notification-service'; -import { OrganisationService } from './services/organisation/organisation.service'; import { ProgressIndicationService } from './services/progress-indication/progress-indication-service'; -import { ProjectService } from './services/project/project.service'; -import { QuickWizardService } from './services/quick-wizard/quick-wizard.service'; -import { SearchBarService } from './services/search-bar/search-bar.service'; import { TimezoneService } from './services/timezone/timezone-service'; -import { UnlinkAccountEmailConfirmationService } from './services/unlink-account-email-confirmation/unlink-account-email-confirmation.service'; -import { UserServiceOld } from './services/user/user.service-old'; import { CollectionUtils } from './services/utilities/collection-utils.service'; import { TypeUtils } from './services/utilities/type-utils.service'; import { SpecialAuthGuard } from './special-auth-guard.service'; //import { KeycloakService } from 'keycloak-angular'; +import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; import { FilterService } from '@common/modules/text-filter/filter-service'; import { DescriptionTemplateService } from './services/description-template/description-template.service'; +import { DescriptionService } from './services/description/description.service'; +import { FileTransformerService } from './services/file-transformer/file-transformer.service'; import { PrincipalService } from './services/http/principal.service'; +import { LanguageHttpService } from './services/language/language.http.service'; +import { MaintenanceService } from './services/maintenance/maintenance.service'; +import { NotificationTemplateService } from './services/notification-template/notification-template.service'; import { ReferenceTypeService } from './services/reference-type/reference-type.service'; import { ReferenceService } from './services/reference/reference.service'; import { SupportiveMaterialService } from './services/supportive-material/supportive-material.service'; +import { TagService } from './services/tag/tag.service'; import { TenantService } from './services/tenant/tenant.service'; import { UserSettingsHttpService } from './services/user-settings/user-settings-http.service'; import { UserSettingsService } from './services/user-settings/user-settings.service'; import { UserService } from './services/user/user.service'; import { FileUtils } from './services/utilities/file-utils.service'; import { QueryParamsService } from './services/utilities/query-params.service'; -import { LanguageHttpService } from './services/language/language.http.service'; -import { DescriptionService } from './services/description/description.service'; -import { MaintenanceService } from './services/maintenance/maintenance.service'; -import { NotificationTemplateService } from './services/notification-template/notification-template.service'; +import { FileTransformerHttpService } from './services/file-transformer/file-transformer.http.service'; // // // This is shared module that provides all the services. Its imported only once on the AppModule. @@ -86,7 +65,6 @@ export class CoreServiceModule { providers: [ AuthService, CookieService, - BaseHttpService, BaseHttpV2Service, AdminAuthGuard, SpecialAuthGuard, @@ -98,39 +76,14 @@ export class CoreServiceModule { UiNotificationService, ProgressIndicationService, LoggingService, - SearchBarService, DashboardService, - GrantService, - ProjectService, - FunderService, - GrantFileUploadService, - DmpService, - DepositRepositoriesService, + DepositService, DmpBlueprintService, - ExternalSourcesService, - ExternalSourcesConfigurationService, - DatasetService, - DatasetWizardService, - ExternalDatasetService, - ExternalDataRepositoryService, - ExternalRegistryService, - ExternalResearcherService, - ExternalServiceService, - DatasetProfileService, - UserServiceOld, - DmpInvitationService, - DatasetExternalAutocompleteService, - QuickWizardService, - OrganisationService, - EmailConfirmationService, ContactSupportService, LanguageService, LockService, PrincipalService, SupportiveMaterialService, - CurrencyService, - MergeEmailConfirmationService, - UnlinkAccountEmailConfirmationService, LanguageInfoService, PrefillingService, DescriptionTemplateTypeService, @@ -146,10 +99,14 @@ export class CoreServiceModule { TenantService, UserService, LanguageHttpService, - DmpServiceNew, + DmpService, DescriptionService, MaintenanceService, - NotificationTemplateService + NotificationTemplateService, + TagService, + CanDeactivateGuard, + FileTransformerService, + FileTransformerHttpService ], }; } diff --git a/dmp-frontend/src/app/core/formatting.module.ts b/dmp-frontend/src/app/core/formatting.module.ts index efa153368..b5ca3f3c0 100644 --- a/dmp-frontend/src/app/core/formatting.module.ts +++ b/dmp-frontend/src/app/core/formatting.module.ts @@ -9,7 +9,6 @@ import { JsonParserPipe } from './pipes/json-parser.pipe'; import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe'; import {FieldValuePipe} from "@app/core/pipes/field-value.pipe"; import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe"; -import { DatasetInSectioPipe } from './pipes/dataset-in-section.pipe'; import { PipeService } from '@common/formatting/pipe.service'; // @@ -28,7 +27,6 @@ import { PipeService } from '@common/formatting/pipe.service'; JsonParserPipe, FieldValuePipe, ColumnClassPipe, - DatasetInSectioPipe, ], exports: [ NgForLimitPipe, @@ -39,7 +37,6 @@ import { PipeService } from '@common/formatting/pipe.service'; JsonParserPipe, FieldValuePipe, ColumnClassPipe, - DatasetInSectioPipe ], providers: [ EnumUtils, @@ -53,7 +50,6 @@ import { PipeService } from '@common/formatting/pipe.service'; JsonParserPipe, FieldValuePipe, ColumnClassPipe, - DatasetInSectioPipe ] }) export class FormattingModule { } diff --git a/dmp-frontend/src/app/core/model/admin/dataset-profile/dataset-profile.ts b/dmp-frontend/src/app/core/model/admin/dataset-profile/dataset-profile.ts deleted file mode 100644 index 68b0d64db..000000000 --- a/dmp-frontend/src/app/core/model/admin/dataset-profile/dataset-profile.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { ValidationType } from "../../../common/enum/validation-type"; -import { UserInfoListingModel } from "../../user/user-info-listing"; - -export interface DatasetProfile { - label: string; - type: string; - sections: Section[]; - pages: Page[]; - status: number; - version: number; - description: string; - language: string; - users: UserInfoListingModel[]; -} - -export interface Page { - id: string; - ordinal: number; - title: string; -} - -export interface Section { - sections: Section[]; - fieldSets: FieldSet[]; - defaultVisibility: boolean; - page: string; - ordinal: number; - id: string; - title: string; - description: string; -} - -export interface FieldSet { - id: string; - ordinal: number; - multiplicity: Multiplicity; - title: string; - description: string; - extendedDescription: string; - additionalInformation:string; - hasCommentField: boolean; - fields: Field[]; -} - -export interface Multiplicity { - min: number; - max: number; - placeholder: string; - tableView: boolean; -} - -export interface Field { - id: string; - ordinal: number; - value: string; - viewStyle: ViewStyle; - datatype: string; - page: number; - defaultValue: DefaultValue; - data: any; - visible: Visibility; - validations: ValidationType[]; - schematics: string[]; - export: boolean; -} - -export interface ViewStyle { - renderStyle: string; - cssClass: string; -} - -export interface DefaultValue { - type: string; - value: string; -} - - -export interface Visibility { - rules: Rule[]; - style: string; -} - -export interface Rule { - ruleType: string; - target: string; - ruleStyle: string; - value: string; - valueType: string; -} diff --git a/dmp-frontend/src/app/core/model/auth/principal.ts b/dmp-frontend/src/app/core/model/auth/principal.ts index 27609c091..380b8d68c 100644 --- a/dmp-frontend/src/app/core/model/auth/principal.ts +++ b/dmp-frontend/src/app/core/model/auth/principal.ts @@ -4,14 +4,13 @@ import { Guid } from "@common/types/guid"; export interface AppAccount { isAuthenticated: boolean; - // permissions: AppPermission[]; roles: AppRole[]; permissions: AppPermission[]; principal: AppPrincipalInfo; profile: UserProfileInfo; } -export interface AppPrincipalInfo{ +export interface AppPrincipalInfo { subject: Guid; name: string; scope: string[]; @@ -22,6 +21,7 @@ export interface AppPrincipalInfo{ userId: Guid; more: Record } + export interface UserProfileInfo { culture: string; language: string; diff --git a/dmp-frontend/src/app/core/model/base-form-model.ts b/dmp-frontend/src/app/core/model/base-form-model.ts deleted file mode 100644 index d16130d72..000000000 --- a/dmp-frontend/src/app/core/model/base-form-model.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { UntypedFormBuilder } from '@angular/forms'; -export abstract class BaseFormModel { - public formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); -} diff --git a/dmp-frontend/src/app/core/model/dashboard/search-bar-item.ts b/dmp-frontend/src/app/core/model/dashboard/search-bar-item.ts deleted file mode 100644 index 7ee083226..000000000 --- a/dmp-frontend/src/app/core/model/dashboard/search-bar-item.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { SearchBarType } from "../../../ui/misc/navigation/navigation.component"; - -export interface SearchBarItem { - id: string; - label: string; - type: SearchBarType; - isPublished: boolean; -} diff --git a/dmp-frontend/src/app/core/model/data-repository/data-repository.ts b/dmp-frontend/src/app/core/model/data-repository/data-repository.ts deleted file mode 100644 index 08c8582c2..000000000 --- a/dmp-frontend/src/app/core/model/data-repository/data-repository.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface DataRepositoryModel { - id: string; - name: string; - abbreviation: string; - uri: string; - pid: string; - info: string; - source: string; -} diff --git a/dmp-frontend/src/app/core/model/data-table/column-ordering.ts b/dmp-frontend/src/app/core/model/data-table/column-ordering.ts deleted file mode 100644 index 3d86f8fd2..000000000 --- a/dmp-frontend/src/app/core/model/data-table/column-ordering.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class ColumnOrdering { - public fields: Array = new Array(); -} diff --git a/dmp-frontend/src/app/core/model/data-table/data-table-data.ts b/dmp-frontend/src/app/core/model/data-table/data-table-data.ts deleted file mode 100644 index f5a1e78d8..000000000 --- a/dmp-frontend/src/app/core/model/data-table/data-table-data.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class DataTableData { - data = new Array(); - totalCount = 0; -} diff --git a/dmp-frontend/src/app/core/model/data-table/data-table-request.ts b/dmp-frontend/src/app/core/model/data-table/data-table-request.ts deleted file mode 100644 index 51d2a4b69..000000000 --- a/dmp-frontend/src/app/core/model/data-table/data-table-request.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { RequestItem } from '../../query/request-item'; -import { ColumnOrdering } from './column-ordering'; - -export class DataTableRequest extends RequestItem { - offset = 0; - length = 0; - public orderings: ColumnOrdering; - constructor(offset: number, length: number, orderings: ColumnOrdering) { - super(); - this.length = length; - this.offset = offset; - this.orderings = orderings; - } -} - -export class DataTableMultiTypeRequest extends RequestItem { - dmpOffset = 0; - datasetOffset = 0; - length = 0; - public orderings: ColumnOrdering; - constructor(dmpOffset: number, datasetOffset: number, length: number, orderings: ColumnOrdering) { - super(); - this.length = length; - this.dmpOffset = dmpOffset; - this.datasetOffset = datasetOffset; - this.orderings = orderings; - } -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/auth-type.enum.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/auth-type.enum.ts deleted file mode 100644 index 9f26507c7..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/auth-type.enum.ts +++ /dev/null @@ -1,3 +0,0 @@ -export enum AuthType { - BEARER = 'Bearer' -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/composite-field.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/composite-field.ts deleted file mode 100644 index 019d1818b..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/composite-field.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Field } from './field'; -import { Multiplicity } from './multiplicity'; - -export interface CompositeField { - fields: Array; - ordinal: number; - id: string; - numbering: string; - multiplicity: Multiplicity; - multiplicityItems: Array; - title: string; - description: string; - extendedDescription: string; - additionalInformation:string; - hasCommentField: boolean; - commentFieldValue: string; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/dataset-profile-definition.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/dataset-profile-definition.ts deleted file mode 100644 index 00edec7bb..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/dataset-profile-definition.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Page } from "./page"; -import { Rule } from "./rule"; - -export interface DatasetProfileDefinitionModel { - status: number; - pages: Page[]; - rules: Rule[]; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/default-value.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/default-value.ts deleted file mode 100644 index de586f657..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/default-value.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DefaultValue { - type: string; - value: string; -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts deleted file mode 100644 index 6225f46bc..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { ExternalDatasetTypeEnum } from "@app/core/common/enum/external-dataset-type-enum"; -import { DatasetProfileComboBoxType } from "../../../common/enum/dataset-profile-combo-box-type"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../common/enum/dataset-profile-internal-dmp-entities-type"; - -export interface FieldData { - label: string; -} - -export interface AutoCompleteFieldData extends FieldData { - type: DatasetProfileComboBoxType; - autoCompleteSingleDataList: AutoCompleteSingleData[]; - multiAutoComplete: boolean; -} - -export interface AuthAutoCompleteData extends FieldData { - url: string; - method: string; - body: string; - path: string; - type: string; -} - -export interface AutoCompleteSingleData extends FieldData { - url: string; - optionsRoot: string; - autoCompleteOptions: FieldDataOption; - autocompleteType: number; - hasAuth: boolean; - method: string; - auth: AuthAutoCompleteData; -} - -export interface CheckBoxFieldData extends FieldData { - -} - -export interface BooleanDecisionFieldData extends FieldData { - -} - -export interface FreeTextFieldData extends FieldData { - -} - -export interface RadioBoxFieldData extends FieldData { - options: Array; -} - -export interface TextAreaFieldData extends FieldData { - -} - -export interface RichTextAreaFieldData extends FieldData { - -} - -// export interface TableFieldData extends FieldData { -// headers: string[]; -// rows: Array; -// } - -export interface UploadFieldData extends FieldData { - types: Array; - maxFileSizeInMB: number; -} - -export interface WordListFieldData extends FieldData { - type: DatasetProfileComboBoxType; - options: Array; - multiList: boolean; -} - -export interface FieldDataOption extends FieldData { - label: string; - value: string; - source: string; -} - -export interface DatePickerFieldData extends FieldData { - -} - -export interface ResearchersAutoCompleteFieldData extends FieldData { - type: DatasetProfileInternalDmpEntitiesType; - multiAutoComplete: boolean; -} - -export interface DatasetsAutoCompleteFieldData extends FieldData { - type: DatasetProfileInternalDmpEntitiesType; - multiAutoComplete: boolean; - autoCompleteType: number; -} - -export interface DmpsAutoCompleteFieldData extends FieldData { - type: DatasetProfileInternalDmpEntitiesType; - multiAutoComplete: boolean; -} - -export interface ExternalDatasetsFieldData extends FieldData { - multiAutoComplete: boolean; - type?: ExternalDatasetTypeEnum; -} - -export interface DataRepositoriesFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface TaxonomiesFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface LicensesFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface PublicationsFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface RegistriesFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface ServicesFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface TagsFieldData extends FieldData { - -} - -export interface ResearchersFieldData extends FieldData { - multiAutoComplete: boolean; -} - -export interface OrganizationsFieldData extends AutoCompleteFieldData { - -} - -export interface DatasetIdentifierFieldData extends FieldData { - -} - -export interface CurrencyFieldData extends FieldData { - -} - -export interface ValidationFieldData extends FieldData { - -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-group.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/field-group.ts deleted file mode 100644 index a4ac67cf2..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-group.ts +++ /dev/null @@ -1,51 +0,0 @@ -// import { FormGroup } from "@angular/forms"; -// import { JsonSerializer } from "../../../common/types/json/json-serializer"; -// import { Serializable } from "../../../common/types/json/serializable"; -// import { BaseModel } from "../../../models/BaseModel"; -// import { CompositeField } from "./composite-field"; - -// export class FieldGroup extends BaseModel implements Serializable { -// public id: string; -// public title: string; -// public section: string; -// public value: string; -// public description: string; -// public extendedDescription: string; -// public defaultVisibility: boolean; -// public page: number; -// public compositeFields: Array = new Array(); - -// fromJSONObject(item: any): FieldGroup { -// this.id = item.id; -// this.title = item.title; -// this.value = item.value; -// this.description = item.description; -// this.extendedDescription = item.extendedDescription; -// this.defaultVisibility = item.defaultVisibility; -// this.page = item.page; -// this.compositeFields = new JsonSerializer(CompositeField).fromJSONArray(item.compositeFields); -// return this; -// } - -// buildForm(): FormGroup { -// const formGroup: FormGroup = this.formBuilder.group({ -// /* id: [this.id], -// title: [this.title], -// value: [this.value], -// description: [this.description], -// extendedDescription: [this.extendedDescription], -// defaultVisibility: [this.defaultVisibility], -// page: [this.page] */ -// }); -// const compositeFieldsFormArray = new Array(); -// if (this.compositeFields) { -// this.compositeFields.forEach(item => { -// const form: FormGroup = item.buildForm(); -// compositeFieldsFormArray.push(form); -// }); -// } -// formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray)); - -// return formGroup; -// } -// } diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/field.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/field.ts deleted file mode 100644 index d3168db86..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/field.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ValidationType } from "../../common/enum/validation-type"; -import { DefaultValue } from "./default-value"; -import { Multiplicity } from "./multiplicity"; -import { ViewStyle } from "./view-style"; - -export interface Field { - - id: string; - title: string; - value: any; - defaultValue: DefaultValue; - description: string; - numbering: string; - extendedDescription: string; - additionalInformation: string; - viewStyle: ViewStyle; - defaultVisibility: boolean; - page: number; - multiplicity: Multiplicity; - multiplicityItems: Array; - data: any; - validations: Array; - validationRequired; - validationURL; - ordinal: number; -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/html-method.enum.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/html-method.enum.ts deleted file mode 100644 index ed63f9540..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/html-method.enum.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum HtmlMethod { - GET = 'GET', - POST = 'POST', - PUT = 'PUT', - PATCH = 'PATCH' -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/multiplicity.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/multiplicity.ts deleted file mode 100644 index 65af94550..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/multiplicity.ts +++ /dev/null @@ -1,9 +0,0 @@ - - -export interface Multiplicity { - min: number; - max: number; - placeholder: string; - tableView: boolean; -} - diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/page.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/page.ts deleted file mode 100644 index b8c05a808..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/page.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Section } from "./section"; - -export interface Page { - ordinal: number; - title: string; - sections: Array
; -} diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/section.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/section.ts deleted file mode 100644 index 8c52b1c4f..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/section.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { CompositeField } from "./composite-field"; - -export interface Section { - sections: Array
; - defaultVisibility: boolean; - page: number; - numbering: string; - ordinal: number; - id: string; - title: string; - description: string; - compositeFields: Array; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/view-style.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/view-style.ts deleted file mode 100644 index daaba384c..000000000 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/view-style.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ViewStyle { - cssClass: string; - renderStyle: string; -} diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts b/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts deleted file mode 100644 index 3396be391..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { UntypedFormGroup, UntypedFormBuilder } from '@angular/forms'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; - -export class DatasetIdModel { - identifier: string; - type: string; - - constructor(data: any) { - try{ - const parsed = JSON.parse(data); - if (!isNullOrUndefined(parsed)) { - if(typeof parsed !== 'string'){ - this.identifier = parsed.identifier; - this.type = parsed.type; - } - else{ - const parsedObjectFromString = JSON.parse(parsed); - this.identifier = parsedObjectFromString.identifier; - this.type = parsedObjectFromString.type; - } - } - } - catch(error){ - console.warn('Could not parse DatasetIdModel'); - } - } - - buildForm(): UntypedFormGroup { - return new UntypedFormBuilder().group({ - identifier: [this.identifier], - type: [this.type] - }); - } -} diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-listing.ts b/dmp-frontend/src/app/core/model/dataset/dataset-listing.ts deleted file mode 100644 index 377c8a2bf..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset-listing.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { DatasetProfileModel } from './dataset-profile'; - -export interface DatasetListingModel { - id: string; - label: string; - dmp: String; - dmpId: String; - grant: String; - grantId: String; - grantAbbreviation: String; - profile: DatasetProfileModel; - dataRepositories: String; - registries: String; - services: String; - description: String; - status: number; - created: Date; - modified: Date; - finalizedAt: Date; - dmpPublishedAt?: Date; - version: number; - users: any[]; - public: boolean; - isProfileLatestVersion: boolean; -} diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-overview.ts b/dmp-frontend/src/app/core/model/dataset/dataset-overview.ts deleted file mode 100644 index 3c4cdbb6d..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset-overview.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { DatasetProfileModel } from "./dataset-profile"; -import { GrantOverviewModel } from '../grant/grant-overview'; -import { DmpOverviewModel } from '../dmp/dmp-overview'; - -export interface DatasetOverviewModel { - id: string; - label: string; - status: number; - datasetTemplate: DatasetProfileModel; - - users: any[]; - dmp: DmpOverviewModel; - grant: GrantOverviewModel; - description: String; - public: boolean; - modified: Date; -} diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-profile.ts b/dmp-frontend/src/app/core/model/dataset/dataset-profile.ts deleted file mode 100644 index d67dce6b0..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset-profile.ts +++ /dev/null @@ -1,34 +0,0 @@ - -export interface DatasetProfileModel { - id: string; - label: string; - description: string; -} - -// export class DatasetProfileModel implements Serializable { -// public id: String; -// public label: String; - -// fromJSONObject(item: any): DatasetProfileModel { -// this.id = item.id; -// this.label = item.label; - -// return this; -// } - -// buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { -// if (context == null) { context = this.createValidationContext(); } - -// const formGroup = new FormBuilder().group({ -// id: [{ value: this.id, disabled: disabled }], -// }); - -// return formGroup; -// } - -// createValidationContext(): ValidationContext { -// const baseContext: ValidationContext = new ValidationContext(); -// //baseContext.validation.push({ key: 'id', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'id')] }); -// return baseContext; -// } -// } diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-url-listing.ts b/dmp-frontend/src/app/core/model/dataset/dataset-url-listing.ts deleted file mode 100644 index fd2c53dee..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset-url-listing.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DatasetUrlListing { - label: String; - url: String; -} diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts b/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts deleted file mode 100644 index ccbe8d43c..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset-wizard.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { DataRepositoryModel } from "../data-repository/data-repository"; -import { DatasetProfileDefinitionModel } from "../dataset-profile-definition/dataset-profile-definition"; -import { DmpModel } from "../dmp/dmp"; -import { ExternalDatasetModel } from "../external-dataset/external-dataset"; -import { RegistryModel } from "../registry/registry"; -import { ServiceModel } from "../service/service"; -import { TagModel } from "../tag/tag"; -import { DatasetProfileModel } from "./dataset-profile"; - -export interface DatasetWizardModel { - id?: string; - label?: string; - uri?: String; - description?: String; - status?: number; - dmp?: DmpModel; - dmpSectionIndex?: number; - datasetProfileDefinition?: DatasetProfileDefinitionModel; - registries?: RegistryModel[]; - services?: ServiceModel[]; - dataRepositories?: DataRepositoryModel[]; - tags?: TagModel[]; - externalDatasets?: ExternalDatasetModel[]; - profile?: DatasetProfileModel; - isProfileLatestVersion?: Boolean; - modified?: Date; -} diff --git a/dmp-frontend/src/app/core/model/dataset/dataset.ts b/dmp-frontend/src/app/core/model/dataset/dataset.ts deleted file mode 100644 index 91214d136..000000000 --- a/dmp-frontend/src/app/core/model/dataset/dataset.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { DataRepositoryModel } from '../data-repository/data-repository'; -import { RegistryModel } from '../registry/registry'; -import { ServiceModel } from '../service/service'; - -export interface DatasetModel { - id: String; - label: String; - profile: String; - uri: String; - status: String; - description: String; - services: ServiceModel[]; - registries: RegistryModel[]; - dataRepositories: DataRepositoryModel[]; -} -// export class DatasetModel implements Serializable { -// public id: String; -// public label: String; -// public profile: String; -// public uri: String; -// public status: String; -// public description: String; -// public services: ServiceModel[] = []; -// public registries: RegistryModel[] = []; -// public dataRepositories: DataRepositoryModel[] = []; - -// public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - -// fromJSONObject(item: any): DatasetModel { -// this.id = item.id; -// this.label = item.label; -// this.profile = item.profile; -// this.uri = item.uri; -// this.status = item.status; -// this.description = item.description; -// this.services = new JsonSerializer(ServiceModel).fromJSONArray(item.services); -// this.registries = new JsonSerializer(RegistryModel).fromJSONArray(item.registries); -// this.dataRepositories = new JsonSerializer(DataRepositoryModel).fromJSONArray(item.dataRepositories); - -// return this; -// } - -// buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { -// if (context == null) { context = this.createValidationContext(); } - -// const formGroup = new FormBuilder().group({ -// label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], -// profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators], -// uri: [{ value: this.uri, disabled: disabled }, context.getValidation('uri').validators], -// status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], -// description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], -// services: [{ value: this.services, disabled: disabled }, context.getValidation('services').validators], -// registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators], -// dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators] -// }); - -// return formGroup; -// } - -// createValidationContext(): ValidationContext { -// const baseContext: ValidationContext = new ValidationContext(); -// baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); -// baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'profile')] }); -// baseContext.validation.push({ key: 'uri', validators: [BackendErrorValidator(this.validationErrorModel, 'uri')] }); -// baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] }); -// baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); -// baseContext.validation.push({ key: 'services', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'services')] }); -// baseContext.validation.push({ key: 'registries', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'registries')] }); -// baseContext.validation.push({ key: 'dataRepositories', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dataRepositories')] }); - -// return baseContext; -// } -// } diff --git a/dmp-frontend/src/app/core/model/dataset/datasets-toBeFinalized.ts b/dmp-frontend/src/app/core/model/dataset/datasets-toBeFinalized.ts deleted file mode 100644 index 01abafb22..000000000 --- a/dmp-frontend/src/app/core/model/dataset/datasets-toBeFinalized.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface DatasetsToBeFinalized { - uuids: string[]; -} diff --git a/dmp-frontend/src/app/core/model/dataset/prefilling.ts b/dmp-frontend/src/app/core/model/dataset/prefilling.ts deleted file mode 100644 index 978dfe1eb..000000000 --- a/dmp-frontend/src/app/core/model/dataset/prefilling.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface Prefilling { - pid: string; - name: string; - data: any; - key: string; - tag: string; -} diff --git a/dmp-frontend/src/app/core/model/deposit/deposit-configuration.ts b/dmp-frontend/src/app/core/model/deposit/deposit-configuration.ts index fe92ddd5b..73438e6cf 100644 --- a/dmp-frontend/src/app/core/model/deposit/deposit-configuration.ts +++ b/dmp-frontend/src/app/core/model/deposit/deposit-configuration.ts @@ -1,6 +1,6 @@ import { DepositConfigurationStatus } from "@app/core/common/enum/deposit-configuration-status"; -export class DepositConfigurationModel { +export class DepositConfiguration { depositType: DepositConfigurationStatus; repositoryId: string; repositoryAuthorizationUrl: string; diff --git a/dmp-frontend/src/app/core/model/deposit/deposit-request.ts b/dmp-frontend/src/app/core/model/deposit/deposit-request.ts index 10ee13980..156b6460a 100644 --- a/dmp-frontend/src/app/core/model/deposit/deposit-request.ts +++ b/dmp-frontend/src/app/core/model/deposit/deposit-request.ts @@ -1,10 +1,12 @@ +import { Guid } from "@common/types/guid"; + export class DepositRequest { repositoryId: string; - dmpId: string; - accessToken: string; + dmpId: Guid; + accessToken: String; } -export class DepositCode { +export class DepositAuthenticateRequest { repositoryId: string; code: string; } \ 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 b70557e07..77addc8e2 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 @@ -30,13 +30,13 @@ export interface DescriptionTemplateDefinitionPersist { export interface DescriptionTemplatePagePersist { - id: Guid; + id: string; ordinal: number; title: string; } export interface DescriptionTemplateSectionPersist { - id: Guid; + id: string; ordinal: number; defaultVisibility: boolean; multiplicity: boolean; @@ -49,7 +49,7 @@ export interface DescriptionTemplateSectionPersist { } export interface DescriptionTemplateFieldSetPersist { - id: Guid; + id: string; ordinal: number; numbering: string; title: string; @@ -62,7 +62,7 @@ export interface DescriptionTemplateFieldSetPersist { } export interface DescriptionTemplateFieldPersist { - id: Guid; + id: string; ordinal: number; schematics: string[]; defaultValue: 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 19ceb9801..e652a7041 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 @@ -34,13 +34,13 @@ export interface DescriptionTemplateDefinition { export interface DescriptionTemplatePage { - id: Guid; + id: string; ordinal: number; title: string; } export interface DescriptionTemplateSection { - id: Guid; + id: string; ordinal: number; defaultVisibility: boolean; multiplicity: boolean; @@ -55,7 +55,7 @@ export interface DescriptionTemplateSection { } export interface DescriptionTemplateFieldSet { - id: Guid; + id: string; ordinal: number; numbering: string; title: string; @@ -68,7 +68,7 @@ export interface DescriptionTemplateFieldSet { } export interface DescriptionTemplateField { - id: Guid; + id: string; ordinal: number; numbering?: string; schematics?: string[]; diff --git a/dmp-frontend/src/app/core/model/description/description.ts b/dmp-frontend/src/app/core/model/description/description.ts index 84723774c..1dc6a8b6f 100644 --- a/dmp-frontend/src/app/core/model/description/description.ts +++ b/dmp-frontend/src/app/core/model/description/description.ts @@ -2,13 +2,11 @@ import { DescriptionStatus } from "@app/core/common/enum/description-status"; import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; import { Guid } from "@common/types/guid"; import { DescriptionTemplate } from "../description-template/description-template"; -import { Dmp, DmpDescriptionTemplatePersist } from "../dmp/dmp"; +import { Dmp, DmpDescriptionTemplate } from "../dmp/dmp"; import { Reference, ReferencePersist } from "../reference/reference"; import { Tag } from "../tag/tag"; import { User } from "../user/user"; - - export interface Description extends BaseEntity { label: string; properties: PropertyDefinition; @@ -19,7 +17,7 @@ export interface Description extends BaseEntity { descriptionReferences: DescriptionReference[]; descriptionTags: DescriptionTag[]; descriptionTemplate: DescriptionTemplate; - dmpDescriptionTemplate: DmpDescriptionTemplatePersist; + dmpDescriptionTemplate: DmpDescriptionTemplate; dmp: Dmp; } 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 8d09fc90f..85d0c1d20 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,9 @@ +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 { DmpBlueprintExtraFieldDataType } from "@app/core/common/enum/dmp-blueprint-field-type"; -import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint-system-field-type"; export interface DmpBlueprint extends BaseEntity { diff --git a/dmp-frontend/src/app/core/model/dmp/cost.ts b/dmp-frontend/src/app/core/model/dmp/cost.ts deleted file mode 100644 index ab432f02b..000000000 --- a/dmp-frontend/src/app/core/model/dmp/cost.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - -export interface CostModel { - code: string; - description: string; - title: string; - value: number; -} diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-create-wizard/dmp-create-wizard-form.model.ts b/dmp-frontend/src/app/core/model/dmp/dmp-create-wizard/dmp-create-wizard-form.model.ts deleted file mode 100644 index 22e5dcba0..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-create-wizard/dmp-create-wizard-form.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - -export class DmpCreateWizardFormModel { - dmp: DmpModel; - datasetProfile: DatasetProfileModel; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - - fromModel(item: DmpCreateWizardFormModel): DmpCreateWizardFormModel { - this.dmp = item.dmp; - this.datasetProfile = item.datasetProfile; - - return this; - } - - buildForm(context: ValidationContext = null): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - const formBuilder = new UntypedFormBuilder(); - const formGroup = formBuilder.group({ - dmp: [this.dmp, context.getValidation('dmp').validators], - datasetProfile: [this.datasetProfile, context.getValidation('datasetProfile').validators], - }); - - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'datasetProfile', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasetProfile')] }); - baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.validationErrorModel, 'dmp')] }); - - return baseContext; - } -} diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts b/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts deleted file mode 100644 index 9e5f9a355..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { UntypedFormGroup, UntypedFormBuilder } from "@angular/forms"; -import { BackendErrorValidator } from "@common/forms/validation/custom-validator"; -import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model"; -import { ValidationContext } from "@common/forms/validation/validation-context"; - -export class DmpDatasetProfileSectionsFormModel { - public dmpSectionIndex: number[] = []; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - - fromModel(item: any): DmpDatasetProfileSectionsFormModel { - this.dmpSectionIndex = item.dmpSectionIndex; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - const formGroup = new UntypedFormBuilder().group({ - language: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators], - }); - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] }); - return baseContext; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts b/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts deleted file mode 100644 index 043f4d525..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DmpDatasetProfileSectionsFormModel } from "./dmp-dataset-profile-sections-form.model"; - -export interface DmpDatasetProfile { - id: string; - descriptionTemplateId: string; - label: string; - data: DmpDatasetProfileSectionsFormModel; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-dynamic-field-dependency.ts b/dmp-frontend/src/app/core/model/dmp/dmp-dynamic-field-dependency.ts deleted file mode 100644 index 36ec05572..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-dynamic-field-dependency.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DmpDynamicFieldDependency { - id: string; - queryProperty: string; -} diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-dynamic-field.ts b/dmp-frontend/src/app/core/model/dmp/dmp-dynamic-field.ts deleted file mode 100644 index 08f932d7e..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-dynamic-field.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { DmpDynamicFieldDependency } from "./dmp-dynamic-field-dependency"; - -export interface DmpDynamicField { - id: string; - name: string; - required: boolean; - queryProperty; - value: string; - dependencies: Array; -} diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-extra-field.ts b/dmp-frontend/src/app/core/model/dmp/dmp-extra-field.ts deleted file mode 100644 index 4d789e64d..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-extra-field.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DmpExtraField { - id: string; - value: string; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-listing.ts b/dmp-frontend/src/app/core/model/dmp/dmp-listing.ts deleted file mode 100644 index b7423fa67..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-listing.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { DmpStatus } from "../../common/enum/dmp-status"; - -export interface DmpListingModel { - id: string; - label: string; - description: String; - status: DmpStatus; - grant: String; - grantId: String; - grantAbbreviation: String; - profile: String; - creationTime: string; - modifiedTime: string; - publishedAt: Date; - finalizedAt: Date; - organisations: String; - groupId: string; - version: number; - datasets: any[]; - users: any[]; - public: boolean; -} diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts b/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts deleted file mode 100644 index 9dfff2490..000000000 --- a/dmp-frontend/src/app/core/model/dmp/dmp-overview.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { OrganizationModel } from "../organisation/organization"; -import { UserInfoListingModel } from "../user/user-info-listing"; -import { ResearcherModel } from "../researcher/researcher"; -import { GrantOverviewModel } from "../grant/grant-overview"; -import { DatasetOverviewModel } from "../dataset/dataset-overview"; -import { DoiModel } from "../doi/doi"; - -export interface DmpOverviewModel { - id: string; - label: string; - profile: string; - creationTime: string; - modifiedTime: string; - version: number; - status: number; - isPublic: boolean; - groupId: string; - description: string; - grant: GrantOverviewModel; - users: UserInfoListingModel[]; - organisations: OrganizationModel[]; - datasets: DatasetOverviewModel[]; - datasetsToBeFinalized: string[]; - researchers: ResearcherModel[]; - finalizedAt: Date; - publishedAt: Date; - doi: string; - dois: DoiModel[]; -} diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts b/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts index 8c009455a..df308ce03 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts @@ -1,12 +1,9 @@ -import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; -import { Guid } from "@common/types/guid"; +import { BaseEntity } from "@common/base/base-entity.model"; import { Reference } from "../reference/reference"; import { Dmp } from "./dmp"; - - export interface DmpReference extends BaseEntity { dmp?: Dmp; reference?: Reference; - data: String; + data: string; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 29966f13d..aa6452d44 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -4,54 +4,13 @@ import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { DmpVersionStatus } from '@app/core/common/enum/dmp-version-status'; import { BaseEntity, BaseEntityPersist } from '@common/base/base-entity.model'; import { Guid } from '@common/types/guid'; -import { DatasetWizardModel } from '../dataset/dataset-wizard'; import { DescriptionTemplate } from '../description-template/description-template'; import { Description } from '../description/description'; +import { DmpBlueprint } from '../dmp-blueprint/dmp-blueprint'; import { EntityDoi } from '../entity-doi/entity-doi'; -import { FunderModel } from "../funder/funder"; -import { GrantListingModel } from "../grant/grant-listing"; -import { OrganizationModel } from "../organisation/organization"; -import { ProjectModel } from "../project/project"; -import { DmpReference, ReferencePersist } from '../reference/reference'; -import { ResearcherModel } from "../researcher/researcher"; -import { User, UserModel } from "../user/user"; -import { UserInfoListingModel } from "../user/user-info-listing"; -import { DmpDatasetProfile } from "./dmp-dataset-profile/dmp-dataset-profile"; -import { DmpDynamicField } from "./dmp-dynamic-field"; -import { DmpExtraField } from "./dmp-extra-field"; - -export interface DmpModel { //TODO: Delete - id: string; - label: string; - groupId: String; - profile: DmpBlueprint; - version: number; - status: DmpStatus; - lockable: boolean; - description: String; - grant: GrantListingModel; - project: ProjectModel; - funder: FunderModel; - datasets: DatasetWizardModel[]; - datasetsToBeFinalized: string[]; - profiles: DmpDatasetProfile[]; - organisations: OrganizationModel[]; - researchers: ResearcherModel[]; - associatedUsers: UserModel[]; - users: UserInfoListingModel[]; - creator: UserModel; - extraFields: Array; - dynamicFields: Array; - modified: Date; - extraProperties: Map; - language: String; -} - - -export interface DmpBlueprint { - id: string; - label: string; -} +import { ReferencePersist } from '../reference/reference'; +import { User } from "../user/user"; +import { DmpReference } from './dmp-reference'; export interface Dmp extends BaseEntity { label: string; @@ -71,29 +30,8 @@ export interface Dmp extends BaseEntity { dmpReferences: DmpReference[]; dmpUsers: DmpUser[]; descriptions: Description[]; + dmpDescriptionTemplates: DmpDescriptionTemplate[]; entityDois: EntityDoi[]; - - - // TODO: delete - // grant: GrantListingModel; - // project: ProjectModel; - // funder: FunderModel; - // organisations: OrganizationModel[]; - // researchers: ResearcherModel[]; - - // datasets: DatasetWizardModel[]; - // datasetsToBeFinalized: string[]; - // profiles: DmpDatasetProfile[]; - - - - // associatedUsers: UserModel[]; - // users: UserInfoListingModel[]; - // creator: UserModel; - // extraFields: Array; - // dynamicFields: Array; - // extraProperties: Map; - // language: String; } export interface DmpUser extends BaseEntity { @@ -119,15 +57,15 @@ export interface DmpPersist extends BaseEntityPersist { properties: string; description: String; language: String; - blueprint: DmpBlueprint; + blueprint: Guid; accessType: DmpAccessType; references: DmpReferencePersist[]; descriptionTemplates: DmpDescriptionTemplatePersist[]; } export interface DmpReferencePersist extends BaseEntityPersist { - reference: ReferencePersist; - data: string; + reference?: ReferencePersist; + data?: string; } export interface DmpDescriptionTemplatePersist extends BaseEntityPersist { @@ -159,4 +97,15 @@ export interface DmpUserRemovePersist { id: Guid; dmpId: Guid; role: DmpUserRole; -} \ No newline at end of file +} + +export interface DmpUserInvitePersist { + users: DmpUserInviteTypePersist[]; + role: DmpUserRole; +} + +export interface DmpUserInviteTypePersist { + userId: Guid; + email: string; +} + diff --git a/dmp-frontend/src/app/core/model/dmp/invitation/dmp-invitation-user.ts b/dmp-frontend/src/app/core/model/dmp/invitation/dmp-invitation-user.ts deleted file mode 100644 index 8a261b428..000000000 --- a/dmp-frontend/src/app/core/model/dmp/invitation/dmp-invitation-user.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { Serializable } from '@common/types/json/serializable'; - -export class DmpInvitationUser implements Serializable { - - public id: string; - public email: string; - public name: string; - - fromJSONObject(item: any): DmpInvitationUser { - this.id = item.id; - this.email = item.email; - this.name = item.name; - return this; - } - - buildForm(): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - email: [this.email], - name: [this.name] - }); - } - -} diff --git a/dmp-frontend/src/app/core/model/dmp/invitation/dmp-invitation.ts b/dmp-frontend/src/app/core/model/dmp/invitation/dmp-invitation.ts deleted file mode 100644 index 02bda1e75..000000000 --- a/dmp-frontend/src/app/core/model/dmp/invitation/dmp-invitation.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { DmpInvitationUser } from './dmp-invitation-user'; - -export class DmpInvitation { - - public dataManagementPlan: string; - public users = new Array(); - public role: number; - - buildForm(): UntypedFormGroup { - const formGroup = new UntypedFormBuilder().group({ - dataManagementPlan: [this.dataManagementPlan], - users: [this.users], - role: [this.role] - }); - - return formGroup; - } -} diff --git a/dmp-frontend/src/app/core/model/doi/doi.ts b/dmp-frontend/src/app/core/model/doi/doi.ts deleted file mode 100644 index c72ba0023..000000000 --- a/dmp-frontend/src/app/core/model/doi/doi.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface DoiModel { - id: string; - repositoryId: string; - doi: string; - createdAt: Date; - updatedAt: Date; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/external-dataset/external-dataset.ts b/dmp-frontend/src/app/core/model/external-dataset/external-dataset.ts deleted file mode 100644 index 40d841e5e..000000000 --- a/dmp-frontend/src/app/core/model/external-dataset/external-dataset.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ExternalDatasetType } from '../../common/enum/external-dataset-type'; - -export interface ExternalDatasetModel { - abbreviation: String; - id: String; - name: String; - reference: String; - type: ExternalDatasetType; - info: String; - source: String; -} diff --git a/dmp-frontend/src/app/core/model/external-sources/external-source-item.ts b/dmp-frontend/src/app/core/model/external-sources/external-source-item.ts deleted file mode 100644 index 2e703911a..000000000 --- a/dmp-frontend/src/app/core/model/external-sources/external-source-item.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface ExternalSourceItemModel { - id: String; - name: String; - description: String; -} diff --git a/dmp-frontend/src/app/core/model/external-sources/external-source-url.ts b/dmp-frontend/src/app/core/model/external-sources/external-source-url.ts deleted file mode 100644 index 3965eb618..000000000 --- a/dmp-frontend/src/app/core/model/external-sources/external-source-url.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class ExternalSourceUrlModel { - public key: String; - public label: String; -} diff --git a/dmp-frontend/src/app/core/model/external-sources/external-sources-configuration.ts b/dmp-frontend/src/app/core/model/external-sources/external-sources-configuration.ts deleted file mode 100644 index 7ca3e955d..000000000 --- a/dmp-frontend/src/app/core/model/external-sources/external-sources-configuration.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ExternalSourceUrlModel } from "./external-source-url"; - -export class ExternalSourcesConfiguration { - public registries: Array; - public dataRepositories: Array; - public services: Array; - public externalDatasets: Array; - public tags: Array; -} diff --git a/dmp-frontend/src/app/core/model/file/file-format.model.ts b/dmp-frontend/src/app/core/model/file/file-format.model.ts index a166c7151..e3243e117 100644 --- a/dmp-frontend/src/app/core/model/file/file-format.model.ts +++ b/dmp-frontend/src/app/core/model/file/file-format.model.ts @@ -1,4 +1,4 @@ -export class FileFormat { +export interface FileFormat { format: string; formatName: string; icon: string; diff --git a/dmp-frontend/src/app/core/model/funder/funder.ts b/dmp-frontend/src/app/core/model/funder/funder.ts deleted file mode 100644 index a266d90ea..000000000 --- a/dmp-frontend/src/app/core/model/funder/funder.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Status } from "../../common/enum/status"; - -export class FunderModel { - id: string; - label: string; - reference: string; - definition: string; - status: Status; - created: Date; - modified: Date; - type: number; -} diff --git a/dmp-frontend/src/app/core/model/grant/grant-listing.ts b/dmp-frontend/src/app/core/model/grant/grant-listing.ts deleted file mode 100644 index d6d2fba85..000000000 --- a/dmp-frontend/src/app/core/model/grant/grant-listing.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { UrlListingItem } from "../../../library/url-listing/url-listing-item"; -import { GrantType } from '../../common/enum/grant-type'; -import { Status } from '../../common/enum/status'; - -export interface GrantListingModel { - id?: string; - label?: string; - abbreviation?: string; - reference?: string; - type?: GrantType; - uri?: String; - status?: Status; - startDate?: Date; - endDate?: Date; - description?: String; - contentUrl?: string; - funderId?: string; - files?: ContentFile[]; - dmps?: UrlListingItem[]; - source?: string; -} - -export interface ContentFile { - filename?: string; - id?: string; - location?: string; - type?: string; -} diff --git a/dmp-frontend/src/app/core/model/grant/grant-overview.ts b/dmp-frontend/src/app/core/model/grant/grant-overview.ts deleted file mode 100644 index 94b507aa2..000000000 --- a/dmp-frontend/src/app/core/model/grant/grant-overview.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface GrantOverviewModel { - id: String; - label: String; - uri: String; - abbreviation: String; - description: String; - startDate: Date; - endDate: Date; -} diff --git a/dmp-frontend/src/app/core/model/help-content/active-topic-questions.ts b/dmp-frontend/src/app/core/model/help-content/active-topic-questions.ts deleted file mode 100644 index f5f78806f..000000000 --- a/dmp-frontend/src/app/core/model/help-content/active-topic-questions.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Created by stefania on 4/26/17. - */ -import { Topic } from './topic'; -import { Question } from './question'; - -export interface ActiveTopicQuestions { - topic: Topic; - questionList: Question[]; -} diff --git a/dmp-frontend/src/app/core/model/help-content/page-help-content.ts b/dmp-frontend/src/app/core/model/help-content/page-help-content.ts deleted file mode 100644 index 1adb534bd..000000000 --- a/dmp-frontend/src/app/core/model/help-content/page-help-content.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -import { Page } from './page'; - -export interface PageHelpContent { - _id: string; - page: Page | string; - placement: string; - order: number; - content: string; - isActive: boolean; -} - -export interface CheckPageHelpContent { - pageHelpContent: PageHelpContent; - checked: boolean; -} - -export interface PageHelpContentFilterOptions { - id: string; - active: Boolean; - text: RegExp; -} diff --git a/dmp-frontend/src/app/core/model/help-content/page.ts b/dmp-frontend/src/app/core/model/help-content/page.ts deleted file mode 100644 index 7d204e02b..000000000 --- a/dmp-frontend/src/app/core/model/help-content/page.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -export interface Page { - _id: string; - route: string; - name: string; -} - -export interface CheckPage { - page: Page; - checked: boolean; -} diff --git a/dmp-frontend/src/app/core/model/help-content/question.ts b/dmp-frontend/src/app/core/model/help-content/question.ts deleted file mode 100644 index caf9eec73..000000000 --- a/dmp-frontend/src/app/core/model/help-content/question.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Created by stefania on 4/26/17. - */ -import { Topic } from './topic'; - -export interface Question { - _id: string; - question: string; - answer: string; - date: Date; - isActive: boolean; - weight: number; - hitCount: number; - topics: Topic[] | string[]; -} - -export interface CheckQuestion { - question: Question; - checked: boolean; -} - -export interface QuestionFilterOptions { - id: string; - active: Boolean; - text: RegExp; -} diff --git a/dmp-frontend/src/app/core/model/help-content/topic.ts b/dmp-frontend/src/app/core/model/help-content/topic.ts deleted file mode 100644 index 4fb5c3a95..000000000 --- a/dmp-frontend/src/app/core/model/help-content/topic.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Created by stefania on 4/26/17. - */ -export interface Topic { - _id: string; - name: string; - description: string; - date: Date; - weight: number; - questionOrder: string; -} - -export interface CheckTopic { - topic: Topic; - checked: boolean; -} diff --git a/dmp-frontend/src/app/core/model/license/license.ts b/dmp-frontend/src/app/core/model/license/license.ts deleted file mode 100644 index 9ac8d7ad5..000000000 --- a/dmp-frontend/src/app/core/model/license/license.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface LicenseModel { - id: string; - name: string; - abbreviation: string; - uri: string; - pid: string; - info: string; - source: string; -} diff --git a/dmp-frontend/src/app/core/model/local-fetch/local-fetch.model.ts b/dmp-frontend/src/app/core/model/local-fetch/local-fetch.model.ts deleted file mode 100644 index 4ca43879a..000000000 --- a/dmp-frontend/src/app/core/model/local-fetch/local-fetch.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class LocalFetchModel { - name: string; - value: string; -} diff --git a/dmp-frontend/src/app/core/model/lock/lock.model.ts b/dmp-frontend/src/app/core/model/lock/lock.model.ts index 27c9904ae..062a1b669 100644 --- a/dmp-frontend/src/app/core/model/lock/lock.model.ts +++ b/dmp-frontend/src/app/core/model/lock/lock.model.ts @@ -1,31 +1,12 @@ -import { Guid } from '@common/types/guid'; -import { UserInfoListingModel } from '../user/user-info-listing'; import { LockTargetType } from '@app/core/common/enum/lock-target-type'; +import { Guid } from '@common/types/guid'; import { User } from '../user/user'; -// old model -export class LockModel { - id: Guid; - target: Guid; - lockedBy: UserInfoListingModel; - lockedAt: Date; - touchedAt: Date; - - constructor(targetId: string, lockedBy: any) { - this.lockedAt = new Date(); - this.touchedAt = new Date(); - this.target = Guid.parse(targetId); - this.lockedBy = lockedBy; - - } -} - - -export interface Lock{ +export interface Lock { id: Guid; target: Guid; targetType: LockTargetType; - lockedBy: User; + lockedBy: User; lockedAt: Date; touchedAt: Date; hash: String; @@ -33,10 +14,10 @@ export interface Lock{ // Persist -export interface LockPersist{ +export interface LockPersist { id: Guid; target: Guid; targetType: LockTargetType; - lockedBy: User; + lockedBy: User; hash: String; } diff --git a/dmp-frontend/src/app/core/model/merge/user-merge-request.ts b/dmp-frontend/src/app/core/model/merge/user-merge-request.ts deleted file mode 100644 index 471463abb..000000000 --- a/dmp-frontend/src/app/core/model/merge/user-merge-request.ts +++ /dev/null @@ -1,5 +0,0 @@ -export class UserMergeRequestModel { - userId: String; - email: String; - provider: number; -} diff --git a/dmp-frontend/src/app/core/model/organisation/organization.ts b/dmp-frontend/src/app/core/model/organisation/organization.ts deleted file mode 100644 index 7cc4afa30..000000000 --- a/dmp-frontend/src/app/core/model/organisation/organization.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Status } from "../../common/enum/status"; - -export interface OrganizationModel { - id: string; - name: string; - label: string; - status: Status; - tag: string; - reference?: string; -} diff --git a/dmp-frontend/src/app/core/model/project/project.ts b/dmp-frontend/src/app/core/model/project/project.ts deleted file mode 100644 index bd467a575..000000000 --- a/dmp-frontend/src/app/core/model/project/project.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Status } from "../../common/enum/status"; -import { UrlListingItem } from "../../../library/url-listing/url-listing-item"; -import { ProjectType } from "../../common/enum/project-type"; - -export class ProjectModel { - id?: string; - label?: string; - abbreviation?: string; - reference?: string; - type?: ProjectType; - uri?: String; - status?: Status; - startDate?: Date; - endDate?: Date; - description?: String; - contentUrl?: string; - files?: ContentFile[]; - dmps?: UrlListingItem[]; -} - -export interface ContentFile { - filename?: string; - id?: string; - location?: string; - type?: string; -} diff --git a/dmp-frontend/src/app/core/model/publication/publication.ts b/dmp-frontend/src/app/core/model/publication/publication.ts deleted file mode 100644 index 5f4954ddb..000000000 --- a/dmp-frontend/src/app/core/model/publication/publication.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface PublicationModel { - id: string; - name: string; - abbreviation: string; - uri: string; - pid: string; - info: string; - source: string; -} diff --git a/dmp-frontend/src/app/core/model/reference/reference.ts b/dmp-frontend/src/app/core/model/reference/reference.ts index f243d3cd5..e5a19a695 100644 --- a/dmp-frontend/src/app/core/model/reference/reference.ts +++ b/dmp-frontend/src/app/core/model/reference/reference.ts @@ -1,11 +1,9 @@ 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 { UUID } from "crypto"; -import { DmpModel } from "../dmp/dmp"; import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; -export interface Reference extends BaseEntity{ +export interface Reference extends BaseEntity { label: string; type: ReferenceType; description: string; @@ -14,7 +12,6 @@ export interface Reference extends BaseEntity{ abbreviation: string; source: string; sourceType: ReferenceSourceType; - dmpReferences: DmpReference[]; } export interface Definition { @@ -27,15 +24,6 @@ export interface Field { value: string; } -export interface DmpReference { - id: UUID; - dmp: DmpModel; - reference: Reference; - data: string; - createdAt: Date; - updatedAt: Date; -} - // old fetcher export interface FetcherReference { id: string; @@ -61,7 +49,7 @@ export interface ReferencePersist extends BaseEntityPersist { label: string; type: ReferenceType; description: string; - definition?: DefinitionPersist; + definition: DefinitionPersist; reference: string; abbreviation: string; source: string; diff --git a/dmp-frontend/src/app/core/model/registry/registry.ts b/dmp-frontend/src/app/core/model/registry/registry.ts deleted file mode 100644 index 6658e9b57..000000000 --- a/dmp-frontend/src/app/core/model/registry/registry.ts +++ /dev/null @@ -1,11 +0,0 @@ - -export interface RegistryModel { - abbreviation: String; - definition: String; - id: String; - pid: String; - label: String; - reference: String; - uri: String; - source: String; -} diff --git a/dmp-frontend/src/app/core/model/researcher/researcher.ts b/dmp-frontend/src/app/core/model/researcher/researcher.ts deleted file mode 100644 index 9d23a8403..000000000 --- a/dmp-frontend/src/app/core/model/researcher/researcher.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface ResearcherModel { - id: string; - name: String; - reference: String; - lastName: String; - uri: String; - email: String; -} diff --git a/dmp-frontend/src/app/core/model/service/service.ts b/dmp-frontend/src/app/core/model/service/service.ts deleted file mode 100644 index 699a1c613..000000000 --- a/dmp-frontend/src/app/core/model/service/service.ts +++ /dev/null @@ -1,10 +0,0 @@ -export interface ServiceModel { - id: String; - abbreviation: String; - definition: String; - uri: String; - label: String; - reference: String; - source: String; -} - diff --git a/dmp-frontend/src/app/core/model/supportive-material/supportive-material.ts b/dmp-frontend/src/app/core/model/supportive-material/supportive-material.ts index adfca35ff..64e63c599 100644 --- a/dmp-frontend/src/app/core/model/supportive-material/supportive-material.ts +++ b/dmp-frontend/src/app/core/model/supportive-material/supportive-material.ts @@ -1,15 +1,15 @@ import { SupportiveMaterialFieldType } from "@app/core/common/enum/supportive-material-field-type"; import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; -export interface SupportiveMaterial extends BaseEntity{ - type: SupportiveMaterialFieldType; - languageCode: string; - payload: string; +export interface SupportiveMaterial extends BaseEntity { + type: SupportiveMaterialFieldType; + languageCode: string; + payload: string; } -export interface SupportiveMaterialPersist extends BaseEntityPersist{ - type: SupportiveMaterialFieldType; - languageCode: string; - payload: string; +export interface SupportiveMaterialPersist extends BaseEntityPersist { + type: SupportiveMaterialFieldType; + languageCode: string; + payload: string; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/tag/tag.ts b/dmp-frontend/src/app/core/model/tag/tag.ts index 68204c2c9..757216fa6 100644 --- a/dmp-frontend/src/app/core/model/tag/tag.ts +++ b/dmp-frontend/src/app/core/model/tag/tag.ts @@ -1,12 +1,11 @@ -import { BaseEntity } from "@common/base/base-entity.model"; +import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; import { User } from "../user/user"; -export interface TagModel { //TODO: old entity, delete - id: string; - name: string; -} - export interface Tag extends BaseEntity { label?: string; createdBy?: User; } + +export interface TagPersist extends BaseEntityPersist { + label?: string; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/taxonomy/taxonomy.ts b/dmp-frontend/src/app/core/model/taxonomy/taxonomy.ts deleted file mode 100644 index b8be84ca4..000000000 --- a/dmp-frontend/src/app/core/model/taxonomy/taxonomy.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface TaxonomyModel { - id: string; - name: string; - abbreviation: string; - uri: string; - pid: string; - info: string; - source: string; -} diff --git a/dmp-frontend/src/app/core/model/unlink-account/unlink-account.ts b/dmp-frontend/src/app/core/model/unlink-account/unlink-account.ts deleted file mode 100644 index 89c6aa33a..000000000 --- a/dmp-frontend/src/app/core/model/unlink-account/unlink-account.ts +++ /dev/null @@ -1,5 +0,0 @@ -export class UnlinkAccountRequestModel { - userId: String; - email: String; - provider: number; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/user/user-credential.ts b/dmp-frontend/src/app/core/model/user/user-credential.ts deleted file mode 100644 index fe716aea0..000000000 --- a/dmp-frontend/src/app/core/model/user/user-credential.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { AuthProvider } from '@app/core/common/enum/auth-provider'; - -export class UserCredentialModel { - email: string; - provider: AuthProvider; -} diff --git a/dmp-frontend/src/app/core/model/user/user-info-listing.ts b/dmp-frontend/src/app/core/model/user/user-info-listing.ts deleted file mode 100644 index 9da6b457f..000000000 --- a/dmp-frontend/src/app/core/model/user/user-info-listing.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface UserInfoListingModel { - id: String; - name: String; - role: number; - email: String; -} diff --git a/dmp-frontend/src/app/core/model/user/user-listing.ts b/dmp-frontend/src/app/core/model/user/user-listing.ts deleted file mode 100644 index 3c79e8664..000000000 --- a/dmp-frontend/src/app/core/model/user/user-listing.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; -import { AppRole } from "../../common/enum/app-role"; -import { OrganizationModel } from '../organisation/organization'; - -export interface UserListingModel { - id: String; - name: String; - email: string; - appRoles: AppRole[]; - associatedDmps: any[]; - language: any; - culture: any; - timezone: String; - avatarUrl: String; - organization: OrganizationModel; - roleOrganization: RoleOrganizationType; -} diff --git a/dmp-frontend/src/app/core/model/user/user.ts b/dmp-frontend/src/app/core/model/user/user.ts index f253d72c0..8e95be828 100644 --- a/dmp-frontend/src/app/core/model/user/user.ts +++ b/dmp-frontend/src/app/core/model/user/user.ts @@ -1,16 +1,9 @@ import { ContactInfoType } from "@app/core/common/enum/contact-info-type"; +import { RoleOrganizationType } from "@app/core/common/enum/role-organization-type"; import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; import { Guid } from "@common/types/guid"; -import { AppRole } from "../../common/enum/app-role"; import { Reference } from "../reference/reference"; -export interface UserModel { //TODO: Delete after refactor, since its old model. - id: String; - name: String; - appRoles: AppRole[]; - email: String; -} - export interface User extends BaseEntity { name: string; additionalInfo: UserAdditionalInfo; @@ -38,7 +31,7 @@ export interface UserAdditionalInfo { timezone: String; culture: String; language: String; - roleOrganization: String; + roleOrganization: RoleOrganizationType; organization: Reference; } diff --git a/dmp-frontend/src/app/core/model/version/version-listing.model.ts b/dmp-frontend/src/app/core/model/version/version-listing.model.ts deleted file mode 100644 index 571f2d361..000000000 --- a/dmp-frontend/src/app/core/model/version/version-listing.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface VersionListingModel { - id: string; - groupId: string; - version: number; -} diff --git a/dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts b/dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts deleted file mode 100644 index fd9e2e4f2..000000000 --- a/dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { UntypedFormGroup } from "@angular/forms"; - -@Pipe({ - name: 'datasetInSection' -}) -export class DatasetInSectioPipe implements PipeTransform{ - - transform(datasets: UntypedFormGroup[], args: string): UntypedFormGroup[] { - let values = []; - for(var dataset of datasets){ - if(dataset.get('dmpSectionIndex').value == args){ - values.push(dataset); - } - } - return values; - } -} \ No newline at end of file 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 360b8e87e..0e14cb8b5 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,6 @@ -import {Pipe, PipeTransform} from "@angular/core"; -import {DatePipe} from "@angular/common"; -import {DatasetProfileFieldViewStyle} from "@app/core/common/enum/dataset-profile-field-view-style"; +import { DatePipe } from "@angular/common"; +import { Pipe, PipeTransform } from "@angular/core"; +import { DescriptionTemplateFieldType } from "../common/enum/description-template-field-type"; @Pipe({ name: 'fieldValue' @@ -15,56 +15,59 @@ export class FieldValuePipe implements PipeTransform { let renderStyle = controlValue.viewStyle?.renderStyle; if (renderStyle && value) { switch (renderStyle) { - case DatasetProfileFieldViewStyle.Currency: + case DescriptionTemplateFieldType.CURRENCY: if (value) { return JSON.parse(value).name; } break; - case DatasetProfileFieldViewStyle.BooleanDecision: + case DescriptionTemplateFieldType.BOOLEAN_DECISION: return value == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'; - case DatasetProfileFieldViewStyle.CheckBox: + case DescriptionTemplateFieldType.CHECK_BOX: return value ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'; - case DatasetProfileFieldViewStyle.RadioBox: + case DescriptionTemplateFieldType.RADIO_BOX: if (value && controlValue.data.options) { return controlValue.data.options.find(option => option.value === value).label; } break; - case DatasetProfileFieldViewStyle.DatePicker: + case DescriptionTemplateFieldType.DATE_PICKER: return this.date.transform(controlValue.value, 'dd/MM/yyyy'); - case DatasetProfileFieldViewStyle.FreeText: + case DescriptionTemplateFieldType.FREE_TEXT: return value; - case DatasetProfileFieldViewStyle.ComboBox: + case DescriptionTemplateFieldType.AUTO_COMPLETE: + case DescriptionTemplateFieldType.WORD_LIST: if (value && controlValue.data.options && !controlValue.data.multiList) { return controlValue.data.options.find(option => value == option.value).label; } else if (value && controlValue.data.options && controlValue.data.multiList) { return controlValue.data.options.filter(option => value.includes(option.value)).map(option => option.label).join(','); } break; - case DatasetProfileFieldViewStyle.RichTextArea: - if(value) { + case DescriptionTemplateFieldType.RICH_TEXT_AREA: + if (value) { return value.replace(/ /g, ' ').replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ").replace(/<[^>]*>/g, ''); } break; - case DatasetProfileFieldViewStyle.TextArea: + case DescriptionTemplateFieldType.TEXT_AREA: return value; - case DatasetProfileFieldViewStyle.Registries: - case DatasetProfileFieldViewStyle.Services: - case DatasetProfileFieldViewStyle.Researchers: - case DatasetProfileFieldViewStyle.Organizations: - case DatasetProfileFieldViewStyle.ExternalDatasets: - case DatasetProfileFieldViewStyle.DataRepositories: - case DatasetProfileFieldViewStyle.PubRepositories: - case DatasetProfileFieldViewStyle.JournalRepositories: - case DatasetProfileFieldViewStyle.Taxonomies: - case DatasetProfileFieldViewStyle.Licenses: - case DatasetProfileFieldViewStyle.Publications: - case DatasetProfileFieldViewStyle.Tags: + case DescriptionTemplateFieldType.REGISTRIES: + case DescriptionTemplateFieldType.SERVICES: + case DescriptionTemplateFieldType.RESEARCHERS: + case DescriptionTemplateFieldType.ORGANIZATIONS: + 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 DatasetProfileFieldViewStyle.InternalDmpEntities: + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DATASETS: return this.parseJson(value, 'label'); - case DatasetProfileFieldViewStyle.DatasetIdentifier: - case DatasetProfileFieldViewStyle.Validation: - if(value && value.identifier) { + case DescriptionTemplateFieldType.DATASET_IDENTIFIER: + case DescriptionTemplateFieldType.VALIDATION: + if (value && value.identifier) { return value.identifier; } break; @@ -76,7 +79,7 @@ export class FieldValuePipe implements PipeTransform { } public parseJson(value: any, field: string = 'name') { - if(Array.isArray(value)) { + if (Array.isArray(value)) { return value.map(element => JSON.parse(element)[field]).join(','); } else { return JSON.parse(value)[field]; diff --git a/dmp-frontend/src/app/core/query/data-repository/data-repository-criteria.ts b/dmp-frontend/src/app/core/query/data-repository/data-repository-criteria.ts deleted file mode 100644 index c4f286878..000000000 --- a/dmp-frontend/src/app/core/query/data-repository/data-repository-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class DataRepositoryCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/dataset-profile/dataset-profile-criteria.ts b/dmp-frontend/src/app/core/query/dataset-profile/dataset-profile-criteria.ts deleted file mode 100644 index b9bbd9b5e..000000000 --- a/dmp-frontend/src/app/core/query/dataset-profile/dataset-profile-criteria.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class DatasetProfileCriteria extends BaseCriteria { - public id: String; - public groupIds: string[]; - public allVersions: boolean; - public finalized: boolean = true; - public status: number; -} diff --git a/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts b/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts deleted file mode 100644 index f32a40cd6..000000000 --- a/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { AutoCompleteSingleData } from "@app/core/model/dataset-profile-definition/field-data/field-data"; -import { BaseCriteria } from "../base-criteria"; - -export class DatasetExternalAutocompleteCriteria extends BaseCriteria { - public profileID: String; - public fieldID: String; -} - -export class DatasetExternalAutocompleteOptionsCriteria extends BaseCriteria { - public autoCompleteSingleDataList: AutoCompleteSingleData[]; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts b/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts deleted file mode 100644 index 8ec8a8edb..000000000 --- a/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ExternalSourceItemModel } from "../../model/external-sources/external-source-item"; -import { BaseCriteria } from "../base-criteria"; - -export class DatasetCriteria extends BaseCriteria { - public grants?: string[] = []; - public status?: Number; - public dmpIds?: string[] = []; - public tags?: ExternalSourceItemModel[] = []; - public allVersions?: boolean = false; - public role?: number; - public organisations?: string[] = []; - public collaborators?: string[] = []; - public datasetTemplates?: string[] = []; - public groupIds?: string[] = []; - public isPublic?: boolean = false; - public grantStatus?: number; -} diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts deleted file mode 100644 index f3e1a430a..000000000 --- a/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DmpBlueprintStatus } from "@app/core/common/enum/dmp-blueprint-status"; -import { BaseCriteria } from "../base-criteria"; - -export class DmpBlueprintCriteria extends BaseCriteria { - public status?: DmpBlueprintStatus; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts deleted file mode 100644 index 5e024c1d3..000000000 --- a/dmp-frontend/src/app/core/query/dmp/dmp-criteria.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { GrantListingModel } from "../../model/grant/grant-listing"; -import { BaseCriteria } from "../base-criteria"; -import { OrganizationModel } from "../../model/organisation/organization"; - -export class DmpCriteria extends BaseCriteria { - public organisations?: string[] = []; - public grants?: GrantListingModel[] = []; - public groupIds?: string[]; - public allVersions?: boolean; - public status?: number; - public role?: number; - public collaborators?: string[] = []; - public datasetTemplates?: string[] = []; - public isPublic?: boolean; - public onlyPublic?: boolean; - public grantStatus?: boolean; -} diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-invitation-user-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-invitation-user-criteria.ts deleted file mode 100644 index 32c0b6653..000000000 --- a/dmp-frontend/src/app/core/query/dmp/dmp-invitation-user-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class DmpInvitationUserCriteria extends BaseCriteria { - -} diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-profile-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-profile-criteria.ts deleted file mode 100644 index 71f660eae..000000000 --- a/dmp-frontend/src/app/core/query/dmp/dmp-profile-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class DmpBlueprintCriteria extends BaseCriteria { - -} diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-profile-external-autocomplete-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-profile-external-autocomplete-criteria.ts deleted file mode 100644 index 1e57f9192..000000000 --- a/dmp-frontend/src/app/core/query/dmp/dmp-profile-external-autocomplete-criteria.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class DmpBlueprintExternalAutocompleteCriteria extends BaseCriteria { - public profileID: String; - public fieldID: String; -} diff --git a/dmp-frontend/src/app/core/query/explore-dataset/explore-dataset-criteria.ts b/dmp-frontend/src/app/core/query/explore-dataset/explore-dataset-criteria.ts deleted file mode 100644 index 7c10b2bf0..000000000 --- a/dmp-frontend/src/app/core/query/explore-dataset/explore-dataset-criteria.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { GrantStateType } from "../../common/enum/grant-state-type"; -import { BaseCriteria } from "../base-criteria"; -import { Role } from '../../common/enum/role'; - -export class ExploreDatasetCriteriaModel extends BaseCriteria { - public grantStatus: GrantStateType; - public role: Role; - public dmpIds: string[] = []; - public grants: string[] = []; - public datasetProfile: string[] = []; - public dmpOrganisations: string[] = []; - public tags = []; -} diff --git a/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts b/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts deleted file mode 100644 index 376d14196..000000000 --- a/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; -import { GrantStateType } from "../../common/enum/grant-state-type"; -import { Role } from '../../common/enum/role'; - -export class ExploreDmpCriteriaModel extends BaseCriteria { - public grantStatus: GrantStateType; - public role: Role; - public grants: string[] = []; - public datasetProfile: string[] = []; - public dmpOrganisations: string[] = []; - public allVersions: boolean; - public groupIds: string[] = []; -} diff --git a/dmp-frontend/src/app/core/query/external-dataset/external-dataset-criteria.ts b/dmp-frontend/src/app/core/query/external-dataset/external-dataset-criteria.ts deleted file mode 100644 index dec991910..000000000 --- a/dmp-frontend/src/app/core/query/external-dataset/external-dataset-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class ExternalDatasetCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/funder/funder-criteria.ts b/dmp-frontend/src/app/core/query/funder/funder-criteria.ts deleted file mode 100644 index 6c37051b8..000000000 --- a/dmp-frontend/src/app/core/query/funder/funder-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class FunderCriteria extends BaseCriteria { - exactReference:string; - } diff --git a/dmp-frontend/src/app/core/query/grant/grant-criteria.ts b/dmp-frontend/src/app/core/query/grant/grant-criteria.ts deleted file mode 100644 index da457031c..000000000 --- a/dmp-frontend/src/app/core/query/grant/grant-criteria.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { GrantStateType } from "../../common/enum/grant-state-type"; -import { BaseCriteria } from "../base-criteria"; - -export class GrantCriteria extends BaseCriteria { - public periodStart: Date; - public periodEnd: Date; - public funderReference: String; - public grantStateType: GrantStateType; - public exactReference: string; -} diff --git a/dmp-frontend/src/app/core/query/license/license-criteria.ts b/dmp-frontend/src/app/core/query/license/license-criteria.ts deleted file mode 100644 index ea2c3138a..000000000 --- a/dmp-frontend/src/app/core/query/license/license-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class LicenseCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts b/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts deleted file mode 100644 index 2012bf40a..000000000 --- a/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class OrganisationCriteria extends BaseCriteria { - public labelLike: string; - public like?: string; -} diff --git a/dmp-frontend/src/app/core/query/project/project-criteria.ts b/dmp-frontend/src/app/core/query/project/project-criteria.ts deleted file mode 100644 index 47a0d88b9..000000000 --- a/dmp-frontend/src/app/core/query/project/project-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class ProjectCriteria extends BaseCriteria { - exactReference: string; - } diff --git a/dmp-frontend/src/app/core/query/publication/publication-criteria.ts b/dmp-frontend/src/app/core/query/publication/publication-criteria.ts deleted file mode 100644 index c7d7d6b27..000000000 --- a/dmp-frontend/src/app/core/query/publication/publication-criteria.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; -export class PublicationCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/registry/registry-criteria.ts b/dmp-frontend/src/app/core/query/registry/registry-criteria.ts deleted file mode 100644 index be7d0da31..000000000 --- a/dmp-frontend/src/app/core/query/registry/registry-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class RegistryCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/researcher/researcher-criteria.ts b/dmp-frontend/src/app/core/query/researcher/researcher-criteria.ts deleted file mode 100644 index fd529c381..000000000 --- a/dmp-frontend/src/app/core/query/researcher/researcher-criteria.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class ResearcherCriteria extends BaseCriteria { - public name: String; - public reference?: string; -} diff --git a/dmp-frontend/src/app/core/query/service/service-criteria.ts b/dmp-frontend/src/app/core/query/service/service-criteria.ts deleted file mode 100644 index 8c397cf4d..000000000 --- a/dmp-frontend/src/app/core/query/service/service-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class ServiceCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/tag.lookup.ts b/dmp-frontend/src/app/core/query/tag.lookup.ts new file mode 100644 index 000000000..28627e99d --- /dev/null +++ b/dmp-frontend/src/app/core/query/tag.lookup.ts @@ -0,0 +1,23 @@ +import { Lookup } from "@common/model/lookup"; +import { Guid } from "@common/types/guid"; +import { IsActive } from "../common/enum/is-active.enum"; + +export class TagLookup extends Lookup implements TagFilter { + ids: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + createdByIds: Guid[]; + + constructor() { + super(); + } +} + +export interface TagFilter { + ids: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + createdByIds: Guid[]; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/tag/tag-criteria.ts b/dmp-frontend/src/app/core/query/tag/tag-criteria.ts deleted file mode 100644 index e78ed43c6..000000000 --- a/dmp-frontend/src/app/core/query/tag/tag-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class TagCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/taxonomy/taxonomy-criteria.ts b/dmp-frontend/src/app/core/query/taxonomy/taxonomy-criteria.ts deleted file mode 100644 index 0d94bc701..000000000 --- a/dmp-frontend/src/app/core/query/taxonomy/taxonomy-criteria.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseCriteria } from "../base-criteria"; - -export class TaxonomyCriteria extends BaseCriteria { - public type: string; -} diff --git a/dmp-frontend/src/app/core/query/user/user-criteria.ts b/dmp-frontend/src/app/core/query/user/user-criteria.ts deleted file mode 100644 index 17c986c48..000000000 --- a/dmp-frontend/src/app/core/query/user/user-criteria.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { AppRole } from "../../common/enum/app-role"; -import { BaseCriteria } from "../base-criteria"; - -export class UserCriteria extends BaseCriteria { - public label: String; - public appRoles: AppRole[]; - public collaboratorLike: string; -} diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index be4e7ebfc..72eaee247 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -143,7 +143,7 @@ export class AuthService extends BaseService { this.accessToken ? this.principalService.me(httpParams) : of(null) ])), map((item) => { - this.currentAccount(item[0]); + this.currentAccount(item[0]?.payload); return true; }) ); diff --git a/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts b/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts index 3d2610eb5..9105f77b4 100644 --- a/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts +++ b/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts @@ -1,17 +1,15 @@ -import { BaseHttpService } from "../../../core/services/http/base-http.service"; -import { HttpHeaders } from "@angular/common/http"; -import { environment } from "../../../../environments/environment"; import { Injectable } from "@angular/core"; -import { ContactEmail } from "../../model/contact/contact-email-form-model"; import { Observable } from "rxjs"; +import { ContactEmail } from "../../model/contact/contact-email-form-model"; import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from "../http/base-http-v2.service"; @Injectable() export class ContactSupportService { private actionUrl: string; - constructor(private http: BaseHttpService, + constructor(private http: BaseHttpV2Service, private configurationService: ConfigurationService) { this.actionUrl = configurationService.server + 'contactEmail/'; } diff --git a/dmp-frontend/src/app/core/services/currency/currency.service.ts b/dmp-frontend/src/app/core/services/currency/currency.service.ts deleted file mode 100644 index 77fcf084c..000000000 --- a/dmp-frontend/src/app/core/services/currency/currency.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ConfigurationService } from '../configuration/configuration.service'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; -import { BaseHttpService } from '../http/base-http.service'; - - - -@Injectable() -export class CurrencyService { - - private actionUrl: string; - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'currency'; - } - - get(query: string): Observable { - return this.http.get(`${this.actionUrl}?query=${query}`); - } - -} diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts deleted file mode 100644 index 521b71da7..000000000 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { DatasetProfile } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileDefinitionModel } from '@app/core/model/dataset-profile-definition/dataset-profile-definition'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { BaseHttpService } from '@app/core/services/http/base-http.service'; -import { DatasetProfileEditorModel } from '@app/ui/admin/dataset-profile/editor/dataset-profile-editor-model'; -import { BaseService } from '@common/base/base.service'; -import { BaseHttpParams } from '@common/http/base-http-params'; -import { InterceptorType } from '@common/http/interceptors/interceptor-type'; -import { environment } from 'environments/environment'; -import { Observable } from 'rxjs'; -import { takeUntil } from "rxjs/operators"; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class DatasetProfileService extends BaseService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - super(); - this.actionUrl = configurationService.server + 'admin/'; - } - - createForm(data) { - return this.httpClient.post(this.actionUrl + 'addDmp', data); - } - - updateForm(id, data): Observable { - return this.http.post(this.actionUrl + 'addDmp/' + id, data); - } - - getDatasetProfileById(datasetProfileID): Observable { - return this.http.get(this.actionUrl + 'get/' + datasetProfileID); - } - - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest); - } - - preview(data: DatasetProfile): Observable { - return this.http.post(this.actionUrl + 'preview', data); - } - - clone(id: string): Observable { - return this.http.post(this.actionUrl + 'datasetprofile/clone/' + id, {}); - } - - newVersion(id, data) { - return this.httpClient.post(this.actionUrl + 'newVersion/' + id, data); - } - - delete(id: string, data): Observable { - //return this.http.post(this.actionUrl + 'addDmp/' + id, data); - return this.http.delete(this.actionUrl + id, {}); - } - - downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml }); - } - - uploadFile(file: FileList, labelSent: string, datasetProfileId?: string): Observable> { - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - const formData = new FormData(); - formData.append('file', file[0], labelSent); - return (datasetProfileId === undefined || datasetProfileId == null) - ? this.http.post(this.actionUrl + "upload", formData, { params: params }) - : this.http.post(this.actionUrl + "upload/" + datasetProfileId, formData, { params: params }); - - } - - searchSemantics(like: string): Observable { - return this.http.get(this.actionUrl + "getSemantics?query=" + like); - } -} diff --git a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts deleted file mode 100644 index 437a413ea..000000000 --- a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { BaseHttpParams } from '../../../../common/http/base-http-params'; -import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; -import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition'; -import { DatasetProfileModel } from '../../model/dataset/dataset-profile'; -import { DatasetWizardModel } from '../../model/dataset/dataset-wizard'; -import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; -import { RequestItem } from '../../query/request-item'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class DatasetWizardService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'datasets/'; - } - - // public userDmps(criteria: RequestItem): Observable { - // return this.http.post(this.actionUrl + 'userDmps', criteria, { headers: this.headers }); - // } - - public getAvailableProfiles(criteria: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers }); - } - - public getSingle(id: String): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); // + 'getSingle/' - } - - public getSinglePublic(id: String): Observable { - return this.http.get(this.actionUrl + 'public/' + id, { headers: this.headers }); // + 'getSingle/' - } - - public delete(id: string): Observable { - return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); - } - - createDataset(datasetModel: DatasetWizardModel): Observable { - return this.http.post(this.actionUrl, datasetModel, { headers: this.headers }); - } - - public downloadPDF(id: string): Observable> { - return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: this.headers }); - } - - public downloadDOCX(id: string): Observable> { - let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDocx }); - } - - public downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); // + 'getXml/' - } - - public getDefinition(id: String): Observable { - return this.http.get(this.actionUrl + 'get/' + id, { headers: this.headers }); - } - - unlock(id: String): Observable { - return this.http.get(this.actionUrl + id + '/unlock', { headers: this.headers }); - } - - public uploadXml(fileList: FileList, datasetTitle: string, dmpId: string, datasetProfileId: string): Observable { - const formData: FormData = new FormData(); - if (fileList instanceof FileList) { - for (let i = 0; i < fileList.length; i++) { - formData.append('file', fileList[i], datasetTitle); - } - } else if (Array.isArray(fileList)) { - formData.append('files', fileList); - } else { - formData.append('file', fileList); - } - formData.append('dmpId', dmpId); - formData.append('datasetProfileId', datasetProfileId); - - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - return this.http.post(this.actionUrl + 'upload', formData, { params: params }); - } - - public updateDatasetProfile(id: String): Observable { - return this.http.get(this.actionUrl + "profile/" + id, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts deleted file mode 100644 index 48e7348cf..000000000 --- a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria'; -import { RequestItem } from '../../query/request-item'; -import { DatasetProfileService } from '../dataset-profile/dataset-profile.service'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { map } from 'rxjs/operators'; - -@Injectable() -export class DatasetExternalAutocompleteService { - - private actionUrl: string; - - constructor( - private httpClient: HttpClient, - private datasetProfileService: DatasetProfileService, - private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + '/'; - } - - getDatasetProfileById(datasetProfileID) { - return this.datasetProfileService.getDatasetProfileById(datasetProfileID); - } - - queryAutocomplete(lookUpItem: RequestItem): Observable { - return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem); - } - - queryApi(lookUpItem: RequestItem): Observable{ - return this.httpClient.post(this.configurationService.server + 'search/autocompleteOptions', lookUpItem); - } - -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts deleted file mode 100644 index 418196418..000000000 --- a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DataTableData } from '../../model/data-table/data-table-data'; -import { DataTableRequest } from '../../model/data-table/data-table-request'; -import { DatasetListingModel } from '../../model/dataset/dataset-listing'; -import { DatasetProfileModel } from '../../model/dataset/dataset-profile'; -import { DatasetCriteria } from '../../query/dataset/dataset-criteria'; -import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria'; -import { BaseHttpService } from '../http/base-http.service'; -import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview'; -import { HttpHeaders, HttpResponse, HttpClient } from '@angular/common/http'; -import { DatasetModel } from '@app/core/model/dataset/dataset'; - -@Injectable() -export class DatasetService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor( - private http: BaseHttpService, - private configurationSevice: ConfigurationService, - private httpClient: HttpClient) { - this.actionUrl = configurationSevice.server + 'datasets/'; - } - - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'paged', dataTableRequest); - } - - getPublicPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'public/paged', dataTableRequest); - } - - makeDatasetPublic(id: String) { - return this.http.get(this.actionUrl + 'makepublic/' + id); - } - - getDatasetProfiles(dataTableRequest: DataTableRequest): Observable { - return this.http.post(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest); - } - - getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest) { - return this.http.post>(this.actionUrl + 'datasetProfilesUsedByDatasets/paged', dataTableRequest); - } - - generateIndex() { - return this.http.post(this.actionUrl + 'index', {}); - } - - clearIndex() { - return this.http.delete(this.actionUrl + 'index'); - } - - getOverviewSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'overview/' + id, { headers: this.headers }); - } - - getOverviewSinglePublic(id: string): Observable { - return this.http.get(this.actionUrl + 'publicOverview/' + id, { headers: this.headers }) - } - - clone(datasetModel: DatasetModel, id: String): Observable { - return this.http.post(this.actionUrl + 'clone/' + id, datasetModel, { headers: this.headers }); - } - - delete(id: String): Observable { - return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); // + 'delete/' - } - - publish(id: String): Observable { - return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }); - } - - public downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); //+ "/getXml/" - } - - public downloadDocx(id: string): Observable> { - let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDoc }); - } - - public downloadPDF(id: string): Observable> { - let headerPdf: HttpHeaders = this.headers.set('Content-Type', 'application/pdf') - return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf }); - } - - public validateDataset(id: string) : Observable{ - return this.http.get(this.actionUrl+id+"/validate"); - } - - //GK: NO - // public downloadJson(id: string): Observable> { - // return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); - // } -} diff --git a/dmp-frontend/src/app/core/services/deposit-repositories/deposit-repositories.service.ts b/dmp-frontend/src/app/core/services/deposit-repositories/deposit-repositories.service.ts deleted file mode 100644 index c40347075..000000000 --- a/dmp-frontend/src/app/core/services/deposit-repositories/deposit-repositories.service.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration'; -import { DepositCode, DepositRequest } from '@app/core/model/deposit/deposit-request'; -import { DoiModel } from '@app/core/model/doi/doi'; -import { Observable } from 'rxjs'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { BaseHttpService } from '../http/base-http.service'; - -@Injectable() -export class DepositRepositoriesService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'deposit/'; - } - - getAvailableRepos(): Observable { - return this.http.get(this.actionUrl + 'repos', { headers: this.headers }); - } - - getAccessToken(repositoryId: string, code: string): Observable { - const depositCode = new DepositCode(); - depositCode.repositoryId = repositoryId; - depositCode.code = code; - return this.http.post(this.actionUrl + 'getAccessToken', depositCode, { headers: this.headers }); - } - - createDoi(repositoryId: string, dmpId: string, accessToken: string | null): Observable { - const depositRequest = new DepositRequest(); - depositRequest.repositoryId = repositoryId; - depositRequest.dmpId = dmpId; - depositRequest.accessToken = accessToken; - return this.http.post(this.actionUrl + 'createDoi', depositRequest, { headers: this.headers }); - } - - getLogo(repositoryId: string): Observable { - return this.http.get(this.actionUrl + 'logo/' + repositoryId, { headers: this.headers }); - } - -} diff --git a/dmp-frontend/src/app/core/services/deposit/deposit.service.ts b/dmp-frontend/src/app/core/services/deposit/deposit.service.ts new file mode 100644 index 000000000..4c8cf1803 --- /dev/null +++ b/dmp-frontend/src/app/core/services/deposit/deposit.service.ts @@ -0,0 +1,48 @@ +import { HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { DepositConfiguration } from '@app/core/model/deposit/deposit-configuration'; +import { DepositAuthenticateRequest, DepositRequest } from '@app/core/model/deposit/deposit-request'; +import { EntityDoi } from '@app/core/model/entity-doi/entity-doi'; +import { Observable, throwError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from '../http/base-http-v2.service'; + +@Injectable() +export class DepositService { + + private headers = new HttpHeaders(); + + constructor( + private http: BaseHttpV2Service, + private configurationService: ConfigurationService + ) { + } + + private get apiBase(): string { return `${this.configurationService.server}deposit`; } + + getAvailableRepos(reqFields: string[] = []): Observable { + const url = `${this.apiBase}/repositories/available`; + const options = { params: { f: reqFields } }; + + return this.http + .get(url, options).pipe( + catchError((error: any) => throwError(error))); + } + + getAccessToken(item: DepositAuthenticateRequest): Observable { + const url = `${this.apiBase}/get-access-token`; + return this.http.post(url, item).pipe(catchError((error: any) => throwError(error))); + } + + deposit(item: DepositRequest): Observable { + const url = `${this.apiBase}/deposit`; + return this.http.post(url, item).pipe(catchError((error: any) => throwError(error))); + } + + getLogo(repositoryId: string): Observable { + const url = `${this.apiBase}/repositories/${repositoryId}/logo`; + return this.http + .get(url).pipe(catchError((error: any) => throwError(error))); + } +} diff --git a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts index cf3ad57f4..e4cda2701 100644 --- a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts +++ b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts @@ -1,7 +1,6 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { DescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist'; import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup'; @@ -77,7 +76,7 @@ export class DescriptionTemplateService { return this.httpClient.get(url, { params: params, responseType: 'blob', observe: 'response', headers: headerXml }); } - uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable> { + uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable { const url = `${this.apiBase}/xml/import`; const params = new BaseHttpParams(); params.interceptorContext = { @@ -111,7 +110,7 @@ export class DescriptionTemplateService { valueAssign: (item: DescriptionTemplate) => item.id, }; - private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateLookup { + public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateLookup { const lookup: DescriptionTemplateLookup = new DescriptionTemplateLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } diff --git a/dmp-frontend/src/app/core/services/description/description.service.ts b/dmp-frontend/src/app/core/services/description/description.service.ts index 8e7309812..69725a8c9 100644 --- a/dmp-frontend/src/app/core/services/description/description.service.ts +++ b/dmp-frontend/src/app/core/services/description/description.service.ts @@ -86,10 +86,6 @@ export class DescriptionService { return this.httpClient.get(`${this.apiBase}/${id}/export/${format}`, { responseType: 'blob', observe: 'response', headers: this.headers }); } - public getExportFormats(): Observable { - return this.httpClient.get(`${this.apiBase}/export/formats`); - } - // // Autocomplete Commons // @@ -113,7 +109,7 @@ export class DescriptionService { valueAssign: (item: Description) => item.id, }; - private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionLookup { + public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionLookup { const lookup: DescriptionLookup = new DescriptionLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts index 222c958d1..eb788298a 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts @@ -1,8 +1,7 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DmpBlueprint, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DmpBlueprint, DmpBlueprintDefinitionSection, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; @@ -76,7 +75,7 @@ export class DmpBlueprintService { return this.httpClient.get(url, { params: params, responseType: 'blob', observe: 'response', headers: headerXml }); } - uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable> { + uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable { const url = `${this.apiBase}/xml/import`; const params = new BaseHttpParams(); params.interceptorContext = { @@ -126,4 +125,14 @@ export class DmpBlueprintService { if (like) { lookup.like = this.filterService.transformLike(like); } return lookup; } + + // + // + // UI Helpers + // + // + + getSection(dmpBlueprint: DmpBlueprint, sectionId: Guid): DmpBlueprintDefinitionSection { + return dmpBlueprint?.definition?.sections?.find(x => x.id === sectionId); + } } diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts deleted file mode 100644 index a19663de8..000000000 --- a/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { RequestItem } from '../../query/request-item'; -import { DmpInvitation } from '../../model/dmp/invitation/dmp-invitation'; -import { DmpInvitationUser } from '../../model/dmp/invitation/dmp-invitation-user'; -import { DmpInvitationUserCriteria } from '../../query/dmp/dmp-invitation-user-criteria'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class DmpInvitationService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'invite/'; - } - - public inviteDmpInvitationUsers(invitation: DmpInvitation): Observable { - return this.http.post(this.actionUrl + 'users', invitation, { headers: this.headers }); - } - - public getDmpInvitationUsers(usersInvitationRequestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getUsers', usersInvitationRequestItem, { headers: this.headers }); - } - - public exchange(id: String): Observable { - return this.http.get(this.actionUrl + 'exchange/' + id, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 0dfcad89a..722cd8ac9 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -1,9 +1,9 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { VersionListingModel } from '@app/core/model/version/version-listing.model'; +import { DmpDescriptionTemplateLookup } from '@app/core/query/dmp-description-template.lookup'; import { DmpLookup } from '@app/core/query/dmp.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; @@ -15,29 +15,13 @@ import { catchError, map } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { BaseHttpParams } from '../../../../common/http/base-http-params'; import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; -import { DynamicFieldGrantCriteria } from '../../../models/dynamic-field-grant/DynamicFieldGrantCriteria'; -import { DataTableData } from '../../model/data-table/data-table-data'; -import { DataTableRequest } from '../../model/data-table/data-table-request'; -import { DatasetListingModel } from '../../model/dataset/dataset-listing'; -import { DatasetProfileModel } from '../../model/dataset/dataset-profile'; -import { DatasetsToBeFinalized } from '../../model/dataset/datasets-toBeFinalized'; -import { CloneDmpPersist, Dmp, DmpModel, DmpPersist, DmpUser, DmpUserPersist, DmpUserRemovePersist, NewVersionDmpPersist } from '../../model/dmp/dmp'; -import { DmpListingModel } from '../../model/dmp/dmp-listing'; -import { DmpOverviewModel } from '../../model/dmp/dmp-overview'; -import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; -import { DmpCriteria } from '../../query/dmp/dmp-criteria'; -import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria'; -import { RequestItem } from '../../query/request-item'; +import { CloneDmpPersist, Dmp, DmpPersist, DmpUser, DmpUserInvitePersist, DmpUserPersist, DmpUserRemovePersist, NewVersionDmpPersist } from '../../model/dmp/dmp'; import { AuthService } from '../auth/auth.service'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; -import { BaseHttpService } from '../http/base-http.service'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { DmpDescriptionTemplateLookup } from '@app/core/query/dmp-description-template.lookup'; -import { FileFormat } from '@app/core/model/file/file-format.model'; @Injectable() -export class DmpServiceNew { +export class DmpService { private headers = new HttpHeaders(); @@ -105,7 +89,7 @@ export class DmpServiceNew { const options = { params: { f: reqFields } }; return this.http - .get(url, options).pipe( + .post(url, item).pipe( catchError((error: any) => throwError(error))); } @@ -126,6 +110,20 @@ export class DmpServiceNew { catchError((error: any) => throwError(error))); } + inviteUsers(dmpId: Guid, item: DmpUserInvitePersist): Observable { + const url = `${this.apiBase}/${dmpId}/invite-users`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + + acceptInvitation(dmpId: Guid, token: string): Observable { + const url = `${this.apiBase}/${dmpId}/token/${token}/invite-accept`; + + return this.http.get(url).pipe(catchError((error: any) => throwError(error))); + } + public download(id: string, format: string): Observable> { //let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword') return this.httpClient.get(`${this.apiBase}/${id}/export/${format}`, { responseType: 'blob', observe: 'response', headers: this.headers }); @@ -136,10 +134,6 @@ export class DmpServiceNew { return this.httpClient.get(`${this.apiBase}/${id}/export/Pdf`, { responseType: 'blob', observe: 'response', headers: headerPdf }); } - public getExportFormats(): Observable { - return this.httpClient.get(`${this.apiBase}/export/formats`); - } - // public downloadJson(id: string): Observable> { // return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); // } @@ -154,7 +148,7 @@ export class DmpServiceNew { return this.httpClient.get(url, { params: params, responseType: 'blob', observe: 'response', headers: headerXml }); } - uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable> { + uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable { const url = `${this.apiBase}/xml/import`; const params = new BaseHttpParams(); params.interceptorContext = { @@ -225,164 +219,4 @@ export class DmpServiceNew { isDmpOwner(dmpUsers: DmpUser[]): Boolean { return this.getCurrentUserRolesInDmp(dmpUsers).includes(DmpUserRole.Owner); } -} - - -// -// -// Pre refactor TODO: delete -// -// - -@Injectable() -export class DmpService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'dmps/'; - - } - - getPaged(dataTableRequest: DataTableRequest, fieldsGroup?: string): Observable> { - if (fieldsGroup) { - return this.http.post>(this.actionUrl + 'paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers }); - } - else { - return this.http.post>(this.actionUrl + 'paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers }); - } - } - - getSingle(id: String): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); //'getSingle/' + - } - - getSingleNoDatasets(id: String): Observable { - return this.http.get(this.actionUrl + 'plain/' + id, { headers: this.headers }); //'getSingle/' + - } - - getSinglePublic(id: String): Observable { - return this.http.get(this.actionUrl + 'public/' + id, { headers: this.headers }); - } - - getOverviewSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'overview/' + id, { headers: this.headers }); - } - - getOverviewSinglePublic(id: string): Observable { - return this.http.get(this.actionUrl + 'publicOverview/' + id, { headers: this.headers }) - } - - getAllVersions(id: string, isPublic: boolean): Observable { - return this.http.get(this.actionUrl + 'versions/' + id + '?public=' + isPublic, { headers: this.headers }) - } - - unlock(id: String): Observable { - return this.http.get(this.actionUrl + id + '/unlock', { headers: this.headers }); - } - - createDmp(dataManagementPlanModel: DmpModel): Observable { - return this.http.post(this.actionUrl, dataManagementPlanModel, { headers: this.headers }); - } - - createDmpWithDatasets(dataManagementPlanModel: DmpModel): Observable { - return this.http.post(this.actionUrl + 'full', dataManagementPlanModel, { headers: this.headers }); - } - - inactivate(id: String): Observable { - return this.http.delete(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); - } - - searchDmpBlueprints(dataSetProfileRequest: RequestItem): Observable { - return this.http.post(this.actionUrl + 'datasetprofiles/get', dataSetProfileRequest, { headers: this.headers }); - } - - newVersion(dataManagementPlanModel: DmpModel, id: String): Observable { - return this.http.post(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers }); - } - - clone(dataManagementPlanModel: DmpModel, id: String): Observable { - return this.http.post(this.actionUrl + 'clone/' + id, dataManagementPlanModel, { headers: this.headers }); - } - - delete(id: String): Observable { - return this.http.delete(this.actionUrl + id, { headers: this.headers }); // + 'delete/' - } - - publish(id: String): Observable { - return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }); - } - - finalize(datasetsToBeFinalized: DatasetsToBeFinalized, id: String): Observable { - return this.http.post(this.actionUrl + 'finalize/' + id, datasetsToBeFinalized, { headers: this.headers }); - } - - unfinalize(id: String): Observable { - return this.http.post(this.actionUrl + 'unfinalize/' + id, { headers: this.headers }); - } - - updateUsers(id: string, users: UserInfoListingModel[]): Observable { - return this.http.post(`${this.actionUrl}updateusers/${id}`, users, { headers: this.headers }); - } - - getDynamicField(requestItem: RequestItem): any { - return this.http.post(this.actionUrl + 'dynamic', requestItem, { headers: this.headers }); - } - - public downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); //+ "/getXml/" - } - - public downloadDocx(id: string): Observable> { - let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDoc }); - } - - public downloadPDF(id: string): Observable> { - let headerPdf: HttpHeaders = this.headers.set('Content-Type', 'application/pdf') - return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf }); - } - - public downloadJson(id: string): Observable> { - return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); - } - - public uploadXml(fileList: FileList, dmpTitle: string, dmpBlueprints: any[]): Observable { - const formData: FormData = new FormData(); - if (fileList instanceof FileList) { - for (let i = 0; i < fileList.length; i++) { - formData.append('file', fileList[i], dmpTitle); - } - } else if (Array.isArray(fileList)) { - formData.append('file', fileList[0], dmpTitle); - } else { - formData.append('file', fileList, dmpTitle); - } - for (let j = 0; j < dmpBlueprints.length; j++) { - formData.append('profiles', dmpBlueprints[j].id); - } - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - return this.http.post(this.actionUrl + 'upload', formData, { params: params }); - } - - getPublicPaged(dataTableRequest: DataTableRequest, fieldsGroup?: string): Observable> { - return this.http.post>(this.actionUrl + 'public/paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers }); - } - - getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest) { - return this.http.post>(this.actionUrl + 'datasetProfilesUsedByDmps/paged', dataTableRequest); - } - - generateIndex() { - return this.http.post(this.actionUrl + 'index', {}); - } - - clearIndex() { - return this.http.delete(this.actionUrl + 'index'); - } -} +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts b/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts deleted file mode 100644 index bae593b87..000000000 --- a/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from "@angular/core"; -import { environment } from "../../../../environments/environment"; -import { BaseHttpService } from "../http/base-http.service"; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class EmailConfirmationService { - private actioUrl: string; - private headers: HttpHeaders - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actioUrl = configurationService.server + 'emailConfirmation/'; - } - - public emailConfirmation(token: string) { - return this.http.get(this.actioUrl + token, { headers: this.headers }); - } - - public sendConfirmationEmail(email: string) { - return this.http.post(this.actioUrl, email, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/external-sources/currency/currency.service.ts b/dmp-frontend/src/app/core/services/external-sources/currency/currency.service.ts deleted file mode 100644 index 3ab66a2ec..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/currency/currency.service.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ConfigurationService } from '../../configuration/configuration.service'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; -import { BaseHttpService } from '../../http/base-http.service'; - -@Injectable() -export class CurrencyService { - - private actionUrl: string; - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'currency'; - } - - get(): Observable { - return this.http.get(this.actionUrl); - } - -} diff --git a/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts b/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts deleted file mode 100644 index 5fd29f12b..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../../environments/environment'; -import { DataRepositoryModel } from '../../../model/data-repository/data-repository'; -import { BaseHttpService } from '../../http/base-http.service'; -import { ConfigurationService } from '../../configuration/configuration.service'; - -@Injectable() -export class ExternalDataRepositoryService { - - private actionUrl: string; - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'external/datarepos'; - } - - create(dataRepoModel: DataRepositoryModel): Observable { - return this.http.post(this.actionUrl , dataRepoModel); - } - -} diff --git a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts deleted file mode 100644 index 260bb989a..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../../environments/environment'; -import { RequestItem } from '../../../query/request-item'; -import { DataTableData } from '../../../model/data-table/data-table-data'; -import { DataTableRequest } from '../../../model/data-table/data-table-request'; -import { ExternalDatasetModel } from '../../../model/external-dataset/external-dataset'; -import { ExternalDatasetCriteria } from '../../../query/external-dataset/external-dataset-criteria'; -import { BaseHttpService } from '../../http/base-http.service'; -import { ConfigurationService } from '../../configuration/configuration.service'; - -@Injectable() -export class ExternalDatasetService { - - private actionUrl: string; - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'externaldatasets/'; - } - - create(externalDatasetModel: ExternalDatasetModel): Observable { - return this.http.post(this.actionUrl, externalDatasetModel); - } -} diff --git a/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts b/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts deleted file mode 100644 index f443a4004..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { ExternalSourcesConfiguration } from '../../model/external-sources/external-sources-configuration'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class ExternalSourcesConfigurationService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'common/'; - } - - public getExternalSourcesConfiguration(): Observable { - return this.http.get(this.actionUrl + 'externalSourcesConfiguration', { headers: this.headers }); - } - -} diff --git a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts deleted file mode 100644 index 937aa57fa..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { RequestItem } from '../../query/request-item'; -import { ExternalSourceItemModel } from '../../model/external-sources/external-source-item'; -import { DataRepositoryCriteria } from '../../query/data-repository/data-repository-criteria'; -import { ExternalDatasetCriteria } from '../../query/external-dataset/external-dataset-criteria'; -import { RegistryCriteria } from '../../query/registry/registry-criteria'; -import { ResearcherCriteria } from '../../query/researcher/researcher-criteria'; -import { ServiceCriteria } from '../../query/service/service-criteria'; -import { TagCriteria } from '../../query/tag/tag-criteria'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { LicenseCriteria } from '@app/core/query/license/license-criteria'; -import {PublicationCriteria} from "@app/core/query/publication/publication-criteria"; -import { FetcherReference } from '@app/core/model/reference/reference'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -@Injectable() -export class ExternalSourcesService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - - this.actionUrl = configurationService.server + 'external/'; - - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } - - public searchDatasetRegistry(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'registries' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - - public searchDatasetRepository(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'datarepos' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - public searchPublicationRepository(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'pubrepos' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - public searchJournals(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'journals' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - public searchTaxonomies(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'taxonomies' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - public searchPublications(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'publications' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - - public searchDatasetService(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'services' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - - public searchLicense(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'licenses' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - - public listExternal(externalType: ReferenceType, query: string, type: string): Observable { - const url = this.configurationService.server + `reference/search/${externalType}`; - const options = { params: { query: query, type: type } }; - - return this.http.get(url, options); - } - - public searchDatasetTags(requestItem: RequestItem): Observable { - // return Observable.of([ - // { id: '1', name: 'Tag 1', description: '' }, - // { id: '2', name: 'Tag 2', description: '' }, - // { id: '3', name: 'Tag 3', description: '' }, - // { id: '4', name: 'Tag 4', description: '' }, - // { id: '5', name: 'Tag 5', description: '' }, - // { id: '6', name: 'Tag 6', description: '' }, - // { id: '7', name: 'Tag 7', description: '' }, - // { id: '8', name: 'Tag 8', description: '' }, - // ]); - return this.http.get(this.actionUrl + "tags" + "?query=" + requestItem.criteria.like + "&type=" + requestItem.criteria.type, { headers: this.headers }); - } - - public searchDatasetSExternalDatasetservice(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'datasets' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } - - public searchDMPResearchers(requestItem: RequestItem): Observable { - return this.http.post(this.configurationService.server + 'researchers/getWithExternal', requestItem, { headers: this.headers }); - } - - public searchDMPOrganizations(like: string, reference?: string): Observable { - const params = { - query:like - } - if(reference){ - params['reference'] = reference; - } - return this.http.get(this.actionUrl + 'organisations', { headers: this.headers, params: params }); - } - - // TODO: currently not used. - public searchDmpBlueprints(like: string): Observable { - return this.http.get(this.actionUrl + 'datasetprofiles/get' + '?query=' + like, { headers: this.headers }); - } - - public validateIdentifier(like: string, type: string): Observable { - return this.http.get(this.actionUrl + 'validation?query=' + like + '&type=' + type, { headers: this.headers }); - } - -} diff --git a/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts b/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts deleted file mode 100644 index 3b4e1ef3a..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../../environments/environment'; -import { RegistryModel } from '../../../model/registry/registry'; -import { BaseHttpService } from '../../http/base-http.service'; -import { ConfigurationService } from '../../configuration/configuration.service'; - -@Injectable() -export class ExternalRegistryService { - - private actionUrl: string; - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'registries/'; - } - - create(registerModel: RegistryModel): Observable { - return this.http.post(this.actionUrl, registerModel); - } -} diff --git a/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts b/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts deleted file mode 100644 index 3651c83e4..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Injectable } from '@angular/core'; -import { environment } from '../../../../../environments/environment'; -import { ResearcherModel } from '../../../model/researcher/researcher'; -import { BaseHttpService } from '../../http/base-http.service'; -import { ConfigurationService } from '../../configuration/configuration.service'; - -@Injectable() -export class ExternalResearcherService { - - private actionUrl: string; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'researchers/'; - } - - public createResearcher(researcher: ResearcherModel) { - return this.http.post(this.actionUrl, researcher); - } - -} diff --git a/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts b/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts deleted file mode 100644 index 3a5fa623e..000000000 --- a/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../../environments/environment'; -import { ServiceModel } from '../../../model/service/service'; -import { BaseHttpService } from '../../http/base-http.service'; -import { ConfigurationService } from '../../configuration/configuration.service'; - -@Injectable() -export class ExternalServiceService { - - private actionUrl: string; - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'services/'; - } - - create(serviceModel: ServiceModel): Observable { - return this.http.post(this.actionUrl, serviceModel); - } - -} diff --git a/dmp-frontend/src/app/core/services/file-transformer/file-transformer.http.service.ts b/dmp-frontend/src/app/core/services/file-transformer/file-transformer.http.service.ts new file mode 100644 index 000000000..85acc4801 --- /dev/null +++ b/dmp-frontend/src/app/core/services/file-transformer/file-transformer.http.service.ts @@ -0,0 +1,39 @@ +import { HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { FileFormat } from '@app/core/model/file/file-format.model'; +import { BaseService } from '@common/base/base.service'; +import { Guid } from '@common/types/guid'; +import { Observable, throwError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from '../http/base-http-v2.service'; + +@Injectable() +export class FileTransformerHttpService extends BaseService { + + private headers = new HttpHeaders(); + + constructor( + private http: BaseHttpV2Service, + private configurationService: ConfigurationService + ) { super(); } + + private get apiBase(): string { return `${this.configurationService.server}file-transformer`; } + + getAvailableConfigurations(): Observable { + const url = `${this.apiBase}/available`; + return this.http.get(url).pipe(catchError((error: any) => throwError(error))); + } + + exportDmp(dmpId: Guid): Observable { + //TODO: implement + const url = `${this.apiBase}/export-dmp`; + return this.http.post(url, null).pipe(catchError((error: any) => throwError(error))); + } + + exportDescription(item: any): Observable { + //TODO: implement + const url = `${this.apiBase}/export-description`; + return this.http.post(url, item).pipe(catchError((error: any) => throwError(error))); + } +} diff --git a/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts b/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts new file mode 100644 index 000000000..e1dfbf4c0 --- /dev/null +++ b/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts @@ -0,0 +1,37 @@ +import { Injectable } from '@angular/core'; +import { FileFormat } from '@app/core/model/file/file-format.model'; +import { BaseService } from '@common/base/base.service'; +import { catchError, takeUntil } from 'rxjs/operators'; +import { FileTransformerHttpService } from './file-transformer.http.service'; + +@Injectable() +export class FileTransformerService extends BaseService { + + constructor( + private fileTransformerHttpService: FileTransformerHttpService + ) { super(); } + + private _initialized: boolean = false; + private _loading: boolean = false; + + private _availableFormats: FileFormat[] = []; + get availableFormats(): FileFormat[] { + // console.log('availableFormats'); + if (!this._initialized && !this._loading) this.init(); + return this._availableFormats; + } + + init() { + this._loading = true; + // console.log('init'); + this.fileTransformerHttpService.getAvailableConfigurations().pipe(takeUntil(this._destroyed), catchError((error) => { + this._loading = false; + this._initialized = true; + return []; + })).subscribe(items => { + this._availableFormats = items; + this._loading = false; + this._initialized = true; + }); + } +} diff --git a/dmp-frontend/src/app/core/services/file/file.service.ts b/dmp-frontend/src/app/core/services/file/file.service.ts deleted file mode 100644 index 337688e93..000000000 --- a/dmp-frontend/src/app/core/services/file/file.service.ts +++ /dev/null @@ -1,68 +0,0 @@ -import {RequestItem} from "@app/core/query/request-item"; -import {ResearcherCriteria} from "@app/core/query/researcher/researcher-criteria"; -import {Observable} from "rxjs"; -import {ExternalSourceItemModel} from "@app/core/model/external-sources/external-source-item"; -import {Injectable} from "@angular/core"; -import {HttpClient, HttpHeaders, HttpResponse} from "@angular/common/http"; -import {BaseHttpService} from "@app/core/services/http/base-http.service"; -import {ConfigurationService} from "@app/core/services/configuration/configuration.service"; -import {BaseHttpParams} from "@common/http/base-http-params"; -import {InterceptorType} from "@common/http/interceptors/interceptor-type"; -import {tap} from "rxjs/operators"; - -@Injectable() -export class FileService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - - this.actionUrl = configurationService.server + 'file/'; - - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } - - public upload(fileList: File, datasetProfileId: string, fieldId: string): Observable { - const formData: FormData = new FormData(); - // if (fileList instanceof FileList) { - // for (let i = 0; i < fileList.length; i++) { - // formData.append('file', fileList[i], "test-konstantina"); - // } - // } else if (Array.isArray(fileList)) { - // formData.append('files', fileList); - // } else { - formData.append('file', fileList); - formData.append('datasetProfileId', datasetProfileId); - formData.append('fieldId', fieldId); - // } - // formData.append("fileType", fileList.) - console.log(fileList.type, fileList.name, fileList.size); - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - return this.http.post(this.actionUrl + 'upload', formData - , { params: params } - ); - } - - public deleteFromTempFolder(uuid: string) { - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - return this.http.post(this.actionUrl + 'delete-temp', uuid - , { params: params } - ); - } - - public download(id: string): Observable> { - // let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response' - , headers: this.headers - });//.pipe(tap(x => console.log(x)); - } -} diff --git a/dmp-frontend/src/app/core/services/funder/funder.service.ts b/dmp-frontend/src/app/core/services/funder/funder.service.ts deleted file mode 100644 index 86430d977..000000000 --- a/dmp-frontend/src/app/core/services/funder/funder.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Observable } from "rxjs"; -import { Injectable } from "@angular/core"; -import { HttpHeaders } from "@angular/common/http"; -import { RequestItem } from "../../query/request-item"; -import { BaseHttpService } from "../http/base-http.service"; -import { environment } from '../../../../environments/environment'; -import { FunderCriteria } from "../../query/funder/funder-criteria"; -import { FunderModel } from "../../model/funder/funder"; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class FunderService { - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'funders/'; - } - - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'external', requestItem, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts b/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts deleted file mode 100644 index 78aa904d3..000000000 --- a/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { ContentFile } from '../../model/grant/grant-listing'; -import { BaseHttpService } from '../http/base-http.service'; -import { BaseHttpParams } from '../../../../common/http/base-http-params'; -import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class GrantFileUploadService { - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'files/'; - } - - uploadFile(formData: FormData): Observable { - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - return this.http.post(this.actionUrl + 'upload', formData, { params: params }); - } -} diff --git a/dmp-frontend/src/app/core/services/grant/grant.service.ts b/dmp-frontend/src/app/core/services/grant/grant.service.ts deleted file mode 100644 index 01d80993f..000000000 --- a/dmp-frontend/src/app/core/services/grant/grant.service.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DataTableData } from '../../model/data-table/data-table-data'; -import { DataTableRequest } from '../../model/data-table/data-table-request'; -import { GrantListingModel } from '../../model/grant/grant-listing'; -import { GrantCriteria } from '../../query/grant/grant-criteria'; -import { RequestItem } from '../../query/request-item'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; - - -@Injectable() -export class GrantService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'grants/'; - } - - getPaged(dataTableRequest: DataTableRequest, fieldsGroup?: string): Observable> { - if (fieldsGroup) { - return this.http.post>(this.actionUrl + 'paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers }); - } - else { - return this.http.post>(this.actionUrl + 'paged?fieldsGroup=' + 'autocomplete', dataTableRequest, { headers: this.headers }); - } - } - - getPublicPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'public/paged', dataTableRequest, { headers: this.headers }); - } - - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'external', requestItem, { headers: this.headers }); - } - - getSingle(id: string): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); - } - - createGrant(grantModel: GrantListingModel): Observable { - return this.http.post(this.actionUrl, grantModel, { headers: this.headers }); - } - - // Actually sets it inactive. - delete(id: String): Observable { - return this.http.delete(this.actionUrl + id, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/help-content/cached-content-item.ts b/dmp-frontend/src/app/core/services/help-content/cached-content-item.ts deleted file mode 100644 index c33f7a264..000000000 --- a/dmp-frontend/src/app/core/services/help-content/cached-content-item.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { PageHelpContent } from "../../model/help-content/page-help-content"; - -export class CachedContentItem { - public timestamp: number; - public content: PageHelpContent; -} diff --git a/dmp-frontend/src/app/core/services/help-content/help-content.service.ts b/dmp-frontend/src/app/core/services/help-content/help-content.service.ts deleted file mode 100644 index 5682d934f..000000000 --- a/dmp-frontend/src/app/core/services/help-content/help-content.service.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -/** - * Created by stefania on 7/17/17. - */ -import { Injectable } from '@angular/core'; -import { Observable, throwError as observableThrowError } from 'rxjs'; -import { catchError, map } from 'rxjs/operators'; -import { environment } from '../../../../environments/environment'; -import { PageHelpContent } from '../../model/help-content/page-help-content'; -import { CachedContentItem } from './cached-content-item'; -import { ConfigurationService } from '../configuration/configuration.service'; - - -@Injectable() -export class HelpContentService { - private _helpServiceUrl: string; - cache = new Map(); - - constructor(private http: HttpClient, private configurationService: ConfigurationService) { - this._helpServiceUrl = configurationService.helpService.url; - } - - // getActivePageContent(route: string) { - // if (!this.cache.get(route) || !this.isValidCachedItem(route)) { - // return this.http.get(this._helpServiceUrl + '/page/route?q=' + route).pipe( - // map((res: Response) => { - // this.cache.set(route, { timestamp: Date.now(), content: res.json() as PageHelpContent }); - // return res.json(); - // }), - // catchError(this.handleError)); - // } - // return Observable.create(observer => observer.next(this.cache.get(route).content)); - // } - // private extractData(res: Response) { - // const body = res.json(); - // return body. || {}; - // } - // private handleError(error: Response | any) { - // // In a real world app, we might use a remote logging infrastructure - // // We'd also dig deeper into the error to get a better message - // let errMsg = ''; - // if (error instanceof Response) { - // const body = error.text() || ''; - // //const err = body.error || JSON.stringify(body); - // errMsg = `${error.status} - ${error.statusText || ''} ${body}`; - // } else { - // errMsg = (error.message) ? error.message : - // error.status ? `${error.status} - ${error.statusText}` : 'Server error'; - // console.error(errMsg); // log to console instead - // } - // return observableThrowError(errMsg); - // } - - // isValidCachedItem(route) { - // const cachedTimestamp = this.cache.get(route).timestamp; - // const currentTimestamp = Date.now(); - // if (currentTimestamp - cachedTimestamp > 30000) { return false; } else { return true; } - // } -} diff --git a/dmp-frontend/src/app/core/services/http/base-http.service.ts b/dmp-frontend/src/app/core/services/http/base-http.service.ts deleted file mode 100644 index 7fe8f473d..000000000 --- a/dmp-frontend/src/app/core/services/http/base-http.service.ts +++ /dev/null @@ -1,90 +0,0 @@ - -import {map} from 'rxjs/operators'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { ApiMessageCode } from '../../common/enum/api-message-code'; - -@Injectable() -export class BaseHttpService { - constructor( - protected http: HttpClient - ) { - } - - get(url: string, options?: Object): Observable { - return this.interceptRepsonse(this.http.get(url, options)); - } - - post(url: string, body: any, options?: Object): Observable { - return this.interceptRepsonse(this.http.post(url, body, options)); - } - - put(url: string, body: any, options?: Object): Observable { - return this.interceptRepsonse(this.http.put(url, body, options)); - } - - delete(url: string, options?: Object): Observable { - return this.interceptRepsonse(this.http.delete(url, options)); - } - - patch(url: string, body: any, options?: Object): Observable { - return this.interceptRepsonse(this.http.patch(url, body, options)); - } - - head(url: string, options?: Object): Observable { - return this.interceptRepsonse(this.http.head(url, options)); - } - - options(url: string, options?: Object): Observable { - return this.interceptRepsonse(this.http.options(url, options)); - } - - private interceptRepsonse(observable: Observable): Observable { - return observable.pipe( - // .catch((errorResponse) => { - // if (errorResponse.status === 401) { - // this.snackBar.openFromComponent(SnackBarNotificationComponent, { - // data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language }, - // duration: 3000, - // }); - // const currentPage = this.router.url; - // this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: currentPage } }); - // //this.notification.httpError(error); - // return Observable.of(); - // } else { - // const error: any = errorResponse.error; - // if (error.statusCode === ApiMessageCode.ERROR_MESSAGE) { - // this.snackBar.openFromComponent(SnackBarNotificationComponent, { - // data: { message: error.message, language: null }, - // duration: 3000, - // }); - // return Observable.throw(errorResponse); - // } else if (error.statusCode === ApiMessageCode.VALIDATION_MESSAGE) { - // return Observable.throw(errorResponse); - // } else { - // this.snackBar.openFromComponent(SnackBarNotificationComponent, { - // data: { message: 'GENERAL.ERRORS.HTTP-REQUEST-ERROR', language: this.language }, - // duration: 3000, - // }); - // return Observable.throw(errorResponse); - // } - // } - // }) - map(response => { - if (response instanceof Blob) { return response; } - if (response['statusCode'] === ApiMessageCode.SUCCESS_MESSAGE) { - //throw new Error('Request failed'); - // this.snackBar.openFromComponent(SnackBarNotificationComponent, { - // data: { message: response['message'], language: null }, - // duration: 3000, - // }); - return response['payload']; - } else if (response['statusCode'] === ApiMessageCode.NO_MESSAGE) { - return response['payload']; - } else { - return response['payload']; - } - })); - } -} diff --git a/dmp-frontend/src/app/core/services/http/principal.service.ts b/dmp-frontend/src/app/core/services/http/principal.service.ts index 851a3d746..50b9cc5b5 100644 --- a/dmp-frontend/src/app/core/services/http/principal.service.ts +++ b/dmp-frontend/src/app/core/services/http/principal.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { BaseHttpService } from './base-http.service'; -import { Observable } from 'rxjs'; import { AppAccount } from '@app/core/model/auth/principal'; +import { Observable } from 'rxjs'; +import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from './base-http-v2.service'; @Injectable() export class PrincipalService { @@ -11,7 +11,7 @@ export class PrincipalService { constructor( private installationConfiguration: ConfigurationService, - private http: BaseHttpService + private http: BaseHttpV2Service ) { } public me(options?: Object): Observable { diff --git a/dmp-frontend/src/app/core/services/language/language.http.service.ts b/dmp-frontend/src/app/core/services/language/language.http.service.ts index 0ca160433..aff0f3a79 100644 --- a/dmp-frontend/src/app/core/services/language/language.http.service.ts +++ b/dmp-frontend/src/app/core/services/language/language.http.service.ts @@ -12,7 +12,6 @@ import { catchError, map } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; -import { HttpResponse } from '@angular/common/http'; @Injectable() export class LanguageHttpService { diff --git a/dmp-frontend/src/app/core/services/language/server.loader.ts b/dmp-frontend/src/app/core/services/language/server.loader.ts index f794533a0..007e8e892 100644 --- a/dmp-frontend/src/app/core/services/language/server.loader.ts +++ b/dmp-frontend/src/app/core/services/language/server.loader.ts @@ -1,14 +1,9 @@ +import { Language } from '@app/core/model/language/language'; import { TranslateLoader } from '@ngx-translate/core'; import { Observable } from 'rxjs'; -import { environment } from 'environments/environment'; -import { HttpClient } from '@angular/common/http'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { BaseHttpParams } from '@common/http/base-http-params'; -import { InterceptorType } from '@common/http/interceptors/interceptor-type'; -import { LanguageHttpService } from './language.http.service'; import { map } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; -import { Language } from '@app/core/model/language/language'; +import { LanguageHttpService } from './language.http.service'; export class TranslateServerLoader implements TranslateLoader { diff --git a/dmp-frontend/src/app/core/services/lock/lock.service.ts b/dmp-frontend/src/app/core/services/lock/lock.service.ts index 9f689c039..742c73d08 100644 --- a/dmp-frontend/src/app/core/services/lock/lock.service.ts +++ b/dmp-frontend/src/app/core/services/lock/lock.service.ts @@ -1,14 +1,14 @@ +import { HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { HttpHeaders, HttpClient, HttpResponse } from '@angular/common/http'; -import { Observable, throwError } from 'rxjs'; -import { Lock, LockModel, LockPersist } from '@app/core/model/lock/lock.model'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { BaseHttpV2Service } from '../http/base-http-v2.service'; -import { FilterService } from '@common/modules/text-filter/filter-service'; +import { Lock, LockPersist } from '@app/core/model/lock/lock.model'; import { LockLookup } from '@app/core/query/lock.lookup'; import { QueryResult } from '@common/model/query-result'; -import { catchError } from 'rxjs/operators'; +import { FilterService } from '@common/modules/text-filter/filter-service'; import { Guid } from '@common/types/guid'; +import { Observable, throwError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from '../http/base-http-v2.service'; @Injectable() export class LockService { @@ -57,7 +57,7 @@ export class LockService { unlockTarget(targetId: Guid): Observable { return this.http.delete(`${this.apiBase}/target/unlock/${targetId}`) - .pipe(catchError((error: any) => throwError(error))); + .pipe(catchError((error: any) => throwError(error))); } getSingleWithTarget(targetId: Guid, reqFields: string[] = []): Observable { @@ -68,9 +68,4 @@ export class LockService { .get(url, options).pipe( catchError((error: any) => throwError(error))); } - - //ToDo replace with persist function - createOrUpdate(lock: LockModel): Observable { - return this.http.post(`${this.apiBase}`, lock, { headers: this.headers }); - } } diff --git a/dmp-frontend/src/app/core/services/logging/logging-service.ts b/dmp-frontend/src/app/core/services/logging/logging-service.ts index b8d8a2629..0a66c39c6 100644 --- a/dmp-frontend/src/app/core/services/logging/logging-service.ts +++ b/dmp-frontend/src/app/core/services/logging/logging-service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { environment } from '../../../../environments/environment'; import { ConfigurationService } from '../configuration/configuration.service'; export enum LogLevel { diff --git a/dmp-frontend/src/app/core/services/maintenance-tasks/maintenance-tasks.service.ts b/dmp-frontend/src/app/core/services/maintenance-tasks/maintenance-tasks.service.ts deleted file mode 100644 index 01062cd55..000000000 --- a/dmp-frontend/src/app/core/services/maintenance-tasks/maintenance-tasks.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Injectable } from "@angular/core"; -import { BaseService } from "@common/base/base.service"; -import { Observable } from "rxjs"; -import { ConfigurationService } from "../configuration/configuration.service"; -import { BaseHttpService } from "../http/base-http.service"; - -@Injectable() -export class MaintenanceTasksService extends BaseService { - - private actionUrl: string; - - constructor(private http: BaseHttpService, configurationService: ConfigurationService) { - super(); - this.actionUrl = configurationService.server + 'management/'; - } - - migrateSemantics(): Observable { - return this.http.post(this.actionUrl + 'addSemantics/', null); - } - - addRdaInSemantics(): Observable { - return this.http.post(this.actionUrl + 'addRdaInSemantics/', null); - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/maintenance/maintenance.service.ts b/dmp-frontend/src/app/core/services/maintenance/maintenance.service.ts index 2060616e2..ce966e3d3 100644 --- a/dmp-frontend/src/app/core/services/maintenance/maintenance.service.ts +++ b/dmp-frontend/src/app/core/services/maintenance/maintenance.service.ts @@ -1,27 +1,31 @@ -import { BaseService } from "@common/base/base.service"; -import { BaseHttpService } from "../http/base-http.service"; -import { ConfigurationService } from "../configuration/configuration.service"; import { Injectable } from "@angular/core"; -import { Observable } from "rxjs"; +import { BaseService } from "@common/base/base.service"; +import { Observable, throwError } from "rxjs"; +import { catchError } from "rxjs/operators"; +import { ConfigurationService } from "../configuration/configuration.service"; +import { BaseHttpV2Service } from "../http/base-http-v2.service"; @Injectable() -export class MaintenanceService extends BaseService{ +export class MaintenanceService extends BaseService { - private actionUrl: string; + constructor( + private http: BaseHttpV2Service, + private installationConfiguration: ConfigurationService, + ) { super(); } - constructor(private http: BaseHttpService, - private configurationService: ConfigurationService) { - super(); - this.actionUrl = `${configurationService.server}maintenance`; + private get apiBase(): string { return `${this.installationConfiguration.server}maintenance`; } + + generateElasticIndex(): Observable { + const url = `${this.apiBase}/index/elastic`; + return this.http + .post(url, null).pipe( + catchError((error: any) => throwError(error))); } - public generateElasticIndex(): Observable { - return this.http.post(`${this.actionUrl}/index/elastic`, null); + clearElasticIndex(): Observable { + const url = `${this.apiBase}/index/elastic`; + return this.http + .delete(url).pipe( + catchError((error: any) => throwError(error))); } - - public clearElasticIndex(): Observable { - return this.http.delete(`${this.actionUrl}/index/elastic`); - } - - } diff --git a/dmp-frontend/src/app/core/services/merge-email-confirmation/merge-email-confirmation.service.ts b/dmp-frontend/src/app/core/services/merge-email-confirmation/merge-email-confirmation.service.ts deleted file mode 100644 index 0f3676932..000000000 --- a/dmp-frontend/src/app/core/services/merge-email-confirmation/merge-email-confirmation.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from "@angular/core"; -import { BaseHttpService } from "../http/base-http.service"; -import { ConfigurationService } from '../configuration/configuration.service'; -import { UserMergeRequestModel } from '@app/core/model/merge/user-merge-request'; - -@Injectable() -export class MergeEmailConfirmationService { - private actioUrl: string; - private headers: HttpHeaders - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actioUrl = configurationService.server + 'emailMergeConfirmation/'; - } - - public emailConfirmation(token: string) { - return this.http.get(this.actioUrl + token, { headers: this.headers }); - } - - public sendConfirmationEmail(mergeRequest: UserMergeRequestModel) { - return this.http.post(this.actioUrl, mergeRequest, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/organisation/organisation.service.ts b/dmp-frontend/src/app/core/services/organisation/organisation.service.ts deleted file mode 100644 index 0cc4f67d0..000000000 --- a/dmp-frontend/src/app/core/services/organisation/organisation.service.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { HttpHeaders } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import { ExternalSourceItemModel } from "@app/core/model/external-sources/external-source-item"; -import { RequestItem } from "@app/core/query/request-item"; -import { Observable } from "rxjs"; -import { DataTableData } from "../../model/data-table/data-table-data"; -import { DataTableRequest } from "../../model/data-table/data-table-request"; -import { OrganizationModel } from "../../model/organisation/organization"; -import { OrganisationCriteria } from "../../query/organisation/organisation-criteria"; -import { ConfigurationService } from '../configuration/configuration.service'; -import { BaseHttpService } from "../http/base-http.service"; - -@Injectable() -export class OrganisationService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - - this.actionUrl = configurationService.server; - - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } - - public searchInternalOrganisations(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'internal/organisations', dataTableRequest, { headers: this.headers }); - } - - public searchGeneralOrganisations(dataTableRequest: RequestItem): Observable { - return this.http.post(this.actionUrl + 'general/organisations', dataTableRequest, { headers: this.headers }); - } - - public searchPublicOrganisations(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'public/organisations', dataTableRequest, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/prefilling.service.ts b/dmp-frontend/src/app/core/services/prefilling.service.ts index fa940a1f6..4cf7ec2f9 100644 --- a/dmp-frontend/src/app/core/services/prefilling.service.ts +++ b/dmp-frontend/src/app/core/services/prefilling.service.ts @@ -1,29 +1,27 @@ -import {Injectable} from "@angular/core"; -import {HttpClient, HttpHeaders} from "@angular/common/http"; -import {BaseHttpService} from "@app/core/services/http/base-http.service"; -import {ConfigurationService} from "@app/core/services/configuration/configuration.service"; -import {Observable} from "rxjs"; -import {Prefilling} from "@app/core/model/dataset/prefilling"; -import {DatasetWizardModel} from "@app/core/model/dataset/dataset-wizard"; +import { HttpClient, HttpHeaders } from "@angular/common/http"; +import { Injectable } from "@angular/core"; +import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; +import { BaseHttpV2Service } from "./http/base-http-v2.service"; @Injectable() export class PrefillingService { private readonly actionUrl: string; private headers = new HttpHeaders(); - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { + constructor(private http: BaseHttpV2Service, private httpClient: HttpClient, private configurationService: ConfigurationService) { this.actionUrl = configurationService.server + 'prefilling/'; } - public getPrefillingList(like: string): Observable { - return this.http.get(this.actionUrl + 'list?like=' + encodeURIComponent(like), { headers: this.headers }); - } + //TODO: refactor + // public getPrefillingList(like: string): Observable { + // return this.http.get(this.actionUrl + 'list?like=' + encodeURIComponent(like), { headers: this.headers }); + // } - public getPrefillingDataset(pid: string, profileId: string, configId: string): Observable { - return this.http.get(this.actionUrl + '/generate/' + encodeURIComponent(pid) + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), { headers: this.headers }); - } + // public getPrefillingDataset(pid: string, profileId: string, configId: string): Observable { + // return this.http.get(this.actionUrl + '/generate/' + encodeURIComponent(pid) + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), { headers: this.headers }); + // } - public getPrefillingDatasetUsingData(data: any, profileId: string, configId: string): Observable { - return this.http.post(this.actionUrl + '/generateUsingData' + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), data, { headers: this.headers }); - } + // public getPrefillingDatasetUsingData(data: any, profileId: string, configId: string): Observable { + // return this.http.post(this.actionUrl + '/generateUsingData' + '?configId=' + encodeURIComponent(configId) + '&profileId=' + encodeURIComponent(profileId), data, { headers: this.headers }); + // } } diff --git a/dmp-frontend/src/app/core/services/project/project.service.ts b/dmp-frontend/src/app/core/services/project/project.service.ts deleted file mode 100644 index 0532f8c95..000000000 --- a/dmp-frontend/src/app/core/services/project/project.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Observable } from "rxjs"; -import { Injectable } from "@angular/core"; -import { HttpHeaders } from "@angular/common/http"; -import { RequestItem } from "../../query/request-item"; -import { BaseCriteria } from "../../query/base-criteria"; -import { BaseHttpService } from "../http/base-http.service"; -import { environment } from '../../../../environments/environment'; -import { ProjectCriteria } from "../../query/project/project-criteria"; -import { ProjectModel } from "../../model/project/project"; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class ProjectService { - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'projects/'; - } - - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'external', requestItem, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts b/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts deleted file mode 100644 index 4a6d3579d..000000000 --- a/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { QuickWizardEditorWizardModel } from '../../../ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model'; -import { BaseHttpService } from '../http/base-http.service'; -import { DatasetCreateWizardModel } from '../../../ui/dataset-create-wizard/dataset-create-wizard.model'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class QuickWizardService { - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'quick-wizard/'; - } - - createQuickWizard(quickWizard: QuickWizardEditorWizardModel): Observable { - return this.http.post(this.actionUrl, quickWizard, { headers: this.headers }); - } - - createQuickDatasetWizard(datasetCreateWizardModel: DatasetCreateWizardModel): Observable { - return this.http.post(this.actionUrl + 'datasetcreate', datasetCreateWizardModel, { headers: this.headers }); - } -} 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 831e7bf1a..185ed3652 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 @@ -1,18 +1,18 @@ import { Injectable } from '@angular/core'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { ReferenceType, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type'; +import { ReferenceTypeLookup } from '@app/core/query/reference-type.lookup'; +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 { ReferenceTypeEditorResolver } from '@app/ui/admin/reference-type/editor/reference-type-editor.resolver'; import { QueryResult } from '@common/model/query-result'; import { FilterService } from '@common/modules/text-filter/filter-service'; import { Guid } from '@common/types/guid'; import { Observable, throwError } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; -import { ReferenceTypeLookup } from '@app/core/query/reference-type.lookup'; -import { ReferenceType, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { nameof } from 'ts-simple-nameof'; -import { ReferenceTypeEditorResolver } from '@app/ui/admin/reference-type/editor/reference-type-editor.resolver'; @Injectable() export class ReferenceTypeService { @@ -31,7 +31,7 @@ export class ReferenceTypeService { return this.http.post>(url, q).pipe(catchError((error: any) => throwError(error))); } - getSingle(id: Guid, reqFields: string[] = []): Observable { + getSingle(id: Guid, reqFields: string[] = []): Observable { const url = `${this.apiBase}/${id}`; const options = { params: { f: reqFields } }; @@ -67,7 +67,7 @@ export class ReferenceTypeService { // LOOKUP - public static DefaultReferenceTypeLookup(): ReferenceTypeLookup{ + public static DefaultReferenceTypeLookup(): ReferenceTypeLookup { const lookup = new ReferenceTypeLookup(); lookup.project = { @@ -122,7 +122,7 @@ export class ReferenceTypeService { ///system fields - getSystemFields(fields: string[]): string[]{ + getSystemFields(fields: string[]): string[] { fields.push('reference_id'); fields.push('label'); fields.push('description'); 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 36f0b04ca..16ba3f344 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,10 @@ 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, Reference, ReferencePersist } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { Reference, ReferencePersist } from '@app/core/model/reference/reference'; +import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; import { ReferenceLookup } from '@app/core/query/reference.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; @@ -13,9 +16,6 @@ import { catchError, map } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; -import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; -import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; -import { Dmp } from '@app/core/model/dmp/dmp'; @Injectable() export class ReferenceService { @@ -130,5 +130,5 @@ export class ReferenceService { getReferencesForTypesFirstSafe(dmpReferences: DmpReference[], referenceTypes: ReferenceType[]): DmpReference { return this.getReferencesForTypes(dmpReferences, referenceTypes)?.find(Boolean); } - + } diff --git a/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts b/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts deleted file mode 100644 index db5d6341e..000000000 --- a/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { SearchBarItem } from '../../model/dashboard/search-bar-item'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class SearchBarService { - - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - - this.actionUrl = configurationService.server + 'dashboard/'; - } - - search(like: string): Observable { - return this.http.get(this.actionUrl + 'search?like=' + like, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/supportive-material/supportive-material.service.ts b/dmp-frontend/src/app/core/services/supportive-material/supportive-material.service.ts index d5f82c30a..ac5e2380a 100644 --- a/dmp-frontend/src/app/core/services/supportive-material/supportive-material.service.ts +++ b/dmp-frontend/src/app/core/services/supportive-material/supportive-material.service.ts @@ -1,19 +1,18 @@ +import { HttpResponse } from "@angular/common/http"; import { Injectable } from "@angular/core"; -import { ConfigurationService } from "../configuration/configuration.service"; -import { HttpClient, HttpResponse } from "@angular/common/http"; -import { Observable, throwError } from "rxjs"; +import { IsActive } from "@app/core/common/enum/is-active.enum"; import { SupportiveMaterial, SupportiveMaterialPersist } from "@app/core/model/supportive-material/supportive-material"; -import { BaseHttpV2Service } from "../http/base-http-v2.service"; import { SupportiveMaterialLookup } from "@app/core/query/supportive-material.lookup"; import { QueryResult } from "@common/model/query-result"; -import { catchError } from "rxjs/operators"; import { Guid } from "@common/types/guid"; +import { Observable, throwError } from "rxjs"; +import { catchError } from "rxjs/operators"; import { nameof } from "ts-simple-nameof"; -import { IsActive } from "@app/core/common/enum/is-active.enum"; -import { SupportiveMaterialFieldType } from "@app/core/common/enum/supportive-material-field-type"; +import { ConfigurationService } from "../configuration/configuration.service"; +import { BaseHttpV2Service } from "../http/base-http-v2.service"; @Injectable() -export class SupportiveMaterialService{ +export class SupportiveMaterialService { constructor( private http: BaseHttpV2Service, @@ -24,7 +23,7 @@ export class SupportiveMaterialService{ private get apiBase(): string { return `${this.configurationService.server}supportive-material`; } queryPublic(q: SupportiveMaterialLookup): Observable> { - return this.http.post>(`${this.apiBase}/public`, q , {responseType: 'blob', observe: 'response' }); + return this.http.post>(`${this.apiBase}/public`, q, { responseType: 'blob', observe: 'response' }); } query(q: SupportiveMaterialLookup): Observable> { @@ -60,7 +59,7 @@ export class SupportiveMaterialService{ // LOOKUP - public static DefaultSupportiveMaterialLookup(): SupportiveMaterialLookup{ + public static DefaultSupportiveMaterialLookup(): SupportiveMaterialLookup { const lookup = new SupportiveMaterialLookup(); lookup.project = { diff --git a/dmp-frontend/src/app/core/services/tag/tag.service.ts b/dmp-frontend/src/app/core/services/tag/tag.service.ts new file mode 100644 index 000000000..3dc92c9aa --- /dev/null +++ b/dmp-frontend/src/app/core/services/tag/tag.service.ts @@ -0,0 +1,98 @@ +import { Injectable } from '@angular/core'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { Tag, TagPersist } from '@app/core/model/tag/tag'; +import { TagLookup } from '@app/core/query/tag.lookup'; +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 { QueryResult } from '@common/model/query-result'; +import { FilterService } from '@common/modules/text-filter/filter-service'; +import { Guid } from '@common/types/guid'; +import { Observable, throwError } from 'rxjs'; +import { catchError, map } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; +import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from '../http/base-http-v2.service'; + +@Injectable() +export class TagService { + + constructor( + private http: BaseHttpV2Service, + private installationConfiguration: ConfigurationService, + private filterService: FilterService + ) { } + + private get apiBase(): string { return `${this.installationConfiguration.server}tag`; } + + query(q: TagLookup): Observable> { + const url = `${this.apiBase}/query`; + return this.http + .post>(url, q).pipe( + catchError((error: any) => throwError(error))); + } + + getSingle(id: Guid, reqFields: string[] = []): Observable { + const url = `${this.apiBase}/${id}`; + const options = { params: { f: reqFields } }; + + return this.http + .get(url, options).pipe( + catchError((error: any) => throwError(error))); + } + + persist(item: TagPersist): Observable { + const url = `${this.apiBase}/persist`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + + delete(id: Guid): Observable { + const url = `${this.apiBase}/${id}`; + + return this.http + .delete(url).pipe( + catchError((error: any) => throwError(error))); + } + + // + // Autocomplete Commons + // + // tslint:disable-next-line: member-ordering + singleAutocompleteConfiguration: SingleAutoCompleteConfiguration = { + initialItems: (data?: any) => this.query(this.buildAutocompleteLookup()).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), + displayFn: (item: Tag) => item.label, + titleFn: (item: Tag) => item.label, + valueAssign: (item: Tag) => item.id, + }; + + // tslint:disable-next-line: member-ordering + multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = { + initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(searchQuery, excludedItems)).pipe(map(x => x.items)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)), + displayFn: (item: Tag) => item.label, + titleFn: (item: Tag) => item.label, + valueAssign: (item: Tag) => item.id, + }; + + public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): TagLookup { + const lookup: TagLookup = new TagLookup(); + lookup.page = { size: 100, offset: 0 }; + if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } + if (ids && ids.length > 0) { lookup.ids = ids; } + lookup.isActive = [IsActive.Active]; + lookup.project = { + fields: [ + nameof(x => x.id), + nameof(x => x.label) + ] + }; + lookup.order = { items: [nameof(x => x.label)] }; + if (like) { lookup.like = this.filterService.transformLike(like); } + return lookup; + } +} diff --git a/dmp-frontend/src/app/core/services/tenant/tenant.service.ts b/dmp-frontend/src/app/core/services/tenant/tenant.service.ts index c498d5de2..171516e66 100644 --- a/dmp-frontend/src/app/core/services/tenant/tenant.service.ts +++ b/dmp-frontend/src/app/core/services/tenant/tenant.service.ts @@ -1,4 +1,3 @@ -import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { Tenant, TenantPersist } from '@app/core/model/tenant/tenant'; diff --git a/dmp-frontend/src/app/core/services/unlink-account-email-confirmation/unlink-account-email-confirmation.service.ts b/dmp-frontend/src/app/core/services/unlink-account-email-confirmation/unlink-account-email-confirmation.service.ts deleted file mode 100644 index 40846c568..000000000 --- a/dmp-frontend/src/app/core/services/unlink-account-email-confirmation/unlink-account-email-confirmation.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { HttpHeaders } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import { BaseHttpService } from "../http/base-http.service"; -import { ConfigurationService } from "../configuration/configuration.service"; -import { UnlinkAccountRequestModel } from "@app/core/model/unlink-account/unlink-account"; - -@Injectable() -export class UnlinkAccountEmailConfirmationService { - private actioUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actioUrl = configurationService.server + 'emailUnlinkConfirmation/'; - } - - public emailConfirmation(token: string) { - return this.http.get(this.actioUrl + token, { headers: this.headers }); - } - - public sendConfirmationEmail(unlinkRequest: UnlinkAccountRequestModel) { - return this.http.post(this.actioUrl, unlinkRequest, { headers: this.headers }); - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/user-settings/user-settings-http.service.ts b/dmp-frontend/src/app/core/services/user-settings/user-settings-http.service.ts index 5d161b6fa..90e432691 100644 --- a/dmp-frontend/src/app/core/services/user-settings/user-settings-http.service.ts +++ b/dmp-frontend/src/app/core/services/user-settings/user-settings-http.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@angular/core'; +import { UserSettingPersist, UserSettings } from '@app/core/model/user-settings/user-settings.model'; import { Guid } from '@common/types/guid'; import { Observable } from 'rxjs'; -import { UserSettingPersist, UserSettings } from '@app/core/model/user-settings/user-settings.model'; -import { BaseHttpV2Service } from '../http/base-http-v2.service'; import { ConfigurationService } from '../configuration/configuration.service'; +import { BaseHttpV2Service } from '../http/base-http-v2.service'; @Injectable() export class UserSettingsHttpService { @@ -37,7 +37,7 @@ export class UserSettingsHttpService { .delete(url); } - share(item: UserSettingPersist, targetId: Guid): Observable{ + share(item: UserSettingPersist, targetId: Guid): Observable { const url = `${this.apiBase}/share/${targetId}`; return this.http.post(url, item); diff --git a/dmp-frontend/src/app/core/services/user/user.service-old.ts b/dmp-frontend/src/app/core/services/user/user.service-old.ts deleted file mode 100644 index 05b684598..000000000 --- a/dmp-frontend/src/app/core/services/user/user.service-old.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DataTableData } from '../../model/data-table/data-table-data'; -import { DataTableRequest } from '../../model/data-table/data-table-request'; -import { UserListingModel } from '../../model/user/user-listing'; -import { UserCriteria } from '../../query/user/user-criteria'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { UserCredentialModel } from '@app/core/model/user/user-credential'; - -@Injectable() -export class UserServiceOld { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - - this.actionUrl = configurationService.server + 'user/'; - } - - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', JSON.stringify(dataTableRequest), { headers: this.headers }); - } - - getUser(id: String): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); - } - - getEmails(id: String): Observable { - return this.http.get(`${this.actionUrl}${id}/emails`, { headers: this.headers }); - } - - updateRoles(itemToUpdate: UserListingModel): Observable { - return this.http.post(this.actionUrl + 'updateRoles', JSON.stringify(itemToUpdate), { headers: this.headers }); - } - - delete(id: String): Observable { - return this.http.delete(this.actionUrl + id, { headers: this.headers }); - } - - getRecentActivity(): Observable { - return this.http.get(this.actionUrl + 'recentActivity', { headers: this.headers }); - } - - updateUserSettings(value: any): Observable { - return this.http.post(this.actionUrl + 'settings', value, { headers: this.headers }); - } - - getCollaboratorsPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getCollaboratorsPaged', JSON.stringify(dataTableRequest), { headers: this.headers }); - } - - getFromEmail(email: string): Observable { - return this.http.post(this.actionUrl + 'find', email, {headers: this.headers}); - } - - downloadCSV(): Observable> { - let headerCsv: HttpHeaders = this.headers.set('Content-Type', 'application/csv') - return this.httpClient.get(this.actionUrl + 'getCsv/', { responseType: 'blob', observe: 'response', headers: headerCsv }); - } -} diff --git a/dmp-frontend/src/app/core/services/user/user.service.ts b/dmp-frontend/src/app/core/services/user/user.service.ts index 9bc7b2fb2..2506ba5ec 100644 --- a/dmp-frontend/src/app/core/services/user/user.service.ts +++ b/dmp-frontend/src/app/core/services/user/user.service.ts @@ -1,7 +1,6 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; import { User, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user'; import { UserLookup } from '@app/core/query/user.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; @@ -84,7 +83,7 @@ export class UserService { return this.httpClient.get(url, { params: params, responseType: 'blob', observe: 'response', headers: headerXml }); } - uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable> { + uploadFile(file: FileList, labelSent: string, reqFields: string[] = []): Observable { const url = `${this.apiBase}/xml/import`; const params = new BaseHttpParams(); params.interceptorContext = { 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 5b3c35f56..0abdaf342 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 @@ -5,33 +5,27 @@ import { DescriptionTemplateStatus } from '@app/core/common/enum/description-tem import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status'; import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status'; import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; -import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; +import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; +import { EmailOverrideMode } from '@app/core/common/enum/email-override-mode'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { NotificationDataType } from '@app/core/common/enum/notification-data-type'; +import { NotificationTemplateChannel } from '@app/core/common/enum/notification-template-channel'; +import { NotificationTemplateKind } from '@app/core/common/enum/notification-template-kind'; 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 { Role } from '@app/core/common/enum/role'; import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; import { SupportiveMaterialFieldType } from '@app/core/common/enum/supportive-material-field-type'; import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role'; -import { ViewStyleType } from '@app/ui/admin/dataset-profile/editor/components/field/view-style-enum'; import { TranslateService } from '@ngx-translate/core'; import { AppRole } from '../../common/enum/app-role'; -import { DatasetProfileComboBoxType } from '../../common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '../../common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '../../common/enum/dataset-profile-internal-dmp-entities-type'; -import { DatasetStatus } from '../../common/enum/dataset-status'; import { DmpBlueprintExtraFieldDataType } from '../../common/enum/dmp-blueprint-field-type'; import { DmpBlueprintType } from '../../common/enum/dmp-blueprint-type'; import { DmpStatus } from '../../common/enum/dmp-status'; import { ValidationType } from '../../common/enum/validation-type'; -import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; -import { NotificationTemplateKind } from '@app/core/common/enum/notification-template-kind'; -import { NotificationTemplateChannel } from '@app/core/common/enum/notification-template-channel'; -import { NotificationDataType } from '@app/core/common/enum/notification-data-type'; -import { EmailOverrideMode } from '@app/core/common/enum/email-override-mode'; +import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; @Injectable() export class EnumUtils { @@ -81,13 +75,6 @@ export class EnumUtils { } } - toDatasetStatusString(status: DatasetStatus): string { - switch (status) { - case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT'); - case DatasetStatus.Finalized: return this.language.instant('TYPES.DATASET-STATUS.FINALISED'); - } - } - toDmpStatusString(status: DmpStatus): string { switch (status) { case DmpStatus.Draft: return this.language.instant('TYPES.DMP.DRAFT'); @@ -102,103 +89,6 @@ export class EnumUtils { } } - toDatasetProfileFieldViewStyleString(status: DatasetProfileFieldViewStyle): string { - switch (status) { - case DatasetProfileFieldViewStyle.BooleanDecision: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.BOOLEAN-DECISION'); - case DatasetProfileFieldViewStyle.CheckBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CHECKBOX'); - case DatasetProfileFieldViewStyle.ComboBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.COMBO-BOX'); - case DatasetProfileFieldViewStyle.InternalDmpEntities: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.INTERNAL-DMP-ENTITIES'); - case DatasetProfileFieldViewStyle.FreeText: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.FREE-TEXT'); - case DatasetProfileFieldViewStyle.RadioBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RADIO-BOX'); - case DatasetProfileFieldViewStyle.TextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TEXT-AREA'); - case DatasetProfileFieldViewStyle.RichTextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA'); - case DatasetProfileFieldViewStyle.Upload: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.UPLOAD'); - case DatasetProfileFieldViewStyle.Table: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TABLE'); - case DatasetProfileFieldViewStyle.DatePicker: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATE-PICKER'); - case DatasetProfileFieldViewStyle.ExternalDatasets: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.EXTERNAL-DATASETS'); - case DatasetProfileFieldViewStyle.DataRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATA-REPOSITORIES'); - case DatasetProfileFieldViewStyle.PubRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUB-REPOSITORIES'); - case DatasetProfileFieldViewStyle.JournalRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.JOURNALS-REPOSITORIES'); - case DatasetProfileFieldViewStyle.Taxonomies: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAXONOMIES'); - case DatasetProfileFieldViewStyle.Licenses: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.LICENSES'); - case DatasetProfileFieldViewStyle.Publications: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUBLICATIONS'); - case DatasetProfileFieldViewStyle.Registries: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.REGISTRIES'); - case DatasetProfileFieldViewStyle.Services: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SERVICES'); - case DatasetProfileFieldViewStyle.Tags: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAGS'); - case DatasetProfileFieldViewStyle.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RESEARCHERS'); - case DatasetProfileFieldViewStyle.Organizations: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.ORGANIZATIONS'); - case DatasetProfileFieldViewStyle.DatasetIdentifier: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATASET-IDENTIFIER'); - case DatasetProfileFieldViewStyle.Currency: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CURRENCY'); - case DatasetProfileFieldViewStyle.Validation: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.VALIDATION'); - } - } - toDatasetProfileViewTypeString(status: ViewStyleType): string { - switch (status) { - case ViewStyleType.BooleanDecision: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.BOOLEAN-DECISION'); - case ViewStyleType.CheckBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CHECKBOX'); - case ViewStyleType.Select: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SELECT'); - case ViewStyleType.InternalDmpEntities: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.INTERNAL-DMP-ENTITIES'); - case ViewStyleType.FreeText: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.FREE-TEXT'); - case ViewStyleType.RadioBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RADIO-BOX'); - case ViewStyleType.TextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TEXT-AREA'); - case ViewStyleType.RichTextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA'); - case ViewStyleType.Table: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TABLE'); - case ViewStyleType.Upload: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.UPLOAD'); - case ViewStyleType.DatePicker: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATE-PICKER'); - case ViewStyleType.ExternalDatasets: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.EXTERNAL-DATASETS'); - case ViewStyleType.DataRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATA-REPOSITORIES'); - case ViewStyleType.PubRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUB-REPOSITORIES'); - case ViewStyleType.JournalRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.JOURNALS-REPOSITORIES'); - case ViewStyleType.Taxonomies: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAXONOMIES'); - case ViewStyleType.Licenses: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.LICENSES'); - case ViewStyleType.Publications: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUBLICATIONS'); - case ViewStyleType.Registries: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.REGISTRIES'); - case ViewStyleType.Services: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SERVICES'); - case ViewStyleType.Tags: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAGS'); - case ViewStyleType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RESEARCHERS'); - case ViewStyleType.Organizations: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.ORGANIZATIONS'); - case ViewStyleType.DatasetIdentifier: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATASET-IDENTIFIER'); - case ViewStyleType.Currency: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CURRENCY'); - case ViewStyleType.Validation: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.VALIDATION'); - case ViewStyleType.Other: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.OTHER'); - } - - } - - toDatasetProfileComboBoxTypeString(status: DatasetProfileComboBoxType): string { - switch (status) { - case DatasetProfileComboBoxType.WordList: return this.language.instant('TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.WORD-LIST'); - case DatasetProfileComboBoxType.Autocomplete: return this.language.instant('TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.AUTOCOMPLETE'); - } - } - - toDatasetProfileInternalDmpEntitiesTypeString(status: DatasetProfileInternalDmpEntitiesType): string { - switch (status) { - case DatasetProfileInternalDmpEntitiesType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.RESEARCHERS'); - case DatasetProfileInternalDmpEntitiesType.Datasets: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.DATASETS'); - case DatasetProfileInternalDmpEntitiesType.Dmps: return this.language.instant('TYPES.DATASET-PROFILE-INTERNAL-DMP-ENTITIES-TYPE.DMPS'); - } - } - - toRecentActivityOrderString(status: RecentActivityOrder): string { - switch (status) { - case RecentActivityOrder.CREATED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.CREATED'); - case RecentActivityOrder.LABEL: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.LABEL'); - case RecentActivityOrder.MODIFIED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.MODIFIED'); - case RecentActivityOrder.FINALIZED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.FINALIZED'); - case RecentActivityOrder.PUBLISHED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.PUBLISHED'); - case RecentActivityOrder.DATASETPUBLISHED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.PUBLISHED'); - case RecentActivityOrder.STATUS: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.STATUS'); - } - } - - toRoleString(status: Role): string { - switch (status) { - case Role.Owner: return this.language.instant('FACET-SEARCH.ROLE.OWNER'); - case Role.Member: return this.language.instant('FACET-SEARCH.ROLE.MEMBER'); - } - } - toRoleOrganizationString(status: RoleOrganizationType): string { switch (status) { case RoleOrganizationType.Faculty: return this.language.instant('USER-PROFILE.ROLE-ORGANIZATION.FACULTY'); @@ -373,8 +263,8 @@ export class EnumUtils { } } - toDmpUserRolesString(roles: DmpUserRole[]): string { return roles.map(x => this.toDmpUserRoleString(x)).join(', ') } - toDmpUserRoleString(role: DmpUserRole): string { + toDmpUserRolesString(roles: DmpUserRole[]): string { return roles.map(x => this.toDmpUserRoleString(x)).join(', ') } + toDmpUserRoleString(role: DmpUserRole): string { switch (role) { case DmpUserRole.Owner: return this.language.instant('TYPES.DMP-USER-ROLE.OWNER'); case DmpUserRole.User: return this.language.instant('TYPES.DMP-USER-ROLE.USER'); @@ -414,4 +304,16 @@ export class EnumUtils { case EmailOverrideMode.Replace: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-EMAIL-OVERRIDE-MODE.REPLACE'); } } + + toRecentActivityOrderString(status: RecentActivityOrder): string { + switch (status) { + // case RecentActivityOrder.CREATED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.CREATED'); + case RecentActivityOrder.Label: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.LABEL'); + case RecentActivityOrder.UpdatedAt: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.MODIFIED'); + // case RecentActivityOrder.FINALIZED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.FINALIZED'); + // case RecentActivityOrder.PUBLISHED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.PUBLISHED'); + // case RecentActivityOrder.DATASETPUBLISHED: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.PUBLISHED'); + case RecentActivityOrder.Status: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.STATUS'); + } + } } diff --git a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.html b/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.html deleted file mode 100644 index 6e601516c..000000000 --- a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.html +++ /dev/null @@ -1,18 +0,0 @@ -
-
-
- {{ data.message }} -
-
close
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.scss b/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.scss deleted file mode 100644 index f23b9e314..000000000 --- a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.scss +++ /dev/null @@ -1,16 +0,0 @@ -.export-method-dialog { - .export-method-message { - padding-bottom: 20px;; - } - - .close-btn { - margin-left: auto; - cursor: pointer; - } - - button { - // background-color: #aaaaaa; - background-color: var(--primary-color-3); - color: #ffffff; - } -} diff --git a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.ts b/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.ts deleted file mode 100644 index a702a72b8..000000000 --- a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Component, OnInit, Inject } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; - - -@Component({ - selector: 'app-export-method-dialog', - templateUrl: './export-method-dialog.component.html', - styleUrls: ['./export-method-dialog.component.scss'] -}) -export class ExportMethodDialogComponent implements OnInit { - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } - - ngOnInit() { - } - - close() { - this.dialogRef.close(false); - } - - downloadXML() { - this.dialogRef.close("xml"); - } - - downloadDocument() { - this.dialogRef.close("doc"); - } - - downloadPdf() { - this.dialogRef.close("pdf"); - } - - downloadJson() { - this.dialogRef.close("json"); - } - - isFinalized() { - return this.data.isFinalized; - } -} diff --git a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.module.ts b/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.module.ts deleted file mode 100644 index 51f8dedcc..000000000 --- a/dmp-frontend/src/app/library/export-method-dialog/export-method-dialog.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NgModule } from '@angular/core'; -import { ExportMethodDialogComponent } from '@app/library/export-method-dialog/export-method-dialog.component'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [CommonUiModule], - declarations: [ExportMethodDialogComponent], - exports: [ExportMethodDialogComponent] -}) -export class ExportMethodDialogModule { - constructor() { } -} diff --git a/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts b/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts index 4168ab651..097038de2 100644 --- a/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts +++ b/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts @@ -1,6 +1,5 @@ -import {Component, Input} from "@angular/core"; -import {AngularEditorConfig} from "@kolkov/angular-editor"; -import {UntypedFormControl} from "@angular/forms"; +import { ChangeDetectionStrategy, Component, Input } from "@angular/core"; +import { AngularEditorConfig } from "@kolkov/angular-editor"; @Component({ selector: 'rich-text-editor-component', @@ -10,10 +9,12 @@ import {UntypedFormControl} from "@angular/forms"; [config]="editorConfig" [formControlName]="controlName" placeholder="{{(placeholder? (placeholder | translate) : '') + (required ? ' *': '')}}" (paste)="pasteWithoutFormatting($event)"> - close + close `, - styleUrls: ['./rich-text-editor.component.scss'] + styleUrls: ['./rich-text-editor.component.scss'], + // TODO: performance issue with this control. changed the change detection strategy in case it improves + changeDetection: ChangeDetectionStrategy.OnPush }) export class RichTextEditorComponent { @Input() parentFormGroup; @@ -42,12 +43,12 @@ export class RichTextEditorComponent { sanitize: true, toolbarPosition: 'top', customClasses: [ - { name: 'H1 header', class: '', tag: 'h1' }, - { name: 'H2 header', class: '', tag: 'h2' }, - { name: 'H3 header', class: '', tag: 'h3' }, - { name: 'H4 header', class: '', tag: 'h4' }, - { name: 'H5 header', class: '', tag: 'h5'}, - { name: 'H6 header', class: '', tag: 'h6'} + { name: 'H1 header', class: '', tag: 'h1' }, + { name: 'H2 header', class: '', tag: 'h2' }, + { name: 'H3 header', class: '', tag: 'h3' }, + { name: 'H4 header', class: '', tag: 'h4' }, + { name: 'H5 header', class: '', tag: 'h5' }, + { name: 'H6 header', class: '', tag: 'h6' } ], toolbarHiddenButtons: [ [ @@ -66,8 +67,9 @@ export class RichTextEditorComponent { ] }; - get formInput(): UntypedFormControl { - return this.parentFormGroup.get(this.controlName); + + ngOnInit() { + console.log('ngOnInit: '); } ngAfterContentInit() { diff --git a/dmp-frontend/src/app/library/url-listing/url-listing-item.ts b/dmp-frontend/src/app/library/url-listing/url-listing-item.ts deleted file mode 100644 index 6fd4c5639..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing-item.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export class UrlListingItem { - public label: string; - public url: string; - public all: string; -} diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.component.html b/dmp-frontend/src/app/library/url-listing/url-listing.component.html deleted file mode 100644 index baa37bc6c..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.component.html +++ /dev/null @@ -1,4 +0,0 @@ - -{{'URL-LISTING-COMPONENT.SHOW-MORE'|translate}} diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.component.scss b/dmp-frontend/src/app/library/url-listing/url-listing.component.scss deleted file mode 100644 index 757307de7..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -.url-listing-item:hover { - color: #0056b3 !important; - text-decoration: underline !important; -} - -.url-listing-item { - color: #007bff !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.component.ts b/dmp-frontend/src/app/library/url-listing/url-listing.component.ts deleted file mode 100644 index 95bc53b5a..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Component, Input } from "@angular/core"; -import { Router } from "@angular/router"; -import { UrlListingItem } from "./url-listing-item"; - -@Component({ - selector: 'app-url-listing', - templateUrl: './url-listing.component.html', - styleUrls: ['./url-listing.component.scss'] -}) -export class UrlListingComponent { - - @Input() items: UrlListingItem[]; - @Input() parameters: any - @Input() urlLimit: number = 3; - - constructor( - private router: Router - ) { } - - ngOnInit() { - - } - - navigate(link: string) { - this.router.navigate([link], { queryParams: this.parameters }); - } -} diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.module.ts b/dmp-frontend/src/app/library/url-listing/url-listing.module.ts deleted file mode 100644 index 3ee5b0996..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.module.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormattingModule } from '@app/core/formatting.module'; -import { UrlListingComponent } from '@app/library/url-listing/url-listing.component'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [ - CommonUiModule, - FormattingModule - ], - declarations: [ - UrlListingComponent - ], - exports: [ - UrlListingComponent - ] -}) -export class UrlListingModule { - constructor() { } -} diff --git a/dmp-frontend/src/app/models/dynamic-field-grant/DynamicFieldGrantCriteria.ts b/dmp-frontend/src/app/models/dynamic-field-grant/DynamicFieldGrantCriteria.ts deleted file mode 100644 index e82f095f5..000000000 --- a/dmp-frontend/src/app/models/dynamic-field-grant/DynamicFieldGrantCriteria.ts +++ /dev/null @@ -1,9 +0,0 @@ -export class DynamicFieldGrantCriteria { - public id: string; - public dynamicFields: DynamicFieldGrantCriteriaDependencies[]; -} - -export class DynamicFieldGrantCriteriaDependencies { - public value; - public property; -} diff --git a/dmp-frontend/src/app/models/language/Language.ts b/dmp-frontend/src/app/models/language/Language.ts deleted file mode 100644 index b75ea3e03..000000000 --- a/dmp-frontend/src/app/models/language/Language.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class Language { - public key: string; - public languageKey: string; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts deleted file mode 100644 index 58e01114a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { DefaultValue } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; - -export class DefaultValueEditorModel extends BaseFormModel { - public type: string; - public value: string; - - fromModel(item: DefaultValue): DefaultValueEditorModel { - this.type = item.type; - this.value = item.value; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DefaultValueEditorModel.type')) }], - value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('DefaultValueEditorModel.value')) }] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts deleted file mode 100644 index 9eec7c2a7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { UntypedFormGroup, Validators } from "@angular/forms"; -import { FieldDataEditorModel } from "./field-data-editor-model"; -import { AuthAutoCompleteData, AutoCompleteSingleData } from "@app/core/model/dataset-profile-definition/field-data/field-data"; - -export class AuthFieldEditorModel extends FieldDataEditorModel { - url: string; - method: string; - body: string; - path: string; - type: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - method: [{ value: this.method, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.method')) }], - url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.url')) },[Validators.required]], - body: [{ value: this.body, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.body')) }], - path: [{ value: this.path, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.path')) }, [Validators.required]], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.type')) }, [Validators.required]] - }); - - return formGroup; - } - - fromModel(item: AuthAutoCompleteData): AuthFieldEditorModel { - this.url = item.url; - this.method = item.method; - this.body = item.body; - this.path = item.path; - this.type = item.type; - return this; - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts deleted file mode 100644 index ecf09ebce..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { AutoCompleteFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; -import { AutoCompleteSingleDataEditorModel } from './auto-complete-single-data'; - -export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - - public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.Autocomplete; - public multiAutoComplete: boolean; - public autoCompleteSingleDataList: Array = new Array(); - //public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }); - - const autocompleteFormArray = new Array(); - if (this.autoCompleteSingleDataList) { - this.autoCompleteSingleDataList.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - autocompleteFormArray.push(form); - }); - } - - formGroup.addControl('autoCompleteSingleDataList', this.formBuilder.array(autocompleteFormArray)); - - return formGroup; - } - - fromModel(item: AutoCompleteFieldData): AutoCompleteFieldDataEditorModel { - this.type = item.type; - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - if (item.autoCompleteSingleDataList) { this.autoCompleteSingleDataList = item.autoCompleteSingleDataList.map(x => new AutoCompleteSingleDataEditorModel().fromModel(x)); } - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts deleted file mode 100644 index e84fd4e1d..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; -import { UntypedFormGroup, Validators } from '@angular/forms'; -import { AutoCompleteFieldData, AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data'; -//import { AuthFieldEditorModel } from './auto-complete-auth-field-data.model'; - -export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel { - - public url: string; - public optionsRoot: string; - - public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - public autoCompleteType: number; - public method: string; - public hasAuth: boolean; - //public auth: AuthFieldEditorModel = new AuthFieldEditorModel(); - //public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.label')) }], - url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.url')) },[Validators.required]], - optionsRoot: [{ value: this.optionsRoot, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.optionsRoot')) }, [Validators.required]], - autoCompleteType: [{ value: this.autoCompleteType, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.autoCompleteType')) }], - hasAuth: [{ value: this.hasAuth, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.hasAuth')) }], - method: [{ value: this.method, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.method')) }] - }); - formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable)); - //formGroup.addControl('auth', this.auth.buildForm(disabled, skipDisable)); - - return formGroup; - } - - fromModel(item: AutoCompleteSingleData): AutoCompleteSingleDataEditorModel { - this.url = item.url; - this.label = item.label; - this.optionsRoot = item.optionsRoot; - this.autoCompleteType = item.autocompleteType; - this.hasAuth = item.hasAuth; - this.method = item.method ? item.method : 'GET'; - this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions); - //this.auth = new AuthFieldEditorModel().fromModel(item.auth); - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts deleted file mode 100644 index ca0332c32..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { BooleanDecisionFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class BooleanDecisionFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('BooleanDecisionFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: BooleanDecisionFieldData): BooleanDecisionFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts deleted file mode 100644 index 996ad10b3..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { CheckBoxFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class CheckBoxFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('CheckBoxFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: CheckBoxFieldData): CheckBoxFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts deleted file mode 100644 index c4f2d35e0..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { CurrencyFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class CurrencyDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('CurrencyDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: CurrencyFieldData): CurrencyDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts deleted file mode 100644 index 45b23fcb2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DataRepositoriesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class DataRepositoriesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: DataRepositoriesFieldData): DataRepositoriesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts deleted file mode 100644 index 414526181..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DatasetIdentifierFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class DatasetIdentifierDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetIdentifierDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: DatasetIdentifierFieldData): DatasetIdentifierDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts deleted file mode 100644 index 32f65bfea..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { UntypedFormGroup } from "@angular/forms"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { DatasetsAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; -import { FieldDataEditorModel } from "./field-data-editor-model"; - -export class DatasetsAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Datasets; - public multiAutoComplete: boolean = false; - //public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.multiAutoComplete')) }], - }) - return formGroup; - } - - fromModel(item: DatasetsAutoCompleteFieldData): DatasetsAutoCompleteFieldDataEditorModel { - this.label = item.label; - this.type = item.type; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts deleted file mode 100644 index 7101a775a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DatePickerFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class DatePickerDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatePickerDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: DatePickerFieldData): DatePickerDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts deleted file mode 100644 index 24bf7d582..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { FieldDataEditorModel } from "./field-data-editor-model"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { FieldDataOptionEditorModel } from "./field-data-option-editor-model"; -import { DmpsAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; -import { UntypedFormGroup } from "@angular/forms"; - -export class DmpsAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Dmps; - public multiAutoComplete: boolean = false; - //public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DmpsAutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DmpsAutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('DmpsAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }) - return formGroup; - } - - fromModel(item: DmpsAutoCompleteFieldData): DmpsAutoCompleteFieldDataEditorModel { - this.label = item.label; - this.type = item.type; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts deleted file mode 100644 index 447c8bb90..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ExternalDatasetsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { ExternalDatasetTypeEnum } from '@app/core/common/enum/external-dataset-type-enum'; - -export class ExternalDatasetsDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - public type: ExternalDatasetTypeEnum; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.multiAutoComplete')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.type')) }] - }); - return formGroup; - } - - fromModel(item: ExternalDatasetsFieldData): ExternalDatasetsDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - this.type = item.type; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts deleted file mode 100644 index 78f15c0d8..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { BaseFormModel } from '../../../../../core/model/base-form-model'; - -export abstract class FieldDataEditorModel extends BaseFormModel { - - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - throw new Error('Build Form Is not not correctly overriden'); - } - - fromJSONObject(item: any): T { - throw new Error('From Json Object is not correctly overriden'); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts deleted file mode 100644 index 991f4fc72..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { FieldDataOption } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class FieldDataOptionEditorModel extends FieldDataEditorModel { - public label: string; - public value: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - return new UntypedFormBuilder().group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.label')) },[Validators.required]], - value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.value')) },[Validators.required]], - }); - } - - fromModel(item: FieldDataOption): FieldDataOptionEditorModel { - if (item) { - this.label = item.label; - this.value = item.value; - } - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts deleted file mode 100644 index bf5c11038..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FreeTextFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class FreeTextFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FreeTextFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: FreeTextFieldData): FreeTextFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts deleted file mode 100644 index 56427d988..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { LicensesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -export class LicensesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: LicensesFieldData): LicensesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts deleted file mode 100644 index 2efa6c160..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { OrganizationsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class OrganizationsDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean = false; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('OrganizationsDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('OrganizationsDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: OrganizationsFieldData): OrganizationsDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts deleted file mode 100644 index 233d18e1d..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { PublicationsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -export class PublicationsDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: PublicationsFieldData): PublicationsDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts deleted file mode 100644 index a7f8ba191..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { RadioBoxFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; - -export class RadioBoxFieldDataEditorModel extends FieldDataEditorModel { - - public options: Array = []; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RadioBoxFieldDataEditorModel.label')) }] - }); - const optionsFormArray = new Array(); - if (this.options) { - this.options.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - optionsFormArray.push(form); - }); - } - formGroup.addControl('options', this.formBuilder.array(optionsFormArray)); - return formGroup; - } - - fromModel(item: RadioBoxFieldData): RadioBoxFieldDataEditorModel { - if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); } - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts deleted file mode 100644 index 6f996564e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { RegistriesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class RegistriesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RegistriesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('RegistriesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: RegistriesFieldData): RegistriesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts deleted file mode 100644 index c4101bdbd..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { FieldDataEditorModel } from "./field-data-editor-model"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { FieldDataOptionEditorModel } from "./field-data-option-editor-model"; -import { UntypedFormGroup } from "@angular/forms"; -import { ResearchersAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; - -export class ResearchersAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - - public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Researchers; - public multiAutoComplete: boolean = false; - //public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }) - //formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable)); - - return formGroup; - } - - fromModel(item: ResearchersAutoCompleteFieldData): ResearchersAutoCompleteFieldDataEditorModel { - this.label = item.label; - this.type = item.type; - this.multiAutoComplete = item.multiAutoComplete; - // this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions); - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts deleted file mode 100644 index 27f9abc12..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ResearchersFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class ResearchersDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean = false; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ResearchersDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: ResearchersFieldData): ResearchersDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts deleted file mode 100644 index cbc8e5ffc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { RichTextAreaFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class RichTextAreaFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RichTextAreaFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: RichTextAreaFieldData): RichTextAreaFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts deleted file mode 100644 index 4c738bbbc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ServicesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class ServicesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: ServicesFieldData): ServicesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts deleted file mode 100644 index b5c20ff22..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { TagsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class TagsDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('TagsDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: TagsFieldData): TagsDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts deleted file mode 100644 index 0f7f0c4d3..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import {TaxonomiesFieldData} from "@app/core/model/dataset-profile-definition/field-data/field-data"; - -export class TaxonomiesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: TaxonomiesFieldData): TaxonomiesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts deleted file mode 100644 index 7c9d9f34b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { TextAreaFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class TextAreaFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('TextAreaFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: TextAreaFieldData): TextAreaFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts deleted file mode 100644 index 950f7e364..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { - FieldDataOption, - UploadFieldData -} from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import {FieldDataOptionEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model"; - -export class UploadFieldDataEditorModel extends FieldDataEditorModel { - public types: Array = []; - public maxFileSizeInMB: number; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('UploadFieldDataEditorModel.label')) }], - maxFileSizeInMB: [{ value: this.maxFileSizeInMB, disabled: (disabled && !skipDisable.includes('UploadFieldDataEditorModel.maxFileSizeInMB')) }], - // types: [{ value: this.types, disabled: (disabled && !skipDisable.includes('UploadFieldDataEditorModel.types')) }] - }); - const optionsFormArray = new Array(); - if (this.types) { - this.types.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - optionsFormArray.push(form); - }); - } - formGroup.addControl('types', this.formBuilder.array(optionsFormArray)); - if(disabled && !skipDisable.includes('UploadFieldDataEditorModel.types')) { - formGroup.disable(); - } - return formGroup; } - - fromModel(item: UploadFieldData): UploadFieldDataEditorModel { - if (item.types) { this.types = item.types.map(x => new FieldDataOptionEditorModel().fromModel(x)); } - this.label = item.label; - this.maxFileSizeInMB = item.maxFileSizeInMB; - // this.types = item.types; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts deleted file mode 100644 index e67cd93dc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ValidationFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class ValidationDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ValidationDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: ValidationFieldData): ValidationDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts deleted file mode 100644 index 82e2497ba..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { WordListFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; - -export class WordListFieldDataEditorModel extends FieldDataEditorModel { - public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.WordList; - public options: Array; - public multipleList: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.type')) }], - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.label')) }], - multiList: [{ value: this.multipleList, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.multipleList'))}] - }); - const optionsFormArray = new Array(); - if (this.options) { - this.options.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - optionsFormArray.push(form); - }); - } - formGroup.addControl('options', this.formBuilder.array(optionsFormArray)); - - return formGroup; - } - - fromModel(item: WordListFieldData): WordListFieldDataEditorModel { - this.type = item.type; - if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); } - this.label = item.label; - this.multipleList = item.multiList; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts deleted file mode 100644 index b4a09b98f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { FormArray, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { ValidationType } from '../../../../core/common/enum/validation-type'; -import { Field } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { DefaultValueEditorModel } from './default-value-editor-model'; -import { AutoCompleteFieldDataEditorModel } from './field-data/auto-complete-field-data-editor-model'; -import { BooleanDecisionFieldDataEditorModel } from './field-data/boolean-decision-field-data-editor-model'; -import { CheckBoxFieldDataEditorModel } from './field-data/check-box-field-data-editor-model'; -import { FieldDataEditorModel } from './field-data/field-data-editor-model'; -import { FreeTextFieldDataEditorModel } from './field-data/free-text-field-data-editor-model'; -import { RadioBoxFieldDataEditorModel } from './field-data/radio-box-field-data-editor-model'; -import { TextAreaFieldDataEditorModel } from './field-data/text-area-field-data-editor-model'; -import { RichTextAreaFieldDataEditorModel } from './field-data/rich-text-area-field-data-editor-model'; -import {UploadFieldDataEditorModel} from "./field-data/upload-field-data-editor-model"; -import { WordListFieldDataEditorModel } from './field-data/word-list-field-data-editor-model'; -import { ViewStyleEditorModel } from './view-style-editor-model'; -import { VisibilityEditorModel } from './visibility-editor-model'; -import { DatasetProfileEditorDatePickerFieldComponent } from '../editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component'; -import { DatePickerDataEditorModel } from './field-data/date-picker-data-editor-models'; -import { ResearchersAutoCompleteFieldDataEditorModel } from './field-data/researchers-auto-complete-field-data-editor-model'; -import { DatasetsAutoCompleteFieldDataEditorModel } from './field-data/datasets-autocomplete-field-data-editor-mode'; -import { DmpsAutoCompleteFieldDataEditorModel } from './field-data/dmps-autocomplete-field-data-editor-model'; -import { ExternalDatasetsDataEditorModel } from './field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from './field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from './field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from './field-data/services-data-editor-models'; -import { TagsDataEditorModel } from './field-data/tags-data-editor-models'; -import { ResearchersDataEditorModel } from './field-data/researchers-data-editor-models'; -import { OrganizationsDataEditorModel } from './field-data/organizations-data-editor-models'; -import { DatasetIdentifierDataEditorModel } from './field-data/dataset-identifier-data-editor-models'; -import { CurrencyDataEditorModel } from './field-data/currency-data-editor-models'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { EditorCustomValidators } from '../editor/custom-validators/editor-custom-validators'; -import { ValidationDataEditorModel } from './field-data/validation-data-editor-models'; -import {PublicationsDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models"; -import {LicensesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models"; -import {TaxonomiesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models"; - -export class FieldEditorModel extends BaseFormModel { - - public id: string; - // public title: string; - public defaultValue: DefaultValueEditorModel = new DefaultValueEditorModel(); - public viewStyle: ViewStyleEditorModel = new ViewStyleEditorModel(); - public page: number = null; - public ordinal: number = null; - public visible: VisibilityEditorModel = new VisibilityEditorModel(); - public data: FieldDataEditorModel; - public validations: ValidationType[] = []; - public schematics: string[]; - public export: boolean = true; - - fromModel(item: Field): FieldEditorModel { - this.id = item.id; - if (item.defaultValue) { this.defaultValue = new DefaultValueEditorModel().fromModel(item.defaultValue); } - this.page = item.page; - this.ordinal = item.ordinal; - this.validations = item.validations; - this.viewStyle = new ViewStyleEditorModel().fromModel(item.viewStyle); - this.visible = new VisibilityEditorModel().fromModel(item.visible); - this.schematics = item.schematics; - this.export = item.export; - - if (item.data) { - if (this.viewStyle.renderStyle === 'combobox') { - if (item.data.type === 'autocomplete') { this.data = new AutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (item.data.type === 'wordlist') { this.data = new WordListFieldDataEditorModel().fromModel(item.data); } - } else if (this.viewStyle.renderStyle === 'internalDmpEntities') { - if (item.data.type === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (item.data.type === 'datasets') { this.data = new DatasetsAutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (item.data.type === 'dmps') { this.data = new DmpsAutoCompleteFieldDataEditorModel().fromModel(item.data); } - } else { - if (this.viewStyle.renderStyle === 'radiobox') { this.data = new RadioBoxFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'checkBox') { this.data = new CheckBoxFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'textarea') { this.data = new TextAreaFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'richTextarea') { this.data = new RichTextAreaFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'upload') { this.data = new UploadFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'freetext') { this.data = new FreeTextFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'booleanDecision') { this.data = new BooleanDecisionFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'datePicker') { this.data = new DatePickerDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'externalDatasets') { this.data = new ExternalDatasetsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'dataRepositories') { this.data = new DataRepositoriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'pubRepositories') { this.data = new DataRepositoriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'journalRepositories') { this.data = new DataRepositoriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'taxonomies') { this.data = new TaxonomiesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'licenses') { this.data = new LicensesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'publications') { this.data = new PublicationsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'registries') { this.data = new RegistriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'services') { this.data = new ServicesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'tags') { this.data = new TagsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'organizations') { this.data = new OrganizationsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'datasetIdentifier') { this.data = new DatasetIdentifierDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'currency') { this.data = new CurrencyDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'validation') { this.data = new ValidationDataEditorModel().fromModel(item.data); } - } - } - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], - // title: [this.title], - page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('FieldEditorModel.page')) }], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldEditorModel.ordinal')) }], - validations: [{ value: this.validations, disabled: (disabled && !skipDisable.includes('FieldEditorModel.validations')) }], - schematics: [{ value: this.schematics, disabled: (disabled && !skipDisable.includes('FieldEditorModel.schematics')) }], - export: [{value: this.export, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.export'))}] - }); - - formGroup.addControl('defaultValue', this.defaultValue.buildForm(disabled, skipDisable)); - formGroup.addControl('viewStyle', this.viewStyle.buildForm(disabled, skipDisable)); - formGroup.addControl('visible', this.visible.buildForm(disabled, skipDisable)); - if (this.data) { formGroup.addControl('data', this.data.buildForm(disabled, skipDisable)); } - else { formGroup.addControl('data', new WordListFieldDataEditorModel().buildForm(disabled, skipDisable)); } - - - // //append validators - - this._appendCustomValidators(formGroup); - - - // //setting up listeners - // formGroup.get('viewStyle').valueChanges.subscribe(changes=>{ - // // const viewStyleChanges:{cssClass:string, renderStyle: string} = changes; - - // this._removeCustomValidators(formGroup); - // this._appendCustomValidators(formGroup); - - // }) - - return formGroup; - } - - - private _appendCustomValidators(formGroup: UntypedFormGroup){ - const renderStyleValue = formGroup.get('viewStyle').get('renderStyle').value; - if(renderStyleValue === 'checkBox'){ - formGroup.get('defaultValue').get('value').setValidators(Validators.required); - formGroup.get('defaultValue').get('value').updateValueAndValidity(); - }else if(renderStyleValue === 'combobox'){ - try{ - const comboType = formGroup.get('data').get('type').value; - if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - }else if(comboType === DatasetProfileComboBoxType.WordList){ - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - } - }catch(e){ - console.error('Error setting validators.'); - console.error(e); - } - }else if(renderStyleValue === 'radiobox'){ - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - }else if(renderStyleValue === 'upload'){ - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('types')); - formGroup.get('data').get('maxFileSizeInMB').setValidators(Validators.required); - } - - formGroup.get('data').updateValueAndValidity(); - } - - // private _removeCustomValidators(formGroup:FormGroup){ - // const renderStyleValue = formGroup.get('viewStyle').get('renderStyle').value; - // if(renderStyleValue != 'checkBox'){ - // formGroup.get('defaultValue').get('value').clearValidators(); - // }else if(renderStyleValue === 'combobox'){ - // formGroup.get('data').clearValidators(); - // } - // } - // private _buildData(formGroup: FormGroup){ - - // } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts deleted file mode 100644 index 56884bc71..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts +++ /dev/null @@ -1,54 +0,0 @@ - -import { UntypedFormGroup, Validators } from '@angular/forms'; -import { FieldSet } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { FieldEditorModel } from './field-editor-model'; -import { MultiplicityEditorModel } from './multiplicity-editor-model'; - -export class FieldSetEditorModel extends BaseFormModel { - - public fields: Array = new Array(); - public id: string; - public ordinal: number; - public multiplicity: MultiplicityEditorModel = new MultiplicityEditorModel(); - public title: string; - public description: string; - public extendedDescription: string; - public additionalInformation: string; - public hasCommentField: boolean; - - fromModel(item: FieldSet): FieldSetEditorModel { - - if (item.fields) { this.fields = item.fields.map(x => new FieldEditorModel().fromModel(x)); } - if (item.multiplicity) this.multiplicity = new MultiplicityEditorModel().fromModel(item.multiplicity); - this.id = item.id; - this.ordinal = item.ordinal; - this.title = item.title; - this.description = item.description; - this.extendedDescription = item.extendedDescription; - this.additionalInformation = item.additionalInformation; - this.hasCommentField = item.hasCommentField; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.ordinal')) }], - title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.title')) }, [Validators.required]], - description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.description')) }], - extendedDescription: [{ value: this.extendedDescription, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.extendedDescription')) }], - additionalInformation: [{ value: this.additionalInformation, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.additionalInformation')) }], - hasCommentField: [{ value: this.hasCommentField, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.hasCommentField')) }] - }); - const fieldsFormArray = new Array(); - this.fields.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - fieldsFormArray.push(form); - }); - formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); - formGroup.addControl('multiplicity', this.multiplicity.buildForm(disabled, skipDisable)); - - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts deleted file mode 100644 index 6efbd8bf1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {UntypedFormGroup} from '@angular/forms'; -import {Multiplicity} from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import {BaseFormModel} from '../../../../core/model/base-form-model'; - -export class MultiplicityEditorModel extends BaseFormModel { - public min: number; - public max: number; - public placeholder: string; - public tableView: boolean; - - fromModel(item: Multiplicity): MultiplicityEditorModel { - this.min = item.min; - this.max = item.max; - this.placeholder = item.placeholder; - this.tableView = item.tableView; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - return this.formBuilder.group({ - min: [{value: this.min, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.min'))}], - max: [{value: this.max, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.max'))}], - placeholder: [{ - value: this.placeholder, - disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.placeholder')) - }], - tableView: [{value: this.tableView, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.tableView'))}] - }); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts deleted file mode 100644 index 1fc8fc536..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { UntypedFormGroup, Validators } from '@angular/forms'; -import { Page } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '@app/core/model/base-form-model'; -import { Guid } from '@common/types/guid'; - -export class PageEditorModel extends BaseFormModel { - public title: string; - public id: string; - public ordinal: number; - - constructor(ordinal?: number) { - super(); - if (isNaN(ordinal)) { this.ordinal = 0; } else { this.ordinal = ordinal; } - this.id = Guid.create().toString(); - } - - fromModel(item: Page): PageEditorModel { - this.title = item.title; - this.id = item.id; - this.ordinal = item.ordinal; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('PageEditorModel.title')) }, [Validators.required]], - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('PageEditorModel.id')) }, [Validators.required]], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('PageEditorModel.ordinal')) }] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts deleted file mode 100644 index 9f3cdc5a6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { UntypedFormGroup, Validators } from "@angular/forms"; -import { Rule } from "../../../../core/model/admin/dataset-profile/dataset-profile"; -import { BaseFormModel } from "../../../../core/model/base-form-model"; - -export class RuleEditorModel extends BaseFormModel { - public target: string; - public value: string; - public ruleType: string; - public ruleStyle: string; - public valueType: string; - - fromModel(item: Rule): RuleEditorModel { - this.target = item.target; - this.value = item.value; - this.ruleType = item.ruleType; - this.ruleStyle = item.ruleStyle; - this.valueType = item.valueType; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - // sourceField: [this.sourceField], - target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }, [Validators.required]], - ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }], - value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }, [Validators.required]], - ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }], - valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts deleted file mode 100644 index 42e5b286f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { UntypedFormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { Section } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { EditorCustomValidators } from '../editor/custom-validators/editor-custom-validators'; -import { FieldSetEditorModel } from './field-set-editor-model'; - -export class SectionEditorModel extends BaseFormModel { - public sections: Array = new Array(); - public defaultVisibility: boolean; - public page: string; - public id: string; - public title: string; - public description: string; - public ordinal: number; - public fieldSets: Array = new Array(); - - fromModel(item: Section): SectionEditorModel { - if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } - this.page = item.page; - this.defaultVisibility = item.defaultVisibility; - this.id = item.id; - this.title = item.title; - this.description = item.description; - this.ordinal = item.ordinal; - if (item.fieldSets) { this.fieldSets = item.fieldSets.map(x => new FieldSetEditorModel().fromModel(x)); } - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({ - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('SectionEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], - page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('SectionEditorModel.page')) }, [Validators.required]], - title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('SectionEditorModel.title')) } , [Validators.required]], - description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('SectionEditorModel.description')) }], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('SectionEditorModel.ordinal')) }, [Validators.required]], - defaultVisibility: [{ value: this.defaultVisibility, disabled: (disabled && !skipDisable.includes('SectionEditorModel.defaultVisibility')) }] - }); - const sectionsFormArray = new Array(); - if (this.sections) { - this.sections.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - sectionsFormArray.push(form); - }); - } - const compositeFieldsFormArray = new Array(); - if (this.fieldSets) { - this.fieldSets.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - compositeFieldsFormArray.push(form); - }); - } - formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - formGroup.addControl('fieldSets', this.formBuilder.array(compositeFieldsFormArray)); - - if (!formGroup.controls['defaultVisibility'].value) { formGroup.controls['defaultVisibility'].setValue(true); } - - formGroup.setValidators(EditorCustomValidators.sectionHasAtLeastOneChildOf('fieldSets','sections')); - formGroup.updateValueAndValidity(); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts deleted file mode 100644 index 19c8853b3..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup, Validators } from "@angular/forms"; -import { ViewStyle } from "../../../../core/model/admin/dataset-profile/dataset-profile"; -import { BaseFormModel } from "../../../../core/model/base-form-model"; - -export class ViewStyleEditorModel extends BaseFormModel { - public cssClass: string; - public renderStyle: string; - - fromModel(item: ViewStyle): ViewStyleEditorModel { - this.cssClass = item.cssClass; - this.renderStyle = item.renderStyle; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - cssClass: [{ value: this.cssClass, disabled: (disabled && !skipDisable.includes('ViewStyleEditorModel.cssClass')) }], - renderStyle: [{ value: this.renderStyle, disabled: (disabled && !skipDisable.includes('ViewStyleEditorModel.renderStyle')) }, Validators.required] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts deleted file mode 100644 index d3b77e405..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { Visibility } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { RuleEditorModel } from './rule-editor-model'; - -export class VisibilityEditorModel extends BaseFormModel { - - public rules: Array = new Array(); - public style: string; - - fromModel(item: Visibility): VisibilityEditorModel { - if (item.rules) { this.rules = item.rules.map(x => new RuleEditorModel().fromModel(x)); } - this.style = item.style; - - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - style: [{ value: this.style, disabled: (disabled && !skipDisable.includes('VisibilityEditorModel.style')) }] - }); - - const rulesFormArray = new Array(); - if (this.rules) { - this.rules.forEach(rule => { - const form: UntypedFormGroup = rule.buildForm(disabled, skipDisable); - rulesFormArray.push(form); - }); - } - - formGroup.addControl('rules', this.formBuilder.array(rulesFormArray)); - - return formGroup; - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts deleted file mode 100644 index 66dcb4cc6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { DragDropModule } from '@angular/cdk/drag-drop'; -import { NgModule } from '@angular/core'; -//matrial -import { MatBadgeModule } from '@angular/material/badge'; -import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { DatasetProfileRoutingModule } from '@app/ui/admin/dataset-profile/dataset-profile.routing'; -import { DatasetProfileEditorCompositeFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component'; -import { DatasetProfileEditorDefaultValueComponent } from '@app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component'; -import { DatasetProfileEditorAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component'; -import { DatasetProfileEditorBooleanDecisionFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component'; -import { DatasetProfileEditorCheckboxFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component'; -import { DatasetProfileEditorComboBoxFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component'; -import { DatasetProfileEditorDatasetsAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component'; -import { DatasetProfileEditorDatePickerFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component'; -import { DatasetProfileEditorDmpsAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component'; -import { DatasetProfileEditorFreeTextFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component'; -import { DatasetProfileEditorInternalDmpEntitiesFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component'; -import { DatasetProfileEditorRadioBoxFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component'; -import { DatasetProfileEditorResearchersAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component'; -import { DatasetProfileEditorTextAreaFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component'; -import { DatasetProfileEditorWordListFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component'; -import { DatasetProfileEditorFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component'; -import { DatasetProfileEditorPageComponent } from '@app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component'; -import { DatasetProfileEditorRuleComponent } from '@app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component'; -import { DatasetProfileEditorSectionComponent } from '@app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component'; -import { DatasetProfileEditorComponent } from '@app/ui/admin/dataset-profile/editor/dataset-profile-editor.component'; -import { DatasetProfileCriteriaComponent } from '@app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component'; -import { DialogConfirmationUploadDatasetProfiles } from '@app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; -import { DatasetProfileListingComponent } from '@app/ui/admin/dataset-profile/listing/dataset-profile-listing.component'; -import { DatasetModule } from '@app/ui/dataset/dataset.module'; -import { FormProgressIndicationModule } from '@app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; -import { DragulaModule } from 'ng2-dragula'; -import { NgxDropzoneModule } from 'ngx-dropzone'; -import { DatasetProfileEditorCurrencyFieldComponent } from './editor/components/field-type/currency/dataset-profile-editor-currency-field.component'; -import { DatasetProfileEditorDataRepositoriesFieldComponent } from './editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component'; -import { DatasetProfileEditorDatasetIdentifierFieldComponent } from './editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component'; -import { DatasetProfileEditorExternalDatasetsFieldComponent } from './editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component'; -import { DatasetProfileEditorOrganizationsFieldComponent } from './editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component'; -import { DatasetProfileEditorRegistriesFieldComponent } from './editor/components/field-type/registries/dataset-profile-editor-registries-field.component'; -import { DatasetProfileEditorResearchersFieldComponent } from './editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component'; -import { DatasetProfileEditorServicesFieldComponent } from './editor/components/field-type/services/dataset-profile-editor-services-field.component'; -import { DatasetProfileEditorTagsFieldComponent } from './editor/components/field-type/tags/dataset-profile-editor-tags-field.component'; -import { DatasetProfileEditorValidatorFieldComponent } from './editor/components/field-type/validator/dataset-profile-editor-validator-field.component'; -import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component'; -import { DatasetProfileEditorSectionFieldSetComponent } from './editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component'; -import { ParseStatus } from './listing/pipe/parse-status.pipe'; -import { DatasetProfileTableOfContents } from './table-of-contents/table-of-contents'; -import { DatasetProfileTableOfContentsInternalSection } from './table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section'; -import {TransitionGroupModule} from "@app/ui/transition-group/transition-group.module"; -import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; -import {DatasetProfileEditorRichTextAreaFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component"; -import {DatasetProfileEditorTaxonomiesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component"; -import {DatasetProfileEditorLicensesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component"; -import {DatasetProfileEditorPublicationsFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component"; -import {DatasetProfileEditorJournalRepositoriesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component"; -import {DatasetProfileEditorPubRepositoriesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component"; -import {DatasetProfileEditorUploadFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component"; -// import { TableEditorModule } from "@app/library/table-editor/table-editor.module"; -// import {DatasetProfileEditorTableFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/table/dataset-profile-editor-table-field.component"; - - - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - FormattingModule, - DatasetProfileRoutingModule, - ConfirmationDialogModule, - NgxDropzoneModule, - FormProgressIndicationModule, - DatasetModule, - AngularStickyThingsModule, - DragDropModule, - MatBadgeModule, - DragulaModule, - AutoCompleteModule, - TransitionGroupModule, - RichTextEditorModule, - // TableEditorModule - ], - declarations: [ - DatasetProfileListingComponent, - DatasetProfileCriteriaComponent, - DatasetProfileEditorComponent, - DatasetProfileEditorSectionComponent, - DatasetProfileEditorCompositeFieldComponent, - DatasetProfileEditorFieldComponent, - DatasetProfileEditorPageComponent, - DatasetProfileEditorRuleComponent, - DatasetProfileEditorAutoCompleteFieldComponent, - DatasetProfileEditorBooleanDecisionFieldComponent, - DatasetProfileEditorCheckboxFieldComponent, - DatasetProfileEditorComboBoxFieldComponent, - DatasetProfileEditorFreeTextFieldComponent, - DatasetProfileEditorRadioBoxFieldComponent, - DatasetProfileEditorTextAreaFieldComponent, - DatasetProfileEditorRichTextAreaFieldComponent, - DatasetProfileEditorUploadFieldComponent, - // DatasetProfileEditorTableFieldComponent, - DatasetProfileEditorDatePickerFieldComponent, - DatasetProfileEditorWordListFieldComponent, - DatasetProfileEditorDefaultValueComponent, - DialogConfirmationUploadDatasetProfiles, - DatasetProfileEditorInternalDmpEntitiesFieldComponent, - DatasetProfileEditorResearchersAutoCompleteFieldComponent, - DatasetProfileEditorDatasetsAutoCompleteFieldComponent, - DatasetProfileEditorDmpsAutoCompleteFieldComponent, - ParseStatus, - DatasetProfileEditorExternalDatasetsFieldComponent, - DatasetProfileEditorDataRepositoriesFieldComponent, - DatasetProfileEditorPubRepositoriesFieldComponent, - DatasetProfileEditorJournalRepositoriesFieldComponent, - DatasetProfileEditorTaxonomiesFieldComponent, - DatasetProfileEditorLicensesFieldComponent, - DatasetProfileEditorPublicationsFieldComponent, - DatasetProfileEditorRegistriesFieldComponent, - DatasetProfileEditorServicesFieldComponent, - DatasetProfileEditorTagsFieldComponent, - DatasetProfileEditorResearchersFieldComponent, - DatasetProfileEditorOrganizationsFieldComponent, - DatasetProfileEditorDatasetIdentifierFieldComponent, - DatasetProfileEditorCurrencyFieldComponent, - DatasetProfileEditorValidatorFieldComponent, - DatasetProfileTableOfContents, - DatasetProfileTableOfContentsInternalSection, - DatasetProfileEditorSectionFieldSetComponent, - FinalPreviewComponent - ] -}) -export class DatasetProfileModule { } - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts deleted file mode 100644 index 9d8f971a7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { DatasetProfileEditorComponent } from './editor/dataset-profile-editor.component'; -import { DatasetProfileListingComponent } from './listing/dataset-profile-listing.component'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; -import { AppRole } from '@app/core/common/enum/app-role'; -import { SpecialAuthGuard } from '@app/core/special-auth-guard.service'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; - -const routes: Routes = [ - { - path: 'new', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-NEW', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: ':id', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-EDIT', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'clone/:cloneid', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-CLONE', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'newversion/:newversionid', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-NEW-VERSION', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'versions/:groupId', - component: DatasetProfileListingComponent, - data: { - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard] - }, - { - path: '', - component: DatasetProfileListingComponent, - data: { - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard] - }, -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class DatasetProfileRoutingModule { } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts deleted file mode 100644 index 5b4cd484a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { animate, keyframes, state, style, transition, trigger } from "@angular/animations"; - -export const STEPPER_ANIMATIONS = [ - trigger('previous_btn',[ - transition(':enter',[ - style({'transform': 'translateX(100%)', 'z-index':'9999', 'opacity':0.4}), - animate('600ms ease-out', style({ - 'transform': 'translateX(0)', - 'opacity':1 - })) - ]), - transition(':leave',[ - style({ - 'transform': 'translateX(0)', - 'opacity':'1', - 'z-index':'9999' - }), - animate('800ms ease-out', keyframes([ - style({'transform': 'translateX(120%)', offset:0.8}), - style({'opacity': '0.2', offset:0.96}) - ])) - ]) - ]), - trigger('next_btn', [ - transition(':leave',[ - style({opacity:1, position:'absolute', 'z-index':'9999'}), - animate('700ms ease-out', keyframes( [ - style({ transform:'translateX(-100%)', offset:0.6}), - style({ opacity:'0.2', offset:0.87}) - ])) - ]), - transition(':enter',[ - style({opacity:0.3, 'z-index':'9999', transform:'translateX(-100%)'}), - animate('600ms ease-out', style({ opacity:'1', transform:'translateX(0)' })) - ]) - ]), - trigger('finalize_btn',[ - transition(':enter',[ - style({opacity:0.3}), - animate('400ms ease-in', style({opacity:1})) - ]), - transition(':leave',[ - style({opacity:1, position:'absolute'}), - animate('600ms ease-in', style({opacity:0.3})) - ]) - ]) -]; -export const GENERAL_ANIMATIONS = [ - trigger('enterIn',[ - transition(':enter',[ - style({ - transform:'scale(0)', - 'transform-origin':'50% 0', - opacity:0 - }), - animate('800ms ease', style({transform:'scale(1)', opacity:1})) - ]) - ]), - trigger('fadeElement',[ - state('updated',style({opacity:0})), - transition("*=>updated", - animate('2s 1s ease-out')) - ]), - trigger('add-new-user-field', [ - state('untriggered', style({ - transform:'translateX(120%)' - })), - state('triggered', style({ - transform:'translateX(0)' - })), - transition('untriggered => triggered', animate('400ms ease')), - transition('triggered => untriggered', animate('400ms 100ms ease')) - ]), - trigger('scroll-on-top-btn',[ - transition(":enter", [style({opacity:0, transform:'scale(0)'}), animate('400ms ease', style({'opacity':1, transform:'scale(1)'}))]), - transition(":leave", [style({opacity:1,transform:'scale(1)'}), animate('400ms ease', style({'opacity':0, transform:'scale(0)'}))]) - ]), - trigger('action-btn',[ - transition(":enter", [style({opacity:0, transform:'scale(0)'}), animate('400ms ease', style({'opacity':1, transform:'scale(1)'}))]), - transition(":leave", [style({opacity:1,transform:'scale(1)'}), animate('400ms ease', style({'opacity':0, transform:'scale(0)'}))]) - ]), - trigger('fade-in',[ - transition(":enter", [style({opacity:0}), animate('1000ms 800ms ease', style({'opacity':1}))]), - ]), - trigger('fade-in-fast',[ - transition(":enter", [style({opacity:0}), animate('800ms 100ms ease', style({'opacity':1}))]), - ]), - - -] \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html deleted file mode 100644 index ec0d23910..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html +++ /dev/null @@ -1,463 +0,0 @@ - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - -
-
-
-
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}}
- - -
-
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXTENDED-DESCRIPTION' | translate}}
- - -
-
- - - -
- -
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
- - - -
-
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}} - -
-
- - - -
- - -
-
- - - - - - - -
-
    -
  • - keyboard_arrow_up -
  • -
  • - keyboard_arrow_down -
  • -
-
-
-
-
- -
- - - -
-
- {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.PREVIEW' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.STATUS.PREVIEW-UPDATED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.STATUS.CALCULATING-PREVIEW' | translate}} - - -
-
-
- - -
-
- -
- - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.NOT-INITIALIZED' | translate}} - -
- -
-
-
-
-
- - - -
-
-
    - - - - -
  • - - - 'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.ADD-INPUT' | translate - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.ADD-INPUT' | translate}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • - - - -
  • - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.COMMENT-FIELD' | translate}} -
  • -
  • - - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.MULTIPLICITY' | translate}} - -
  • -
  • - - more_vert - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXTENDED-DESCRIPTION' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.ADDITIONAL-INFORMATION' | translate}} - -
  • -
-
-
-
- - -
- - - - - - - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss deleted file mode 100644 index 121ec9530..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss +++ /dev/null @@ -1,146 +0,0 @@ -.full-width{ - width: 100%; -} - -.deleteBtn{ - margin-right:0.7em; -} - -.titleStile{ - font-weight: bold; -} - -//REFACTOR SECTION - - -//Palete - -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; - -.actions-list{ - border-radius: 7px; - box-shadow: 0 1px 0.8em $blue-color; - padding: 1em 0em; - font-size: small; -} - -.field-container{ - box-shadow: 0px 1px 2px rgb(173, 173, 173) ; - padding: 3em; - border-radius: .3em; - // border-left: 0.3em solid yellow; - padding-bottom: 2em; - margin-bottom: 2em; - -} -.field-container-active{ - box-shadow: 0px 1px 2px rgb(173, 173, 173) ; - padding: 3em; - border-radius: .3em; - border-left: 0.3em solid $blue-color; - padding-bottom: 2em; - margin-bottom: 2em; - -} -.field-id-container{ - background-color: $blue-color-light; - position: absolute; - right: 0; - top: 0; - padding: .6em 1.2em; - overflow: visible; - .field-id-container-icon{ - position: absolute; - top: -50%; - - } -} - -.main-content-page{ - padding: 0em 1.5em; -} - -.fielset-header{ - font-size: 1.5em; - font-weight: bold; - - // .numbering{ - // padding: 0.5em 0em; - // } -} - -.fieldset-actions-list{ - margin: 0; - cursor: pointer; -} - -// ::ng-deep .main-content-page .fieldset-header .field-title .mat-form-field-infix{ -// border-top: 0px; -// } - - -.numbering-label .mat-input-element:disabled{ - color: #212121; -} - -:host ::ng-deep .fieldset-checkbox-action-dataset-profile-editor -{ - .mat-checkbox-label{ - font-size: 0.8em; - color: #212121; - transform: translateY(3px); - } - .mat-checkbox-frame{ - border: 1px solid $blue-color ; - } -} - -.fieldset-new-input-action { - font-size: 0.8em; - font-weight: 400; - color: #212121; - display: inline-block; - transform: translateY(1px); -} -.inputMenuTrigger { - margin-bottom: 0.3rem; - display: inline-block; -} - -.previewer{ - background-color: #129d9811; - padding: 2em; - border: 1px solid #70707015; - border-radius: 4px; -} - -.input_icon{ - width: 14px; - margin-right: 0.5em; - // display: flex; - // align-items: center; -} - -::ng-deep .mat-menu-panel{ - max-height: 32em; -} -:host ::ng-deep .fielset-header .mat-form-field-wrapper{ - padding-bottom: 0px; -} - -.previewer-text{ - font-weight: bold; - font-style: italic; -} - -.field-input { - position: relative; -} - -.field-input .arrows { - position: absolute; - top: 0; - left: 50%; - transform: translateX(-50%); -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts deleted file mode 100644 index 7e84e85dc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts +++ /dev/null @@ -1,1088 +0,0 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatCheckboxChange } from '@angular/material/checkbox'; -import { MatDialog } from '@angular/material/dialog'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { ValidationType } from '@app/core/common/enum/validation-type'; -import { Field, FieldSet } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { CompositeField } from '@app/core/model/dataset-profile-definition/composite-field'; -import { Field as FieldDefinition } from '@app/core/model/dataset-profile-definition/field'; -import { - AutoCompleteFieldData, - BooleanDecisionFieldData, - CheckBoxFieldData, - CurrencyFieldData, - DataRepositoriesFieldData, - DatasetIdentifierFieldData, - DatePickerFieldData, - DmpsAutoCompleteFieldData, - ExternalDatasetsFieldData, - FieldDataOption, - FreeTextFieldData, - LicensesFieldData, - OrganizationsFieldData, - PublicationsFieldData, - RadioBoxFieldData, - RegistriesFieldData, - ResearchersAutoCompleteFieldData, - RichTextAreaFieldData, - ServicesFieldData, - TagsFieldData, - TaxonomiesFieldData, - TextAreaFieldData, - UploadFieldData, - ValidationFieldData, - WordListFieldData -} from '@app/core/model/dataset-profile-definition/field-data/field-data'; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { - DatasetDescriptionCompositeFieldEditorModel, - DatasetDescriptionFieldEditorModel, - DatasetDescriptionSectionEditorModel -} from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { TransitionGroupComponent } from "@app/ui/transition-group/transition-group.component"; -import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import { Subject } from 'rxjs'; -import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators'; -import { FieldEditorModel } from '../../../admin/field-editor-model'; -import { RuleEditorModel } from '../../../admin/rule-editor-model'; -import { GENERAL_ANIMATIONS } from '../../animations/animations'; -import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators'; -import { ViewStyleType } from '../field/view-style-enum'; - -@Component({ - selector: 'app-dataset-profile-editor-composite-field-component', - templateUrl: './dataset-profile-editor-composite-field.component.html', - styleUrls: ['./dataset-profile-editor-composite-field.component.scss'], - animations: [GENERAL_ANIMATIONS] -}) -export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent implements OnInit, OnChanges { - - @Input() form: UntypedFormGroup; - @Input() indexPath: string; - @Input() viewOnly: boolean; - - @Input() datasetProfileId?: string; - - @Input() numbering: string; - @Input() hasFocus: boolean = false; - @ViewChild("inputs") inputs: TransitionGroupComponent; - - showPreview: boolean = true; - previewDirty: boolean = false; - - - showDescription: boolean = true; - showAdditionalInfo: boolean = false; - showExtendedDescription: boolean = false; - - previewForm: UntypedFormGroup = null; - // isComposite = false; - // isMultiplicityEnabled = false; - viewStyleEnum = DatasetProfileFieldViewStyle; - - viewTypeEnum = ViewStyleType; - - private myCustomValidators: EditorCustomValidators = new EditorCustomValidators(); - - isMultiplicityEnabled = false; - constructor( - private dialog: MatDialog, - private language: TranslateService, - public enumUtils: EnumUtils, - public datasetProfileService: DatasetProfileService, - private configurationService: ConfigurationService - ) { - super(); - } - - ngOnChanges(changes: SimpleChanges) { - // this.setTargetField(null); - // this.showExtendedDescription = !!this.form.get('extendedDescription').value; - // this.showAdditionalInfo = !!this.form.get('additionalInformation').value; - // console.log(this.form.get('fields')['controls']) - if (changes['form']) { - - try { - const multiplicity = this.form.get('multiplicity').value; - this.isMultiplicityEnabled = multiplicity.min > 0 || multiplicity.max > 0; - } catch { - this.isMultiplicityEnabled = false; - } - } - - } - - get firstField() { - try { - return (this.form.get('fields') as UntypedFormArray).at(0); - } catch { - return null; - } - } - - - - - ngOnInit() { - //this.addNewField(); - // if (this.form.get('multiplicity')) { - // if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) { - // this.isMultiplicityEnabled = true; - // } - // } - // this.isComposite = (this.form.get('fields') as FormArray).length > 1; - - if (this.viewOnly) { - this.form.get('hasCommentField').disable(); - } - - //SET UP TARGET FIELD - // if((this.form.get('fields') as FormArray).length>0){ - // //get the first field in list - // this.targetField = (this.form.get('fields') as FormArray).at(0) as FormGroup; - // } - - this.showExtendedDescription = !!this.form.get('extendedDescription').value; - this.showAdditionalInfo = !!this.form.get('additionalInformation').value; - - this.form.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(changes => { - // this.previewForm = null; - this.previewDirty = true; - this.generatePreviewForm(); - - }); - this.previewSubject$ - .pipe(debounceTime(600)) - .pipe( - takeUntil(this._destroyed), - map(model => model.buildForm()), - map(updatedForm => { - const previewContainer = document.getElementById('preview_container' + this.form.get('id').value); - // let clientHeight = -1; - if (previewContainer) { - // console.log(previewContainer); - const clientHeight = previewContainer.clientHeight; - // console.log(clientHeight); - - if (clientHeight) { - previewContainer.style.height = clientHeight.toString() + 'px'; - - // console.log('height:' ,previewContainer.style.height); - } - } - this.showPreview = false; - this.previewDirty = true; - this.previewForm = updatedForm; - return previewContainer; - }), - delay(100), - tap(previewContainer => { - this.showPreview = true; - this.previewDirty = false; - }), - delay(100) - ) - .subscribe(previewContainer => { - - if (previewContainer) { - previewContainer.style.height = 'auto'; - } - - // const updatedForm = model.buildForm(); - // this.reloadPreview(updatedForm) - }); - - - this.generatePreviewForm(); - } - - - get updatedClass() { - if (this.previewDirty) return ''; - else return 'updated'; - } - private reloadPreview(updatedForm: UntypedFormGroup) { - setTimeout(() => { - - const previewContainer = document.getElementById('preview_container' + this.form.get('id').value); - // let clientHeight = -1; - if (previewContainer) { - // console.log(previewContainer); - const clientHeight = previewContainer.clientHeight; - // console.log(clientHeight); - - if (clientHeight) { - previewContainer.style.height = clientHeight.toString() + 'px'; - - // console.log('height:' ,previewContainer.style.height); - } - } - this.showPreview = false; - this.previewDirty = true; - this.previewForm = updatedForm; - - setTimeout(() => { - - - this.showPreview = true; - this.previewDirty = false; - - if (previewContainer) { - setTimeout(() => { - if (previewContainer) { - previewContainer.style.height = 'auto'; - } - }); - } - }); - }); - } - - previewSubject$: Subject = new Subject(); - - private generatePreviewForm() { - const formValue: FieldSet = this.form.getRawValue(); - const fields: FieldDefinition[] = formValue.fields.map(editorField => this._fieldToFieldDefinition(editorField)); - - - const compositeField: CompositeField = { - id: formValue.id, - additionalInformation: formValue.additionalInformation, - extendedDescription: formValue.extendedDescription, - numbering: '', - title: formValue.title, - ordinal: formValue.ordinal, - description: formValue.description, - hasCommentField: formValue.hasCommentField, - commentFieldValue: '', - multiplicity: { - max: formValue.multiplicity.max, min: formValue.multiplicity.min, - placeholder: formValue.multiplicity.placeholder, tableView: formValue.multiplicity.tableView - }, - multiplicityItems: null, - fields: fields.map(editorField => { - const model = new DatasetDescriptionFieldEditorModel().fromModel(editorField); - if (model.viewStyle.renderStyle === this.viewStyleEnum.CheckBox) { - model.value = model.value ? "true" : "false";//patch - } - return model; - }) - } - - - const section = new DatasetDescriptionSectionEditorModel(); - section.title = ''; - section.numbering = ''; - - const compositeForm = new DatasetDescriptionCompositeFieldEditorModel().fromModel(compositeField) - section.compositeFields = [compositeForm]; - - this.previewSubject$.next(section); - } - - - private _fieldToFieldDefinition(editorField: Field): FieldDefinition { - const field = { - id: editorField.id, - title: '', - page: editorField.page, - numbering: '', - multiplicity: null, - multiplicityItems: null, - viewStyle: editorField.viewStyle, - defaultValue: editorField.defaultValue, - value: null, - validations: editorField.validations, - } as FieldDefinition; - - field.data = editorField.data; - - // return new DatasetDescriptionFieldEditorModel().fromModel(field); - return field; - } - - - // generatePreview(){ - // const editorModel = new DatasetDescriptionCompositeFieldEditorModel(); - // editorModel.title = this.form.get('title').value; - // editorModel.description = this.form.get('description').value; - // editorModel.extendedDescription = this.form.get('extendedDescription').value; - // editorModel.additionalInformation = this.form.get('additionalInformation').value; - // editorModel.hasCommentField = this.form.get('hasCommentField').value; - // editorModel.fields = []; - - // (this.form.get('fields') as FormArray).controls.forEach(field=>{ - // const fieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // fieldEditorModel.viewStyle= { - // renderStyle: field.get('viewStyle').get('renderStyle').value, - // cssClass: null - // }; - // fieldEditorModel.defaultValue = field.get('defaultValue').value; - // switch (field.get('viewStyle').get('renderStyle').value) { - // case DatasetProfileFieldViewStyle.TextArea: - // fieldEditorModel.data = { - // label: field.get('data').get('label').value - // }; - // break; - - // default: - // break; - // } - - - // editorModel.fields.push(fieldEditorModel); - // }); - - - // this.previewForm = editorModel.buildForm(); - // } - - onIsCompositeChange(isComposite: boolean) { - if (!isComposite && (this.form.get('fields')).length > 1) { - for (let i = 0; i < (this.form.get('fields')).length - 1; i++) { - (this.form.get('fields')).removeAt(1); - } - (this.form.get('fields') as UntypedFormArray).controls.splice(1); - } - if ((this.form.get('fields')).length === 0) { - const field: FieldEditorModel = new FieldEditorModel(); - (this.form.get('fields')).push(field.buildForm()); - } - } - - onIsMultiplicityEnabledChange(isMultiplicityEnabled: MatCheckboxChange) { - const multiplicity = this.form.get('multiplicity') as UntypedFormGroup; - - const minControl = multiplicity.get('min'); - const maxControl = multiplicity.get('max'); - const placeholder = multiplicity.get('placeholder'); - const tableView = multiplicity.get('tableView'); - - if (isMultiplicityEnabled.checked) { - minControl.setValue(0); - maxControl.setValue(1); - placeholder.setValue(''); - tableView.setValue(false); - } else { - minControl.setValue(0); - maxControl.setValue(0); - placeholder.setValue(null); - tableView.setValue(null); - } - - this.isMultiplicityEnabled = isMultiplicityEnabled.checked; - minControl.updateValueAndValidity(); - maxControl.updateValueAndValidity(); - - } - - addNewField() { - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - - field.ordinal = (this.form.get('fields') as UntypedFormArray).length; - - const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); - - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - - (this.form.get('fields')).push(fieldForm); - - this.setTargetField(fieldForm); - fieldForm.updateValueAndValidity(); - } - - DeleteField(index) { - - const fieldsForm = this.form.get('fields'); - fieldsForm.removeAt(index); - this.inputs.init(); - // calculate ordinals - fieldsForm.controls.forEach((field, idx) => { - field.get('ordinal').setValue(idx); - field.updateValueAndValidity(); - }); - this.form.markAsDirty();//deactivate guard - } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } - - - targetField: UntypedFormGroup; - validationTypeEnum = ValidationType; - - - addVisibilityRule(targetField: UntypedFormGroup) { - const rule: RuleEditorModel = new RuleEditorModel(); - (targetField.get('visible').get('rules')).push(rule.buildForm()); - } - toggleRequired(targetField: UntypedFormGroup, event: MatCheckboxChange) { - - let validationsControl = targetField.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - - if (event.checked) { - if (!validations.includes(ValidationType.Required)) {//IS ALREADY REQUIRED - // validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required)); - // validationsControl.updateValueAndValidity(); - validations.push(ValidationType.Required); - // validationsControl.setValue(validations); - validationsControl.updateValueAndValidity(); - } - } else { - validationsControl.setValue(validations.filter(validator => validator != ValidationType.Required)); - validationsControl.updateValueAndValidity(); - } - - - // if(validations.includes(ValidationType.Required)){//IS ALREADY REQUIRED - // validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required)); - // validationsControl.updateValueAndValidity(); - // }else{ - // //SET REQUIRED VALIDATOR - // console.log('setting required validator'); - // validations.push(ValidationType.Required); - // validationsControl.setValue(validations); - // validationsControl.updateValueAndValidity(); - // } - } - setTargetField(field: AbstractControl) { - this.targetField = field; - } - - - deleteTargetField() { - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - this._deleteTargetField(); - } - }); - - } - - - private _deleteTargetField() { - if (!this.targetField) return; - - let index = -1; - - const fields = this.form.get('fields') as UntypedFormArray; - - for (let i = 0; i < fields.length; i++) { - let field = fields.at(i); - if (field.get('id').value === this.targetField.get('id').value) {//index found - index = i; - break; - } - } - - if (index >= 0) {//target found in fields - this.DeleteField(index); - this.targetField = null; - } - - } - - deleteField(index: number) { - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - this.DeleteField(index); - } - }); - - } - - - - - addNewInput(type: ViewStyleType) { - - const fieldsArray = this.form.get('fields') as UntypedFormArray; - - let targetOrdinal = fieldsArray.length; - try { - targetOrdinal = fieldsArray.controls.map(control => control.get('ordinal').value).reduce((a, b) => Math.max(a, b)) + 1; - } catch { - - } - - - - const field = { - id: Guid.create().toString(), - ordinal: targetOrdinal, - visible: { rules: [], style: null }, - validations: [], - viewStyle: {}, - export: true - - } as Field; - - - // const field: FieldEditorModel = new FieldEditorModel(); - // field.id=Guid.create().toString(); - - // field.ordinal = (this.form.get('fields') as FormArray).length; - - // const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - - - - // if (fieldForm.get('data')) { - // fieldForm.removeControl('data'); - // } - - switch (type) { - case this.viewTypeEnum.BooleanDecision: { - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.BooleanDecision) - // fieldForm.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm()); - - const data: BooleanDecisionFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.BooleanDecision; - field.data = data; - - break; - } - case this.viewTypeEnum.CheckBox: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.CheckBox) - // fieldForm.addControl('data', new CheckBoxFieldDataEditorModel().buildForm()); - const data: CheckBoxFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.CheckBox; - field.data = data; - - break; - } - case this.viewTypeEnum.Select: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // fieldForm.addControl('data', new WordListFieldDataEditorModel().buildForm()); - - // fieldForm.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // fieldForm.get('data').updateValueAndValidity(); - - const firstOption = { label: '', value: '' } as FieldDataOption; - - const data: WordListFieldData = { - label: '', - multiList: false, - options: [firstOption], - type: DatasetProfileComboBoxType.WordList - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } - case this.viewTypeEnum.Other: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // fieldForm.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE - - // fieldForm.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - // fieldForm.get('data').updateValueAndValidity(); - - const data: AutoCompleteFieldData = { - autoCompleteSingleDataList: [], - multiAutoComplete: false, - label: '', - type: DatasetProfileComboBoxType.Autocomplete - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } case this.viewTypeEnum.InternalDmpEntities: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.InternalDmpEntities) - // fieldForm.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());//TODO TO SEE - - const data: DmpsAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Dmps - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities; - field.data = data; - - break; - } - case this.viewTypeEnum.FreeText: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.FreeText) - // fieldForm.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); - - const data: FreeTextFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.FreeText; - field.data = data; - break; - } - case this.viewTypeEnum.RadioBox: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox) - // fieldForm.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - // fieldForm.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // fieldForm.get('data').updateValueAndValidity(); - const data: RadioBoxFieldData = { - label: '', - options: [] - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RadioBox; - field.data = data; - - break; - } - case this.viewTypeEnum.TextArea: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // fieldForm.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: TextAreaFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.TextArea; - field.data = data; - - break; - } - case this.viewTypeEnum.RichTextArea: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // fieldForm.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: RichTextAreaFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RichTextArea; - field.data = data; - - break; - } - case this.viewTypeEnum.Upload: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // fieldForm.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: UploadFieldData = { - label: '', - types: [], - maxFileSizeInMB: this.configurationService.maxFileSizeInMB - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Upload; - field.data = data; - - break; - } - case this.viewTypeEnum.DatePicker: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatePicker) - // fieldForm.addControl('data', new DatePickerDataEditorModel().buildForm()); - const data: DatePickerFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatePicker; - - break; - } - case this.viewTypeEnum.ExternalDatasets: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ExternalDatasets) - // fieldForm.addControl('data', new ExternalDatasetsDataEditorModel().buildForm()); - const data: ExternalDatasetsFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ExternalDatasets; - field.data = data; - break; - } - case this.viewTypeEnum.DataRepositories: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DataRepositories) - // fieldForm.addControl('data', new DataRepositoriesDataEditorModel().buildForm()); - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.PubRepositories: { - - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.JournalRepositories: { - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.Taxonomies: { - - const data: TaxonomiesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Taxonomies; - field.data = data; - - break; - } - case this.viewTypeEnum.Licenses: { - - const data: LicensesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Licenses; - field.data = data; - - break; - } - case this.viewTypeEnum.Publications: { - - const data: PublicationsFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Publications; - field.data = data; - - break; - } - case this.viewTypeEnum.Registries: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Registries) - // fieldForm.addControl('data', new RegistriesDataEditorModel().buildForm()); - - const data: RegistriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Registries; - field.data = data; - - break; - } - case this.viewTypeEnum.Services: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Services) - // fieldForm.addControl('data', new ServicesDataEditorModel().buildForm()); - - const data: ServicesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Services; - field.data = data; - - break; - } - case this.viewTypeEnum.Tags: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Tags) - // fieldForm.addControl('data', new TagsDataEditorModel().buildForm()); - - const data: TagsFieldData = { - label: '' - } - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Tags; - field.data = data; - - break; - } - case this.viewTypeEnum.Researchers: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Researchers) - // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); //TODO TO ASK - // fieldForm.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - - const data: ResearchersAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Researchers - } - - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities; - // field.data = {label:''} - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - field.data = data; - - - - - break; - } - case this.viewTypeEnum.Organizations: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Organizations) - // fieldForm.addControl('data', new OrganizationsDataEditorModel().buildForm()); - // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()) - // fieldForm.addControl('data', new DatasetsAutoCompleteFieldDataEditorModel().buildForm()); //TODO - - const data = { - autoCompleteSingleDataList: [], - label: '', - multiAutoComplete: false, - - } as OrganizationsFieldData; //TODO - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Organizations; - field.data = data; - - break; - } - case this.viewTypeEnum.DatasetIdentifier: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatasetIdentifier) - // fieldForm.addControl('data', new DatasetIdentifierDataEditorModel().buildForm()); - - const data: DatasetIdentifierFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatasetIdentifier; - field.data = data; - - break; - } - case this.viewTypeEnum.Currency: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Currency) - // fieldForm.addControl('data', new CurrencyDataEditorModel().buildForm()); - - const data: CurrencyFieldData = { - label: '' - } - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Currency; - field.data = data; - - break; - } - case this.viewTypeEnum.Validation: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Validation) - // fieldForm.addControl('data', new ValidationDataEditorModel().buildForm()); - - const data: ValidationFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Validation; - field.data = data; - - break; - } - } - - (this.form.get('fields')).push(new FieldEditorModel().fromModel(field).buildForm()); - this.inputs.init(); - // fieldForm.get('viewStyle').get('renderStyle').updateValueAndValidity(); - // fieldForm.get('data').updateValueAndValidity(); - - - } - - // private customFieldValidator(): ValidatorFn{ - // return (control):ValidationErrors | null=>{ - // DatasetProfileFieldViewStyle - // switch(control.get('viewStyle').get('renderStyle').value){ - - // case DatasetProfileFieldViewStyle.TextArea: - // return null; - // case DatasetProfileFieldViewStyle.BooleanDecision: - // return null; - // case DatasetProfileFieldViewStyle.ComboBox: - // return null; - // case DatasetProfileFieldViewStyle.CheckBox: - // return null; - // case DatasetProfileFieldViewStyle.FreeText: - // return null; - // case DatasetProfileFieldViewStyle.RadioBox: - // return null; - // case DatasetProfileFieldViewStyle.DatePicker: - // return null; - // case DatasetProfileFieldViewStyle.InternalDmpEntities: - // return null; - // case DatasetProfileFieldViewStyle.ExternalDatasets: - // return null; - // case DatasetProfileFieldViewStyle.DataRepositories: - // return null; - // case DatasetProfileFieldViewStyle.Registries: - // return null; - // case DatasetProfileFieldViewStyle.Services: - // return null; - // case DatasetProfileFieldViewStyle.Tags: - // return null; - // case DatasetProfileFieldViewStyle.Researchers: - // return null; - // case DatasetProfileFieldViewStyle.Organizations: - // return null; - // case DatasetProfileFieldViewStyle.DatasetIdentifier: - // return null; - // case DatasetProfileFieldViewStyle.Currency: - // return null; - // case DatasetProfileFieldViewStyle.Validation: - // return null; - // default: - // return {inputTypeNotValid: true} - // } - // } - // } - - - // private _atLeastOneElementListValidator(arrayToCheck): ValidatorFn{ - // return (control: AbstractControl): ValidationErrors | null=>{ - - // const fa = control.get(arrayToCheck) as FormArray; - - // if(fa.length === 0){ - // return {emptyArray: true}; - // } - // return null; - // } - // } - - - calculateLabelWidth(numbering: string) { - - const width = numbering.split('.').reduce((acc, item) => item + acc, '').length; - - - return { 'width': width + 'em' } - } - - get fieldsArray(): UntypedFormArray { - if (this.form && this.form.get('fields')) { - return this.form.get('fields') as UntypedFormArray; - } - return null; - } - - move(index, direction: "up" | "down" = "up") { - this.inputs.init(); - if (direction === "up" && this.canGoUp(index)) { - let temp = this.fieldsArray.at(index); - this.fieldsArray.removeAt(index); - this.fieldsArray.insert(index - 1, temp); - } else if (direction === "down" && this.canGoDown(index)) { - let temp = this.fieldsArray.at(index + 1); - this.fieldsArray.removeAt(index + 1); - this.fieldsArray.insert(index, temp); - } - this.fieldsArray.controls.forEach((field, index) => { - field.get('ordinal').setValue(index); - }); - } - - canGoUp(index: number): boolean { - return index > 0 && !this.viewOnly; - } - - canGoDown(index: number): boolean { - return index < (this.fieldsArray.length - 1) && !this.viewOnly; - } -} - - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html deleted file mode 100644 index 4a6fa65ec..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html +++ /dev/null @@ -1,97 +0,0 @@ -
- - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | - translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' - | - translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO' - | - translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }} - {{opt.get('label').value}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - - - {{placeHolder}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}} - {{opt.get('label').value}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{placeHolder}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss deleted file mode 100644 index 946679a44..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width{ - width: 100%; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts deleted file mode 100644 index e1b13e149..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormControl } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type'; - -@Component({ - selector: 'app-component-profile-editor-default-value-component', - templateUrl: './component-profile-editor-default-value.component.html', - styleUrls: ['./component-profile-editor-default-value.component.scss'] -}) -export class DatasetProfileEditorDefaultValueComponent implements OnInit { - - @Input() viewStyle: DatasetProfileFieldViewStyle; - @Input() form: UntypedFormControl; - @Input() formArrayOptions: UntypedFormArray; - @Input() comboBoxType: DatasetProfileComboBoxType; - @Input() internalDmpEntitiesType: DatasetProfileInternalDmpEntitiesType; - @Input() placeHolder: String; - // @Input() required: Boolean; - - comboBoxTypeEnum = DatasetProfileComboBoxType; - internalDmpEntitiesTypeEnum = DatasetProfileInternalDmpEntitiesType; - viewStyleEnum = DatasetProfileFieldViewStyle; - - constructor() { } - - ngOnInit() { - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html deleted file mode 100644 index e00d41f20..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html +++ /dev/null @@ -1,112 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-PLACEHOLDER' | translate}} - - - - -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-SOURCE-TITLE' | translate}}
-
- - - -
- warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-OTHER-SOURCES-REQUIRED'| translate}} -
- -
-
- -
- - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-METHOD' | translate}} - - {{method.value}} - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-LABEL' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-VALUE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-SOURCE' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-HAS-AUTH' | translate}} -
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-METHOD' | translate}} - - {{method.value}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-TYPE' | translate}} - - {{type.value}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-BODY' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- - -
- diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts deleted file mode 100644 index 378fb9aad..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup, UntypedFormArray, AbstractControl } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { AutoCompleteFieldDataEditorModel } from '../../../../admin/field-data/auto-complete-field-data-editor-model'; -import { AutoCompleteSingleDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data'; -// import { HtmlMethod } from '@app/core/model/dataset-profile-definition/html-method.enum'; -// import { AuthType } from '@app/core/model/dataset-profile-definition/auth-type.enum'; - -@Component({ - selector: 'app-dataset-profile-editor-auto-complete-field-component', - styleUrls: ['./dataset-profile-editor-auto-complete-field.component.scss'], - templateUrl: './dataset-profile-editor-auto-complete-field.component.html' -}) -export class DatasetProfileEditorAutoCompleteFieldComponent implements OnInit { - - // public htmlMethods = HtmlMethod; - // public authTypes = AuthType; - - @Input() form: UntypedFormGroup; - private data: AutoCompleteFieldDataEditorModel = new AutoCompleteFieldDataEditorModel(); - multiForm: UntypedFormArray; - - ngOnInit() { - this.multiForm = (this.form.get('data').get('autoCompleteSingleDataList')); - this.data.type = DatasetProfileComboBoxType.Autocomplete; - } - - addSource() { - (this.multiForm).push(new AutoCompleteSingleDataEditorModel().buildForm()); - } - - removeSource(index: number) { - (this.multiForm).removeAt(index); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html deleted file mode 100644 index e1f96a2e1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts deleted file mode 100644 index cb7f31d47..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ - -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { BooleanDecisionFieldDataEditorModel } from '../../../../admin/field-data/boolean-decision-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-boolean-decision-field-component', - styleUrls: ['./dataset-profile-editor-boolean-decision-field.component.scss'], - templateUrl: './dataset-profile-editor-boolean-decision-field.component.html' -}) -export class DatasetProfileEditorBooleanDecisionFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: BooleanDecisionFieldDataEditorModel = new BooleanDecisionFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html deleted file mode 100644 index 56ae77ff2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-TITLE' | translate}}
- - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts deleted file mode 100644 index 8d0e6c756..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { CheckBoxFieldDataEditorModel } from '../../../../admin/field-data/check-box-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-checkbox-field-component', - styleUrls: ['./dataset-profile-editor-checkbox-field.component.scss'], - templateUrl: './dataset-profile-editor-checkbox-field.component.html' -}) -export class DatasetProfileEditorCheckboxFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: CheckBoxFieldDataEditorModel = new CheckBoxFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html deleted file mode 100644 index 9f4e545ab..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts deleted file mode 100644 index 9fc577234..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { AutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model'; -import { WordListFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-editor-combo-box-field-component', - styleUrls: ['./dataset-profile-editor-combo-box-field.component.scss'], - templateUrl: './dataset-profile-editor-combo-box-field.component.html' -}) -export class DatasetProfileEditorComboBoxFieldComponent extends BaseComponent implements OnInit { - - @Input() form: UntypedFormGroup; - options = DatasetProfileComboBoxType; - - constructor( - public enumUtils: EnumUtils - ) { super(); } - - ngOnInit() { - // this.setupListeners(); - } - - setupListeners() { - this.form.get('data').get('type').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (this.form.get('data')) { this.form.removeControl('data'); } - if (x === DatasetProfileComboBoxType.Autocomplete) { - this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); - } else if (x === DatasetProfileComboBoxType.WordList) { - this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - } - this.setupListeners(); - }); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html deleted file mode 100644 index da6e65ae7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CURRENCY-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CURRENCY-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts deleted file mode 100644 index 474ffa93f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-currency-field-component', - styleUrls: ['./dataset-profile-editor-currency-field.component.scss'], - templateUrl: './dataset-profile-editor-currency-field.component.html' -}) -export class DatasetProfileEditorCurrencyFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html deleted file mode 100644 index 641c26ce1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATA-REPOSITORIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATA-REPOSITORIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts deleted file mode 100644 index 5bf8fd251..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-data-repositories-field-component', - styleUrls: ['./dataset-profile-editor-data-repositories-field.component.scss'], - templateUrl: './dataset-profile-editor-data-repositories-field.component.html' -}) -export class DatasetProfileEditorDataRepositoriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html deleted file mode 100644 index 263601838..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASET-IDENTIFIER-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASET-IDENTIFIER-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts deleted file mode 100644 index d9ecf05e1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { Router } from '@angular/router'; -import { DatasetIdentifierDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-dataset-identifier-field-component', - styleUrls: ['./dataset-profile-editor-dataset-identifier-field.component.scss'], - templateUrl: './dataset-profile-editor-dataset-identifier-field.component.html' -}) -export class DatasetProfileEditorDatasetIdentifierFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DatasetIdentifierDataEditorModel = new DatasetIdentifierDataEditorModel(); - - constructor(private router: Router) {} - - ngOnInit() { - if(this.router.url.includes('new')){ - this.form.patchValue({'rdaCommonStandard': 'dataset.dataset_id'}); - } - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html deleted file mode 100644 index e7c6d01dc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASETS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts deleted file mode 100644 index ec9c22260..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { OnInit, Input, Component } from "@angular/core"; -import { UntypedFormGroup } from "@angular/forms"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { DatasetsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/datasets-autocomplete-field-data-editor-mode"; - -@Component({ - selector: 'app-dataset-profile-editor-datasets-autocomplete-field-component', - styleUrls: ['./dataset-profile-editor-datasets-autocomplete-field.component.scss'], - templateUrl: './dataset-profile-editor-datasets-autocomplete-field.component.html' -}) -export class DatasetProfileEditorDatasetsAutoCompleteFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DatasetsAutoCompleteFieldDataEditorModel = new DatasetsAutoCompleteFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileInternalDmpEntitiesType.Datasets; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html deleted file mode 100644 index bf505dbea..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATE-PICKER-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts deleted file mode 100644 index a0d6bbb3b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-date-picker-field-component', - styleUrls: ['./dataset-profile-editor-date-picker-field.component.scss'], - templateUrl: './dataset-profile-editor-date-picker-field.component.html' -}) -export class DatasetProfileEditorDatePickerFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DatePickerDataEditorModel = new DatePickerDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html deleted file mode 100644 index 2109b436b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DMPS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts deleted file mode 100644 index a7ec9d4fb..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { OnInit, Input, Component } from "@angular/core"; -import { UntypedFormGroup } from "@angular/forms"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { DatasetsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/datasets-autocomplete-field-data-editor-mode"; -import { DmpsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/dmps-autocomplete-field-data-editor-model"; - -@Component({ - selector: 'app-dataset-profile-editor-dmps-autocomplete-field-component', - styleUrls: ['./dataset-profile-editor-dmps-autocomplete-field.component.scss'], - templateUrl: './dataset-profile-editor-dmps-autocomplete-field.component.html' -}) -export class DatasetProfileEditorDmpsAutoCompleteFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DmpsAutoCompleteFieldDataEditorModel = new DatasetsAutoCompleteFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileInternalDmpEntitiesType.Dmps; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html deleted file mode 100644 index d8e932f46..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html +++ /dev/null @@ -1,22 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-EXTERNAL-DATASETS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-EXTERNAL-DATASETS-PLACEHOLDER' | translate}} - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPE-NAME' | translate}} - - - {{type.label | translate}} - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts deleted file mode 100644 index dbd2e951e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { ExternalDatasetTypeEnum } from '@app/core/common/enum/external-dataset-type-enum'; - -@Component({ - selector: 'app-dataset-profile-editor-external-datasets-field-component', - styleUrls: ['./dataset-profile-editor-external-datasets-field.component.scss'], - templateUrl: './dataset-profile-editor-external-datasets-field.component.html' -}) -export class DatasetProfileEditorExternalDatasetsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ExternalDatasetsDataEditorModel = new ExternalDatasetsDataEditorModel(); - - externalDatasetTypes = [ - ... Object.keys(ExternalDatasetTypeEnum).map(key=>{ - return { - label: this.parseExtrernalDatasetTypeKey(key), - value: ExternalDatasetTypeEnum[key] - }; - }) - ]; - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } - - parseExtrernalDatasetTypeKey(key: string): string{ - if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ProducedDataset){ - return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.PRODUCED'; - } - if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ReusedDataset){ - return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.REUSED'; - } - if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.Other){ - return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.OTHER'; - } - return key; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html deleted file mode 100644 index cc1248c46..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
- -
- {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-FREE-TEXT-TITLE' | translate}}
- - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-FREE-TEXT-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts deleted file mode 100644 index b0471954e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { FreeTextFieldDataEditorModel } from '../../../../admin/field-data/free-text-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-free-text-field-component', - styleUrls: ['./dataset-profile-editor-free-text-field.component.scss'], - templateUrl: './dataset-profile-editor-free-text-field.component.html' -}) -export class DatasetProfileEditorFreeTextFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: FreeTextFieldDataEditorModel = new FreeTextFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html deleted file mode 100644 index 26d4cff98..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
- - - {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Researchers)}} - {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Datasets)}} - {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Dmps)}} - - - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts deleted file mode 100644 index 63c74dd1e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { DatasetsAutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode'; -import { DmpsAutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model'; -import { ResearchersAutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-internal-dmp-entities-field-component', - styleUrls: ['./dataset-profile-editor-internal-dmp-entities-field.component.scss'], - templateUrl: './dataset-profile-editor-internal-dmp-entities-field.component.html' -}) -export class DatasetProfileEditorInternalDmpEntitiesFieldComponent extends BaseComponent implements OnInit { - @Input() form: UntypedFormGroup; - options = DatasetProfileInternalDmpEntitiesType; - - constructor( - public enumUtils: EnumUtils - ) { super() } - - ngOnInit() { - this.setupListeners(); - } - - setupListeners() { - this.form.get('data').get('type').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (this.form.get('data')) { this.form.removeControl('data'); } - if (x === DatasetProfileInternalDmpEntitiesType.Researchers) { - this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - } else if (x === DatasetProfileInternalDmpEntitiesType.Datasets) { - this.form.addControl('data', new DatasetsAutoCompleteFieldDataEditorModel().buildForm()); - } - else if (x === DatasetProfileInternalDmpEntitiesType.Dmps) { - this.form.addControl('data', new DmpsAutoCompleteFieldDataEditorModel().buildForm()); - } - this.setupListeners(); - }) - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html deleted file mode 100644 index c7be19408..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-JOURNALS-REPOSITORIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-JOURNALS-REPOSITORIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts deleted file mode 100644 index 272b4f55b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { FormControl } from '@angular/forms'; - -@Component({ - selector: 'app-dataset-profile-editor-journal-repositories-field-component', - styleUrls: ['./dataset-profile-editor-journal-repositories-field.component.scss'], - templateUrl: './dataset-profile-editor-journal-repositories-field.component.html' -}) -export class DatasetProfileEditorJournalRepositoriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html deleted file mode 100644 index a133a33da..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-LICENSES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-LICENSES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts deleted file mode 100644 index aac88601b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormGroup} from '@angular/forms'; -import {LicensesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models"; - -@Component({ - selector: 'app-dataset-profile-editor-licenses-field-component', - styleUrls: ['./dataset-profile-editor-licenses-field.component.scss'], - templateUrl: './dataset-profile-editor-licenses-field.component.html' -}) -export class DatasetProfileEditorLicensesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: LicensesDataEditorModel = new LicensesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html deleted file mode 100644 index 303388518..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-ORGANIZATIONS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-ORGANIZATIONS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts deleted file mode 100644 index 8dfb885ae..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; -import { TagsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models'; -import { ResearchersDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models'; -import { OrganizationsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-organizations-field-component', - styleUrls: ['./dataset-profile-editor-organizations-field.component.scss'], - templateUrl: './dataset-profile-editor-organizations-field.component.html' -}) -export class DatasetProfileEditorOrganizationsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: OrganizationsDataEditorModel = new OrganizationsDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html deleted file mode 100644 index d0e981adc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUB-REPOSITORIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUB-REPOSITORIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts deleted file mode 100644 index f4940251e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-pub-repositories-field-component', - styleUrls: ['./dataset-profile-editor-pub-repositories-field.component.scss'], - templateUrl: './dataset-profile-editor-pub-repositories-field.component.html' -}) -export class DatasetProfileEditorPubRepositoriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html deleted file mode 100644 index 3421efdb5..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUBLICATIONS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUBLICATIONS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts deleted file mode 100644 index 56dc16378..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormGroup} from '@angular/forms'; -import {PublicationsDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models"; - -@Component({ - selector: 'app-dataset-profile-editor-publications-field-component', - styleUrls: ['./dataset-profile-editor-publications-field.component.scss'], - templateUrl: './dataset-profile-editor-publications-field.component.html' -}) -export class DatasetProfileEditorPublicationsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: PublicationsDataEditorModel = new PublicationsDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html deleted file mode 100644 index 944b3e3a9..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html +++ /dev/null @@ -1,41 +0,0 @@ -
-
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE' - | translate}}
- - warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}} - -
- - - -
-
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}} - - - -
-
-
- - -
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss deleted file mode 100644 index 8bec9923c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss +++ /dev/null @@ -1,4 +0,0 @@ -.full-width { - width: 100%; -} - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts deleted file mode 100644 index 6c2d2ce36..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { FieldDataOptionEditorModel } from '../../../../admin/field-data/field-data-option-editor-model'; -import { RadioBoxFieldDataEditorModel } from '../../../../admin/field-data/radio-box-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-radio-box-field-component', - styleUrls: ['./dataset-profile-editor-radio-box-field.component.scss'], - templateUrl: './dataset-profile-editor-radio-box-field.component.html' -}) -export class DatasetProfileEditorRadioBoxFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: RadioBoxFieldDataEditorModel = new RadioBoxFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } - - addNewRow() { - const radioListOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - if (!this.form.get('data').get('options')) { (this.form.get('data')).addControl('options', new UntypedFormBuilder().array([])); } - (this.form.get('data').get('options')).push(radioListOptions.buildForm()); - } - - deleteRow(intex: number) { - if (this.form.get('data').get('options')) { (this.form.get('data').get('options')).removeAt(intex); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html deleted file mode 100644 index 7aad9fc38..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-REGISTRIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-REGISTRIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts deleted file mode 100644 index c6f4a3955..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-registries-field-component', - styleUrls: ['./dataset-profile-editor-registries-field.component.scss'], - templateUrl: './dataset-profile-editor-registries-field.component.html' -}) -export class DatasetProfileEditorRegistriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: RegistriesDataEditorModel = new RegistriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html deleted file mode 100644 index 94260ad5a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts deleted file mode 100644 index 723f776d4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ResearchersAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/researchers-auto-complete-field-data-editor-model"; -import { UntypedFormGroup } from "@angular/forms"; -import { Input, Component, OnInit } from "@angular/core"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; - -@Component({ - selector: 'app-dataset-profile-editor-researchers-auto-complete-field-component', - styleUrls: ['./dataset-profile-editor-researchers-auto-complete-field.component.scss'], - templateUrl: './dataset-profile-editor-researchers-auto-complete-field.component.html' -}) -export class DatasetProfileEditorResearchersAutoCompleteFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ResearchersAutoCompleteFieldDataEditorModel = new ResearchersAutoCompleteFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileInternalDmpEntitiesType.Researchers; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html deleted file mode 100644 index bc1c84e39..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts deleted file mode 100644 index b7ecb9364..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; -import { TagsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models'; -import { ResearchersDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'app-dataset-profile-editor-researchers-field-component', - styleUrls: ['./dataset-profile-editor-researchers-field.component.scss'], - templateUrl: './dataset-profile-editor-researchers-field.component.html' -}) -export class DatasetProfileEditorResearchersFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ResearchersDataEditorModel = new ResearchersDataEditorModel(); - - constructor(private router: Router) {} - - ngOnInit() { - if(this.router.url.includes('new')){ - this.form.patchValue({'rdaCommonStandard': 'dmp.contributor'}); - } - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html deleted file mode 100644 index 05e06a486..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RICH-TEXT-AREA-TITLE' - | translate}}
- - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RICH-TEXT-AREA-PLACEHOLDER' | translate}} - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss deleted file mode 100644 index 8da39919b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts deleted file mode 100644 index a1d74a86c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { RichTextAreaFieldDataEditorModel } from '../../../../admin/field-data/rich-text-area-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-rich-text-area-field-component', - styleUrls: ['./dataset-profile-editor-rich-text-area-field.component.scss'], - templateUrl: './dataset-profile-editor-rich-text-area-field.component.html' -}) -export class DatasetProfileEditorRichTextAreaFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: RichTextAreaFieldDataEditorModel = new RichTextAreaFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html deleted file mode 100644 index 9f0991328..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-SERVICES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-SERVICES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts deleted file mode 100644 index bf87cfd08..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-services-field-component', - styleUrls: ['./dataset-profile-editor-services-field.component.scss'], - templateUrl: './dataset-profile-editor-services-field.component.html' -}) -export class DatasetProfileEditorServicesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ServicesDataEditorModel = new ServicesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html deleted file mode 100644 index bab2b500f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAGS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAGS-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts deleted file mode 100644 index 350809a8b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; -import { TagsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'app-dataset-profile-editor-tags-field-component', - styleUrls: ['./dataset-profile-editor-tags-field.component.scss'], - templateUrl: './dataset-profile-editor-tags-field.component.html' -}) -export class DatasetProfileEditorTagsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: TagsDataEditorModel = new TagsDataEditorModel(); - - constructor(private router: Router) {} - - ngOnInit() { - if(this.router.url.includes('new')){ - this.form.patchValue({'rdaCommonStandard': 'dataset.keyword'}); - } - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html deleted file mode 100644 index 8249d5df7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAXONOMIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAXONOMIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts deleted file mode 100644 index 3a1033397..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormGroup} from '@angular/forms'; -import {TaxonomiesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models"; - -@Component({ - selector: 'app-dataset-profile-editor-taxonomies-field-component', - styleUrls: ['./dataset-profile-editor-taxonomies-field.component.scss'], - templateUrl: './dataset-profile-editor-taxonomies-field.component.html' -}) -export class DatasetProfileEditorTaxonomiesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: TaxonomiesDataEditorModel = new TaxonomiesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html deleted file mode 100644 index f3fe6ee4a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TEXT-AREA-TITLE' - | translate}}
- - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TEXT-AREA-PLACEHOLDER' | translate}} - - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts deleted file mode 100644 index 8daf1e271..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { TextAreaFieldDataEditorModel } from '../../../../admin/field-data/text-area-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-text-area-field-component', - styleUrls: ['./dataset-profile-editor-text-area-field.component.scss'], - templateUrl: './dataset-profile-editor-text-area-field.component.html' -}) -export class DatasetProfileEditorTextAreaFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: TextAreaFieldDataEditorModel = new TextAreaFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html deleted file mode 100644 index 73e64e186..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html +++ /dev/null @@ -1,62 +0,0 @@ - -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-TITLE' - | translate}}
- - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-PLACEHOLDER' | translate}} - - - - - - - {{ "DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-MAX-FILE-SIZE" | - translate: { maxfilesize: getConfiguration().maxFileSizeInMB.toString() } }} - - - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-SELECT-FILETYPE' | translate}} - - - - {{type.label}} - - - - -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-CUSTOM-FILETYPE' | translate}}
- -
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-LABEL' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-VALUE' | translate}} - - - -
-
-
-
- -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss deleted file mode 100644 index 8da39919b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts deleted file mode 100644 index 76fb38032..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { FieldDataOption } from "@app/core/model/dataset-profile-definition/field-data/field-data"; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { FieldDataOptionEditorModel } from "@app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model"; -import { UploadFieldDataEditorModel } from '../../../../admin/field-data/upload-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-upload-field-component', - styleUrls: ['./dataset-profile-editor-upload-field.component.scss'], - templateUrl: './dataset-profile-editor-upload-field.component.html' -}) -export class DatasetProfileEditorUploadFieldComponent implements OnInit { - types: Array = [ - // images - { label: "Animated Portable Network Graphics (APNG)", value: "image/apng", source: "" }, - { label: "AV1 Image File Format (AVIF)", value: "image/avif", source: "" }, - { label: "Graphics Interchange Format (GIF)", value: "image/gif", source: "" }, - { label: "Joint Photographic Expert Group image (JPEG)", value: "image/jpeg", source: "" }, - { label: "Portable Network Graphics (PNG)", value: "image/png", source: "" }, - { label: "Scalable Vector Graphics (SVG)", value: "image/svg+xml", source: "" }, - { label: "Web Picture format (WEBP)", value: "image/webp", source: "" }, - { label: "Tagged Image File Format (TIFF)", value: "image/tiff", source: "" }, - - // office word - { label: "Microsoft Word 97-2003", value: "application/msword", source: "" }, // .doc, .dot - { label: "Microsoft Word 2007-2013", value: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", source: "" }, // .docx - { label: "OpenDocument Text", value: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", source: "" }, // .odt - - // office excel - { label: "Microsoft Excel 97-2003", value: "application/vnd.ms-excel", source: "" }, // .xls, .xlt, .xla - { label: "Microsoft Excel 2007-2013", value: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", source: "" }, // .xlsx - { label: "OpenDocument Spreadsheet", value: "application/vnd.oasis.opendocument.spreadsheet", source: "" }, // .ods - - // office powerpoint - { label: "Microsoft PowerPoint 97-2003", value: "application/vnd.ms-powerpoint", source: "" }, // .ppt, .pot, .pps, .ppa - { label: "Microsoft PowerPoint 2007-2013", value: "application/vnd.openxmlformats-officedocument.presentationml.presentation", source: "" }, // .pptx - { label: "OpenDocument Presentation", value: "application/vnd.oasis.opendocument.presentation", source: "" }, // .odp - - - { label: "Comma-Seperated Values (CSV)", value: "text/csv", source: "" }, - { label: "Adobe Portable Document Format (PDF)", value: "application/pdf", source: "" } - ]; - - selected: string[] = []; - public typesFormControl = new UntypedFormControl(); - - @Input() form: UntypedFormGroup; - private data: UploadFieldDataEditorModel = new UploadFieldDataEditorModel(); - - constructor(private configurationService: ConfigurationService) { } - - ngOnInit() { - let typeValues: string[] = this.types.map(type => type.value); - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - if (this.form.get('data') && this.form.get('data').get('types')) { - for (let type of this.form.get('data').get('types').value) { - if (typeValues.indexOf(type.value) != -1) { - this.selected.push(type.value); - } - } - this.typesFormControl.setValue(this.selected); - // if (this.form.get('data').get('types').disabled) { - // this.typesFormControl.disable(); - // } - } - } - - selectedType(type: FieldDataOption) { - if (!this.form.get('data').get('types').disabled) { - let index = this.selected.indexOf(type.value); - if (index == -1) { - this.selected.push(type.value); - this.addNewRow(type); - } else { - this.selected.splice(index, 1); - this.deleteRow(index); - } - } - } - - isCustomType(value: string) { - return this.selected.indexOf(value) == -1; - } - - addNewRow(type: FieldDataOption = null) { - const typeListOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - if (type != null) { - typeListOptions.fromModel(type); - } - (this.form.get('data')).addControl('types', new UntypedFormBuilder().array([])); - (this.form.get('data').get('types')).push(typeListOptions.buildForm()); - } - - deleteRow(index: number) { - if (this.form.get('data').get('types')) { (this.form.get('data').get('types')).removeAt(index); } - } - - public getConfiguration() { - return this.configurationService; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html deleted file mode 100644 index 8b28d4c4e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-VALIDATOR-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-VALIDATOR-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts deleted file mode 100644 index b3ec7f309..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-validator-field-component', - styleUrls: ['./dataset-profile-editor-validator-field.component.scss'], - templateUrl: './dataset-profile-editor-validator-field.component.html' -}) -export class DatasetProfileEditorValidatorFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html deleted file mode 100644 index 12d82cae4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html +++ /dev/null @@ -1,41 +0,0 @@ -
-
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-TITLE' - | translate}}
- - - warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-SELECT-AT-LEAST-ONE-REQUIRED' |translate}} - -
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-WORDLIST' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-PLACEHOLDER' | translate}} - - - -
-
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-LABEL' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-VALUE' | translate}} - - - -
-
-
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts deleted file mode 100644 index b7f78262c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { FieldDataOptionEditorModel } from '../../../../admin/field-data/field-data-option-editor-model'; -import { WordListFieldDataEditorModel } from '../../../../admin/field-data/word-list-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-word-list-field-component', - styleUrls: ['./dataset-profile-editor-word-list-field.component.scss'], - templateUrl: './dataset-profile-editor-word-list-field.component.html' -}) -export class DatasetProfileEditorWordListFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: WordListFieldDataEditorModel = new WordListFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileComboBoxType.WordList; - } - - addNewRow() { - const wordListOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - (this.form.get('data').get('options')).push(wordListOptions.buildForm()); - } - - deleteRow(intex: number) { - if (this.form.get('data').get('options')) { (this.form.get('data').get('options')).removeAt(intex); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html deleted file mode 100644 index f924390b4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html +++ /dev/null @@ -1,333 +0,0 @@ - - - -
- -
-
    -
  • - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
  • -
  • - - {{'GENERAL.VALIDATION.URL.LABEL' | translate}} - -
  • - -
  • - delete -
  • -
-
-
- -
- - - - - - - - - {{enumUtils.toDatasetProfileViewTypeString(select.value)}} - - - TextArea icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.TextArea)}} - - - RichTextArea icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.RichTextArea)}} - - - FreeText icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.FreeText)}} - - - - - upload - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Upload)}} - - - - - - - - Boolean icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.BooleanDecision)}} - - - RadioBox icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.RadioBox)}} - - - - Select icon - - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Select)}} - - - CheckBox icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.CheckBox)}} - - - - - - DatePicker icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DatePicker)}} - - - Current icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Currency)}} - - - - - - - - Registries icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Registries)}} - - - Services icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Services)}} - - - Researchers icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Researchers)}} - - - Organizations icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Organizations)}} - - - ExternalDatasets icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.ExternalDatasets)}} - - - DataRepositories icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DataRepositories)}} - - - PubRepositories icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.PubRepositories)}} - - - Journal Repositories icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.JournalRepositories)}} - - - Taxonomies icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Taxonomies)}} - - - licenses icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Licenses)}} - - - Publications icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Publications)}} - - - Other icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Other)}} - - - - - - - InternalDmpEntities icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.InternalDmpEntities)}} - - - Tags icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Tags)}} - - - DatasetIdentifier icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DatasetIdentifier)}} - - - Validation icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Validation)}} - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - - - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.SEMANTICS' | translate}} - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXPORT' | translate}} - - - - -
-
-
- 'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.ADD-VISIBILITY-RULE' | translate - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.ADD-VISIBILITY-RULE' | translate}} -
-
- -
-
- -

{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | translate}} -

- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss deleted file mode 100644 index 7dfc9b224..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss +++ /dev/null @@ -1,66 +0,0 @@ -.full-width { - width: 100%; -} - - -.preview-box{ - padding: 1em; - border: 1px solid #e8dcdc; - border-radius: 0.3em; -} - -mat-radio-button{ - padding-right: 1em; -} - -li.list-inline-item{ - color: var(--primary-color); - .mat-icon{ - vertical-align: bottom; - } -} - -:host ::ng-deep .field-toggler -{ - .mat-slide-toggle-content{ - font-size: 0.8em; - color: #212121; - } - .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb { - background-color:var(--primary-color) ; - } - .mat-slide-toggle.mat-checked .mat-slide-toggle-bar { - background-color:rgba(0,178,159,0.34); - } - .mat-slide-toggle-bar{ - height: 11.93px; - width: 26.42px; - } - .mat-slide-toggle-thumb-container{ - top: -3px; - } - .mat-slide-toggle-thumb{ - width: 16px; - height: 16px; - } -} - - -.input_icon{ - width: 14px; - margin-right: 0.5em; -} -.visibility-icon{ - width: 20px; - margin-right: 0.5em; -} -.add-visibility-button{ - // display: flex; - // align-items: center; - width: auto; - cursor: pointer; - span{ - font-weight: 400; - font-size: 0.8em; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts deleted file mode 100644 index cf2a828f6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts +++ /dev/null @@ -1,988 +0,0 @@ -import { COMMA, ENTER } from '@angular/cdk/keycodes'; -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { FormGroupDirective, NgForm, UntypedFormArray, UntypedFormControl, UntypedFormGroup, } from '@angular/forms'; -import { ErrorStateMatcher } from '@angular/material/core'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSlideToggleChange } from '@angular/material/slide-toggle'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { ValidationType } from '@app/core/common/enum/validation-type'; -import { DefaultValue, Field } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { - AutoCompleteFieldData, - BooleanDecisionFieldData, - CheckBoxFieldData, - CurrencyFieldData, - DataRepositoriesFieldData, - DatasetIdentifierFieldData, - DatePickerFieldData, - DmpsAutoCompleteFieldData, - ExternalDatasetsFieldData, - FieldDataOption, - FreeTextFieldData, - LicensesFieldData, - OrganizationsFieldData, - PublicationsFieldData, - RadioBoxFieldData, - RegistriesFieldData, - ResearchersAutoCompleteFieldData, - RichTextAreaFieldData, - ServicesFieldData, - // TableFieldData, - TagsFieldData, - TaxonomiesFieldData, - TextAreaFieldData, - UploadFieldData, - ValidationFieldData, - WordListFieldData -} from '@app/core/model/dataset-profile-definition/field-data/field-data'; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { RuleEditorModel } from '@app/ui/admin/dataset-profile/admin/rule-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable, Subscription } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { FieldEditorModel } from '../../../admin/field-editor-model'; -import { ViewStyleType } from './view-style-enum'; - -@Component({ - selector: 'app-dataset-profile-editor-field-component', - templateUrl: './dataset-profile-editor-field.component.html', - styleUrls: ['./dataset-profile-editor-field.component.scss'] -}) -export class DatasetProfileEditorFieldComponent extends BaseComponent implements OnInit, ErrorStateMatcher { - @Input() viewOnly: boolean; - @Input() form: UntypedFormGroup; - @Input() showOrdinal = true; - @Input() indexPath: string; - validationTypeEnum = ValidationType; - viewStyleEnum = DatasetProfileFieldViewStyle; - // isFieldMultiplicityEnabled = false; - - viewType: ViewStyleType; - viewTypeEnum = ViewStyleType; - // private subject$:Subject = new Subject(); - - - - @Input() expandView: boolean = true; - @Input() canBeDeleted: boolean = true; - - @Output() delete = new EventEmitter(); - - readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - semanticsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterSemantics.bind(this), - initialItems: (excludedItems: any[]) => this.filterSemantics('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x !== resultItem)))), - displayFn: (item) => item, - titleFn: (item) => item - } - - filterSemantics(value: string): Observable { - return this.datasetProfileService.searchSemantics(value); - } - - constructor( - public enumUtils: EnumUtils, - public datasetProfileService: DatasetProfileService, - private dialog: MatDialog, - private configurationService: ConfigurationService - ) { - super(); - - } - - - isErrorState(control: UntypedFormControl, form: FormGroupDirective | NgForm): boolean { - - if (this.form.get('viewStyle').untouched) return false; - - return this.form.get('viewStyle').invalid; - } - - ngOnInit() { - - // this.subject$.pipe(takeUntil(this._destroyed)).pipe(debounceTime(600)).subscribe(model=>{ - // this.previewForm = model.buildForm(); - // }); - - - - // if (this.form.get('multiplicity')) { - // if (this.form.get('multiplicity').value.min > 1 && this.form.get('multiplicity').value.max > 1) { - // this.isFieldMultiplicityEnabled = true; - // } - // } - - const renderStyle = this.form.get('viewStyle').get('renderStyle').value; - if (renderStyle) { - - // this.matcher.setReference(this.form); - const type = this.form.get('viewStyle').get('renderStyle').value; - - switch (type) { - case DatasetProfileFieldViewStyle.BooleanDecision: - this.viewType = this.viewTypeEnum.BooleanDecision; - break; - case DatasetProfileFieldViewStyle.CheckBox: - this.viewType = this.viewTypeEnum.CheckBox; - break; - case DatasetProfileFieldViewStyle.ComboBox: - - const comboType = this.form.get('data').get('type').value; - if (comboType === DatasetProfileComboBoxType.Autocomplete) { - this.viewType = this.viewTypeEnum.Other; - } else if (comboType === DatasetProfileComboBoxType.WordList) { - this.viewType = this.viewTypeEnum.Select; - } - break; - case DatasetProfileFieldViewStyle.InternalDmpEntities: - this.viewType = this.viewTypeEnum.InternalDmpEntities; - break; - case DatasetProfileFieldViewStyle.FreeText: - this.viewType = this.viewTypeEnum.FreeText; - break; - case DatasetProfileFieldViewStyle.RadioBox: - this.viewType = this.viewTypeEnum.RadioBox; - break; - case DatasetProfileFieldViewStyle.TextArea: - this.viewType = this.viewTypeEnum.TextArea; - break; - case DatasetProfileFieldViewStyle.RichTextArea: - this.viewType = this.viewTypeEnum.RichTextArea; - break; - case DatasetProfileFieldViewStyle.Upload: - this.viewType = this.viewTypeEnum.Upload; - break; - case DatasetProfileFieldViewStyle.Table: - this.viewType = this.viewTypeEnum.Table; - break; - case DatasetProfileFieldViewStyle.DatePicker: - this.viewType = this.viewTypeEnum.DatePicker; - break; - case DatasetProfileFieldViewStyle.ExternalDatasets: - this.viewType = this.viewTypeEnum.ExternalDatasets; - break; - case DatasetProfileFieldViewStyle.DataRepositories: - this.viewType = this.viewTypeEnum.DataRepositories; - break; - case DatasetProfileFieldViewStyle.PubRepositories: - this.viewType = this.viewTypeEnum.PubRepositories; - break; - case DatasetProfileFieldViewStyle.JournalRepositories: - this.viewType = this.viewTypeEnum.JournalRepositories; - break; - case DatasetProfileFieldViewStyle.Taxonomies: - this.viewType = this.viewTypeEnum.Taxonomies; - break; - case DatasetProfileFieldViewStyle.Licenses: - this.viewType = this.viewTypeEnum.Licenses; - break; - case DatasetProfileFieldViewStyle.Publications: - this.viewType = this.viewTypeEnum.Publications; - break; - case DatasetProfileFieldViewStyle.Registries: - this.viewType = this.viewTypeEnum.Registries; - break; - case DatasetProfileFieldViewStyle.Services: - this.viewType = this.viewTypeEnum.Services; - break; - case DatasetProfileFieldViewStyle.Tags: - this.viewType = this.viewTypeEnum.Tags; - break; - case DatasetProfileFieldViewStyle.Researchers: - this.viewType = this.viewTypeEnum.Researchers; //TODO RESEARCHERS - break; - case DatasetProfileFieldViewStyle.Organizations: - this.viewType = this.viewTypeEnum.Organizations; - break; - case DatasetProfileFieldViewStyle.DatasetIdentifier: - this.viewType = this.viewTypeEnum.DatasetIdentifier; - break; - case DatasetProfileFieldViewStyle.Currency: - this.viewType = this.viewTypeEnum.Currency; - break; - case DatasetProfileFieldViewStyle.Validation: - this.viewType = this.viewTypeEnum.Validation; - break; - } - if (this.viewType !== this.viewTypeEnum.FreeText) { - this.setValidator(ValidationType.URL, false); - } - } - - // this.showPreview = true; - - - - - // this.addNewRule(); - - // this.form.get('viewStyle').get('renderStyle').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => { - - - // // const previewStatus = this.showPreview; - // //!! Important to be before the if statement - // this.showPreview = false; - - // if (this.form.get('data')) { - // this.form.removeControl('data'); - - // switch (x) { - // case DatasetProfileFieldViewStyle.BooleanDecision: - // this.form.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.CheckBox: - // this.form.addControl('data', new CheckBoxFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.ComboBox: - // this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.InternalDmpEntities: - // this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.FreeText: - // this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.RadioBox: - // this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.TextArea: - // this.form.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.DatePicker: - // this.form.addControl('data', new DatePickerDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.ExternalDatasets: - // this.form.addControl('data', new ExternalDatasetsDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.DataRepositories: - // this.form.addControl('data', new DataRepositoriesDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Registries: - // this.form.addControl('data', new RegistriesDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Services: - // this.form.addControl('data', new ServicesDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Tags: - // this.form.addControl('data', new TagsDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Researchers: - // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Organizations: - // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.DatasetIdentifier: - // this.form.addControl('data', new DatasetIdentifierDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Currency: - // this.form.addControl('data', new CurrencyDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Validation: - // this.form.addControl('data', new ValidationDataEditorModel().buildForm()); - // break; - // } - // } - - - // //reset the preview status - // // this.showPreview = previewStatus; - // this.showPreview = true; - // }); - } - - // defaulValueRequired(viewStile: DatasetProfileFieldViewStyle): boolean { - // switch (viewStile) { - // case DatasetProfileFieldViewStyle.CheckBox: - // return true; - // case DatasetProfileFieldViewStyle.RadioBox: - // case DatasetProfileFieldViewStyle.TextArea: - // case DatasetProfileFieldViewStyle.FreeText: - // case DatasetProfileFieldViewStyle.ComboBox: - // case DatasetProfileFieldViewStyle.InternalDmpEntities: - // case DatasetProfileFieldViewStyle.BooleanDecision: - // case DatasetProfileFieldViewStyle.DatePicker: - // case DatasetProfileFieldViewStyle.ExternalDatasets: - // case DatasetProfileFieldViewStyle.DataRepositories: - // case DatasetProfileFieldViewStyle.Registries: - // case DatasetProfileFieldViewStyle.Services: - // case DatasetProfileFieldViewStyle.Tags: - // case DatasetProfileFieldViewStyle.Registries: - // case DatasetProfileFieldViewStyle.Organizations: - // case DatasetProfileFieldViewStyle.DatasetIdentifier: - // case DatasetProfileFieldViewStyle.Currency: - // case DatasetProfileFieldViewStyle.Validation: - // return false; - // default: - // return false; - // } - // } - - - - // onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) { - // if (!isFieldMultiplicityEnabled) { - // (this.form.get('multiplicity').get('min')).setValue(0); - // (this.form.get('multiplicity').get('max')).setValue(0); - // } - // } - - addNewRule() { - const rule: RuleEditorModel = new RuleEditorModel(); - (this.form.get('visible').get('rules')).push(rule.buildForm()); - } - - - private _formChangesSubscription: Subscription; - private _showPreview: boolean = false; - - // get showPreview(): boolean{ - - // return this._showPreview; - // } - - // set showPreview(value:boolean){ - // if(value == false){//hide preview - // //close subsciption - // if(this._formChangesSubscription){ - // this._formChangesSubscription.unsubscribe(); - // this._formChangesSubscription = null; - // } - // } - - // if(value == true){ - // //value is already true - // if(this._showPreview){ - // if(this._formChangesSubscription){ - // this._formChangesSubscription.unsubscribe(); - // this._formChangesSubscription = null; - // } - // } - - // //initialize - // if(this.form.get('viewStyle').get('renderStyle').value){ - // this._generatePreviewForm(); - // } - // this._formChangesSubscription = this.form.valueChanges.subscribe(()=>{ - // this._generatePreviewForm(); - // }); - // } - // this._showPreview = value; - - // } - - // previewForm: FormGroup; - - // private _generatePreviewForm(){ - - // if(!this.form.get('data')){ - // return; - // } - // this.previewForm = null; - // const fieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // fieldEditorModel.viewStyle= { - // renderStyle: this.form.get('viewStyle').get('renderStyle').value, - // cssClass: null - // }; - - // fieldEditorModel.data = (this.form.get('data') as FormGroup).getRawValue(); - // fieldEditorModel.value = this.form.get('defaultValue').get('value').value; - // fieldEditorModel.validationRequired = (this.form.get('validations').value as Array).includes(ValidationType.Required); - - // if(this.form.get('viewStyle').get('renderStyle').value == DatasetProfileFieldViewStyle.CheckBox){ - // fieldEditorModel.value = this.form.get('defaultValue').get('value').value === 'true'; - // } - // // if(this.form.get('viewStyle').get('renderStyle').value == DatasetProfileFieldViewStyle.Researchers){ - // // fieldEditorModel.data = new ResearchersAutoCompleteFieldDataEditorModel().buildForm().getRawValue(); - // // } - // if(fieldEditorModel.viewStyle.renderStyle === DatasetProfileFieldViewStyle.Validation || (fieldEditorModel.viewStyle.renderStyle === DatasetProfileFieldViewStyle.DatasetIdentifier) - // || (fieldEditorModel.viewStyle.renderStyle === DatasetProfileFieldViewStyle.Tags) - // ){ - // fieldEditorModel.value = null; - // } - - // // const myTicket = Guid.create().toString(); - // // this.validTicket = myTicket; - // // setTimeout(() => { //TODO - // // //user hasnt make any new change to inputs /show preview - // // if(myTicket === this.validTicket){ - // // this.previewForm = fieldEditorModel.buildForm(); - // // } - // // }, 600); - - // this.subject$.next(fieldEditorModel); - - - // // setTimeout(() => { - // // this.previewForm = fieldEditorModel.buildForm(); - // // }); - // }; - - get canApplyVisibility(): boolean { - - - switch (this.viewType) { - case this.viewTypeEnum.TextArea: - case this.viewTypeEnum.RichTextArea: - case this.viewTypeEnum.Upload: - case this.viewTypeEnum.FreeText: - case this.viewTypeEnum.BooleanDecision: - case this.viewTypeEnum.RadioBox: - case this.viewTypeEnum.Select: - case this.viewTypeEnum.CheckBox: - case this.viewTypeEnum.DatePicker: - return true; - - } - - - return false; - - } - - // validTicket:string; - // generatePreview(){ - // const fieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // fieldEditorModel.viewStyle= { - // renderStyle: this.form.get('viewStyle').get('renderStyle').value, - // cssClass: null - // }; - // fieldEditorModel.defaultValue = this.form.get('defaultValue').value; - // switch (this.form.get('viewStyle').get('renderStyle').value) { - // case DatasetProfileFieldViewStyle.TextArea: - // fieldEditorModel.data = { - // label: this.form.get('data').get('label').value - // }; - // break; - - // default: - // break; - // } - - // // this.previewForm = fieldEditorModel.buildForm(); - - - // } - onInputTypeChange() { - - - const x = this.viewType; - - // this.showPreview = false; - - - - const field: Field = this.form.getRawValue(); - // field.defaultValue = {type:null, value: null}; - field.defaultValue = undefined; - if (!this.canApplyVisibility) { - field.visible.rules = []; - } - - - - // if (this.form.get('data')) { - // this.form.removeControl('data'); - // } - - // this.form.removeControl('defaultValue'); - // const defaultValueModel = new DefaultValueEditorModel(); - // this.form.addControl('defaultValue',defaultValueModel.buildForm()); - - switch (x) { - case this.viewTypeEnum.BooleanDecision: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.BooleanDecision) - // this.form.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm()); - - const data: BooleanDecisionFieldData = { - label: "" - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.BooleanDecision; - field.data = data; - - break; - } - case this.viewTypeEnum.CheckBox: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.CheckBox) - // this.form.addControl('data', new CheckBoxFieldDataEditorModel().buildForm()); - - const data: CheckBoxFieldData = { - label: '' - } - const defaultValue: DefaultValue = { - type: '', - value: 'false' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.CheckBox; - field.data = data; - field.defaultValue = defaultValue; - - break; - } - case this.viewTypeEnum.Select: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - - // this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // this.form.get('data').updateValueAndValidity(); - const option1 = { label: '', value: '' } as FieldDataOption; - - const data: WordListFieldData = { - label: '', - multiList: false, - options: [option1], - type: DatasetProfileComboBoxType.WordList - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } - case this.viewTypeEnum.Other: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE - - // this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - // this.form.get('data').updateValueAndValidity(); - - const data: AutoCompleteFieldData = { - autoCompleteSingleDataList: [], - multiAutoComplete: false, - label: '', - type: DatasetProfileComboBoxType.Autocomplete - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } - case this.viewTypeEnum.InternalDmpEntities: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.InternalDmpEntities) - // this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());//TODO TO SEE - - const data: DmpsAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Dmps - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities; - field.data = data; - - break; - } - case this.viewTypeEnum.FreeText: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.FreeText) - // this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); - - const data: FreeTextFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.FreeText; - field.data = data; - - break; - } - case this.viewTypeEnum.RadioBox: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox) - // this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - - // this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // this.form.get('data').updateValueAndValidity(); - - const data: RadioBoxFieldData = { - label: '', - options: [] - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RadioBox; - field.data = data; - - break; - } - case this.viewTypeEnum.TextArea: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // this.form.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: TextAreaFieldData = { - label: '' - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.TextArea; - field.data = data; - break; - } - case this.viewTypeEnum.RichTextArea: { - const data: RichTextAreaFieldData = { - label: '' - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RichTextArea; - field.data = data; - break; - } - case this.viewTypeEnum.Upload: { - const data: UploadFieldData = { - label: '', - types: [], - maxFileSizeInMB: this.configurationService.maxFileSizeInMB - } - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Upload; - field.data = data; - break; - } - // case this.viewTypeEnum.Table:{ - // const data: TableFieldData = { - // label:'', - // headers: [], - // rows: [] - // } - // - // - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Table; - // field.data = data; - // break; - // } - case this.viewTypeEnum.DatePicker: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatePicker) - // this.form.addControl('data', new DatePickerDataEditorModel().buildForm()); - - const data: DatePickerFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatePicker; - field.data = data; - - break; - } - case this.viewTypeEnum.ExternalDatasets: { - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ExternalDatasets) - // this.form.addControl('data', new ExternalDatasetsDataEditorModel().buildForm()); - - const data: ExternalDatasetsFieldData = { - label: '', - multiAutoComplete: false - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ExternalDatasets; - field.data = data; - - break; - } - case this.viewTypeEnum.DataRepositories: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DataRepositories) - // this.form.addControl('data', new DataRepositoriesDataEditorModel().buildForm()); - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.PubRepositories: { - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.PubRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.JournalRepositories: { - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.JournalRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.Taxonomies: { - - const data: TaxonomiesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Taxonomies; - field.data = data; - - break; - } - case this.viewTypeEnum.Licenses: { - - const data: LicensesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Licenses; - field.data = data; - - break; - } - case this.viewTypeEnum.Publications: { - - const data: PublicationsFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Publications; - field.data = data; - - break; - } - case this.viewTypeEnum.Registries: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Registries) - // this.form.addControl('data', new RegistriesDataEditorModel().buildForm()); - - const data: RegistriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Registries; - field.data = data; - - break; - } - case this.viewTypeEnum.Services: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Services) - // this.form.addControl('data', new ServicesDataEditorModel().buildForm()); - - const data: ServicesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Services; - field.data = data; - - break; - } - case this.viewTypeEnum.Tags: { - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Tags) - // this.form.addControl('data', new TagsDataEditorModel().buildForm()); - - const data: TagsFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Tags; - field.data = data; - - - break; - } - case this.viewTypeEnum.Researchers: { - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Researchers) - // // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); //TODO TO ASK - // this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - - const data: ResearchersAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Researchers - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - field.data = data; - - - break; - } - case this.viewTypeEnum.Organizations: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Organizations) - // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()); - - const data = { - autoCompleteSingleDataList: [], - label: '', - multiAutoComplete: false, - - } as OrganizationsFieldData; //TODO - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Organizations; - field.data = data; - - break; - } - case this.viewTypeEnum.DatasetIdentifier: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatasetIdentifier) - // this.form.addControl('data', new DatasetIdentifierDataEditorModel().buildForm()); - - const data: DatasetIdentifierFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatasetIdentifier; - field.data = data; - - break; - } - case this.viewTypeEnum.Currency: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Currency) - // this.form.addControl('data', new CurrencyDataEditorModel().buildForm()); - - const data: CurrencyFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Currency; - field.data = data; - break; - } - case this.viewTypeEnum.Validation: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Validation) - // this.form.addControl('data', new ValidationDataEditorModel().buildForm()); - - const data: ValidationFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Validation; - field.data = data; - - break; - } - } - - // this.form.get('data').updateValueAndValidity(); - // this.form.get('viewStyle').get('renderStyle').updateValueAndValidity(); - // this.form.updateValueAndValidity(); - - - const form = (new FieldEditorModel).fromModel(field).buildForm(); - - - const fields = this.form.parent as UntypedFormArray; - let index = -1; - - fields.controls.forEach((control, i) => { - if (this.form.get('id').value === control.get('id').value) { - index = i - } - }); - if (index >= 0) { - fields.removeAt(index); - fields.insert(index, form); - this.form = form; - - - } - - // setTimeout(() => { //TODO - // this.showPreview = true; - // }); - } - - - toggleRequired(event: MatSlideToggleChange) { - this.setValidator(ValidationType.Required, event.checked); - } - - toggleURL(event: MatSlideToggleChange) { - this.setValidator(ValidationType.URL, event.checked); - } - - private setValidator(validationType: ValidationType, add: boolean) { - let validationsControl = this.form.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - - if (add) { - if (!validations.includes(validationType)) { - validations.push(validationType); - validationsControl.updateValueAndValidity(); - } - } else { - validationsControl.setValue(validations.filter(validator => validator != validationType)); - validationsControl.updateValueAndValidity(); - } - this.form.markAsDirty();//deactivate guard - } - - get isRequired() { - let validationsControl = this.form.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - return validations.includes(ValidationType.Required); - } - - get isURL() { - let validationsControl = this.form.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - return validations.includes(ValidationType.URL); - } - - - onDelete() { - this.delete.emit(); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts deleted file mode 100644 index 6bec2f1d2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts +++ /dev/null @@ -1,29 +0,0 @@ -export enum ViewStyleType{ - TextArea = "textarea", - RichTextArea = "richTextarea", - Upload = "upload", - Table = "table", - BooleanDecision = "booleanDecision", - CheckBox = "checkBox", - FreeText = "freetext", - RadioBox = "radiobox", - DatePicker = "datePicker", - InternalDmpEntities = "internalDmpEntities", - ExternalDatasets = "externalDatasets", - DataRepositories = "dataRepositories", - PubRepositories = "pubRepositories", - JournalRepositories = "journalRepositories", - Taxonomies = "taxonomies", - Licenses = "licenses", - Publications = "publications", - Registries = "registries", - Services = "services", - Tags = "tags", - Researchers = "researchers", - Organizations = "organizations", - DatasetIdentifier = "datasetIdentifier", - Currency = "currency", - Validation = 'validation', - Select ="selection", - Other ="other" -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html deleted file mode 100644 index 39882e08c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts deleted file mode 100644 index 25afc4373..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Component, Input, OnInit} from '@angular/core'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; - - -@Component({ - selector: 'app-final-preview-component', - templateUrl: './final-preview.component.html', - styleUrls: ['./final-preview.component.scss'], - providers:[VisibilityRulesService] -}) - -export class FinalPreviewComponent implements OnInit { - - - @Input() formGroup = null; - @Input() visibilityRules:Rule[] = []; - constructor(private visibilityRulesService: VisibilityRulesService){ - - } - - - - ngOnInit(): void { - this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.formGroup); - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html deleted file mode 100644 index 9017f02f1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html +++ /dev/null @@ -1,13 +0,0 @@ - - {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.PAGE-PREFIX' | translate}} {{i + 1}} -
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss deleted file mode 100644 index 135c7a3f6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.page-card { - margin-bottom: 1em; - - .page-card-title { - text-align: center; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts deleted file mode 100644 index 8ef8a40f2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormArray } from '@angular/forms'; - -@Component({ - selector: 'app-dataset-profile-editor-page-component', - templateUrl: './dataset-profile-editor-page.component.html', - styleUrls: ['./dataset-profile-editor-page.component.scss'] -}) -export class DatasetProfileEditorPageComponent { - - @Input() form: UntypedFormArray; - @Input() viewOnly: boolean; - - removePage(index) { - (this.form).removeAt(index); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html deleted file mode 100644 index dd2a26762..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html +++ /dev/null @@ -1,99 +0,0 @@ -
- {{i + 1}} - - - - - - - - - - - - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-THEN'| translate}} - - - - - - - - {{option.label? option.label:'<'+ ('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) + '>'}} -
- - {{option.id}} - -
-
- - - - - {{option.label? option.label:'<'+ ('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) + '>'}} -
- - {{option.id}} - -
-
- - -
- {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
- -
-
-
- - - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts deleted file mode 100644 index 645853d74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; -import { UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileComboBoxType } from '../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { ToCEntryType } from '../../../table-of-contents/table-of-contents-entry'; -import { Rule } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { TranslateService } from '@ngx-translate/core'; - -@Component({ - selector: 'app-dataset-profile-editor-rule-component', - templateUrl: './dataset-profile-editor-rule.component.html', - styleUrls: ['./dataset-profile-editor-rule.component.scss'] -}) - -export class DatasetProfileEditorRuleComponent implements OnInit { - - - @Input() form: UntypedFormArray; - - @Input() viewStyleForCheck: DatasetProfileFieldViewStyle; - @Input() formControlForCheck: UntypedFormControl; - @Input() formArrayOptionsForCheck: UntypedFormArray; - @Input() comboBoxTypeForCheck: DatasetProfileComboBoxType; - @Input() viewOnly: boolean; - - - options: OptionItem[]; - sectionOptions: OptionItem[]; - fieldSetOptions: OptionItem[]; - fieldOptions: OptionItem[]; - - parentIds: string[] = []; - hiddenBy: string[] = []; - - constructor(private language: TranslateService){ - - } - - targetValidation() { - //TODO - } - - deleteRule(index) { - this.form.removeAt(index); - this.form.markAsDirty();//deactivate guard - } - - ngOnInit(): void { - this._computeOptions(); - } - - private _computeOptions(){ - this.options = this.getOptions(); - - this.sectionOptions = []; - this.fieldOptions = []; - this.fieldSetOptions = []; - this.options.forEach(option=>{ - switch (option.type) { - case ToCEntryType.Field: - this.fieldOptions.push(option); - break; - case ToCEntryType.FieldSet: - this.fieldSetOptions.push(option); - break; - case ToCEntryType.Section: - this.sectionOptions.push(option); - break; - default: - break; - } - }); - //remove options to hide if given fieldset is already hidden by option - - this.fieldOptions.forEach(e=>this._buildHiddenBy(e)); - this.fieldSetOptions.forEach(e=>this._buildHiddenBy(e)); - this.parentIds = this.computeParentIds(); - this.hiddenBy = this.computeHiddenBy(); - } - - - - computeOptions(isOpened: boolean){ - if(isOpened){ - this._computeOptions(); - } - } - - private _buildHiddenBy(fo:OptionItem){ - try{ - this.fieldOptions.forEach(foption=>{ - const rules = (foption.form.get('visible').get('rules') as UntypedFormArray).controls.map(c=>(c as UntypedFormGroup).getRawValue()) as Rule[] - const targets = rules.map(rule=>rule.target); - targets.forEach(target=>{ - if(fo.parentsIds.includes(target) && !fo.hiddenBy.includes(foption.id)){ - fo.hiddenBy.push(...foption.parentsIds); - } - }) - - }); - }catch{ - console.log('error'); - } - } - - - - - - getOptions():OptionItem[]{ - const rootForm = this.form.root; - if(rootForm){ - // const parentSections = rootForm.get('sections') as FormArray; - - const result:OptionItem[] =[]; - - const sections = rootForm.get('sections') as UntypedFormArray; - - if(sections){ - sections.controls.forEach(section=>{ - const subResult = this.buildOptions(section as UntypedFormGroup, ToCEntryType.Section,[]); - result.push(...subResult); - }); - } - - //return options - return result; - - } - //nothing found - return []; - } - - private buildOptions(form: UntypedFormGroup, type: ToCEntryType, parentIds:string[]):OptionItem[]{ - - const sections = form.get('sections') as UntypedFormArray; - const fieldSets = form.get('fieldSets') as UntypedFormArray; - const fields = form.get('fields') as UntypedFormArray; - - const result:OptionItem[] = []; - - // parentIds.push(form.get('id').value); - const currentOptionItem:OptionItem = { - id: form.get('id').value, - type: type, - label: type ===ToCEntryType.Field? form.get('data').get('label').value :form.get('title').value, - // parentsIds: [form.get('id').value] - parentsIds: [...parentIds, form.get('id').value], - form: form, - hiddenBy:[] - } - result.push(currentOptionItem); - - if(sections){ - sections.controls.forEach(section=>{ - result.push( ...this.buildOptions(section as UntypedFormGroup, ToCEntryType.Section, currentOptionItem.parentsIds) ); - }); - } - if(fieldSets){ - fieldSets.controls.forEach(fieldset=>{ - result.push( ...this.buildOptions(fieldset as UntypedFormGroup, ToCEntryType.FieldSet, currentOptionItem.parentsIds) ); - }); - } - if(fields){ - fields.controls.forEach(field=>{ - result.push( ...this.buildOptions(field as UntypedFormGroup, ToCEntryType.Field, currentOptionItem.parentsIds) ); //TODO NA TO DOUME - }); - } - - return result; - } - - // get parentIds(): string[]{ - - - // } - // get hiddenBy(): string[]{ - - // } - - computeParentIds(): string[]{ - if(!this.formControlForCheck.get('id')) return []; - - const current = this.options.find(opt=> opt.id === this.formControlForCheck.get('id').value); - - if(current){ - return current.parentsIds; - } - return []; - } - - computeHiddenBy(): string[]{ - if(!this.formControlForCheck.get('id')) return []; - - const current = this.options.find(opt=> opt.id === this.formControlForCheck.get('id').value); - - if(current){ - return current.hiddenBy; - } - return []; - } - - getToolTipMessage(id: string){ - if(this.parentIds.includes(id)){ - // return 'Cannot hide element that contain the field'; - return this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.HINTS.ELEMENT-CHILD-OF-TARGET'); - }else if(this.hiddenBy.includes(id)){ - return this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.HINTS.ELEMENT-HIDDEN-FROM-ELEMENT'); - } - return ''; - } - -} - - -interface OptionItem{ - id: string, - label: string, - type: ToCEntryType, - parentsIds: string[], - form:UntypedFormGroup, - hiddenBy:string[] -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html deleted file mode 100644 index d57310531..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html +++ /dev/null @@ -1,173 +0,0 @@ -
-
- - -
-
- -
- - - - - - -
-
- Add Question icon - {{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.NEW-INPUT-SET' | translate}} -
-
-
-
- -
- -
-
-
- -
- - -
- -
- - - - - -
-
-
- - - - - drag_indicator - - - - - -
- -
-
- -
-
-
-
-
- Add Question icon - {{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.NEW-INPUT-SET' | translate}} -
-
-
- - - - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss deleted file mode 100644 index 4870b869e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss +++ /dev/null @@ -1,80 +0,0 @@ -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; - - -.field-container-active{ - border-radius: .3em; - border-left: 0.3em solid $blue-color; -} -.fieldset-actions-list li{ - cursor: pointer; -} -.fieldset{ - .add-question{ - cursor: pointer; - visibility: hidden; - transition-property: visibility; - transition-delay: 20ms; - transition-timing-function: ease; - transition-duration: 200ms; - } -} -.fieldset:hover{ - .add-question{ - visibility: visible; - } -} -.question-icon{ - width: 20px; -} -.stick-list{ - position: sticky; - top: 7em; -} -.actions-list{ - // border: 1px solid $blue-color; - // box-shadow: 0px 3px 12px var(--primary-color)99; - border-radius: 4px; - // padding-top: 1rem; - padding: 1em 0.9em; - padding-bottom: 3em; - min-width: 166px; - box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%); - - .mat-list-item-content{ - padding: 0px; - } - - - .action-list-item{ - display: flex; - align-items: center; - cursor: pointer; - - - .action-list-icon{ - font-size: 1.2em; - // padding-right: 1em; - width: 14px; - margin-right: 0.5em; - margin-left: -.09em; - height: auto; - color: var(--primary-color);; - } - .input_icon{ - width: 14px; - margin-right: .5em; - } - .action-list-text{ - font-size: 0.9em; - } - } - .action-list-label{ - color: #212121; - font-size: small; - opacity: 0.6; - } - .list-unstyled{ - margin-bottom: 0.2rem; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts deleted file mode 100644 index 3e45e2c28..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts +++ /dev/null @@ -1,269 +0,0 @@ -import { OnDestroy } from '@angular/core'; -import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { Guid } from '@common/types/guid'; -import { isNullOrUndefined } from '@swimlane/ngx-datatable'; -import { DragulaService } from 'ng2-dragula'; -import { pipe, Subject, Subscription } from 'rxjs'; -import { debounceTime, delay, tap } from 'rxjs/operators'; -import { FieldEditorModel } from '../../../admin/field-editor-model'; -import { FieldSetEditorModel } from '../../../admin/field-set-editor-model'; -import { ToCEntry, ToCEntryType } from '../../../table-of-contents/table-of-contents-entry'; -import { GENERAL_ANIMATIONS } from '../../animations/animations'; - -@Component({ - selector: 'app-dataset-profile-editor-section-fieldset-component', - templateUrl: './dataset-profile-editor-section-fieldset.component.html', - styleUrls: ['./dataset-profile-editor-section-fieldset.component.scss'], - animations:[GENERAL_ANIMATIONS] -}) - -export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnChanges, OnDestroy { - // @Input() form: FormGroup; - //@Input() dataModel: SectionEditorModel; - // @Input() indexPath: string; - @Input() viewOnly: boolean; - // @Input() numbering: string; - @Input() tocentry: ToCEntry; - - @Input() datasetProfileId?: string; - - @Output() selectedEntryId = new EventEmitter(); - @Output() dataNeedsRefresh = new EventEmitter (); - @Output() removeFieldSet = new EventEmitter(); - @Output() addNewFieldSet = new EventEmitter(); - @Output() cloneFieldSet = new EventEmitter(); - - - // FIELDSET_PREFIX_ID="FIELDSET_PREFIX_ID"; - - // @Output() fieldsetAdded = new EventEmitter(); //returns the id of the fieldset added - idprefix = "id"; - readonly dragula_prefix = "dragulaid"; - private subs = new Subscription(); - private FIELDSETS = 'FIELDSETS'; - - private initializer = new Subject(); - private scroller = new Subject(); - // private $selectedFieldsetId = new Subject(); - constructor( - private dragulaService: DragulaService, - private myElement: ElementRef - ) - { - if(this.dragulaService.find(this.FIELDSETS)){ - this.dragulaService.destroy(this.FIELDSETS); - } - - - this.dragulaService.createGroup(this.FIELDSETS,{ - moves:(el, container, handle)=>{ - // if(this.viewOnly) return false; //uncomment if want to unable drag n drop in viewonly mode - if(el.id != (this.dragula_prefix+this.tocentry.id)) return false; - if(handle.className && handle.classList.contains('handle')) return true; - return false; - } - }); - this.subs.add(this.dragulaService.drop(this.FIELDSETS).subscribe(obs=>{ - - - (this.form.get('fieldSets') as UntypedFormArray).controls.forEach((e,i)=>{ - e.get('ordinal').setValue(i); - }); - - - // obs. - this.dataNeedsRefresh.emit(); - return ; - })); - const initializerSub = this.initializer - .pipe( - debounceTime(100) - ) - .subscribe(() =>{ - this.initialize(); - }); - this.subs.add(initializerSub); - this.subs.add( - this.scroller - .pipe(debounceTime(700)) - .subscribe(id => { - if(isNullOrUndefined(id)){ - this._scrollOnTop(); - return ; - } - this._scrollToElement(id); - }) - ); - - // this.subs.add( - // this.$selectedFieldsetId - // .pipe( - // debounceTime(100) - // ) - // .subscribe(id => this.selectedEntryId.emit(id)) - // ); - - } - ngOnDestroy(){ - // console.log('elemement destroyed -->'); - - this.subs.unsubscribe(); - } - ngOnChanges(changes: SimpleChanges): void { - this.initializer.next(); - } - - - form; - numbering; - - - - private _selectedFieldSetId: string = null; - get selectedFieldSetId(){ - return this._selectedFieldSetId; - } - set selectedFieldSetId(id: string){ - - if(id === this._selectedFieldSetId) return; - this._selectedFieldSetId = id; - this.selectedEntryId.emit(id); - } - - - - - - // private _findParentSection():FormGroup{ - // const parent = this.form.parent; - - // return parent; - // } - - - private initialize(){ - if(this.tocentry.type === ToCEntryType.Section){ - this.form = this.tocentry.form; - this.numbering = this.tocentry.numbering; - this._selectedFieldSetId = null; - - // this.scroller.next(null); - this._scrollOnTop(true); - }else if(this.tocentry.type === ToCEntryType.FieldSet){ - this.form = this.tocentry.form.parent.parent; - const numberingArray = this.tocentry.numbering.split('.'); - if(numberingArray.length){ - numberingArray.splice(numberingArray.length-1); - this.numbering = numberingArray.join('.'); - }else{ - // console.warn('!not found numbering'); - } - this._selectedFieldSetId = this.tocentry.id; - - // this._scrollToElement(this.selectedFieldSetId); - this.scroller.next(this.tocentry.id); - }else{//scroll on top - // this._scrollOnTop(); - this.scroller.next(null); - } - } - - private _scrollToElement(id: string){ - let el = this.myElement.nativeElement.querySelector("#"+this.idprefix+id); - if(el){ - el.scrollIntoView({behavior: "smooth", block:'start'}); - } - } - private _scrollOnTop(instant?: boolean){ - const el = this.myElement.nativeElement.querySelector('#topofcontainer'); - if(el){ - if(instant){ - el.scrollIntoView({ block:'end'}); - }else{ - el.scrollIntoView({behavior:'smooth', block:'end'}); - } - } - } - ngOnInit() { - - } - - onRemoveFieldSet(fieldsetId: string){ - this.removeFieldSet.emit(fieldsetId); - } - - onCloneFieldSet(fieldset: UntypedFormGroup){ - this.cloneFieldSet.emit(fieldset); - } - onAddFieldSet(){ - // this.addNewFieldSet.emit(this.form); - try{ - const length = (this.form.get('fieldSets') as UntypedFormArray).length; - if(length === 0){ - this.addFieldSetAfter(-9999, 0); - return; - } - else{ - const lastElement = (this.form.get('fieldSets') as UntypedFormArray).at(length -1); - this.addFieldSetAfter(lastElement.get('ordinal').value, length-1); - } - } catch {} - } - - addFieldSetAfter(afterOrdinal: number, afterIndex: number):void{ - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first filed in the fields list - const fieldForm = field.buildForm(); - - //give fieldset id and ordinal - const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); - const fieldSetId = Guid.create().toString(); - fieldSet.id = fieldSetId; - fieldSet.ordinal = afterOrdinal < 0? 0 :afterOrdinal; - - const parentArray = this.form.get('fieldSets') as UntypedFormArray; - - parentArray.controls.forEach(fieldset=>{ - const ordinalControl = fieldset.get('ordinal'); - const ordinalValue = ordinalControl.value; - if(ordinalValue > afterOrdinal){ - ordinalControl.setValue(ordinalValue +1); - } - }); - const fieldsetForm = fieldSet.buildForm(); - (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); - - const index = afterOrdinal < 0 ? 0: afterIndex +1; - parentArray.insert(index, fieldsetForm); - this.dataNeedsRefresh.emit(); - - // this.selectedFieldSetId = fieldSetId; - setTimeout(() => { - this.selectedFieldSetId = fieldSetId; - }, 200); - } - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html deleted file mode 100644 index 391dd4238..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html +++ /dev/null @@ -1,95 +0,0 @@ -
- - - - - -
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-NAME' | translate}} *
-
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-NAME-HINT' | translate}}
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - -
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION' | translate}}
-
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION-HINT' | translate}}
-
- - -
- - - - - - - - - - - - - - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss deleted file mode 100644 index 7645fb831..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss +++ /dev/null @@ -1,31 +0,0 @@ -.dataset-profile-editor { - - - .field-card { - margin-bottom: 1em; - } -} -.deleteBtn{ - margin-right:2em; -} - -.heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - // margin-top: 1.625rem; - margin-bottom: 0.625rem; -} - -.hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 0.125rem; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts deleted file mode 100644 index c608c731b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { FieldEditorModel } from '@app/ui/admin/dataset-profile/admin/field-editor-model'; -import { FieldSetEditorModel } from '@app/ui/admin/dataset-profile/admin/field-set-editor-model'; -import { SectionEditorModel } from '@app/ui/admin/dataset-profile/admin/section-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { Guid } from '@common/types/guid'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-editor-section-component', - templateUrl: './dataset-profile-editor-section.component.html', - styleUrls: ['./dataset-profile-editor-section.component.scss'] -}) - -export class DatasetProfileEditorSectionComponent extends BaseComponent implements OnInit { - - @Input() form: UntypedFormGroup; - //@Input() dataModel: SectionEditorModel; - @Input() indexPath: string; - @Input() viewOnly: boolean; - @Output() fieldsetAdded = new EventEmitter(); //returns the id of the fieldset added - - constructor() { super(); } - - ngOnInit() { - - //TODO - // this.form.root.get('pages').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => - // this.keepPageSelectionValid(x) - // ); - } - - addField() { - const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); - fieldSet.ordinal = (this.form.get('fieldSets') as UntypedFormArray).length; - - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first field in fields - fieldSet.fields.push(field); - // if (this.dataModel.fieldSets) { - fieldSet.id = Guid.create().toString(); - //this.dataModel.fieldSets.push(fieldSet); - //} - const fieldsetsArray = this.form.get('fieldSets') as UntypedFormArray; - fieldsetsArray.push(fieldSet.buildForm()); - - const fieldSetForm = fieldsetsArray.at(fieldsetsArray.length-1); - //emit id inserted - if(fieldSetForm){ - const id: string = fieldSetForm.get('id').value; - this.fieldsetAdded.emit(id); - } - } - - addSectioninSection() { - const section: SectionEditorModel = new SectionEditorModel(); - //this.dataModel.sections.push(section); - (this.form.get('sections')).push(section.buildForm()); - } - - DeleteSectionInSection(index) { - //this.dataModel.sections.splice(index, 1); - (this.form.get('sections')).removeAt(index); - } - - deleteFieldSet(index) { - //this.dataModel.fieldSets.splice(index, 1); - (this.form.get('fieldSets')).removeAt(index); - } - - keepPageSelectionValid(pagesJson: Array) { - const selectedPage = this.form.get('page').value as String; - // const pages: Array = JsonSerializer.fromJSONArray(pagesJson, Page); - if (pagesJson.find(elem => elem.id === selectedPage) === undefined) { - this.form.get('page').reset(); - } - } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts deleted file mode 100644 index 94649b0bc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Inject, Injectable } from "@angular/core"; -import { AbstractControl, UntypedFormArray, ValidationErrors, ValidatorFn } from "@angular/forms"; - - -export class EditorCustomValidators{ - - static atLeastOneElementListValidator(arrayToCheck): ValidatorFn{ - return (control: AbstractControl): ValidationErrors | null=>{ - - const fa = control.get(arrayToCheck) as UntypedFormArray; - - if(!fa || fa.length === 0){ - return {[EditorCustomValidatorsEnum.emptyArray]: true}; - } - return null; - } - } - static pagesHaveAtLeastOneSection(pagesArrayName:string,sectionsArrayName:string ): ValidatorFn{ - - return (control: AbstractControl): ValidationErrors | null=>{ - - const pages = control.get(pagesArrayName) as UntypedFormArray; - const sections = control.get(sectionsArrayName) as UntypedFormArray; - - - const pageIdsArray = pages.controls.map(page=>page.get('id').value); - const sectionsPageIds = sections.controls.map(section=> section.get('page').value); - - let invalidMessage = null; - - pageIdsArray.forEach(pageId=>{ - if(!sectionsPageIds.includes(pageId)){ - invalidMessage = {[EditorCustomValidatorsEnum.atLeastOneSectionInPage]:true}; - } - }) - - return invalidMessage; - } - } - - static sectionHasAtLeastOneChildOf(fieldsetsArrayName, sectionsArrayName): ValidatorFn{ - - return (control: AbstractControl): ValidationErrors | null=>{ - - const fieldsets = control.get(fieldsetsArrayName) as UntypedFormArray; - const sections = control.get(sectionsArrayName) as UntypedFormArray; - - - if((fieldsets && fieldsets.length) || (sections && sections.length)){ - return null; - } - - return {[EditorCustomValidatorsEnum.sectionMustHaveOneChild] : true}; - } - } - - - -} - - - -export enum EditorCustomValidatorsEnum{ - sectionMustHaveOneChild = "sectionMustHaveOneChild", - atLeastOneSectionInPage = 'atLeastOneSectionInPage', - emptyArray="emptyArray" -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts deleted file mode 100644 index 4cd0066cf..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { UntypedFormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DatasetProfile } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { PageEditorModel } from '../admin/page-editor-model'; -import { SectionEditorModel } from '../admin/section-editor-model'; -import { EditorCustomValidators } from './custom-validators/editor-custom-validators'; - - -export class DatasetProfileEditorModel extends BaseFormModel { - - public sections: Array = new Array(); - public pages: Array = new Array(); - public label: string; - public status: number; - public version: number; - private description: string; - private type: string; - private language: string; - private users: UserInfoListingModel[] = []; - - fromModel(item: DatasetProfile): DatasetProfileEditorModel { - if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } - if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); } - this.label = item.label; - this.type = item.type; - this.status = item.status; - this.version = item.version; - this.description = item.description; - this.language = item.language; - this.users = item.users; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.label')) }, [Validators.required]], - description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.type')) }, [Validators.required]], - language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]], - status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }], - version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }], - users: [{ value: this.users, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.users')) }] - }); - - const sectionsFormArray = new Array(); - this.sections.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - sectionsFormArray.push(form); - }); - formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - - const pagesFormArray = new Array(); - this.pages.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - pagesFormArray.push(form); - }); - formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); - - formGroup.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages','sections')]); - formGroup.updateValueAndValidity(); - - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html deleted file mode 100644 index b943a4bb1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ /dev/null @@ -1,522 +0,0 @@ - - -
-
- - - - - -
-
-
- -
-

{{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE' | translate}}

-

- {{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE-CLONE' | translate}} - {{form.get('label').value}} -

-

- {{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE-VERSION' | translate}} - {{form.get('label').value}} -

- -

{{form.get('label').value}}

-
- - - - -
-
- -
- - - -
-
- - - - - - -
-
-
-
- - - done - - - {{idx+1}} - - {{step.label}} - -
-
-
- - - - - - - - -
-
-
-
- - - - - - - - - -
-
-
-
1.1 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NAME'| translate}} *
-
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NAME-HINT'| translate}}
- - - {{'GENERAL.VALIDATION.REQUIRED' | - translate}} - - -
-
-
1.2 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-DESCRIPTION'| translate}} *
- -
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-DESCRIPTION-HINT'| translate}}
-
- - -
- - {{'GENERAL.VALIDATION.REQUIRED'| translate}} - -
-
-
- -
-
1.3 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-TYPE'| translate}} *
- - - - {{ type.name }} - - - {{'GENERAL.VALIDATION.REQUIRED' | - translate}} - - -
-
- -
1.4 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-LANGUAGE'| translate}} *
- - - - - {{ lang.name }} - - - {{'GENERAL.VALIDATION.REQUIRED' | - translate}} - - -
-
-
1.5 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}
-
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS-HINT'| translate}}
-
- - - - - - - - - - - - - - - - - - -
{{'USERS.LISTING.NAME' | translate}}{{'USERS.LISTING.EMAIL' | translate}}
{{user.name}}{{user.email}} - -
- {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NO-USERS-YET' | translate}} -
-
-
- -
-
-
-
- - - -
-
- -
- -
-
-
- -
- - - -
-
- - -
- - -
- - -
- - -
-
- - - -
- -
- -
-
- - -
-
-
- -
-
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME' | translate}} *
-
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME-HINT' | translate}}
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
- -
- - -
- -
-
- -
- - - -
- - -
- -
-
-
-
- {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.NOTHING-HERE-HINT'| translate}} -
-
-
-
- {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-START'| translate}} - - add - - {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-END'| translate}} - -
-
-
-
- -
-
-
- - -
-
- - - - -
-
-
- - - -
-
-
- - - -
-
- -
- - - - - - - - - - - - - - - arrow_upward - -
SCROLL
-
- - -
- - -
-
- - - - - - - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss deleted file mode 100644 index cd066b05f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss +++ /dev/null @@ -1,386 +0,0 @@ -.dataset-profile-editor { - //margin-top: 1.3rem; - - .full-width { - width: 100%; - } -} - -.deleteBtn{ - margin-right:2em; -} - - - -// REFACTORED CSS - -.stepper{ - background-color: transparent; - min-height: 500px; -} -.content-displayer{ - background-color: #fff; - border-radius: 7px; - box-shadow: 0px 1px 2px #bfbfbf; - padding: 0em; - // padding-top: 0em; - overflow: visible; - // min-height: 30em; -} - -.heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - // margin-top: 1.625rem; - margin-bottom: 0.625rem; -} - -.hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 0.125rem; -} - -//TO CHECK -:host ::ng-deep .mat-horizontal-content-container { - overflow: visible; - // padding: 0px; -} -:host ::ng-deep .mat-form-field-outline{ - background-color: #ffffff4f; -} - -:host ::ng-deep .mat-horizontal-stepper-header-container { - display: none !important; -} - -#progress{ - position: absolute; - height: 100%; - width: 100%; - clip-path: polygon(0 0, 0 0, 0 0, 0 0); - transition-property: clip-path; - transition-duration: 600ms; - transition-timing-function: ease-out; - transition-delay: 50ms; - box-shadow: 0px 1px 2px #bfbfbf; - background-color: var(--secondary-color); -} -#progress-container{ - box-shadow: 1px 1px 6px #00000029;; - // border-radius: .3em; -} -// .import-btn { -// background: #ffffff 0% 0% no-repeat padding-box; -// border-radius: 30px; -// // color: var(--primary-color); -// // border: 1px solid var(--primary-color); -// padding-left: 2em; -// padding-right: 2em; -// color: #000; -// border: 1px solid #000; -// } -.navigate-btn { - border-radius: 30px; - background-color: var(--secondary-color); - border: 1px solid transparent; - padding-left: 2em; - padding-right: 2em; - box-shadow: 0px 3px 6px #1E202029; - - transition-property: background-color, color; - transition-duration: 200ms; - transition-delay: 50ms; - transition-timing-function: ease-in-out; -} -.navigate-btn-disabled{ -background-color: #CBCBCB; -color: #FFF; -} - -.create-section-btn { - border-radius: 30px; - background-color: var(--secondary-color); - border: 1px solid transparent; - padding-left: 1em; - padding-right: 1em; - box-shadow: 0px 3px 6px #1E202029; - line-height: 1.7em; -} - - -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; - -.finalize-btn { - border-radius: 30px; - border: 1px solid var(--primary-color); - background: transparent; - padding-left: 2em; - padding-right: 2em; - box-shadow: 0px 3px 6px #1E202029; - color: var(--primary-color); -} -.template_action_btn{ - border-radius: 30px; - border: 1px solid var(--primary-color); - background: transparent; - //padding-left: 2em; - //padding-right: 2em; - height: 2.5em; - min-width: 110px; - width: auto; - box-shadow: 0px 3px 6px #1E202029; - color: var(--primary-color); - flex: 0 0 auto; - &.save-btn{ - background-color: var(--secondary-color); - border: 1px solid transparent; - //padding-left: 2em; - //padding-right: 2em; - box-shadow: 0px 3px 6px #1E202029; - color: #212121; - - transition-property: background-color, color; - transition-duration: 200ms; - transition-delay: 50ms; - transition-timing-function: ease-in-out; - } - &:disabled{ - background-color: #CBCBCB; - color: #FFF; - border: 0px; - } -} - - - - -.stepper-title-label{ - cursor: pointer; - transition-property: color, opacity; - transition-duration: 200ms; - transition-delay: 50ms; - transition-timing-function: ease-in-out; - color: #212121; - font-size: 0.9em; -} - -.stepper-title-label-locked{ - color: #DEDEDE; -} - -.stepper-title-label-completed{ - opacity: 0.5; -} -.page-infos{ - padding: 2em; -} -.mat-subheader{ - padding: 0px; -} - -//for the acitons list toolbar -// .mat-list-item.mat-list-item-with-avatar{ -// padding-left: 0em; -// } - - -.actions-list{ - // border: 1px solid $blue-color; - box-shadow: 0px 3px 12px var(--primary-color)99; - border-radius: 4px; - // padding-top: 1rem; - padding: 1em 0.9em; - min-width: 166px; - - .mat-list-item-content{ - padding: 0px; - } - - - .action-list-item{ - display: flex; - align-items: center; - cursor: pointer; - - - .action-list-icon{ - font-size: 1.2em; - // padding-right: 1em; - width: 14px; - margin-right: 0.5em; - margin-left: -.09em; - height: auto; - color: var(--primary-color);; - } - .input_icon{ - width: 14px; - margin-right: .5em; - } - .action-list-text{ - font-size: 0.9em; - } - } - .action-list-label{ - color: #212121; - font-size: small; - opacity: 0.6; - } - .list-unstyled{ - margin-bottom: 0.2rem; - } -} - - -// .mli{ -// height: auto; -// } - - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -.basic-info-input{ - margin-top: 2em; - margin-bottom: 2em; -} - -.delete-btn { - // background-color: rgba(255, 0, 0, 0.76); - // color: white; -} - -.email-input { - border-color: black; - border-style: solid; - border-width: thin; - border-radius: 4px; - margin-right: 5px; - background-color: white; - padding-top: 10px; - padding-bottom: 10px; -} - - -.user-table { - // border: thin solid rgb(179, 173, 173); - // border: 1px solid rgba(0, 0, 0, 0.12); - background-color: white; - border-radius: 4px; - padding-bottom: 1em; - box-shadow: -1px 1px 11px -3px #00000017; -} - -.user-table-header { - text-align: center; - display: revert; - background-color: rgb(243 245 248); - // background-color: #129d9811; -} - -.user-table-header th { - padding-top: 10px; - padding-bottom: 10px; - // border: thin solid darkgray; -} - -.user-table-row { - // display: revert; - background-color: #fafafa; - td{ - padding-top: .5em; - padding-bottom: .5em; - } - &:hover{ - background-color: #eef5f6; - } - border-top:1px solid rgba(0, 0, 0, 0.12); -} - -.user-table-row:nth-child(even) { - // background-color: silver; -} -.user-table-body{ - text-align: center; -} -.scroll-on-top{ - position: fixed; - bottom: 20em; - right: 2em; - color: var(--primary-color) !important; - cursor: pointer; - font-size: 1rem; - font-weight: 400; -} - -.floating-btn { - position: fixed; - bottom: 2em; - right: 2em; -} - -.progress-min-height { - min-height: 35px; -} - - -#stepper-navigation-wrapper{ - z-index: 99; - width: 100%; - #stepper-navigation{ - background-color: #f4f4f4; - z-index: 99; - } -} - -.actions-template{ - align-self:flex-end; - display: flex; - justify-content: space-between; - width: 100%; - padding-left: 15px; - padding-right: 15px; -} -.stepper-navigation-outer-wrapper{ - padding: 2em; - margin-bottom: 1em; - //background: #f4f4f4; - //position: sticky; - //top: 0.01em; - //z-index: 9999; -} - -#header-outer-wrapper { - padding-top: 1.3rem; - background: #f4f4f4; - position: sticky; - top: 0.01em; - z-index: 9999; -} - -#title-column{ - justify-content: space-between; - align-items: baseline; - padding-right: 15px; -} -.side-actions{ - display: flex; - height: 40vh; - position: sticky; - top: 2em; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts deleted file mode 100644 index 75a254984..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ /dev/null @@ -1,2142 +0,0 @@ - -import { of as observableOf, Observable, combineLatest, BehaviorSubject,of } from 'rxjs'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { Component, OnInit, QueryList, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatStepper} from '@angular/material/stepper'; -import { ActivatedRoute, ParamMap, Router } from '@angular/router'; -import { TranslateService } from '@ngx-translate/core'; -import { debounceTime, filter, map, mergeMap, takeUntil, tap } from 'rxjs/operators'; -import * as FileSaver from 'file-saver'; -import { BaseComponent } from '@common/base/base.component'; -import { DatasetProfileEditorModel } from '@app/ui/admin/dataset-profile/editor/dataset-profile-editor-model'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { LoggingService } from '@app/core/services/logging/logging-service'; -import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; -import { DatasetProfile } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { DatasetProfileEnum } from '@app/core/common/enum/dataset-profile'; -import { SectionEditorModel } from '@app/ui/admin/dataset-profile/admin/section-editor-model'; -import { PageEditorModel } from '@app/ui/admin/dataset-profile/admin/page-editor-model'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { LanguageInfo } from '@app/core/model/language-info'; -import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; -import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { NewEntryType, ToCEntry, ToCEntryType } from '../table-of-contents/table-of-contents-entry'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FieldSetEditorModel } from '../admin/field-set-editor-model'; -import { Guid } from '@common/types/guid'; -import { FieldEditorModel } from '../admin/field-editor-model'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; -import { CdkStep, StepperSelectionEvent } from '@angular/cdk/stepper'; -import { DatasetDescriptionCompositeFieldEditorModel, DatasetDescriptionFieldEditorModel, DatasetDescriptionSectionEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { SideNavService } from '@app/core/services/sidenav/side-nav.sevice'; -import { EditorCustomValidators, EditorCustomValidatorsEnum } from './custom-validators/editor-custom-validators'; -import { GENERAL_ANIMATIONS, STEPPER_ANIMATIONS } from './animations/animations'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { MatInput } from '@angular/material/input'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service'; -import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type'; -import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status'; -import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template-type.lookup'; -import { nameof } from 'ts-simple-nameof'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; - -const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json'); - -@Component({ - selector: 'app-dataset-profile-editor-component', - templateUrl: './dataset-profile-editor.component.html', - styleUrls: ['./dataset-profile-editor.component.scss'], - animations:[...STEPPER_ANIMATIONS, ...GENERAL_ANIMATIONS], - providers:[VisibilityRulesService] -}) -export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent implements OnInit { - - canDeactivate(): boolean { - return !this.form.dirty; - } - - isNew = true; - isNewVersion = false; - isClone = false; - isDeleted = false; - dataModel: DatasetProfileEditorModel; - form: UntypedFormGroup; - previewerFormGroup: UntypedFormGroup; - private datasetProfileId: string; - newVersionId: string; - dataWizardModel: DatasetWizardModel; - // breadCrumbs: Observable; - @ViewChild('stepper') stepper: MatStepper; - viewOnly = false; - nestedCount: number[] = []; - nestedIndex: number = 0; - errorMessages: string[] = []; - tocEntryEnumValues = ToCEntryType; - public userChipList:any[] = []; - displayedColumns: String[] = ['name', 'email', 'button']; - descriptionTemplateTypes: DescriptionTemplateType[] = []; - - colorizeInvalid:boolean = false; - inputUserState: 'untriggered'| 'triggered' = 'untriggered'; - private _inputUserField$:BehaviorSubject = new BehaviorSubject(false); - private _inputUserButton$:BehaviorSubject = new BehaviorSubject(false); - showScrollOnTopButton:boolean = true; - - private stepperNavigationObserver: IntersectionObserver; - - // customEditorValidators = new EditorCustomValidators(); - - // sectionIdPreviewed:string = null; - // currentSubForm:FormGroup = null; - // currentSectionIndex: number = null; - // currentSectionEditorModel: SectionEditorModel = null; - - constructor( - private datasetProfileService: DatasetProfileService, - private route: ActivatedRoute, - private router: Router, - private logger: LoggingService, - private uiNotificationService: UiNotificationService, - private language: TranslateService, - private dialog: MatDialog, - private languageInfoService: LanguageInfoService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private enumUtils: EnumUtils, - private datasetWizardService: DatasetWizardService, - private visibilityRulesService: VisibilityRulesService, - private fb: UntypedFormBuilder, - private sidenavService: SideNavService, - private userService: UserServiceOld, - private descriptionTemplateTypeService: DescriptionTemplateTypeService, - private fileUtils: FileUtils - ) { - super(); - // this.profileID = route.snapshot.params['id']; - // this.cloneId = route.snapshot.params['cloneid']; - } - - ngOnDestroy(){ - this.sidenavService.setStatus(true); - if(this.stepperNavigationObserver){ - this.stepperNavigationObserver.disconnect(); - this.stepperNavigationObserver = null; - } - } - - ngOnInit() { - this.sidenavService.setStatus(false); - this.matomoService.trackPageView('Admin: Dataset Profile Edit'); - this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((paramMap: ParamMap) => { - this.datasetProfileId = paramMap.get('id'); - const cloneId = paramMap.get('cloneid'); - this.newVersionId = paramMap.get('newversionid'); - - if (this.datasetProfileId != null) { - this.isNew = false; - this.datasetProfileService.getDatasetProfileById(this.datasetProfileId) - .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) - .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - this.form = this.dataModel.buildForm(true, skipDisable); - this.viewOnly = true; - } else { - this.form = this.dataModel.buildForm(); - } - this.prepareForm(); - } catch (error) { - this.logger.error('Could not parse MasterItem: ' + data); - console.log(error) - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) - ); - // this.breadCrumbs = observableOf([{ - // parentComponentName: 'DatasetProfileListingComponent', - // label: this.language.instant('NAV-BAR.TEMPLATE'), - // url: '/dataset-profiles/' + this.datasetProfileId - // }]); - } else if (cloneId != null) { - this.isClone = true; - this.datasetProfileService.clone(cloneId) - .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) - .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.dataModel.status = DatasetProfileEnum.SAVED; - this.form = this.dataModel.buildForm(); - this.prepareForm(); - } catch (error){ - this.logger.error('Could not parse MasterItem: ' + data); - this.logger.error(error); - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) - ); - } else if (this.newVersionId != null) { - this.isNewVersion = true; - this.datasetProfileService.getDatasetProfileById(this.newVersionId) - .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) - .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.form = this.dataModel.buildForm(); - this.form.get('version').setValue(this.form.get('version').value + 1); - // this.form.controls['label'].disable(); - // this.form.controls['description'].disable(); - // this.form.controls['language'].disable(); - this.prepareForm(); - } catch (error){ - this.logger.error('Could not parse MasterItem: ' + data); - this.logger.error(error); - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) - ); - } else { - this.dataModel = new DatasetProfileEditorModel(); - this.form = this.dataModel.buildForm(); - // this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]); - - if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - this.form.disable(); - this.viewOnly = true; - } - // this.addSection(); - // this.addPage(); - this.visibilityRulesService.buildVisibilityRules([],this.form); - setTimeout(() => { - this.steps = this.stepper.steps; - }); - this._initializeToCEntries(); - - } - }); - - this.getDescriptionTemplateTypes(); - - combineLatest(this._inputUserButton$.asObservable(),this._inputUserField$.asObservable()) - .pipe(takeUntil(this._destroyed)) - .pipe(debounceTime(400)) - .pipe(filter(_=> !_[0] && !_[1])) - .subscribe(_=>{ - // if(!this.userFormDisabled) - this.inputUserState = 'untriggered'; - }); - } - - private _initializeToCEntries(){ - const tocentries = this.refreshToCEntries();//tocentries are sorted based on their ordinal value - - this._updateOrdinals(tocentries); - - if(tocentries && tocentries.length){ - this.selectedTocEntry = tocentries[0]; - } - // setTimeout(() => { - // // const stepperNavigation = document.getElementById('stepper-navigation'); - // // const titleColumn = document.getElementById('title-column'); - // // const stepperNavigationWrapper = document.getElementById('stepper-navigation-wrapper'); - // - // if(titleColumn){ - // if(this.stepperNavigationObserver){ - // this.stepperNavigationObserver.disconnect(); - // this.stepperNavigationObserver = null; - // } - // this.stepperNavigationObserver = new IntersectionObserver((e)=>{ - // e.forEach(_=>{ - // if(_.isIntersecting){ - // this.showScrollOnTopButton = false; - // // stepperNavigation.classList.remove('fixed-navigation'); - // // stepperNavigationWrapper.classList.remove('fixed-navigation'); - // }else{ - // this.showScrollOnTopButton = true; - // // stepperNavigation.classList.add('fixed-navigation'); - // // stepperNavigationWrapper.classList.add('fixed-navigation'); - // } - // }) - // }, {root:null, rootMargin:'0px', threshold:0}); - // this.stepperNavigationObserver.observe(titleColumn); - // }else{ - // console.log('Could not load scroll On Top Observer') - // } - // }, 400); - // this._initializeFormValidity(tocentries); - - //Checking invalid visibilty RULES - const fieldsetEntries = this._getAllFieldSets(this.toCEntries); - const fieldSetHavingInvalidVisibilityRules:ToCEntry[] = fieldsetEntries - .filter(entry=>{ - const fieldsFormGroup = entry.form.get('fields'); - const invalid = (fieldsFormGroup as UntypedFormArray).controls.filter(field=>{ - return this.hasInvalidVisibilityRule(field as UntypedFormGroup); - - }); - if(invalid && invalid.length){ - return true; - } - return false; - }); - - - if(fieldSetHavingInvalidVisibilityRules.length){ - const occurences = fieldSetHavingInvalidVisibilityRules.map(record=>record.numbering).join(' , '); - this.dialog.open(ConfirmationDialogComponent, { - data:{ - message: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.MESSAGE-START')+occurences+ this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.MESSAGE-END'), - confirmButton: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.CONFIRM-YES'), - cancelButton: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.CONFIRM-NO') - }, - maxWidth:'30em' - }) - .afterClosed() - .subscribe(confirm=>{ - if(confirm){ - this.removeFieldSetVisibilityRules(fieldSetHavingInvalidVisibilityRules); - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.REMOVE-SUCCESS'), SnackBarNotificationLevel.Success); - - }else{ - console.log('User not confirmed'); - } - }) - } - - - } - - private removeFieldSetVisibilityRules(fieldsets:ToCEntry[]){ - - if(!fieldsets || !fieldsets.length) return; - - fieldsets.forEach(fieldset=>{ - if(fieldset.type != ToCEntryType.FieldSet){ - return; - } - const fields = fieldset.form.get('fields') as UntypedFormArray; - - fields.controls.forEach(fieldControl=>{ - if(this.hasInvalidVisibilityRule(fieldControl as UntypedFormGroup)){ - try{ - (fieldControl.get('visible').get('rules') as UntypedFormArray).clear(); - }catch{} - } - }) - - }) - - } - - private hasInvalidVisibilityRule(field: UntypedFormGroup):boolean{ - const renderStyle = field.get('viewStyle').get('renderStyle').value; - if(renderStyle && ![ - DatasetProfileFieldViewStyle.TextArea, - DatasetProfileFieldViewStyle.RichTextArea, - DatasetProfileFieldViewStyle.Upload, - DatasetProfileFieldViewStyle.FreeText, - DatasetProfileFieldViewStyle.BooleanDecision, - DatasetProfileFieldViewStyle.RadioBox, - DatasetProfileFieldViewStyle.CheckBox, - DatasetProfileFieldViewStyle.DatePicker, - DatasetProfileFieldViewStyle.ComboBox, - ].includes(renderStyle)){ - if(((renderStyle === DatasetProfileFieldViewStyle) && (field.get('data').get('type').value === DatasetProfileComboBoxType.WordList))){ - return false; - } - try{ - if(field.get('visible').get('rules').value.length){ - return true; - } - return false; - - }catch{ - return false; - } - }else{ - return false; - } - } - - - prepareForm() { - this.visibilityRulesService.buildVisibilityRules([],this.form); - // this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'),EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]); - // this.form.updateValueAndValidity(); - this.form.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(change => { - - // this.datasetProfileService.preview(this.form.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(dataset => { - // const datasetModel = new DatasetWizardModel(); - // datasetModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(dataset, DatasetProfileDefinitionModel); - // this.dataWizardModel = datasetModel; - // this.previewerFormGroup = this.dataWizardModel.buildForm().get('datasetProfileDefinition'); - // }); - }); - setTimeout(() => { - this.steps = this.stepper.steps; - }); - this._initializeToCEntries(); - // console.log(this.form.get('users').value); - if (this.form.get('users').value !== null && this.form.get('users').value !== undefined) { - this.userChipList = [...this.form.get('users').value]; - } else { - this.userChipList = []; - } - - } - - onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { - if (!isMultiplicityEnabled) { - (this.form.get('multiplicity').get('min')).setValue(0); - (this.form.get('multiplicity').get('max')).setValue(0); - } - } - - // addSection() { - // const section: SectionEditorModel = new SectionEditorModel(); - // this.dataModel.sections.push(section); - // (this.form.get('sections')).push(section.buildForm()); - // } - - // addPage() { - // const page: PageEditorModel = new PageEditorModel(this.dataModel.pages.length); - // this.dataModel.pages.push(page); - // (this.form.get('pages')).push(page.buildForm()); - // } - - // DeleteSection(index) { - // this.dataModel.sections.splice(index, 1); - // (this.form.get('sections')).removeAt(index); - // } - - onSubmit(close: boolean = false) { - let data = this.form.value; - - if (this.datasetProfileId) { - this.datasetProfileService.updateForm(this.datasetProfileId, data) - .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - this.afterSave(); - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); - },error=> this.onCallbackError(error)); - } else if (this.newVersionId) { - data.label = this.form.get('label').value; - data.description = this.form.get('description').value; - this.datasetProfileService.newVersion(this.newVersionId, data) - .pipe(takeUntil(this._destroyed)) - .subscribe((newVersionTemplateId: string) => { - this.afterSave(newVersionTemplateId); - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); - }, - error => this.onCallbackErrorNewVersion(error) - ); - } else { - if(this.form.get('status').value != DatasetStatus.Finalized){// forn created and finalized instantly - this.form.get('status').setValue(DatasetStatus.Draft); - } - data = this.form.value; - this.datasetProfileService.createForm(data) - .pipe(takeUntil(this._destroyed)) - .subscribe(newTemplateId => { - this.afterSave(newTemplateId); - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); - }, error=> this.onCallbackError(error)); - } - } - - afterSave(newId: string = null) { - if(newId) { - this.datasetProfileId = newId; - this.form.value.id = newId; - } - this.isNew = false; - this.newVersionId = null; - - // this.dataModel.fromModel(this.form.value); - // if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - // this.form = this.dataModel.buildForm(true, skipDisable); - // this.viewOnly = true; - // } else { - // this.form = this.dataModel.buildForm(); - // } - // this.prepareForm(); - } - - finalize() { - //const data = this.form.value; - this.form.get('status').setValue(DatasetProfileEnum.FINALIZED); - - this.onSubmit(true); - } - - updateFinalized(close: boolean = false) { - this.datasetProfileService.updateForm(this.datasetProfileId, this.form.getRawValue()) - .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success) - },error=>this.onCallbackError(error)); - } - - showUpdateButton() { - return !this.isNew && this.dataModel.status === DatasetProfileEnum.FINALIZED; - } - - // isStepActive(step: number) { - // return this.stepper && this.stepper.selectedIndex === step; - // } - - // onCallbackSuccess(): void { - // this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - // this.router.navigate(['/master-items']); - // } - - onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) { - this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error); - } - - onCallbackError(errorResponse: HttpErrorResponse) { - // const error: HttpError = this.httpErrorHandlingService.getError(errorResponse); - // if (error.statusCode === 400) { - // this.masterItem.validationErrorModel.fromJSONObject(errorResponse.error); - // this.formService.validateAllFormFields(this.formGroup); - // } else { - this.uiNotificationService.snackBarNotification(errorResponse.message, SnackBarNotificationLevel.Warning); - // } - } - - // DELETE Function - public delete(): void { - if (this.datasetProfileId && !this.isNew) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - //this.form.get('status').setValue(DatasetProfileEnum.DELETED); - this.datasetProfileService.delete(this.datasetProfileId, this.form.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/dataset-profiles']); - }, - error => { - this.onCallbackError(error); - if (error.error.statusCode == 674) { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - } - } - ); - } - }); - } - } - - downloadXML(): void { - this.datasetProfileService.downloadXML(this.datasetProfileId) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - }); - } - - getDescriptionTemplateTypes(): DescriptionTemplateType[] { - let lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup(); - lookup.project = { - fields: [ - nameof(x => x.id), - nameof(x => x.name), - nameof(x => x.status) - ] - }; - this.descriptionTemplateTypeService.query(lookup).pipe(takeUntil(this._destroyed)) - .subscribe(types => { - this.descriptionTemplateTypes = types.items.filter(type => type.status === DescriptionTemplateTypeStatus.Finalized); - }); - return this.descriptionTemplateTypes; - } - - getLanguageInfos(): LanguageInfo[] { - return this.languageInfoService.getLanguageInfoValues(); - } - - checkFormValidation() { - this.colorizeInvalid = true; - this.printMyErrors(this.form); - - - // if (!this.form.valid) { - // this.nestedIndex = -1; - // this.form.markAllAsTouched(); - // this.printErrors(this.form); - // this.showValidationErrorsDialog(); - // this.nestedCount = []; - // this.nestedIndex = 0; - // this.errorMessages = []; - // } - } - - - //BEFORE REDESIGN - // printErrors(rootform: FormGroup) { - // if (!rootform.valid) { - // Object.keys(rootform.controls).forEach(key => { - // const errors = rootform.get(key).errors; - // if (errors !== null) { - // let numbering: string = ''; - // for (let j = 0; j < this.nestedCount.length; j++) { - // numbering += this.nestedCount[j]; - // if (j < this.nestedIndex) { - // numbering += '.'; - // } else { - // break; - // } - // } - // Object.keys(errors).forEach(keyError => { - // if (typeof errors[keyError] === 'boolean') { - // this.errorMessages.push(numbering + ' ' + key + ' is ' + keyError); - // } else { - // this.errorMessages.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); - // } - // }); - // } else { - // if (rootform.get(key) instanceof FormGroup) { - // this.printErrors(rootform.get(key)); - // } else if (rootform.get(key) instanceof FormArray) { - // this.nestedIndex++; - // this.nestedCount[this.nestedIndex] = 0; - // for (let childForm of (rootform.get(key)).controls) { - // this.nestedCount[this.nestedIndex]++; - // this.printErrors(childForm); - // } - // this.nestedCount[this.nestedIndex] = 0; - // this.nestedIndex--; - - // } - // } - // }); - // } - // } - - // private showValidationErrorsDialog(projectOnly?: boolean) { - // const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - // disableClose: true, - // autoFocus: false, - // restoreFocus: false, - // data: { - // errorMessages: this.errorMessages, - // projectOnly: projectOnly - // }, - // }); - // } - - - - - - - // links: Link[] = []; - - // getLinks(currentLinks: Link[]) { - // this.links = currentLinks; - // } - - - datasetWizardModel: DatasetWizardEditorModel; - formGroup: UntypedFormGroup; - getPreview() { - let data = this.form.getRawValue(); - this.datasetProfileService.preview(data).subscribe(x => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel({ - datasetProfileDefinition: x - }); - this.updateVisibilityRules(); - this.formGroup = this.datasetWizardModel.buildForm().get('datasetProfileDefinition'); - }); - //this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - //this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - // this.formGroup.disable(); - // this.viewOnly = true; - // } - //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - // this.registerFormListeners(); - // this.dmpValueChanged(null); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('DATASET-LISTING.ACTIONS.CREATE-NEW').toUpperCase(), - // url: '/datasets/new/' - // }]); - - - - // this.datasetWizardService.updateDatasetProfile(this.profileUpdateId) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(data => { - // this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - // this.needsUpdate(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // }, - // ] - // }]); - // this.formGroup = this.datasetWizardModel.buildForm(); - // this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - // this.formGroup.disable(); - // this.viewOnly = true; - // } - // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - // this.loadDatasetProfiles(); - // }); - } - - private refreshToCEntries(): ToCEntry[]{ - this.toCEntries = this.getTocEntries(); - //update selected tocentry - if(this.selectedTocEntry){ - this.selectedTocEntry = this._findTocEntryById(this.selectedTocEntry.id, this.toCEntries); - } - // this.updateOrdinals(this.toCEntries); - // this._updateNumbering(this.toCEntries); - return this.toCEntries; - } - - /** - * Updates entries ordinal form value - * based on the index they have on the tocentry array. - * Tocentries that are on the same level have distinct ordinal value - * - * @param tocentries - * - */ - private _updateOrdinals(tocentries: ToCEntry[]){ - - if(!tocentries || !tocentries.length) return; - tocentries.forEach((e,idx)=>{ - const ordinalControl = e.form.get('ordinal'); - if(ordinalControl){ - ordinalControl.setValue(idx); - ordinalControl.updateValueAndValidity(); - } - this._updateOrdinals(e.subEntries); - }); - } - - //sort tocentries based on their ordinality - private _sortToCentries(entries: ToCEntry[]){ - if(!entries || !entries.length) return; - entries.sort(this._compareOrdinals); - entries.forEach(e=>{ - this._sortToCentries(e.subEntries) - }); - } - private _compareOrdinals(a, b){ - - const aValue = a.form.get('ordinal').value as number; - const bValue = b.form.get('ordinal').value as number; - - // if(!aValue || !bValue) return 0; - return aValue - bValue; - } - private _updateNumbering(entries:ToCEntry[], parentNumbering:string){ - if(!entries || !entries.length) return; - let prefix =''; - if(parentNumbering.length){ - prefix = parentNumbering + '.'; - } - entries.forEach((entry,index)=>{ - const numbering = prefix + (index+1); - entry.numbering = numbering; - this._updateNumbering(entry.subEntries, numbering); - }) - } - - toCEntries:ToCEntry[]; - - getTocEntries(): ToCEntry[] { - if (this.form == null) { return []; } - const result: ToCEntry[] = []; - - //build parent pages - (this.form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { - result.push({ - id: pageElement.get('id').value, - label: pageElement.get('title').value, - type: ToCEntryType.Page, - form: pageElement, - numbering: (i + 1).toString(), - subEntriesType: ToCEntryType.Section - } as ToCEntry) - }); - - // build first level sections - (this.form.get('sections') as UntypedFormArray).controls.forEach((sectionElement, i) => { - const currentSectionPageId = sectionElement.get('page').value; - const pageToAdd = result.filter(x => x.id == currentSectionPageId)[0]; - if (pageToAdd.subEntries == null) pageToAdd.subEntries = []; - - const item = { - id: sectionElement.get('id').value, - label: sectionElement.get('title').value, - type: ToCEntryType.Section, - form: sectionElement, - numbering: pageToAdd.numbering + '.' + (pageToAdd.subEntries.length +1) - } as ToCEntry; - const sectionItems = this.populateSections(sectionElement.get('sections') as UntypedFormArray, item.numbering); - const fieldSetItems = this.populateFieldSets(sectionElement.get('fieldSets') as UntypedFormArray, item.numbering); - if (sectionItems != null) { - item.subEntries = sectionItems; - item.subEntriesType = ToCEntryType.Section; - } - if (fieldSetItems != null) { - if (item.subEntries == null) { - item.subEntries = fieldSetItems; - } else { - item.subEntries.push(...fieldSetItems); - } - item.subEntriesType = ToCEntryType.FieldSet; - - } - pageToAdd.subEntries.push(item); - - }); - this._sortToCentries(result);//ordeby ordinal - this._updateNumbering(result, '');//update nubering if needed - return result; - } - - private populateSections(sections: UntypedFormArray, existingNumbering: string): ToCEntry[] { - if (sections == null || sections.controls == null || sections.controls.length == 0) { return null; } - - const result: ToCEntry[] = []; - sections.controls.forEach((sectionElement, i) => { - - const item = { - id: sectionElement.get('id').value, - label: sectionElement.get('title').value, - type: ToCEntryType.Section, - form: sectionElement, - numbering: existingNumbering + '.' + (i + 1) - } as ToCEntry; - const sectionItems = this.populateSections(sectionElement.get('sections') as UntypedFormArray, item.numbering); - const fieldSetItems = this.populateFieldSets(sectionElement.get('fieldSets') as UntypedFormArray, item.numbering); - if (sectionItems != null) { - item.subEntries = sectionItems; - item.subEntriesType = ToCEntryType.Section; - } - if (fieldSetItems != null) { - if (item.subEntries == null) { - item.subEntries = fieldSetItems; - } else { - item.subEntries.push(...fieldSetItems); - } - item.subEntriesType = ToCEntryType.FieldSet; - } - result.push(item); - }); - - return result; - } - - private populateFieldSets(fieldSets: UntypedFormArray, existingNumbering: string): ToCEntry[] { - if (fieldSets == null || fieldSets.controls == null || fieldSets.controls.length == 0) { return null; } - - const result: ToCEntry[] = []; - fieldSets.controls.forEach((fieldSetElement, i) => { - - result.push({ - id: fieldSetElement.get('id').value, - label: fieldSetElement.get('title').value, - type: ToCEntryType.FieldSet, - //subEntries: this.populateSections((fieldSetElement.get('fieldSets') as FormArray), existingNumbering + '.' + i), - form: fieldSetElement, - numbering: existingNumbering + '.' + (i + 1) - } as ToCEntry) - - }); - - return result; - } - - - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries || !tocentries.length){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } - addNewEntry(tce: NewEntryType) { - - const parent = tce.parent; - - //define entry type - switch (tce.childType) { - case ToCEntryType.Page: - const pagesArray = (this.form.get('pages') as UntypedFormArray); - - const page: PageEditorModel = new PageEditorModel(pagesArray.length); - const pageForm = page.buildForm(); - // this.dataModel.pages.push(page); - - pagesArray.push(pageForm); - // this.form.updateValueAndValidity(); - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(pageForm.get('id').value, this.toCEntries); - - break; - case ToCEntryType.Section: - - const section: SectionEditorModel = new SectionEditorModel(); - section.id = Guid.create().toString(); - let sectionsArray:UntypedFormArray; - - if (parent.type === ToCEntryType.Page) {//FIRST LEVEL SECTION - sectionsArray = this.form.get('sections') as UntypedFormArray; - - section.page = parent.id; - - try{ - const max = sectionsArray.controls.filter(control=>control.get('page').value === parent.id) - .map(control=>control.get('ordinal').value) - .reduce((a,b)=>Math.max(a,b)); - - section.ordinal = max + 1; - }catch{ - section.ordinal = sectionsArray.length; - - } - sectionsArray.push(section.buildForm()); - // this.form.updateValueAndValidity(); - - } else if( parent.type == ToCEntryType.Section) { //SUBSECTION OF SECTION - sectionsArray = parent.form.get('sections') as UntypedFormArray; - - //adding page parent MAYBE NOT NEEDED - section.page = parent.form.get('page').value; - try{ - const maxOrdinal = sectionsArray.controls.map(control=>control.get('ordinal').value).reduce((a,b)=>Math.max(a, b)); - section.ordinal = maxOrdinal+1; - }catch{ - section.ordinal = sectionsArray.length; - } - - sectionsArray.push(section.buildForm()); - // (child.form.parent as FormArray).push(section.buildForm()); - - }else{ - console.error('Section can only be child of a page or another section'); - } - - - const sectionAdded = sectionsArray.at(sectionsArray.length -1) as UntypedFormGroup; - // sectionAdded.setValidators(this.customEditorValidators.sectionHasAtLeastOneChildOf('fieldSets','sections')); - // sectionAdded.updateValueAndValidity(); - - - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(sectionAdded.get('id').value, this.toCEntries); - - break; - case ToCEntryType.FieldSet: - - //create one field form fieldset - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first filed in the fields list - const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - - // fieldSet.fields.push(field); - // field.ordinal = fieldSet.fields.length-1; - - const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray - - //give fieldset id and ordinal - const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); - const fieldSetId = Guid.create().toString(); - fieldSet.id = fieldSetId; - - try{ - const maxOrdinal = fieldSetsArray.controls.map(control=>control.get('ordinal').value).reduce((a,b)=>Math.max(a, b)); - fieldSet.ordinal = maxOrdinal+1; - }catch{ - fieldSet.ordinal = fieldSetsArray.length; - } - const fieldsetForm = fieldSet.buildForm(); - - - - (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); - fieldSetsArray.push(fieldsetForm); - - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(fieldSetId, this.toCEntries); - // fieldForm.updateValueAndValidity(); - - break; - - default: - break; - } - - this.form.updateValueAndValidity(); - } - - - onRemoveEntry(tce: ToCEntry){ - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this._deleteEntry(tce); - } - }); - - } - - - private _deleteEntry(tce: ToCEntry) { - //define entry type - switch (tce.type) { - case ToCEntryType.Page: - const pages = this.form.get('pages') as UntypedFormArray; - - let pageIndex = -1; - //get the index - for (let i = 0; i < pages.length; i++) { - let page = pages.at(i) as UntypedFormGroup; - - if (page.controls.id.value === tce.id) { - pageIndex = i; - break; - } - } - - if (pageIndex >= 0) { - //remove page - this._updateSelectedItem(tce); - pages.removeAt(pageIndex); - //clean up sections of removed page - - const sections = (this.form.get('sections') as UntypedFormArray); - - const sectionsIndexToBeRemoved = []; - - sections.controls.forEach((section,idx)=>{ - if(section.get('page').value === tce.id){ - sectionsIndexToBeRemoved.push(idx); - } - }); - - if(sectionsIndexToBeRemoved.length){ - sectionsIndexToBeRemoved.reverse().forEach(index=>{ - sections.removeAt(index); - }); - } - - //update page ordinals - for(let i=0; i= 0) { //section found - - const sections = (this.form.get('sections') as UntypedFormArray); - - //remove section - this._updateSelectedItem(tce); - sections.removeAt(index); - - //update ordinal - for(let i=0; i< sections.length; i++){ - sections.at(i).get('ordinal').patchValue(i); - } - } else {//NOT FOUND IN FIRST LEVEL CASE - - //LOOK FOR SUBSECTION CASE - let parentFormArray = tce.form.parent as UntypedFormArray; - - for (let i = 0; i < parentFormArray.length; i++) { - let section = parentFormArray.at(i); - - if (section.get('id').value == tce.id) { - index = i; - break; - } - } - if (index >= 0) { - this._updateSelectedItem(tce); - parentFormArray.removeAt(index); - - //update odrinal - - for(let i=0; i=0){//fieldset found - this._updateSelectedItem(tce); - parentFormArray.removeAt(idx); - - //patching order - for(let i=0; i{ - if(section.get('id').value === tce.id){ - isFirstLevel = true; - } - }); - - let parentId = null; - if(isFirstLevel){ - parentId = tce.form.get('page').value; - }else{ - parentId = tce.form.parent.parent.get('id').value - } - - // const parentId = tce.form.parent.parent.get('id').value; - if(parentId){ - const tocentries = this.getTocEntries(); - const parent = this._findTocEntryById(parentId, tocentries); - - if(parent){ - this.selectedTocEntry = parent; - }else{ - this.selectedTocEntry = null; - } - }else{ - this.selectedTocEntry = null; - } - } - } - } - } - - tocEntryIsChildOf(testingChild: ToCEntry,parent: ToCEntry): boolean{ - - if(!testingChild || !parent) return false; - - if(testingChild.id == parent.id){return true;} - - if(parent.subEntries){ - let childFound:boolean = false; - - parent.subEntries.forEach(subEntry=>{ - if(this.tocEntryIsChildOf(testingChild, subEntry)){ - childFound = true; - return true; - } - }) - - return childFound; - } - return false; - } - - selectedTocEntry: ToCEntry - displayItem(entry: ToCEntry): void { - this.selectedTocEntry = entry; - } - - get numOfPages(){ - return (this.form.get('pages')).length; - } - - // getSectionIndex(): number{ - // // if(this.sectionIdPreviewed == null) return; - // const valuesArray = this.form.get('sections').value; - // let currentVal = this.sectionIdPreviewed; - // let indexArray:string[] = valuesArray.map(element=> element.page); - // let index = indexArray.indexOf(currentVal); - // console.log(index); - // return index ? index :-1; - // } - - // getCurrentEditorModel(): SectionEditorModel{ - // let currentEditor = this.dataModel.sections.filter(section=> section.page == this.sectionIdPreviewed)[0]; - // return currentEditor; - - // } - - - // subForm(){ - // const valuesArray = this.form.get('sections').value; - // let currentVal = this.sectionIdPreviewed; - // let indexArray:string[] = valuesArray.map(element=> element.page); - // let index = indexArray.indexOf(currentVal); - // let subForm = (this.form.get('sections') as FormArray).controls[index]; - // console.log(subForm); - // return subForm; - // } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } - - deleteFieldSet(formArray: UntypedFormArray, index: number) { - formArray.removeAt(index); - } - - - - printForm(){ - // console.log(this.form.value); - console.log(this.form); - } - - get barPercentage(){ - if(!this.stepper || !this.steps){ - return 0; - } - const selectedIndex = this.stepper.selectedIndex + 1; - return (selectedIndex / this.stepper.steps.length) * 100; - } - - - get progressStyle(){ - // return {'transform': 'translateX('+this.barPercentage+'%) skewX(-25deg)'} - const diff = 3; - - return { - 'clip-path': `polygon(0 0, ${Math.round(this.barPercentage + diff)}% 0, ${Math.round(this.barPercentage)}% 100%, 0 100%)` - } - } - - steps:QueryList; - // get steps(){ - // if(!this.stepper){ - // return []; - // } - - // return this.stepper.steps; - // } - - - // generatePreviewForm(){ - - - // const model = new DatasetDescriptionFormEditorModel(); - - // const toCentries = this.getTocEntries(); - - - // //first level is always pages - // model.pages = toCentries.map((entry,idx)=>{ - // if( !(entry.type == ToCEntryType.Page)){ - // return null; - // } - // const pageModel = new DatasetDescriptionPageEditorModel(); - - // pageModel.ordinal = entry.form.get('ordinal').value; - // pageModel.title = entry.label; - - // if(entry.subEntries){ - // pageModel.sections = entry.subEntries.map(section=>{ - // const sectionModel = new DatasetDescriptionSectionEditorModel(); - - // sectionModel.id = section.id; - // sectionModel.ordinal = section.form.get('ordinal').value; - // sectionModel.description = section.form.get('description').value; - // sectionModel.page = entry.form.get('ordinal').value; - // sectionModel.title = section.label; - // sectionModel.numbering = (idx+1).toString(); - - - // if(section.subEntriesType == ToCEntryType.Section){ - // sectionModel.sections = this._buildSectionsRecursively(section.subEntries, sectionModel.numbering); - // }else{ - // sectionModel.compositeFields = this._buildFormFields(section.subEntries, sectionModel.numbering) - // } - - // return sectionModel; - // }); - // }; - // return pageModel; - - // }); - - - // //populate rules - // const rules:Rule[] =[]; - // const fieldSets = this._getFieldSets(toCentries); - - // fieldSets.forEach(fs=>{ - // const fields = fs.form.get('fields') as FormArray; - // if(fields){ - // fields.controls.forEach(field=>{ - // const rulesArray = field.get('visible').get('rules').value; - // if(rulesArray){ - // rulesArray.forEach(ruleElement => { - // const rule: Rule = new Rule(); - // rule.targetField = ruleElement.target; - // rule.sourceField = field.get('id').value; - // rule.requiredValue = ruleElement.value; - // rules.push(rule); - // }); - // } - // }); - // } - // }); - - // model.rules = rules; - // this.visibilityRules = rules; - - // this.previewForm = model.buildForm(); - // } - - - updateVisibilityRules(){ - const rules:Rule[] =[]; - const fieldSets = this._getFieldSets(this.getTocEntries()); - - fieldSets.forEach(fs=>{ - const fields = fs.form.get('fields') as UntypedFormArray; - if(fields){ - fields.controls.forEach(field=>{ - const rulesArray = field.get('visible').get('rules').value; - if(rulesArray){ - rulesArray.forEach(ruleElement => { - const rule: Rule = new Rule(); - rule.targetField = ruleElement.target; - rule.sourceField = field.get('id').value; - rule.requiredValue = ruleElement.value; - rules.push(rule); - }); - } - }); - } - }); - - this.visibilityRules = rules; - - } - - visibilityRules:Rule[]; - private _buildSectionsRecursively( tocentries: ToCEntry[], parentNumbering:string): DatasetDescriptionSectionEditorModel[]{ - - - if(!tocentries) return null; - - - const result: Array = []; - - tocentries.forEach((tocentry, idx)=>{ - - const sectionModel = new DatasetDescriptionSectionEditorModel(); - sectionModel.id = tocentry.id; - sectionModel.ordinal = tocentry.form.get('ordinal').value; - sectionModel.description = tocentry.form.get('description').value; - // sectionModel.page = entry.form.get('ordinal').value; - sectionModel.title = tocentry.label; - // sectionModel.numbering = tocentry.numbering; - sectionModel.numbering = parentNumbering+"."+(idx+1);; - - if(tocentry.subEntriesType == ToCEntryType.Section){ - sectionModel.sections = this._buildSectionsRecursively(tocentry.subEntries, sectionModel.numbering); - - }else{ - sectionModel.compositeFields = this._buildFormFields(tocentry.subEntries, sectionModel.numbering); - } - - result.push(sectionModel); - }) - - return result; - } - - private _buildFormFields(tocentries: ToCEntry[], parentNumbering: string):DatasetDescriptionCompositeFieldEditorModel[]{ - if(!tocentries) return null; - - const fieldsets:DatasetDescriptionCompositeFieldEditorModel[] = []; - - tocentries.forEach((fs, idx)=>{ - - const fieldset = new DatasetDescriptionCompositeFieldEditorModel(); - - fieldset.description = fs.form.get('description').value; - fieldset.extendedDescription = fs.form.get('extendedDescription').value; - fieldset.id = fs.form.get('id').value; - fieldset.multiplicity = fs.form.get('multiplicity').value; - fieldset.additionalInformation = fs.form.get('additionalInformation').value; - fieldset.ordinal = fs.form.get('ordinal').value; - // fieldset.numbering = fs.numbering; - fieldset.numbering = parentNumbering+"."+(idx+1); - fieldset.hasCommentField = fs.form.get('hasCommentField').value; - fieldset.title = fs.label; - // fieldset.fields = (fs.form.get('fields') as FormArray).getRawValue(); - fieldset.fields = (fs.form.get('fields') as UntypedFormArray).controls.map(field=>{ - - const fieldModel = new DatasetDescriptionFieldEditorModel(); - - fieldModel.data = (field.get('data') as UntypedFormGroup).getRawValue(); - fieldModel.id = field.get('id').value; - fieldModel.viewStyle = (field.get('viewStyle') as UntypedFormGroup).getRawValue(); - // fieldModel.defaultValue = (field.get('defaultValue') as FormGroup).getRawValue(); - fieldModel.value = (field.get('defaultValue') as UntypedFormGroup).get('value').value; - fieldModel.defaultValue = fieldModel.value; - fieldModel.page = field.get('page').value; - fieldModel.validations = field.get('validations').value; - - return fieldModel; - }); - - - - fieldsets.push(fieldset); - }); - - return fieldsets; - } - - private _getFieldSets(tocentries: ToCEntry[]):ToCEntry[]{ - - const fieldsets:ToCEntry[] = []; - - if(!tocentries) return fieldsets; - - tocentries.forEach(entry=>{ - if(entry.type == ToCEntryType.FieldSet){ - fieldsets.push(entry); - }else{ - fieldsets.push(...this._getFieldSets(entry.subEntries)); - } - }); - - return fieldsets; - } - - - - // get basicInfo(){ - - // const label = this.form.get('label'); - // const description = this.form.get('description'); - // const language = this.form.get('language'); - - - - // const fg = new FormGroup({ - // label: label, - // description: description, - // language: language - // }) - - // return fg; - // } - - - - - - onMatStepperSelectionChange(event: StepperSelectionEvent){ - - if(event.selectedIndex === (this.steps.length -1)){//preview selected - // this.generatePreviewForm();//TODO LAZY LOADING IN THE TEMPLATE - this.getPreview(); - }else{ - // this.previewForm = null; - this.formGroup = null; - } - this.form.markAsUntouched(); - - } - - // previewForm:FormGroup; - onDataNeedsRefresh(params?){ - - const tocentries = this.refreshToCEntries(); - - if(params && params.draggedItemId){ - if(params.draggedItemId){ - this.displayItem(this._findTocEntryById(params.draggedItemId, tocentries)); - } - } - this.form.markAsDirty(); - } - - cloneFieldSet(fieldset: UntypedFormGroup){ - const values = fieldset.getRawValue(); - const parentArray = fieldset.parent as UntypedFormArray; - - values.id = Guid.create().toString(); - values.ordinal = parentArray.length; - - values.fields.forEach(element => { - element.id = Guid.create().toString() - }); - - - const clonedModel = new FieldSetEditorModel().fromModel(values); - const clonedForm = clonedModel.buildForm(); - parentArray.push(clonedForm); - - //update tocentries and make selected tocentry the cloedn - let entries = this.refreshToCEntries(); - - const entryfound = this._findTocEntryById(clonedForm.get('id').value, entries); - if(entryfound){ - this.selectedTocEntry = entryfound; - } - - // //create one field form fieldset - // const field: FieldEditorModel = new FieldEditorModel(); //to ask - // field.id = Guid.create().toString(); - // field.ordinal = 0;//first filed in the fields list - // fieldSet.fields.push(field); - // // field.ordinal = fieldSet.fields.length-1; - - // //give fieldset id and ordinal - // fieldSet.id = Guid.create().toString(); - // fieldSet.ordinal = (parent.form.get('fieldSets') as FormArray).length; - - // (parent.form.get('fieldSets')).push(fieldSet.buildForm()); - - // // const parentArray = parent.form.get('fieldSets') as FormArray; - // const addedFieldSet = parentArray.at(parentArray.length - 1); - - - - - } - - isStepCompleted(stepIndex: number){ - - let stepCompleted = false; - this.steps.forEach((step,index)=>{ - if(stepIndex === index){ - stepCompleted = step.completed; - } - }); - - return stepCompleted; - } - - isStepUnlocked(stepIndex: number): boolean{ - if(stepIndex === 0) return true; - if(stepIndex <0 ) return false; - //if previous step is valid then unlock - let stepUnlocked: boolean = false; - - if(!this.isStepUnlocked(stepIndex -1)) return false; - - this.steps.forEach((step,index)=>{ - - if(index+1 == stepIndex){//previous step - - if(step.completed){ - stepUnlocked = true; - } - } - }); - - return stepUnlocked; - } - - validateStep(selectedIndex){ - - if(selectedIndex === 1){//form description - if(this.form.invalid){ - this.checkFormValidation(); - } - } - - - // if(step.hasError){ - // this.printMyErrors(this.form); - // } - } - - // getFormValidationErrors() { - // Object.keys(this.form.controls).forEach(key => { - - // const controlErrors: ValidationErrors = this.form.get(key).errors; - // if (controlErrors != null) { - // Object.keys(controlErrors).forEach(keyError => { - // console.log('Key control: ' + key + ', keyError: ' + keyError + ', err value: ', controlErrors[keyError]); - // }); - // } - // }); - - // if(this.form.invalid){ - // console.log('this form is invalid!'); - // console.log(this.form.errors); - // } - // } - - - - private _buildErrorMessage(errors, numbering, key):string[]{ - const errmess: string[] = []; - - Object.keys(errors).forEach(keyError => { - - switch(keyError){ - case EditorCustomValidatorsEnum.atLeastOneSectionInPage: - errmess.push( this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.PAGE-MUST-HAVE-SECTION')); - break; - case EditorCustomValidatorsEnum.emptyArray: - errmess.push(numbering+this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.NEEDS-MORE-INFORMATION')) - break; - case EditorCustomValidatorsEnum.sectionMustHaveOneChild: - errmess.push(numbering+this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.MUST-HAVE-SECTION-OR-FIELDSET')) - break; - default: - if (typeof errors[keyError] === 'boolean') { - errmess.push(numbering + ' ' + key + ' is ' + keyError); - } else { - errmess.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); - } - - } - - }); - - return errmess; - } - - - printMyErrors(form: AbstractControl){ - // this._printToCentriesErrrors(this.toCEntries); - const result = this._getErrors(form); - - // console.log('got errors '); - // console.log(result); - - if(result && form.invalid){ - const errmess:string[] = []; - if(result.length){ - form.markAllAsTouched(); - - let indexes:number[] = []; - ///search in pages,sections and fieldsets for the id - result.forEach((err,i)=>{ - const entry = this._findTocEntryById(err.id, this.toCEntries); - if(entry){ - - // errmess.push(`Error on ${entry.numbering} ${entry.label} . ${err.key}`); - errmess.push(...this._buildErrorMessage(err.errors, entry.numbering, err.key)); - indexes.push(i); - } - }); - indexes.reverse().forEach(index=>{ - result.splice(index,1); - }); - - indexes = []; - //searching in fields - const fieldsets = this._getAllFieldSets(this.toCEntries); - result.forEach((err,i)=>{ - fieldsets.filter(fs=>{ - let fieldFound = false; - (fs.form.get('fields') as UntypedFormArray).controls.forEach(field=>{ - if(field.get('id').value === err.id){ - fieldFound = true; - indexes.push(i); - } - }); - return fieldFound; - }) - //printing fieldsets that the field missing - .forEach(fs=>{ - // errmess.push(`Missing input in ${fs.numbering} ${fs.label} . ${err.key}`); - errmess.push(...this._buildErrorMessage(err.errors, fs.numbering, err.key)); - }); - }); - - indexes.reverse().forEach(index=>{ - result.splice(index,1); - }); - - result.forEach(err=>{ - // console.log(err); - if(err.key){ - errmess.push(`${this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.MISSING')} ${err.key}` ); - }else{ - - errmess.push(this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.PROVIDE-PAGE-AND-SECTION')); - } - // errmess.push(...this._buildErrorMessage(err.errors,"", err.key) ); - - }) - } - - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - errorMessages: errmess, - projectOnly: false - }, - }); - } - } - - /** - * Get all filedsets in a tocentry array; - * @param entries Tocentries to search in - * @returns The tocentries that are Fieldsets provided in the entries - */ - private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{ - - const fieldsets:ToCEntry[] = []; - if(!entries || !entries.length) return fieldsets; - - - entries.forEach(e=>{ - if(e.type === ToCEntryType.FieldSet){ - fieldsets.push(e); - }else{ - fieldsets.push(...this._getAllFieldSets(e.subEntries)); - } - }); - return fieldsets; - } - - - private _getErrors(aControl: AbstractControl):InvalidControl[]{ - - - if(aControl.valid) return; - - let controlType = 'control'; - - if(aControl instanceof UntypedFormGroup) controlType="fg" - if(aControl instanceof UntypedFormControl) controlType="fc"; - if(aControl instanceof UntypedFormArray) controlType="fa"; - - - const invalidControls:InvalidControl[] = []; - //invalid - switch (controlType){ - case 'fg': - - const controls = (aControl as UntypedFormGroup).controls; - const keys = Object.keys(controls); - keys.forEach(key=>{ - const control = controls[key]; - if(!control.invalid) return; //// !!!!! Important to be !invalid. (In case the template is finalized) - - if(control instanceof UntypedFormControl){ - const ctrl = control as UntypedFormControl; - - invalidControls.push({ - errors:ctrl.errors, - id: ctrl.get('id')? ctrl.get('id').value: null, - invalidSubControls: [], - key: key - }); - - }else{ - // if(aControl.errors){ - // invalidControls.push({ - // id: aControl.get('id')? aControl.get('id').value: null, - // errors:aControl.errors, - // key: aControl.get('title')? aControl.get('title').value: 'unspecified', - // invalidSubControls:[]//TODO TO CHECK - // }); - // } - - - //THE ONE WE REMOVED - // if(control.errors){ - // // invalidControls.push({ - // // id: aControl.get('id')? aControl.get('id').value: null, - // // errors:aControl.errors, - // // key: aControl.get('title')? aControl.get('title').value: 'unspecified', - // // invalidSubControls:[]//TODO TO CHECK - // // }); - - // invalidControls.push({ - // errors:control.errors, - // id: control.get('id')? control.get('id').value: null, - // invalidSubControls: [], - // key: key - // }); - // } - invalidControls.push(...this._getErrors(control)) ; - - } - }); - - /**In case there is an error in a formgroup then the validator probably is custom */ - if(aControl.errors){ - invalidControls.push({ - errors:aControl.errors, - id: aControl.get('id')? aControl.get('id').value: null, - invalidSubControls: [], - key: aControl.get('title')?aControl.get('title').value: null - }); - } - - break; - case 'fa': - // const fa = (aControl as FormArray); - const ctrls = (aControl as UntypedFormArray).controls; - const keys_ = Object.keys(ctrls); - keys_.forEach(key=>{ - const control = ctrls[key]; - if(control.valid) return; - - - if(control instanceof UntypedFormControl){ //for completion purposes. should never run this case - const ctrl = control as UntypedFormControl; - invalidControls.push({ - errors:ctrl.errors, - id: ctrl.get('id')? ctrl.get('id').value: null, - invalidSubControls: [], - key: key - }); - - }else{ - invalidControls.push(... this._getErrors(control)); - } - }); - - break; - } - - invalidControls.forEach(e=>{ - if(!e.id){ - e.id = aControl.get('id')? aControl.get('id').value : null; - } - }) - return invalidControls; - - } - userFormDisabled:boolean = false; - addUser(email:MatInput){ - - // email.focus(); - if(this.userFormDisabled) return; - - // console.log('user add'); - if(this.inputUserState === 'triggered'){ - // this.checkAndAdd(email); - - of(email.value) - .pipe(tap(_=> {this.userFormDisabled = true; email.focus()})) - .pipe(mergeMap(email=>this.userService.getFromEmail(email))) - .pipe(takeUntil(this._destroyed)) - .subscribe((result) => { - this.userChipList.push(result); - this.form.patchValue({'users': this.userChipList}); - - email.value = ''; - this.userFormDisabled = false; - this.form.markAsDirty(); - // email.focus(); - // this.inputUserState = 'triggered'; - - - }, - error=>{ - // console.log(error.message); - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.ERRORS.USER-NOT-FOUND'), SnackBarNotificationLevel.Error); - this.userFormDisabled = false; - // this.inputUserState = 'triggered';//when it loses focus(when disabled) it becomes untriggered - // email.focus(); - }); - // this.inputUserState = 'untriggered'; - }else{ - this.inputUserState = 'triggered'; - email.focus(); - - } - } - onUserButtonFocus(){ - this._inputUserButton$.next(true); - } - onUserButtonBlur(){ - this._inputUserButton$.next(false); - } - onUserFieldFocus(){ - this._inputUserField$.next(true); - } - onUserFieldBlur(){ - this._inputUserField$.next(false); - } - - - - //Temporary patch - /** - * Append custom validators to fields. Some validators are applied on template. In case they are never rendereed, - * he form might be valid when it shouldnt. - * @param - */ - private _initializeFormValidity(tocentries: ToCEntry[]) { - const fieldsets = this._getAllFieldSets(tocentries); - - try{ - fieldsets.forEach(fs=>{ - fs.form.get('title').setValidators(Validators.required); - const fieldsF = fs.form.get('fields') as UntypedFormArray; - if(fieldsF){ - fieldsF.controls.forEach(field=>{ - const renderStyleValue = field.get('viewStyle').get('renderStyle').value; - - if(renderStyleValue === DatasetProfileFieldViewStyle.CheckBox){ - field.get('defaultValue').get('value').setValidators(Validators.required); - }else if(renderStyleValue === 'combobox'){ - - const comboType = field.get('data').get('type').value; - if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - }else if(comboType === DatasetProfileComboBoxType.WordList){ - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - } - - }else if(renderStyleValue === DatasetProfileFieldViewStyle.RadioBox){ - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - } else if(renderStyleValue === DatasetProfileFieldViewStyle.Upload) { - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('types')); - field.get('data').get('maxFileSizeInMB').setValidators(Validators.required); - } - }); - } - }); - }catch(e){ - console.error('Error initializing validators.'); - console.error(e); - } - - } - - checkAndAdd(ev: any) { - this.userService.getFromEmail(ev).pipe(takeUntil(this._destroyed)).subscribe((result) => { - this.userChipList.push(result); - this.form.patchValue({'users': this.userChipList}); - }); - } - - removeUser(user: any) { - this.userChipList.splice(this.userChipList.indexOf(user), 1); - this.form.patchValue({'users': this.userChipList}); - this.form.markAsDirty();//deactivate guard - } - - - verifyAndRemoveUser(user:any){ - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(approve => { - if (approve) { - this.removeUser(user); - } - }); - } - - scrollOnTop(){ - try{ - const topPage = document.getElementById('main-content'); - topPage.scrollIntoView({behavior:'smooth'}); - }catch{ - console.log('coulnd not scroll'); - } - } - - updateAndFinalize(close: boolean = false){ - if(this.form.get('status').value == DatasetProfileEnum.FINALIZED ){ - //UPDATE FORM - if(this.newVersionId){ - this.onSubmit(close); - }else{ - this.updateFinalized(close); - } - }else{ - //finalize - this.finalize(); - } - - } - discardChanges(){ - this.router.navigate([ - 'dataset-profiles' - ]); - } - -} - -interface InvalidControl{ - key: string, - errors: any, - id: string, - invalidSubControls: InvalidControl[] -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html deleted file mode 100644 index 45a016601..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
-
- {{'CRITERIA.USERS.SHOW' | translate}}: -
- - - - {{'DATASET-PROFILE-STATUS.NONE' | translate}} - {{'DATASET-PROFILE-STATUS.DRAFT' | translate}} - {{'DATASET-PROFILE-STATUS.FINALIZED' | translate}} - - - -
-
- - - search - -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss deleted file mode 100644 index 9b64c055a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss +++ /dev/null @@ -1,17 +0,0 @@ -.mat-form-field{ - display: inline-block !important; -} - -:host ::ng-deep .status-form-field .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .search-form-field .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts deleted file mode 100644 index 7cf625f1f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { DialogConfirmationUploadDatasetProfiles } from '@app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-criteria-component', - templateUrl: './dataset-profile.component.html', - styleUrls: ['./dataset-profile.component.scss'] -}) -export class DatasetProfileCriteriaComponent extends BaseCriteriaComponent implements OnInit { - - public criteria: DatasetProfileCriteria = new DatasetProfileCriteria(); - - constructor( - private datasetService: DatasetProfileService, - private dialog: MatDialog, - private language: TranslateService, - ) { - super(new ValidationErrorModel()); - } - - ngOnInit() { - super.ngOnInit(); - if (this.criteria == null) { this.criteria = new DatasetProfileCriteria(); } - } - - setCriteria(criteria: DatasetProfileCriteria): void { - this.criteria = criteria; - } - - onCallbackError(error: any) { - this.setErrorModel(error.error); - } - - controlModified(): void { - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2) - ) { - this.refreshCallback(); - } - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html deleted file mode 100644 index d071e4cb2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html +++ /dev/null @@ -1,44 +0,0 @@ -
-
-
-

{{ data.message }}

-
-
- close -
-
- -
-
- - - {{ selectedFileName }} - - -
-
- -
-
- - -
-
- -
- - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss deleted file mode 100644 index c79fa2851..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss +++ /dev/null @@ -1,102 +0,0 @@ -.hidden { - display: none; -} - - -.cancel-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid #b5b5b5; - border-radius: 30px; -min-width: 101px; - height: 43px; - color: #212121; - font-weight: 500; -} - -.next-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid var(--primary-color); - border-radius: 30px; - opacity: 1; -min-width: 101px; - height: 43px; - color: var(--primary-color); - font-weight: 500; -} - -.next-btn[disabled] { - width: 100px; - height: 43px; - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid #b5b5b5; - border-radius: 30px; - opacity: 1; -} - -.next-btn:not([disabled]):hover { - background-color: var(--primary-color); - color: #ffffff; -} - -//ngx dropzone -.drop-file { - background-color: #fafafa; - border: 1px dashed #d1d1d1; - border-radius: 4px; - max-width: 480px; - height: 98px; - margin-top: 0.5rem; -} - -.file-preview { - height: auto !important; - width: auto !important; - max-width: 500px !important; - min-height: 1rem !important; - - background-color: #e0e0e0 !important; - background-image: none !important; - color: rgba(0, 0, 0, 0.87) !important; - font-weight: 500 !important; - border-radius: 24px !important; - line-height: 1.25 !important; -} - -.file-label { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - font-size: 14px !important; -} - -::ng-deep ngx-dropzone-remove-badge { - opacity: 1 !important; - margin-left: .5rem !important; - position: initial !important; -} - - -//attach file - -.attach-btn { - top: -20px; -} - -.attach-file { - width: 156px; - height: 44px; - color: #ffffff; - background: var(--primary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border-radius: 30px; -} - -.attach-file:hover { - background-color: #ffffff; - border: 1px solid var(--primary-color); - color: var(--primary-color); -} - -.close-btn:hover{ - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts deleted file mode 100644 index 144bde02f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { Inject, Component } from '@angular/core'; - - -@Component({ - selector: 'app-dialog-confirmation-upload', - templateUrl: './dialog-confirmation-upload-profiles.component.html', - styleUrls: ['./dialog-confirmation-upload-profiles.component.scss'] -}) -export class DialogConfirmationUploadDatasetProfiles { - - sizeError = false; - selectedFileName= ""; - selectFile =false; - maxFileSize: number = 1048576; - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } - - - selectXML(event) { - let file: FileList = null; - - if(event.target && event.target.files){ - file = event.target.files; - }else if(event.addedFiles && event.addedFiles.length){ - file = event.addedFiles; - } - if(!file) return;//no select closed with cancel . no file selected - const size: number = file[0].size; // Get file size. - this.sizeError = size > this.maxFileSize; // Checks if file size is valid. - const formdata: FormData = new FormData(); - if (!this.sizeError) { - this.data.file = file; - this.selectFile=true; - this.selectedFileName = file[0].name; - } - this.data.name = file[0].name; - } - - cancel() { - this.data.sucsess = false; - this.dialogRef.close(this.data); - } - - confirm() { - this.data.sucsess = true; - this.dialogRef.close(this.data); - } - - hasProfile():boolean{ - return (this.selectFile && !this.sizeError); - } - - //remove selected file - onRemove(){ - this.data.name=""; - this.selectFile = false; - this.selectedFileName = ""; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html deleted file mode 100644 index b1c49f61c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html +++ /dev/null @@ -1,100 +0,0 @@ -
-
- -
-
-

{{titlePrefix}} {{'DATASET-PROFILE-LISTING.TITLE' | translate}}

-
-
-
- - -
-
-
-
-
- -
-
- -
- - - - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.NAME' | translate}} - {{row.label}} - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.DESCRIPTION' | translate}} - - - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.CREATED' | - translate}} - {{row.created | date:'short'}} - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.STATUS' | - translate}} -
{{ (row.status | parseStatus) | translate}}
-
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
-
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss deleted file mode 100644 index d6013801d..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss +++ /dev/null @@ -1,119 +0,0 @@ -.dataset-profile-listing { - margin-top: 1rem; - margin-left: 1rem; - margin-right: 2rem; -} - -.mat-table { - margin-top: 47px; - // margin-bottom: 20px; - border-radius: 4px; - -} - -.mat-fab-bottom-right { - // top: auto !important; - // right: 20px !important; - // bottom: 10px !important; - // left: auto !important; - // position: fixed !important; - float: right; - z-index: 5; -} - -.mat-header-row{ - background: #f3f5f8; -} - -.full-width { - width: 100%; -} - -.mat-card { - margin: 16px 0; -} - -.mat-row { - cursor: pointer; - min-height: 4.5em; -} - -mat-row:hover { - background-color: #eef5f6; -} - -.status-chip{ - - border-radius: 20px; - padding-left: 1em; - padding-right: 1em; - padding-top: 0.2em; - font-size: .8em; -} - -.status-chip-finalized{ - color: #568b5a; - background: #9dd1a1 0% 0% no-repeat padding-box; -} - -.status-chip-draft{ - color: #00c4ff; - background: #d3f5ff 0% 0% no-repeat padding-box; -} -// mat-row:nth-child(even){ -// background-color:red; -// } - -// mat-row:nth-child(odd) { -// background-color: #0c748914; -// // background-color: #eef0fb; -// } - -:host ::ng-deep .mat-paginator-container { - flex-direction: row-reverse !important; - justify-content: space-between !important; - background-color: #f6f6f6; - align-items: center; - // height: 30px; - // min-height: 30px !important; -} - -// ::ng-deep .mat-paginator-page-size { -// height: 43px; -// } - -// ::ng-deep .mat-paginator-range-label { -// margin: 15px 32px 0 24px !important; -// } - -// ::ng-deep .mat-paginator-range-actions { -// width: 55% !important; -// min-height: 43px !important; -// justify-content: space-between; -// } - -// ::ng-deep .mat-paginator-navigation-previous { -// margin-left: auto !important; -// } - -// ::ng-deep .mat-icon-button { -// height: 30px !important; -// font-size: 12px !important; -// } - -.import-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - // color: var(--primary-color); - // border: 1px solid var(--primary-color); - padding-left: 2em; - padding-right: 2em; - color: #000; - border: 1px solid #000; -} -.create-btn { - border-radius: 30px; - background-color: var(--secondary-color); - padding-left: 2em; - padding-right: 2em; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts deleted file mode 100644 index f9181daab..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts +++ /dev/null @@ -1,319 +0,0 @@ -import { DataSource } from '@angular/cdk/table'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { MatPaginator, PageEvent } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { DatasetProfileCriteriaComponent } from '@app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { Observable, merge as observableMerge } from 'rxjs'; -import { map, startWith, switchMap, takeUntil } from 'rxjs/operators'; -import { DialogConfirmationUploadDatasetProfiles } from './criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; - -@Component({ - selector: 'app-dataset-profile-listing-component', - templateUrl: 'dataset-profile-listing.component.html', - styleUrls: ['./dataset-profile-listing.component.scss'] -}) -export class DatasetProfileListingComponent extends BaseComponent implements OnInit { - - @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; - @ViewChild(MatSort, { static: true }) sort: MatSort; - @ViewChild(DatasetProfileCriteriaComponent, { static: true }) criteria: DatasetProfileCriteriaComponent; - - // breadCrumbs: Observable; - dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'description', 'created', 'status', 'actions']; - pageEvent: PageEvent; - titlePrefix: String; - dmpId: String; - itemId: string; - datasetStatusEnum = DatasetStatus; - - constructor( - private datasetService: DatasetProfileService, - private router: Router, - private route: ActivatedRoute, - private dmpService: DmpService, - private language: TranslateService, - private uiNotificationService: UiNotificationService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private dialog: MatDialog, - private datasetProfileService: DatasetProfileService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Admin: Dataset Templates'); - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - if (params['dmpId']) { - this.dmpId = params['dmpId']; - if (this.dmpId != null) { this.setDmpTitle(this.dmpId); } - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - // this.breadCrumbs = Observable.of([{ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.DATASET-TEMPLATES'), - // url: 'plans/edit/' + this.dmpId - // }]); - } else { - this.itemId = params['groupId']; - if (this.itemId) { - const datasetProfileLabel = this.route.snapshot.queryParams.groupLabel; - } - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - // this.breadCrumbs = observableOf([{ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.DATASET-TEMPLATES'), - // url: '/dataset-profiles' - // }]); - } - }); - } - - setDmpTitle(dmpId: String) { - this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.titlePrefix = data.label; - } - ); - } - - refresh() { - this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.criteria, this.itemId); - this._paginator.pageIndex = 0; - } - - rowClick(rowId: String) { - this.router.navigate(['dataset-profiles/' + rowId]); - } - - getDefaultCriteria(): DatasetProfileCriteria { - const defaultCriteria = new DatasetProfileCriteria(); - return defaultCriteria; - } - - clone(id: string) { - this.router.navigate(['dataset-profiles/clone/' + id]); - } - - newVersion(id: string, label: string) { - this.router.navigate(['dataset-profiles/newversion/' + id]); - } - - newVersionFromFile(id: string, label: string): void { - const dialogRef = this.dialog.open(DialogConfirmationUploadDatasetProfiles, { - width: '500px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-FILE-TITLE', { datasetName: label }), - confirmButton: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML'), - cancelButton: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-FILE-CANCEL'), - name: "", - file: FileList, - sucsess: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { - if (data && data.sucsess && data.name != null && data.file != null) { - this.datasetService.uploadFile(data.file, data.name, id) - .pipe(takeUntil(this._destroyed)) - .subscribe(_ => { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-SUCCESSFUL'), SnackBarNotificationLevel.Success); - this.refresh(); - }, - error => { - this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); - } - ); - } - }); - } - - viewVersions(rowId, rowLabel) { - this.router.navigate(['/dataset-profiles/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } - downloadXML(datasetProfileId: string): void { - this.datasetProfileService.downloadXML(datasetProfileId) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - }); - } - - deleteTemplate(id: string) { - if (id) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - //this.form.get('status').setValue(DatasetProfileEnum.DELETED); - this.datasetProfileService.delete(id, null) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); - this.refresh(); - }, - error => { - this.onCallbackError(error); - if (error.error.statusCode == 674) { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - } - } - ); - } - }); - - - } - } - - onCallbackError(errorResponse: HttpErrorResponse) { - this.uiNotificationService.snackBarNotification(errorResponse.message, SnackBarNotificationLevel.Warning); - } - // makeItPublic(id: String) { - // debugger; - // this.datasetService.makeDatasetPublic(id).pipe(takeUntil(this._destroyed)).subscribe(); - // } - - openDialog(): void { - const dialogRef = this.dialog.open(DialogConfirmationUploadDatasetProfiles, { - width: '500px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-TITLE'), - confirmButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML'), - cancelButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-CANCEL'), - name: "", - file: FileList, - sucsess: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { - if (data && data.sucsess && data.name != null && data.file != null) { - this.datasetService.uploadFile(data.file, data.name) - .pipe(takeUntil(this._destroyed)) - .subscribe(_ => { - this.uiNotificationService.snackBarNotification('Template successfully uploaded', SnackBarNotificationLevel.Success); - this.refresh(); - }, - error => { - this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); - } - ); - } - }); - } - - /** - * gets as a a pameter a number representing the status and returns the class that is applied - * to status-chip */ - getStatusClass(status: DatasetStatus): string { - - if (status == DatasetStatus.Finalized) { - return 'status-chip-finalized' - } - - return 'status-chip-draft'; - } - -} - -export class DatasetDataSource extends DataSource { - - totalCount = 0; - - constructor( - private _service: DatasetProfileService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _criteria: DatasetProfileCriteriaComponent, - private itemId - ) { - super(); - - } - - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; - - return observableMerge(...displayDataChanges).pipe( - startWith(null), - switchMap(() => { - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array(); - if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.criteria; - request.criteria.finalized = false; - if (this.itemId) { - request.criteria.groupIds = [this.itemId]; - request.criteria.allVersions = true; - } - return this._service.getPaged(request); - }), - /*.catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }); - //this._criteria.criteria.onCallbackError(error); - return Observable.of(null); - })*/ - map(result => { - return result; - }), - map(result => { - if (!result) { return []; } - // if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.totalCount = result.totalCount; - return result.data; - })); - } - - disconnect() { - // No-op - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts deleted file mode 100644 index 82b75d2ab..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; - -@Pipe({ - name: 'parseStatus', - pure: true -}) -export class ParseStatus implements PipeTransform { - transform(value: any, ...args: any[]) { - return this.parseStatus(value); - } - - - parseStatus(status: DatasetStatus): string { - - switch (status) { - case DatasetStatus.Finalized: - return 'DATASET-PROFILE-STATUS.FINALIZED'; - case DatasetStatus.Draft: - return 'DATASET-PROFILE-STATUS.DRAFT'; - case DatasetStatus.Deleted: - return 'DATASET-PROFILE-STATUS.DRAFT.DELETED'; - default: - return 'DATASET-PROFILE-STATUS.DRAFT.NONE'; - } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html deleted file mode 100644 index eb2d6a4ba..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html +++ /dev/null @@ -1,2 +0,0 @@ - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts deleted file mode 100644 index 092d41f6a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Inject, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -// @Component({ -// selector: 'app-dataset-profile-preview-component', -// templateUrl: './dataset-profile-preview.component.html', -// styleUrls: ['./dataset-profile-preview.component.scss'] -// }) -export class DatasetProfilePreviewerComponent extends BaseComponent implements OnInit { - formGroup: FormGroup; - datasetWizardModel: DatasetWizardEditorModel; - constructor( - private datasetProfileService: DatasetProfileService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { super(); } - - ngOnInit(): void { - - this.datasetProfileService.preview(this.data['model']) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel({ - datasetProfileDefinition: x - }); - this.formGroup = this.datasetWizardModel.buildForm().get('datasetProfileDefinition'); - }); - - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts deleted file mode 100644 index b1ddf7e9a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AbstractControl } from "@angular/forms"; - -export interface ToCEntry { - id: string; - label: string; - subEntriesType: ToCEntryType; - subEntries: ToCEntry[]; - type: ToCEntryType; - form: AbstractControl; - numbering: string; -} - - -export enum ToCEntryType { - Page = 0, - Section = 1, - FieldSet = 2, - Field = 3 -} - -export interface NewEntryType { - childType: ToCEntryType, - parent: ToCEntry -} - -export interface TableUpdateInfo{ - draggedItemId?: string; - data?:any; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html deleted file mode 100644 index f31a10a89..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html +++ /dev/null @@ -1,252 +0,0 @@ - - -
- -
- - - - - {{parentLink.subEntries?.length}} - - - - - - delete - -
-
- - - - -
- - -
- - -
- -
- -
- - - - - - - - - - - - - - - -
- - -
- -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss deleted file mode 100644 index 3e4c13517..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss +++ /dev/null @@ -1,116 +0,0 @@ -// .docs-toc-container { -// width: 100%; -// padding: 5px 0 10px 0px; -// // cursor: pointer; -// // border-left: solid 4px #0c7489; - -// .scroll-container { -// overflow-y: auto; -// // calc(100vh - 250px) -// // height: calc(100vh - 250px); -// } - -// .docs-link { -// color: rgba(0, 0, 0, 0.54); -// // color: mat-color($app-blue-theme-foreground, secondary-text); -// transition: color 100ms; - -// &:hover, -// &.docs-active { -// .link-name { -// background-color: #ececec; -// border-radius: 6px; -// cursor: pointer;; -// // color: #0c7489; -// } -// // color: mat-color($primary, if($is-dark-theme, 200, default)); -// } -// } -// } - -// .docs-toc-heading { -// margin: 0; -// padding: 0; -// font-size: 13px; -// font-weight: bold; -// } - -// .table-item-actions{ -// // display: none; -// display: inline-block; -// visibility: hidden; -// } - -// .table-item:hover { -// .table-item-actions{ -// // display: inline-block; -// visibility: visible; -// } -// } - -// .table-item col{ -// text-overflow: ellipsis; -// overflow: hidden; -// white-space: nowrap; -// } - -.link-info{ - // display: inline-block; cursor: pointer; - // padding-top: .6em; - // padding-left: .6em; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - - -.border-left-active{ - border-left: 1px solid #000; -} - - -.side-bolder{ - border-left: 1px solid red; -} - - -.cdk-link-list { - - display: block; - // background: white; - overflow: hidden; -} - - - -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; -$yellow: var(--secondary-color); -.badge-ball{ - display: inline-block; - border-radius: 50%; - background-color: #FFF; - font-size: small; - font-weight: bold; - min-width: 2em; - text-align: center; -} - -.table-label-element{ - cursor: pointer; - // font-weight: normal; - - // transition-property: font-weight; - // transition-duration: 160ms; - // transition-delay: 50ms; - // transition-timing-function: ease-in-out; -} - - -.table-label-element-active{ - font-weight: bold; - // color: red; -} -.add-input-icon{ - width: 20px; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts deleted file mode 100644 index a7098cd0b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts +++ /dev/null @@ -1,281 +0,0 @@ -import { CdkDrag, CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop'; -import { DOCUMENT } from '@angular/common'; -import { Component, EventEmitter, Inject, Input, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { BaseComponent } from '@common/base/base.component'; -import { NewEntryType, ToCEntry, ToCEntryType } from '../table-of-contents-entry'; - -@Component({ - selector: 'app-dataset-profile-table-of-contents-internal-section', - styleUrls: ['./table-of-contents-internal-section.scss'], - templateUrl: './table-of-contents-internal-section.html' -}) -export class DatasetProfileTableOfContentsInternalSection extends BaseComponent implements OnInit { - - @Input() links: ToCEntry[]; - @Output() itemClick = new EventEmitter(); - @Output() removeEntry = new EventEmitter(); - - @Output() createFooEntry = new EventEmitter(); - - @Output() dataNeedsRefresh = new EventEmitter(); - - - - @Input() parentLink: ToCEntry; - @Input() itemSelected: ToCEntry; - @Input() DRAGULA_ITEM_ID_PREFIX; - @Input() overContainerId: string; - @Input() isDragging; - @Input() draggingItemId: string; - @Input() parentRootId: string; - - @Input() colorizeInvalid:boolean = false; - - @Input() viewOnly: boolean; - // @Input() dropListGroup: Set = new Set(); - // @Input() dropListGroup: string[]; - - // @Input() dragHoveringOver: boolean = false; - // @Input() depth: number = 0; - - // @Input() dropListStruct: { id: string, depth: number}[] = []; - - constructor( - @Inject(DOCUMENT) private _document: Document) { - super(); - } - - tocEntryType = ToCEntryType; - - - // compareFn(a, b){ - // if(a.depth> b.depth) return -1; - // if(a.depth< b.depth) return 1; - - // return 0; - // } - - ngOnInit(): void { - } - - // hoveroverEnter(){ - // // console.log('user hovering drag over', this.parentLink.id, this.parentLink.label); - // this.dragHoveringOver = true; - // } - // hoveroverLeft(){ - // this.dragHoveringOver = false; - // } - - ngOnChanges(changes: SimpleChanges) { - - } - - // get grouListIds(){ - // return Array.from(this.dropListGroup); - // } - itemClicked(item: ToCEntry) { - //leaf node - this.itemClick.emit(item); - } - - deleteEntry(currentLink: ToCEntry){ - this.removeEntry.emit(currentLink); - } - - createNewEntry(foo: NewEntryType){ - this.createFooEntry.emit(foo); - } - - // tocEntryIsChildOf(testingChild: ToCEntry,parent: ToCEntry): boolean{ - - // if(!testingChild || !parent) return false; - - // if(testingChild.id == parent.id){return true;} - - // if(parent.subEntries){ - // let childFound:boolean = false; - - // parent.subEntries.forEach(subEntry=>{ - // if(this.tocEntryIsChildOf(testingChild, subEntry)){ - // childFound = true; - // return true; - // } - // }) - - // return childFound; - // } - // return false; - // } - - get selectedItemInLinks(){ - if(!this.links || !this.itemSelected) return false; - - const link = this.links.find(l=>l.id === this.itemSelected.id); - - if(link) return true; - return false; - } - - // appendAndGetDroplists(dropList: CdkDropList){ - // this.dropListGroup.push(dropList); - // return this.dropListGroup; - // } - - // drop(event: CdkDragDrop) { - // // if(!this.links || !this.links.length) return; - - // if(event.container === event.previousContainer){ - // moveItemInArray(this.links, event.previousIndex, event.currentIndex); - - // let arrayToUpdate: FormArray = this.links[0].form.parent as FormArray; - // // if(this.parentLink && this.parentLink.form){ - // // switch(this.parentLink.subEntriesType){ - // // case this.tocEntryType.Field: - // // arrayToUpdate = (this.parentLink.form.get('fields') as FormArray); - // // break; - // // case this.tocEntryType.FieldSet: - // // arrayToUpdate = (this.parentLink.form.get('fieldSets') as FormArray); - // // break; - // // case this.tocEntryType.Section: - // // arrayToUpdate = (this.parentLink.form.get('sections') as FormArray); - // // break - // // } - - // // } - // if(arrayToUpdate.controls){ - // moveItemInArray(arrayToUpdate.controls, event.previousIndex, event.currentIndex); - // //update ordinality - // arrayToUpdate.controls.forEach((element,idx ) => { - // element.get('ordinal').setValue(idx); - // element.updateValueAndValidity(); - // }); - // } - - // this.dataNeedsRefresh.emit(); - // }else{ - // console.log('not same container'); - // } - - // console.log(event.container.id); - - // } - - onDataNeedsRefresh(){ - this.dataNeedsRefresh.emit(); - } - - - // get hoveringOverParent(){ - // if(!this.overContainerId) return false; - // const child = this._findTocEntryById(this.overContainerId, this.parentLink.subEntries); - // if(!child) return false; - // return true; - // } - - - public _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } - - - - colorError():boolean{ - - if(!this.colorizeInvalid) return false; - - const form = this.parentLink.form; - if((!form || form.valid || !form.touched) && this.parentLink.type !== this.tocEntryType.Page) return false; - - const allFieldsAreTouched = this.allFieldsAreTouched(form); - - //fieldset may have errros that are inside its controls and not in the fieldsetFormGroup - if(this.parentLink.type === this.tocEntryType.FieldSet && allFieldsAreTouched) return true; - - if(form.errors && allFieldsAreTouched) return true; - - //check if page has sections - if(this.parentLink.type === this.tocEntryType.Page && allFieldsAreTouched){ - const rootForm = form.root; - if(rootForm){ - const sections = rootForm.get('sections') as UntypedFormArray; - if(!sections.controls.find(section=>section.get('page').value === this.parentLink.id)){ - return true; - } - } - } - - - //checking first child form controls if have errors - let hasErrors = false; - if(allFieldsAreTouched){ - if(form instanceof UntypedFormGroup){ - const formGroup = form as UntypedFormGroup; - - const controls = Object.keys(formGroup.controls); - - controls.forEach(control=>{ - if(formGroup.get(control).errors){ - hasErrors = true; - } - }) - - } - } - - return hasErrors; - } - - - allFieldsAreTouched(aControl:AbstractControl){//auto na testaroume - - if(!aControl|| aControl.untouched) return false; - - if(aControl instanceof UntypedFormControl){ - return aControl.touched; - }else if(aControl instanceof UntypedFormGroup){ - const controlKeys = Object.keys((aControl as UntypedFormGroup).controls); - let areAllTouched = true; - controlKeys.forEach(key=>{ - if(!this.allFieldsAreTouched(aControl.get(key))){ - areAllTouched = false; - } - }) - // const areAllTouched = controlKeys.reduce((acc, key)=>acc && this._allFieldsAreTouched(aControl.get(key)), true); - return areAllTouched; - - }else if(aControl instanceof UntypedFormArray){ - const controls = (aControl as UntypedFormArray).controls; - // const areAllTouched = controls.reduce((acc, control)=>acc && this._allFieldsAreTouched(control), true); - let areAllTouched = true; - // controls.reduce((acc, control)=>acc && this._allFieldsAreTouched(control), true); - controls.forEach(control=>{ - if(!this.allFieldsAreTouched(control)){ - areAllTouched = false; - } - }); - return areAllTouched; - } - - - return false; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html deleted file mode 100644 index 69b4f0247..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html +++ /dev/null @@ -1,32 +0,0 @@ -
-

{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.TEMPLATE-OUTLINE' | translate}}

-
- - - -
-
- keyboard_arrow_up -
-
-
-
- keyboard_arrow_down -
-
-
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss deleted file mode 100644 index dc1e64f35..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss +++ /dev/null @@ -1,92 +0,0 @@ -$scroller-height: 3em; -.scroll-container { - // overflow-y: auto; - max-height: 60vh; - overflow-y: scroll; - padding-left: .2em; - padding-right: 1em; - // padding-top: $scroller-height; - // padding-bottom: $scroller-height; -} - -// #style-6::-webkit-scrollbar-track -// { -// -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); -// background-color: #F5F5F5; -// } - -// #style-6::-webkit-scrollbar -// { -// width: 6px; -// background-color: #F5F5F5; -// } - -// #style-6::-webkit-scrollbar-thumb -// { -// background-color: rgb(162, 163, 163); -// background-image: -webkit-linear-gradient(45deg, -// rgba(255, 255, 255, .2) 25%, -// transparent 25%, -// transparent 50%, -// rgba(255, 255, 255, .2) 50%, -// rgba(255, 255, 255, .2) 75%, -// transparent 75%, -// transparent) -// } - - -#tocentrytable::-webkit-scrollbar-track -{ - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); - border-radius: 10px; - background-color: #F5F5F5; -} - -#tocentrytable::-webkit-scrollbar -{ - width: 4px; - background-color: #F5F5F5; -} - -#tocentrytable::-webkit-scrollbar-thumb -{ - border-radius: 2px; - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); - background-color: rgb(158, 158, 158);// #FFF;//$blue-color-light;// rgb(162, 163, 163);// #D62929; -} - - -#guide-steps{ - color: #212121; - opacity: 0.6; - font-size: 1.6em; - margin-top: 0px; -} - -.table-container{ - position: relative; -} -.table-scroller{ - // background-color: #5cf7f221; - position: absolute; - width: 95%; - height: $scroller-height; - display: flex; - align-items: center; - justify-content: center; - // z-index: -9999; -} -.top-scroller{ - top: 1px; - background: rgb(255,255,255); - background: linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(92,247,242,0.4542191876750701) 100%); -} -.bottom-scroller{ - bottom: 1px; - background: rgb(255,255,255); - background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(92,247,242,0.4542191876750701) 100%); -} - -.opacity-0{ - opacity: 0 !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts deleted file mode 100644 index 9fe19a5b9..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts +++ /dev/null @@ -1,605 +0,0 @@ -import { DOCUMENT } from '@angular/common'; -import { AfterViewInit, Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormArray } from '@angular/forms'; -import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { DragulaService } from 'ng2-dragula'; -import { interval } from 'rxjs'; -import { filter, takeUntil } from 'rxjs/operators'; -import { NewEntryType, TableUpdateInfo, ToCEntry, ToCEntryType } from './table-of-contents-entry'; - - -@Component({ - selector: 'dataset-profile-table-of-contents', - styleUrls: ['./table-of-contents.scss'], - templateUrl: './table-of-contents.html' -}) -export class DatasetProfileTableOfContents extends BaseComponent implements OnInit, AfterViewInit { - - @Input() links: ToCEntry[]; - @Input() itemSelected: ToCEntry; - @Input() colorizeInvalid: boolean = false; - @Input() viewOnly: boolean; - - - @Output() itemClick = new EventEmitter(); - // @Output() newEntry = new EventEmitter(); - @Output() removeEntry = new EventEmitter(); - @Output() createEntry = new EventEmitter(); - @Output() dataNeedsRefresh = new EventEmitter(); - - isDragging: boolean = false; - draggingItemId: string = null; - tocEntryType = ToCEntryType; - - DRAGULA_ITEM_ID_PREFIX = "table_item_id_"; - ROOT_ID: string = "ROOT_ID";//no special meaning - private _dragStartedAt; - private VALID_DROP_TIME = 500;//ms - overcontainer: string = null; - - $clock = interval(10); - scrollTableTop = false; - scrollTableBottom = false; - pxToScroll = 15; - - constructor( - @Inject(DOCUMENT) private _document: Document, - private dragulaService: DragulaService, - private snackbar: MatSnackBar, - private language: TranslateService - ) { - super(); - - if (this.dragulaService.find('TABLEDRAG')) { - this.dragulaService.destroy('TABLEDRAG'); - } - - const dragula = this.dragulaService.createGroup('TABLEDRAG', {}); - - const drake = dragula.drake; - - drake.on('drop', (el, target, source, sibling) => { - - if (this._dragStartedAt) { - const timeNow = new Date().getTime(); - - if (timeNow - this._dragStartedAt > this.VALID_DROP_TIME) { - // console.log('timenow: ', timeNow); - // console.log('timestarted', this._dragStartedAt); - this._dragStartedAt = null; - - } else { - this.dataNeedsRefresh.emit();// even though the data is not changed the TABLE DRAG may has changed - return; - } - } else { - this.dataNeedsRefresh.emit();// even though the data is not changed the TABLE DRAG may has changed - return; - - } - - const elementId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - const targetId = target.id as string; - const sourceId = source.id as string; - - - if (!(elementId && targetId && sourceId)) { - console.info('Elements do not have an id'); - this.dataNeedsRefresh.emit(); - return; - } - - - const element: ToCEntry = this._findTocEntryById(elementId, this.links); - const targetContainer: ToCEntry = this._findTocEntryById(targetId, this.links); - const sourceContainer: ToCEntry = this._findTocEntryById(sourceId, this.links); - - if (!(element && (targetContainer || ((element.type === ToCEntryType.Page) && (targetId === this.ROOT_ID))) && (sourceContainer || ((element.type === ToCEntryType.Page) && (sourceId === this.ROOT_ID))))) { - // console.info('Could not find elements'); - this.dataNeedsRefresh.emit(); - //TODO: angular update //drake.cancel(true); - return; - } - - - switch (element.type) { - case ToCEntryType.FieldSet: { - if (targetContainer.type != this.tocEntryType.Section) { - // const message = 'Fieldset can only be child of Subsections'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.FIELDSET-MUST-HAVE-PARENT-SECTION'); - // console.error(message); - this.notifyUser(message) - this.dataNeedsRefresh.emit(); - return; - } - - //check if target container has no sections - if ((targetContainer.form.get('sections') as UntypedFormArray).length) { - // const message = 'Cannot have inputs and sections on the same level'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL'); - this.notifyUser(message); - // console.error(message); - this.dataNeedsRefresh.emit(); - return; - } - - const fieldsetForm = element.form; - const targetFieldsets = targetContainer.form.get('fieldSets') as UntypedFormArray; - const sourceFieldsets = sourceContainer.form.get('fieldSets') as UntypedFormArray; - - if (!targetFieldsets) { - console.info('Not target fieldsets container found'); - this.dataNeedsRefresh.emit(); - return; - } - - let sourceOrdinal = -1; - let idx = -1; - sourceFieldsets.controls.forEach((elem, index) => { - if (elem.get('id').value === elementId) { - sourceOrdinal = elem.get('ordinal').value; - idx = index - } - }); - - if (sourceOrdinal >= 0 && idx >= 0) { - sourceFieldsets.removeAt(idx); - - sourceFieldsets.controls.forEach(control => { - const ordinal = control.get('ordinal'); - if ((ordinal.value >= sourceOrdinal) && sourceOrdinal > 0) { - const updatedOrdinalVal = ordinal.value - 1; - ordinal.setValue(updatedOrdinalVal); - } - }); - sourceFieldsets.controls.sort(this._compareOrdinals); - } - - let position: number = targetFieldsets.length; - - if (!sibling || !sibling.id) { - console.info('No sibling Id found'); - } else { - const siblingId = (sibling.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - let siblingIndex = -1; - targetFieldsets.controls.forEach((e, idx) => { - if (e.get('id').value === siblingId) { - siblingIndex = idx; - position = e.get('ordinal').value; - } - - }); - - if (siblingIndex >= 0) { //sibling found - - targetFieldsets.controls.filter(control => control.get('ordinal').value >= position).forEach(control => { - const ordinal = control.get('ordinal'); - const updatedOrdinalVal = ordinal.value + 1; - ordinal.setValue(updatedOrdinalVal); - }) - } - - } - - - fieldsetForm.get('ordinal').setValue(position); - targetFieldsets.insert(position, fieldsetForm); - targetFieldsets.controls.sort(this._compareOrdinals); - this.dataNeedsRefresh.emit({ draggedItemId: elementId }); - - break; - } - case ToCEntryType.Section: { - - if (targetContainer.type == ToCEntryType.Section) { - if ((targetContainer.form.get('fieldSets') as UntypedFormArray).length) { - // const message = 'Cannot have inputs and sections on the same level'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL');; - this.notifyUser(message); - // console.info(message); - this.dataNeedsRefresh.emit(); - return; - } - - const targetSections = targetContainer.form.get('sections') as UntypedFormArray; - const elementSectionForm = element.form; - const sourceSections = elementSectionForm.parent as UntypedFormArray; - - if (!(targetSections && sourceSections && elementSectionForm)) { - console.info('Could not load sections'); - this.dataNeedsRefresh.emit(); - return; - } - - let idx = -1; - sourceSections.controls.forEach((section, i) => { - if (section.get('id').value === elementId) { - idx = i; - } - }); - - if (!(idx >= 0)) { - console.info('Could not find element in Parent container'); - this.dataNeedsRefresh.emit(); - return; - } - - sourceSections.controls.filter(control => control.get('ordinal').value >= elementSectionForm.get('ordinal').value).forEach(control => { - const ordinal = control.get('ordinal'); - const updatedOrdinalVal = ordinal.value ? ordinal.value - 1 : 0; - ordinal.setValue(updatedOrdinalVal); - }); - - - sourceSections.removeAt(idx); - - let targetOrdinal = targetSections.length; - - if (sibling && sibling.id) { - const siblingId = sibling.id.replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - - targetSections.controls.forEach((section, i) => { - if (section.get('id').value === siblingId) { - targetOrdinal = section.get('ordinal').value; - } - }) - - // if(targetOrdinal!=targetSections.length){//mporei na einai idio - // section.get('ordinal').setValue(i+1); - targetSections.controls.filter(control => control.get('ordinal').value >= targetOrdinal).forEach(control => { - const ordinal = control.get('ordinal'); - const updatedOrdinalVal = ordinal.value + 1; - ordinal.setValue(updatedOrdinalVal); - }); - // } - - } else { - console.info('no siblings found'); - } - elementSectionForm.get('ordinal').setValue(targetOrdinal); - targetSections.insert(targetOrdinal, elementSectionForm); - - } else if (targetContainer.type === ToCEntryType.Page) { - // const pageId = targetContainer.form.get('id').value; - - const rootform = targetContainer.form.root; - const sectionForm = element.form; - const parentSections = sectionForm.parent as UntypedFormArray; - - let parentIndex = -1; - parentSections.controls.forEach((section, i) => { - if (section.get('id').value === elementId) { - parentIndex = i - } - }) - - - if (parentIndex < 0) { - console.info('could not locate section in parents array'); - this.dataNeedsRefresh.emit(); - return; - } - - //update parent sections ordinal - parentSections.controls.filter(section => section.get('ordinal').value >= sectionForm.get('ordinal').value).forEach(section => { - const ordinal = section.get('ordinal'); - const updatedOrdinalVal = ordinal.value ? ordinal.value - 1 : 0; - ordinal.setValue(updatedOrdinalVal); - }) - - parentSections.removeAt(parentIndex); - - - - let position = 0; - if (targetContainer.subEntries) { - position = targetContainer.subEntries.length; - } - //populate sections - const targetSectionsArray = rootform.get('sections') as UntypedFormArray; - - - if (sibling && sibling.id) { - const siblingId = sibling.id.replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - let indx = -1; - - targetContainer.subEntries.forEach((e, i) => { - if (e.form.get('id').value === siblingId) { - indx = i; - position = e.form.get('ordinal').value; - } - }); - if (indx >= 0) { - - // e.form.get('ordinal').setValue(i+1); - targetContainer.subEntries.filter(e => e.form.get('ordinal').value >= position).forEach(e => { - const ordinal = e.form.get('ordinal'); - const updatedOrdinalVal = ordinal.value + 1; - ordinal.setValue(updatedOrdinalVal); - }); - } - - } else { - console.info('No sibling found'); - } - - sectionForm.get('ordinal').setValue(position); - sectionForm.get('page').setValue(targetContainer.id); - targetSectionsArray.push(sectionForm); - - } else { - // const message = 'Drag not support to specific container'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.DRAG-NOT-SUPPORTED'); - this.notifyUser(message); - // console.info(message); - this.dataNeedsRefresh.emit(); - return; - } - - - - this.dataNeedsRefresh.emit({ draggedItemId: elementId }); - break; - } - case ToCEntryType.Page: { - if (targetId != this.ROOT_ID) { - // const message = 'A page element can only be at top level'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.PAGE-ELEMENT-ONLY-TOP-LEVEL'); - this.notifyUser(message); - // console.info(message); - this.dataNeedsRefresh.emit(); - return; - } - - const rootForm = element.form.root; - if (!rootForm) { - console.info('Could not find root!') - this.dataNeedsRefresh.emit(); - return; - } - - - const pages = rootForm.get('pages') as UntypedFormArray; - const pageForm = element.form; - - let index = -1; - - pages.controls.forEach((page, i) => { - if (page.get('id').value === elementId) { - index = i; - } - }); - - if (index < 0) { - console.info('Could not locate page on pages'); - this.dataNeedsRefresh.emit(); - return; - } - - - //ordinality - pages.controls.filter(page => page.get('ordinal').value >= pageForm.get('ordinal').value).forEach(page => { - const ordinal = page.get('ordinal'); - const ordinalVal = ordinal.value ? ordinal.value - 1 : 0; - ordinal.setValue(ordinalVal); - }); - - pages.removeAt(index); - - let targetPosition = pages.length; - - if (sibling) { - const siblingId = sibling.id.replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - - pages.controls.forEach((page, i) => { - if (page.get('id').value === siblingId) { - targetPosition = page.get('ordinal').value; - } - }); - } - pageForm.get('ordinal').setValue(targetPosition); - - //update ordinality - pages.controls.filter(page => page.get('ordinal').value >= targetPosition).forEach(page => { - const ordinal = page.get('ordinal'); - const ordinalVal = ordinal.value + 1; - ordinal.setValue(ordinalVal); - }); - - - pages.insert(targetPosition, pageForm); - this.dataNeedsRefresh.emit({ draggedItemId: elementId }); - break; - } - default: - - console.info('Could not support moving objects for specific type of element'); - this.dataNeedsRefresh.emit(); - return; - - } - }); - - - drake.on('drag', (el, source) => { - this._dragStartedAt = new Date().getTime(); - // console.log('drag fired'); - this.isDragging = true; - this.draggingItemId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - - // setTimeout(() => { - // if(this.isDragging){ - // this._scrollIntoDragginItem(this.draggingItemId); - // } - // }, this.VALID_DROP_TIME); - }); - drake.on('over', (el, container, source) => { - try { - this.overcontainer = container.id; - } catch (error) { - this.overcontainer = null; - } - }); - drake.on('dragend', (el) => { - this.isDragging = false; - this.draggingItemId = null; - this.overcontainer = null; - }); - - - - - } - ngAfterViewInit(): void { - - const top = document.querySelector('.top-scroller'); - const bottom = document.querySelector('.bottom-scroller'); - const tableDiv = document.querySelector('#tocentrytable'); - - try { - top.addEventListener('mouseover', (e) => { this.scrollTableTop = true; }, { - passive: true - }); - bottom.addEventListener('mouseover', (e) => { this.scrollTableBottom = true; }, { - passive: true - }); - - top.addEventListener('mouseout', (e) => { this.scrollTableTop = false }, { - passive: true - }); - bottom.addEventListener('mouseout', (e) => { this.scrollTableBottom = false; }, { - passive: true - }); - - - this.$clock - .pipe( - takeUntil(this._destroyed), - filter(() => this.scrollTableTop) - ) - .subscribe(() => { - try { - tableDiv.scrollBy(0, -this.pxToScroll); - } catch { } - }); - this.$clock - .pipe( - takeUntil(this._destroyed), - filter(() => this.scrollTableBottom) - ) - .subscribe(() => { - try { - tableDiv.scrollBy(0, this.pxToScroll); - } catch { } - }); - } catch { - console.log('could not find scrolling elements'); - } - - - } - - private _scrollIntoDragginItem(id: string) { - - // const table = document.getElementById('tocentrytable'); - // if(table){ - // // const element = document.getElementById('TABLE_ENTRY'+id); - // console.log('Table found!'); - // const element = document.getElementById('TABLE_ENTRY' + id); - // const elementFromTable = table.closest('#TABLE_ENTRY'+ id); - - - // if(elementFromTable){ - // console.log('found from table:', elementFromTable); - // } - // if(element){ - // console.log('Element found!'); - // // element.classList.add('text-danger'); - // // console.log(element); - - // const tableRect = table.getBoundingClientRect(); - // const elementRect = element.getBoundingClientRect(); - - - // console.log('tablerect :',tableRect); - // console.log('elementRect :',elementRect); - - // const dY = elementRect.top - tableRect.top; - // console.log('Distance from table is ', dY); - // // table.scroll({top:dY,behavior:'smooth'}); - // console.log('found from document ', element); - - // // element.scrollIntoView(); - // } - // // element.scrollIntoView(); - // } - } - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { - if (!tocentries) { - return null; - } - - let tocEntryFound = tocentries.find(entry => entry.id === id); - - if (tocEntryFound) { - return tocEntryFound; - } - - for (let entry of tocentries) { - const result = this._findTocEntryById(id, entry.subEntries); - if (result) { - tocEntryFound = result; - break; - } - } - - return tocEntryFound ? tocEntryFound : null; - } - - ngOnInit(): void { - - - } - - - itemClicked(item: ToCEntry) { - //leaf node - this.itemClick.emit(item); - } - - // addNewEntry(tce: ToCEntry){ - // this.newEntry.emit(tce); - // } - deleteEntry(currentLink: ToCEntry) { - this.removeEntry.emit(currentLink); - } - - createNewEntry(newEntry: NewEntryType) { - this.createEntry.emit(newEntry); - } - onDataNeedsRefresh() { - this.dataNeedsRefresh.emit(); - } - - notifyUser(message: string) { - this.snackbar.open(message, null, this._snackBarConfig); - } - - private _snackBarConfig: MatSnackBarConfig = { - duration: 2000 - } - - private _compareOrdinals(a, b) { - - const aValue = a.get('ordinal').value as number; - const bValue = b.get('ordinal').value as number; - - // if(!aValue || !bValue) return 0; - return aValue - bValue; - } - - -} 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 ecb2df333..08cc416ad 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 @@ -2,7 +2,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -33,7 +32,6 @@ import { ImportDescriptionTemplateDialogComponent } from './listing/import-descr imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, DescriptionTemplateRoutingModule, NgxDropzoneModule, 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 4318649bd..89762f754 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 @@ -92,8 +92,9 @@
- - + +
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 7775b1e19..700e44e14 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 @@ -35,9 +35,6 @@ import { import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { - DatasetDescriptionSectionEditorModel -} from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; import { TransitionGroupComponent } from "@app/ui/transition-group/transition-group.component"; import { BaseComponent } from '@common/base/base.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; @@ -47,8 +44,7 @@ import { Subject } from 'rxjs'; import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators'; import { GENERAL_ANIMATIONS } from '../../animations/animations'; import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators'; -import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model'; -import { ViewStyleType } from '../field/view-style-enum'; +import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel, DescriptionTemplateSectionEditorModel } from '../../description-template-editor.model'; @Component({ selector: 'app-description-template-editor-composite-field-component', @@ -237,7 +233,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon }); } - previewSubject$: Subject = new Subject(); + previewSubject$: Subject = new Subject(); private generatePreviewForm() { // const formValue: DescriptionTemplateFieldSet = this.form.getRawValue(); @@ -341,7 +337,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon addNewField() { const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create(); + field.id = Guid.create().toString(); field.ordinal = (this.form.get('fields') as UntypedFormArray).length; @@ -494,7 +490,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon } const field = { - id: Guid.create(), + id: Guid.create().toString(), ordinal: targetOrdinal, validations: [], includeInExport: true diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts index 25afc4373..3b9cdbda6 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts @@ -1,28 +1,28 @@ -import { Component, Input, OnInit} from '@angular/core'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +import { Component, Input, OnInit } from '@angular/core'; +import { Rule } from '@app/ui/description/editor/description-form/visibility-rules/models/rule'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; @Component({ selector: 'app-final-preview-component', templateUrl: './final-preview.component.html', styleUrls: ['./final-preview.component.scss'], - providers:[VisibilityRulesService] + providers: [VisibilityRulesService] }) -export class FinalPreviewComponent implements OnInit { +export class FinalPreviewComponent implements OnInit { + - @Input() formGroup = null; - @Input() visibilityRules:Rule[] = []; - constructor(private visibilityRulesService: VisibilityRulesService){ - + @Input() visibilityRules: Rule[] = []; + constructor(private visibilityRulesService: VisibilityRulesService) { + } - + ngOnInit(): void { this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.formGroup); } - + } diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts index 77a8e8e44..c3b1d5580 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts @@ -22,7 +22,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit @Input() datasetProfileId?: string; - @Output() selectedEntryId = new EventEmitter(); + @Output() selectedEntryId = new EventEmitter(); @Output() dataNeedsRefresh = new EventEmitter(); @Output() removeFieldSet = new EventEmitter(); @Output() addNewFieldSet = new EventEmitter(); @@ -101,11 +101,11 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit - private _selectedFieldSetId: Guid = null; + private _selectedFieldSetId: string = null; get selectedFieldSetId() { return this._selectedFieldSetId; } - set selectedFieldSetId(id: Guid) { + set selectedFieldSetId(id: string) { if (id === this._selectedFieldSetId) return; this._selectedFieldSetId = id; @@ -140,7 +140,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit } else { // console.warn('!not found numbering'); } - this._selectedFieldSetId = Guid.parse(this.tocentry.id); + this._selectedFieldSetId = this.tocentry.id; // this._scrollToElement(this.selectedFieldSetId); this.scroller.next(this.tocentry.id); @@ -194,13 +194,13 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit addFieldSetAfter(afterOrdinal: number, afterIndex: number): void { const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create(); + field.id = Guid.create().toString(); field.ordinal = 0;//first filed in the fields list const fieldForm = field.buildForm(); //give fieldset id and ordinal const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(); - const fieldSetId = Guid.create(); + const fieldSetId = Guid.create().toString(); fieldSet.id = fieldSetId; fieldSet.ordinal = afterOrdinal < 0 ? 0 : afterOrdinal; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts index 77df70aed..90d7edc70 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts @@ -28,10 +28,10 @@ export class DescriptionTemplateEditorSectionComponent extends BaseComponent imp fieldSet.ordinal = (this.form.get('fieldSets') as UntypedFormArray).length; const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create(); + field.id = Guid.create().toString(); field.ordinal = 0;//first field in fields fieldSet.fields.push(field); - fieldSet.id = Guid.create(); + fieldSet.id = Guid.create().toString(); const fieldsetsArray = this.form.get('fieldSets') as UntypedFormArray; fieldsetsArray.push(fieldSet.buildForm()); 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 e75c7eaed..280839d77 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 @@ -5,15 +5,14 @@ import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { BehaviorSubject } from 'rxjs'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { CdkStep, StepperSelectionEvent } from '@angular/cdk/stepper'; import { DatePipe } from '@angular/common'; -import { MatInput } from '@angular/material/input'; import { MatStepper } from '@angular/material/stepper'; import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; +import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { DescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist'; import { LanguageInfo } from '@app/core/model/language-info'; @@ -22,7 +21,6 @@ import { AuthService } from '@app/core/services/auth/auth.service'; import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service'; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; import { LoggingService } from '@app/core/services/logging/logging-service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { UserService } from '@app/core/services/user/user.service'; @@ -35,14 +33,12 @@ import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/ import { FilterService } from '@common/modules/text-filter/filter-service'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; -import { combineLatest } from 'rxjs'; -import { debounceTime, filter, map, takeUntil } from 'rxjs/operators'; +import { map, takeUntil } from 'rxjs/operators'; import { GENERAL_ANIMATIONS, STEPPER_ANIMATIONS } from './animations/animations'; import { DescriptionTemplateEditorModel, DescriptionTemplateFieldEditorModel, DescriptionTemplateFieldSetEditorModel, DescriptionTemplatePageEditorModel, DescriptionTemplateSectionEditorModel, UserDescriptionTemplateEditorModel } from './description-template-editor.model'; import { DescriptionTemplateEditorResolver } from './description-template-editor.resolver'; import { DescriptionTemplateEditorService } from './description-template-editor.service'; import { NewEntryType, ToCEntry, ToCEntryType } from './table-of-contents/description-template-table-of-contents-entry'; -import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role'; @Component({ @@ -130,7 +126,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor {this.usersMap.set(obj.user.id, obj.user); }); + (this.item?.users ?? []).forEach(obj => { this.usersMap.set(obj.user.id, obj.user); }); this.isDeleted = data ? data.isActive === IsActive.Inactive : false; this.buildForm(); @@ -267,7 +262,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditorthis.formGroup.get('pages'))?.length; } 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 6f8046505..d4ea24d40 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 @@ -208,7 +208,7 @@ export class DescriptionTemplateDefinitionEditorModel implements DescriptionTemp } export class DescriptionTemplatePageEditorModel implements DescriptionTemplatePagePersist { - id: Guid; + id: string; ordinal: number; title: string; @@ -266,7 +266,7 @@ export class DescriptionTemplatePageEditorModel implements DescriptionTemplatePa } export class DescriptionTemplateSectionEditorModel implements DescriptionTemplateSectionPersist { - id: Guid; + id: string; ordinal: number; defaultVisibility: boolean = false; // TODO: check if used and remove multiplicity: boolean = false; @@ -364,7 +364,7 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat } export class DescriptionTemplateFieldSetEditorModel implements DescriptionTemplateFieldSetPersist { - id: Guid; + id: string; ordinal: number; numbering: string = "0"; // Check if used and remove title: string; @@ -525,7 +525,7 @@ export class DescriptionTemplateMultiplicityEditorModel implements DescriptionTe // // export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateFieldPersist { - id: Guid; + id: string; ordinal: number; schematics: string[]; defaultValue: string; diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts index c0cce8cea..fa3871907 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { ImportDmpBlueprintDialogComponent } from './listing/import-dmp-blueprin imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, DmpBlueprintRoutingModule, NgxDropzoneModule, 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 802661181..400849d3b 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 @@ -15,17 +15,13 @@ 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 { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; import { DmpBlueprint, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DmpService } from '@app/core/services/dmp/dmp.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 { 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 { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; @@ -35,7 +31,6 @@ import { FilterService } from '@common/modules/text-filter/filter-service'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; import * as FileSaver from 'file-saver'; -import { Observable } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; import { DescriptionTemplatesInSectionEditorModel, DmpBlueprintDefinitionSectionEditorModel, DmpBlueprintEditorModel, FieldInSectionEditorModel } from './dmp-blueprint-editor.model'; import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver'; @@ -61,14 +56,15 @@ export class DmpBlueprintEditorComponent extends BaseEditor(DmpBlueprintExtraFieldDataType); - blueprintsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterDescriptionTempaltes.bind(this), - initialItems: (excludedItems: any[]) => this.filterDescriptionTempaltes('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item: DatasetProfileModel) => item.label, - titleFn: (item: DatasetProfileModel) => item.label, - subtitleFn: (item: DatasetProfileModel) => item.description, - popupItemActionIcon: 'visibility' - }; + //TODO refactor + // blueprintsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { + // filterFn: this.filterDescriptionTempaltes.bind(this), + // initialItems: (excludedItems: any[]) => this.filterDescriptionTempaltes('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + // displayFn: (item: DatasetProfileModel) => item.label, + // titleFn: (item: DatasetProfileModel) => item.label, + // subtitleFn: (item: DatasetProfileModel) => item.description, + // popupItemActionIcon: 'visibility' + // }; protected get canDelete(): boolean { return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteDmpBlueprint); @@ -318,13 +314,14 @@ export class DmpBlueprintEditorComponent extends BaseEditor { - const request = new DataTableRequest(null, null, { fields: ['+label'] }); - const criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this.dmpService.searchDmpBlueprints(request); - } + //TODO refactor + // filterDescriptionTempaltes(value: string): Observable { + // const request = new DataTableRequest(null, null, { fields: ['+label'] }); + // const criteria = new DatasetProfileCriteria(); + // criteria.like = value; + // request.criteria = criteria; + // return this.dmpService.searchDmpBlueprints(request); + // } onRemoveDescritionTemplate(event, sectionIndex: number) { const descriptionTemplateFormArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray; diff --git a/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts b/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts index 4abe57908..5f9077200 100644 --- a/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts +++ b/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts @@ -1,11 +1,9 @@ import { Component, OnInit } from '@angular/core'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; import { BaseComponent } from '@common/base/base.component'; import { takeUntil } from 'rxjs/operators'; import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; import { TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; import { MaintenanceService } from '@app/core/services/maintenance/maintenance.service'; @Component({ @@ -16,7 +14,6 @@ import { MaintenanceService } from '@app/core/services/maintenance/maintenance.s export class IndexManagmentComponent extends BaseComponent implements OnInit { constructor( - private datasetService: DatasetService, private uiNotificationService: UiNotificationService, private translate: TranslateService, private router: Router, diff --git a/dmp-frontend/src/app/ui/admin/language/language.module.ts b/dmp-frontend/src/app/ui/admin/language/language.module.ts index f188ebe86..b3c3fd6da 100644 --- a/dmp-frontend/src/app/ui/admin/language/language.module.ts +++ b/dmp-frontend/src/app/ui/admin/language/language.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-ed imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, LanguageRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.html b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.html index 7e90cea4f..d1a063acb 100644 --- a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.html +++ b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.html @@ -2,8 +2,8 @@
Warning: Danger zone. Irreversible actions!
- - + +
diff --git a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.ts b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.ts index 4c86f3dd6..65b3ca8b0 100644 --- a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.ts +++ b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.component.ts @@ -1,65 +1,65 @@ import { Component, OnInit } from '@angular/core'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; -import { TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; -import { MaintenanceTasksService } from '@app/core/services/maintenance-tasks/maintenance-tasks.service'; +import { MaintenanceService } from '@app/core/services/maintenance/maintenance.service'; +import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { BaseComponent } from '@common/base/base.component'; +import { TranslateService } from '@ngx-translate/core'; @Component({ - selector: 'app-maintenance-tasks', - templateUrl: './maintenance-tasks.component.html', - styleUrls: ['./maintenance-tasks.component.scss'] + selector: 'app-maintenance-tasks', + templateUrl: './maintenance-tasks.component.html', + styleUrls: ['./maintenance-tasks.component.scss'] }) export class MaintenanceTasksComponent extends BaseComponent implements OnInit { - constructor( - private maintenanceTasksService: MaintenanceTasksService, - private uiNotificationService: UiNotificationService, - private translate: TranslateService, - private router: Router, - ) { - super(); - } + constructor( + private maintenanceService: MaintenanceService, + private uiNotificationService: UiNotificationService, + private translate: TranslateService, + private router: Router, + ) { + super(); + } - ngOnInit(): void { - } + ngOnInit(): void { + } - migrateSemantics(ev: Event) { - (ev.srcElement as HTMLButtonElement).disabled = true; - this.maintenanceTasksService.migrateSemantics().pipe(takeUntil(this._destroyed)).subscribe( - response => { - (ev.srcElement as HTMLButtonElement).disabled = false; - this.onCallbackSuccess(); - }, - error => { - (ev.srcElement as HTMLButtonElement).disabled = false; - this.onCallbackError(error); - } - ); - } + //TODO: refactor + // migrateSemantics(ev: Event) { + // (ev.srcElement as HTMLButtonElement).disabled = true; + // this.maintenanceTasksService.migrateSemantics().pipe(takeUntil(this._destroyed)).subscribe( + // response => { + // (ev.srcElement as HTMLButtonElement).disabled = false; + // this.onCallbackSuccess(); + // }, + // error => { + // (ev.srcElement as HTMLButtonElement).disabled = false; + // this.onCallbackError(error); + // } + // ); + // } - addRdaInSemantics(ev: Event) { - (ev.srcElement as HTMLButtonElement).disabled = true; - this.maintenanceTasksService.addRdaInSemantics().pipe(takeUntil(this._destroyed)).subscribe( - response => { - (ev.srcElement as HTMLButtonElement).disabled = false; - this.onCallbackSuccess(); - }, - error => { - (ev.srcElement as HTMLButtonElement).disabled = false; - this.onCallbackError(error); - } - ); - } + // addRdaInSemantics(ev: Event) { + // (ev.srcElement as HTMLButtonElement).disabled = true; + // this.maintenanceTasksService.addRdaInSemantics().pipe(takeUntil(this._destroyed)).subscribe( + // response => { + // (ev.srcElement as HTMLButtonElement).disabled = false; + // this.onCallbackSuccess(); + // }, + // error => { + // (ev.srcElement as HTMLButtonElement).disabled = false; + // this.onCallbackError(error); + // } + // ); + // } - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification( this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/reload']).then(() => this.router.navigate(['/maintenance-tasks'])); - } - - onCallbackError(error: any) { - this.uiNotificationService.snackBarNotification( error, SnackBarNotificationLevel.Error); - } + onCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + this.router.navigate(['/reload']).then(() => this.router.navigate(['/maintenance-tasks'])); + } + + onCallbackError(error: any) { + this.uiNotificationService.snackBarNotification(error, SnackBarNotificationLevel.Error); + } } diff --git a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.module.ts b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.module.ts index fe1988755..ce65af9ee 100644 --- a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.module.ts +++ b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.module.ts @@ -5,7 +5,6 @@ import { MaintenanceTasksComponent } from './maintenance-tasks.component'; import { CommonUiModule } from '@common/ui/common-ui.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { MaintenanceTasksService } from '@app/core/services/maintenance-tasks/maintenance-tasks.service'; @NgModule({ @@ -17,7 +16,6 @@ import { MaintenanceTasksService } from '@app/core/services/maintenance-tasks/ma MaintenanceTasksRoutingModule ], providers: [ - MaintenanceTasksService ] }) export class MaintenanceTasksModule { } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts b/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts index c324591a2..0e494b5fe 100644 --- a/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts +++ b/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -22,7 +21,6 @@ import { EditorModule } from '@tinymce/tinymce-angular'; imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, NotificationTemplateRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts b/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts index 8a4e8ab4d..57eca9e06 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts @@ -9,7 +9,6 @@ import { HybridListingModule } from '@common/modules/hybrid-listing/hybrid-listi import { TextFilterModule } from '@common/modules/text-filter/text-filter.module'; import { UserSettingsModule } from '@common/modules/user-settings/user-settings.module'; import { ReferenceTypeListingFiltersComponent } from './listing/filters/reference-type-listing-filters.component'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { NgxDropzoneModule } from 'ngx-dropzone'; import { DragDropModule } from '@angular/cdk/drag-drop'; @@ -28,7 +27,6 @@ import { ReferenceTypeListingComponent } from './listing/reference-type-listing. CommonModule, CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, ReferenceTypeRoutingModule, EditorModule, diff --git a/dmp-frontend/src/app/ui/admin/reference/reference.module.ts b/dmp-frontend/src/app/ui/admin/reference/reference.module.ts index 8bcc715e9..e7a9a6940 100644 --- a/dmp-frontend/src/app/ui/admin/reference/reference.module.ts +++ b/dmp-frontend/src/app/ui/admin/reference/reference.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-ed imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, ReferenceRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts b/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts index bd58b40e6..79e6dceb0 100644 --- a/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts +++ b/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-ed imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, TenantRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.html b/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.html deleted file mode 100644 index 4170ef7b5..000000000 --- a/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.html +++ /dev/null @@ -1,22 +0,0 @@ -
-
-
-
-

{{ 'EMAIL-CONFIRMATION.CARD-TITLE' | translate }}

-
-
-
-
{{ 'EMAIL-CONFIRMATION.REQUEST-EMAIL-HEADER' | translate }}
-

{{ 'EMAIL-CONFIRMATION.REQUEST-EMAIL-TEXT' | translate }}

- - - - -
-
{{ 'EMAIL-CONFIRMATION.SENT-EMAIL-HEADER' | translate }}
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.scss b/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.scss deleted file mode 100644 index 4b946ea03..000000000 --- a/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.scss +++ /dev/null @@ -1,5 +0,0 @@ -.form { - min-width: 150px; - max-width: 500px; - width: 100%; - } diff --git a/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.ts b/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.ts deleted file mode 100644 index ae92d1208..000000000 --- a/dmp-frontend/src/app/ui/auth/login/email-confirmation/email-confirmation.component.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Component, OnInit } from "@angular/core"; -import { UntypedFormControl } from '@angular/forms'; -import { ActivatedRoute, Router } from "@angular/router"; -import { EmailConfirmationService } from '@app/core/services/email-confirmation/email-confirmation.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { takeUntil } from "rxjs/operators"; - -@Component({ - selector: 'app-email-confirmation-component', - templateUrl: './email-confirmation.component.html' -}) -export class EmailConfirmation extends BaseComponent implements OnInit { - - public emailFormControl = new UntypedFormControl(''); - public showForm: boolean = false; - public mailSent: boolean = false; - - constructor( - private emailConfirmationService: EmailConfirmationService, - private route: ActivatedRoute, - private router: Router, - private language: TranslateService, - private uiNotificationService: UiNotificationService - ) { super(); } - - ngOnInit() { - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe(params => { - const token = params['token'] - if (token != null) { - this.showForm = false; - this.emailConfirmationService.emailConfirmation(token) - .pipe(takeUntil(this._destroyed)) - .subscribe( - result => this.onCallbackEmailConfirmationSuccess(), - error => this.onCallbackError(error) - ) - } else { - this.showForm = true; - } - }); - } - - sendConfirmationEmail() { - this.emailConfirmationService.sendConfirmationEmail(this.emailFormControl.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - result => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ) - } - - onCallbackSuccess() { - this.mailSent = true; - } - - onCallbackEmailConfirmationSuccess() { - this.router.navigate(['home']); - } - - onCallbackError(error: any) { - if (error.status === 302) { - this.uiNotificationService.snackBarNotification(this.language.instant('EMAIL-CONFIRMATION.EMAIL-FOUND'), SnackBarNotificationLevel.Warning); - this.router.navigate(['home']); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL'), SnackBarNotificationLevel.Error); - this.router.navigate(['login']); - } - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/login.component.ts b/dmp-frontend/src/app/ui/auth/login/login.component.ts index 4b2216188..9fe5e0c52 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.component.ts @@ -3,12 +3,6 @@ import { ActivatedRoute } from '@angular/router'; import { AuthService } from '@app/core/services/auth/auth.service'; import { BaseComponent } from '@common/base/base.component'; -/// -/// - -declare const gapi: any; -declare const FB: any; - @Component({ selector: 'app-login', templateUrl: './login.component.html', diff --git a/dmp-frontend/src/app/ui/auth/login/login.module.ts b/dmp-frontend/src/app/ui/auth/login/login.module.ts index a0aae9b78..224ebb388 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.module.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.module.ts @@ -1,5 +1,4 @@ import { NgModule } from '@angular/core'; -import { EmailConfirmation } from '@app/ui/auth/login/email-confirmation/email-confirmation.component'; import { LoginComponent } from '@app/ui/auth/login/login.component'; import { LoginRoutingModule } from '@app/ui/auth/login/login.routing'; import { LoginService } from '@app/ui/auth/login/utilities/login.service'; @@ -7,7 +6,6 @@ import { Oauth2DialogModule } from '@app/ui/misc/oauth2-dialog/oauth2-dialog.mod import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component'; -import { MergeLoginService } from './utilities/merge-login.service'; import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component'; @NgModule({ @@ -19,13 +17,12 @@ import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-emai ], declarations: [ LoginComponent, - EmailConfirmation, MergeEmailConfirmation, UnlinkEmailConfirmation, ], exports: [ LoginComponent ], - providers: [LoginService, MergeLoginService] + providers: [LoginService] }) export class LoginModule { } diff --git a/dmp-frontend/src/app/ui/auth/login/login.routing.ts b/dmp-frontend/src/app/ui/auth/login/login.routing.ts index 48e43575e..c874ba0c7 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.routing.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.routing.ts @@ -1,16 +1,13 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { EmailConfirmation } from './email-confirmation/email-confirmation.component'; import { LoginComponent } from './login.component'; import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component'; import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component'; const routes: Routes = [ { path: '', component: LoginComponent }, - { path: 'confirmation/:token', component: EmailConfirmation }, { path: 'merge/confirmation/:token', component: MergeEmailConfirmation }, { path: 'unlink/confirmation/:token', component: UnlinkEmailConfirmation }, - { path: 'confirmation', component: EmailConfirmation } ]; @NgModule({ diff --git a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts index 1feabe3ee..20dd25566 100644 --- a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts @@ -2,8 +2,6 @@ import { Component, OnInit } from "@angular/core"; import { UntypedFormControl } from '@angular/forms'; import { ActivatedRoute, Router } from "@angular/router"; import { AuthService } from "@app/core/services/auth/auth.service"; -import { EmailConfirmationService } from '@app/core/services/email-confirmation/email-confirmation.service'; -import { MergeEmailConfirmationService } from '@app/core/services/merge-email-confirmation/merge-email-confirmation.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; @@ -20,7 +18,8 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit { public mailSent: boolean = false; constructor( - private emailConfirmationService: MergeEmailConfirmationService, + //TODO: refactor + // private emailConfirmationService: MergeEmailConfirmationService, private authService: AuthService, private route: ActivatedRoute, private router: Router, @@ -35,18 +34,19 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit { const token = params['token'] if (token != null) { this.showForm = false; - this.emailConfirmationService.emailConfirmation(token) - .pipe(takeUntil(this._destroyed)) - .subscribe( - result => { - const email = this.authService.getUserProfileEmail(); - if(!email || !result || (email == result)) - this.authService.clear(); - this.uiNotificationService.snackBarNotification(this.language.instant('USER-PROFILE.MERGING-SUCCESS'), SnackBarNotificationLevel.Success); - this.onCallbackEmailConfirmationSuccess(); - }, - error => this.onCallbackError(error) - ) + //TODO: refactor + // this.emailConfirmationService.emailConfirmation(token) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // result => { + // const email = this.authService.getUserProfileEmail(); + // if(!email || !result || (email == result)) + // this.authService.clear(); + // this.uiNotificationService.snackBarNotification(this.language.instant('USER-PROFILE.MERGING-SUCCESS'), SnackBarNotificationLevel.Success); + // this.onCallbackEmailConfirmationSuccess(); + // }, + // error => this.onCallbackError(error) + // ) } else { this.showForm = true; } @@ -62,8 +62,8 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit { this.uiNotificationService.snackBarNotification(this.language.instant('EMAIL-CONFIRMATION.EMAIL-FOUND'), SnackBarNotificationLevel.Warning); this.router.navigate(['home']); } else { - this.uiNotificationService.snackBarNotification(this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL'), SnackBarNotificationLevel.Error); - this.router.navigate(['login']); + this.uiNotificationService.snackBarNotification(this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL'), SnackBarNotificationLevel.Error); + this.router.navigate(['login']); } } } diff --git a/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts b/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts index 453eb754c..339d3e631 100644 --- a/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/unlink-email-confirmation/unlink-email-confirmation.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { UnlinkAccountEmailConfirmationService } from '@app/core/services/unlink-account-email-confirmation/unlink-account-email-confirmation.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; @@ -13,7 +12,6 @@ import { takeUntil } from "rxjs/operators"; export class UnlinkEmailConfirmation extends BaseComponent implements OnInit { constructor( - private emailConfirmationService: UnlinkAccountEmailConfirmationService, private route: ActivatedRoute, private router: Router, private language: TranslateService, @@ -26,12 +24,13 @@ export class UnlinkEmailConfirmation extends BaseComponent implements OnInit { .subscribe(params => { const token = params['token'] if (token != null) { - this.emailConfirmationService.emailConfirmation(token) - .pipe(takeUntil(this._destroyed)) - .subscribe( - result => this.onCallbackEmailConfirmationSuccess(), - error => this.onCallbackError(error) - ) + //TODO refactor + // this.emailConfirmationService.emailConfirmation(token) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // result => this.onCallbackEmailConfirmationSuccess(), + // error => this.onCallbackError(error) + // ) } }); } diff --git a/dmp-frontend/src/app/ui/auth/login/utilities/merge-login.service.ts b/dmp-frontend/src/app/ui/auth/login/utilities/merge-login.service.ts deleted file mode 100644 index 7ca95970a..000000000 --- a/dmp-frontend/src/app/ui/auth/login/utilities/merge-login.service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Injectable } from '@angular/core'; -import { UserMergeRequestModel } from '@app/core/model/merge/user-merge-request'; -import { Observable, Subject } from 'rxjs'; - -@Injectable() -export class MergeLoginService { - private serviceStore = new Subject(); - - getObservable(): Observable { - return this.serviceStore.asObservable(); - } - - setRequest(request: UserMergeRequestModel) { - this.serviceStore.next(request); - } -} diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts index e96011ff1..e9bdb74cf 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts @@ -11,7 +11,7 @@ import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service' import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; import { takeUntil } from 'rxjs/operators'; -import { StartNewDmpDialogComponent } from '../dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; +import { StartNewDmpDialogComponent } from '../dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component'; @Component({ diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts index 915656f2c..fcb9c5f13 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts @@ -1,32 +1,31 @@ import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormattingModule } from '@app/core/formatting.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; import { DashboardComponent } from '@app/ui/dashboard/dashboard.component'; import { DashboardRoutingModule } from '@app/ui/dashboard/dashboard.routing'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; -import { DatasetCopyDialogModule } from '../dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module'; import { DescriptionModule } from '../description/description.module'; import { DmpModule } from '../dmp/dmp.module'; import { DraftsComponent } from './drafts/drafts.component'; import { RecentEditedActivityComponent } from './recent-edited-activity/recent-edited-activity.component'; import { RecentEditedDescriptionActivityComponent } from './recent-edited-description-activity/recent-edited-description-activity.component'; import { RecentEditedDmpActivityComponent } from './recent-edited-dmp-activity/recent-edited-dmp-activity.component'; +import { StartNewDmpDialogModule } from '../dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.module'; @NgModule({ imports: [ CommonUiModule, FormattingModule, DashboardRoutingModule, - ExportMethodDialogModule, ConfirmationDialogModule, - DatasetCopyDialogModule, + // DatasetCopyDialogModule, FormsModule, ReactiveFormsModule, DmpModule, //TODO: add only listing component to a seperate module - DescriptionModule //TODO: add only listing component to a seperate module + DescriptionModule, //TODO: add only listing component to a seperate module + StartNewDmpDialogModule ], declarations: [ DashboardComponent, diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html index 964c18692..647f8a1c7 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html @@ -24,8 +24,8 @@
- - + +
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts index d71b40a1c..524733b50 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts @@ -7,17 +7,18 @@ import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-it import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from "@app/core/model/dmp/dmp"; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { FileFormat } from '@app/core/model/file/file-format.model'; +import { Reference } from '@app/core/model/reference/reference'; import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { DashboardService } from "@app/core/services/dashboard/dashboard.service"; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { BaseComponent } from '@common/base/base.component'; import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { AuthService } from '../../../core/services/auth/auth.service'; -import { FileFormat } from '@app/core/model/file/file-format.model'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; @Component({ selector: 'app-drafts', @@ -29,7 +30,6 @@ export class DraftsComponent extends BaseComponent implements OnInit { lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); pageSize: number = 5; listingItems: RecentActivityItem[]; - fileFormats: FileFormat[] = []; public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), @@ -53,7 +53,7 @@ export class DraftsComponent extends BaseComponent implements OnInit { private dashboardService: DashboardService, private location: Location, private matomoService: MatomoService, - private dmpServiceNew: DmpServiceNew + private dmpService: DmpService ) { super(); } @@ -76,9 +76,10 @@ export class DraftsComponent extends BaseComponent implements OnInit { order = this.order.UpdatedAt; } } else { - if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { - order = this.order.PUBLISHED; - } + //TODO refactor + // if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { + // order = this.order.PUBLISHED; + // } } this.formGroup.get('order').setValue(order); @@ -88,10 +89,6 @@ export class DraftsComponent extends BaseComponent implements OnInit { this.updateUrl(); } }); - this.dmpServiceNew.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result); - if (this.isAuthenticated()) { - this.refresh(); - } } ngOnChanges() { @@ -103,7 +100,8 @@ export class DraftsComponent extends BaseComponent implements OnInit { updateUrl() { let parameters = "?type=dmps" + (this.page != 1 ? "&page=" + this.page : "") + - (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + + //TODO refactor + //(((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); this.location.go(this.router.url.split('?')[0] + parameters); } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html index 957d1e861..2c61f0e17 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html @@ -26,7 +26,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index a94a3e005..8f6a6f352 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -7,12 +7,13 @@ import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-it import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; import { FileFormat } from '@app/core/model/file/file-format.model'; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { Reference } from '@app/core/model/reference/reference'; import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DashboardService } from '@app/core/services/dashboard/dashboard.service'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { BaseComponent } from '@common/base/base.component'; @@ -29,8 +30,6 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); pageSize: number = 5; listingItems: RecentActivityItem[]; - fileFormats: FileFormat[] = []; - public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), @@ -54,7 +53,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn private dashboardService: DashboardService, private location: Location, private matomoService: MatomoService, - private dmpServiceNew: DmpServiceNew + private dmpService: DmpService ) { super(); } @@ -77,9 +76,10 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn order = this.order.UpdatedAt; } } else { - if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { - order = this.order.PUBLISHED; - } + //TODO refactor + // if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { + // order = this.order.PUBLISHED; + // } } this.formGroup.get('order').setValue(order); @@ -89,10 +89,6 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn this.updateUrl(); } }); - this.dmpServiceNew.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result); - if (this.isAuthenticated()) { - this.refresh(); - } } ngOnChanges() { @@ -104,7 +100,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn updateUrl() { let parameters = "?type=dmps" + (this.page != 1 ? "&page=" + this.page : "") + - (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + + //TODO refactor + //(((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); this.location.go(this.router.url.split('?')[0] + parameters); } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts index 8ae9d67ca..a9f39ee5a 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts @@ -6,7 +6,8 @@ import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { Reference } from '@app/core/model/reference/reference'; import { DescriptionLookup } from '@app/core/query/description.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DescriptionService } from '@app/core/services/description/description.service'; @@ -72,9 +73,10 @@ export class RecentEditedDescriptionActivityComponent extends BaseComponent impl order = this.order.UpdatedAt; } } else { - if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { - order = this.order.PUBLISHED; - } + //TODO refactor + // if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { + // order = this.order.PUBLISHED; + // } } this.formGroup.get('order').setValue(order); @@ -98,7 +100,8 @@ export class RecentEditedDescriptionActivityComponent extends BaseComponent impl updateUrl() { let parameters = "?type=dmps" + (this.page != 1 ? "&page=" + this.page : "") + - (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + + //TODO refactor + //(((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); this.location.go(this.router.url.split('?')[0] + parameters); } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html index 9f44d103b..5f3495173 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html @@ -24,7 +24,7 @@
- +
- -
-
-
-
- diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss deleted file mode 100644 index 69f3e2062..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss +++ /dev/null @@ -1,50 +0,0 @@ -.confirmation-message { - padding-bottom: 20px; -} - -.close-btn { - cursor: pointer; -} - -.dataset-copy-dialog { - margin-bottom: 1.125rem; -} - -.cancel-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid #b5b5b5; - border-radius: 30px; -min-width: 101px; - height: 43px; - color: #212121; - font-weight: 500; -} - -.confirm-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid var(--primary-color); - border-radius: 30px; - opacity: 1; -min-width: 101px; - height: 43px; - color: var(--primary-color); - font-weight: 500; -} - -.confirm-btn:hover { - background-color: var(--primary-color); - color: #ffffff; -} - -.close-icon { - cursor: pointer; - // margin-right: 20px; - padding: .4rem; - width: auto !important; - height: auto !important; -} - -.close-icon:hover { - background-color: #ECECED !important; - border-radius: 50%; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts deleted file mode 100644 index dc98a3e37..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts +++ /dev/null @@ -1,95 +0,0 @@ - -import { map, filter } from 'rxjs/operators'; -import { Component } from "@angular/core"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; -import { SingleAutoCompleteConfiguration } from "../../../../library/auto-complete/single/single-auto-complete-configuration"; -import { Observable } from "rxjs"; -import { DataTableRequest } from "../../../../core/model/data-table/data-table-request"; -import { DmpCriteria } from "../../../../core/query/dmp/dmp-criteria"; -import { DmpListingModel } from "../../../../core/model/dmp/dmp-listing"; -import { DmpService } from "../../../../core/services/dmp/dmp.service"; -import { Inject } from "@angular/core"; -import { DmpModel } from "../../../../core/model/dmp/dmp"; -import { TranslateService } from "@ngx-translate/core"; - -@Component({ - selector: 'dataset-copy-dialogue-component', - templateUrl: 'dataset-copy-dialogue.component.html', - styleUrls: ['./dataset-copy-dialogue.component.scss'], -}) -export class DatasetCopyDialogueComponent { - - dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - dmpModel: DmpModel; - datasetDescriptionTemplateLabel: String; - - constructor( - public dialogRef: MatDialogRef, - public dmpService: DmpService, - public language: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } - - ngOnInit() { - this.dmpAutoCompleteConfiguration = { - filterFn: this.searchDmp.bind(this), - initialItems: (extraData) => this.searchDmp(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - }; - } - - cancel() { - this.dialogRef.close(this.data); - } - - confirm() { - this.datasetProfileValidate().subscribe(x => { - if (this.data.datasetProfileExist) { - this.dialogRef.close(this.data); - } - else if (!this.data.datasetProfileExist) { - this.data.formControl.setErrors({ 'incorrect': true }); - } - }); - } - - searchDmp(query: string): Observable { - const fields: Array = new Array(); - fields.push('asc'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = query; - dmpDataTableRequest.criteria.datasetTemplates = [this.data.datasetProfileId]; - return this.dmpService.getPaged(dmpDataTableRequest, "profiles").pipe(map(x => x.data)); - } - - datasetProfileValidate() { - return this.dmpService.getSingle(this.data.formControl.value.id).pipe(map(result => result as DmpModel), - map(result => { - this.dmpModel = result - this.dmpModel.profiles.forEach((element) => { - if (element.id == this.data.datasetProfileId) { - this.data.datasetProfileExist = true; - } - }) - })); - } - - getErrorMessage() { - return this.language.instant('DATASET-WIZARD.DIALOGUE.ERROR-MESSAGE'); - } - - hasValidDatasetProfile() { - if (this.data.datasetProfileExist) { - return true; - } - else { - return false; - } - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts deleted file mode 100644 index d1c8a4602..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { DatasetCopyDialogueComponent } from './dataset-copy-dialogue.component'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - AutoCompleteModule - ], - declarations: [ - DatasetCopyDialogueComponent - ] -}) -export class DatasetCopyDialogModule { } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html deleted file mode 100644 index c56c214e4..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html +++ /dev/null @@ -1,107 +0,0 @@ -
-
-

{{'DATASET-EDITOR.TITLE.INTRO' | translate}}

- {{'DATASET-EDITOR.TITLE.INTRO-TIP' | translate}} -
-
- -
-
-
1.1 {{'DATASET-EDITOR.FIELDS.TITLE' | translate}}*
- - -
- - - {{formGroup.get('label').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
- -
-
-
1.2 {{'DATASET-EDITOR.FIELDS.DESCRIPTION' | translate}}
- {{'DATASET-EDITOR.HINT.DESCRIPTION' | translate}} - -
- - -
- {{formGroup.get('description').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - - -
1.4 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
-
- - - -
- {{profile.label}} -
-
-
- {{formGroup.get('profile').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss deleted file mode 100644 index b006bc845..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss +++ /dev/null @@ -1,117 +0,0 @@ -.dataset-editor { - .intro { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - opacity: 1; - margin: 3rem 0rem 3rem 0rem; - } - - .heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-top: 1.625rem; - margin-bottom: 0.625rem; - } - - .hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 2.125rem; - } - - .title-form, - .description-form, - .profile-form { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0.15px; - color: #7d7d7d; - opacity: 1; - margin-bottom: 1rem; - } - - // textarea::placeholder { - // font-style: oblique; - // } - - .input-btn { - border: none; - color: #aaaaaa; - background-color: #ffffff00; - cursor: pointer; - } - - .input-btn :hover { - color: var(--primary-color-3) !important; - } - - .dmp-link { - color: #3fafac; - font-weight: 400; - font-size: 16px; - cursor: pointer; - } - - .dmp-link:hover { - text-decoration: underline; - } -} - -::ng-deep .title-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .description-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .uri-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .tags-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .profile-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - - - - -::ng-deep .title-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .description-form .mat-form-field-appearance-outline .mat-form-field-infix { - // font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .uri-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .tags-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .profile-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts deleted file mode 100644 index e9b339ad4..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { Router } from '@angular/router'; -import { BaseComponent } from '@common/base/base.component'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; -import { TranslateService } from '@ngx-translate/core'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { takeUntil } from 'rxjs/operators'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { MatDialog } from '@angular/material/dialog'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { Guid } from '@common/types/guid'; -import { nameof } from 'ts-simple-nameof'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; - -@Component({ - selector: 'app-dataset-editor-component', - templateUrl: 'dataset-editor.component.html', - styleUrls: ['./dataset-editor.component.scss'] -}) -export class DatasetEditorComponent extends BaseComponent { - - @Input() formGroup: UntypedFormGroup; - // @Input() formGroup: FormGroup = null; - @Input() availableProfiles: DatasetProfileModel[]; - @Input() dmpId: string; - showUri: boolean = false; - dmpText: string = null; - viewOnly = false; - - constructor( - private router: Router, - private dmpBlueprintService: DmpBlueprintService, - private dialog: MatDialog, - private guidedTourService: GuidedTourService, - private language: TranslateService - ) { super(); } - - public dashboardTourDmp: GuidedTour = { - tourId: 'only-dmp-tour', - useOrb: true, - steps: [ - { - title: this.dmpText, - content: 'Step 1', - orientation: Orientation.Bottom, - highlightPadding: 3, - isStepUnique: true, - customTopOffset: 8 - } - ] - }; - - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); - const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; - const blueprintId = this.formGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, - [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [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.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if(section.hasTemplates){ - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if(this.formGroup.get('dmp').value.datasets != null){ - for(let dataset of this.formGroup.get('dmp').value.datasets){ - if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ - count++; - } - } - if(count === foundTemplate.maxMultiplicity){ - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - } - else{ - this.formGroup.get('profile').setValue(profile); - } - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - }); - } - - getDmpText(): string { - return this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' + - this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' + - this.language.instant('DMP-LISTING.LINK-ZENODO') + ' ' + - this.language.instant('DMP-LISTING.GET-IDEA'); - } - - setDashboardTourDmp(label: string): void { - this.dashboardTourDmp.steps[0].title = this.getDmpText(); - this.dashboardTourDmp.steps[0].selector = '.dmp-tour-' + label; - } - - public restartTour(label: string): void { - this.setDashboardTourDmp(label); - this.guidedTourService.startTour(this.dashboardTourDmp); - - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - public compareWith(object1: any, object2: any) { - return object1 && object2 && object1.id === object2.id; - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts deleted file mode 100644 index 47ec72a17..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts +++ /dev/null @@ -1,382 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { ExternalDatasetType } from '@app/core/common/enum/external-dataset-type'; -import { DataRepositoryModel } from '@app/core/model/data-repository/data-repository'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { ExternalDatasetModel } from '@app/core/model/external-dataset/external-dataset'; -import { RegistryModel } from '@app/core/model/registry/registry'; -import { ServiceModel } from '@app/core/model/service/service'; -import { TagModel } from '@app/core/model/tag/tag'; -import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - -export class DatasetWizardEditorModel { - public id: string; - public label: string; - public profile: DatasetProfileModel; - public uri: String; - public status: number; - public description: String; - public services: ExternalServiceEditorModel[] = []; - public registries: ExternalRegistryEditorModel[] = []; - public dataRepositories: ExternalDataRepositoryEditorModel[] = []; - public tags: ExternalTagEditorModel[] = []; - public externalDatasets: ExternalDatasetEditorModel[] = []; - public dmp: DmpModel; - public dmpSectionIndex: number; - public datasetProfileDefinition: DatasetDescriptionFormEditorModel; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - public isProfileLatestVersion: Boolean; - public modified: Date; - - fromModel(item: DatasetWizardModel): DatasetWizardEditorModel { - this.id = item.id; - this.label = item.label; - this.profile = item.profile; - this.uri = item.uri; - this.status = item.status; - this.description = item.description; - if (item.services) { this.services = item.services.map(x => new ExternalServiceEditorModel().fromModel(x)); } - if (item.registries) { this.registries = item.registries.map(x => new ExternalRegistryEditorModel().fromModel(x)); } - if (item.dataRepositories) { this.dataRepositories = item.dataRepositories.map(x => new ExternalDataRepositoryEditorModel().fromModel(x)); } - if (item.externalDatasets) { this.externalDatasets = item.externalDatasets.map(x => new ExternalDatasetEditorModel().fromModel(x)); } - this.dmp = item.dmp; - this.dmpSectionIndex = item.dmpSectionIndex; - if (item.datasetProfileDefinition) { this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item.datasetProfileDefinition); } - if (item.tags) { this.tags = item.tags.map(x => new ExternalTagEditorModel().fromModel(x)); } - this.isProfileLatestVersion = item.isProfileLatestVersion; - this.modified = new Date(item.modified); - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - const formBuilder = new UntypedFormBuilder(); - const formGroup = formBuilder.group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], - label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], - uri: [{ value: this.uri, disabled: disabled }, context.getValidation('uri').validators], - status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], - description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], - dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators], - dmpSectionIndex: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators], - //externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators], - tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators], - //registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators], - //dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators], - //services: [{ value: this.services, disabled: disabled }, context.getValidation('services').validators], - profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators], - modified: [{value: this.modified, disabled: disabled}, context.getValidation('modified').validators] - }); - - const externalDatasetsFormArray = new Array(); - //if (this.externalDatasets && this.externalDatasets.length > 0) { - this.externalDatasets.forEach(item => { - externalDatasetsFormArray.push(item.buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('externalDatasets', formBuilder.array(externalDatasetsFormArray)); - - // const tagsFormArray = new Array(); - // if (this.tags && this.tags.length > 0) { - // this.tags.forEach(item => { - // tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled)); - // }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - // formGroup.addControl('tags', formBuilder.array(tagsFormArray)); - - const registriesFormArray = new Array(); - //if (this.registries && this.registries.length > 0) { - this.registries.forEach(item => { - registriesFormArray.push(item.buildForm(context.getValidation('registries').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('registries', formBuilder.array(registriesFormArray)); - - const dataRepositoriesFormArray = new Array(); - //if (this.dataRepositories && this.dataRepositories.length > 0) { - this.dataRepositories.forEach(item => { - dataRepositoriesFormArray.push(item.buildForm(context.getValidation('dataRepositories').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('dataRepositories', formBuilder.array(dataRepositoriesFormArray)); - - const servicesFormArray = new Array(); - // if (this.services && this.services.length > 0) { - this.services.forEach(item => { - servicesFormArray.push(item.buildForm(context.getValidation('services').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('services', formBuilder.array(servicesFormArray)); - - // const tagsFormArray = new Array(); - // this.tags.forEach(item => { - // tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled)); - // }); - // formGroup.addControl('tags', formBuilder.array(tagsFormArray)); - - if (this.datasetProfileDefinition) { formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinition.buildForm()); } - // formGroup.addControl('profile', this.profile.buildForm()); - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); - baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'profile')] }); - baseContext.validation.push({ key: 'uri', validators: [BackendErrorValidator(this.validationErrorModel, 'uri')] }); - baseContext.validation.push({ key: 'status', validators: [BackendErrorValidator(this.validationErrorModel, 'status')] }); - baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); - baseContext.validation.push({ key: 'services', validators: [BackendErrorValidator(this.validationErrorModel, 'services')] }); - baseContext.validation.push({ key: 'registries', validators: [BackendErrorValidator(this.validationErrorModel, 'registries')] }); - baseContext.validation.push({ key: 'dataRepositories', validators: [BackendErrorValidator(this.validationErrorModel, 'dataRepositories')] }); - baseContext.validation.push({ key: 'externalDatasets', validators: [BackendErrorValidator(this.validationErrorModel, 'externalDatasets')] }); - baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.validationErrorModel, 'dmp')] }); - baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] }); - baseContext.validation.push({ key: 'datasetProfileDefinition', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetProfileDefinition')] }); - baseContext.validation.push({ key: 'tags', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetProfileDefinition')] }); - baseContext.validation.push({ key: 'modified', validators: []}); - return baseContext; - } -} - -export class ExternalTagEditorModel { - public abbreviation: String; - public definition: String; - public id: String; - public name: String; - public reference: String; - public uri: String; - - constructor(id?: String, name?: String) { - this.id = id; - this.name = name; - } - - fromModel(item: TagModel): ExternalTagEditorModel { - this.id = item.id; - this.name = item.name; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - name: [this.name] - }); - } -} - -export class ExternalServiceEditorModel { - public id: String; - public abbreviation: String; - public definition: String; - public uri: String; - public label: String; - public reference: String; - public source: String; - - constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) { - this.id = id; - this.abbreviation = abbreviation; - this.definition = definition; - this.uri = uri; - this.label = label; - this.reference = reference; - this.source = source; - } - - fromModel(item: ServiceModel): ExternalServiceEditorModel { - this.id = item.id; - this.abbreviation = item.abbreviation; - this.definition = item.definition; - this.uri = item.uri; - this.label = item.label; - this.reference = item.reference; - this.source = item.source; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - abbreviation: [this.abbreviation], - label: [this.label, Validators.required], - reference: [this.reference], - uri: [this.uri, Validators.required], - definition: [this.definition], - source: [this.source] - }); - } -} - -export class ExternalRegistryEditorModel { - public abbreviation: String; - public definition: String; - public id: String; - public label: String; - public reference: String; - public uri: String; - public source: String - - constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) { - this.abbreviation = abbreviation; - this.definition = definition; - this.id = id; - this.label = label; - this.reference = reference; - this.uri = uri; - this.source = source; - } - - fromModel(item: RegistryModel): ExternalRegistryEditorModel { - this.abbreviation = item.abbreviation; - this.definition = item.definition; - this.id = item.id; - this.label = item.label; - this.reference = item.pid ? item.pid : item.reference; - this.uri = item.uri; - this.source = item.source - - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - abbreviation: [this.abbreviation], - label: [this.label, Validators.required], - reference: [this.reference], - uri: [this.uri, Validators.required], - definition: [this.definition], - source: [this.source] - }); - } -} - -export class ExternalDatasetEditorModel { - - public abbreviation: String; - public id: String; - public name: String; - public reference: String; - public type: ExternalDatasetType; - public info: String; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - public source: String; - - constructor(id?: string, abbreviation?: string, name?: string, reference?: string, source?: String, info?: string, type?: ExternalDatasetType) { - this.id = id; - this.name = name; - this.abbreviation = abbreviation; - this.reference = reference; - this.info = info; - this.type = type; - this.source = source; - } - - fromModel(item: ExternalDatasetModel): ExternalDatasetEditorModel { - this.abbreviation = item.abbreviation; - this.id = item.id; - this.name = item.name; - this.reference = item.reference; - this.type = item.type; - this.info = item.info; - this.source = item.source; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - abbreviation: [this.abbreviation], - name: [this.name, Validators.required], - reference: [this.reference], - type: [this.type], - info: [this.info], - source: [this.source] - }); - } -} - -export class ExternalDataRepositoryEditorModel { - public id: string; - public name: string; - public abbreviation: string; - public uri: string; - public reference: string; - public info: string; - public created: Date; - public modified: Date; - public source: string; - - constructor(id?: string, name?: string, abbreviation?: string, uri?: string, reference?: string, source?: string) { - this.id = id; - this.name = name; - this.abbreviation = abbreviation; - this.uri = uri; - this.reference = reference; - this.source = source; - } - - fromModel(item: DataRepositoryModel): ExternalDataRepositoryEditorModel { - this.id = item.id; - this.name = item.name; - this.abbreviation = item.abbreviation; - this.uri = item.uri; - this.info = item.info; - this.reference = item.pid; - this.source = item.source; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - name: [this.name, [Validators.required]], - abbreviation: [this.abbreviation], - uri: [this.uri, [Validators.required]], - info: [this.info], - reference: [this.reference], - source: [this.source] - }); - } -} - -// export class TagModel implements Serializable { - -// public id: string; -// public name: string; - -// constructor(id?: string, name?: string) { -// this.id = id; -// this.name = name; -// } - -// fromJSONObject(item: any): TagModel { -// this.id = item.id; -// this.name = item.name; -// return this; -// } - -// buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { -// return new FormBuilder().group({ -// id: [this.id], -// name: [this.name] -// }); -// } -// } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html deleted file mode 100644 index 6f65a8697..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ /dev/null @@ -1,288 +0,0 @@ -
-
-
- - -
-
-
-
-
- -
{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}}
-
{{'DMP-EDITOR.TITLE.EDIT-DESCRIPTION' | translate}}
-
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
- -
{{'DMP-EDITOR.TITLE.PREVIEW-DATASET' | translate}}
-
-
-
{{'DATASET-LISTING.TOOLTIP.TO-DMP' | translate}}
-
: {{ formGroup.get('dmp').value.label }}
- -
-
-
-
- - - - - - -
- - - -
- -
-
- - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
- chevron_left - {{'DATASET-WIZARD.ACTIONS.BACK-TO' | translate}} -
-
{{'DATASET-LISTING.TOOLTIP.DMP' | translate}}
-
-
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
-
-
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
-
-
- -
-
-
-
- - -
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
-
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
- -
-
- -
-
-
- - -
-
-
-
-
- - - - - - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss deleted file mode 100644 index 246e7ad8b..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss +++ /dev/null @@ -1,524 +0,0 @@ -.main-content { - height: 100vh !important; - margin-top: -80px; -} - -.dataset-wizard { - .toc-pane-container { - &.is-sticky ~ .nav-spacer { - height: 500px; // the container size } - // height: calc(100vh - 100px); // the container size } - } - } - - .step-container { - margin-top: 1em; - } - - .external-item-card { - margin-top: 1em; - } - - .external-item-action-row, - .description-action-row { - margin-top: 1em; - } - - .deleteButton, - .reverseButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .cancelButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .saveButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .saveAndFinalizeButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .finalizeButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .export-btn { - padding-right: 6px; - } - - .downloadPDF { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .downloadXML { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .downloadDOCX { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .updateDatasetProfile { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .actions { - display: flex; - justify-content: flex-end; - } - - // .actions > button { - // background-color: #0070c0; - // color: #ffffff; - // text-transform: uppercase; - // } - - .more-horiz { - font-size: 28px; - color: #aaaaaa; - } - - .more-icon :hover { - color: var(--primary-color-3); - } - - .new-dataset { - height: 3.5em; - } - - .fixed-editor-header { - // position: fixed; - // width: calc(100% - 310px); - z-index: 3; - background-color: whitesmoke; - } - - .dataset-editor-header { - height: 113px; - background: var(--unnamed-color-var(--primary-color)) 0% 0% no-repeat padding-box; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #00000029; - padding: 0.6rem; - margin: 30px 0px 0px 0px; - border-radius: 4px; - opacity: 1; - - .info { - flex: 2; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - } - - .dataset-title { - text-align: left; - letter-spacing: 0px; - color: #212121; - opacity: 0.9; - font-size: 14px; - font-weight: 400; - } - - .subtitle { - text-align: left; - color: #ffffff; - font-weight: 700; - font-size: 16px; - opacity: 1; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - - .dataset-subtitle { - text-align: left; - letter-spacing: 0px; - color: #212121; - font-weight: 700; - font-size: 16px; - opacity: 0.9; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - - .discard-btn { - background: transparent; - border: 1px solid #ffffff; - color: white; - border-radius: 30px; - opacity: 1; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - } - - .save-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - width: auto; - min-width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - font-weight: 700; - color: var(--primary-color); - } - - .dataset-discard-btn { - border: 1px solid #212121; - border-radius: 30px; - opacity: 1; - background-color: transparent; - font-weight: 700; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - } - - .dataset-save-btn, .dataset-export-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - width: auto; - min-width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - } - - .dataset-to-dmp { - display: flex; - align-items: center; - padding: 0; - text-align: left; - font-size: 1rem; - font-weight: 700; - color: var(--primary-color); - line-height: 25px; - } - - .dmp-info { - padding-top: 0.75rem; - } - - .dmp-label { - min-width: 67px; - height: 37px; - background: var(--primary-color) 0% 0% no-repeat padding-box; - color: white; - border-radius: 4px; - opacity: 1; - display: flex; - align-items: center; - justify-content: center; - } - - .dmp-title { - text-align: left; - font-weight: 700; - font-family: "Roboto", sans-serif; - font-size: 1rem; - color: #212121; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - line-height: 25px; - } - - .open-in-new-icon { - color: #434343; - opacity: 0.75; - } - .open-in-new-icon:hover { - color: var(--primary-color); - } - - .dataset-stepper { - position: fixed; - // height: 100%; - display: flex; - flex-direction: column; - height: calc(100vh - 246px); - // max-width: 366px; - } - - .stepper-options { - height: calc(100vh - 600px); - overflow-y: auto; - .main-info { - padding-left: .2rem; - color: #21212194; - font-weight: 400; - cursor: pointer; - } - .main-info:hover { - background-color: #ececec; - border-radius: 6px; - } - } - - .stepper-back { - margin-top: 3.125rem; - padding-left: 0.5rem; - font-size: 0.875rem; - letter-spacing: 0px; - color: #848484; - opacity: 1; - } - - .stepper-title { - text-align: left; - font-weight: 300; - font-size: 20px; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; - margin: 2.875rem 0rem 2.25rem 0rem; - padding-left: 1rem; - } - - .stepper-list { - .toc-pane-container { - // padding-left: 0.2rem; - // overflow-x: hidden; - span { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - padding: 0.3rem 0.1rem; - opacity: 0.6; - cursor: pointer; - max-width: 290px; - } - } - } - - .stepper-list span:hover { - background-color: #ececec; - border-radius: 6px; - } - - .stepper-list .active { - color: #212121; - font-weight: 700; - opacity: 1; - } - - .stepper-list .active-dataset { - color: #212121; - font-weight: 700; - opacity: 1; - .label { - width: 100%; - height: 27px; - line-height: 27px; - background-color: var(--secondary-color); - color: #5d5d5d; - border-radius: 4px; - font-weight: 400; - font-size: 14px; - justify-content: left; - display: flex; - align-items: center; - padding-left: 0.625rem; - padding-right: 0.625rem; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - display: inline-block; - } - } - - .back-to-dmp:hover { - background: #ececec; - border-radius: 6px; - } - - .back-icon { - display: inline-flex; - vertical-align: middle; - } - - .editor-content { - .form { - // position: relative; - // left: 362px; - // width: calc(100% - 366px); - - position: relative; - left: 362px; - width: calc(100% - 366px); - overflow-y: auto; - height: calc(100vh - 218px); - } - } - - form { - height: calc(100vh - 124px); - margin-top: 6rem; - } - - .stepper-actions { - display: flex; - padding-left: 1rem; - margin-top: auto; - margin-bottom: 0.5rem; - // margin-top: 5rem; - // flex-grow: 8; - } - - .stepper-btn { - border-radius: 30px; - opacity: 1; - width: 154px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - font-size: 14px; - } - - .previous { - color: #212121; - background: #f5f5f5 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border: 2px solid #212121; - font-weight: 500; - cursor: pointer; - } - - .add-dataset-btn { - background: var(--secondary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 500; - word-wrap: break-word; - white-space: normal; - line-height: normal; - } - - .next { - background: var(--primary-color) 0% 0% no-repeat padding-box; - color: white; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 400; - cursor: pointer; - } - - .dataset-next { - background: var(--secondary-color) 0% 0% no-repeat padding-box; - color: #212121; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 700; - cursor: pointer; - } - - .previous-disabled { - border: 1px solid #b5b5b5; - color: #b5b5b5 !important; - cursor: auto !important; - } - - .next-disabled { - background: #cbcbcb 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - color: white; - cursor: auto !important; - } -} - -mat-icon.size-18 { - width: 18px; - height: 18px; - line-height: 18px; - font-size: 18px; -} - -.menu-item { - width: 248px; -} - -.toc-pane-container { - &.is-sticky ~ .nav-spacer { - height: 500px; // the container size } - // height: calc(100vh - 100px); // the container size } - } -} - -.is-sticky { - margin-top: 70px !important; -} - -.done-icon { - display: inline-flex; - vertical-align: middle; - font-size: 16px !important; - height: auto; - width: auto; -} - -// ::ng-deep .mat-tab-labels { -// justify-content: space-between; -// } - -// ::ng-deep .mat-tab-label-content { -// text-transform: uppercase; -// } - -// ::ng-deep .mat-ink-bar { -// background-color: var(--primary-color-3) !important; -// // background-color: #0070c0 !important; -// } - -// @media (max-width: 768px) { -// .main-content { -// padding: 30px 0px; -// } - -// ::ng-deep .mat-expansion-panel-header { -// min-height: 48px; -// height: auto !important; -// } - -// ::ng-deep .mat-expansion-panel-body { -// padding: 0 0px 16px !important; -// } - -// ::ng-deep .mat-vertical-content { -// padding: 0 14px 24px 14px !important; -// } -// } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts deleted file mode 100644 index 0bc56e515..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ /dev/null @@ -1,1507 +0,0 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { ActivatedRoute, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { SaveType } from '@app/core/common/enum/save-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { LockModel } from '@app/core/model/lock/lock.model'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { - ExternalSourcesConfigurationService -} from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.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 { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { - DatasetCopyDialogueComponent -} from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { PrefillDatasetComponent } from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component"; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { ToCEntry, ToCEntryType } from "@app/ui/misc/dataset-description-form/dataset-description.component"; -import { - Link, - LinkToScroll, - TableOfContents -} from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { FormService } from '@common/forms/form-service'; -import { - FormValidationErrorsDialogComponent -} from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { Observable, interval, of as observableOf } from 'rxjs'; -import { catchError, debounceTime, filter, map, takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-wizard-component', - templateUrl: 'dataset-wizard.component.html', - styleUrls: ['./dataset-wizard.component.scss'] -}) -export class DatasetWizardComponent extends CheckDeactivateBaseComponent implements OnInit {//IBreadCrumbComponent - canDeactivate(): boolean { - return !this.isDirty(); - } - - // breadCrumbs: Observable; - viewOnly = false; - editMode = false; - publicMode = false; - hasChanges = false; - isDiscarded = false; - formGroupRawValue: any; - saving = false; - - DatasetStatus = DatasetStatus; - dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - - datasetWizardModel: DatasetWizardEditorModel; - isNew = true; - isCopy = false; - formGroup: UntypedFormGroup = null; - datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel; - - availableProfiles: DatasetProfileModel[] = []; - finalize: boolean = false; - itemId: string; - dmpId: string; - dmpSectionIndex: number; - availableDescriptionTemplates: DatasetProfileModel[] = []; - newDmpId: string; - publicId: string; - profileUpdateId: string; - downloadDocumentId: string; - isLinear = false; - lock: LockModel; - lockStatus: Boolean; - - step: number = 0; - stepOffset: number = 1; - - saveAnd = SaveType; - datasetSavedLinks: any = null; - - scrollTop: number; - tocScrollTop: number; - links: Link[] = []; - //the table seraches for elements to scroll on page with id (TOCENTRY_ID_PREFIX+fieldsetId) - TOCENTRY_ID_PREFIX = "TocEntRy"; - showtocentriesErrors = false; - @ViewChild('table0fContents') table0fContents: TableOfContents; - hintErrors: boolean = false; - datasetIsOnceSaved = false; - - fieldsetIdWithFocus: string; - visRulesService: VisibilityRulesService; - - constructor( - private datasetWizardService: DatasetWizardService, - private route: ActivatedRoute, - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - public externalSourcesService: ExternalSourcesService, - public dmpService: DmpService, - public dialog: MatDialog, - public externalSourcesConfigurationService: ExternalSourcesConfigurationService, - private uiNotificationService: UiNotificationService, - private formService: FormService, - private lockService: LockService, - private location: Location, - private authService: AuthService, - private configurationService: ConfigurationService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Editor'); - this.route - .data - .pipe(takeUntil(this._destroyed)) - .subscribe(v => { - this.viewOnly = v['public']; - }); - - const dmpRequestItem: RequestItem = new RequestItem(); - dmpRequestItem.criteria = new DmpCriteria(); - - this.dmpAutoCompleteConfiguration = { - filterFn: this.searchDmp.bind(this), - initialItems: (extraData) => this.searchDmp(''), - displayFn: (item) => this.getDatasetDisplay(item), - titleFn: (item) => item['label'], - subtitleFn: (item) => this.language.instant('DATASET-WIZARD.FIRST-STEP.SUB-TITLE') + new Date(item['creationTime']).toISOString() - // iconFn: (item) => this.publicMode ? '' : (item['status'] ? 'lock' : 'lock_open'), - // linkFn: (item) => this.publicMode ? '/explore-plans/overview/' + item['id'] : '/plans/overview/' + item['id'] - }; - - const params = this.route.snapshot.params; - const queryParams = this.route.snapshot.queryParams; - const data: any = this.route.snapshot.data; - this.itemId = params['id']; - this.dmpId = params['dmpId']; - this.dmpSectionIndex = parseInt(params['dmpSectionIndex']); - this.newDmpId = queryParams['newDmpId']; - this.publicId = params['publicId']; - this.profileUpdateId = params['updateId']; - this.finalize = data.finalize; - this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId - - this.init(); - // this.route.params - // .pipe(takeUntil(this._destroyed)) - // .subscribe((params: Params) => { - // const itemId = params['id']; - // if (itemId != null) { setTimeout(() => this.stepper.selectedIndex = 2); } - // }); - } - - init() { - if (this.itemId != null && this.newDmpId == null) { - this.isNew = false; - this.datasetWizardService.getSingle(this.itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { - this.lockStatus = lockStatus; - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex; - this.needsUpdate(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.datasetWizardModel.label, - // url: '/datasets/edit/' + this.datasetWizardModel.id, - // notFoundResolver: [ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS').toUpperCase(), - // url: '/datasets' - // }, - // ] - // }]); - this.formGroup = this.datasetWizardModel.buildForm(); - let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.datasetWizardModel.dmpSectionIndex)); - for (var profile of profiles) { - this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) - } - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) { - this.formGroup.disable(); - this.viewOnly = true; - } - if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { - const lockedBy: UserInfoListingModel = { - email: this.authService.getUserProfileEmail(), - id: this.authService.userId()?.toString(), - name: this.authService.getPrincipalName(), - role: 0 //TODO - //role: this.authService.getRoles()?.at(0) - } - this.lock = new LockModel(data.id, lockedBy); - - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - this.lock.id = Guid.parse(result); - interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); - }); - } - // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.loadDatasetProfiles(); - this.registerFormListeners(); - - if (lockStatus) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'), - message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE') - }, maxWidth: '30em' - }); - } - if (this.finalize && !this.lockStatus && !this.viewOnly) { - setTimeout(() => { - this.saveFinalize(); - }, 0); - } - // this.availableProfiles = this.datasetWizardModel.dmp.profiles; - }); - }, - error => { - switch (error.status) { - case 403: - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-ALLOWED'), SnackBarNotificationLevel.Error); - break; - case 404: - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-FOUND'), SnackBarNotificationLevel.Error); - break; - default: - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), SnackBarNotificationLevel.Error); - } - this.router.navigate(['/datasets/']); - return observableOf(null); - }); - } else if (this.dmpId != null) { - this.isNew = true; - this.dmpService.getSingle(this.dmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.datasetWizardModel = new DatasetWizardEditorModel(); - setTimeout(() => { - this.datasetWizardModel.dmp = data; - this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; - this.formGroup = this.datasetWizardModel.buildForm(); - let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.dmpSectionIndex)); - for (var profile of profiles) { - this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) - } - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - this.formGroup.get('dmp').disable(); - const dialogRef = this.dialog.open(PrefillDatasetComponent, { - width: '590px', - minHeight: '200px', - restoreFocus: false, - data: { - availableProfiles: this.availableDescriptionTemplates, - datasetFormGroup: this.formGroup - }, - panelClass: 'custom-modalbox' - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - this.datasetWizardModel = this.datasetWizardModel.fromModel(result); - this.datasetWizardModel.dmp = data; - this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.formGroup.get('dmp').disable(); - this.loadDatasetProfiles(); - this.registerFormListeners(); - } - }) - this.loadDatasetProfiles(); - this.registerFormListeners(); - // this.availableProfiles = data.profiles; - - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // }] - // }]); - }); - }); - } else if (this.newDmpId != null) { - this.isNew = false; - this.isCopy = true; - this.datasetWizardService.getSingle(this.itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { - this.lockStatus = lockStatus; - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex; - this.datasetWizardModel.status = 0; - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroup.get('id').setValue(null); - this.dmpService.getSingleNoDatasets(this.newDmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - setTimeout(() => { - this.datasetWizardModel.dmp = data; - this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - this.loadDatasetProfiles(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // } - // ] - // }]); - }); - }); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) { - this.formGroup.disable(); - this.viewOnly = true; - } - if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { - const lockedBy: UserInfoListingModel = { - email: this.authService.getUserProfileEmail(), - id: this.authService.userId()?.toString(), - name: this.authService.getPrincipalName(), - role: 0 //TODO - //role: this.authService.getRoles()?.at(0) - } - this.lock = new LockModel(data.id, lockedBy); - - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - this.lock.id = Guid.parse(result); - interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); - }); - } - // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.loadDatasetProfiles(); - // this.availableProfiles = data.dmp.profiles; - }) - }); - } else if (this.publicId != null) { // For Finalized -> Public Datasets - this.isNew = false; - this.datasetWizardService.getSinglePublic(this.publicId) - .pipe(takeUntil(this._destroyed)).pipe( - catchError((error: any) => { - this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); - this.router.navigate(['/datasets/publicEdit/' + this.publicId]); - return observableOf(null); - })) - .subscribe(data => { - if (data) { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.formGroup.disable(); - this.viewOnly = true; - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp); - const breadcrumbs = []; - breadcrumbs.push({ - parentComponentName: null, - label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), - url: '/explore-descriptions' - }); - breadcrumbs.push({ - parentComponentName: null, - label: this.datasetWizardModel.label, - url: '/datasets/publicEdit/' + this.datasetWizardModel.id - }); - // this.breadCrumbs = observableOf(breadcrumbs); - } - }); - this.publicMode = true; - } else if (this.profileUpdateId != null) { - this.datasetWizardService.updateDatasetProfile(this.profileUpdateId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - this.needsUpdate(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // }, - // ] - // }]); - this.formGroup = this.datasetWizardModel.buildForm(); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - this.formGroup.disable(); - this.viewOnly = true; - } - // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.loadDatasetProfiles(); - }); - - } else { - this.datasetWizardModel = new DatasetWizardEditorModel(); - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - this.formGroup.disable(); - this.viewOnly = true; - } - //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.registerFormListeners(); - this.dmpValueChanged(null); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('DATASET-LISTING.ACTIONS.CREATE-NEW').toUpperCase(), - // url: '/datasets/new/' - // }]); - } - } - - // private _listenersSubscription:Subscription = new Subscription(); - registerFormListeners() { - // const dmpSubscription = - this.formGroup.get('dmp').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.dmpValueChanged(x); - }); - // const profileSubscription = - this.formGroup.get('profile').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (x) { - this.showtocentriesErrors = false; - this.datasetProfileValueChanged(x.id); - this.formChanged(); - } - }); - // const labelSubscription = - this.formGroup.get('label').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // const descriptionSubscription = - this.formGroup.get('description').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // const uriSubscription = - this.formGroup.get('uri').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // const tagsSubscription = - this.formGroup.get('tags').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - if (this.formGroup.get('datasetProfileDefinition')) { - // const datasetProfileDefinitionSubscription = - this.formGroup.get('datasetProfileDefinition').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // this._listenersSubscription.add(datasetProfileDefinitionSubscription); - } - - // this._listenersSubscription.add(dmpSubscription); - // this._listenersSubscription.add(profileSubscription); - // this._listenersSubscription.add(labelSubscription); - // this._listenersSubscription.add(descriptionSubscription); - // this._listenersSubscription.add(uriSubscription); - // this._listenersSubscription.add(tagsSubscription); - } - - // private _unregisterFormListeners(){ - // this._listenersSubscription.unsubscribe(); - // this._listenersSubscription = new Subscription(); - // } - - dmpValueChanged(dmp: DmpListingModel) { - if (dmp) { - this.formGroup.get('profile').enable(); - this.loadDatasetProfiles(); - } else { - this.availableProfiles = []; - this.formGroup.get('profile').reset(); - this.formGroup.get('profile').disable(); - this.formGroup.removeControl('datasetProfileDefinition'); - } - } - - datasetProfileValueChanged(profiledId: string) { - if (profiledId && profiledId.length > 0) { - this.formGroup.removeControl('datasetProfileDefinition'); - this.getDefinition(profiledId); - } - } - - searchDmp(query: string): Observable { - const fields: Array = new Array(); - fields.push('-created'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = query; - dmpDataTableRequest.criteria.status = DmpStatus.Draft; - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete").pipe(map(x => x.data)); - } - - loadDatasetProfiles() { - const datasetProfileRequestItem: RequestItem = new RequestItem(); - datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - datasetProfileRequestItem.criteria.id = this.formGroup.get('dmp').value.id; - if (datasetProfileRequestItem.criteria.id) { - this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.availableProfiles = items; - }); - } - } - - public formChanged() { - if (!this.isDiscarded) { - this.hasChanges = true; - } - } - - public cancel(): void { - if (!isNullOrUndefined(this.lock)) { - this.lockService.unlockTarget(Guid.parse(this.datasetWizardModel.id)).pipe(takeUntil(this._destroyed)).subscribe( - complete => { - this.publicMode ? this.router.navigate(['/explore-descriptions']) : this.router.navigate(['/datasets']); - }, - error => { - this.formGroup.get('status').setValue(DmpStatus.Draft); - this.onCallbackError(error); - } - ) - } else { - this.publicMode ? this.router.navigate(['/explore-descriptions']) : this.router.navigate(['/datasets']); - } - - } - - getDatasetDisplay(item: any): string { - if (!this.publicMode) { - return (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label']; - } else { - return item['label']; - } - } - - getDefinition(profileId: string) { - // if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; } - this.datasetWizardService.getDefinition(profileId) - .pipe(takeUntil(this._destroyed)) - .subscribe(item => { - this.datasetWizardModel.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); - this.datasetProfileDefinitionModel = this.datasetWizardModel.datasetProfileDefinition; - this.formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinitionModel.buildForm()); - - // const datasetProfileDefinitionForm = this.datasetProfileDefinitionModel.buildForm(); - - // let profId = null; - // try{ - // profId = this.formGroup.get('profile').value.id; - // }catch{ - - // } - // if(this.formGroupRawValue && this.formGroupRawValue.datasetProfileDefinition && (this.formGroupRawValue.profile.id === profId)){ - // // this.formGroup.get('datasetProfileDefinition').patchValue( this.formGroupRawValue.datasetProfileDefinition); - // datasetProfileDefinitionForm.patchValue(this.formGroupRawValue.datasetProfileDefinition); - // } - - // this.formGroup.addControl('datasetProfileDefinition', datasetProfileDefinitionForm); - this.formGroup.get('datasetProfileDefinition').valueChanges - .pipe(debounceTime(600)) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - }); - } - - // formSubmit(): void { - // if (!this.isFormValid()) { return; } - // this.onSubmit(); - // } - - public isFormValid() { - return this.formGroup.valid; - } - - public isSemiFormValid(formGroup: UntypedFormGroup): boolean { - var isValid: boolean = true; - Object.keys(formGroup.controls).forEach(controlName => { - if (controlName != 'datasetProfileDefinition' && !formGroup.get(controlName).disabled && !(formGroup.get(controlName).valid)) { - isValid = false; - } - }); - return isValid; - } - - // onSubmit(): void { - // this.datasetWizardService.createDataset(this.formGroup.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => { - // this.datasetWizardService.getSingle(complete.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // result => { - // this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result); - // } - // ); - // this.onCallbackSuccess(); - // }, - // error => this.onCallbackError(error) - // ); - // } - - - submit(saveType?: SaveType, onSuccess: Function = null, onError: Function = null) { - this.scrollTop = document.getElementById('dataset-editor-form').scrollTop; - this.tocScrollTop = document.getElementById('stepper-options').scrollTop; - this.datasetWizardService.createDataset(this.formGroup.getRawValue()) - .pipe(takeUntil(this._destroyed)) - .subscribe( - data => { - this.hasChanges = false; - this.datasetIsOnceSaved = true; - this.onCallbackSuccess(data, saveType); - if (onSuccess) { - onSuccess(); - } - }, - error => { - if (onError) { - onError(); - } - this.onCallbackError(error) - }); - } - - - private _getErrorMessage(formControl: AbstractControl, name: string): string[] { - const errors: string[] = []; - Object.keys(formControl.errors).forEach(key => { - if (key === 'required') { - errors.push(this.language.instant(name + ": " + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED'))); - } - // if (key === 'required') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + this.getPlaceHolder(formControl) + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED')); } - else if (key === 'email') { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.EMAIL')); - } else if (key === 'min') { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MIN-VALUE', { 'min': formControl.getError('min').min })); - } else if (key === 'max') { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MAX-VALUE', { 'max': formControl.getError('max').max })); - } else { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + formControl.errors[key].message); - } - }); - return errors; - } - - private _getPlaceHolder(formControl: any): string { - if (formControl.nativeElement.localName === 'input' || formControl.nativeElement.localName === 'textarea' - || formControl.nativeElement.localName === 'richTextarea') { - return formControl.nativeElement.getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'mat-select') { - return formControl.nativeElement.getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'app-single-auto-complete') { - return (Array.from(formControl.nativeElement.firstChild.children).filter((x: any) => x.localName === 'input')[0] as any).getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'app-multiple-auto-complete') { - return (Array.from(formControl.nativeElement.firstChild.firstChild.firstChild.children).filter((x: any) => x.localName === 'input')[0] as any).getAttribute('placeholder'); - } - } - - - private _buildSemiFormErrorMessages(): string[] {//not including datasetProfileDefinition - const errmess: string[] = []; - Object.keys(this.formGroup.controls).forEach(controlName => { - if (controlName != 'datasetProfileDefinition' && this.formGroup.get(controlName).invalid) { - errmess.push(...this._buildErrorMessagesForAbstractControl(this.formGroup.get(controlName), controlName)); - } - }) - - return errmess; - } - - // takes as an input an abstract control and gets its error messages[] - private _buildErrorMessagesForAbstractControl(aControl: AbstractControl, controlName: string): string[] { - const errmess: string[] = []; - - if (aControl.invalid) { - - if (aControl.errors) { - //check if has placeholder - if ((aControl).nativeElement !== undefined && (aControl).nativeElement !== null) { - const placeholder = this._getPlaceHolder(aControl); - if (placeholder) { - controlName = placeholder; - } - } - const errorMessage = this._getErrorMessage(aControl, controlName); - - errmess.push(...errorMessage); - } - - /*in case the aControl is FormControl then the it should have provided its error messages above. - No need to check case of FormControl below*/ - - if (aControl instanceof UntypedFormGroup) { - - const fg = aControl as UntypedFormGroup; - //check children - Object.keys(fg.controls).forEach(controlName => { - errmess.push(...this._buildErrorMessagesForAbstractControl(fg.get(controlName), controlName)); - }); - } else if (aControl instanceof UntypedFormArray) { - - const fa = aControl as UntypedFormArray; - - fa.controls.forEach((control, index) => { - errmess.push(...this._buildErrorMessagesForAbstractControl(control, `${controlName} --> ${index + 1}`)); - }); - - } - } - - return errmess; - } - - save(saveType?: SaveType) { - this.saving = true; - Object.keys(this.formGroup.controls).forEach(controlName => { - if (controlName == 'datasetProfileDefinition') { - return; - } - this.formService.touchAllFormFields(this.formGroup.get(controlName)); - }) - - - // this.formService.touchAllFormFields(this.formGroup); - if (!this.isSemiFormValid(this.formGroup)) { - //build messages - const errorMessages = this._buildSemiFormErrorMessages(); - this.showValidationErrorsDialog(undefined, errorMessages); - this.hintErrors = true; - this.saving = false; - return; - } - this.submit(saveType); - } - - private showValidationErrorsDialog(projectOnly?: boolean, errmess?: string[]) { - if (errmess) { - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - errorMessages: errmess, - projectOnly: projectOnly - }, - }); - } else { - - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - formGroup: this.formGroup, - projectOnly: projectOnly - }, - }); - } - - } - - hasReversableStatus(): boolean { - if (this.formGroup.get('dmp').value) { - return (this.formGroup.get('dmp').value.status == DmpStatus.Draft && this.formGroup.get('status').value == DatasetStatus.Finalized); - } else { - return false; - } - } - - hasNotReversableStatus(): boolean { - if (this.formGroup.get('dmp').value && !this.publicMode) { - return (this.formGroup.get('dmp').value.status == DmpStatus.Finalized && this.formGroup.get('status').value == DatasetStatus.Finalized); - } else { - return false; - } - } - - reverse() { - - this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.UNDO-FINALIZATION-QUESTION'), - confirmButton: this.language.instant('DATASET-WIZARD.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('DATASET-WIZARD.ACTIONS.REJECT'), - }, - maxWidth: '30em' - }) - .afterClosed() - .pipe( - filter(x => x), - takeUntil(this._destroyed) - ).subscribe(result => { - if (result) { - // if (!this.isFormValid()) { return; } - this.formGroup.get('status').setValue(DatasetStatus.Draft); - this.submit(SaveType.finalize, () => { - this.viewOnly = false; - this.datasetWizardModel.status = DatasetStatus.Draft; - setTimeout(x => { - this.formGroup = null; - }); - setTimeout(x => { - this.formGroup = this.datasetWizardModel.buildForm(); - this.registerFormListeners(); - }); - }, () => { - this.formGroup.get('status').setValue(DatasetStatus.Finalized); - this.viewOnly = true; - }); - } else { - this.saving = false; - } - }); - - - } - - saveFinalize() { - // this.formService.touchAllFormFields(this.formGroup); - this.saving = true; - if (!this.isSemiFormValid(this.formGroup) || (this.table0fContents && this.table0fContents.hasVisibleInvalidFields())) { - // this.showValidationErrorsDialog(); - this.dialog.open(FormValidationErrorsDialogComponent, { - data: { - errorMessages: [this.language.instant('DATASET-WIZARD.MESSAGES.MISSING-FIELDS')] - } - }) - - - this.touchForm(); - this.hintErrors = true; - this.saving = false; - return; - } - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - // if (!this.isFormValid()) { return; } - this.formGroup.get('status').setValue(DatasetStatus.Finalized); - this.submit(SaveType.finalize, null, () => { - this.formGroup.get('status').setValue(DatasetStatus.Draft); - }); - } else { - this.saving = false; - } - }); - } - - onCallbackSuccess(data?: DatasetWizardModel, saveType?: SaveType): void { - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - if (data) { - if (saveType === this.saveAnd.addNew) { - this.router.navigate(['/reload']).then(() => { - this.router.navigate(['/datasets', 'new', this.formGroup.get('dmp').value.id, this.dmpSectionIndex]); - }) - } else if (saveType === this.saveAnd.close) { - this.router.navigate(['/reload']).then(() => { - this.router.navigate(['/plans', 'edit', this.formGroup.get('dmp').value.id]); - }); - } else if (saveType === SaveType.finalize) { - this.router.navigate(['/reload']).then(() => { - this.router.navigate(['/datasets', 'edit', data.id]); - }); - } else { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // setTimeout(() => { this.formGroup = null; }); - setTimeout(() => { - this.formGroup.get('id').patchValue(data.id); - this.formGroup.get('modified').patchValue(data.modified); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.hasChanges = false; - - // this.formGroup = this.datasetWizardModel.buildForm(); - // if (this.formGroup.get('datasetProfileDefinition')) { - // this.formGroup.removeControl('datasetProfileDefinition'); - // this.getDefinition(data.profile.id); - // this.maxStep = 1; - // } else { - // this.getDefinition(data.profile.id); - // this.maxStep = 1; - // } - }); - - setTimeout(() => { - document.getElementById('dataset-editor-form').scrollTop = this.scrollTop; - document.getElementById('stepper-options').scrollTop = this.tocScrollTop; - }, 500); - this.saving = false; - if (this.isNew) { - this.reloadDateset(this.datasetWizardModel.id); - } - // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); - } - } else { - this.router.navigate(['/datasets']); - } - } - - onCallbackError(error: any) { - const errmes = error && error.message ? error.message as string : null; - let feedbackMessage = this.language.instant('DATASET-EDITOR.ERRORS.ERROR-OCCURED'); - if (errmes) { - feedbackMessage += errmes; - } - this.uiNotificationService.snackBarNotification(feedbackMessage, SnackBarNotificationLevel.Warning); - this.setErrorModel(error.error); - this.saving = false; - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.datasetWizardModel.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - downloadPDF(id: string): void { - this.datasetWizardService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", id); - }); - } - - downloadDOCX(id: string): void { - this.datasetWizardService.downloadDOCX(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", id); - }); - - } - - downloadXML(id: string): void { - this.datasetWizardService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", id); - }); - } - - // advancedClicked() { - // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { - // maxWidth: '500px', - // data: { - // message: "Download as:", - // XMLButton: "XML", - // documentButton: "Document", - // pdfButton: "PDF" - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result == "pdf") { - // this.downloadPDF(); - // } else if (result == "xml") { - // this.downloadXML(); - // } else if (result == "doc") { - // this.downloadDOCX(); - // } - // }); - // } - - public redirectToGrant() { - this.router.navigate(['grants/edit/' + this.datasetWizardModel.dmp.grant.id]); - } - - public redirectToDmp() { - this.router.navigate(['plans/edit/' + this.datasetWizardModel.dmp.id]); - } - - public enableForm() { - if (this.formGroup.get('status').value !== DatasetStatus.Finalized) { - this.editMode = true; - this.viewOnly = false; - this.formGroup.enable(); - } else { - this.datasetWizardService.unlock(this.formGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.editMode = true; - this.viewOnly = false; - this.datasetWizardModel.status = DatasetStatus.Draft; - this.formGroup.get('status').patchValue(DatasetStatus.Draft); - this.formGroup.enable(); - }); - } - } - - public disableForm() { - this.editMode = false; - //this.viewOnly = true; - this.formGroup.disable(); - } - - openConfirm(dmpLabel, id): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - }); - } - - openDmpSearchDialogue() { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: this.formGroup.value.id, - datasetProfileId: this.formGroup.value.profile, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - } - }); - } - - needsUpdate() { - if (this.datasetWizardModel.isProfileLatestVersion || (this.datasetWizardModel.status === DatasetStatus.Finalized) - || (this.datasetWizardModel.isProfileLatestVersion == undefined && this.datasetWizardModel.status == undefined)) { - return false; - } else { - return true; - } - } - - linkToScroll: LinkToScroll; - - onStepFound(linkToScroll: LinkToScroll) { - this.linkToScroll = linkToScroll; - } - - private pumpLock() { - this.lock.touchedAt = new Date(); - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - if (!isNullOrUndefined(result)) { - this.lock.id = Guid.parse(result); - } else { - this.location.back(); - } - }); - } - - getEntryVisibleFieldSets(entry: ToCEntry): ToCEntry[] { - let fieldSets = []; - if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id)) { - fieldSets.push(entry); - } else if (entry.type !== ToCEntryType.FieldSet) { - entry.subEntries.forEach(subEntry => { - fieldSets = fieldSets.concat(this.getEntryVisibleFieldSets(subEntry)); - }); - } - return fieldSets; - } - - get visibleFieldSets(): ToCEntry[] { - let fieldSets = []; - let arrays = this.table0fContents ? this.table0fContents.tocentries. - filter(entry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id)).map(entry => { - return this.getEntryVisibleFieldSets(entry); - }) - : []; - arrays.forEach(array => { - fieldSets = fieldSets.concat(array); - }); - return fieldSets; - } - - getFirstFieldSet(entry: ToCEntry): ToCEntry { - if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id)) { - return entry; - } else { - let subEntries = entry.subEntries.filter(subEntry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === subEntry.id)); - if (subEntries.length > 0) { - return this.getFirstFieldSet(subEntries[0]); - } else { - return null; - } - } - } - - public changeStep(selected: ToCEntry = null, execute: boolean = true) { - if (execute) { - if (selected) { - let fieldSet = this.getFirstFieldSet(selected); - let index = this.visibleFieldSets.findIndex(entry => entry.id === fieldSet.id); - this.step = index + (selected.type === ToCEntryType.FieldSet ? 1 : 0.5); - } else { - this.step = 0; - this.resetScroll(); - } - } - } - - get maxStep() { - return this.visibleFieldSets.length; - } - - public nextStep() { - if (this.step < this.maxStep) {//view is changing - this.step = Math.floor(this.step + 1); - let entry = this.visibleFieldSets[this.step - 1]; - this.table0fContents.onToCentrySelected(entry, false); - this.scroll(entry); - } - } - - public previousStep() { - if (this.step > 0) { - this.step = Math.ceil(this.step - 1); - if (this.step >= 1) { - let entry = this.visibleFieldSets[this.step - 1]; - this.table0fContents.onToCentrySelected(entry, false); - this.scroll(entry); - } else { - this.table0fContents.onToCentrySelected(null, false); - this.resetScroll(); - } - } - } - - private resetScroll() { - document.getElementById('dataset-editor-form').scrollTop = 0; - } - - private scroll(entry: ToCEntry) { - document.getElementById(entry.id).scrollIntoView(); - } - - isDirty() { - return this.formGroup.dirty && this.hasChanges; // do we need this.formGroup.dirty - } - - discardChanges() { - // this.isDiscarded = true; - // this.hasChanges = false; - // this.hintErrors = false; - let messageText = ""; - let confirmButtonText = ""; - let cancelButtonText = ""; - let isDeleteConfirmation = false; - - if (this.isNew && !this.datasetIsOnceSaved) { - - messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE'); - confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM'); - cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY'); - isDeleteConfirmation = true; - - // Object.keys(this.formGroup['controls']).forEach((key: string) => { - // if (key !== 'dmp' && (key!== 'profile')) { - // if(key === 'datasetProfileDefinition'){ - // this.formGroup.get(key).patchValue(this.datasetProfileDefinitionModel.buildForm().getRawValue); - // }else{ - // this.formGroup.get(key).reset(); - // } - - // } - // }); - } else { - - messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE'); - confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM'); - cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-DENY'); - isDeleteConfirmation = false; - - // this.isDiscarded = true; - // this.hasChanges = false; - // this.hintErrors = false; - // // this._unregisterFormListeners(); - // this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue))); - // // this.registerFormListeners(); - // this.isDiscarded = false; - - - } - - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: messageText, - confirmButton: confirmButtonText, - cancelButton: cancelButtonText, - isDeleteConfirmation: true - }, - maxWidth: '40em' - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - // this.backToDmp(this.formGroup.get('dmp').value.id) - setTimeout(x => { - this.init(); - }); - } - }); - - - // this.isDiscarded = false; - } - - addDataset(dmpId: string) { - this.router.navigate(['/datasets', 'new', dmpId]); - } - - reloadDateset(datasetId: string) { - let url = this.router.createUrlTree(['/datasets', 'edit', datasetId]).toString(); - this.location.go(url); - } - - backToDmp(id: string) { - this.router.navigate(['/plans', 'edit', id]); - } - - datasetInfoValid(): boolean { - return this.formGroup.get('label') && this.formGroup.get('label').valid && this.formGroup.get('profile') && this.formGroup.get('profile').valid; - } - - getLinks(currentLinks: Link[]) { - this.links = currentLinks; - } - - printForm() { - console.log(this.formGroup); - } - - printFormValue() { - console.log(this.formGroup.value); - } - - touchForm() { - this.formGroup.markAllAsTouched(); - this.showtocentriesErrors = true; - } - - // tocentries; - // this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); //TODO - - - // get tocentries(){ - // const form = this.formGroup.get('datasetProfileDefinition') - // if(!form) return null; - - // return this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); - // } - - - // private _buildRecursively(form: FormGroup,whatAmI:ToCEntryType):ToCEntry{ - // if(!form) return null; - - // switch(whatAmI){ - // case ToCEntryType.Section: - // const sections = form.get('sections') as FormArray; - // const fieldsets = form.get('compositeFields') as FormArray; - - - // const tempResult:ToCEntry[] = []; - - // if(sections &§ions.length){ - // sections.controls.forEach(section=>{ - // tempResult.push(this._buildRecursively(section as FormGroup, ToCEntryType.Section)); - // }); - - // }else if(fieldsets && fieldsets.length){ - // fieldsets.controls.forEach(fieldset=>{ - // tempResult.push(this._buildRecursively(fieldset as FormGroup, ToCEntryType.FieldSet)); - // }); - // } - // return { - // form: form, - // id: form.get('id').value, - // label: form.get('title').value, - // numbering: '', - // subEntries:tempResult, - // subEntriesType: sections &§ions.length? ToCEntryType.Section: ToCEntryType.FieldSet, - // type: ToCEntryType.Section, - // ordinal: form.get('ordinal').value - // } - // case ToCEntryType.FieldSet: - // return { - // form: form, - // label:form.get('title').value, - // id: form.get('id').value, - // numbering:'s', - // subEntries:[], - // subEntriesType: ToCEntryType.Field, - // type: ToCEntryType.FieldSet, - // ordinal: form.get('ordinal').value - // } - // } - // } - - // private _sortByOrdinal(tocentries: ToCEntry[]){ - - // if(!tocentries || !tocentries.length) return; - - // tocentries.sort(this._customCompare); - // tocentries.forEach(entry=>{ - // this._sortByOrdinal(entry.subEntries); - // }); - // } - - // private _customCompare(a,b){ - // return a.ordinal - b.ordinal; - // } - - // private _calculateNumbering(tocentries: ToCEntry[], depth:number[] = []){ - // if(!tocentries || !tocentries.length){ - // return; - // } - - // let prefixNumbering = depth.length? depth.join('.'): ''; - - // if(depth.length) prefixNumbering = prefixNumbering+"."; - // tocentries.forEach((entry,i)=>{ - // entry.numbering = prefixNumbering + (i+1); - // this._calculateNumbering(entry.subEntries, [...depth, i+1]) - // }); - // } - - - // getTocEntries(form): ToCEntry[] { - // if (form == null) { return []; } - // const result: ToCEntry[] = []; - - // //build parent pages - // (form.get('pages') as FormArray).controls.forEach((pageElement, i) => { - // result.push({ - // id: i+'id', - // label: pageElement.get('title').value, - // type: ToCEntryType.Page, - // form: pageElement, - // numbering: (i + 1).toString(), - // subEntriesType: ToCEntryType.Section, - // subEntries:[], - // ordinal: pageElement.get('ordinal').value - // } as ToCEntry) - // }); - - - // result.forEach((entry,i)=>{ - - // const sections = entry.form.get('sections') as FormArray; - - // sections.controls.forEach(section=>{ - // const tempResults = this._buildRecursively(section as FormGroup,ToCEntryType.Section); - // entry.subEntries.push(tempResults); - // }); - - // }); - - // this._sortByOrdinal(result); - // //calculate numbering - // this._calculateNumbering(result); - // return result; - - // } - - -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html deleted file mode 100644 index 4cf8f26cc..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html +++ /dev/null @@ -1,489 +0,0 @@ -
- -
-
-
-

1.3 {{'DATASET-EDITOR.FIELDS.TAGS' | translate}}

-
-
-
- - - -
-
- - - - - - - - -
- - - - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts deleted file mode 100644 index cac88b15d..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalSourcesConfiguration } from '@app/core/model/external-sources/external-sources-configuration'; -import { DataRepositoryCriteria } from '@app/core/query/data-repository/data-repository-criteria'; -import { ExternalDatasetCriteria } from '@app/core/query/external-dataset/external-dataset-criteria'; -import { RegistryCriteria } from '@app/core/query/registry/registry-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { ServiceCriteria } from '@app/core/query/service/service-criteria'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { ExternalSourcesConfigurationService } from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { ExternalDataRepositoryEditorModel, ExternalDatasetEditorModel, ExternalRegistryEditorModel, ExternalServiceEditorModel, ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { DatasetExternalDataRepositoryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component'; -import { DatasetExternalDatasetDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component'; -import { DatasetExternalRegistryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component'; -import { DatasetExternalServiceDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable } from 'rxjs'; -import { takeUntil, map } from 'rxjs/operators'; -import { ENTER, COMMA } from '@angular/cdk/keycodes'; -import { MatChipInputEvent } from '@angular/material/chips'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service'; -import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service'; -import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; - -@Component({ - selector: 'app-dataset-external-references-editor-component', - templateUrl: 'dataset-external-references-editor.component.html', - styleUrls: ['./dataset-external-references-editor.component.scss'] -}) -export class DatasetExternalReferencesEditorComponent extends BaseComponent implements OnInit { - - @Input() formGroup: UntypedFormGroup = null; - @Input() viewOnly = false; - @Output() formChanged: EventEmitter = new EventEmitter(); - - public filteringTagsAsync = false; - public filteredTags: ExternalSourceItemModel[]; - - readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDatasets.bind(this), - initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => 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') - }; - - registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalRegistries.bind(this), - initialItems: (type) => this.searchDatasetExternalRegistries('', type), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => 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') - }; - - dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDataRepositories.bind(this), - initialItems: (type) => this.searchDatasetExternalDataRepositories('', type), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => 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') - }; - - servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalServices.bind(this), - initialItems: (type) => this.searchDatasetExternalServices('', type), - displayFn: (item) => item ? item.label : null, - titleFn: (item) => item ? item.label : null, - subtitleFn: (item) => 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') - }; - - tagsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => this.showTag(item), - titleFn: (item) => item['name'], - valueAssign: (item) => this.addTag(item) - }; - - externalSourcesConfiguration: ExternalSourcesConfiguration; - - // new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), - - constructor( - private dialog: MatDialog, - private router: Router, - private language: TranslateService, - private externalSourcesService: ExternalSourcesService, - private externalSourcesConfigurationService: ExternalSourcesConfigurationService, - private externalDataRepositoryService: ExternalDataRepositoryService, - private externalDatasetService: ExternalDatasetService, - private externalRegistryService: ExternalRegistryService, - private externalServiceService: ExternalServiceService, - ) { super(); } - - ngOnInit() { - - this.externalSourcesConfigurationService.getExternalSourcesConfiguration() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.externalSourcesConfiguration = result; - this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.services.push({ key: '', label: 'All' }); - if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) { - this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' }); - } else { - this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }]; - } - }); - - this.formGroup.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(val => { - this.formChanged.emit(val); - }); - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - externalDatasetsOnItemChange(event) { - const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.name, event.pid ? event.pid : event.reference, event.source); - (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - } - - registriesOnItemChange(event) { - const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.name, event.pid ? event.pid : event.reference, event.uri, event.source); - (this.formGroup.get('registries')).push(registryModel.buildForm()); - } - - servicesOnItemChange(event) { - const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri); - (this.formGroup.get('services')).push(serviceModel.buildForm()); - } - - tagsOnItemChange(event) { - const tagModel = new ExternalTagEditorModel(event.id, event.name); - (this.formGroup.get('tags')).push(tagModel.buildForm()); - } - - - dataRepositoriesOnItemChange(event) { - const dataRepositoryModel = new ExternalDataRepositoryEditorModel(event.id, event.name, event.abbreviation, event.uri, event.pid, event.source); - (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - } - - addDataRepository() { - const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source); - (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - }); - } - - addRegistry() { - const dialogRef = this.dialog.open(DatasetExternalRegistryDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - (this.formGroup.get('registries')).push(registryModel.buildForm()); - }); - } - - addExternalDataset() { - const dialogRef = this.dialog.open(DatasetExternalDatasetDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const externalDatasetModel = new ExternalDatasetEditorModel(result.id, result.abbreviation, result.name, result.reference, result.source); - (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - }); - } - - addService() { - const dialogRef = this.dialog.open(DatasetExternalServiceDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - (this.formGroup.get('services')).push(serviceModel.buildForm()); - }); - } - - searchDatasetExternalDatasets(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ExternalDatasetCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); - } - - searchDatasetExternalDataRepositories(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new DataRepositoryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetRepository(requestItem); - } - - searchDatasetExternalRegistries(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new RegistryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetRegistry(requestItem); - } - - searchDatasetExternalServices(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ServiceCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetService(requestItem); - } - - searchDatasetTags(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new TagCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - removeTag(tag: any) { - (this.formGroup.get('tags')).removeAt(((this.formGroup.get('tags')).value as any[]).indexOf(tag)); - } - - addTag(ev: any) { - let item: ExternalTagEditorModel; - //this.filteredTags = this.formGroup.get('tags').value; - if (typeof ev === 'string') { - item = new ExternalTagEditorModel('', ev); - } else { - item = ev; - } - if (item.name !== '' ) { - return item; - } - } - - isInternal(element: any): boolean { - if (element.get('source') == null) { - // console.log(element); - } - return element.get('source').value === 'Internal'; - } - - updateDataRepository(dataRepository: UntypedFormGroup) { - this.externalDataRepositoryService.create(dataRepository.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - dataRepository.setValue(result); - } - ); - } - - updateExternalDataset(externalDataset: UntypedFormGroup) { - this.externalDatasetService.create(externalDataset.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - externalDataset.setValue(result); - } - ); - } - - updateRegistry(registry: UntypedFormGroup) { - this.externalRegistryService.create(registry.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - registry.setValue(result); - } - ); - } - - updateService(service: UntypedFormGroup) { - this.externalServiceService.create(service.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - service.setValue(result); - } - ); - } - - filterTags(value: string): Observable { - this.filteringTagsAsync = true; - - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - showTag(ev: any) { - if (typeof ev === 'string') { - return ev; - } else { - return ev.name; - } - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html deleted file mode 100644 index 2367cc238..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts deleted file mode 100644 index 9c53aa709..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDataRepositoryEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: 'dataset-external-data-repository-dialog-editor.component.html', - styleUrls: ['./dataset-external-data-repository-dialog-editor.component.scss'] -}) -export class DatasetExternalDataRepositoryDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalDataRepositoryService: ExternalDataRepositoryService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const datarepo = new ExternalDataRepositoryEditorModel(); - this.formGroup = datarepo.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalDataRepositoryService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html deleted file mode 100644 index 530a33bd4..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts deleted file mode 100644 index 676181d56..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service'; -import { ExternalDatasetEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { FormService } from '@common/forms/form-service'; - -@Component({ - templateUrl: 'dataset-external-dataset-dialog-editor.component.html', - styleUrls: ['./dataset-external-dataset-dialog-editor.component.scss'] -}) -export class DatasetExternalDatasetDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalDatasetService: ExternalDatasetService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const externalDatasetModel = new ExternalDatasetEditorModel(); - this.formGroup = externalDatasetModel.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalDatasetService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html deleted file mode 100644 index 111e52fc6..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.REGISTRY.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts deleted file mode 100644 index 9179bdbc7..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service'; -import { ExternalRegistryEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: 'dataset-external-registry-dialog-editor.component.html', - styleUrls: ['./dataset-external-registry-dialog-editor.component.scss'] -}) -export class DatasetExternalRegistryDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalRegistryService: ExternalRegistryService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const registryModel = new ExternalRegistryEditorModel(); - this.formGroup = registryModel.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalRegistryService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html deleted file mode 100644 index 994c214e7..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.SERVICES.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts deleted file mode 100644 index 5da9f1b59..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service'; -import { ExternalServiceEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { FormService } from '@common/forms/form-service'; - -@Component({ - templateUrl: 'dataset-external-service-dialog-editor.component.html', - styleUrls: ['./dataset-external-service-dialog-editor.component.scss'] -}) -export class DatasetExternalServiceDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalServiceService: ExternalServiceService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const serviceModel = new ExternalServiceEditorModel(); - this.formGroup = serviceModel.buildForm(); - } - - send() { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalServiceService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset.module.ts b/dmp-frontend/src/app/ui/dataset/dataset.module.ts deleted file mode 100644 index c31346c9b..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset.module.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; -import { DatasetEditorComponent } from '@app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component'; -import { DatasetWizardComponent } from '@app/ui/dataset/dataset-wizard/dataset-wizard.component'; -import { DatasetExternalReferencesEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component'; -import { DatasetExternalDataRepositoryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component'; -import { DatasetExternalDatasetDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component'; -import { DatasetExternalRegistryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component'; -import { DatasetExternalServiceDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component'; -import { DatasetRoutingModule } from '@app/ui/dataset/dataset.routing'; -import { DatasetCriteriaComponent } from '@app/ui/dataset/listing/criteria/dataset-criteria.component'; -import { DatasetUploadDialogue } from '@app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component'; -import { DatasetListingComponent } from '@app/ui/dataset/listing/dataset-listing.component'; -import { DatasetListingItemComponent } from '@app/ui/dataset/listing/listing-item/dataset-listing-item.component'; -import { DatasetDescriptionFormModule } from '@app/ui/misc/dataset-description-form/dataset-description-form.module'; -import { TableOfContentsModule } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module'; -import { ExternalSourcesModule } from '@app/ui/misc/external-sources/external-sources.module'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; -import { FormProgressIndicationModule } from '../misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module'; -import { DatasetCopyDialogModule } from './dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module'; -import { DatasetCriteriaDialogComponent } from './listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component'; -import { DatasetOverviewModule } from './overview/dataset-overview.module'; -import {RichTextEditorModule} from "@app/library/rich-text-editor/rich-text-editor.module"; -import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component"; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - UrlListingModule, - FormattingModule, - ConfirmationDialogModule, - AutoCompleteModule, - ExternalSourcesModule, - ExportMethodDialogModule, - DatasetDescriptionFormModule, - TableOfContentsModule, - AngularStickyThingsModule, - DatasetRoutingModule, - FormValidationErrorsDialogModule, - DatasetCopyDialogModule, - DatasetOverviewModule, - FormProgressIndicationModule, - RichTextEditorModule - ], - declarations: [ - DatasetListingComponent, - DatasetCriteriaComponent, - DatasetWizardComponent, - DatasetEditorComponent, - DatasetExternalReferencesEditorComponent, - DatasetExternalDataRepositoryDialogEditorComponent, - DatasetExternalDatasetDialogEditorComponent, - DatasetExternalRegistryDialogEditorComponent, - DatasetExternalServiceDialogEditorComponent, - DatasetUploadDialogue, - DatasetListingItemComponent, - DatasetCriteriaDialogComponent, - PrefillDatasetComponent - ], - exports: [ - DatasetExternalReferencesEditorComponent, - DatasetExternalDataRepositoryDialogEditorComponent, - DatasetExternalDatasetDialogEditorComponent, - DatasetExternalRegistryDialogEditorComponent, - DatasetExternalServiceDialogEditorComponent, - DatasetEditorComponent, - DatasetDescriptionFormModule - ] -}) -export class DatasetModule { } diff --git a/dmp-frontend/src/app/ui/dataset/dataset.routing.ts b/dmp-frontend/src/app/ui/dataset/dataset.routing.ts deleted file mode 100644 index ab3bb27ed..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset.routing.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; -import { AuthGuard } from '../../core/auth-guard.service'; -import { DatasetWizardComponent } from './dataset-wizard/dataset-wizard.component'; -import { DatasetListingComponent } from './listing/dataset-listing.component'; -import { DatasetOverviewComponent } from './overview/dataset-overview.component'; - -const routes: Routes = [ - { - path: 'new/:dmpId/:dmpSectionIndex', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-NEW' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'edit/:id', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - public: false, - title: 'GENERAL.TITLES.DATASET-EDIT' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'edit/:id/finalize', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - public: false, - title: 'GENERAL.TITLES.DATASET-EDIT', - finalize: true - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'publicEdit/:publicId', - component: DatasetWizardComponent, - //canActivate: [AuthGuard], - data: { - public: true, - title: 'GENERAL.TITLES.DATASET-PUBLIC-EDIT' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'new', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-NEW' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: '', - component: DatasetListingComponent, - // canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, - { - path: 'dmp/:dmpId', - component: DatasetListingComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, - { - path: 'copy/:id', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-COPY' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'profileupdate/:updateId', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-UPDATE' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'overview/:id', - component: DatasetOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - }, - { - path: 'publicOverview/:publicId', - component: DatasetOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class DatasetRoutingModule { } diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html deleted file mode 100644 index db2bddfee..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html +++ /dev/null @@ -1,2 +0,0 @@ -clear - diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss deleted file mode 100644 index 6ad258085..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss +++ /dev/null @@ -1,20 +0,0 @@ -.clear-icon { - cursor: pointer; - color: #212121; - padding: 0.4rem; -} - -.clear-icon:hover { - background-color: #ececec !important; - border-radius: 50%; - padding: 0.4rem; -} - -:host ::ng-deep .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts deleted file mode 100644 index d640a6d1f..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, Inject, OnInit, ViewChild } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { DatasetCriteriaComponent } from '../dataset-criteria.component'; - -@Component({ - selector: 'dataset-criteria-dialog-component', - templateUrl: './dataset-criteria-dialog.component.html', - styleUrls: ['./dataset-criteria-dialog.component.scss'] -}) - -export class DatasetCriteriaDialogComponent implements OnInit { - - @ViewChild(DatasetCriteriaComponent, { static: true }) criteria: DatasetCriteriaComponent; - - constructor( - public dialogRef: MatDialogRef, - private httpClient: HttpClient, - private matomoService: MatomoService, - @Inject(MAT_DIALOG_DATA) public data: { isPublic: boolean, status: Number, criteria: DatasetCriteria, formGroup: UntypedFormGroup, updateDataFn: Function } - ) { - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Criteria'); - this.criteria.setCriteria(this.data.criteria); - } - - onNoClick(): void { - this.dialogRef.close(); - } - - onClose(): void { - this.dialogRef.close(); - } - - onFiltersChanged(event) { - this.data.updateDataFn(this.criteria); - } - -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html deleted file mode 100644 index 6498dc3f5..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html +++ /dev/null @@ -1,200 +0,0 @@ -
-
-
-
-
{{'CRITERIA.FILTERS'| translate}}
-
-
-
- - - - - -
-
{{'CRITERIA.DATA-SETS.STATUS'| translate}}
- - - {{ 'TYPES.DATASET-STATUS.ANY' | translate }} - - - {{ 'TYPES.DATASET-STATUS.DRAFT' | translate }} - - - {{ 'TYPES.DATASET-STATUS.FINALISED' | translate }} - - -
-
- - - -
-
{{ 'FACET-SEARCH.GRANT-STATUS.TITLE' | translate }}
- - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ANY' | translate }} - - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE' | translate }} - - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE' | translate }} - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-DATASET-TEMPLATES' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-DATASET-TEMPLATES' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-DMP' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-DMP' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.ALL-VERSIONS'| translate}}
- -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-GRANT' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-GRANTS' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-COLLABORATORS' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-COLLABORATORS' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.ROLE' | translate }}
- - - {{ 'TYPES.DATASET-ROLE.ANY' | translate }} - - - {{ 'TYPES.DATASET-ROLE.OWNER' | translate }} - - - {{ 'TYPES.DATASET-ROLE.MEMBER' | translate }} - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.ORGANIZATION' | translate }}
- - {{'CRITERIA.DATA-SETS.SELECT-ORGANIZATIONS' | translate}} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.TAGS' | translate }}
- - {{'CRITERIA.DATA-SETS.SELECT-TAGS' | translate}} - - - -
- - - - - -
-
-
- - diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss deleted file mode 100644 index a8e92de7c..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss +++ /dev/null @@ -1,56 +0,0 @@ -.search ::ng-deep.mat-form-field-infix { - margin-left: 1em; -} - -.category-title { - color: black; - // color: #089dbb; - margin-top: 8px; - margin-bottom: 12px; - text-transform: none; - font-size: 1rem; - font-weight: 400; -} - -.import { - margin: 10px; - padding: 0px; -} - -.filters { - // border: 1px solid #e4e4e4; - // border-radius: 5px; -} - -.criteria-title { - color: black; - font-weight: 500; - text-transform: none; - font-size: 1.25rem; - margin-bottom: 1.5em; - opacity: 0.8; -} - -.filters-title { - width: 93px; - // color: #089dbb; - color: var(--primary-color-2); - background-color: white; - padding: 0px 20px; - margin-top: -10px; - margin-left: 20px; - text-transform: uppercase; -} - -.style-icon { - color: #adadad; -} - -::ng-deep .search-form .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts deleted file mode 100644 index a05881fc8..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts +++ /dev/null @@ -1,339 +0,0 @@ - -import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { OrganisationCriteria } from '@app/core/query/organisation/organisation-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { UserCriteria } from '@app/core/query/user/user-criteria'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { OrganisationService } from '@app/core/services/organisation/organisation.service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { DatasetUploadDialogue } from '@app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; - -@Component({ - selector: 'app-dataset-criteria-component', - templateUrl: './dataset-criteria.component.html', - styleUrls: ['./dataset-criteria.component.scss'] -}) -export class DatasetCriteriaComponent extends BaseCriteriaComponent implements OnInit { - - @Input() dmpSearchEnabled; - @Input() status; - @Input() isPublic: boolean; - @Input() criteriaFormGroup: UntypedFormGroup; - @Output() filtersChanged: EventEmitter = new EventEmitter(); - public criteria: any; - public filteringTagsAsync = false; - public filteredTags: ExternalSourceItemModel[]; - statuses = DatasetStatus; - - options: UntypedFormGroup; - - public formGroup = new UntypedFormBuilder().group({ - like: new UntypedFormControl(), - groupIds: new UntypedFormControl(), - grants: new UntypedFormControl(), - status: new UntypedFormControl(), - role: new UntypedFormControl(), - organisations: new UntypedFormControl(), - collaborators: new UntypedFormControl(), - datasetTemplates: new UntypedFormControl(), - tags: new UntypedFormControl(), - allVersions: new UntypedFormControl(), - grantStatus: new UntypedFormControl() - }); - - tagsAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - }; - - datasetTemplateAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterDatasetTemplate.bind(this), - initialItems: (excludedItems: any[]) => this.filterDatasetTemplate('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'] - }; - - dmpAutoCompleteConfiguration = { - filterFn: (x, excluded) => this.filterDmps(x).pipe(map(x => x.data)), - initialItems: (extraData) => this.filterDmps('').pipe(map(x => x.data)), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - collaboratorsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterCollaborators.bind(this), - initialItems: (excludedItems: any[]) => this.filterCollaborators('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - }; - - grantAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterGrant.bind(this), - initialItems: (excludedItems: any[]) => this.filterGrant('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - organisationAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - 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) => item['name'], - titleFn: (item) => item['name'] - } - - constructor( - private externalSourcesService: ExternalSourcesService, - public enumUtils: EnumUtils, - public dmpService: DmpService, - public datasetWizardService: DatasetWizardService, - private dialog: MatDialog, - private snackBar: MatSnackBar, - private uiNotificationService: UiNotificationService, - private router: Router, - private language: TranslateService, - public grantService: GrantService, - private organisationService: OrganisationService, - private userService: UserServiceOld, - private datasetService: DatasetService, - fb: UntypedFormBuilder, - private authService: AuthService - - ) { - super(new ValidationErrorModel()); - // this.options = fb.group({ - // status: new FormControl(), - // floatLabel: 'auto', - // }); - } - - ngOnInit() { - super.ngOnInit(); - - // This if is just for passing label on chips of dialog - if (this.formGroup && this.criteriaFormGroup) { - this.formGroup.get('datasetTemplates').setValue(this.criteriaFormGroup.get('datasetTemplates').value); - this.formGroup.get('groupIds').setValue(this.criteriaFormGroup.get('groupIds').value); - this.formGroup.get('grants').setValue(this.criteriaFormGroup.get('grants').value); - this.formGroup.get('collaborators').setValue(this.criteriaFormGroup.get('collaborators').value); - this.formGroup.get('organisations').setValue(this.criteriaFormGroup.get('organisations').value); - this.formGroup.get('tags').setValue(this.criteriaFormGroup.get('tags').value); - - } - - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('groupIds').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('grants').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('status').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('role').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('organisations').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('collaborators').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('datasetTemplates').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('allVersions').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('tags').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('grantStatus').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - // if (this.criteria == null) { this.criteria = {}; } - // this.formGroup.patchValue({'status': this.status !== undefined ? this.status : 'null'}); - } - - setCriteria(criteria: DatasetCriteria): void { - this.formGroup.get('like').patchValue(criteria.like); - this.formGroup.get('groupIds').patchValue(criteria.groupIds); - this.formGroup.get('grants').patchValue(criteria.grants); - this.formGroup.get('status').patchValue(criteria.status); - this.formGroup.get('role').patchValue(criteria.role); - this.formGroup.get('collaborators').patchValue(criteria.collaborators); - this.formGroup.get('datasetTemplates').patchValue(criteria.datasetTemplates); - this.formGroup.get('allVersions').patchValue(criteria.allVersions); - this.formGroup.get('tags').patchValue(criteria.tags); - this.formGroup.get('grantStatus').patchValue(criteria.grantStatus); - // this.criteria = criteria; - } - - controlModified(): void { - this.clearErrorModel(); - this.filtersChanged.emit(); - if (this.refreshCallback != null && - (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) - ) { - setTimeout(() => this.refreshCallback(true)); - } - // if (this.refreshCallback != null && - // (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2) - // ) { - // this.refreshCallback(); - // } - } - - filterTags(value: string): Observable { - this.filteredTags = undefined; - this.filteringTagsAsync = true; - - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - filterDatasetTemplate(query: string): Observable { - const fields: Array = new Array(); - fields.push('asc'); - const datasetTemplateRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - datasetTemplateRequestItem.criteria = new DatasetProfileCriteria(); - datasetTemplateRequestItem.criteria.like = query; - if (this.isPublic) { - return this.datasetService.getDatasetProfiles(datasetTemplateRequestItem); - } else { - return this.datasetService.getDatasetProfilesUsedPaged(datasetTemplateRequestItem).pipe(map(x => x.data)); - } - } - - filterDmps(value: string): Observable> { - const fields: Array = new Array(); - fields.push('asc'); - - // if (this.isPublic) { - // const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - // dmpDataTableRequest.criteria = new ExploreDmpCriteriaModel(); - // dmpDataTableRequest.criteria.like = value; - // return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete"); - // } else { - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = value; - if (this.isPublic) { - dmpDataTableRequest.criteria.isPublic = true; - dmpDataTableRequest.criteria.onlyPublic = true; - } - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); - // } - } - - filterGrant(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const grantRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - if (this.isPublic) { - return this.grantService.getPublicPaged(grantRequestItem).pipe(map(x => x.data)); - } else { - return this.grantService.getPaged(grantRequestItem, "autocomplete").pipe(map(x => x.data)); - } - } - - filterOrganisations(value: string) { - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = value; - if (this.isPublic) { - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } else { - return this.organisationService.searchInternalOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - } - - filterCollaborators(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const collaboratorsRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - collaboratorsRequestItem.criteria = new UserCriteria(); - collaboratorsRequestItem.criteria.collaboratorLike = query; - return this.userService.getCollaboratorsPaged(collaboratorsRequestItem).pipe(map(x => x.data)); - } - - fileImport(event) { - const dialogRef = this.dialog.open(DatasetUploadDialogue, { - data: { - fileList: FileList, - success: Boolean, - datasetTitle: String, - dmpId: String, - datasetProfileId: String, - dmpSearchEnabled: this.dmpSearchEnabled, - criteria: this.criteria - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result && result.success) { - this.datasetWizardService.uploadXml(result.fileList, result.datasetTitle, result.dmpId, result.datasetProfileId) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - }) - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-UPLOAD.SNACK-BAR.SUCCESSFUL-CREATION'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - onCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Success); - } - - isAuthenticated(): boolean { - return this.authService.currentAccountIsAuthenticated(); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html deleted file mode 100644 index f631c3a39..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html +++ /dev/null @@ -1,42 +0,0 @@ -
-
-
-

{{'DATASET-UPLOAD.TITLE' | translate}}

-
-
- - -
-
-
- - - - - - - - - - - - - {{datasetProfile.label}} - - - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss deleted file mode 100644 index c066ed1b5..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss +++ /dev/null @@ -1,21 +0,0 @@ -.confirmation-dialog { - .confirmation-message { - padding-bottom: 20px; - } - - .hidden { - display: none; - } - - .uploadButton { - float: right; - } - - .col-md-6 { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - margin: -4px; - } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts deleted file mode 100644 index 307907fcd..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts +++ /dev/null @@ -1,157 +0,0 @@ - -import { Component, Inject, OnInit } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'dataset-upload-dialogue', - templateUrl: './dataset-upload-dialogue.component.html', - styleUrls: ['./dataset-upload-dialogue.component.scss'] -}) -export class DatasetUploadDialogue extends BaseCriteriaComponent implements OnInit { - - public dialogueCriteria: any; - datasetTitle: string; - dmp: DmpModel; - datasetProfile: DatasetProfileModel; - availableProfiles: DatasetProfileModel[] = []; - - dmpAutoCompleteConfiguration = { - filterFn: (x, excluded) => this.filterDmps(x).pipe(map(x => x.data)), - initialItems: (extraData) => this.filterDmps('').pipe(map(x => x.data)), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - constructor( - public dialogRef: MatDialogRef, - public dmpService: DmpService, - private datasetWizardService: DatasetWizardService, - @Inject(MAT_DIALOG_DATA) public data: any, - ) { super(new ValidationErrorModel()); } - - ngOnInit() { - super.ngOnInit(); - if (this.dialogueCriteria == null) { this.dialogueCriteria = {}; } - if (!this.data.dmpSearchEnabled) { - this.dialogueCriteria = this.data.criteria; - this.dmp = this.dialogueCriteria.dmpIds[0]; - this.loadDatasetProfiles(); - } - } - - cancel() { - this.data.success = false; - this.dialogRef.close(this.data) - } - - confirm() { - this.data.success = true; - this.data.datasetTitle = this.datasetTitle; - this.data.dmpId = this.dmp.id; - this.data.datasetProfileId = this.datasetProfile.id; - this.dialogRef.close(this.data); - } - - uploadFile(event) { - const fileList: FileList = event.target.files - this.data.fileList = fileList; - if (this.data.fileList.length > 0) { - this.datasetTitle = fileList.item(0).name; - } - } - - filterDmps(value: string): Observable> { - const fields: Array = new Array(); - fields.push('asc'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = value; - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); - } - - controlModified(): void { - this.loadDatasetProfiles(); - if (!this.dmp) { - this.availableProfiles = []; - } - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.dialogueCriteria.like == null || this.dialogueCriteria.like.length === 0 || this.dialogueCriteria.like.length > 2) - ) { - this.refreshCallback(); - } - } - - loadDatasetProfiles() { - const datasetProfileRequestItem: RequestItem = new RequestItem(); - datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - if (this.dmp) { - datasetProfileRequestItem.criteria.id = this.dmp.id; - } - if (datasetProfileRequestItem.criteria.id) { - this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.availableProfiles = items; - if (this.availableProfiles.length === 1) { - this.datasetProfile = this.availableProfiles[0]; - } - }); - } - } - - setCriteriaDialogue(criteria: DatasetCriteria): void { - this.dialogueCriteria = criteria; - } - - disableButton() { - if (!(this.data.fileList.length > 0) || !this.dmp) { - return true; - } - else { - return false; - } - } - - disableDatasetName() { - if (!(this.data.fileList.length > 0)) { - return true; - } - else { - return false; - } - } - - disableDmpSearch() { - if (!(this.data.fileList.length > 0) || !this.data.dmpSearchEnabled) { - return true; - } - else { - return false; - } - } - - disableDatasetProfile() { - if (!this.dmp || (!this.data.dmpSearchEnabled && !(this.data.fileList.length > 0)) || (!this.data.dmpSearchEnabled && this.availableProfiles.length === 1)) { - return true; - } - else { - return false; - } - } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html deleted file mode 100644 index 632807de0..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html +++ /dev/null @@ -1,120 +0,0 @@ -
-
-
-
- - -
-

{{'DATASET-LISTING.TEXT-INFO' | translate}} {{'DATASET-LISTING.LINK-PUBLIC-DATASETS' | translate}} {{'DATASET-LISTING.TEXT-INFO-REST' | translate}}

-

{{'DATASET-LISTING.TEXT-INFO-PAR' | translate}} -

- - -
-
-
-

{{(isPublic ? 'GENERAL.TITLES.EXPLORE' : 'GENERAL.TITLES.DESCRIPTIONS') | translate}}

-
-
- -
-
-
- -
-
-
-
-
-
- - {{'DMP-LISTING.SORT-BY' | translate}}: - - - {{enumUtils.toRecentActivityOrderString(order.MODIFIED)}} - {{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}} - {{enumUtils.toRecentActivityOrderString(order.LABEL)}} - {{enumUtils.toRecentActivityOrderString(order.STATUS)}} - - - - -
- -
- {{ 'GENERAL.ACTIONS.TAKE-A-TOUR'| translate }} -
- - - - search - - {{formGroup.get('like').getError('backendError').message}} - - -
-
-
-
-
- -
-
- -
-
-
- {{'DATASET-LISTING.EMPTY-LIST' | translate}} -
-
-
-
-
- - - diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss deleted file mode 100644 index 5042fe772..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss +++ /dev/null @@ -1,265 +0,0 @@ -@import "node_modules/bootstrap/scss/functions"; -@import "node_modules/bootstrap/scss/variables"; -@import "node_modules/bootstrap/scss/mixins/_breakpoints"; - -@include media-breakpoint-down(sm) { - .lightblue-btn { - font-size: 12px; - } - ::ng-deep .mat-paginator-container { - height: auto !important; - } -} - -.header-image { - background: url("/assets/images/new-dashboard-bg.png") no-repeat; - background-size: cover; - margin-top: 70px; - min-height: 15em; - position: relative; -} - -.header-title { - text-align: left; - font-size: 1.25rem; - font-weight: 300; - color: #212121; - padding: 0px; -} - -.header-text-container { - background: rgba(255, 255, 255, 0.7); - position: absolute; - bottom: 0px; - padding-left: 5em; - padding-right: 10em; - padding-top: 2em; - padding-bottom: 2em; -} - -.explore-dmp-content { - padding: 30px 15px; -} - -.main-content { - background-color: #f5f5f5; - padding-top: 4.68rem; - padding-bottom: 3rem; - padding-left: 3rem; - padding-right: 3rem; - margin: 0; - display: flex; - flex-grow: 1; -} - -.card { - background: #ffffff 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #00000029; - border-radius: 4px; - // width: 987px; - margin-bottom: 3.75rem; - /* height: 407px; */ - opacity: 1; -} - -.card-title { - text-align: left; - font: Bold 20px/30px Roboto; - letter-spacing: 0px; - color: #212121; - padding-left: 40px; - /* padding-top: 40px; */ - padding-right: 55px; - opacity: 1; -} - -.card-content { - text-align: left; - font-weight: 300; - letter-spacing: 0px; - color: #212121; - padding-left: 40px; - padding-top: 36px; -// padding-bottom: 36px; - padding-right: 55px; - opacity: 1; -} - -.clear-icon { - cursor: pointer; - color: #212121; - padding: 0.4rem; -} - -.clear-icon:hover { - background-color: #ececec !important; - border-radius: 50%; - padding: 0.4rem; -} - -.normal-btn { - min-width: 162px; - max-width: 256px; - height: 40px; - cursor: pointer; - background: var(--primary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border-radius: 30px; - border: none; - color: #ffffff; - opacity: 1; - line-height: 1; - font-size: 0.87rem; - padding: 0.62rem 1.87rem; - margin-left: 40px; -} - -.yellow-btn { - min-width: 162px; - max-width: 256px; - height: 40px; - cursor: pointer; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - border: none; - color: #000000; - opacity: 1; - line-height: 1; - font-size: 0.87rem; - padding: 0.62rem 1.87rem; - font-weight: 700; -} - -.info-text { - text-align: left; - font-weight: 300; - font-size: 1rem; - letter-spacing: 0px; - color: #212121; -} - -.filter-btn { - position: fixed; - right: 0px; - z-index: 100; - width: 37px; -} - -.filter-btn button { - color: white; - background-color: var(--primary-color-2); - width: 37px; - height: 45px; -} - -.center-content { - width: 100%; - min-width: 10rem; - margin: auto; - padding: 0 15px; - text-align: right; - font-size: 0.875rem; - font-weight: 600; - letter-spacing: 0.02rem; - color: #2d72d6; - cursor: pointer; -} - -.search-form { - // font-size: 12px; - text-align: left; - width: 20rem; -} - -.search-form mat-icon { - color: var(--primary-color); -} - -.empty-list { - text-align: center; - font-weight: 300; - font-size: 1.25rem; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; -} - -.pointer:hover { - color: var(--primary-color-3); -} - -::ng-deep .search-form .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -::ng-deep .sort-form .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} - -:host ::ng-deep .mat-paginator-container { - flex-direction: row-reverse !important; - justify-content: space-between !important; - background-color: #f6f6f6; - height: 30px; - min-height: 30px !important; -} - -:host ::ng-deep .mat-paginator-page-size { - height: 43px; -} - -:host ::ng-deep .mat-icon-button { - height: 30px !important; - font-size: 12px !important; -} - -:host ::ng-deep .mat-paginator-range-label { - margin: 15px 32px 0 24px !important; -} - -:host ::ng-deep .mat-paginator-range-actions { - width: auto !important; - min-width: 55% !important; - min-height: 43px !important; - justify-content: space-between; -} - -:host ::ng-deep .mat-paginator-navigation-previous { - margin-left: auto !important; -} - -::ng-deep .mat-ripple-element { - background-color: #2e74b649 !important; -} - -::ng-deep .mat-radio-container { - border-radius: 1em; - background: white; -} - -::ng-deep .mat-radio-button .mat-radio-outer-circle { - border: 1px solid #aaaaaa; -} - -::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle { - border-color: #777777; - // border-color: var(--primary-color-3); -} - -::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle { - // color: var(--primary-color-3); - // background-color: var(--primary-color-3); - color: #777777; - background-color: #777777; -} - -.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { - background-color: #2e74b649; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts deleted file mode 100644 index cea9fb961..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts +++ /dev/null @@ -1,446 +0,0 @@ - -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatPaginator } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { DatasetCriteriaComponent } from '@app/ui/dataset/listing/criteria/dataset-criteria.component'; -import { StartNewDatasetDialogComponent } from '@app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component'; -import { StartNewDmpDialogComponent } from '@app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { debounceTime, takeUntil } from 'rxjs/operators'; -import { DatasetWizardEditorModel, ExternalTagEditorModel } from '../dataset-wizard/dataset-wizard-editor.model'; -import { DatasetCriteriaDialogComponent } from './criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component'; - -@Component({ - selector: 'app-dataset-listing-component', - templateUrl: 'dataset-listing.component.html', - styleUrls: ['./dataset-listing.component.scss'] -}) -export class DatasetListingComponent extends BaseComponent implements OnInit {//IBreadCrumbComponent - - @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - // @ViewChild(DatasetCriteriaComponent, { static: true }) criteria: DatasetCriteriaComponent; - - // breadCrumbs: Observable; - - titlePrefix: String; - dmpId: string; - status: Number; - totalCount: number; - dmpSearchEnabled = true; - listingItems: DatasetListingModel[] = []; - hasListingItems = null; - - isPublic: boolean = false; - public isVisible = true - - startIndex: number = 0; - pageSize: number = 5; - criteria: DatasetCriteria; - criteriaFormGroup: UntypedFormGroup; - public formGroup = new UntypedFormBuilder().group({ - like: new UntypedFormControl(), - order: new UntypedFormControl() - }); - - scrollbar: boolean; - order = RecentActivityOrder; - dmpText: string; - datasetText: string; - - constructor( - private datasetService: DatasetService, - private router: Router, - private route: ActivatedRoute, - public dialog: MatDialog, - private dmpService: DmpService, - private language: TranslateService, - private authService: AuthService, - public enumUtils: EnumUtils, - private authentication: AuthService, - private guidedTourService: GuidedTourService, - private httpClient: HttpClient, - private matomoService: MatomoService - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Datasets'); - this.isPublic = this.router.url === '/explore-descriptions'; - if (this.isPublic) { - this.formGroup.get('order').setValue(this.order.DATASETPUBLISHED); - } else { - this.formGroup.get('order').setValue(this.order.MODIFIED); - } - if (!this.isPublic && !this.authService.currentAccountIsAuthenticated()) { - this.router.navigateByUrl("/explore"); - } - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe(async (params: Params) => { - const queryParams = this.route.snapshot.queryParams; - this.dmpId = queryParams['dmpId']; - this.status = queryParams['status']; - // Makes multiple post requests - // this.criteria.setRefreshCallback(() => this.refresh()); - if (this.dmpId != null) { - this.dmpSearchEnabled = false; - const dmp = await this.dmpService.getSingle(this.dmpId).toPromise(); - this.criteria = this.getDefaultCriteria(dmp); - // this.criteria.setCriteria(this.getDefaultCriteria(dmp)); - this.refresh(); - // this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); - // this.breadCrumbs = observableOf([{ - // parentComponentName: 'DmpEditorComponent', - // label: dmp.label, - // url: '/plans/edit/' + this.dmpId - // }]); - if (params['dmpLabel'] !== undefined) { - this.titlePrefix = 'for ' + params['dmpLabel']; - } - } else { - this.criteria = this.getDefaultCriteria(); - // this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - // this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); - // this.breadCrumbs = observableOf([{ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: this.isPublic ? "/explore" : "/datasets" - // }]); - } - - if (this.status != null && this.status == DatasetStatus.Draft) { - this.criteria = this.getDraftCriteria(); - // this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); - this.refresh(); - } - }); - - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.controlModified()); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); - } - - ngAfterContentChecked(): void { - this.scrollbar = this.hasScrollbar(); - } - - public dashboardTour: GuidedTour = { - tourId: 'dmp-dataset-tour', - useOrb: true, - steps: [ - { - selector: '.dmp-tour', - content: 'Step 1', - orientation: Orientation.Right, - isStepUnique: false - }, - { - selector: '.dataset-tour', - content: 'Step 2', - orientation: Orientation.Right, - isStepUnique: false - } - ] - }; - - public isAuthenticated(): boolean { - return this.authService.currentAccountIsAuthenticated(); - } - - controlModified(): void { - // this.clearErrorModel(); - // if (this.refreshCallback != null && - // (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) - // ) { - // setTimeout(() => this.refreshCallback(true)); - // } - this.criteria.like = this.formGroup.get("like").value; - this.startIndex = 0; - this.refresh(); - } - - refresh(resetPages = false) { - // if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10; - // if (resetPages) this._paginator.pageIndex = 0; - // const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - // let fields: Array = new Array(); - // fields.push('-modified'); - //if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const request = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }); - this.criteria.isPublic = this.isPublic; - request.criteria = this.criteria; - - this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - // if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.totalCount = result.totalCount; - this.listingItems = result.data; - this.hasListingItems = true; - }); - } - - public loadMore() { - this.startIndex = this.startIndex + this.pageSize; - // const fields: Array = ["-modified"]; - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const request = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }); - this.criteria.isPublic = this.isPublic; - request.criteria = this.criteria; - - this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - // if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - // this.listingItems = this.listingItems.concat(result.data); - this.listingItems = this.listingItems.length > 0 ? this.mergeTwoSortedLists(this.listingItems, result.data, this.formGroup.get('order').value) : result.data; - this.hasListingItems = true; - }); - } - - pageThisEvent(event) { - this.refresh(); - } - - getDefaultCriteria(dmp: any = null): DatasetCriteria { - const defaultCriteria = new DatasetCriteria(); - if (dmp != null) { - defaultCriteria.dmpIds.push(dmp); - } - return defaultCriteria; - } - - getDraftCriteria(): DatasetCriteria { - const draftCriteria = new DatasetCriteria(); - draftCriteria.status = DatasetStatus.Draft; - return draftCriteria; - } - - makeItPublic(id: String) { - this.datasetService.makeDatasetPublic(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(); - } - - openFiltersDialog(): void { - const dialogRef = this.dialog.open(DatasetCriteriaDialogComponent, { - width: '456px', - height: '100%', - id: 'filters', - restoreFocus: false, - data: { - isPublic: this.isPublic, - status: this.status, - criteria: this.criteria, - formGroup: this.criteriaFormGroup, - // criteria: this.grantId ? this.criteria : this.getDefaultCriteria(), - updateDataFn: this.updateDataFn.bind(this) - }, - position: { right: '0px;' }, - panelClass: 'dialog-side-panel' - }); - - dialogRef.afterClosed().subscribe(result => { - }); - } - - updateDataFn(criteria: DatasetCriteriaComponent): void { - this.criteriaFormGroup = criteria.formGroup; - this.toDatasetCriteria(criteria); - this.refresh(); - } - - toDatasetCriteria(criteria: DatasetCriteriaComponent) { - let formGroup = criteria.formGroup; - this.criteria = { - like: formGroup.get("like").value, - status: formGroup.get("status").value, - allVersions: formGroup.get("allVersions").value, - role: formGroup.get("role").value - } - if (formGroup.get("tags") && formGroup.get("tags").value) { - this.criteria.tags = formGroup.get("tags").value.map(x => (x)); - } - if (formGroup.get("collaborators") && formGroup.get("collaborators").value) { - this.criteria.collaborators = formGroup.get("collaborators").value.map(x => x.id); - } - if (formGroup.get("dmpIds") && formGroup.get("dmpIds").value) { - this.criteria.dmpIds = formGroup.get("dmpIds").value.map(x => x.id); - } - if (formGroup.get("groupIds") && formGroup.get("groupIds").value) { - this.criteria.groupIds = formGroup.get("groupIds").value.map(x => x.groupId); - } - if (formGroup.get("grants") && formGroup.get("grants").value) { - this.criteria.grants = formGroup.get("grants").value.map(x => x.id); - } - if (formGroup.get("organisations") && formGroup.get("organisations").value) { - this.criteria.organisations = formGroup.get("organisations").value.map(x => x.id); - } - if (formGroup.get("datasetTemplates") && formGroup.get("datasetTemplates").value) { - this.criteria.datasetTemplates = formGroup.get("datasetTemplates").value.map(x => x.id) - } - if (formGroup.get("grantStatus") && formGroup.get("grantStatus").value) { - this.criteria.grantStatus = formGroup.get("grantStatus").value; - } - this.criteria.isPublic = this.isPublic; - // if (this.itemId) { - // // this.criteria.groupIds = [this.itemId]; - // this.criteria.allVersions = true; - // } - } - - public closeCard(): void { - this.isVisible = false; - } - - hasScrollbar(): boolean { - return document.getElementById("main-page").scrollHeight > document.documentElement.clientHeight - } - - private mergeTwoSortedLists(arr1: DatasetListingModel[], arr2: DatasetListingModel[], order: string): DatasetListingModel[] { - let merged = []; - let index1 = 0; - let index2 = 0; - let current = 0; - - while (current < (arr1.length + arr2.length)) { - - let isArr1Depleted = index1 >= arr1.length; - let isArr2Depleted = index2 >= arr2.length; - - if (order === 'modified') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].modified) > new Date(arr2[index2].modified)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'created') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].created) > new Date(arr2[index2].created)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'label') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].label.localeCompare(arr2[index2].label)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'status') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].status < arr2[index2].status))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'dmp:publishedAt|join|') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].dmpPublishedAt) > new Date(arr2[index2].dmpPublishedAt)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } - current++; - } - return merged; - } - - public setDashboardTourDmpText(): void { - this.dmpText = this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' + - this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' + - this.language.instant('DMP-LISTING.LINK-ZENODO') + ' ' + - this.language.instant('DMP-LISTING.GET-IDEA'); - this.dashboardTour.steps[0].title = this.dmpText; - } - - public setDashboardTourDatasetText(): void { - this.datasetText = this.language.instant('DATASET-LISTING.TEXT-INFO') + - this.language.instant('DATASET-LISTING.LINK-PUBLIC-DATASETS') + ' ' + - this.language.instant('DATASET-LISTING.TEXT-INFO-REST') + '\n\n' + - this.language.instant('DATASET-LISTING.TEXT-INFO-PAR'); - this.dashboardTour.steps[1].title = this.datasetText; - } - - public restartTour(): void { - this.setDashboardTourDmpText(); - this.setDashboardTourDatasetText(); - this.guidedTourService.startTour(this.dashboardTour); - } - - openNewDmpDialog() { - if (this.dialog.openDialogs.length > 0) { - this.dialog.closeAll(); - } - else { - const dialogRef = this.dialog.open(StartNewDmpDialogComponent, { - disableClose: false, - data: { - isDialog: true - } - }); - } - } - - addNewDataset() { - const dialogRef = this.dialog.open(StartNewDatasetDialogComponent, { - disableClose: false, - restoreFocus: false, - data: { - startNewDmp: false, - formGroup: new DatasetWizardEditorModel().buildForm() - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (result.startNewDmp) { - this.openNewDmpDialog(); - } else { - this.router.navigate(['/plans', 'edit', result.formGroup.get('dmp').value.id]); - } - } - }); - } - - hasLikeCriteria(): boolean { - return this.criteria.like !== undefined && this.criteria.like !== null; - } - - // rowClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/datasets/edit/' + dataset.id]); - // } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html deleted file mode 100644 index fe2eebae2..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss deleted file mode 100644 index 20b421820..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss +++ /dev/null @@ -1,261 +0,0 @@ -.gray-container { - letter-spacing: 5px; - color: #aaaaaa; -} - -.container-header { - display: flex; - align-items: baseline; - margin-top: 0px; - text-transform: uppercase; -} - -.container-header p { - letter-spacing: 5px; - color: #aaaaaa; - padding-top: 10px; - margin-bottom: 0px; -} - -.container-header :hover { - color: var(--primary-color-3); -} - -h4 { - display: inline; - padding-left: 1em; - color: #333333; -} - -h4 > span { - text-transform: uppercase; -} - -.title h4 { - padding-left: 30px; - line-height: 2em; -} - -.about-item { - display: flex; - flex-wrap: wrap; -} - -.links :hover { - color: var(--primary-color-3); -} - -.about-item .length { - color: var(--primary-color-3); -} - -.about-item .title { - margin: 2px 10px; - // text-transform: uppercase; -} - -.about-item p { - margin-left: auto; - margin-bottom: 0px; - padding-top: 7px; - color: #aaaaaa; -} - -p { - color: #333333; -} - -.storage :hover { - color: var(--primary-color-3); -} - -.draft-bookmark { - color: #e7e6e6; -} - -.finalized-bookmark { - color: #08bd63; -} - -.dmp-card, -.dataset-card { - min-width: 712px; - /* min-height: 308px; */ - background: #ffffff 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #0000001a; - border-radius: 4px; - opacity: 1; - margin-top: 2.43rem; - margin-bottom: 1rem; -} - -.remove-border-bottom ::ng-deep .mat-tab-header { - border-bottom: none; -} - -input[type="text"] { - background: #fafafa 0% 0% no-repeat padding-box; - border: 1px solid #d1d1d1; - border-radius: 4px; - opacity: 1; - width: 347px; - height: 56px; - font-family: Arial, FontAwesome; - padding-left: 15px; -} - -.edited-date { - text-align: left; - font-weight: 300; - font-family: "Roboto", sans-serif; - line-height: 2.4; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; -} - -.dmp-label { - background: var(--primary-color) 0% 0% no-repeat padding-box; - border-radius: 4px 0px; - opacity: 1; - min-width: 67px; - height: 37px; - color: #ffffff; - line-height: 2.4; -} - -.dataset-label { - width: auto; - height: 37px; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - border-radius: 4px 0px; - text-align: left; - line-height: 2.8; - font-size: 0.875rem; - font-weight: 400; - letter-spacing: 0px; - color: #212121; -} - -.dmp-title, -.dataset-title { - text-align: left; - font-weight: 600; - font-family: "Roboto", sans-serif; - font-size: 1rem; - // opacity: 0.81; - padding-top: 0.75rem; - padding-bottom: 0.55rem; - color: #212121; -} - -.dataset-subtitle, -.dmp-subtitle { - display: flex; - flex-direction: row; - text-align: left; - font-weight: 400; - font-family: "Roboto", sans-serif; - font-size: 0.875rem; - opacity: 1; - align-items: center; - color: #848484; -} - -.dmp-title-draft, -.dataset-title-draft { - text-align: left; - font-weight: 600; - font-family: "Roboto", sans-serif; - font-size: 1rem; - // opacity: 0.81; - padding-top: 0.75rem; - padding-bottom: 0.55rem; - color: #f16868; -} - -.icon-align { - display: inline-flex; - vertical-align: middle; - // line-height: .9em; - // padding-bottom: 0.4rem; -} - -.dmp-subtitle, -.dataset-subtitle { - - .icon-align { - display: inline-flex; - vertical-align: top; - margin-right: .2rem; - line-height: .95em; - } -} - -.dataset-card-actions, -.dmp-card-actions { - display: flex; - flex-direction: row; - border-top: 1px solid #dbdbdb; - line-height: 4; - color: #848484; -} - -.dataset-card-actions a, -.dmp-card-actions a { - color: #848484 !important; - text-decoration: none !important; -} - -.dataset-card-actions a:hover, -.dmp-card-actions a:hover { - color: var(--primary-color) !important; -} - -.dmp-dataset-descriptions-title { - color: #000000; - opacity: 0.6; - padding-top: 1.5rem; - padding-bottom: 0.8rem; -} - -.dmp-dataset-descriptions-name { - color: #000000; - opacity: 0.6; - font-weight: 700; -} - -.show-more { - color: black !important; -} - -.show-more:hover { - color: var(--primary-color) !important; -} - -.btn-load-more { - border: 2px solid #212121; - border-radius: 30px; - opacity: 1; - min-width: 132px; - width: auto; - height: 40px; - margin-top: 4.125rem; -} - -.btn-load-more:hover { - background-color: black; - color: white; -} - -.draft { - color: #f16868; -} - -.pointer { - cursor: pointer; -} - -::ng-deep .mat-menu-panel { - max-width: 282px !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts deleted file mode 100644 index 2b3aded48..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts +++ /dev/null @@ -1,294 +0,0 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { Role } from '@app/core/common/enum/role'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.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 { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { takeUntil } from 'rxjs/operators'; -import { DatasetStatus } from '../../../../core/common/enum/dataset-status'; -import { DatasetListingModel } from '../../../../core/model/dataset/dataset-listing'; -import { DatasetCopyDialogueComponent } from '../../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { Guid } from '@common/types/guid'; - -@Component({ - selector: 'app-dataset-listing-item-component', - templateUrl: './dataset-listing-item.component.html', - styleUrls: ['./dataset-listing-item.component.scss'] -}) -export class DatasetListingItemComponent extends BaseComponent implements OnInit { - - @Input() dataset: DatasetListingModel; - @Input() showDivider: boolean = true; - @Input() isPublic: boolean = false; - @Output() onClick: EventEmitter = new EventEmitter(); - - isDraft: boolean; - isDeleted: boolean; - isUserOwner: boolean; - - constructor( - private router: Router, - public enumUtils: EnumUtils, - private datasetWizardService: DatasetWizardService, - public dialog: MatDialog, - private language: TranslateService, - private authentication: AuthService, - private uiNotificationService: UiNotificationService, - private lockService: LockService, - private location: Location, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Listing Item'); - if (this.dataset.status === DatasetStatus.Draft) { - this.isDraft = true; - this.isDeleted = false; - this.setIsUserOwner(); - } else if (this.dataset.status === DatasetStatus.Deleted) { - this.isDeleted = true; - } - else { - this.isDraft = false; - this.isDeleted = false; - this.setIsUserOwner(); - } - } - - setIsUserOwner() { - if (this.dataset) { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) this.isUserOwner = !!this.dataset.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - getItemLink(): string[] { - // return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`]; - return this.isPublic ? ['/datasets/publicOverview/' + this.dataset.id] : ['/datasets/overview/' + this.dataset.id]; - } - - getDmpLink(): string[] { - return this.isPublic ? [`/explore-plans/publicOverview/${this.dataset.dmpId}`] : [`/plans/edit/${this.dataset.dmpId}`]; - } - - downloadPDF(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadPDF(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", dataset.id); - }); - } - - downloadDOCX(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadDOCX(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", dataset.id); - }); - - } - - downloadXML(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadXML(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", dataset.id); - }); - } - - openShareDialog(dmpRowId: any, dmpRowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: dmpRowId, - dmpName: dmpRowName - } - }); - } - - openDmpSearchDialogue(dataset: DatasetListingModel) { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: dataset.id, - datasetProfileId: dataset.profile.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]); - // window.open(url.toString(), '_blank'); - } - }); - } - - deleteClicked(id: string) { - this.lockService.checkLockStatus(Guid.parse(id)).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDialog(id); - } else { - this.openLockedByUserDialog(); - } - }); - } - - openDeleteDialog(id: string): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK') - } - }); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { - this.router.navigate([path]); - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onCallbackSuccess(id?: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']); - } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.language.instant('DMP-LISTING.OWNER'); - } - else if (role === 1) { - return this.language.instant('DMP-LISTING.MEMBER'); - } - else { - return this.language.instant('DMP-LISTING.OWNER'); - } - } - - isUserDatasetRelated() { - const principalId: string = this.authentication.userId()?.toString(); - let isRelated: boolean = false; - if (this.dataset && principalId) { - this.dataset.users.forEach(element => { - if (element.id === principalId) { - isRelated = true; - } - }) - } - return isRelated; - } - - - - // onCallbackError(error: any) { - // this.setErrorModel(error.error); - // } - - // public setErrorModel(validationErrorModel: ValidationErrorModel) { - // Object.keys(validationErrorModel).forEach(item => { - // (this.dataset.validationErrorModel)[item] = (validationErrorModel)[item]; - // }); - // } - - // grantClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/grants/edit/' + dataset.grantId]); - // } - - // itemClicked() { - // this.onClick.emit(this.dataset); - // } - - // datasetClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/plans/edit/' + dataset.dmpId]) - // } - -} diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html deleted file mode 100644 index 92c068c65..000000000 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html +++ /dev/null @@ -1,186 +0,0 @@ -
-
-
- - chevron_left -

{{'DMP-WIZARD.ACTIONS.BACK' | translate}}

-
-
-
-
- -

{{ dataset.label }}

-
-
-
-

- {{ roleDisplayFromList(dataset.users) }} -

-
- . - - -
- public - {{'DMP-OVERVIEW.PUBLIC' | translate}} -
- . - - -
- lock_outline - {{'DMP-OVERVIEW.LOCKED' | translate}} -
- . -
{{'GENERAL.STATUSES.EDIT' | translate}} : - - {{dataset.modified | dateTimeCultureFormatter: "d MMMM y"}} -
-
-
- check - {{'TYPES.DATASET-STATUS.FINALISED' | translate}} -
-
-
-
- - - -
-
{{'DATASET-LISTING.TOOLTIP.PART-OF' | translate}}
-
- -
- -
-
{{'DMP-OVERVIEW.GRANT' | translate}}
-
{{ dataset.grant.label }}
-
- -
{{'DMP-OVERVIEW.RESEARCHERS' | translate}}
-
-
- - -
 
-
{{ researcher.name }},
-
{{ researcher.name }}
-
-
- -
{{ researcher.name }},
-
{{ researcher.name }}
-
-
- horizontal_rule -
- -
{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}
-
-

-
-
- horizontal_rule -
-
-
-
-
-
- -

{{ 'DMP-LISTING.ACTIONS.FINALIZE' | translate }}

-
-
-
-
-
-
- -

{{ 'DATASET-WIZARD.ACTIONS.REVERSE' | translate }}

-
-
- -

- {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}

-
- - - - - - - - -
-
-
-

{{ 'DATASET-OVERVIEW.DESCRIPTION-AUTHORS' | translate }}

-
-
-
-
- -
-

{{ user.name }} - - ({{ 'DMP-OVERVIEW.YOU' | translate }}) -

-

{{ roleDisplay(user) }}

-
-
- -
-
-
- -
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss deleted file mode 100644 index 4d5c9c4c6..000000000 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss +++ /dev/null @@ -1,301 +0,0 @@ -.container-fluid { - margin: 2em 4em; - padding: 2em; -} - -.dataset-overview { - // margin-top: 5rem; -} - -// ********ICONS******** - -.back-icon { - opacity: 0.4; -} - -.mat-mini-fab { - width: 2.5em; - height: 2.5em; - color: #212121; - background-color: var(--secondary-color); -} - -.mat-mini-fab-icon, -.status-icon { - font-size: 1.2em; -} - -.actions-btn:hover, -.finalize-btn:hover { - background-color: var(--primary-color); - color: #ffffff; -} - -.status-icon { - color: #a7a7a7; -} - -.check-icon { - font-weight: bold; -} - -.account-icon { - font-size: 2.5em; -} - -// ********BUTTONS******** - -.version-btn { - // width: 6.7em; - height: 1.8em; - border: 1px solid #707070; - border-radius: 4px; - background-color: transparent; -} - -.id-btn { - background: url("../../../../assets/images/NoPath.png") no-repeat center; - width: 1em; - margin-right: 0.3em; - align-self: center; -} - -.dmp-btn { - width: 35em; - min-height: 2.3em; - background-color: var(--primary-color); - border-radius: 4px; - flex-direction: row; - justify-content: space-between; - border: none; -} - -.dmp-btn, -.dmp-btn > mat-icon { - color: #ffffff; - // opacity: 0.8; -} - -.show-more-btn { - width: 31.6em; - padding: 0 1em; - background-color: #ffffff00; - color: var(--primary-color); - font-weight: 700; -} - -.frame-btn { - border: 1px solid #212121; - color: black; - background: #ffffff; -} - -.finalize-btn { - // border: 1px solid var(--secondary-color); - background: #f5db71; -} - -.frame-btn, -.finalize-btn { - box-shadow: 0px 2px 6px #00000029; -} - -.remove-btn { - border: none; - background-color: transparent; - font-size: 0.875em; - font-weight: bold; - margin-left: auto; -} - -.invite-btn { - width: 9.4em; - height: 2.9em; - background: #ffffff; - box-shadow: 0px 3px 6px #1e202029; - border: 2px solid #212121; - border-radius: 30px; -} - -.account_btn { - background: white; - color: #d5d5d5; - border: none; - height: 2.9em; -} - -// ********TEXT******** - -.dataset-logo { - width: 6em; - height: 2.6em; - background: var(--secondary-color); - border-radius: 4px; - font-size: 0.875em; - // color: #212121; - // color: black; - // opacity: 0.75; -} - -.label-txt { - font-size: 0.875em; -} - -.label2-txt { - font-size: 1em; -} - -.label-txt, -.label2-txt { - color: #848484; - font-weight: 400; -} - -.dataset-label { - font-weight: bold; - width: auto; -} - -.uppercase { - text-transform: uppercase; -} - -.researcher { - font-size: 0.875em; - color: var(--primary-color); - padding-right: 0.5em; - align-self: center; -} - -.header { - opacity: 0.6; - margin-top: 1em; - margin-bottom: 0.5em; -} - -.dataset-label, -.header { - font-size: 1.25em; - color: #212121; -} - -.desc-txt { - width: 48.25em; - font-size: 1em; - color: #212121; - margin-bottom: 1.875em; -} - -.dmp-btn-label { - margin-right: 1em; - overflow: hidden; - color: #ffffff; - opacity: 0.8; - text-align: left; -} - -.doi-label { - font-size: 1em; - color: #212121; - opacity: 0.6; - margin-bottom: 0.3em; -} - -.doi-txt { - font-size: 0.8em; - letter-spacing: 0.009em; - color: #7d7d7d; - width: 12em; - height: 1em; - overflow: hidden; - border: none; - padding: 0px; -} - -.doi-panel { - height: 3.5em; - background: #fafafa; - border: 1px solid #d1d1d1; - border-radius: 4px; - flex-direction: row; - justify-content: space-between; -} - -.doi-link { - color: white; -} - -.frame { - background: #ffffff; - box-shadow: 0px 1px 5px #00000026; - border-radius: 4px; - overflow: hidden; -} - -.frame-txt { - color: #000000; -} - -.frame-txt, -.finalize-txt { - font-size: 0.75em; - font-weight: bold; - letter-spacing: 0px; - text-transform: uppercase; - cursor: pointer; -} - -.hr-line { - border: 1px solid #dbdbdb; - // width: 274px; - // width: 17em; - width: 100%; -} - -.authors { - display: flex; - flex-direction: row; - justify-content: space-between; - width: 100%; -} - -.authors-label { - font-size: 0.875em; - color: #212121; - height: 1.4em; - margin-bottom: 0px; -} - -.authors-role { - font-size: 0.875em; - color: #a8a8a8; - height: 1.4em; - margin-bottom: 0px; -} - -// ********CENTER ELEMENTS******** - -.mat-mini-fab, -.mat-mini-fab-icon, -.actions-btn, -.status-icon, -.dataset-logo, -.frame-btn, -.finalize-btn { - display: flex; - justify-content: center; - align-items: center; -} - -.dataset-label, -.dmp-btn, -.doi-panel, -.researcher { - display: flex; - align-items: center; -} - -.show-more-btn { - display: flex; - justify-content: center; -} diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts deleted file mode 100644 index 5fcb6c281..000000000 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ /dev/null @@ -1,550 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview'; -import { BaseComponent } from '@common/base/base.component'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { UntypedFormControl } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { Role } from '@app/core/common/enum/role'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview'; -import { ResearcherModel } from '@app/core/model/researcher/researcher'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.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 { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { filter, takeUntil } from 'rxjs/operators'; -import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { Guid } from '@common/types/guid'; - - -@Component({ - selector: 'app-dataset-overview', - templateUrl: './dataset-overview.component.html', - styleUrls: ['./dataset-overview.component.scss'] -}) -export class DatasetOverviewComponent extends BaseComponent implements OnInit { - - dataset: DatasetOverviewModel; - // datasetWizardEditorModel: DatasetWizardEditorModel; - datasetWizardModel: DatasetWizardModel; - isNew = true; - isFinalized = false; - isPublicView = true; - hasPublishButton: boolean = true; - // breadCrumbs: Observable = observableOf(); - isUserOwner: boolean; - expand = false; - researchers: ResearcherModel[]; - users: UserInfoListingModel[]; - lockStatus: Boolean; - - constructor( - private route: ActivatedRoute, - private router: Router, - private datasetService: DatasetService, - private translate: TranslateService, - private authentication: AuthService, - private dialog: MatDialog, - private language: TranslateService, - private uiNotificationService: UiNotificationService, - private configurationService: ConfigurationService, - private oauth2DialogService: Oauth2DialogService, - private userService: UserServiceOld, - private dmpService: DmpService, - private location: Location, - private datasetWizardService: DatasetWizardService, - private lockService: LockService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Overview'); - // Gets dataset data using parameter id - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - const itemId = params['id']; - const publicId = params['publicId']; - if (itemId != null) { - this.isNew = false; - this.isPublicView = false; - this.datasetService.getOverviewSingle(itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dataset = data; - this.researchers = this.dataset.dmp.researchers; - this.users = this.dataset.dmp.users; - this.checkLockStatus(this.dataset.id); - this.setIsUserOwner(); - // const breadCrumbs = []; - // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" }); - // breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/overview/' + this.dataset.id }); - // this.breadCrumbs = observableOf(breadCrumbs); - }, (error: any) => { - if (error.status === 404) { - return this.onFetchingDeletedCallbackError('/datasets/'); - } - if (error.status === 403) { - return this.onFetchingForbiddenCallbackError('/datasets/'); - } - }); - } - else if (publicId != null) { - this.isNew = false; - this.isFinalized = true; - this.isPublicView = true; - this.datasetService.getOverviewSinglePublic(publicId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dataset = data; - this.researchers = this.dataset.dmp.researchers; - this.users = this.dataset.dmp.users; - // const breadCrumbs = []; - // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); - // breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/publicOverview/' + this.dataset.id }); - // this.breadCrumbs = observableOf(breadCrumbs); - }, (error: any) => { - if (error.status === 404) { - return this.onFetchingDeletedCallbackError('/explore'); - } - if (error.status === 403) { - return this.onFetchingForbiddenCallbackError('/explore'); - } - }); - } - }); - } - - checkLockStatus(id: string) { - this.lockService.checkLockStatus(Guid.parse(id)).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - this.lockStatus = lockStatus - if (lockStatus) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-OVERVIEW.LOCKED.TITLE'), - message: this.language.instant('DATASET-OVERVIEW.LOCKED.MESSAGE') - }, maxWidth: '30em' - }); - } - }); - } - - onFetchingDeletedCallbackError(redirectRoot: string) { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.DELETED-DATASET'), SnackBarNotificationLevel.Error); - this.router.navigate([redirectRoot]); - } - - onFetchingForbiddenCallbackError(redirectRoot: string) { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.FORBIDEN-DATASET'), SnackBarNotificationLevel.Error); - this.router.navigate([redirectRoot]); - } - - goBack(): void { - this.location.back(); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path])); - } - - setIsUserOwner() { - if (this.dataset) { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) this.isUserOwner = !!this.dataset.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - } - - isUserAuthor(userId: string): boolean { - if (this.isAuthenticated()) { - const principalId: string = this.authentication.userId()?.toString(); - return userId === principalId; - } else return false; - } - - isUserDatasetRelated() { - const principalId: string = this.authentication.userId()?.toString(); - let isRelated: boolean = false; - if (this.dataset && principalId) { - this.dataset.users.forEach(element => { - if (element.id === principalId) { - isRelated = true; - } - }) - } - return isRelated; - } - - roleDisplay(value: UserInfoListingModel) { - if (value.role === Role.Owner) { - return this.translate.instant('DMP-LISTING.OWNER'); - } else if (value.role === Role.Member) { - return this.translate.instant('DMP-LISTING.MEMBER'); - } else { - return this.translate.instant('DMP-LISTING.OWNER'); - } - } - - - roleDisplayFromList(value: UserInfoListingModel[]) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === Role.Owner) { - return this.translate.instant('DMP-LISTING.OWNER'); - } else if (role === Role.Member) { - return this.translate.instant('DMP-LISTING.MEMBER'); - } else { - return this.translate.instant('DMP-LISTING.OWNER'); - } - } - - openShareDialog(rowId: any, rowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - autoFocus: false, - restoreFocus: false, - data: { - dmpId: rowId, - dmpName: rowName - } - }); - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - isDraftDataset(dataset: DatasetOverviewModel) { - return dataset.status == DatasetStatus.Draft; - } - - isFinalizedDataset(dataset: DatasetOverviewModel) { - return dataset.status == DatasetStatus.Finalized; - } - - editClicked(dataset: DatasetOverviewModel) { - if (dataset.public) { - this.router.navigate(['/datasets/publicEdit/', dataset.id]); - // let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id]); - // window.open(url.toString(), '_blank'); - } else { - this.router.navigate(['/datasets/edit/', dataset.id]); - // let url = this.router.createUrlTree(['/datasets/edit/', dataset.id]); - // let url = this.router.createUrlTree(['/plans/edit/', dataset.dmp.id], { queryParams: { dataset: dataset.id } }); - // window.open(url.toString(), '_blank'); - } - } - - deleteClicked() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetService.delete(this.dataset.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onDeleteCallbackSuccess(); - }, - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - dmpClicked(dmp: DmpOverviewModel) { - if (this.isPublicView) { - this.router.navigate(['/explore-plans/publicOverview/' + dmp.id]); - } else { - this.router.navigate(['/plans/overview/' + dmp.id]); - } - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/datasets']); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onUpdateCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onUpdateCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.tryTranslate(error.error.message) : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); - } - tryTranslate(errorMessage: string): string { - return errorMessage.replace('Field value of', this.language.instant('Field value of')) - .replace('must be filled', this.language.instant('must be filled')); - } - - public getOrcidPath(): string { - return this.configurationService.orcidPath; - } - - isOrcid(reference: string) { - const head = reference.split(':')[0]; - return head === 'orcid'; - } - - getOrcidPathForResearcher(reference: string): string { - const path = this.getOrcidPath(); - const userId = reference.split(':')[1]; - return path + userId; - } - - downloadPDF(id: string) { - this.datasetService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", id); - }); - } - - downloadDocx(id: string) { - this.datasetService.downloadDocx(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", id); - }); - } - - downloadXml(id: string) { - this.datasetService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", id); - }); - } - - //GK: NO - // downloadJson(id: string) { - // this.datasetService.downloadJson(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(response => { - // const blob = new Blob([response.body], { type: 'application/json' }); - // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - // FileSaver.saveAs(blob, filename); - // }) - // } - - openDmpSearchDialogue() { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: this.dataset.id, - datasetProfileId: this.dataset.datasetTemplate.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]) - // window.open(url.toString(), '_blank') - } - }); - } - - updateUsers() { - return this.dmpService.updateUsers(this.dataset.dmp.id, this.users).pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onUpdateCallbackSuccess(); - }, - error => this.onUpdateCallbackError(error) - ); - } - - removeUserFromDmp(user: UserInfoListingModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-USER'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - const index = this.users.findIndex(x => x.id === user.id); - if (index > -1) { - this.users.splice(index, 1); - } - this.updateUsers(); - } - }); - } - - showPublishButton(dataset: DatasetOverviewModel) { - return this.isFinalizedDataset(dataset) && !dataset.public && this.hasPublishButton; - } - - // publish(id: String) { - // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - // maxWidth: '500px', - // restoreFocus: false, - // data: { - // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'), - // privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'), - // confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - // cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - // isDeleteConfirmation: false - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // this.datasetService.publish(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(() => { - // this.hasPublishButton = false; - // this.reloadPage(); - // }); - // } - // }); - // } - - finalize(dataset: DatasetOverviewModel) { - - - this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('DATASET-OVERVIEW.FINALISE-POPUP.MESSAGE'), - confirmButton: this.language.instant('DATASET-OVERVIEW.FINALISE-POPUP.CONFIRM'), - cancelButton: this.language.instant('DATASET-OVERVIEW.FINALISE-POPUP.CANCEL'), - }, - maxWidth: '30em' - }) - .afterClosed() - .pipe( - filter(x => x), - takeUntil(this._destroyed) - ) - .subscribe(_ => { - this.router.navigate(['datasets', 'edit', dataset.id, 'finalize']); - }) - - - - - - // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - // restoreFocus: false, - // data: { - // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), - // confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - // cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - // isDeleteConfirmation: false - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // this.datasetWizardService.getSingle(dataset.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(data => { - // this.datasetWizardModel = data; - // this.datasetWizardModel.status = DatasetStatus.Finalized; - // this.datasetWizardService.createDataset(this.datasetWizardModel) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // data => this.onUpdateCallbackSuccess(), - // error => this.onUpdateCallbackError(error) - // ); - // }); - // } - // }); - } - - hasReversableStatus(dataset: DatasetOverviewModel): boolean { - return dataset.dmp.status == DmpStatus.Draft && dataset.status == DatasetStatus.Finalized - } - - reverse(dataset: DatasetOverviewModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.getSingle(dataset.id) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.datasetWizardModel = data; - this.datasetWizardModel.status = DatasetStatus.Draft; - this.datasetWizardService.createDataset(this.datasetWizardModel) - .pipe(takeUntil(this._destroyed)) - .subscribe( - data => this.onUpdateCallbackSuccess(), - error => this.onUpdateCallbackError(error) - ); - }); - } - }); - } - -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html deleted file mode 100644 index c56c214e4..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html +++ /dev/null @@ -1,107 +0,0 @@ -
-
-

{{'DATASET-EDITOR.TITLE.INTRO' | translate}}

- {{'DATASET-EDITOR.TITLE.INTRO-TIP' | translate}} -
-
- -
-
-
1.1 {{'DATASET-EDITOR.FIELDS.TITLE' | translate}}*
- - -
- - - {{formGroup.get('label').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
- -
-
-
1.2 {{'DATASET-EDITOR.FIELDS.DESCRIPTION' | translate}}
- {{'DATASET-EDITOR.HINT.DESCRIPTION' | translate}} - -
- - -
- {{formGroup.get('description').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - - -
1.4 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
-
- - - -
- {{profile.label}} -
-
-
- {{formGroup.get('profile').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts deleted file mode 100644 index e9b339ad4..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { Router } from '@angular/router'; -import { BaseComponent } from '@common/base/base.component'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; -import { TranslateService } from '@ngx-translate/core'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { takeUntil } from 'rxjs/operators'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { MatDialog } from '@angular/material/dialog'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { Guid } from '@common/types/guid'; -import { nameof } from 'ts-simple-nameof'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; - -@Component({ - selector: 'app-dataset-editor-component', - templateUrl: 'dataset-editor.component.html', - styleUrls: ['./dataset-editor.component.scss'] -}) -export class DatasetEditorComponent extends BaseComponent { - - @Input() formGroup: UntypedFormGroup; - // @Input() formGroup: FormGroup = null; - @Input() availableProfiles: DatasetProfileModel[]; - @Input() dmpId: string; - showUri: boolean = false; - dmpText: string = null; - viewOnly = false; - - constructor( - private router: Router, - private dmpBlueprintService: DmpBlueprintService, - private dialog: MatDialog, - private guidedTourService: GuidedTourService, - private language: TranslateService - ) { super(); } - - public dashboardTourDmp: GuidedTour = { - tourId: 'only-dmp-tour', - useOrb: true, - steps: [ - { - title: this.dmpText, - content: 'Step 1', - orientation: Orientation.Bottom, - highlightPadding: 3, - isStepUnique: true, - customTopOffset: 8 - } - ] - }; - - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); - const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; - const blueprintId = this.formGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, - [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [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.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if(section.hasTemplates){ - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if(this.formGroup.get('dmp').value.datasets != null){ - for(let dataset of this.formGroup.get('dmp').value.datasets){ - if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ - count++; - } - } - if(count === foundTemplate.maxMultiplicity){ - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - } - else{ - this.formGroup.get('profile').setValue(profile); - } - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - }); - } - - getDmpText(): string { - return this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' + - this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' + - this.language.instant('DMP-LISTING.LINK-ZENODO') + ' ' + - this.language.instant('DMP-LISTING.GET-IDEA'); - } - - setDashboardTourDmp(label: string): void { - this.dashboardTourDmp.steps[0].title = this.getDmpText(); - this.dashboardTourDmp.steps[0].selector = '.dmp-tour-' + label; - } - - public restartTour(label: string): void { - this.setDashboardTourDmp(label); - this.guidedTourService.startTour(this.dashboardTourDmp); - - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - public compareWith(object1: any, object2: any) { - return object1 && object2 && object1.id === object2.id; - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html deleted file mode 100644 index 33a12bf33..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html +++ /dev/null @@ -1,150 +0,0 @@ -
-
-
- - -
-
-
-
-
- -
{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}}
-
{{'DMP-EDITOR.TITLE.EDIT-DESCRIPTION' | translate}}
-
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
- -
{{'DMP-EDITOR.TITLE.PREVIEW-DATASET' | translate}}
-
-
-
{{'DATASET-LISTING.TOOLTIP.TO-DMP' | translate}}
-
: {{ formGroup.get('dmp').value.label }}
- -
-
-
-
- - - - - - -
- - - -
- -
-
- - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
- chevron_left - {{'DATASET-WIZARD.ACTIONS.BACK-TO' | translate}} -
-
{{'DATASET-LISTING.TOOLTIP.DMP' | translate}}
-
-
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
-
-
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
-
-
- -
-
-
-
- - -
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
-
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
- -
-
- -
-
-
- - -
-
-
-
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts deleted file mode 100644 index 633ed936d..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; -import { Description, DescriptionField, DescriptionReference, DescriptionTag, PropertyDefinition } from '@app/core/model/description/description'; -import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; -import { Reference } from '@app/core/model/reference/reference'; -import { Tag } from '@app/core/model/tag/tag'; -import { DescriptionService } from '@app/core/services/description/description.service'; -import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; -import { BaseEditorResolver } from '@common/base/base-editor.resolver'; -import { Guid } from '@common/types/guid'; -import { takeUntil, tap } from 'rxjs/operators'; -import { nameof } from 'ts-simple-nameof'; - -@Injectable() -export class DescriptionEditorResolver extends BaseEditorResolver { - - constructor(private descriptionService: DescriptionService, private breadcrumbService: BreadcrumbService) { - super(); - } - - public static lookupFields(): string[] { - return [ - ...BaseEditorResolver.lookupFields(), - nameof(x => x.id), - nameof(x => x.label), - nameof(x => x.status), - nameof(x => x.description), - nameof(x => x.status), - [nameof(x => x.dmp), nameof(x => x.id)].join('.'), - - [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), - - [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), - - [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.key)].join('.'), - [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.value)].join('.'), - - [nameof(x => x.descriptionTags), nameof(x => x.id),].join('.'), - [nameof(x => x.descriptionTags), nameof(x => x.tag), nameof(x => x.label)].join('.'), - - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), - nameof(x => x.createdAt), - nameof(x => x.hash), - nameof(x => x.isActive) - ] - } - - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - - const fields = [ - ...DescriptionEditorResolver.lookupFields() - ]; - const id = route.paramMap.get('id'); - // const cloneid = route.paramMap.get('cloneid'); - if (id != null) { - return this.descriptionService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); - } - //TODO: check this - // else if (cloneid != null) { - // return this.descriptionService.clone(Guid.parse(cloneid), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); - // } - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.scss b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.scss deleted file mode 100644 index 5221d29c7..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.scss +++ /dev/null @@ -1,35 +0,0 @@ -.dataset-external-references-editor { - .heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-top: 1.625rem; - margin-bottom: 0.625rem; - } - - .hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 2.125rem; - } - - .external-item-card { - margin-bottom: 1em; - } -} - -::ng-deep .tags-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .tags-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.ts deleted file mode 100644 index cac88b15d..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalSourcesConfiguration } from '@app/core/model/external-sources/external-sources-configuration'; -import { DataRepositoryCriteria } from '@app/core/query/data-repository/data-repository-criteria'; -import { ExternalDatasetCriteria } from '@app/core/query/external-dataset/external-dataset-criteria'; -import { RegistryCriteria } from '@app/core/query/registry/registry-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { ServiceCriteria } from '@app/core/query/service/service-criteria'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { ExternalSourcesConfigurationService } from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { ExternalDataRepositoryEditorModel, ExternalDatasetEditorModel, ExternalRegistryEditorModel, ExternalServiceEditorModel, ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { DatasetExternalDataRepositoryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component'; -import { DatasetExternalDatasetDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component'; -import { DatasetExternalRegistryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component'; -import { DatasetExternalServiceDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable } from 'rxjs'; -import { takeUntil, map } from 'rxjs/operators'; -import { ENTER, COMMA } from '@angular/cdk/keycodes'; -import { MatChipInputEvent } from '@angular/material/chips'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service'; -import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service'; -import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; - -@Component({ - selector: 'app-dataset-external-references-editor-component', - templateUrl: 'dataset-external-references-editor.component.html', - styleUrls: ['./dataset-external-references-editor.component.scss'] -}) -export class DatasetExternalReferencesEditorComponent extends BaseComponent implements OnInit { - - @Input() formGroup: UntypedFormGroup = null; - @Input() viewOnly = false; - @Output() formChanged: EventEmitter = new EventEmitter(); - - public filteringTagsAsync = false; - public filteredTags: ExternalSourceItemModel[]; - - readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDatasets.bind(this), - initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => 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') - }; - - registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalRegistries.bind(this), - initialItems: (type) => this.searchDatasetExternalRegistries('', type), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => 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') - }; - - dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDataRepositories.bind(this), - initialItems: (type) => this.searchDatasetExternalDataRepositories('', type), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => 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') - }; - - servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalServices.bind(this), - initialItems: (type) => this.searchDatasetExternalServices('', type), - displayFn: (item) => item ? item.label : null, - titleFn: (item) => item ? item.label : null, - subtitleFn: (item) => 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') - }; - - tagsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => this.showTag(item), - titleFn: (item) => item['name'], - valueAssign: (item) => this.addTag(item) - }; - - externalSourcesConfiguration: ExternalSourcesConfiguration; - - // new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), - - constructor( - private dialog: MatDialog, - private router: Router, - private language: TranslateService, - private externalSourcesService: ExternalSourcesService, - private externalSourcesConfigurationService: ExternalSourcesConfigurationService, - private externalDataRepositoryService: ExternalDataRepositoryService, - private externalDatasetService: ExternalDatasetService, - private externalRegistryService: ExternalRegistryService, - private externalServiceService: ExternalServiceService, - ) { super(); } - - ngOnInit() { - - this.externalSourcesConfigurationService.getExternalSourcesConfiguration() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.externalSourcesConfiguration = result; - this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.services.push({ key: '', label: 'All' }); - if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) { - this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' }); - } else { - this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }]; - } - }); - - this.formGroup.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(val => { - this.formChanged.emit(val); - }); - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - externalDatasetsOnItemChange(event) { - const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.name, event.pid ? event.pid : event.reference, event.source); - (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - } - - registriesOnItemChange(event) { - const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.name, event.pid ? event.pid : event.reference, event.uri, event.source); - (this.formGroup.get('registries')).push(registryModel.buildForm()); - } - - servicesOnItemChange(event) { - const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri); - (this.formGroup.get('services')).push(serviceModel.buildForm()); - } - - tagsOnItemChange(event) { - const tagModel = new ExternalTagEditorModel(event.id, event.name); - (this.formGroup.get('tags')).push(tagModel.buildForm()); - } - - - dataRepositoriesOnItemChange(event) { - const dataRepositoryModel = new ExternalDataRepositoryEditorModel(event.id, event.name, event.abbreviation, event.uri, event.pid, event.source); - (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - } - - addDataRepository() { - const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source); - (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - }); - } - - addRegistry() { - const dialogRef = this.dialog.open(DatasetExternalRegistryDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - (this.formGroup.get('registries')).push(registryModel.buildForm()); - }); - } - - addExternalDataset() { - const dialogRef = this.dialog.open(DatasetExternalDatasetDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const externalDatasetModel = new ExternalDatasetEditorModel(result.id, result.abbreviation, result.name, result.reference, result.source); - (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - }); - } - - addService() { - const dialogRef = this.dialog.open(DatasetExternalServiceDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - (this.formGroup.get('services')).push(serviceModel.buildForm()); - }); - } - - searchDatasetExternalDatasets(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ExternalDatasetCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); - } - - searchDatasetExternalDataRepositories(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new DataRepositoryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetRepository(requestItem); - } - - searchDatasetExternalRegistries(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new RegistryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetRegistry(requestItem); - } - - searchDatasetExternalServices(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ServiceCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetService(requestItem); - } - - searchDatasetTags(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new TagCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - removeTag(tag: any) { - (this.formGroup.get('tags')).removeAt(((this.formGroup.get('tags')).value as any[]).indexOf(tag)); - } - - addTag(ev: any) { - let item: ExternalTagEditorModel; - //this.filteredTags = this.formGroup.get('tags').value; - if (typeof ev === 'string') { - item = new ExternalTagEditorModel('', ev); - } else { - item = ev; - } - if (item.name !== '' ) { - return item; - } - } - - isInternal(element: any): boolean { - if (element.get('source') == null) { - // console.log(element); - } - return element.get('source').value === 'Internal'; - } - - updateDataRepository(dataRepository: UntypedFormGroup) { - this.externalDataRepositoryService.create(dataRepository.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - dataRepository.setValue(result); - } - ); - } - - updateExternalDataset(externalDataset: UntypedFormGroup) { - this.externalDatasetService.create(externalDataset.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - externalDataset.setValue(result); - } - ); - } - - updateRegistry(registry: UntypedFormGroup) { - this.externalRegistryService.create(registry.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - registry.setValue(result); - } - ); - } - - updateService(service: UntypedFormGroup) { - this.externalServiceService.create(service.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - service.setValue(result); - } - ); - } - - filterTags(value: string): Observable { - this.filteringTagsAsync = true; - - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - showTag(ev: any) { - if (typeof ev === 'string') { - return ev; - } else { - return ev.name; - } - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html deleted file mode 100644 index 2367cc238..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts deleted file mode 100644 index 9c53aa709..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDataRepositoryEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: 'dataset-external-data-repository-dialog-editor.component.html', - styleUrls: ['./dataset-external-data-repository-dialog-editor.component.scss'] -}) -export class DatasetExternalDataRepositoryDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalDataRepositoryService: ExternalDataRepositoryService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const datarepo = new ExternalDataRepositoryEditorModel(); - this.formGroup = datarepo.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalDataRepositoryService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html deleted file mode 100644 index 530a33bd4..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts deleted file mode 100644 index 676181d56..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service'; -import { ExternalDatasetEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { FormService } from '@common/forms/form-service'; - -@Component({ - templateUrl: 'dataset-external-dataset-dialog-editor.component.html', - styleUrls: ['./dataset-external-dataset-dialog-editor.component.scss'] -}) -export class DatasetExternalDatasetDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalDatasetService: ExternalDatasetService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const externalDatasetModel = new ExternalDatasetEditorModel(); - this.formGroup = externalDatasetModel.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalDatasetService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html deleted file mode 100644 index 111e52fc6..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.REGISTRY.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts deleted file mode 100644 index 9179bdbc7..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service'; -import { ExternalRegistryEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: 'dataset-external-registry-dialog-editor.component.html', - styleUrls: ['./dataset-external-registry-dialog-editor.component.scss'] -}) -export class DatasetExternalRegistryDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalRegistryService: ExternalRegistryService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const registryModel = new ExternalRegistryEditorModel(); - this.formGroup = registryModel.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalRegistryService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html deleted file mode 100644 index 994c214e7..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.SERVICES.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts deleted file mode 100644 index 5da9f1b59..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service'; -import { ExternalServiceEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { FormService } from '@common/forms/form-service'; - -@Component({ - templateUrl: 'dataset-external-service-dialog-editor.component.html', - styleUrls: ['./dataset-external-service-dialog-editor.component.scss'] -}) -export class DatasetExternalServiceDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalServiceService: ExternalServiceService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const serviceModel = new ExternalServiceEditorModel(); - this.formGroup = serviceModel.buildForm(); - } - - send() { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalServiceService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.html deleted file mode 100644 index b6d159d7b..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.html +++ /dev/null @@ -1,57 +0,0 @@ -
-
- {{'DATASET-CREATE-WIZARD.PREFILL-STEP.TITLE' | translate}} - close -
-
- -
-
-
-
- {{'DATASET-CREATE-WIZARD.PREFILL-STEP.HINT' | translate}} -
-
-
- -
{{'DATASET-CREATE-WIZARD.PREFILL-STEP.OR' | translate}}
- -
-
-
-

{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE' | translate}}

-
- - - -
- {{profile.label}} -
-
-
- {{prefillForm.get('profile').getError('backendError').message}} -
-
-
-
-

{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILLED-DATASET' | translate}}

-
- - - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.scss b/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.scss deleted file mode 100644 index 7a892e68b..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.scss +++ /dev/null @@ -1,57 +0,0 @@ -.template-container { - .header { - display: flex; - width: 100%; - height: 60px; - background-color: var(--secondary-color); - color: #212121; - font-size: 1.25rem; - } - - .template-title { - margin-left: 37px; - white-space: nowrap; - width: 480px; - overflow: hidden; - text-overflow: ellipsis; - } - - .close-icon { - cursor: pointer; - margin-right: 20px; - } - - .close-icon:hover { - background-color: #fefefe6e !important; - border-radius: 50%; - } - - .definition-content { - display: block; - margin: 0; - padding: 25px; - } - - .empty-btn, .prefill-btn { - background: var(--secondary-color) 0 0 no-repeat padding-box; - border: 1px solid var(--secondary-color); - border-radius: 30px; - opacity: 1; - min-width: 101px; - height: 43px; - color: #212121; - font-weight: 500; - } - - .prefill-btn:disabled { - background: #a1a1a1 0 0 no-repeat padding-box; - border: 1px solid #a1a1a1; - opacity: 0.5; - } - - .empty-btn { - background: #ffffff 0 0 no-repeat padding-box; - border: 1px solid #a1a1a1; - } -} - diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.ts deleted file mode 100644 index 08bdc21d1..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.ts +++ /dev/null @@ -1,200 +0,0 @@ -import { Component, Inject, OnInit } from "@angular/core"; -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog"; -import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile"; -import { Prefilling } from "@app/core/model/dataset/prefilling"; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint"; -import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service"; -import { PrefillingService } from "@app/core/services/prefilling.service"; -import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service"; -import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration"; -import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component"; -import { BaseComponent } from "@common/base/base.component"; -import { Guid } from "@common/types/guid"; -import { TranslateService } from "@ngx-translate/core"; -import { Observable } from "rxjs"; -import { map, takeUntil } from "rxjs/operators"; -import { nameof } from "ts-simple-nameof"; - -@Component({ - selector: 'prefill-dataset-component', - templateUrl: 'prefill-dataset.component.html', - styleUrls: ['prefill-dataset.component.scss'] -}) -export class PrefillDatasetComponent extends BaseComponent implements OnInit { - - progressIndication = false; - prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - isPrefilled: boolean = false; - prefillForm: UntypedFormGroup; - - constructor(public dialogRef: MatDialogRef, - private prefillingService: PrefillingService, - private dmpBlueprintService: DmpBlueprintService, - private dialog: MatDialog, - private language: TranslateService, - private progressIndicationService: ProgressIndicationService, - private fb: UntypedFormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { - super(); - } - - ngOnInit() { - this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - setTimeout(() => { this.progressIndication = x; }); - }); - this.prefillForm = this.fb.group({ - type: this.fb.control(false), - profile: this.fb.control('', Validators.required), - prefill: this.fb.control(null, Validators.required) - }) - if (this.data.availableProfiles && this.data.availableProfiles.length === 1) { - this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]); - } - this.prefillAutoCompleteConfiguration = { - filterFn: this.searchDatasets.bind(this), - loadDataOnStart: false, - displayFn: (item) => (item['name'].length > 60) ? (item['name'].substr(0, 60) + "...") : item['name'], - titleFn: (item) => item['name'], - subtitleFn: (item) => item['pid'] - }; - } - - addProfileIfUsedLessThanMax(profile: DatasetProfileModel) { - const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value; - const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields()) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if (section.hasTemplates) { - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if (this.data.datasetFormGroup.get('dmp').value.datasets != null) { - for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) { - if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) { - count++; - } - } - if (count < foundTemplate.maxMultiplicity) { - this.prefillForm.get('profile').patchValue(profile); - } - } - } - else { - this.prefillForm.get('profile').patchValue(profile); - } - } - else { - this.prefillForm.get('profile').patchValue(profile); - } - }); - } - - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); - const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value; - const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields()) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if (section.hasTemplates) { - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if (this.data.datasetFormGroup.get('dmp').value.datasets != null) { - for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) { - if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) { - count++; - } - } - if (count === foundTemplate.maxMultiplicity) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - } - else { - this.prefillForm.get('profile').setValue(profile); - } - } - } - else { - this.prefillForm.get('profile').setValue(profile); - } - } - else { - this.prefillForm.get('profile').setValue(profile); - } - }); - } - - private getBlueprintDefinitionFields() { - return [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [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.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - } - - public compareWith(object1: any, object2: any) { - return object1 && object2 && object1.id === object2.id; - } - - searchDatasets(query: string): Observable { - return this.prefillingService.getPrefillingList(query).pipe(map(prefilling => prefilling.sort((a, b) => { - if (a.name > b.name) { - return 1; - } else if (a.name < b.name) { - return -1; - } else { - return 0; - } - }))); - } - - next() { - if (this.isPrefilled) { - if (this.prefillForm.get('prefill').value.data == null) { - this.prefillingService.getPrefillingDataset(this.prefillForm.get('prefill').value.pid, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => { - wizard.profile = this.prefillForm.get('profile').value; - this.closeDialog(wizard); - }); - } - else { - this.prefillingService.getPrefillingDatasetUsingData(this.prefillForm.get('prefill').value.data, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => { - wizard.profile = this.prefillForm.get('profile').value; - this.closeDialog(wizard); - }); - } - } else { - this.closeDialog(); - } - } - - closeDialog(result = null): void { - this.dialogRef.close(result); - } -} diff --git a/dmp-frontend/src/app/ui/description/description-copy-dialog/description-copy-dialog.component.ts b/dmp-frontend/src/app/ui/description/description-copy-dialog/description-copy-dialog.component.ts index e10134a84..5aa32b4bc 100644 --- a/dmp-frontend/src/app/ui/description/description-copy-dialog/description-copy-dialog.component.ts +++ b/dmp-frontend/src/app/ui/description/description-copy-dialog/description-copy-dialog.component.ts @@ -7,7 +7,7 @@ import { Inject } from "@angular/core"; import { TranslateService } from "@ngx-translate/core"; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { Dmp } from '@app/core/model/dmp/dmp'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { DescriptionService } from '@app/core/services/description/description.service'; import { DmpDescriptionTemplateLookup } from '@app/core/query/dmp-description-template.lookup'; import { IsActive } from '@app/core/common/enum/is-active.enum'; @@ -37,7 +37,7 @@ export class DescriptionCopyDialogComponent { constructor( public dialogRef: MatDialogRef, - public dmpService: DmpServiceNew, + public dmpService: DmpService, public descriptionService: DescriptionService, public language: TranslateService, @Inject(MAT_DIALOG_DATA) public data: any diff --git a/dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.html b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.html similarity index 100% rename from dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.html rename to dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.html diff --git a/dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.scss b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.scss rename to dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.scss diff --git a/dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.ts b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.ts rename to dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.ts diff --git a/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts new file mode 100644 index 000000000..30c165387 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DatasetPreviewDialogComponent } from './dataset-preview-dialog.component'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + FormattingModule, + ], + declarations: [ + DatasetPreviewDialogComponent, + ], + exports: [ + DatasetPreviewDialogComponent, + ] +}) +export class DatasetPreviewDialogModule { } diff --git a/dmp-frontend/src/app/ui/description/description.module.ts b/dmp-frontend/src/app/ui/description/description.module.ts index 6d15033b4..d24d8bab1 100644 --- a/dmp-frontend/src/app/ui/description/description.module.ts +++ b/dmp-frontend/src/app/ui/description/description.module.ts @@ -1,84 +1,19 @@ import { NgModule } from '@angular/core'; import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; -import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; -// import { DescriptionEditorComponent } from '@app/ui/description/description-wizard/description-editor/description-editor.component'; -// import { DescriptionWizardComponent } from '@app/ui/description/description-wizard/description-wizard.component'; -// import { DescriptionExternalReferencesEditorComponent } from '@app/ui/description/description-wizard/external-references/description-external-references-editor.component'; -// import { DescriptionExternalDataRepositoryDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/data-repository/description-external-data-repository-dialog-editor.component'; -// import { DescriptionExternalDescriptionDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/external-description/description-external-description-dialog-editor.component'; -// import { DescriptionExternalRegistryDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/registry/description-external-registry-dialog-editor.component'; -// import { DescriptionExternalServiceDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/service/description-external-service-dialog-editor.component'; -// import { PrefillDescriptionComponent } from "@app/ui/description/description-wizard/prefill-description/prefill-description.component"; import { DescriptionRoutingModule } from '@app/ui/description/description.routing'; -// import { DescriptionCriteriaComponent } from '@app/ui/description/listing/criteria/description-criteria.component'; -// import { DescriptionUploadDialogue } from '@app/ui/description/listing/criteria/description-upload-dialogue/description-upload-dialogue.component'; -import { DescriptionListingComponent } from '@app/ui/description/listing/description-listing.component'; -import { DescriptionListingItemComponent } from '@app/ui/description/listing/listing-item/description-listing-item.component'; -// import { DescriptionDescriptionFormModule } from '@app/ui/misc/description-description-form/description-description-form.module'; -// import { TableOfContentsModule } from '@app/ui/misc/description-description-form/tableOfContentsMaterial/table-of-contents.module'; -import { ExternalSourcesModule } from '@app/ui/misc/external-sources/external-sources.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; -import { DescriptionCopyDialogModule } from './description-copy-dialog/description-copy-dialog.module'; -import { DescriptionOverviewModule } from './overview/description-overview.module'; -import { DescriptionEditorComponent } from './dataset-wizard/description-editor.component'; -// import { FormProgressIndicationModule } from '../misc/description-description-form/components/form-progress-indication/form-progress-indication.module'; -// import { DescriptionCopyDialogModule } from './description-wizard/description-copy-dialogue/description-copy-dialogue.module'; -// import { DescriptionCriteriaDialogComponent } from './listing/criteria/description-criteria-dialogue/description-criteria-dialog.component'; -// import { DescriptionOverviewModule } from './overview/description-overview.module'; @NgModule({ imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, FormattingModule, - ConfirmationDialogModule, - AutoCompleteModule, - ExternalSourcesModule, - ExportMethodDialogModule, - // DescriptionDescriptionFormModule, - // TableOfContentsModule, - AngularStickyThingsModule, DescriptionRoutingModule, - FormValidationErrorsDialogModule, - // DescriptionCopyDialogModule, - // DescriptionOverviewModule, - // FormProgressIndicationModule, - RichTextEditorModule, - - DescriptionCopyDialogModule, - DescriptionOverviewModule, ], declarations: [ - DescriptionListingComponent, - // DescriptionCriteriaComponent, - // DescriptionWizardComponent, - DescriptionEditorComponent, - // DescriptionExternalReferencesEditorComponent, - // DescriptionExternalDataRepositoryDialogEditorComponent, - // DescriptionExternalDescriptionDialogEditorComponent, - // DescriptionExternalRegistryDialogEditorComponent, - // DescriptionExternalServiceDialogEditorComponent, - // DescriptionUploadDialogue, - DescriptionListingItemComponent, - // DescriptionCriteriaDialogComponent, - // PrefillDescriptionComponent ], exports: [ - // DescriptionExternalReferencesEditorComponent, - // DescriptionExternalDataRepositoryDialogEditorComponent, - // DescriptionExternalDescriptionDialogEditorComponent, - // DescriptionExternalRegistryDialogEditorComponent, - // DescriptionExternalServiceDialogEditorComponent, - // DescriptionEditorComponent, - // DescriptionDescriptionFormModule ] }) export class DescriptionModule { } diff --git a/dmp-frontend/src/app/ui/description/description.routing.ts b/dmp-frontend/src/app/ui/description/description.routing.ts index 08f511956..2b2b32dc9 100644 --- a/dmp-frontend/src/app/ui/description/description.routing.ts +++ b/dmp-frontend/src/app/ui/description/description.routing.ts @@ -1,136 +1,35 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AuthGuard } from '../../core/auth-guard.service'; // import { DescriptionWizardComponent } from './description-wizard/description-wizard.component'; -import { DescriptionListingComponent } from './listing/description-listing.component'; -import { DescriptionOverviewComponent } from './overview/description-overview.component'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; -import { DescriptionEditorComponent } from './dataset-wizard/description-editor.component'; -import { AppPermission } from '@app/core/common/enum/permission.enum'; -import { DescriptionEditorResolver } from './dataset-wizard/description-editor.resolver'; -import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; // import { DescriptionOverviewComponent } from './overview/description-overview.component'; -import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; const routes: Routes = [ { - path: '', - component: DescriptionListingComponent, - // canActivate: [AuthGuard], + path: 'overview', + loadChildren: () => import('./overview/description-overview.module').then(m => m.DescriptionOverviewModule), data: { breadcrumb: true - }, - }, - { - path: 'dmp/:dmpId', - component: DescriptionListingComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, - { - path: 'overview/:id', - component: DescriptionOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - }, - { - path: 'publicOverview/:publicId', - component: DescriptionOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - }, - { - path: 'edit/:id', - canActivate: [AuthGuard], - component: DescriptionEditorComponent, - canDeactivate: [PendingChangesGuard], - resolve: { - 'entity': DescriptionEditorResolver - }, - data: { - ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.EDIT-DESCRIPTION' - }), - authContext: { - permissions: [AppPermission.EditDescription] - } } }, - // { - // path: 'new/:dmpId/:dmpSectionIndex', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-NEW' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - - // { - // path: 'edit/:id/finalize', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // public: false, - // title: 'GENERAL.TITLES.DATASET-EDIT', - // finalize: true - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'publicEdit/:publicId', - // component: DescriptionWizardComponent, - // //canActivate: [AuthGuard], - // data: { - // public: true, - // title: 'GENERAL.TITLES.DATASET-PUBLIC-EDIT' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'new', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-NEW' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'copy/:id', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-COPY' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'profileupdate/:updateId', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-UPDATE' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - + { + path: 'edit', + loadChildren: () => import('./editor/description-editor.module').then(m => m.DescriptionEditorModule), + data: { + breadcrumb: true + } + }, + { + path: '', + loadChildren: () => import('./listing/description-listing.module').then(m => m.DescriptionListingModule), + data: { + breadcrumb: true + }, + }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule], - providers: [DescriptionEditorResolver] + providers: [] }) export class DescriptionRoutingModule { } diff --git a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html new file mode 100644 index 000000000..f5a0a48fc --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html @@ -0,0 +1,65 @@ +
+
+

{{'DESCRIPTION-EDITOR.BASE-INFO.INTRO' | translate}}

+ {{'DESCRIPTION-EDITOR.BASE-INFO.INTRO-TIP' | translate}} +
+
+ +
+
+
1.1 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.TITLE' | translate}}*
+
+ + + {{formGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+
+ +
+
+
1.2 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.DESCRIPTION' | translate}}
+ {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.DESCRIPTION-HINT' | translate}} +
+ + +
+ {{formGroup.get('description').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+
+
+
+ +
+
+
1.3 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.TAGS' | translate}}*
+
+ +
+
+
+ +
+
+
1.4 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.DESCRIPTION-TEMPLATE' | translate}}*
+
+ + + +
+ {{descriptionTemplate.label}} +
+
+
+ {{formGroup.get('descriptionTemplateId').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.scss similarity index 98% rename from dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.scss index b006bc845..76fe2f2df 100644 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.scss +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.scss @@ -1,4 +1,4 @@ -.dataset-editor { +.description-base-fields-editor { .intro { text-align: left; font-weight: 400; diff --git a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts new file mode 100644 index 000000000..af3fab1f2 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts @@ -0,0 +1,44 @@ +import { Component, Input } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { Description } from '@app/core/model/description/description'; +import { DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { Dmp } from '@app/core/model/dmp/dmp'; +import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; +import { DescriptionService } from '@app/core/services/description/description.service'; +import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; +import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from 'rxjs/operators'; + +@Component({ + selector: 'app-description-base-fields-editor-component', + templateUrl: 'description-base-fields-editor.component.html', + styleUrls: ['./description-base-fields-editor.component.scss'] +}) +export class DescriptionBaseFieldsEditorComponent extends BaseComponent { + + @Input() formGroup: UntypedFormGroup; + @Input() availableDescriptionTemplates: DescriptionTemplate[] = []; + @Input() description: Description; + viewOnly = false; //TODO: not used. + + constructor( + private dmpBlueprintService: DmpBlueprintService, + private descriptionTemplateService: DescriptionTemplateService, + ) { super(); } + + ngOnInit() { + const section: DmpBlueprintDefinitionSection = this.dmpBlueprintService.getSection(this.description.dmp.blueprint, this.description.dmpDescriptionTemplate.sectionId); + const descriptionTemplateIds = section ? section.descriptionTemplates.map(x => x.descriptionTemplateId) : []; + if (descriptionTemplateIds && descriptionTemplateIds.length > 0) { + this.descriptionTemplateService.query(this.descriptionTemplateService.buildAutocompleteLookup(null, null, descriptionTemplateIds)) + .pipe(takeUntil(this._destroyed)).subscribe(queryResult => { + this.availableDescriptionTemplates = queryResult.items; + }); + } + } + + public compareWith(object1: any, object2: any) { + return object1 && object2 && object1.id === object2.id; + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html new file mode 100644 index 000000000..e1bc4b90d --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html @@ -0,0 +1,142 @@ +
+
+
+ +
+
+
+
+
+ +
{{'DESCRIPTION-EDITOR.TITLE-ADD-DESCRIPTION' | translate}}
+
{{'DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION' | translate}}
+
{{ formGroup.get('label').value }} ({{'DESCRIPTION-EDITOR.CHANGES' | translate}})
+
+ +
{{'DESCRIPTION-EDITOR.TITLE-PREVIEW-DESCRIPTION' | translate}}
+
+
+
{{'DESCRIPTION-EDITOR.TO-DMP' | translate}}
+
: {{ item.dmp.label }}
+ +
+
+
+
+ + + + + + +
+ + + +
+ +
+
+ + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+ chevron_left + {{'DESCRIPTION-EDITOR.ACTIONS.BACK-TO' | translate}} +
+
{{'DESCRIPTION-EDITOR.DMP' | translate}}
+
+
{{'DESCRIPTION-EDITOR.TOC.TITLE' | translate}}
+
+
+
0. {{'DESCRIPTION-EDITOR.TOC.MAIN-INFO' | translate}} (2)
+
0. {{'DESCRIPTION-EDITOR.TOC.MAIN-INFO' | translate}} (done)
+
+
+ +
+
+
+
+ + +
+
{{'DESCRIPTION-EDITOR.TOC.NEXT' | translate}}
+ chevron_right +
+
+
{{'DESCRIPTION-EDITOR.TOC.NEXT' | translate}}
+ chevron_right +
+ +
+
+ +
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/description-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts similarity index 72% rename from dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 371c917b2..fca886fcc 100644 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -1,27 +1,10 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; +import { UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute, Params, Router } from '@angular/router'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { SaveType } from '@app/core/common/enum/save-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { LockModel } from '@app/core/model/lock/lock.model'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { - ExternalSourcesConfigurationService -} from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { @@ -29,37 +12,34 @@ import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; // import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { FormService } from '@common/forms/form-service'; -import { - FormValidationErrorsDialogComponent -} from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { Observable, interval, of as observableOf } from 'rxjs'; -import { catchError, debounceTime, filter, map, takeUntil } from 'rxjs/operators'; -import { DescriptionEditorService } from './description-editor.service'; -import { BaseEditor } from '@common/base/base-editor'; -import { DescriptionEditorModel } from './description-editor.model'; -import { Description, DescriptionPersist } from '@app/core/model/description/description'; +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 { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; -import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; -import { FilterService } from '@common/modules/text-filter/filter-service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { Description, DescriptionPersist } from '@app/core/model/description/description'; import { DescriptionService } from '@app/core/services/description/description.service'; import { LoggingService } from '@app/core/services/logging/logging-service'; +import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; +import { BaseEditor } from '@common/base/base-editor'; +import { FormService } from '@common/forms/form-service'; +import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; +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 { DescriptionEditorModel } from './description-editor.model'; import { DescriptionEditorResolver } from './description-editor.resolver'; -import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DatePipe } from '@angular/common'; +import { DescriptionEditorService } from './description-editor.service'; +import { ToCEntry } from './table-of-contents/models/toc-entry'; +import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component'; +import { ToCEntryType } from './table-of-contents/models/toc-entry-type.enum'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; @Component({ selector: 'app-description-editor-component', @@ -71,7 +51,7 @@ export class DescriptionEditorComponent extends BaseEditor = []; // DescriptionSectionFieldCategory = DescriptionSectionFieldCategory; @@ -89,6 +69,14 @@ export class DescriptionEditorComponent extends BaseEditor { + const isPublicDescription = params['public']; + const itemId = params['id']; + const newDmpId = params['newDmpId']; + // const publicId = params['publicId']; + // this.dmpId = params['dmpId']; + // this.dmpSectionIndex = parseInt(params['dmpSectionIndex']); + // this.newDmpId = queryParams['newDmpId']; + // this.publicId = params['publicId']; + // this.profileUpdateId = params['updateId']; + // this.finalize = data.finalize; + // this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId + + this.viewOnly = isPublicDescription; + // if (itemId != null) { + // this.isNew = false; + // this.isPublicView = false; + // this.descriptionService.getSingle(itemId, this.lookupFields()) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.description = data; + // this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [ReferenceType.Researcher]); + // // this.users = this.description.dmp.users; + // this.checkLockStatus(this.description.id); + // this.setIsUserOwner(); + // }, (error: any) => { + // if (error.status === 404) { + // return this.onFetchingDeletedCallbackError('/descriptions/'); + // } + // if (error.status === 403) { + // return this.onFetchingForbiddenCallbackError('/descriptions/'); + // } + // }); + // } + // else if (publicId != null) { + // this.isNew = false; + // this.isFinalized = true; + // this.isPublicView = true; + // this.descriptionService.getPublicSingle(publicId, this.lookupFields()) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.description = data; + // this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [ReferenceType.Researcher]); + // // this.users = this.description.dmp.users; + // // const breadCrumbs = []; + // // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" }); + // // breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/public/' + this.description.id }); + // // this.breadCrumbs = observableOf(breadCrumbs); + // }, (error: any) => { + // if (error.status === 404) { + // return this.onFetchingDeletedCallbackError('/explore-descriptions'); + // } + // if (error.status === 403) { + // return this.onFetchingForbiddenCallbackError('/explore-descriptions'); + // } + // }); + // } + if (itemId != null && newDmpId == null) { + this.isNew = false; + this.lockService.checkLockStatus(itemId).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + this.lockStatus = lockStatus; + if (this.item.status === DescriptionStatus.Finalized || lockStatus) { + this.formGroup.disable(); + this.viewOnly = true; + } + if (lockStatus) { + this.dialog.open(PopupNotificationDialogComponent, { + data: { + title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'), + message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE') + }, maxWidth: '30em' + }); + } + + if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { + //TODO: lock it. + // const lockedBy: UserInfoListingModel = { + // email: this.authService.getUserProfileEmail(), + // id: this.authService.userId()?.toString(), + // name: this.authService.getPrincipalName(), + // role: 0 //TODO + // //role: this.authService.getRoles()?.at(0) + // } + // this.lock = new LockModel(data.id, lockedBy); + + // this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + // this.lock.id = Guid.parse(result); + // interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + // }); + } + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + }); + } + + // if (this.itemId != null && this.newDmpId == null) { + // this.isNew = false; + // this.descriptionService.getSingle(this.itemId) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + // this.lockStatus = lockStatus; + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.dmpSectionIndex = this.descriptionModel.dmpSectionIndex; + // this.needsUpdate(); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.label, + // // url: '/descriptions/edit/' + this.descriptionModel.id, + // // notFoundResolver: [ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS').toUpperCase(), + // // url: '/descriptions' + // // }, + // // ] + // // }]); + // this.formGroup = this.descriptionModel.buildForm(); + // let profiles = this.descriptionModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.descriptionModel.dmpSectionIndex)); + // for (var profile of profiles) { + // this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) + // } + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized || lockStatus) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { + // const lockedBy: UserInfoListingModel = { + // email: this.authService.getUserProfileEmail(), + // id: this.authService.userId()?.toString(), + // name: this.authService.getPrincipalName(), + // role: 0 //TODO + // //role: this.authService.getRoles()?.at(0) + // } + // this.lock = new LockModel(data.id, lockedBy); + + // this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + // this.lock.id = Guid.parse(result); + // interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + // }); + // } + // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + + // if (lockStatus) { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'), + // message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE') + // }, maxWidth: '30em' + // }); + // } + // if (this.finalize && !this.lockStatus && !this.viewOnly) { + // setTimeout(() => { + // this.saveFinalize(); + // }, 0); + // } + // // this.availableProfiles = this.descriptionModel.dmp.profiles; + // }); + // }, + // error => { + // switch (error.status) { + // case 403: + // this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-ALLOWED'), SnackBarNotificationLevel.Error); + // break; + // case 404: + // this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-FOUND'), SnackBarNotificationLevel.Error); + // break; + // default: + // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), SnackBarNotificationLevel.Error); + // } + // this.router.navigate(['/descriptions/']); + // return observableOf(null); + // }); + // } else if (this.dmpId != null) { + // this.isNew = true; + // this.dmpService.getSingle(this.dmpId).pipe(map(data => data as DmpModel)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.descriptionModel = new DescriptionEditorModel(); + // setTimeout(() => { + // this.descriptionModel.dmp = data; + // this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex; + // this.formGroup = this.descriptionModel.buildForm(); + // let profiles = this.descriptionModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.dmpSectionIndex)); + // for (var profile of profiles) { + // this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) + // } + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // this.formGroup.get('dmp').disable(); + // const dialogRef = this.dialog.open(PrefillDescriptionComponent, { + // width: '590px', + // minHeight: '200px', + // restoreFocus: false, + // data: { + // availableProfiles: this.availableDescriptionTemplates, + // descriptionFormGroup: this.formGroup + // }, + // panelClass: 'custom-modalbox' + // }); + // dialogRef.afterClosed().subscribe(result => { + // if (result) { + // this.descriptionModel = this.descriptionModel.fromModel(result); + // this.descriptionModel.dmp = data; + // this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex; + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.formGroup.get('dmp').disable(); + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + // } + // }) + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + // // this.availableProfiles = data.profiles; + + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), + // // url: '/descriptions', + // // notFoundResolver: [ + // // // { + // // // parentComponentName: null, + // // // label: this.descriptionModel.dmp.grant.label, + // // // url: '/grants/edit/' + this.descriptionModel.dmp.grant.id + // // // }, + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.dmp.label, + // // url: '/plans/edit/' + this.descriptionModel.dmp.id, + // // }] + // // }]); + // }); + // }); + // } else if (this.newDmpId != null) { + // this.isNew = false; + // this.isCopy = true; + // this.descriptionService.getSingle(this.itemId) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + // this.lockStatus = lockStatus; + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.dmpSectionIndex = this.descriptionModel.dmpSectionIndex; + // this.descriptionModel.status = 0; + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroup.get('id').setValue(null); + // this.dmpService.getSingleNoDescriptions(this.newDmpId).pipe(map(data => data as DmpModel)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // setTimeout(() => { + // this.descriptionModel.dmp = data; + // this.formGroup.get('dmp').setValue(this.descriptionModel.dmp); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + + // this.loadDescriptionProfiles(); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), + // // url: '/descriptions', + // // notFoundResolver: [ + // // // { + // // // parentComponentName: null, + // // // label: this.descriptionModel.dmp.grant.label, + // // // url: '/grants/edit/' + this.descriptionModel.dmp.grant.id + // // // }, + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.dmp.label, + // // url: '/plans/edit/' + this.descriptionModel.dmp.id, + // // } + // // ] + // // }]); + // }); + // }); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized || lockStatus) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { + // const lockedBy: UserInfoListingModel = { + // email: this.authService.getUserProfileEmail(), + // id: this.authService.userId()?.toString(), + // name: this.authService.getPrincipalName(), + // role: 0 //TODO + // //role: this.authService.getRoles()?.at(0) + // } + // this.lock = new LockModel(data.id, lockedBy); + + // this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + // this.lock.id = Guid.parse(result); + // interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + // }); + // } + // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.loadDescriptionProfiles(); + // // this.availableProfiles = data.dmp.profiles; + // }) + // }); + // } else if (this.publicId != null) { // For Finalized -> Public Descriptions + // this.isNew = false; + // this.descriptionService.getSinglePublic(this.publicId) + // .pipe(takeUntil(this._destroyed)).pipe( + // catchError((error: any) => { + // this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); + // this.router.navigate(['/descriptions/publicEdit/' + this.publicId]); + // return observableOf(null); + // })) + // .subscribe(data => { + // if (data) { + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.formGroup.disable(); + // this.viewOnly = true; + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // this.formGroup.get('dmp').setValue(this.descriptionModel.dmp); + // const breadcrumbs = []; + // breadcrumbs.push({ + // parentComponentName: null, + // label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), + // url: '/explore-descriptions' + // }); + // breadcrumbs.push({ + // parentComponentName: null, + // label: this.descriptionModel.label, + // url: '/descriptions/publicEdit/' + this.descriptionModel.id + // }); + // // this.breadCrumbs = observableOf(breadcrumbs); + // } + // }); + // this.publicMode = true; + // } else if (this.profileUpdateId != null) { + // this.descriptionService.updateDescriptionProfile(this.profileUpdateId) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + + // this.needsUpdate(); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), + // // url: '/descriptions', + // // notFoundResolver: [ + // // // { + // // // parentComponentName: null, + // // // label: this.descriptionModel.dmp.grant.label, + // // // url: '/grants/edit/' + this.descriptionModel.dmp.grant.id + // // // }, + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.dmp.label, + // // url: '/plans/edit/' + this.descriptionModel.dmp.id, + // // }, + // // ] + // // }]); + // this.formGroup = this.descriptionModel.buildForm(); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.loadDescriptionProfiles(); + // }); + + // } else { + // this.descriptionModel = new DescriptionEditorModel(); + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.registerFormListeners(); + // this.dmpValueChanged(null); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('DATASET-LISTING.ACTIONS.CREATE-NEW').toUpperCase(), + // // url: '/descriptions/new/' + // // }]); + // } + }); + } getItem(itemId: Guid, successFunction: (item: Description) => void) { @@ -148,6 +550,7 @@ export class DescriptionEditorComponent extends BaseEditor entry.id === fieldSet.id); + this.step = index + (selected.type === ToCEntryType.FieldSet ? 1 : 0.5); + } else { + this.step = 0; + this.resetScroll(); + } + } + } + + getFirstFieldSet(entry: ToCEntry): ToCEntry { + if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id.toString())) { + return entry; + } else { + let subEntries = entry.subEntries.filter(subEntry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === subEntry.id.toString())); + if (subEntries.length > 0) { + return this.getFirstFieldSet(subEntries[0]); + } else { + return null; + } + } + } + + private resetScroll() { + document.getElementById('description-editor-form').scrollTop = 0; + } + + get visibleFieldSets(): ToCEntry[] { + let fieldSets = []; + let arrays = this.table0fContents ? this.table0fContents.tocentries. + filter(entry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id.toString())).map(entry => { + return this.getEntryVisibleFieldSets(entry); + }) + : []; + arrays.forEach(array => { + fieldSets = fieldSets.concat(array); + }); + return fieldSets; + } + + getEntryVisibleFieldSets(entry: ToCEntry): ToCEntry[] { + let fieldSets = []; + if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id.toString())) { + fieldSets.push(entry); + } else if (entry.type !== ToCEntryType.FieldSet) { + entry.subEntries.forEach(subEntry => { + fieldSets = fieldSets.concat(this.getEntryVisibleFieldSets(subEntry)); + }); + } + return fieldSets; + } + + // registerFormListeners() { + // // const dmpSubscription = + // this.formGroup.get('dmp').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.dmpValueChanged(x); + // }); + // // const profileSubscription = + // this.formGroup.get('profile').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // if (x) { + // this.showtocentriesErrors = false; + // this.descriptionProfileValueChanged(x.id); + // this.formChanged(); + // } + // }); + // // const labelSubscription = + // this.formGroup.get('label').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // const descriptionSubscription = + // this.formGroup.get('description').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // const uriSubscription = + // this.formGroup.get('uri').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // const tagsSubscription = + // this.formGroup.get('tags').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // if (this.formGroup.get('descriptionProfileDefinition')) { + // // const descriptionProfileDefinitionSubscription = + // this.formGroup.get('descriptionProfileDefinition').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // this._listenersSubscription.add(descriptionProfileDefinitionSubscription); + // } + + // // this._listenersSubscription.add(dmpSubscription); + // // this._listenersSubscription.add(profileSubscription); + // // this._listenersSubscription.add(labelSubscription); + // // this._listenersSubscription.add(descriptionSubscription); + // // this._listenersSubscription.add(uriSubscription); + // // this._listenersSubscription.add(tagsSubscription); + // } + // // // // // // Sections @@ -437,7 +984,6 @@ export class DescriptionEditorComponent extends BaseEditor new DescriptionFieldEditorModel( - this.validationErrorModel - ).fromModel(item).buildForm({ - rootPath: `${rootPath}fields[${index}].` - }), context.getValidation('fields') - ) - ), - }); + const formGroup = this.formBuilder.group({}); + (this.fields ?? []).map( + (item, index) => formGroup.addControl(item.key, new DescriptionFieldEditorModel( + this.validationErrorModel + ).fromModel(item).buildForm({ + rootPath: `${rootPath}fields[${index}].` + })), context.getValidation('fields') + ) + return formGroup; + + // return this.formBuilder.group({ + // fields: this.formBuilder.array( + // (this.fields ?? []).map( + // (item, index) => new DescriptionFieldEditorModel( + // this.validationErrorModel + // ).fromModel(item).buildForm({ + // rootPath: `${rootPath}fields[${index}].` + // }), context.getValidation('fields') + // ) + // ) + // }); } static createValidationContext(params: { diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts new file mode 100644 index 000000000..350589979 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts @@ -0,0 +1,39 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DescriptionBaseFieldsEditorComponent } from './description-base-fields-editor/description-base-fields-editor.component'; +import { DescriptionEditorComponent } from './description-editor.component'; +import { DescriptionEditorRoutingModule } from './description-editor.routing'; +import { DescriptionFormModule } from './description-form/description-form.module'; +import { VisibilityRulesService } from './description-form/visibility-rules/visibility-rules.service'; +import { DescriptionFormProgressIndicationModule } from './form-progress-indication/form-progress-indication.module'; +import { TableOfContentsModule } from './table-of-contents/table-of-contents.module'; +import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module'; +import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + FormattingModule, + ConfirmationDialogModule, + TableOfContentsModule, + DescriptionFormProgressIndicationModule, + DescriptionFormModule, + DescriptionEditorRoutingModule, + RichTextEditorModule, + TagsFieldModule + ], + declarations: [ + DescriptionEditorComponent, + DescriptionBaseFieldsEditorComponent + ], + exports: [ + ], + providers: [ + VisibilityRulesService + ] +}) +export class DescriptionEditorModule { } diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts new file mode 100644 index 000000000..87c1c6fda --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -0,0 +1,126 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { Description, DescriptionField, DescriptionReference, DescriptionTag, PropertyDefinition } from '@app/core/model/description/description'; +import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; +import { Reference } from '@app/core/model/reference/reference'; +import { Tag } from '@app/core/model/tag/tag'; +import { DescriptionService } from '@app/core/services/description/description.service'; +import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; +import { BaseEditorResolver } from '@common/base/base-editor.resolver'; +import { Guid } from '@common/types/guid'; +import { takeUntil, tap } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; + +@Injectable() +export class DescriptionEditorResolver extends BaseEditorResolver { + + constructor(private descriptionService: DescriptionService, private breadcrumbService: BreadcrumbService) { + super(); + } + + public static lookupFields(): string[] { + return [ + ...BaseEditorResolver.lookupFields(), + nameof(x => x.id), + nameof(x => x.label), + nameof(x => x.status), + nameof(x => x.description), + nameof(x => x.status), + [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), + + [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.sectionId)].join('.'), + + [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.ordinal)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.title)].join('.'), + + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.defaultVisibility)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.multiplicity)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.numbering)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.page)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.title)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.extendedDescription)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), // TODO: need to sort based on that + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.sections)].join('.'), // TODO: it is recursive here + + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.numbering)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.title)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.description)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.extendedDescription)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.additionalInformation)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.hasCommentField)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.min)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.max)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.placeholder)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.tableView)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.id)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.numbering)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.schematics)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.fieldType)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.includeInExport)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.validations)].join('.'), + + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.target)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.value)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.label)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.fieldType)].join('.'), + + + [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.key)].join('.'), + [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.value)].join('.'), + + [nameof(x => x.descriptionTags), nameof(x => x.id),].join('.'), + [nameof(x => x.descriptionTags), nameof(x => x.tag), nameof(x => x.label)].join('.'), + + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + nameof(x => x.createdAt), + nameof(x => x.hash), + nameof(x => x.isActive) + + ] + } + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + + const fields = [ + ...DescriptionEditorResolver.lookupFields() + ]; + const id = route.paramMap.get('id'); + // const cloneid = route.paramMap.get('cloneid'); + if (id != null) { + return this.descriptionService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); + } + //TODO: check this + // else if (cloneid != null) { + // return this.descriptionService.clone(Guid.parse(cloneid), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); + // } + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts new file mode 100644 index 000000000..7a513afba --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts @@ -0,0 +1,101 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +// import { DescriptionWizardComponent } from './description-wizard/description-wizard.component'; +import { AppPermission } from '@app/core/common/enum/permission.enum'; +import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; +// import { DescriptionOverviewComponent } from './overview/description-overview.component'; +import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; +import { DescriptionEditorComponent } from './description-editor.component'; +import { DescriptionEditorResolver } from './description-editor.resolver'; +import { AuthGuard } from '@app/core/auth-guard.service'; + +const routes: Routes = [ + { + path: ':id', + canActivate: [AuthGuard], + component: DescriptionEditorComponent, + canDeactivate: [PendingChangesGuard], + resolve: { + 'entity': DescriptionEditorResolver + }, + data: { + ...BreadcrumbService.generateRouteDataConfiguration({ + title: 'BREADCRUMBS.EDIT-DESCRIPTION' + }), + authContext: { + permissions: [AppPermission.EditDescription] + } + } + }, + // { + // path: 'new/:dmpId/:dmpSectionIndex', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-NEW' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + + // { + // path: 'edit/:id/finalize', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // public: false, + // title: 'GENERAL.TITLES.DATASET-EDIT', + // finalize: true + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'publicEdit/:publicId', + // component: DescriptionWizardComponent, + // //canActivate: [AuthGuard], + // data: { + // public: true, + // title: 'GENERAL.TITLES.DATASET-PUBLIC-EDIT' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'new', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-NEW' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'copy/:id', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-COPY' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'profileupdate/:updateId', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-UPDATE' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [DescriptionEditorResolver] +}) +export class DescriptionEditorRoutingModule { } diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.service.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.service.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.service.ts rename to dmp-frontend/src/app/ui/description/editor/description-editor.service.ts diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts similarity index 85% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts index d1a3625cb..ac15f6dff 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts @@ -1,6 +1,6 @@ import {Component, Inject} from "@angular/core"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; -import {VisibilityRulesService} from "@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service"; +import { VisibilityRulesService } from "../../visibility-rules/visibility-rules.service"; @Component({ selector: 'app-form-composite-field-dialog', diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html new file mode 100644 index 000000000..5c7661260 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html @@ -0,0 +1,24 @@ +
+
+
+ {{path}} + {{fieldSet.title}} +
+ info +
+
+ + +
+ +
+
+ {{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-MORE' | translate}} +
+
+
+ + {{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-LESS' | translate}} + +
+
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.scss diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts new file mode 100644 index 000000000..ce931d8c0 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts @@ -0,0 +1,22 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { DescriptionTemplateFieldSet } from '@app/core/model/description-template/description-template'; + +@Component({ + selector: 'app-form-composite-title', + templateUrl: './form-composite-title.component.html', + styleUrls: ['./form-composite-title.component.scss'] +}) +export class DescriptionFormCompositeTitleComponent implements OnInit { + + @Input() fieldSet: DescriptionTemplateFieldSet; + @Input() isChild: Boolean = false; + @Input() path: string; + + public showExtendedDescription: boolean = false; + + constructor() { } + + ngOnInit() { + } + +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html new file mode 100644 index 000000000..0670dcec6 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -0,0 +1,55 @@ +
+
+
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
{{field.label}}
+
+ +
+
+
+
+ +
+
+
+
+ + + + {{propertiesFormGroup.get(field.id).get('value').getRawValue() | fieldValue | translate}} + + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.scss diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts new file mode 100644 index 000000000..d6c477e10 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts @@ -0,0 +1,119 @@ +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { MatDialog } from "@angular/material/dialog"; +import { DescriptionTemplateFieldSet } from '@app/core/model/description-template/description-template'; +import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from 'rxjs/operators'; +import { ToCEntry } from '../../../table-of-contents/models/toc-entry'; +import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; + +@Component({ + selector: 'app-form-field-set', + templateUrl: './form-field-set.component.html', + styleUrls: ['./form-field-set.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class DescriptionFormFieldSetComponent extends BaseComponent { + + @Input() fieldSet: DescriptionTemplateFieldSet; + @Input() propertiesFormGroup: UntypedFormGroup; + isVisibleByVisibilityService: boolean = true; + @Input() visibilityRulesService: VisibilityRulesService; + @Input() path: String; + + + @Input() datasetProfileId: String; + // @Input() form: UntypedFormGroup; + @Input() isChild: Boolean = false; + @Input() showDelete: Boolean = false; + @Input() tocentry: ToCEntry; + @Input() tableRow: boolean = false; + @Input() showTitle: boolean = true; + @Input() placeholderTitle: boolean = false; + + constructor( + private dialog: MatDialog, + private changeDetector: ChangeDetectorRef + ) { + super(); + } + + ngOnInit() { + this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { + console.log('getElementVisibilityMapObservable form field'); + if (x[this.fieldSet.id]) { + this.isVisibleByVisibilityService = x[this.fieldSet.id]; + // this.changeDetector.markForCheck(); + } else { + this.isVisibleByVisibilityService = false; + } + }); + // if (this.tocentry) { + // this.form = this.tocentry.form as UntypedFormGroup; + // } + } + + // editCompositeFieldInDialog() { + // const dialogRef = this.dialog.open(FormCompositeFieldDialogComponent, { + // width: '750px', + // disableClose: true, + // data: { + // formGroup: cloneAbstractControl(this.form), + // datasetProfileId: this.datasetProfileId, + // visibilityRulesService: this.visibilityRulesService + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { + // if (data) { + // this.form.patchValue(data.value); + // this.changeDetector.detectChanges(); + // } + // }); + // } + + // deleteCompositeField() { + // if (this.isChild) { + // this.deleteMultipeFieldFromCompositeFormGroup(); + // } else { + // this.deleteCompositeFieldFormGroup(); + // } + // } + + // deleteCompositeFieldFormGroup() { + + // const compositeFieldId = ((this.form.get('multiplicityItems') as UntypedFormArray).get('' + 0) as UntypedFormGroup).getRawValue().id; + // const fieldIds = (this.form.get('fields') as UntypedFormArray).controls.map(control => control.get('id').value) as string[]; + + // const numberOfItems = this.form.get('multiplicityItems').get('' + 0).get('fields').value.length; + // for (let i = 0; i < numberOfItems; i++) { + // const multiplicityItem = this.form.get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; + // this.form.get('fields').get('' + i).patchValue(multiplicityItem); + // } + // ((this.form.get('multiplicityItems'))).removeAt(0); + + + // this.visibilityRulesService.removeAllIdReferences(compositeFieldId); + // fieldIds.forEach(x => this.visibilityRulesService.removeAllIdReferences(x)); + // } + + // deleteMultipeFieldFromCompositeFormGroup() { + // const parent = this.form.parent; + // const index = (parent as UntypedFormArray).controls.indexOf(this.form); + + // const currentId = this.form.get('id').value; + // const fieldIds = (this.form.get('fields') as UntypedFormArray).controls.map(control => control.get('id').value) as string[]; + + + // this.visibilityRulesService.removeAllIdReferences(currentId); + // fieldIds.forEach(x => this.visibilityRulesService.removeAllIdReferences(x)); + + // (parent as UntypedFormArray).removeAt(index); + // (parent as UntypedFormArray).controls.forEach((control, i) => { + // try { + // control.get('ordinal').setValue(i); + // } catch { + // throw 'Could not find ordinal'; + // } + // }); + // } +} 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 new file mode 100644 index 000000000..77e01051a --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -0,0 +1,473 @@ +
+ + + info + +
{{fieldSet.description}} +
+
+ {{fieldSet.extendedDescription}} +
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{'GENERAL.VALIDATION.URL.MESSAGE' | translate}} + + +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + {{opt.label}} + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+ + {{field.data.label}} +
+ + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + +
+
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+
+
+ +
+ + + {{ propertiesFormGroup.get(field.id).get('value').value.name }} + + +
+
+ + + +
+
+
+ + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }} + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+ +
+ + {{option.label}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} * +
+ + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + + + {{ type.name }} + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+ +
+
+ + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+ +
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + + + {{ type.name }} + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+ + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+ + {{validationIcon}} +
+
+
+
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.scss diff --git a/dmp-frontend/src/app/ui/misc/dataset-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 similarity index 53% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts index bb3a47cf5..023b40ee6 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-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 @@ -1,59 +1,27 @@ -import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges} from '@angular/core'; -import { UntypedFormGroup, FormArray, UntypedFormControl } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '@app/core/query/dataset/daatset-external-autocomplete-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { ResearcherCriteria } from '@app/core/query/researcher/researcher-criteria'; -import { DatasetExternalAutocompleteService } from '@app/core/services/dataset/dataset-external-autocomplete.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; +import { COMMA, ENTER } from '@angular/cdk/keycodes'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges } from '@angular/core'; +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 { DescriptionTemplateAutoCompleteData, DescriptionTemplateAutoCompleteSingleData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateUploadData, DescriptionTemplateWordListData } 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 { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; +import { SnackBarNotificationLevel, UiNotificationService } from "@app/core/services/notification/ui-notification-service"; +import { ReferenceService } from '@app/core/services/reference/reference.service'; +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/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +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 { distinctUntilChanged, map, takeUntil } from 'rxjs/operators'; import { Observable } from 'rxjs'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalDatasetCriteria } from '@app/core/query/external-dataset/external-dataset-criteria'; -import { DataRepositoryCriteria } from '@app/core/query/data-repository/data-repository-criteria'; -import { RegistryCriteria } from '@app/core/query/registry/registry-criteria'; -import { ServiceCriteria } from '@app/core/query/service/service-criteria'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { MatChipInputEvent } from '@angular/material/chips'; -import { ENTER, COMMA } from '@angular/cdk/keycodes'; -import { DatasetIdModel } from '@app/core/model/dataset/dataset-id.model'; -import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; -import { CurrencyService } from '@app/core/services/currency/currency.service'; -import { AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data'; -import {LicenseCriteria} from "@app/core/query/license/license-criteria"; -import {TaxonomyCriteria} from "@app/core/query/taxonomy/taxonomy-criteria"; -import {PublicationCriteria} from "@app/core/query/publication/publication-criteria"; -import {FileService} from "@app/core/services/file/file.service"; -import { - SnackBarNotificationLevel, - UiNotificationService -} from "@app/core/services/notification/ui-notification-service"; -import {FormValidationErrorsDialogComponent} from "@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component"; -import {MatDialog} from "@angular/material/dialog"; -import {HttpError} from "@common/modules/errors/error-handling/http-error-handling.service"; -import {HttpErrorResponse} from "@angular/common/http"; -import * as FileSaver from "file-saver"; -import { FetcherReference, Reference } from '@app/core/model/reference/reference'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; -import { lookup } from 'dns'; -import { ReferenceService } from '@app/core/services/reference/reference.service'; +import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators'; +import { DescriptionFieldEditorModel } from '../../../description-editor.model'; @Component({ selector: 'app-form-field', @@ -61,30 +29,33 @@ import { ReferenceService } from '@app/core/services/reference/reference.service styleUrls: ['./form-field.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class FormFieldComponent extends BaseComponent implements OnInit { +export class DescriptionFormFieldComponent extends BaseComponent implements OnInit { + + @Input() field: DescriptionTemplateField; + @Input() fieldSet: DescriptionTemplateFieldSet; + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() visibilityRulesService: VisibilityRulesService; + isRequired: boolean = false; + // @Input() field: Field; - @Input() form: UntypedFormGroup; + // @Input() form: UntypedFormGroup; @Input() datasetProfileId: any; @Input() isChild: Boolean = false; - autocompleteOptions: AutoCompleteSingleData[]; + autocompleteOptions: DescriptionTemplateAutoCompleteSingleData[]; visible: boolean = true; - _renderStyle: DatasetProfileFieldViewStyle = null; - - get renderStyle() { - //console.log('renderStyle'); - return this._renderStyle; - } // change: Subscription; // trackByFn = (index, item) => item ? item['id'] : null; + descriptionTemplateFieldTypeEnum = DescriptionTemplateFieldType; + + + public singleAutoCompleteConfiguration: SingleAutoCompleteConfiguration; public multipleAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - datasetProfileFieldViewStyleEnum = DatasetProfileFieldViewStyle; - datasetProfileComboBoxTypeEnum = DatasetProfileComboBoxType; - datasetProfileInternalDmpEntitiesTypeEnum = DatasetProfileInternalDmpEntitiesType; + externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration; dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; pubRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; @@ -101,7 +72,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - tags: ExternalTagEditorModel[] = []; + // tags: ExternalTagEditorModel[] = []; datasetIdInitialized: boolean = false; @@ -123,14 +94,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit { filesToUpload: FileList; constructor( - public visibilityRulesService: VisibilityRulesService, - private datasetExternalAutocompleteService: DatasetExternalAutocompleteService, - private externalSourcesService: ExternalSourcesService, private language: TranslateService, - private datasetService: DatasetService, private dmpService: DmpService, - private currencyService: CurrencyService, - private fileService: FileService, private cdr: ChangeDetectorRef, private uiNotificationService: UiNotificationService, public dialog: MatDialog, @@ -138,46 +103,60 @@ export class FormFieldComponent extends BaseComponent implements OnInit { private referenceService: ReferenceService ) { super(); - - this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - this.visible = this.visibilityRulesService.checkElementVisibility(this.form?.get('id')?.value); - }); } ngOnChanges(changes: SimpleChanges) { if (changes['form']) { - this._renderStyle = this.form.get('viewStyle')?.value?.renderStyle; } } ngOnInit() { - if (this.form.get('value').value) { - this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, this.form.get('value').value); + this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { + console.log('getElementVisibilityMapObservable form field set'); + + if (x[this.field.id]) { + this.visible = x[this.field.id]; + } else { + this.visible = true; + } + }); + + //TODO: validate that this logic is correct. Validation contenxt path might need to be fixed. + if (this.propertiesFormGroup.get(this.field.id).get('value') == null) { + const item: DescriptionFieldEditorModel = new DescriptionFieldEditorModel(); + item.key = this.field.id; + this.propertiesFormGroup.addControl(this.field.id, item.buildForm()); } - if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList) { - if (this.form.get('data').value.multiList) { - const originalValue = this.form.get('value').value; + if (this.propertiesFormGroup.get(this.field.id).get('value').value) { + this.visibilityRulesService.updateValueAndVisibility(this.field?.id, this.propertiesFormGroup.get(this.field.id).get('value').value); + } + + this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required); + + if (this.field?.data?.fieldType === DescriptionTemplateFieldType.WORD_LIST) { + if ((this.field.data as DescriptionTemplateWordListData).multiList) { + const originalValue = this.propertiesFormGroup.get(this.field.id).get('value').value; if (originalValue !== null && typeof originalValue === 'string') { - let values = (this.form.get('value').value).slice(1, -1).split(', ').filter((value) => !value.includes('"')); - let specialValue = (this.form.get('value').value).split('"').filter((value) => !value.startsWith('[') && !value.endsWith(']') && !values.includes(value) && value !== ', '); + let values = (this.propertiesFormGroup.get(this.field.id).get('value').value).slice(1, -1).split(', ').filter((value) => !value.includes('"')); + let specialValue = (this.propertiesFormGroup.get(this.field.id).get('value').value).split('"').filter((value) => !value.startsWith('[') && !value.endsWith(']') && !values.includes(value) && value !== ', '); specialValue.forEach(value => values.push(value)); if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) { values = undefined; values = [originalValue]; } - this.form.patchValue({ 'value': values }); + this.propertiesFormGroup.get(this.field.id).get('value').patchValue(values); values.forEach(element => { - this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, element); + this.visibilityRulesService.updateValueAndVisibility(this.field?.id, element); }); } } } // Setup autocomplete configuration if needed - if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.Autocomplete) { - if (!(this.form.controls['data'].value.multiAutoComplete)) { + if (this.field?.data?.fieldType === DescriptionTemplateFieldType.AUTO_COMPLETE) { + if (!((this.field.data as DescriptionTemplateAutoCompleteData).multiAutoComplete)) { this.singleAutoCompleteConfiguration = { filterFn: this.searchFromAutocomplete.bind(this), initialItems: () => this.searchFromAutocomplete(''), @@ -197,13 +176,13 @@ export class FormFieldComponent extends BaseComponent implements OnInit { 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.form.get('data').value.autoCompleteSingleDataList; + if (isNullOrUndefined(this.datasetProfileId)) { + this.autocompleteOptions = (this.field.data as DescriptionTemplateAutoCompleteData).autoCompleteSingleDataList; } } - switch (this.form.get('viewStyle').value.renderStyle) { - case DatasetProfileFieldViewStyle.ExternalDatasets: + 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), @@ -213,7 +192,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.DataRepositories: + case DescriptionTemplateFieldType.DATA_REPOSITORIES: this.dataRepositoriesAutoCompleteConfiguration = { filterFn: this.searchDatasetExternalDataRepositories.bind(this), initialItems: () => this.searchDatasetExternalDataRepositories(''), @@ -223,57 +202,57 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.PubRepositories: + 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''}} + 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 DatasetProfileFieldViewStyle.JournalRepositories: + 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''}} + 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 DatasetProfileFieldViewStyle.Taxonomies: + 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''}} + 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 DatasetProfileFieldViewStyle.Licenses: + 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''}} + 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 DatasetProfileFieldViewStyle.Publications: + 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''}} + 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 DatasetProfileFieldViewStyle.Registries: + case DescriptionTemplateFieldType.REGISTRIES: this.registriesAutoCompleteConfiguration = { filterFn: this.searchDatasetExternalRegistries.bind(this), initialItems: () => this.searchDatasetExternalRegistries(''), @@ -283,7 +262,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.Services: + case DescriptionTemplateFieldType.SERVICES: this.servicesAutoCompleteConfiguration = { filterFn: this.searchDatasetExternalServices.bind(this), initialItems: () => this.searchDatasetExternalServices(''), @@ -293,7 +272,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.Tags: + case DescriptionTemplateFieldType.TAGS: this.tagsAutoCompleteConfiguration = { filterFn: this.filterTags.bind(this), initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), @@ -303,7 +282,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { }; this.parseTags(); break; - case DatasetProfileFieldViewStyle.Researchers: + 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))), @@ -313,7 +292,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.Organizations: + 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))), @@ -323,17 +302,18 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.DatasetIdentifier: - const value = this.form.get('value').value; - const disabled = this.form.disabled; - this.form.removeControl('value'); - this.form.addControl('value', new DatasetIdModel(value).buildForm()); - if(disabled) { - this.form.disable(); - } + case DescriptionTemplateFieldType.DATASET_IDENTIFIER: + const value = this.propertiesFormGroup.get(this.field.id).get('value').value; + const disabled = this.propertiesFormGroup.get(this.field.id).disabled; + //TODO: Refactor this. + // this.form.removeControl('value'); + // this.form.addControl('value', new DatasetIdModel(value).buildForm()); + // if (disabled) { + // this.form.disable(); + // } this.datasetIdInitialized = true; break; - case DatasetProfileFieldViewStyle.Currency: + case DescriptionTemplateFieldType.CURRENCY: this.currencyAutoCompleteConfiguration = { filterFn: this.searchCurrency.bind(this), initialItems: () => this.searchCurrency(''), @@ -342,113 +322,124 @@ export class FormFieldComponent extends BaseComponent implements OnInit { valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } }; break; - case DatasetProfileFieldViewStyle.Validation: - const value1 = this.form.get('value').value; - const disabled1 = this.form.disabled; - this.form.removeControl('value'); - this.form.addControl('value', new DatasetIdModel(value1).buildForm()); - if(disabled1) { - this.form.disable(); - } - //this.datasetIdInitialized = true; + case DescriptionTemplateFieldType.VALIDATION: + const value1 = this.propertiesFormGroup.get(this.field.id).get('value').value; + const disabled1 = this.propertiesFormGroup.get(this.field.id).disabled; + //TODO: Refactor this. + // this.form.removeControl('value'); + // this.form.addControl('value', new DatasetIdModel(value1).buildForm()); + // if (disabled1) { + // this.form.disable(); + // } + break; + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: + this.makeAutocompleteConfiguration(this.searchResearchers.bind(this), "name", "tag"); + break; + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DATASETS: + this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label"); + break; + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: + this.makeAutocompleteConfiguration(this.searchDmps.bind(this), "label"); break; } - if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) { - if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Researchers) { - this.makeAutocompleteConfiguration(this.searchResearchers.bind(this), "name", "tag"); - } - else if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Datasets) { - this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label"); - } - else if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Dmps) { - this.makeAutocompleteConfiguration(this.searchDmps.bind(this), "label"); - } - } - // this.form = this.visibilityRulesService.getFormGroup(this.field.id); - this.form.get('value').valueChanges + this.propertiesFormGroup.get(this.field.id).get('value').valueChanges .pipe( takeUntil(this._destroyed), distinctUntilChanged() ) .subscribe(item => { - // if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList && this.form.get('data').value.multiList) { + // if (this.field?.data?.fieldType === DescriptionTemplateFieldType.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList && this.form.get('data').value.multiList) { // item.forEach(element => { - // this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, element); + // this.visibilityRulesService.updateValueAndVisibility(this.field?.id, element); // }); // } else { - this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, item); + this.visibilityRulesService.updateValueAndVisibility(this.field?.id, item); // } }); } // _optionRemove(event) { - // const array = JSON.parse(this.form.get('value').value); + // const array = JSON.parse(this.propertiesFormGroup.get(this.field.id).get('value').value); // if (array) { // const index = array.map(x => x.id).indexOf(event.id); // if (index >= 0) { // array.splice(index, 1); // } - // this.form.get('value').patchValue(JSON.stringify(array)); + // this.propertiesFormGroup.get(this.field.id).get('value').patchValue(JSON.stringify(array)); // } // } searchFromAutocomplete(query: string) { - if (this.autocompleteOptions) { - const autocompleteRequestItem: RequestItem = new RequestItem(); - autocompleteRequestItem.criteria = new DatasetExternalAutocompleteOptionsCriteria(); - autocompleteRequestItem.criteria.autoCompleteSingleDataList = this.autocompleteOptions; - autocompleteRequestItem.criteria.like = query; - return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem); - } - else{ - const autocompleteRequestItem: RequestItem = new RequestItem(); - autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria(); - let parseIdArray: string[] = this.form.get('id').value.split('_'); - if(parseIdArray.length > 1) { - autocompleteRequestItem.criteria.fieldID = parseIdArray[parseIdArray.length - 1]; - } else { - autocompleteRequestItem.criteria.fieldID = this.form.get('id').value; - } - if (typeof this.datasetProfileId === 'string') { - autocompleteRequestItem.criteria.profileID = this.datasetProfileId; - } - else if (this.datasetProfileId != null) { - autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id; - } - autocompleteRequestItem.criteria.like = query; - return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem); - } + //TODO refactor + return null; + // if (this.autocompleteOptions) { + // const autocompleteRequestItem: RequestItem = new RequestItem(); + // autocompleteRequestItem.criteria = new DatasetExternalAutocompleteOptionsCriteria(); + // //TODO: refactor this + // //autocompleteRequestItem.criteria.autoCompleteSingleDataList = this.autocompleteOptions; + // // autocompleteRequestItem.criteria.like = query; + // // return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem); + // return null; + // } + // else { + // const autocompleteRequestItem: RequestItem = new RequestItem(); + // autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria(); + // let parseIdArray: string[] = this.field?.id.split('_'); + // if (parseIdArray.length > 1) { + // autocompleteRequestItem.criteria.fieldID = parseIdArray[parseIdArray.length - 1]; + // } else { + // autocompleteRequestItem.criteria.fieldID = this.field?.id; + // } + // if (typeof this.datasetProfileId === 'string') { + // autocompleteRequestItem.criteria.profileID = this.datasetProfileId; + // } + // else if (this.datasetProfileId != null) { + // autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id; + // } + // autocompleteRequestItem.criteria.like = query; + // //TODO: refactor this + // // return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem); + // return null; + // } } searchResearchers(query: string) { - const reasearcherAutocompleteRequestItem: RequestItem = new RequestItem(); - reasearcherAutocompleteRequestItem.criteria = new ResearcherCriteria; - reasearcherAutocompleteRequestItem.criteria.name = query; - return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem); + //TODO refactor + return null; + // const reasearcherAutocompleteRequestItem: RequestItem = new RequestItem(); + // reasearcherAutocompleteRequestItem.criteria = new ResearcherCriteria; + // reasearcherAutocompleteRequestItem.criteria.name = query; + // return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem); } searchDatasets(query: string) { - let fields: Array = new Array(); - const datasetsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); - datasetsAutocompleteRequestItem.criteria = new DatasetCriteria(); - datasetsAutocompleteRequestItem.criteria.like = query; - return this.datasetService.getPaged(datasetsAutocompleteRequestItem).pipe(map(item => item.data)); + //TODO refactor + return null; + // let fields: Array = new Array(); + // const datasetsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); + // datasetsAutocompleteRequestItem.criteria = new DatasetCriteria(); + // datasetsAutocompleteRequestItem.criteria.like = query; + // //TODO: refactor this + // // return this.datasetService.getPaged(datasetsAutocompleteRequestItem).pipe(map(item => item.data)); + // return null; } searchDmps(query: string) { - let fields: Array = new Array(); - const dmpsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); - dmpsAutocompleteRequestItem.criteria = new DmpCriteria(); - dmpsAutocompleteRequestItem.criteria.like = query; - return this.dmpService.getPaged(dmpsAutocompleteRequestItem).pipe(map(item => item.data)); + //TODO refactor + return null; + // let fields: Array = new Array(); + // const dmpsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); + // dmpsAutocompleteRequestItem.criteria = new DmpCriteria(); + // dmpsAutocompleteRequestItem.criteria.like = query; + // return this.dmpService.getPaged(dmpsAutocompleteRequestItem).pipe(map(item => item.data)); } makeAutocompleteConfiguration(myfunc: Function, title: string, subtitle?: string): void { - if (!(this.form.controls['data'].value.multiAutoComplete)) { + if (!((this.field.data as DescriptionTemplateAutoCompleteData).multiAutoComplete)) { this.singleAutoCompleteConfiguration = { filterFn: myfunc.bind(this), initialItems: (extraData) => myfunc(''), @@ -521,11 +512,13 @@ export class FormFieldComponent extends BaseComponent implements OnInit { return this.referenceService.search(lookup); } searchDatasetExternalTaxonomies(query: string): Observable { - 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); + //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(); @@ -554,34 +547,40 @@ export class FormFieldComponent extends BaseComponent implements OnInit { } searchDatasetExternalRegistries(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new RegistryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.listExternal(ReferenceType.Registries, requestItem.criteria.like, requestItem.criteria.type); + //TODO refactor + return null; + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new RegistryCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.listExternal(ReferenceType.Registries, requestItem.criteria.like, requestItem.criteria.type); } searchDatasetExternalServices(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ServiceCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.listExternal(ReferenceType.Services, requestItem.criteria.like, requestItem.criteria.type); + //TODO refactor + return null; + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new ServiceCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.listExternal(ReferenceType.Services, requestItem.criteria.like, requestItem.criteria.type); } - searchDatasetTags(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new TagCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.searchDatasetTags(requestItem); + searchDatasetTags(query: string): Observable { + //TODO refactor + return null; + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new TagCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.searchDatasetTags(requestItem); } parseTags() { try { - let stringValue = this.form.get('value').value; + let stringValue = this.propertiesFormGroup.get(this.field.id).get('value').value; if (typeof stringValue === 'string') { stringValue = (stringValue).replace(new RegExp('{', 'g'), '{"').replace(new RegExp('=', 'g'), '":"').replace(new RegExp(',', 'g'), '",').replace(new RegExp(', ', 'g'), ', "').replace(new RegExp('}', 'g'), '"}'); stringValue = stringValue.replace(new RegExp('}"', 'g'), '}').replace(new RegExp('"{', 'g'), '{'); @@ -593,18 +592,20 @@ export class FormFieldComponent extends BaseComponent implements OnInit { stringValue = JSON.stringify(tempArray); } const tagArray = JSON.parse(stringValue); - this.form.patchValue({ 'value': tagArray }); + this.propertiesFormGroup.get(this.field.id).get('value').patchValue(tagArray); } catch (e) { console.warn('Could not parse tags'); } } - filterTags(value: string): Observable { - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); + filterTags(value: string): Observable { + //TODO refactor + return null; + // const requestItem: RequestItem = new RequestItem(); + // const criteria: TagCriteria = new TagCriteria(); + // criteria.like = value; + // requestItem.criteria = criteria; + // return this.externalSourcesService.searchDatasetTags(requestItem); } showTag(ev: any) { @@ -616,16 +617,16 @@ export class FormFieldComponent extends BaseComponent implements OnInit { } addTag(ev: any) { - let item: ExternalTagEditorModel; - //this.filteredTags = this.formGroup.get('tags').value; - if (typeof ev === 'string') { - item = new ExternalTagEditorModel('', ev); - } else { - item = ev; - } - if (item.name !== '') { - return item; - } + // let item: ExternalTagEditorModel; + // //this.filteredTags = this.formGroup.get('tags').value; + // if (typeof ev === 'string') { + // item = new ExternalTagEditorModel('', ev); + // } else { + // item = ev; + // } + // if (item.name !== '') { + // return item; + // } } filterOrganisations(value: string): Observable { @@ -649,31 +650,36 @@ export class FormFieldComponent extends BaseComponent implements OnInit { } getDatasetIdControl(name: string): UntypedFormControl { - return this.form.get('value').get(name) as UntypedFormControl; + return this.propertiesFormGroup.get(this.field.id).get(name) as UntypedFormControl; } - searchCurrency(query: string): Observable { - return this.currencyService.get(query); + searchCurrency(query: string): Observable { + //TODO refactor + return null; + // return this.currencyService.get(query); } validateId() { - const identifier = this.getDatasetIdControl('identifier').value; - const type = this.getDatasetIdControl('type').value; - this.validationIcon = 'loading'; - this.externalSourcesService.validateIdentifier(identifier, type).pipe(takeUntil(this._destroyed)).subscribe(result => { - this.validationIcon = result === true ? 'done' : 'clear'; - }); + //TODO refactor + return null; + // const identifier = this.getDatasetIdControl('identifier').value; + // const type = this.getDatasetIdControl('type').value; + // this.validationIcon = 'loading'; + // this.externalSourcesService.validateIdentifier(identifier, type).pipe(takeUntil(this._destroyed)).subscribe(result => { + // this.validationIcon = result === true ? 'done' : 'clear'; + // }); } public upload() { - this.fileService.upload(this.filesToUpload[0], this.datasetProfileId.id, this.form.value.id).subscribe((fileId: string) => { - this.form.get("value").patchValue( - {"name": this.filesToUpload[0].name, "id": fileId+"", "type": this.filesToUpload[0].type}); - this.cdr.detectChanges(); - }, error => { - this.onCallbackUploadFail(error.error); - }) + //TODO: refactor this + // this.fileService.upload(this.filesToUpload[0], this.datasetProfileId.id, this.form.value.id).subscribe((fileId: string) => { + // this.form.get("value").patchValue( + // { "name": this.filesToUpload[0].name, "id": fileId + "", "type": this.filesToUpload[0].type }); + // this.cdr.detectChanges(); + // }, error => { + // this.onCallbackUploadFail(error.error); + // }) } @@ -683,84 +689,81 @@ export class FormFieldComponent extends BaseComponent implements OnInit { } fileChangeEvent(fileInput: any, dropped: boolean = false) { - if(this.form.value.value) { - this.onRemove(false); - } + //TODO: refactor this + // if (this.form.value.value) { + // this.onRemove(false); + // } - if(dropped) { - this.filesToUpload = fileInput.addedFiles; - } else { - this.filesToUpload = fileInput.target.files; - } + // if (dropped) { + // this.filesToUpload = fileInput.addedFiles; + // } else { + // this.filesToUpload = fileInput.target.files; + // } - let messages: string[] = []; - if (this.filesToUpload.length == 0) { - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.NO-FILES-SELECTED')); - return; - } else { - let fileToUpload = this.filesToUpload[0]; - if (this.form.get("data") && this.form.get("data").value.types - && this.form.get("data").value.types.map(type => type.value).includes(fileToUpload.type) - && this.form.get("data").value.maxFileSizeInMB - && this.form.get("data").value.maxFileSizeInMB*1048576 >= fileToUpload.size) { - this.upload(); - } else { - this.filesToUpload = null; - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.LARGE-FILE-OR-UNACCEPTED-TYPE')); - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.MAX-FILE-SIZE', {'maxfilesize': this.form.get("data").value.maxFileSizeInMB})); - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.ACCEPTED-FILE-TYPES')+ this.form.get("data").value.types.map(type => type.value).join(", ")); - } + // let messages: string[] = []; + // if (this.filesToUpload.length == 0) { + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.NO-FILES-SELECTED')); + // return; + // } else { + // let fileToUpload = this.filesToUpload[0]; + // if (this.form.get("data") && this.form.get("data").value.types + // && this.form.get("data").value.types.map(type => type.value).includes(fileToUpload.type) + // && this.form.get("data").value.maxFileSizeInMB + // && this.form.get("data").value.maxFileSizeInMB * 1048576 >= fileToUpload.size) { + // this.upload(); + // } else { + // this.filesToUpload = null; + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.LARGE-FILE-OR-UNACCEPTED-TYPE')); + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.MAX-FILE-SIZE', { 'maxfilesize': this.form.get("data").value.maxFileSizeInMB })); + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.ACCEPTED-FILE-TYPES') + this.form.get("data").value.types.map(type => type.value).join(", ")); + // } - if(messages && messages.length > 0) { - this.dialog.open(FormValidationErrorsDialogComponent, { - data: { - errorMessages: messages - } - }) - } - } + // if (messages && messages.length > 0) { + // this.dialog.open(FormValidationErrorsDialogComponent, { + // data: { + // errorMessages: messages + // } + // }) + // } + // } } onRemove(makeFilesNull: boolean = true) { + //TODO: refactor this // delete from tmp folder - subscribe call - this.fileService.deleteFromTempFolder(this.form.value.value.id).subscribe(res => { - if(makeFilesNull) { - this.makeFilesNull(); - } - this.cdr.detectChanges(); - }, error => { - if(makeFilesNull) { - this.makeFilesNull(); - } - }) + // this.fileService.deleteFromTempFolder(this.form.value.value.id).subscribe(res => { + // if (makeFilesNull) { + // this.makeFilesNull(); + // } + // this.cdr.detectChanges(); + // }, error => { + // if (makeFilesNull) { + // this.makeFilesNull(); + // } + // }) } makeFilesNull() { - this.filesToUpload = null; - this.form.value.value = null; - this.form.get("value").patchValue(null); + //TODO: refactor this + // this.filesToUpload = null; + // this.form.value.value = null; + // this.form.get("value").patchValue(null); } typesToString() { - return this.form.get("data").value.types.map(type => type.value).toString(); + return (this.field.data as DescriptionTemplateUploadData).types.map(type => type.value).toString(); } download(): void { - this.fileService.download(this.form.value.value.id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], {type: this.form.value.value.type}); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + //TODO: refactor this + // this.fileService.download(this.form.value.value.id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(response => { + // const blob = new Blob([response.body], { type: this.form.value.value.type }); + // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - }); + // FileSaver.saveAs(blob, filename); + // }); } - - // isImageFile(fileType: string) { - // if(!fileType) { - // return false; - // } - // return fileType.startsWith("image/"); - // } } diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html new file mode 100644 index 000000000..2243510e0 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html @@ -0,0 +1,89 @@ +
+ + + + +
{{path}}.section {{section.title}}
+
{{path}} {{section.title}}
+
+
+ +
+
+
+ +
+
+
+ + +
+ +
+
+ +
+
+ +
+
+ + + +
+
+ +
+ + +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.scss diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts new file mode 100644 index 000000000..7efec3364 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts @@ -0,0 +1,265 @@ +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + EventEmitter, + Input, + OnChanges, + OnInit, + Output, + SimpleChanges +} from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { BaseComponent } from '@common/base/base.component'; +import { DescriptionFieldEditorModel } from '../../../description-editor.model'; +import { ToCEntry } from '../../../table-of-contents/models/toc-entry'; +import { ToCEntryType } from '../../../table-of-contents/models/toc-entry-type.enum'; +import { LinkToScroll } from '../../../table-of-contents/table-of-contents.component'; +import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; + + +@Component({ + selector: 'app-form-section', + templateUrl: './form-section.component.html', + styleUrls: ['./form-section.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class DescriptionFormSectionComponent extends BaseComponent implements OnInit, OnChanges { + + @Input() section: DescriptionTemplateSection; + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() visibilityRulesService: VisibilityRulesService; + @Input() path: string; + + // @Input() datasetProfileId: String; + // @Input() form: UntypedFormGroup; + @Input() tocentry: ToCEntry; + @Input() pathName: string; + @Input() linkToScroll: LinkToScroll; + @Input() hiddenEntriesIds: string[] = []; + panelExpanded = true; + subsectionLinkToScroll: LinkToScroll; + @Output() askedToScroll = new EventEmitter(); + tocentriesType = ToCEntryType; + @Input() TOCENTRY_ID_PREFIX = ""; + + constructor( + private changeDetector: ChangeDetectorRef + ) { + super(); + + } + + ngOnInit() { + + // this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { + // this.changeDetector.markForCheck(); + // }); + // Set comment fields to properties + this.section.fieldSets.forEach(fieldSet => { + if (fieldSet.hasCommentField && !this.propertiesFormGroup.contains('commentFieldValue' + fieldSet.id)) { + const item: DescriptionFieldEditorModel = new DescriptionFieldEditorModel(); + item.key = 'commentFieldValue' + fieldSet.id; + this.propertiesFormGroup.addControl('commentFieldValue' + fieldSet.id, item.buildForm()); + } + }); + + //TODO uncomment + // if (this.tocentry) {//maybe not needed as well + // this.form = this.tocentry.form as UntypedFormGroup; + // } + // this.initMultipleFieldsVisibility(); + } + + ngOnChanges(changes: SimpleChanges) { + + if (changes['linkToScroll']) { + if (changes['linkToScroll'].currentValue && changes['linkToScroll'].currentValue.section) { + + if (this.pathName === changes['linkToScroll'].currentValue.section) { + this.panelExpanded = true; + } else if (changes['linkToScroll'].currentValue.section.includes(this.pathName)) { + this.subsectionLinkToScroll = changes['linkToScroll'].currentValue; + this.panelExpanded = true; + } + } + } + } + + // setMultipleFieldVisibility(parentCompositeField, compositeField: DatasetDescriptionCompositeFieldEditorModel, idMappings: { old: string, new: string }[]) { + // // ** COMPOSITE FIELD IS SHOWN OR HIDDEN FROM ANOTHER ELEMENT + // const compositeFieldVisibilityDependencies = this.visibilityRulesService.getVisibilityDependency(parentCompositeField); + // if (compositeFieldVisibilityDependencies && compositeFieldVisibilityDependencies.length) { + + // compositeFieldVisibilityDependencies.forEach(x => { + // const visRule: Rule = { + // targetField: compositeField.id, + // sourceField: x.sourceControlId, + // requiredValue: x.sourceControlValue + // } + // this.visibilityRulesService.addNewRule(visRule); + // }); + // } + + // // console.log('idMappings ', idMappings); + // parentCompositeField.fields.forEach(element => { + // // console.log(this.visibilityRulesService.getVisibilityDependency(element.id)); + // const dependency = this.visibilityRulesService.getVisibilityDependency(element.id); + // if (dependency && dependency.length) { + // // * INNER VISIBILITY DEPENDENCIES + // // * IF INNER INPUT HIDES ANOTHER INNER INPUT + // const innerDependency = parentCompositeField.fields.reduce((innerD, currentElement) => { + // const innerDependecies = dependency.filter(d => d.sourceControlId === currentElement.id); + // return [...innerD, ...innerDependecies]; + // }, []) as VisibilityRuleSource[]; + // if (innerDependency.length) { + // //Build visibility source + // const updatedRules = innerDependency.map(x => { + // const newId = idMappings.find(y => y.old === x.sourceControlId); + // return { ...x, sourceControlId: newId.new }; + // }); + // // const visRule: VisibilityRule = { + // // targetControlId: idMappings.find(x => x.old === element.id).new, + // // sourceVisibilityRules: updatedRules + // // } + + + // const rules = updatedRules.map(x => { + // return { + // requiredValue: x.sourceControlValue, + // sourceField: x.sourceControlId, + // targetField: idMappings.find(l => l.old === element.id).new, + // type: '' + // } as Rule; + // }); + + // rules.forEach(rule => { + // this.visibilityRulesService.addNewRule(rule); + // }) + + // // this.visibilityRulesService.appendVisibilityRule(visRule); + // } + + // } + + + // // * OUTER DEPENDENCIES + + // // * IF INNER INPUT HIDES OUTER INPUTS + // const innerIds = idMappings.map(x => x.old) as string[]; + + // const outerTargets = this.visibilityRulesService.getVisibilityTargets(element.id).filter(x => !innerIds.includes(x)); + + // outerTargets.forEach(target => { + + // const outerRules = (this.visibilityRulesService.getVisibilityDependency(target) as VisibilityRuleSource[]).filter(x => x.sourceControlId === element.id); + // const updatedRules = outerRules.map(x => { + // return { ...x, sourceControlId: idMappings.find(y => y.old === element.id).new }; + // }); + + // // const visRule: VisibilityRule = { + // // targetControlId: target, + // // sourceVisibilityRules: updatedRules + // // } + + + // const rules = updatedRules.map(x => { + // return { + // requiredValue: x.sourceControlValue, + // sourceField: x.sourceControlId, + // targetField: target, + // type: '' + // } as Rule; + // }) + // rules.forEach(rule => { + // this.visibilityRulesService.addNewRule(rule); + // }) + // // this.visibilityRulesService.appendVisibilityRule(visRule); + // }); + // // * IF INNER INPUT IS HIDDEN BY OUTER INPUT + // if (dependency && dependency.length) { + // const fieldsThatHideInnerElement = dependency.filter(x => !innerIds.includes(x.sourceControlId)); + // if (fieldsThatHideInnerElement.length) { + // fieldsThatHideInnerElement.forEach(x => { + // const visRule: Rule = { + // targetField: idMappings.find(l => l.old === element.id).new, + // sourceField: x.sourceControlId, + // requiredValue: x.sourceControlValue + // } + // const shouldBeVisibile = this.visibilityRulesService.checkTargetVisibilityProvidedBySource(x.sourceControlId, element.id); + // this.visibilityRulesService.addNewRule(visRule, shouldBeVisibile); + // }); + // } + // } + // // console.log(`for ${element.id} targets are`, outerTargets); + // }); + // } + + // initMultipleFieldsVisibility() { + // (this.form.get('compositeFields') as UntypedFormArray).controls.forEach(control => { + // let parentCompositeField = (control as UntypedFormGroup).getRawValue(); + // if (parentCompositeField.multiplicityItems && parentCompositeField.multiplicityItems.length > 0) { + // parentCompositeField.multiplicityItems.forEach(compositeField => { + // let idMappings: { old: string, new: string }[] = [{ old: parentCompositeField.id, new: compositeField.id }]; + // parentCompositeField.fields.forEach((field, index) => { + // idMappings.push({ old: field.id, new: compositeField.fields[index].id }); + // }); + // this.setMultipleFieldVisibility(parentCompositeField, compositeField, idMappings); + // }) + // } + // }); + // } + + // addMultipleField(fieldsetIndex: number) { + // if (this.form.get('compositeFields').get('' + fieldsetIndex).disabled) { + // return; + // } + // const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as UntypedFormGroup).getRawValue(); + // const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))); + + // const ordinal = multiplicityItemsArray.length ? multiplicityItemsArray.controls.reduce((ordinal, currentControl) => { + // const currentOrdinal = currentControl.get('ordinal').value as number; + + // if (currentOrdinal >= ordinal) { + // return currentOrdinal + 1; + // } + // return ordinal as number; + // }, 0) : 0; + // const idMappings = [] as { old: string, new: string }[]; + // const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, ordinal, idMappings); + + // this.setMultipleFieldVisibility(compositeFieldToBeCloned, compositeField, idMappings); + // multiplicityItemsArray.push(compositeField.buildForm()); + // } + + // deleteCompositeFieldFormGroup(compositeFildIndex: number) { + // const numberOfItems = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').value.length; + // for (let i = 0; i < numberOfItems; i++) { + // const multiplicityItem = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; + // this.form.get('compositeFields').get('' + compositeFildIndex).get('fields').get('' + i).patchValue(multiplicityItem); + // } + // ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(0); + // } + + // deleteMultipeFieldFromCompositeFormGroup(compositeFildIndex: number, fildIndex: number) { + // const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))); + // multiplicityItemsArray.removeAt(fildIndex); + // multiplicityItemsArray.controls.forEach((control, i) => { + // try { + // control.get('ordinal').setValue(i); + // } catch { + // throw 'Could not find ordinal'; + // } + // }); + // } + + // onAskedToScroll(id: string) { + // this.panelExpanded = true; + // this.askedToScroll.emit(id); + // } + + // visibleControls(controls: any[]) { + // return controls.filter(control => this.visibilityRulesService.isVisibleMap[control.get('id').value)); + // } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html new file mode 100644 index 000000000..f8dabcd80 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html @@ -0,0 +1,27 @@ +
+
+
+
+
+ + + + + +

+ {{z+1}}. {{page.title |uppercase}} +

+
+
+ +
+ +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.scss diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts new file mode 100644 index 000000000..1bf5e7e6a --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts @@ -0,0 +1,371 @@ +import { AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { MatExpansionPanel } from '@angular/material/expansion'; +import { DescriptionTemplate, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { BaseComponent } from '@common/base/base.component'; +import { LinkToScroll } from '../table-of-contents/table-of-contents.component'; +import { Rule } from './visibility-rules/models/rule'; +import { VisibilityRulesService } from './visibility-rules/visibility-rules.service'; + +@Component({ + selector: 'app-description-form', + templateUrl: './description-form.component.html', + styleUrls: ['./description-form.component.scss'] +}) +export class DescriptionFormComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges { + + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() descriptionTemplate: DescriptionTemplate; + @Input() visibilityRulesService: VisibilityRulesService; + + // @ViewChild('stepper', { static: false }) stepper: MatStepper; + @Input() path: string; + @Input() visibilityRules: Rule[] = []; + @Input() datasetDescription: String; + @Input() linkToScroll: LinkToScroll; + @Output() formChanged: EventEmitter = new EventEmitter(); + @Output() fieldsetFocusChange: EventEmitter = new EventEmitter(); + + // tocentries: ToCEntry[]; + + + @Input() TOCENTRY_ID_PREFIX = ""; + @Output() visibilityRulesInstance = new EventEmitter(); + + public sectionsPerPage: { [key: string]: DescriptionTemplateSection[] } = {}; + // public hiddenEntriesIds: string[] = []; + + constructor( + ) { + super(); + + } + + ngOnInit() { + this.init(); + } + + ngOnChanges(changes: SimpleChanges) { + this.init(); + // When the form is changed set stepper index to 0. + // if (this.stepper && changes['form'] && !changes['form'].isFirstChange()) { + // this.stepper.selectedIndex = 0; + // } else if (this.stepper && changes['linkToScroll'] && changes['linkToScroll'].currentValue) { + // if (changes['linkToScroll'].currentValue.page >= 0) { + // this.stepper.selectedIndex = changes['linkToScroll'].currentValue.page; + // } + // } + } + + ngAfterViewInit() { + + } + + init() { + this.descriptionTemplate?.definition?.pages.forEach(page => { + this.sectionsPerPage[page.id] = this.descriptionTemplate.definition.sections.filter(x => x.page == page.id); + }) + // this.tocentries = this.getTocEntries(); + // const rules_to_append = this._enrichWithMultiplicityRules(this.tocentries); + + // this.visibilityRulesService.buildVisibilityRules([...this.visibilityRules, ...rules_to_append], this.form); + + // if (this.form) { + // this.form.valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(val => { + // this.formChanged.emit(val); + // }); + // } + // this.visibilityRulesInstance.emit(this.visibilityRulesService); + + + + + // this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries); + + // this.visibilityRulesService.visibilityChange + // .pipe( + // takeUntil(this._destroyed), + // debounceTime(100) + // ) + // .subscribe(_ => { + // this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries); + // }) + } + + onAskedToScroll(panel: MatExpansionPanel, id?: string) { + panel.open(); + this.fieldsetFocusChange.emit(id); + } + + + + // private _enrichWithMultiplicityRules(tocentries: ToCEntry[]): Rule[] { + // if (tocentries) { + // return tocentries.map(entry => { + // if (entry.type === ToCEntryType.Field) return []; // * TODO Me to tora implementation den tha ftasei pote edo + + + // if (entry.type === ToCEntryType.FieldSet) { + // // if(multiplicity: ) + // try { + // // TODO OTAN KANW HIDE MULTIPLE PEDIO TOTE STO ON SHOW HANO TA VALUES (AUTO MPOREI NA EINAI KAI LEGIT) ('NA DOUME AN ONTOS DIAGRAFONTAI I APLA DEN TA DEIXNOUME') + // // * UPDATE KANEI DESTROY TO COMPONENT H NGIF . PITHANOTATA NA XREIASTEI NA TO KANOUME HIDDEN AN THELOUME KATI ALLO + // const multiplicity = entry.form.get('multiplicity').value; + // if ((multiplicity.max > 1) && (multiplicity.min > 0) && (multiplicity.max >= multiplicity.min)) { // has valid multiplicity + // return this._createAndAppendVisibilityRule(entry); + // } + // } catch { + + // } + // return []; + // } + + // if (entry.subEntries) { + // return this._enrichWithMultiplicityRules(entry.subEntries); + // } + // }) + // .reduce((r, c) => { return [...c, ...r] }, []); + // } + // return []; + // } + + // private _createAndAppendVisibilityRule(entry: ToCEntry): Rule[] { + + + // const rules_to_append = []; + + // if (entry && (entry.type === ToCEntryType.FieldSet)) { + + // //childs that are either target or source + // const childIdsWithVisRules = (entry.form.get('fields') as UntypedFormArray).controls.reduce((all, s) => { + // const sval = s.value as Field; + // return this.visibilityRules.find(x => (x.targetField === sval.id) || (x.sourceField === sval.id)) ? [...all, sval] : all; + // }, []) as Field[]; + + + // const innerCompositeFieldOriginalIds = (entry.form.get('fields') as UntypedFormArray).controls.map(x => x.get('id').value) as string[]; + + // //multiplicity items + // const multiplicityItemsValue = entry.form.get('multiplicityItems').value as CompositeField[]; + + + // // ********* FIELDS OF FIELDSET ARE EITHER TARGETS OR SOURCES ***** + + + // if (childIdsWithVisRules.length && multiplicityItemsValue && multiplicityItemsValue.length) { + // //check each multiplicity item composite field + // multiplicityItemsValue.forEach(mi => { + + // const multiplicityCompositeFieldIds = mi.fields.map(x => x.id); + // const idMappings = multiplicityCompositeFieldIds.map(x => { + // return { + // original: innerCompositeFieldOriginalIds.find(l => x.includes(l)), + // multiplicityIdValue: x + // } + // }) as { original: string, multiplicityIdValue: string }[]; + + // //each field of mutliplicity item + // mi.fields.forEach(field => { + + + // //get original visibility rules (original field) + + // //original id + // const original_id = childIdsWithVisRules.find(x => field.id.includes(x.id)).id; + + + // //get vis rules + + // //as source + // const original_as_source = this.visibilityRules.filter(x => x.sourceField === original_id); + // const original_as_target = this.visibilityRules.filter(x => x.targetField === original_id); + + + + // if (original_as_source.length) { + + // //inner dependencies + // const innerDep = original_as_source.filter(x => innerCompositeFieldOriginalIds.includes(x.targetField)); + // innerDep.forEach(x => { + // const newRule = { ...x, sourceField: field.id, targetField: idMappings.find(l => l.original === x.targetField).multiplicityIdValue } as Rule; + // rules_to_append.push(newRule); + // }) + + + // //outer dependencies + // const outerDep = original_as_source.filter(x => !innerCompositeFieldOriginalIds.includes(x.targetField)); + // outerDep.forEach(x => { + // const newRule = { ...x, sourceField: field.id }; + // rules_to_append.push(newRule); + // }) + // } + + + + // if (original_as_target.length) { + + // //inner dependencies + // const innerDep = original_as_target.filter(x => innerCompositeFieldOriginalIds.includes(x.sourceField)); + // innerDep.forEach(x => { + // const newRule = { ...x, targetField: field.id, sourceField: idMappings.find(l => l.original === x.sourceField).multiplicityIdValue } as Rule; + // rules_to_append.push(newRule); + // }) + + // //outer dependencies + // const outerDep = original_as_target.filter(x => !innerCompositeFieldOriginalIds.includes(x.sourceField)); + // outerDep.forEach(x => { + // const newRule = { ...x, targetField: field.id } as Rule; + // rules_to_append.push(newRule); + // }) + // } + + // }) + // }); + // } + + + + + // // ** FIELDSET ITSELF IS TARGET + // // ** source it can never be + + // const compositeFieldAsTargetRules = this.visibilityRules.filter(x => x.targetField === entry.id); + // const idCompositeFieldMappings = multiplicityItemsValue.map(x => { + // return { + // originalValue: entry.id, + // newValue: x.id + // } + // }) as { originalValue: string, newValue: string }[]; + + + // if (compositeFieldAsTargetRules.length) { + + // compositeFieldAsTargetRules.forEach(x => { + // idCompositeFieldMappings.forEach(l => { + // const newRule = { ...x, targetField: l.newValue }; + // rules_to_append.push(newRule); + // }); + // }); + // } + + + // } + + // return rules_to_append; + // } + + // private _buildRecursively(form: UntypedFormGroup, whatAmI: ToCEntryType): ToCEntry { + // if (!form) return null; + + // switch (whatAmI) { + // case ToCEntryType.Section: + // const sections = form.get('sections') as UntypedFormArray; + // const fieldsets = form.get('compositeFields') as UntypedFormArray; + + + // const tempResult: ToCEntry[] = []; + + // if (sections && sections.length) { + // sections.controls.forEach(section => { + // tempResult.push(this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section)); + // }); + + // } else if (fieldsets && fieldsets.length) { + // fieldsets.controls.forEach(fieldset => { + // tempResult.push(this._buildRecursively(fieldset as UntypedFormGroup, ToCEntryType.FieldSet)); + // }); + // } + // return { + // // form: form, + // id: form.get('id').value, + // label: form.get('title').value, + // numbering: '', + // subEntries: tempResult, + // subEntriesType: sections && sections.length ? ToCEntryType.Section : ToCEntryType.FieldSet, + // type: ToCEntryType.Section, + // ordinal: form.get('ordinal').value + // } + // case ToCEntryType.FieldSet: + // return { + // // form: form, + // label: form.get('title').value, + // id: form.get('id').value, + // numbering: 's', + // subEntries: [], + // subEntriesType: ToCEntryType.Field, + // type: ToCEntryType.FieldSet, + // ordinal: form.get('ordinal').value + // } + // } + // } + + // private _sortByOrdinal(tocentries: ToCEntry[]) { + + // if (!tocentries || !tocentries.length) return; + + // tocentries.sort(this._customCompare); + // tocentries.forEach(entry => { + // this._sortByOrdinal(entry.subEntries); + // }); + // } + + // private _customCompare(a, b) { + // return a.ordinal - b.ordinal; + // } + + // private _calculateNumbering(tocentries: ToCEntry[], depth: number[] = []) { + // if (!tocentries || !tocentries.length) { + // return; + // } + + // let prefixNumbering = depth.length ? depth.join('.') : ''; + + // if (depth.length) prefixNumbering = prefixNumbering + "."; + // tocentries.forEach((entry, i) => { + // entry.numbering = prefixNumbering + (i + 1); + // this._calculateNumbering(entry.subEntries, [...depth, i + 1]) + // }); + // } + + // getTocEntries(): ToCEntry[] { + // if (!this.form) { return []; } + // const result: ToCEntry[] = []; + + // //build parent pages + // (this.form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { + // result.push({ + // id: i + 'id', + // label: pageElement.get('title').value, + // type: ToCEntryType.Page, + // // form: pageElement, + // numbering: (i + 1).toString(), + // subEntriesType: ToCEntryType.Section, + // subEntries: [], + // ordinal: pageElement.get('ordinal').value + // } as ToCEntry) + // }); + + + + // result.forEach((entry, i) => { + + // const sections = entry.form.get('sections') as UntypedFormArray; + + // sections.controls.forEach(section => { + // const tempResults = this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section); + // entry.subEntries.push(tempResults); + // }); + + // }); + + // this._sortByOrdinal(result); + // //calculate numbering + // this._calculateNumbering(result); + // return result; + + // } + + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts new file mode 100644 index 000000000..d6937da9b --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts @@ -0,0 +1,38 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from "@app/core/formatting.module"; +import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; +import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { NgxDropzoneModule } from "ngx-dropzone"; +import { DescriptionFormCompositeTitleComponent } from './components/form-composite-title/form-composite-title.component'; +import { DescriptionFormFieldSetComponent } from './components/form-field-set/form-field-set.component'; +import { DescriptionFormFieldComponent } from './components/form-field/form-field.component'; +import { DescriptionFormSectionComponent } from './components/form-section/form-section.component'; +import { DescriptionFormComponent } from './description-form.component'; + + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + AutoCompleteModule, + RichTextEditorModule, + NgxDropzoneModule, + FormattingModule + ], + declarations: [ + DescriptionFormComponent, + DescriptionFormSectionComponent, + DescriptionFormFieldSetComponent, + DescriptionFormFieldComponent, + DescriptionFormCompositeTitleComponent + ], + exports: [ + DescriptionFormComponent + ], + providers: [ + ] +}) +export class DescriptionFormModule { } + diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts similarity index 84% rename from dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts index b17886989..9e60b6de8 100644 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/rule.ts @@ -2,5 +2,4 @@ export class Rule { sourceField: string; targetField: string; requiredValue: any; - type: string; } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule-source.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule-source.ts similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule-source.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule-source.ts diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule.ts similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule.ts diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rules-context.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts similarity index 80% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rules-context.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts index 2eba9ff10..5bcf12efb 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rules-context.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts @@ -1,4 +1,4 @@ -import { Rule } from "../../../../../core/model/dataset-profile-definition/rule"; +import { Rule } from "./rule"; import { VisibilityRule } from "./visibility-rule"; export class VisibilityRulesContext { @@ -26,14 +26,14 @@ export class VisibilityRulesContext { if (this.rules[i].targetControlId === item.targetField) { const newRule = { sourceControlId: item.sourceField, sourceControlValue: item.requiredValue }; - const ruleExists = this.rules[i].sourceVisibilityRules.find(x =>{ - return Object.keys(x).reduce((exact, key)=>{ - if(!exact) return false; + const ruleExists = this.rules[i].sourceVisibilityRules.find(x => { + return Object.keys(x).reduce((exact, key) => { + if (!exact) return false; return x[key] === newRule[key]; - },true); + }, true); }) - if(!ruleExists){ + if (!ruleExists) { this.rules[i].sourceVisibilityRules.push(newRule); } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts similarity index 63% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts rename to dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts index 2501cd894..1e372bb0d 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts @@ -1,12 +1,12 @@ import { ApplicationRef, Injectable, NgZone } from '@angular/core'; import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; import { isNumeric } from '@app/utilities/enhancers/utils'; import { Observable, Subject } from 'rxjs'; -import { Rule } from '../../../../core/model/dataset-profile-definition/rule'; import { VisibilityRule } from './models/visibility-rule'; import { VisibilityRuleSource } from './models/visibility-rule-source'; import { VisibilityRulesContext } from './models/visibility-rules-context'; +import { DescriptionTemplate, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { Rule } from './models/rule'; @Injectable() export class VisibilityRulesService { @@ -16,12 +16,20 @@ export class VisibilityRulesService { private visibilityRuleContext: VisibilityRulesContext; private form: AbstractControl; - public elementVisibilityMap = new Map(); - private elementVisibilityMapSubject = new Subject>(); + + public isVisibleMap : { [key: string]: boolean } = {}; + + private elementVisibilityMapSubject = new Subject<{ [key: string]: boolean }>(); private elementComputationalMap = new Map>(); /// keep saved the values of each form control validity value private _changeMade$ = new Subject(); + // get isVisibleMap(): MapWithDefault { + // // console.log('isVisibleMap'); + // return this.elementVisibilityMap; + + // }; /// keep saved the values of each form control validity value + constructor( public applicationReference: ApplicationRef, public ngZone: NgZone @@ -29,13 +37,18 @@ export class VisibilityRulesService { } - getElementVisibilityMapObservable(): Observable> { + getElementVisibilityMapObservable(): Observable<{ [key: string]: boolean }> { + // this.isVisibleMap + // console.log('getElementVisibilityMapObservable: '); return this.elementVisibilityMapSubject.asObservable(); } public checkElementVisibility(id: string): boolean { - if (this.visibilityRuleContext.rules.filter(item => item.targetControlId === id).length === 0) { return true; } - return this.elementVisibilityMap.has(id) ? this.elementVisibilityMap.get(id) : false; + console.log('checkElementVisibility: ' + id); + return true; + // if (this.visibilityRuleContext.rules.filter(item => item.targetControlId === id).length === 0) { return true; } + // console.log(this.elementVisibilityMap.has(id) ? this.elementVisibilityMap.get(id) : false); + // return this.elementVisibilityMap.has(id) ? this.elementVisibilityMap.get(id) : false; } public buildVisibilityRules(item: Array, form: AbstractControl) { @@ -46,14 +59,16 @@ export class VisibilityRulesService { } public updateValueAndVisibility(id: string, value: any) { + console.log('updateValueAndVisibility: ' + id + ' value: ' + value); const visibilityRules = this.visibilityRuleContext.rules.filter(item => item.sourceVisibilityRules.filter(source => source.sourceControlId === id).length > 0); if (visibilityRules.length > 0) { visibilityRules.forEach(item => this.evaluateVisibility(item, value, id)); - this.elementVisibilityMapSubject.next(this.elementVisibilityMap); + this.elementVisibilityMapSubject.next(this.isVisibleMap); } } private evaluateVisibility(visibilityRule: VisibilityRule, value: any, sourceId: string) {// source controlId is the same + console.log('evaluateVisibility: ' + visibilityRule + ' value: ' + value + ' sourceId: ' + sourceId); const targetId = visibilityRule.targetControlId; const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); @@ -92,8 +107,8 @@ export class VisibilityRulesService { const isVisible = this._computeVisibility(targetId); this._emitChangesIfNeeded(targetId, isVisible); - const previousVisibility = this.elementVisibilityMap.get(targetId); - this.elementVisibilityMap.set(targetId, isVisible); + const previousVisibility = this.isVisibleMap[targetId]; + this.isVisibleMap[targetId] = isVisible; if (!isVisible && previousVisibility !== isVisible) { this.resetControlWithId(this.form, targetId); @@ -118,6 +133,8 @@ export class VisibilityRulesService { private _computeVisibility(targetId: string): boolean { + console.log('_computeVisibility: ' + targetId); + const visibilityMap = this.elementComputationalMap.get(targetId); const values = visibilityMap.values(); let currentVal = values.next(); @@ -142,8 +159,9 @@ export class VisibilityRulesService { } private resetVisibilityRules() { - this.elementVisibilityMap.clear(); - this.elementVisibilityMap = new Map(); + console.log('resetVisibilityRules: '); + + this.isVisibleMap = {}; this.elementComputationalMap.clear(); this.elementComputationalMap = new Map>(); this._populateComputationMap(); /// !IMPORTANT FOR THE AND LOGIC @@ -151,14 +169,15 @@ export class VisibilityRulesService { } private _populateComputationMap(): void { - this.visibilityRuleContext.rules.forEach(rule => { - const targetId = rule.targetControlId; - const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); - rule.sourceVisibilityRules.forEach(vr => { - visibilityMap.set(vr.sourceControlId, this.DEFAULTVISIBILITY); - }); - this.elementComputationalMap.set(targetId, visibilityMap); - }); + console.log('_populateComputationMap: '); + // this.visibilityRuleContext.rules.forEach(rule => { + // const targetId = rule.targetControlId; + // const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); + // rule.sourceVisibilityRules.forEach(vr => { + // visibilityMap.set(vr.sourceControlId, this.DEFAULTVISIBILITY); + // }); + // this.elementComputationalMap.set(targetId, visibilityMap); + // }); } parseValue(value: any) { @@ -191,13 +210,17 @@ export class VisibilityRulesService { } scanIfChildsOfCompositeFieldHasVisibleItems(compositeFieldParent: UntypedFormGroup): boolean { - let isVisible = false; - ((compositeFieldParent.get('fields'))).controls.forEach(element => { - if (this.checkElementVisibility(element.get('id').value)) { - isVisible = true; - } - }); - return isVisible; + // console.log('scanIfChildsOfCompositeFieldHasVisibleItems: ' + compositeFieldParent); + + //TODO: implement this + return true; + // let isVisible = false; + // ((compositeFieldParent.get('fields'))).controls.forEach(element => { + // if (this.checkElementVisibility(element.get('id').value)) { + // isVisible = true; + // } + // }); + // return isVisible; } private translate(item: any) { @@ -209,43 +232,49 @@ export class VisibilityRulesService { } private resetControlWithId(formControl: AbstractControl, id: string) { - if (formControl instanceof UntypedFormGroup) { - if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (formControl as UntypedFormGroup).get('id').value === id) { - this.resetFieldFormGroup(formControl); - } if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields') && (formControl as UntypedFormGroup).get('id').value === id) { - this.resetCompositeFieldFormGroup(formControl); - } else { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.resetControlWithId(control, id); - }); - } - } else if (formControl instanceof UntypedFormArray) { - formControl.controls.forEach(item => { - this.resetControlWithId(item, id); - }); - } + console.log('resetControlWithId: ' + id); + //TODO: implement this + // if (formControl instanceof UntypedFormGroup) { + // if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (formControl as UntypedFormGroup).get('id').value === id) { + // this.resetFieldFormGroup(formControl); + // } if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields') && (formControl as UntypedFormGroup).get('id').value === id) { + // this.resetCompositeFieldFormGroup(formControl); + // } else { + // Object.keys(formControl.controls).forEach(item => { + // const control = formControl.get(item); + // this.resetControlWithId(control, id); + // }); + // } + // } else if (formControl instanceof UntypedFormArray) { + // formControl.controls.forEach(item => { + // this.resetControlWithId(item, id); + // }); + // } } private resetFieldFormGroup(formGroup: UntypedFormGroup) { - const renderStyle = formGroup.getRawValue().viewStyle.renderStyle; - if (renderStyle === DatasetProfileFieldViewStyle.Validation || renderStyle === DatasetProfileFieldViewStyle.DatasetIdentifier) { - formGroup.get('value').setValue({ identifier: '', type: '' }); - } else { - formGroup.get('value').setValue(formGroup.get('defaultValue').value ? this.parseValue(formGroup.get('defaultValue').value.value) : undefined); - } + console.log('resetFieldFormGroup: ' + formGroup); + //TODO: implement this + // const renderStyle = formGroup.getRawValue().viewStyle.renderStyle; + // if (renderStyle === DatasetProfileFieldViewStyle.Validation || renderStyle === DatasetProfileFieldViewStyle.DatasetIdentifier) { + // formGroup.get('value').setValue({ identifier: '', type: '' }); + // } else { + // formGroup.get('value').setValue(formGroup.get('defaultValue').value ? this.parseValue(formGroup.get('defaultValue').value.value) : undefined); + // } } private resetCompositeFieldFormGroup(formGroup: UntypedFormGroup) { - (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { - this.resetFieldFormGroup(element); - }); - (formGroup.get('multiplicityItems') as UntypedFormArray).controls.splice(0); + console.log('resetCompositeFieldFormGroup: ' + formGroup); + //TODO: implement this + // (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { + // this.resetFieldFormGroup(element); + // }); + // (formGroup.get('multiplicityItems') as UntypedFormArray).controls.splice(0); } private _emitChangesIfNeeded(id: string, valueToBeSet: boolean) { - if (this.elementVisibilityMap.has(id)) { - if (this.elementVisibilityMap.get(id) != valueToBeSet) { + if (this.isVisibleMap[id]) { + if (this.isVisibleMap[id] != valueToBeSet) { this._changeMade$.next(); } } else { @@ -256,6 +285,7 @@ export class VisibilityRulesService { return this._changeMade$.asObservable(); } public getVisibilityDependency(targetId: string): VisibilityRuleSource[] | null { + console.log('getVisibilityDependency: ' + targetId); return this.visibilityRuleContext.rules.reduce((hasDependency, rule) => { if (hasDependency) return hasDependency; @@ -268,6 +298,7 @@ export class VisibilityRulesService { } public getVisibilityTargets(sourceId: string): string[] { + console.log('getVisibilityTargets: ' + sourceId); return this.visibilityRuleContext.rules.filter(x => { const result = x.sourceVisibilityRules.filter(y => y.sourceControlId === sourceId); return result.length; @@ -292,6 +323,7 @@ export class VisibilityRulesService { //removes rule that has the specific id either as a source either as a target public removeAllIdReferences(id: string): void { + console.log('removeAllIdReferences: ' + id); // * Remove from visibility rues and visibility rules context @@ -299,7 +331,7 @@ export class VisibilityRulesService { const temp = this.visibilityRuleContext.rules.map((x, i) => (x.targetControlId === id) ? i : null); const indexes = temp.filter(x => x !== null); indexes.reverse().forEach(index => this.visibilityRuleContext.rules.splice(index, 1)); - this.elementVisibilityMap.delete(id); + this.isVisibleMap[id] = undefined; @@ -344,6 +376,8 @@ export class VisibilityRulesService { public addNewRule(rule: Rule, currentVisibility = this.DEFAULTVISIBILITY): void { + console.log('addNewRule: ' + rule + ' currentVisibility: ' + currentVisibility); + const targetId = rule.targetField; const sourceId = rule.sourceField; this.visibilityRuleContext.addToVisibilityRulesContext(rule); @@ -360,8 +394,8 @@ export class VisibilityRulesService { const isVisible = this._computeVisibility(targetId); this._emitChangesIfNeeded(targetId, isVisible); - this.elementVisibilityMap.set(targetId, isVisible); - this.elementVisibilityMapSubject.next(this.elementVisibilityMap); + this.isVisibleMap[targetId] = isVisible; + this.elementVisibilityMapSubject.next(this.isVisibleMap); } @@ -370,6 +404,7 @@ export class VisibilityRulesService { * return true if no rule found */ public checkTargetVisibilityProvidedBySource(sourceId: string, targetId: string): boolean { + console.log('checkTargetVisibilityProvidedBySource: ' + sourceId + ' targetId: ' + targetId); const computationalMap = this.elementComputationalMap.get(targetId); if (computationalMap) { @@ -378,4 +413,41 @@ export class VisibilityRulesService { return true; } + + public getVisibilityRulesFromDescriptionTempalte(descriptionTemplate: DescriptionTemplate): Rule[] { + console.log('getVisibilityRulesFromDescriptionTempalte: ' + descriptionTemplate); + const result: Rule[] = this.getVisibilityRulesFromDescriptionTempalteSections(descriptionTemplate?.definition?.sections); + return result; + } + + public getVisibilityRulesFromDescriptionTempalteSections(sections: DescriptionTemplateSection[]): Rule[] { + console.log('getVisibilityRulesFromDescriptionTempalteSections: ' + sections); + const result: Rule[] = []; + + sections.forEach(section => { + if (section.sections != null) { result.push(...this.getVisibilityRulesFromDescriptionTempalteSections(section.sections)); }; + section?.fieldSets?.forEach(fieldSet => { + fieldSet?.fields?.forEach(field => { + field.visibilityRules?.forEach(visibilityRule => { + result.push({ + sourceField: field.id.toString(), + targetField: visibilityRule.target, + requiredValue: visibilityRule.value + }) + }); + }); + }); + }); + return result; + } } + +class MapWithDefault extends Map { + get(key) { + console.log('MapWithDefault'); + if (!this.has(key)) { + this.set(key, true); + } + return super.get(key); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.html b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.html similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.html rename to dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.html diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.scss b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.scss rename to dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.scss diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts similarity index 91% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts rename to dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts index 689270e7c..908acd641 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts @@ -1,6 +1,6 @@ import {ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; import { BaseComponent } from '@common/base/base.component'; import { takeUntil } from 'rxjs/operators'; @@ -80,12 +80,12 @@ export class FormProgressIndicationComponent extends BaseComponent implements On return valueCurent; } private hasValue(formGroup: UntypedFormGroup): boolean { - return formGroup.get('value').valid && formGroup.get('value').value != null && formGroup.get('value').value !== '' && this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value); + return formGroup.get('value').valid && formGroup.get('value').value != null && formGroup.get('value').value !== '' && (this.visibilityRulesService.isVisibleMap[formGroup.get('id').value] ?? true); } private compositeFieldsGetChildsForProgress(formGroup: UntypedFormGroup): number { let valueCurent = 0; - if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { + if (this.visibilityRulesService.isVisibleMap[formGroup.get('id').value] ?? true) { (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); }); @@ -122,7 +122,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(item); }); } else if (formControl instanceof UntypedFormGroup) { - if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (this.visibilityRulesService.checkElementVisibility((formControl as UntypedFormGroup).get('id').value)) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { + if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (this.visibilityRulesService.isVisibleMap[(formControl as UntypedFormGroup).get('id').value] ?? true) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { valueCurent++; } else if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields')) { valueCurent = valueCurent + this.compositeFieldsGetChildsForTotal(formControl); @@ -139,7 +139,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On private compositeFieldsGetChildsForTotal(formGroup: UntypedFormGroup): number { let valueCurent = 0; - if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { + if (this.visibilityRulesService.isVisibleMap[formGroup.get('id').value] ?? true) { (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); }); @@ -176,7 +176,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On valueCurrent++; } } else if (formControl instanceof UntypedFormGroup) { - if(!checkVisibility || (!formControl.get('id')?.value || this.visibilityRulesService.checkElementVisibility(formControl.get('id').value))) { + if(!checkVisibility || (!formControl.get('id')?.value || (this.visibilityRulesService.isVisibleMap[formControl.get('id').value] ?? true))) { Object.keys(formControl.controls).forEach(item => { const control = formControl.get(item); valueCurrent = valueCurrent + this.countFormControlsRequiredFieldsForTotal(control, checkVisibility); diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module.ts b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts similarity index 88% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module.ts rename to dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts index f287d329d..5a834c683 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module.ts +++ b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts @@ -15,4 +15,4 @@ import { FormProgressIndicationComponent } from './form-progress-indication.comp FormProgressIndicationComponent ] }) -export class FormProgressIndicationModule { } +export class DescriptionFormProgressIndicationModule { } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.html similarity index 100% rename from dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html rename to dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.html diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.scss b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.scss rename to dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.scss diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts rename to dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts new file mode 100644 index 000000000..395c8ff33 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts @@ -0,0 +1,6 @@ +export enum ToCEntryType { + Page = 0, + Section = 1, + FieldSet = 2, + Field = 3 +} diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts new file mode 100644 index 000000000..353f72d7e --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts @@ -0,0 +1,14 @@ +import { Guid } from "@common/types/guid"; +import { ToCEntryType } from "./toc-entry-type.enum"; + +export interface ToCEntry { + id: string; + label: string; + subEntriesType: ToCEntryType; + subEntries: ToCEntry[]; + type: ToCEntryType; + // form: AbstractControl; + numbering: string; + ordinal: number; + hidden?: boolean +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html similarity index 77% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html rename to dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html index f78625aa2..3ffaf7c2c 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html @@ -3,14 +3,15 @@ - + + - + {{entry.numbering}}. {{entry.label}} - -
{{link.name}} -
- -
@@ -33,8 +15,10 @@ [selected]="tocentrySelected" [hiddenEntries]="hiddenEntries" [visibilityRulesService]="visibilityRulesService" + [propertiesFormGroup]="propertiesFormGroup" >
-
\ No newline at end of file + +{{hiddenEntries | json}} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.scss b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.scss rename to dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.scss diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts similarity index 56% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts rename to dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts index 6e21ab54d..8f107d4b7 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts @@ -1,14 +1,13 @@ import { DOCUMENT } from '@angular/common'; -import { Component, EventEmitter, Inject, OnInit, Output, Input, OnChanges, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Inject, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { DescriptionTemplate, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; import { BaseComponent } from '@common/base/base.component'; -import { interval, Subject, Subscription } from 'rxjs'; +import { Subject, Subscription, interval } from 'rxjs'; import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; -import { type } from 'os'; -import { SimpleChanges } from '@angular/core'; -import { ToCEntry, ToCEntryType } from '../dataset-description.component'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; +import { ToCEntry } from './models/toc-entry'; +import { ToCEntryType } from './models/toc-entry-type.enum'; import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal'; export interface Link { @@ -29,11 +28,11 @@ export interface Link { } @Component({ - selector: 'table-of-contents', - styleUrls: ['./table-of-contents.scss'], - templateUrl: './table-of-contents.html' + selector: 'app-table-of-contents', + styleUrls: ['./table-of-contents.component.scss'], + templateUrl: './table-of-contents.component.html' }) -export class TableOfContents extends BaseComponent implements OnInit, OnChanges { +export class TableOfContentsComponent extends BaseComponent implements OnInit, OnChanges { @ViewChild('internalTable') internalTable: TableOfContentsInternal; @@ -51,24 +50,23 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges tocentries: ToCEntry[] = null; @Input() TOCENTRY_ID_PREFIX = ''; - // visibilityRules:Rule[] = []; - @Input() visibilityRules:Rule[] = []; @Input() showErrors: boolean = false; - @Input() selectedFieldsetId:string; + @Input() selectedFieldsetId: string; - private _tocentrySelected:ToCEntry = null; + private _tocentrySelected: ToCEntry = null; private isSelecting: boolean = false; private _intersectionObserver: IntersectionObserver; private _actOnObservation: boolean = true; - public hiddenEntries:string[] = []; - get tocentrySelected(){ - return this.hasFocus?this._tocentrySelected: null; + public hiddenEntries: string[] = []; + get tocentrySelected() { + return this.hasFocus ? this._tocentrySelected : null; } - set tocentrySelected(value){ + set tocentrySelected(value) { this._tocentrySelected = value; } - @Input() formGroup: UntypedFormGroup; + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() descriptionTemplate: DescriptionTemplate; @Input() hasFocus: boolean = false; @Input() visibilityRulesService: VisibilityRulesService; show: boolean = false; @@ -76,32 +74,20 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges constructor( @Inject(DOCUMENT) private _document: Document, // public visibilityRulesService: VisibilityRulesService - ) { + ) { super(); } ngOnInit(): void { - // this.visibilityRulesService.visibilityChange - // .pipe(takeUntil(this._destroyed)) - // .pipe(debounceTime(200)) - // .subscribe(_=>{ - // if(this.hasFocus){ - // this._resetObserver(); - // this.hiddenEntries = this._findHiddenEntries(this.tocentries); - // } - // }) - - if(this.formGroup){ - this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); - const fg = this.formGroup.get('datasetProfileDefinition'); - // this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, fg); - if(this.visibilityRulesService){ + if (this.descriptionTemplate) { + this.tocentries = this.getTocEntries(this.descriptionTemplate); + if (this.visibilityRulesService) { this.hiddenEntries = this._findHiddenEntries(this.tocentries); } - }else{ + } else { //emit value every 500ms const source = interval(500); @@ -165,31 +151,29 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges } - private _findHiddenEntries(tocentries:ToCEntry[]):string[]{ - if(!tocentries) return []; + private _findHiddenEntries(tocentries: ToCEntry[]): string[] { + if (!tocentries) return []; - const invisibleEntries:string[] = [] - tocentries.forEach(entry=>{ - if(entry.type === ToCEntryType.FieldSet){ - const isVisible = this.visibilityRulesService.checkElementVisibility(entry.id); - if(!isVisible){ - invisibleEntries.push(entry.id); - }else{ + const invisibleEntries: string[] = [] + tocentries.forEach(entry => { + if (entry.type === ToCEntryType.FieldSet) { + const isVisible = this.visibilityRulesService.isVisibleMap[entry.id.toString()] ?? true; + if (!isVisible) { + invisibleEntries.push(entry.id.toString()); + } else { //check field inputs - const fields = entry.form.get('fields') as UntypedFormArray; - - const oneFieldAtLeastIsVisible = fields.controls.some(field=> this.visibilityRulesService.checkElementVisibility(field.get('id').value)); - if(!oneFieldAtLeastIsVisible){ - invisibleEntries.push(entry.id); + const oneFieldAtLeastIsVisible = entry.subEntries.some(field => this.visibilityRulesService.isVisibleMap[field.id.toString()] ?? true); + if (!oneFieldAtLeastIsVisible) { + invisibleEntries.push(entry.id.toString()); } } - }else{ + } else { const hiddenEntries = this._findHiddenEntries(entry.subEntries); - if(entry.subEntries&& (entry.subEntries.every(e=> hiddenEntries.includes(e.id)))){ + if (entry.subEntries && (entry.subEntries.every(e => hiddenEntries.includes(e.id.toString())))) { //all children all hidden then hide parent node; - invisibleEntries.push(entry.id); - }else{ + invisibleEntries.push(entry.id.toString()); + } else { invisibleEntries.push(...hiddenEntries); } } @@ -198,11 +182,11 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges return invisibleEntries; } - private _visibilityRulesSubscription:Subscription; + private _visibilityRulesSubscription: Subscription; ngOnChanges(changes: SimpleChanges) { - if(this.selectedFieldsetId){ - this.onToCentrySelected(this._findTocEntryById(this.selectedFieldsetId,this.tocentries), false); + if (this.selectedFieldsetId) { + this.onToCentrySelected(this._findTocEntryById(this.selectedFieldsetId, this.tocentries), false); this._actOnObservation = false; setTimeout(() => { this._actOnObservation = true; @@ -211,24 +195,24 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges } - if(changes['hasFocus'] && changes.hasFocus.currentValue){ + if (changes['hasFocus'] && changes.hasFocus.currentValue) { this._resetObserver(); } - if('visibilityRulesService'){ - if(this._visibilityRulesSubscription){ + if ('visibilityRulesService') { + if (this._visibilityRulesSubscription) { this._visibilityRulesSubscription.unsubscribe(); this._visibilityRulesSubscription = null; } - if(!this.visibilityRulesService) return; + if (!this.visibilityRulesService) return; this._visibilityRulesSubscription = this.visibilityRulesService.visibilityChange .pipe(takeUntil(this._destroyed)) .pipe(debounceTime(200)) - .subscribe(_=>{ - if(this.hasFocus){ + .subscribe(_ => { + if (this.hasFocus) { this._resetObserver(); this.hiddenEntries = this._findHiddenEntries(this.tocentries); } @@ -244,8 +228,8 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges } - private _resetObserver(){ - if(this._intersectionObserver){//clean up + private _resetObserver() { + if (this._intersectionObserver) {//clean up this._intersectionObserver.disconnect(); this._intersectionObserver = null; } @@ -254,21 +238,21 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges root: null, rootMargin: '-38% 0px -60% 0px', threshold: 0 - } + } - this._intersectionObserver = new IntersectionObserver((entries,observer)=>{ - if(!this._actOnObservation){ + this._intersectionObserver = new IntersectionObserver((entries, observer) => { + if (!this._actOnObservation) { return; } - entries.forEach(ie=>{ - if(ie.isIntersecting){ - try{ - const target_id = ie.target.id.replace(this.TOCENTRY_ID_PREFIX,''); - if(this.visibilityRulesService.checkElementVisibility(target_id)){ - this.onToCentrySelected(this._findTocEntryById(target_id,this.tocentries)); + entries.forEach(ie => { + if (ie.isIntersecting) { + try { + const target_id = ie.target.id.replace(this.TOCENTRY_ID_PREFIX, ''); + if (this.visibilityRulesService.isVisibleMap[target_id] ?? true) { + this.onToCentrySelected(this._findTocEntryById(target_id, this.tocentries)); } - }catch{ + } catch { } } @@ -277,12 +261,12 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges const fieldsetsEtries = this._getAllFieldSets(this.tocentries); - fieldsetsEtries.forEach(e=>{ - if(e.type === ToCEntryType.FieldSet){ - try{ - const targetElement = document.getElementById(this.TOCENTRY_ID_PREFIX+e.id); + fieldsetsEtries.forEach(e => { + if (e.type === ToCEntryType.FieldSet) { + try { + const targetElement = document.getElementById(this.TOCENTRY_ID_PREFIX + e.id); this._intersectionObserver.observe(targetElement); - }catch{ + } catch { console.log('element not found'); } } @@ -330,109 +314,127 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges // } - private _buildRecursively(form: UntypedFormGroup,whatAmI:ToCEntryType):ToCEntry{ - if(!form) return null; + private _buildRecursivelySection(item: DescriptionTemplateSection): ToCEntry { + if (!item) return null; - switch(whatAmI){ - case ToCEntryType.Section: - const sections = form.get('sections') as UntypedFormArray; - const fieldsets = form.get('compositeFields') as UntypedFormArray; + const sections = item.sections; + const fieldsets = item.fieldSets; - const tempResult:ToCEntry[] = []; + const tempResult: ToCEntry[] = []; - if(sections &§ions.length){ - sections.controls.forEach(section=>{ - tempResult.push(this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section)); - }); + if (sections && sections.length) { + sections.forEach(section => { + tempResult.push(this._buildRecursivelySection(section)); + }); - }else if(fieldsets && fieldsets.length){ - fieldsets.controls.forEach(fieldset=>{ - tempResult.push(this._buildRecursively(fieldset as UntypedFormGroup, ToCEntryType.FieldSet)); - }); - } - return { - form: form, - id: form.get('id').value, - label: form.get('title').value, - numbering: '', - subEntries:tempResult, - subEntriesType: sections &§ions.length? ToCEntryType.Section: ToCEntryType.FieldSet, - type: ToCEntryType.Section, - ordinal: form.get('ordinal').value - } - case ToCEntryType.FieldSet: - return { - form: form, - label:form.get('title').value, - id: form.get('id').value, - numbering:'s', - subEntries:[], - subEntriesType: ToCEntryType.Field, - type: ToCEntryType.FieldSet, - ordinal: form.get('ordinal').value - } + } else if (fieldsets && fieldsets.length) { + fieldsets.forEach(fieldset => { + tempResult.push(this._buildRecursivelyFieldSet(fieldset)); + }); + } + return { + // form: form, + id: item.id, + label: item.title, + numbering: '', + subEntries: tempResult, + subEntriesType: sections && sections.length ? ToCEntryType.Section : ToCEntryType.FieldSet, + type: ToCEntryType.Section, + ordinal: item.ordinal } } - private _sortByOrdinal(tocentries: ToCEntry[]){ + private _buildRecursivelyFieldSet(item: DescriptionTemplateFieldSet): ToCEntry { + if (!item) return null; + const tempResult: ToCEntry[] = []; + if (item && item.fields.length > 0) { + item.fields.forEach(field => { + tempResult.push(this._buildRecursivelyField(field)); + }); + } - if(!tocentries || !tocentries.length) return; + return { + // form: form, + id: item.id, + label: item.title, + numbering: 's', + subEntries: tempResult, + subEntriesType: ToCEntryType.Field, + type: ToCEntryType.FieldSet, + ordinal: item.ordinal + }; + } + + private _buildRecursivelyField(item: DescriptionTemplateField): ToCEntry { + if (!item) return null; + return { + // form: form, + id: item.id, + label: null, + numbering: 's', + subEntries: null, + subEntriesType: null, + type: ToCEntryType.Field, + ordinal: item.ordinal, + hidden: true + }; + } + + private _sortByOrdinal(tocentries: ToCEntry[]) { + + if (!tocentries || !tocentries.length) return; tocentries.sort(this._customCompare); - tocentries.forEach(entry=>{ + tocentries.forEach(entry => { this._sortByOrdinal(entry.subEntries); }); } - private _customCompare(a,b){ + private _customCompare(a, b) { return a.ordinal - b.ordinal; } - private _calculateNumbering(tocentries: ToCEntry[], depth:number[] = []){ - if(!tocentries || !tocentries.length){ + private _calculateNumbering(tocentries: ToCEntry[], depth: number[] = []) { + if (!tocentries || !tocentries.length) { return; } - let prefixNumbering = depth.length? depth.join('.'): ''; + let prefixNumbering = depth.length ? depth.join('.') : ''; - if(depth.length) prefixNumbering = prefixNumbering+"."; - tocentries.forEach((entry,i)=>{ - entry.numbering = prefixNumbering + (i+1); - this._calculateNumbering(entry.subEntries, [...depth, i+1]) + if (depth.length) prefixNumbering = prefixNumbering + "."; + tocentries.forEach((entry, i) => { + entry.numbering = prefixNumbering + (i + 1); + this._calculateNumbering(entry.subEntries, [...depth, i + 1]) }); } - getTocEntries(form): ToCEntry[] { - if (form == null) { return []; } + getTocEntries(descriptionTemplate: DescriptionTemplate): ToCEntry[] { + if (descriptionTemplate == null) { return []; } const result: ToCEntry[] = []; //build parent pages - (form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { - result.push({ - id: i+'id', - label: pageElement.get('title').value, + descriptionTemplate.definition.pages.forEach((pageElement, i) => { + const tocEntry: ToCEntry = { + // id: i + 'id', + id: pageElement.id, + label: pageElement.title, type: ToCEntryType.Page, - form: pageElement, + // form: pageElement, numbering: (i + 1).toString(), subEntriesType: ToCEntryType.Section, - subEntries:[], - ordinal: pageElement.get('ordinal').value - } as ToCEntry) - }); + subEntries: [], + ordinal: pageElement.ordinal + }; + const sections = descriptionTemplate.definition.sections.filter(x => x.page == pageElement.id); - - result.forEach((entry,i)=>{ - - const sections = entry.form.get('sections') as UntypedFormArray; - - sections.controls.forEach(section=>{ - const tempResults = this._buildRecursively(section as UntypedFormGroup,ToCEntryType.Section); - entry.subEntries.push(tempResults); + sections.forEach(section => { + const tempResults = this._buildRecursivelySection(section); + tocEntry.subEntries.push(tempResults); }); - + result.push(tocEntry) }); this._sortByOrdinal(result); @@ -442,53 +444,53 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges } - onToCentrySelected(entry: ToCEntry = null, execute: boolean = true){ - if(!this.isSelecting) { + onToCentrySelected(entry: ToCEntry = null, execute: boolean = true) { + if (!this.isSelecting) { this.isSelecting = true; this.tocentrySelected = entry; - this.entrySelected.emit({entry: entry, execute: execute}); + this.entrySelected.emit({ entry: entry, execute: execute }); setTimeout(() => { this.isSelecting = false; }, 600); } } - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries || !tocentries.length){ + private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { + if (!tocentries || !tocentries.length) { return null; } - let tocEntryFound = tocentries.find(entry=>entry.id === id); + let tocEntryFound = tocentries.find(entry => entry.id === id); - if(tocEntryFound){ + if (tocEntryFound) { return tocEntryFound; } - for(let entry of tocentries){ + for (let entry of tocentries) { const result = this._findTocEntryById(id, entry.subEntries); - if(result){ + if (result) { tocEntryFound = result; break; } } - return tocEntryFound? tocEntryFound: null; + return tocEntryFound ? tocEntryFound : null; } /** * Get all filedsets in a tocentry array; * @param entries Tocentries to search in * @returns The tocentries that are Fieldsets provided in the entries */ - private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{ + private _getAllFieldSets(entries: ToCEntry[]): ToCEntry[] { - const fieldsets:ToCEntry[] = []; - if(!entries || !entries.length) return fieldsets; + const fieldsets: ToCEntry[] = []; + if (!entries || !entries.length) return fieldsets; - entries.forEach(e=>{ - if(e.type === ToCEntryType.FieldSet){ + entries.forEach(e => { + if (e.type === ToCEntryType.FieldSet) { fieldsets.push(e); - }else{ + } else { fieldsets.push(...this._getAllFieldSets(e.subEntries)); } }); @@ -496,8 +498,8 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges } - public hasVisibleInvalidFields():boolean { - if(!this.internalTable || !this.tocentries){ + public hasVisibleInvalidFields(): boolean { + if (!this.internalTable || !this.tocentries) { return false; } return this.tocentries.some(e => this.internalTable.invalidChildsVisible(e)); diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts similarity index 58% rename from dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module.ts rename to dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts index 76b5706bb..2a7bc3749 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts @@ -1,15 +1,15 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {TableOfContents} from './table-of-contents'; import {RouterModule} from '@angular/router'; import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal'; -import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service'; import { MatIconModule } from '@angular/material/icon'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { TableOfContentsComponent } from './table-of-contents.component'; @NgModule({ imports: [CommonModule, RouterModule, MatIconModule], - declarations: [TableOfContents, TableOfContentsInternal], - exports: [TableOfContents], + declarations: [TableOfContentsComponent, TableOfContentsInternal], + exports: [TableOfContentsComponent], providers: [VisibilityRulesService] }) export class TableOfContentsModule { } diff --git a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-criteria.component.ts b/dmp-frontend/src/app/ui/description/listing/criteria/dataset-criteria.component.ts index a05881fc8..8181f59f8 100644 --- a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-criteria.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/criteria/dataset-criteria.component.ts @@ -1,42 +1,20 @@ -import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { OrganisationCriteria } from '@app/core/query/organisation/organisation-criteria'; import { RequestItem } from '@app/core/query/request-item'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { UserCriteria } from '@app/core/query/user/user-criteria'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; +import { AuthService } from '@app/core/services/auth/auth.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { OrganisationService } from '@app/core/services/organisation/organisation.service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { DatasetUploadDialogue } from '@app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component'; import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; @Component({ selector: 'app-dataset-criteria-component', @@ -178,11 +156,11 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O .pipe(takeUntil(this._destroyed)) .subscribe(x => this.controlModified()); this.formGroup.get('allVersions').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); this.formGroup.get('tags').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); this.formGroup.get('grantStatus').valueChanges .pipe(takeUntil(this._destroyed)) .subscribe(x => this.controlModified()); @@ -239,11 +217,11 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O if (this.isPublic) { return this.datasetService.getDatasetProfiles(datasetTemplateRequestItem); } else { - return this.datasetService.getDatasetProfilesUsedPaged(datasetTemplateRequestItem).pipe(map(x => x.data)); + return this.datasetService.getDatasetProfilesUsedPaged(datasetTemplateRequestItem).pipe(map(x => x.data)); } } - filterDmps(value: string): Observable> { + filterDmps(value: string): Observable { const fields: Array = new Array(); fields.push('asc'); @@ -253,7 +231,7 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O // dmpDataTableRequest.criteria.like = value; // return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete"); // } else { - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); + const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); dmpDataTableRequest.criteria = new DmpCriteria(); dmpDataTableRequest.criteria.like = value; if (this.isPublic) { diff --git a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html b/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html deleted file mode 100644 index f631c3a39..000000000 --- a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html +++ /dev/null @@ -1,42 +0,0 @@ -
-
-
-

{{'DATASET-UPLOAD.TITLE' | translate}}

-
-
- - -
-
-
- - - - - - - - - - - - - {{datasetProfile.label}} - - - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss b/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss deleted file mode 100644 index c066ed1b5..000000000 --- a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss +++ /dev/null @@ -1,21 +0,0 @@ -.confirmation-dialog { - .confirmation-message { - padding-bottom: 20px; - } - - .hidden { - display: none; - } - - .uploadButton { - float: right; - } - - .col-md-6 { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - margin: -4px; - } -} diff --git a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts b/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts deleted file mode 100644 index 307907fcd..000000000 --- a/dmp-frontend/src/app/ui/description/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts +++ /dev/null @@ -1,157 +0,0 @@ - -import { Component, Inject, OnInit } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'dataset-upload-dialogue', - templateUrl: './dataset-upload-dialogue.component.html', - styleUrls: ['./dataset-upload-dialogue.component.scss'] -}) -export class DatasetUploadDialogue extends BaseCriteriaComponent implements OnInit { - - public dialogueCriteria: any; - datasetTitle: string; - dmp: DmpModel; - datasetProfile: DatasetProfileModel; - availableProfiles: DatasetProfileModel[] = []; - - dmpAutoCompleteConfiguration = { - filterFn: (x, excluded) => this.filterDmps(x).pipe(map(x => x.data)), - initialItems: (extraData) => this.filterDmps('').pipe(map(x => x.data)), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - constructor( - public dialogRef: MatDialogRef, - public dmpService: DmpService, - private datasetWizardService: DatasetWizardService, - @Inject(MAT_DIALOG_DATA) public data: any, - ) { super(new ValidationErrorModel()); } - - ngOnInit() { - super.ngOnInit(); - if (this.dialogueCriteria == null) { this.dialogueCriteria = {}; } - if (!this.data.dmpSearchEnabled) { - this.dialogueCriteria = this.data.criteria; - this.dmp = this.dialogueCriteria.dmpIds[0]; - this.loadDatasetProfiles(); - } - } - - cancel() { - this.data.success = false; - this.dialogRef.close(this.data) - } - - confirm() { - this.data.success = true; - this.data.datasetTitle = this.datasetTitle; - this.data.dmpId = this.dmp.id; - this.data.datasetProfileId = this.datasetProfile.id; - this.dialogRef.close(this.data); - } - - uploadFile(event) { - const fileList: FileList = event.target.files - this.data.fileList = fileList; - if (this.data.fileList.length > 0) { - this.datasetTitle = fileList.item(0).name; - } - } - - filterDmps(value: string): Observable> { - const fields: Array = new Array(); - fields.push('asc'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = value; - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); - } - - controlModified(): void { - this.loadDatasetProfiles(); - if (!this.dmp) { - this.availableProfiles = []; - } - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.dialogueCriteria.like == null || this.dialogueCriteria.like.length === 0 || this.dialogueCriteria.like.length > 2) - ) { - this.refreshCallback(); - } - } - - loadDatasetProfiles() { - const datasetProfileRequestItem: RequestItem = new RequestItem(); - datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - if (this.dmp) { - datasetProfileRequestItem.criteria.id = this.dmp.id; - } - if (datasetProfileRequestItem.criteria.id) { - this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.availableProfiles = items; - if (this.availableProfiles.length === 1) { - this.datasetProfile = this.availableProfiles[0]; - } - }); - } - } - - setCriteriaDialogue(criteria: DatasetCriteria): void { - this.dialogueCriteria = criteria; - } - - disableButton() { - if (!(this.data.fileList.length > 0) || !this.dmp) { - return true; - } - else { - return false; - } - } - - disableDatasetName() { - if (!(this.data.fileList.length > 0)) { - return true; - } - else { - return false; - } - } - - disableDmpSearch() { - if (!(this.data.fileList.length > 0) || !this.data.dmpSearchEnabled) { - return true; - } - else { - return false; - } - } - - disableDatasetProfile() { - if (!this.dmp || (!this.data.dmpSearchEnabled && !(this.data.fileList.length > 0)) || (!this.data.dmpSearchEnabled && this.availableProfiles.length === 1)) { - return true; - } - else { - return false; - } - } -} diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.component.html b/dmp-frontend/src/app/ui/description/listing/description-listing.component.html index 3141e10ae..142839cc1 100644 --- a/dmp-frontend/src/app/ui/description/listing/description-listing.component.html +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.component.html @@ -63,7 +63,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts index 4d2154b91..772b95841 100644 --- a/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts @@ -9,12 +9,12 @@ import { ActivatedRoute, Params, Router } from '@angular/router'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; -import { Description, DescriptionReference } from '@app/core/model/description/description'; +import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; import { FileFormat } from '@app/core/model/file/file-format.model'; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { Reference } from '@app/core/model/reference/reference'; import { DescriptionLookup } from '@app/core/query/description.lookup'; import { DmpLookup } from '@app/core/query/dmp.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; @@ -24,14 +24,12 @@ import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { StartNewDmpDialogComponent } from '@app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; +import { StartNewDmpDialogComponent } from '@app/ui/dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component'; // import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseComponent } from '@common/base/base.component'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; @@ -71,14 +69,12 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit order = RecentActivityOrder; dmpText: string; descriptionText: string; - fileFormats: FileFormat[] = []; constructor( private descriptionService: DescriptionService, private router: Router, private route: ActivatedRoute, public dialog: MatDialog, - private dmpService: DmpService, private language: TranslateService, private authService: AuthService, public enumUtils: EnumUtils, @@ -94,9 +90,11 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit this.matomoService.trackPageView('Descriptions'); this.isPublic = this.router.url === '/explore-descriptions'; if (this.isPublic) { - this.formGroup.get('order').setValue(this.order.DATASETPUBLISHED); + //TODO: refactor + // this.formGroup.get('order').setValue(this.order.DATASETPUBLISHED); } else { - this.formGroup.get('order').setValue(this.order.MODIFIED); + //TODO: refactor + // this.formGroup.get('order').setValue(this.order.MODIFIED); } if (!this.isPublic && !this.authService.currentAccountIsAuthenticated()) { this.router.navigateByUrl("/explore"); @@ -139,9 +137,6 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit this.lookup.page = { size: this.pageSize, offset: 0 }; this.refresh(this.lookup); }); - - this.descriptionService.getExportFormats().pipe(takeUntil(this._destroyed)) - .subscribe(result => this.fileFormats = result); } ngAfterContentChecked(): void { diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.module.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.module.ts new file mode 100644 index 000000000..920e30ca1 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { DescriptionListingComponent } from '@app/ui/description/listing/description-listing.component'; +import { DescriptionListingItemComponent } from '@app/ui/description/listing/listing-item/description-listing-item.component'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DescriptionListingRoutingModule } from './description-listing.routing'; +import { DescriptionCopyDialogModule } from '../description-copy-dialog/description-copy-dialog.module'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + FormattingModule, + DescriptionCopyDialogModule, + DescriptionListingRoutingModule + ], + declarations: [ + DescriptionListingComponent, + DescriptionListingItemComponent, + ], + exports: [ + ] +}) +export class DescriptionListingModule { } diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts new file mode 100644 index 000000000..38230cad5 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts @@ -0,0 +1,30 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { AuthGuard } from '@app/core/auth-guard.service'; +import { DescriptionListingComponent } from './description-listing.component'; + +const routes: Routes = [ + { + path: '', + component: DescriptionListingComponent, + // canActivate: [AuthGuard], + data: { + breadcrumb: true + }, + }, + { + path: 'dmp/:dmpId', + component: DescriptionListingComponent, + canActivate: [AuthGuard], + data: { + breadcrumb: true + }, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [] +}) +export class DescriptionListingRoutingModule { } 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 79ed9bbe9..0f7f4badb 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 @@ -24,7 +24,7 @@
+
\ No newline at end of file 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 ffd5a95ee..f4c5e3bc9 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 @@ -1,34 +1,31 @@ import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { UntypedFormControl } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; -import { Role } from '@app/core/common/enum/role'; +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'; +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 { 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'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; +import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component'; import { BaseComponent } from '@common/base/base.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; import * as FileSaver from 'file-saver'; import { takeUntil } from 'rxjs/operators'; import { DescriptionStatus } from '../../../../core/common/enum/description-status'; -import { Description } from '@app/core/model/description/description'; -import { DescriptionService } from '@app/core/services/description/description.service'; -import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { Guid } from '@common/types/guid'; -import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; -import { DmpUser } from '@app/core/model/dmp/dmp'; -import { DmpService, DmpServiceNew } from '@app/core/services/dmp/dmp.service'; -import { ReferenceService } from '@app/core/services/reference/reference.service'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; import { DescriptionCopyDialogComponent } from '../../description-copy-dialog/description-copy-dialog.component'; -import { FileFormat } from '@app/core/model/file/file-format.model'; @Component({ selector: 'app-description-listing-item-component', @@ -40,7 +37,6 @@ export class DescriptionListingItemComponent extends BaseComponent implements On @Input() description: Description; @Input() showDivider: boolean = true; @Input() isPublic: boolean = false; - @Input() fileFormats: FileFormat[] = []; @Output() onClick: EventEmitter = new EventEmitter(); isDraft: boolean; @@ -61,11 +57,11 @@ export class DescriptionListingItemComponent extends BaseComponent implements On private uiNotificationService: UiNotificationService, private lockService: LockService, private location: Location, - private httpClient: HttpClient, private matomoService: MatomoService, private fileUtils: FileUtils, - public dmpService: DmpServiceNew, - public referenceService: ReferenceService + public dmpService: DmpService, + public referenceService: ReferenceService, + public fileTransformerService: FileTransformerService ) { super(); } @@ -99,11 +95,11 @@ export class DescriptionListingItemComponent extends BaseComponent implements On getItemLink(): string[] { // return this.isPublic ? [`/descriptions/publicEdit/${this.description.id}`] : [`/descriptions/edit/${this.description.id}`]; - return this.isPublic ? ['/descriptions/publicOverview/' + this.description.id] : ['/descriptions/overview/' + this.description.id]; + return this.isPublic ? ['/descriptions/overview/public/' + this.description.id] : ['/descriptions/overview/' + this.description.id]; } getDmpLink(): string[] { - return this.isPublic ? [`/explore-plans/publicOverview/${this.description.dmp.id}`] : [`/plans/edit/${this.description.dmp.id}`]; + return this.isPublic ? [`/explore-plans/overview/public/${this.description.dmp.id}`] : [`/plans/edit/${this.description.dmp.id}`]; } // downloadPDF(description: Description): void { 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 967bf04a8..10fdb6144 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 @@ -117,28 +117,11 @@ {{ 'DESCRIPTION-OVERVIEW.ACTIONS.EXPORT' | 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 16eb10feb..6e23e99fb 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 @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'; import { BaseComponent } from '@common/base/base.component'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { UntypedFormControl } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; @@ -14,27 +13,25 @@ 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'; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { Reference } from '@app/core/model/reference/reference'; import { AuthService } from '@app/core/services/auth/auth.service'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { DescriptionService } from '@app/core/services/description/description.service'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; -import { LockService } from '@app/core/services/lock/lock.service'; +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 { ReferenceService } from '@app/core/services/reference/reference.service'; -import { UserService } from '@app/core/services/user/user.service'; +import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; -import { filter, take, takeUntil } from 'rxjs/operators'; +import * as FileSaver from 'file-saver'; +import { filter, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { DescriptionCopyDialogComponent } from '../description-copy-dialog/description-copy-dialog.component'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import * as FileSaver from 'file-saver'; -import { FileFormat } from '@app/core/model/file/file-format.model'; @Component({ @@ -59,27 +56,23 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni referenceTypeEnum = ReferenceType; dmpStatusEnum = DmpStatus; dmpUserRoleEnum = DmpUserRole; - fileFormats: FileFormat[] = []; constructor( private route: ActivatedRoute, private router: Router, private descriptionService: DescriptionService, - private translate: TranslateService, private authentication: AuthService, private dialog: MatDialog, private language: TranslateService, private uiNotificationService: UiNotificationService, private configurationService: ConfigurationService, - private oauth2DialogService: Oauth2DialogService, - private userService: UserService, - private dmpService: DmpServiceNew, + private dmpService: DmpService, public referenceService: ReferenceService, private location: Location, - private lockService: LockService, public enumUtils: EnumUtils, private matomoService: MatomoService, - private fileUtils: FileUtils + private fileUtils: FileUtils, + public fileTransformerService: FileTransformerService ) { super(); } @@ -128,7 +121,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni // this.users = this.description.dmp.users; // const breadCrumbs = []; // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" }); - // breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/publicOverview/' + this.description.id }); + // breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/public/' + this.description.id }); // this.breadCrumbs = observableOf(breadCrumbs); }, (error: any) => { if (error.status === 404) { @@ -140,8 +133,6 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni }); } }); - - this.descriptionService.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result); } checkLockStatus(id: Guid) { @@ -253,7 +244,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni dmpClicked(dmp: Dmp) { if (this.isPublicView) { - this.router.navigate(['/explore-plans/publicOverview/' + dmp.id]); + this.router.navigate(['/explore-plans/overview/public/' + dmp.id]); } else { this.router.navigate(['/plans/overview/' + dmp.id]); } diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts index 31a9bc4d8..690bd7481 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts @@ -1,22 +1,22 @@ import { NgModule } from '@angular/core'; import { FormattingModule } from '@app/core/formatting.module'; import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DescriptionCopyDialogModule } from '../description-copy-dialog/description-copy-dialog.module'; import { DescriptionOverviewComponent } from './description-overview.component'; +import { DescriptionOverviewRoutingModule } from './description-overview.routing'; @NgModule({ imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, - ExportMethodDialogModule, FormattingModule, - AutoCompleteModule + AutoCompleteModule, + DescriptionCopyDialogModule, + DescriptionOverviewRoutingModule ], declarations: [ DescriptionOverviewComponent diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts new file mode 100644 index 000000000..05cf0c095 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts @@ -0,0 +1,29 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { DescriptionOverviewComponent } from './description-overview.component'; + +const routes: Routes = [ + { + path: ':id', + component: DescriptionOverviewComponent, + data: { + breadcrumb: true, + title: 'GENERAL.TITLES.DATASET-OVERVIEW' + }, + }, + { + path: 'public/:publicId', + component: DescriptionOverviewComponent, + data: { + breadcrumb: true, + title: 'GENERAL.TITLES.DATASET-OVERVIEW' + }, + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [] +}) +export class DescriptionOverviewRoutingModule { } diff --git a/dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.html b/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.html similarity index 100% rename from dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.html rename to dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.html diff --git a/dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.scss b/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.scss rename to dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.scss diff --git a/dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.ts b/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.ts similarity index 58% rename from dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.ts rename to dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.ts index 0783b92bf..5fe33618f 100644 --- a/dmp-frontend/src/app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.ts +++ b/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.component.ts @@ -1,23 +1,21 @@ import { Component, Inject } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; -import { BaseComponent } from '@common/base/base.component'; +import { UntypedFormGroup } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { DmpStatus } from '@app/core/common/enum/dmp-status'; +import { Dmp } from '@app/core/model/dmp/dmp'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; +import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { map } from 'rxjs/operators'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { UntypedFormGroup } from '@angular/forms'; @Component({ - selector: 'app-start-new-dataset', - templateUrl: './start-new-dataset-dialog.component.html', - styleUrls: ['./start-new-dataset-dialog.component.scss'] + selector: 'app-start-new-description-dialog', + templateUrl: './start-new-description-dialog.component.html', + styleUrls: ['./start-new-description-dialog.component.scss'] }) -export class StartNewDatasetDialogComponent extends BaseComponent { +export class StartNewDescriptionDialogComponent extends BaseComponent { public isDialog: boolean = false; public formGroup: UntypedFormGroup; @@ -27,11 +25,11 @@ export class StartNewDatasetDialogComponent extends BaseComponent { initialItems: (extraData) => this.searchDmp(''), displayFn: (item) => this.getDatasetDisplay(item), titleFn: (item) => item['label'], - subtitleFn: (item) => {try{return this.language.instant('DATASET-WIZARD.FIRST-STEP.SUB-TITLE') + new Date(item['creationTime']).toISOString();}catch{return '-';}} + subtitleFn: (item) => { try { return this.language.instant('DATASET-WIZARD.FIRST-STEP.SUB-TITLE') + new Date(item['creationTime']).toISOString(); } catch { return '-'; } } }; constructor( - public dialogRef: MatDialogRef, + public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, public dialog: MatDialog, private language: TranslateService, @@ -62,14 +60,16 @@ export class StartNewDatasetDialogComponent extends BaseComponent { this.dialogRef.close(this.data); } - searchDmp(query: string): Observable { - const fields: Array = new Array(); - fields.push('-created'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = query; - dmpDataTableRequest.criteria.status = DmpStatus.Draft; - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete").pipe(map(x => x.data)); + searchDmp(query: string): Observable { + // TODO refactor + // const fields: Array = new Array(); + // fields.push('-created'); + // const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); + // dmpDataTableRequest.criteria = new DmpCriteria(); + // dmpDataTableRequest.criteria.like = query; + // dmpDataTableRequest.criteria.status = DmpStatus.Draft; + // return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete").pipe(map(x => x.data)); + return null; } getDatasetDisplay(item: any): string { diff --git a/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.module.ts b/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.module.ts new file mode 100644 index 000000000..2afb2699f --- /dev/null +++ b/dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { StartNewDescriptionDialogComponent } from './start-new-description-dialog.component'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + FormattingModule, + ], + declarations: [ + StartNewDescriptionDialogComponent, + ], + exports: [ + StartNewDescriptionDialogComponent, + ] +}) +export class StartNewDescriptionDialogModule { } diff --git a/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.html b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.html new file mode 100644 index 000000000..8b33f023b --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.html @@ -0,0 +1,55 @@ +
+
+
{{'DMP-CLONE-DIALOG.TITLE' | translate}}
+ close +
+ +
+
+
{{'DMP-CLONE-DIALOG.FIELDS.LABEL' | translate}}*
+
+
+ + + {{formGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+ +
+
+
{{'DMP-CLONE-DIALOG.FIELDS.DESCRIPTION' | translate}}
+
+
{{'DMP-CLONE-DIALOG.FIELDS.DESCRIPTION-HINT' | translate}}
+
+ + +
+
+
+
+
{{'DMP-CLONE-DIALOG.FIELDS.DESCRIPTIONS' | translate}}
+
+
+
{{'DMP-CLONE-DIALOG.FIELDS.DESCRIPTIONS-HINT' | translate}}
+
+
+ + + + {{description.label}} + + + +
+
+
{{'DMP-CLONE-DIALOG.NO-DESCRIPTIONS' | translate}}
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.scss b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.scss similarity index 96% rename from dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.scss rename to dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.scss index d2a67e117..28605e240 100644 --- a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.scss +++ b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.scss @@ -1,4 +1,6 @@ .clone-dialog { + padding: 1.5rem; + .heading { text-align: left; font-weight: 700; @@ -33,7 +35,7 @@ } .cancel-btn { - min-width: 101px; + min-width: 101px; height: 43px; background: #ffffff; border: 1px solid #b5b5b5; diff --git a/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.ts new file mode 100644 index 000000000..a42799b5d --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.component.ts @@ -0,0 +1,64 @@ +import { Component, Inject } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { CloneDmpPersist, Dmp } from '@app/core/model/dmp/dmp'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { BaseComponent } from '@common/base/base.component'; +import { TranslateService } from '@ngx-translate/core'; +import { takeUntil } from 'rxjs/operators'; +import { DmpCloneDialogEditorModel } from './dmp-clone-dialog.editor.model'; + +@Component({ + selector: 'app-dmp-clone-dialog', + templateUrl: './dmp-clone-dialog.component.html', + styleUrls: ['./dmp-clone-dialog.component.scss'] +}) +export class CloneDmpDialogComponent extends BaseComponent { + + dmp: Dmp; + editorModel: DmpCloneDialogEditorModel; + formGroup: UntypedFormGroup; + + constructor( + public dialogRef: MatDialogRef, + private dmpService: DmpService, + private uiNotificationService: UiNotificationService, + private language: TranslateService, + @Inject(MAT_DIALOG_DATA) public data: any + ) { + super(); + this.dmp = data.dmp; + } + + ngOnInit() { + this.editorModel = new DmpCloneDialogEditorModel().fromModel(this.data.dmp); + this.formGroup = this.editorModel.buildForm(); + } + + hasDescriptions() { + return this.dmp.descriptions.length > 0; + } + + close() { + this.dialogRef.close(null); + } + + cancel() { + this.dialogRef.close(null); + } + + confirm() { + if (!this.formGroup.valid) { return; } + const value: CloneDmpPersist = this.formGroup.value; + this.dmpService.clone(value).pipe(takeUntil(this._destroyed)).subscribe( + dmp => this.dialogRef.close(dmp), + error => this.onCallbackError(error) + ); + + } + + onCallbackError(error: any) { + this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); + } +} diff --git a/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.editor.model.ts b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.editor.model.ts new file mode 100644 index 000000000..093b2ff2f --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.editor.model.ts @@ -0,0 +1,50 @@ +import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; +import { CloneDmpPersist, Dmp } from "@app/core/model/dmp/dmp"; +import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; +import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; +import { Validation, ValidationContext } from '@common/forms/validation/validation-context'; +import { Guid } from "@common/types/guid"; + +export class DmpCloneDialogEditorModel implements CloneDmpPersist { + id: Guid; + label: string; + description: String; + descriptions: Guid[] = []; + + public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); + protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); + + constructor() { } + + public fromModel(item: Dmp): DmpCloneDialogEditorModel { + if (item) { + this.id = item.id; + this.label = item.label; + this.description = item.description; + if (item.descriptions) { this.descriptions = item.descriptions.map(x => x.id); } + } + return this; + } + + buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { + if (context == null) { context = this.createValidationContext(); } + + return this.formBuilder.group({ + id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], + label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], + description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], + descriptions: [{ value: this.descriptions, disabled: disabled }, context.getValidation('descriptions').validators], + }); + } + + createValidationContext(): ValidationContext { + const baseContext: ValidationContext = new ValidationContext(); + const baseValidationArray: Validation[] = new Array(); + baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); + baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); + baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); + baseValidationArray.push({ key: 'descriptions', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptions')] }); + baseContext.validation = baseValidationArray; + return baseContext; + } +} diff --git a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.module.ts b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.module.ts similarity index 71% rename from dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.module.ts rename to dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.module.ts index a68cbe124..e2040ebd5 100644 --- a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.module.ts +++ b/dmp-frontend/src/app/ui/dmp/clone-dialog/dmp-clone-dialog.module.ts @@ -1,15 +1,15 @@ import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CommonUiModule } from '@common/ui/common-ui.module'; -import { CloneDialogComponent } from './clone-dialog.component'; +import { CloneDmpDialogComponent } from './dmp-clone-dialog.component'; import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; import {RichTextEditorModule} from "@app/library/rich-text-editor/rich-text-editor.module"; @NgModule({ imports: [CommonUiModule, FormsModule, ReactiveFormsModule, AutoCompleteModule, RichTextEditorModule], - declarations: [CloneDialogComponent], - exports: [CloneDialogComponent] + declarations: [CloneDmpDialogComponent], + exports: [CloneDmpDialogComponent] }) -export class CloneDialogModule { +export class CloneDmpDialogModule { constructor() { } } diff --git a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.html b/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.html deleted file mode 100644 index ef4ae836c..000000000 --- a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.html +++ /dev/null @@ -1,77 +0,0 @@ -
-
-
{{'DMP-EDITOR.TITLE.CLONE-DMP' | translate}}
-
{{'DMP-EDITOR.TITLE.NEW-VERSION' | translate}}
- close -
- -
-
-
{{'DMP-EDITOR.FIELDS.NAME' | translate}}*
-
- - - - {{this.data.formGroup.get('label').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
- -
-
-
{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}
-
{{'DMP-EDITOR.MAIN-INFO.HINT' | translate}}
-
- - -
-
-
- -
-
-
{{'DMP-EDITOR.FIELDS.TEMPLATES' | translate}}
- - {{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}} - - - - {{data.formGroup.get('profiles').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
- -
-
-
{{'DMP-EDITOR.FIELDS.DESCRIPTIONS' | translate}}
-
-
{{'DATASET-LISTING.SELECT-DESCRIPTIONS-TO-CLONE' | translate}}
- - - - {{dataset.label}} - - - -
-
-
{{'DATASET-LISTING.SELECT-DESCRIPTIONS-NONE' | translate}}
-
-
-
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.ts deleted file mode 100644 index 804b42942..000000000 --- a/dmp-frontend/src/app/ui/dmp/clone/clone-dialog/clone-dialog.component.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { Component, Inject } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { DatasetPreviewDialogComponent } from '../../dataset-preview/dataset-preview-dialog.component'; - -@Component({ - selector: 'app-clone-dialog', - templateUrl: './clone-dialog.component.html', - styleUrls: ['./clone-dialog.component.scss'] -}) -export class CloneDialogComponent extends BaseComponent { - - agreePrivacyPolicyNames = false; - initialItems = []; - profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - - constructor( - public dialogRef: MatDialogRef, - private dialog: MatDialog, - private dmpService: DmpService, - @Inject(MAT_DIALOG_DATA) public data: any - ) { - super(); - - this.selectionChanged(this.initialItems) - - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'], - popupItemActionIcon: 'visibility' - }; - - if (this.data.isNewVersion) { - // this.data.formGroup.get('label').disable(); - } - } - - close() { - this.dialogRef.close(false); - } - - cancel() { - this.dialogRef.close(false); - } - - confirm() { - this.dialogRef.close(true); - } - - selectionChanged(selectedItems) { - this.data.formGroup.removeControl('datasets'); - this.data.formGroup.addControl('datasets', new UntypedFormBuilder().array(new Array())); - if (selectedItems && selectedItems.selectedOptions && selectedItems.selectedOptions.selected.length > 0) { - selectedItems.selectedOptions.selected.forEach(element => { - (this.data.formGroup.get('datasets')).push(new UntypedFormBuilder().group({ id: element.value })); - }); - } - } - - hasDatasets() { - return this.data.datasets.length > 0; - } - - filterProfiles(value: string): Observable { - const request = new DataTableRequest(null, null, { fields: ['+label'] }); - const criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this.dmpService.searchDmpBlueprints(request); - } - - onPreviewTemplate(event) { - const dialogRef = this.dialog.open(DatasetPreviewDialogComponent, { - width: '590px', - minHeight: '200px', - restoreFocus: false, - data: { - template: event - }, - panelClass: 'custom-modalbox' - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - let profiles = this.data.formGroup.get('profiles').value; - profiles.push(event); - this.data.formGroup.get('profiles').setValue(profiles); - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'], - popupItemActionIcon: 'visibility' - }; - } - }); - } - -} diff --git a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html deleted file mode 100644 index ed8b1a92e..000000000 --- a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html +++ /dev/null @@ -1,175 +0,0 @@ -
-
-
- -
-
-
-
-
-
{{'DMP-EDITOR.TITLE.CLONE-DMP' | translate}}
-
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
-
- -
- -
-
-
-
-
-
- -
-
-
-
-
- -
{{'DATASET-LISTING.SELECT-DESCRIPTIONS-TO-CLONE' | translate}}
-
{{ dataset.value.label }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
-
{{'DATASET-LISTING.TOOLTIP.PART-OF' | translate}} -
{{'DATASET-LISTING.TOOLTIP.DMP' | translate}}
-
-
{{ formGroup.get('label').value }}
- -
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
-
-
    -
  1. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (4)
  2. -
  3. {{'DMP-EDITOR.STEPPER.FUNDING-INFO' | translate}} (3)
  4. -
  5. {{'DMP-EDITOR.STEPPER.LICENSE-INFO' | translate}} (6)
  6. -
  7. {{'DMP-EDITOR.STEPPER.DESCRIPTION-INFO' | translate}}
  8. -
  9. -
    {{'DMP-EDITOR.STEPPER.DATASET' | translate}}
    - -
    {{'DMP-EDITOR.STEPPER.DATASET' | translate}}: {{ dataset.get('label').value }}
    - close -
    - check{{'TYPES.DATASET-STATUS.FINALISED' | translate}} -
    - -
    - -
  10. -
-
-
- -
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
-
- add -
{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}}
-
-
-
-
- - - - - -
- -
-
-
-
-
-
- - diff --git a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.scss b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.scss deleted file mode 100644 index 5a9122ecf..000000000 --- a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.scss +++ /dev/null @@ -1,421 +0,0 @@ -form { - height: calc(100vh - 124px); -} - -a { - color: #000000; -} - -a:hover { - color: var(--primary-color-3); -} - -.main-content { - height: 100vh !important; -} - -.fixed-editor-header { - // position: fixed; - // width: calc(100% - 310px); - z-index: 3; - background-color: whitesmoke; -} - -.editor-header { - height: 64px; - background: var(--unnamed-color-var(--primary-color)) 0% 0% no-repeat padding-box; - background: var(--primary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #00000029; - padding: 0.6rem; - margin: 30px 0px 0px 0px; - border-radius: 4px; - opacity: 1; - - .info { - flex: 2; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } -} - -.dataset-editor-header { - height: 113px; - background: var(--unnamed-color-var(--primary-color)) 0% 0% no-repeat padding-box; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #00000029; - padding: 0.6rem; - margin: 30px 0px 0px 0px; - border-radius: 4px; - opacity: 1; - - .info { - flex: 2; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } -} - -.editor-content { - .form { - // position: relative; - // left: 362px; - // width: calc(100% - 366px); - - position: relative; - left: 362px; - width: calc(100% - 366px); - overflow-y: auto; - height: calc(100vh - 218px); - } -} - -.title { - text-align: left; - font-weight: 400; - font-size: 14px; - color: #ffffff; - opacity: 0.75; -} - -.dataset-title { - text-align: left; - letter-spacing: 0px; - color: #212121; - opacity: 0.9; - font-size: 14px; - font-weight: 400; -} - -.subtitle { - text-align: left; - color: #ffffff; - font-weight: 700; - font-size: 16px; - opacity: 1; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.dataset-subtitle { - text-align: left; - letter-spacing: 0px; - color: #212121; - font-weight: 700; - font-size: 16px; - opacity: 0.9; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.discard-btn { - background: transparent; - border: 1px solid #ffffff; - color: white; - border-radius: 30px; - opacity: 1; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; -} - -.save-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - font-weight: 700; - color: var(--primary-color); - cursor: pointer; -} - -.dataset-discard-btn { - border: 1px solid #212121; - border-radius: 30px; - opacity: 1; - background-color: transparent; - font-weight: 700; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; -} - -.dataset-save-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; -} - -.dataset-part-of { - display: flex; - flex-direction: row; - text-align: left; - font-weight: 400; - font-family: "Roboto", sans-serif; - font-size: 0.875rem; - align-items: center; - letter-spacing: 0px; - color: #3d3d3d; - padding: 0; -} - -.changes { - font-weight: 400; - color: #ffffff; -} - -.dataset-changes { - font-weight: 400; - color: #000000; -} - -.dataset-stepper { - position: fixed; - // height: 100%; - display: flex; - flex-direction: column; - height: calc(100vh - 240px); - overflow-y: auto; -} - -.dmp-stepper { - position: fixed; - // height: 100%; - display: flex; - flex-direction: column; - height: calc(100vh - 190px); - overflow-y: auto; -} - -.stepper-title { - text-align: left; - font-weight: 300; - font-size: 20px; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; - margin: 2.875rem 0rem 2.875rem 0rem; - padding-left: 1rem; -} - -.stepper-list li { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - padding: 0.3rem 0.1rem; - opacity: 0.6; - cursor: pointer; - max-width: 290px; -} - -.stepper-list .active { - color: #212121; - font-weight: 700; - opacity: 1; -} - -.stepper-list .active-dataset { - color: #212121; - font-weight: 700; - opacity: 1; - .dataset-tag { - width: 73px; - height: 27px; - background-color: var(--secondary-color); - color: #5d5d5d; - border-radius: 4px; - font-weight: 400; - font-size: 14px; - justify-content: center; - display: flex; - align-items: center; - } -} - -.stepper-options { - // flex-grow: 1; -} - -.stepper-actions { - display: flex; - padding-left: 1rem; - margin-top: auto; - margin-bottom: 0.5rem; - // margin-top: 5rem; - // flex-grow: 8; -} - -.stepper-btn { - border-radius: 30px; - opacity: 1; - width: 154px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - font-size: 14px; -} - -.previous { - color: #212121; - background: #f5f5f5 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border: 2px solid #212121; - font-weight: 500; - cursor: pointer; -} - -.next { - background: var(--primary-color) 0% 0% no-repeat padding-box; - color: white; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 400; - cursor: pointer; -} - -.dataset-next { - background: var(--secondary-color) 0% 0% no-repeat padding-box; - color: #212121; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 700; - cursor: pointer; -} - -.previous-disabled { - border: 1px solid #b5b5b5; - color: #b5b5b5; - cursor: auto !important; -} - -.next-disabled { - background: #cbcbcb 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - color: white; - cursor: auto !important; -} - -.dataset-list { - list-style-type: none; - padding-left: 0px; -} - -.dmp-label { - min-width: 67px; - height: 37px; - background: var(--primary-color) 0% 0% no-repeat padding-box; - color: white; - border-radius: 4px; - opacity: 1; - display: flex; - align-items: center; - justify-content: center; -} - -.dmp-title { - text-align: left; - font-weight: 500; - font-family: "Roboto", sans-serif; - font-size: 1rem; - opacity: 0.81; - padding-top: 0.75rem; - padding-bottom: 0.55rem; - color: #212121; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.status-icon { - font-size: 1.2em; - color: #a7a7a7; - vertical-align: text-top; -} - -.cursor-default { - cursor: default; -} - -.finalized-label { - display: flex; - align-items: center; - padding-right: 1rem; - font-weight: 400; - font-size: 0.875rem; -} - -// ::ng-deep .mat-tab-labels { -// justify-content: space-between; -// } - -// ::ng-deep .mat-tab-label-content { -// text-transform: uppercase; -// } - -::ng-deep .mat-ink-bar { - background-color: var(--primary-color-3) !important; - // background-color: #0070c0 !important; -} - -/////// Old version style - -// .menu-item { -// width: 248px; -// } - -// .more-horiz { -// font-size: 28px; -// color: #aaaaaa; -// } - -// .clone-dmp { -// height: 3.5em; -// } - -// .clone-mode { -// // line-height: 2em; -// text-transform: uppercase; -// color: #089dbb; -// font-weight: 400; -// align-self: center; -// } - -// .clone-mode-text { -// color: black; -// align-self: center; -// } - -// .more-icon :hover { -// color: var(--primary-color-3); -// } - -// ::ng-deep .mat-tab-labels { -// justify-content: space-between; -// } - -// ::ng-deep .mat-tab-label-content { -// text-transform: uppercase; -// } - -// ::ng-deep .mat-ink-bar { -// background-color: var(--primary-color-3) !important; -// } diff --git a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts deleted file mode 100644 index b413710b0..000000000 --- a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts +++ /dev/null @@ -1,382 +0,0 @@ - -import { HttpErrorResponse } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; -import { UntypedFormGroup, UntypedFormControl, UntypedFormBuilder, UntypedFormArray } from '@angular/forms'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { FunderFormModel } from '@app/ui/dmp/editor/grant-tab/funder-form-model'; -import { GrantTabModel } from '@app/ui/dmp/editor/grant-tab/grant-tab-model'; -import { ProjectFormModel } from '@app/ui/dmp/editor/grant-tab/project-form-model'; -import { DmpWizardEditorModel } from '@app/ui/dmp/wizard/dmp-wizard-editor.model'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { BaseComponent } from '@common/base/base.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { ExtraPropertiesFormModel } from '../editor/general-tab/extra-properties-form.model'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { Role } from '@app/core/common/enum/role'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpEditorModel } from '../editor/dmp-editor.model'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { MatDialog } from '@angular/material/dialog'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { Guid } from '@common/types/guid'; -import { nameof } from 'ts-simple-nameof'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; - - -@Component({ - selector: 'app-dmp-clone', - templateUrl: './dmp-clone.component.html', - styleUrls: ['./dmp-clone.component.scss'] -}) -export class DmpCloneComponent extends BaseComponent implements OnInit { - - // breadCrumbs: Observable; - // dmp: DmpWizardEditorModel; - dmp: DmpEditorModel; - formGroup: UntypedFormGroup; - itemId: string; - datasetId: string = null; - isFinalized: false; - isPublic: false; - parentDmpLabel: string; - isNewVersion: boolean = false; - isClone: boolean = true; - isNew: boolean = false; - isUserOwner: boolean = true; - // datasets: DatasetListingModel[] = []; - datasets = new UntypedFormArray([]); - removeIndexes = []; - - selectedTab = 0; - step: number = 0; - stepsBeforeDatasets: number = 3; - maxStep: number = 3; - - constructor( - private route: ActivatedRoute, - private router: Router, - private language: TranslateService, - private dmpService: DmpService, - private dmpBlueprintService: DmpBlueprintService, - private authentication: AuthService, - private uiNotificationService: UiNotificationService, - private datasetService: DatasetService, - private dialog: MatDialog - ) { - super(); - } - - ngOnInit() { - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - this.itemId = params['id']; - this.dmpService.getSingle(this.itemId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dmp = new DmpEditorModel(); - this.dmp.grant = new GrantTabModel(); - this.dmp.project = new ProjectFormModel(); - this.dmp.funder = new FunderFormModel(); - this.dmp.extraProperties = new ExtraPropertiesFormModel(); - this.dmp.fromModel(data); - this.dmp.status = DmpStatus.Draft; - this.formGroup = this.dmp.buildForm(); - - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => { - this.checkForGrant(result.definition); - this.checkForFunder(result.definition); - this.checkForProject(result.definition); - }); - } - - this.datasets = this.formGroup.get('datasets') as UntypedFormArray; - - this.parentDmpLabel = this.formGroup.get('label').value; - if (this.route.routeConfig.path.startsWith('new_version/')) { - this.formGroup.get('version').setValue(this.formGroup.get('version').value + 1); - this.formGroup.controls['label'].disable(); - this.formGroup.controls['grant'].disable(); - this.isNewVersion = true; - } else if (this.route.routeConfig.path.startsWith('clone/')) { - this.formGroup.get('label').setValue(this.dmp.label + " New"); - this.isNewVersion = false; - } - - // const request: DataTableRequest = new DataTableRequest(null, null, null); - // request.criteria = new DatasetCriteria(); - // request.criteria.dmpIds = [this.formGroup.get('id').value]; - // request.criteria.allVersions = true; - // this.datasetService.getPaged(request) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(items => { - // this.datasets = items.data; - // this.formGroup.addControl('datasets', new FormBuilder().array(new Array())); - // this.datasets.forEach(element => { - // console.log(element); - // (this.formGroup.get('datasets')).push(new FormBuilder().group({ id: element.value })); - // }); - // }); - - - // const breadCrumbs = []; - // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" }); - // breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/clone/' + this.dmp.id }); - // this.breadCrumbs = observableOf(breadCrumbs); - }); - }); - - } - - private getBlueprintDefinition(blueprintId: Guid, successFunction) { - this.dmpBlueprintService.getSingle(blueprintId, [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [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.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed)) - .subscribe( - data => successFunction(data), - error => this.onCallbackError(error) - ); - } - - private checkForGrant(blueprint: DmpBlueprintDefinition) { - let hasGrant = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { - hasGrant = true; - } - } - )); - if (!hasGrant) { - this.formGroup.removeControl('grant'); - } - } - - private checkForFunder(blueprint: DmpBlueprintDefinition) { - let hasFunder = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { - hasFunder = true; - } - } - )); - if (!hasFunder) { - this.formGroup.removeControl('funder'); - } - } - - private checkForProject(blueprint: DmpBlueprintDefinition) { - let hasProject = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { - hasProject = true; - } - } - )); - if (!hasProject) { - this.formGroup.removeControl('project'); - } - } - - public cancel(id: String): void { - if (id != null) { - this.router.navigate(['/plans/overview/' + id]); - } else { - this.router.navigate(['/plans']); - } - } - - public isFormValid(): boolean { - return this.formGroup.valid; - } - - formSubmit(): void { - if (!this.isFormValid()) { return; } - if (this.isNewVersion) { - this.dmpService.newVersion(this.formGroup.getRawValue(), this.itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackErrorNewVersion(error) - ); - } - else { - this.removeDatasetsFromClone(); - this.dmpService.clone(this.formGroup.getRawValue(), this.itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - onCallbackError(error: any) { - this.setErrorModel(error.error); - } - - onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) { - this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error); - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.dmp.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - isDirty() { - - } - - discardChanges() { - - } - - public changeStep(index: number, dataset?: DatasetListingModel) { - this.step = index; - if (dataset) { this.datasetId = dataset.id }; - } - - public nextStep() { - this.step = this.step < this.maxStep ? this.step + 1 : this.step; - if (this.step >= this.stepsBeforeDatasets) { - this.datasetId = this.datasets[this.step - this.stepsBeforeDatasets].id; - } - } - - public previousStep() { - this.step = this.step !== 0 ? this.step - 1 : this.step; - if (this.step >= this.stepsBeforeDatasets) { - this.datasetId = this.datasets[this.step - this.stepsBeforeDatasets].id; - } - } - - setIsUserOwner() { - if (this.dmp) { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) { - this.isUserOwner = !!this.dmp.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } else { - this.isUserOwner = false; - } - } - } - - formChanged() { - - } - - addDataset() { - if (!this.formGroup.get('datasets')) { - this.formGroup.addControl('datasets', new UntypedFormBuilder().array(new Array())); - } - this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm()); - this.datasets = this.formGroup.get('datasets') as UntypedFormArray; - this.step = this.stepsBeforeDatasets + this.formGroup.get('datasets')['controls'].length - 1; - this.maxStep = this.maxStep + this.formGroup.get('datasets')['controls'].length - 1; - } - - editDataset(id: string) { - this.router.navigate(['/datasets', 'edit', id]); - } - - hasProfile(): boolean { - return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.length > 0; - } - - selectionChanged(event, dataset) { - var datasetIndex = this.formGroup.get('datasets').value.map(function (item) { return item.id; }).indexOf(dataset.value.id); - if (!event.checked) { - if (this.removeIndexes.indexOf(datasetIndex) === -1) { this.removeIndexes.push(datasetIndex); } - } else { - var index = this.removeIndexes.indexOf(datasetIndex); - this.removeIndexes.splice(index, 1) - } - } - - removeDatasetsFromClone() { - this.removeIndexes.forEach(index => { - this.formGroup.get('datasets')['controls'].splice(index, 1); - this.formGroup.get('datasets').value.splice(index, 1) - }) - } - - public removeDataset(datasetId: string, index: number) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (datasetId) { - this.datasetService.delete(datasetId) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onDeleteCallbackSuccess(); - }, - error => this.onDeleteCallbackError(error) - ); - } - this.formGroup.get('datasets')['controls'].splice(index, 1); - this.step = 0; - } - }); - } - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.dmp.id != null ? this.router.navigate(['/plans', 'edit', this.dmp.id]) : this.router.navigate(['/plans']); - } - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } -} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts deleted file mode 100644 index d0c6b6c0a..000000000 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts +++ /dev/null @@ -1,1236 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DmpBlueprintExtraFieldDataType } from '@app/core/common/enum/dmp-blueprint-extra-field-data-type'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; -import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { Role } from '@app/core/common/enum/role'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpDatasetProfile } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile'; -import { DmpDatasetProfileSectionsFormModel } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile-sections-form.model'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { LanguageInfo } from '@app/core/model/language-info'; -import { Lock, LockPersist } from '@app/core/model/lock/lock.model'; -import { UserModel } from '@app/core/model/user/user'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -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 { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.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 { OrganisationService } from '@app/core/services/organisation/organisation.service'; -import { ReferenceService } from '@app/core/services/reference/reference.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { FormService } from '@common/forms/form-service'; -import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, interval } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { nameof } from 'ts-simple-nameof'; -import { DatasetPreviewDialogComponent } from '../dataset-preview/dataset-preview-dialog.component'; -import { DmpToDatasetDialogComponent } from '../dmp-to-dataset/dmp-to-dataset-dialog.component'; -import { AddOrganizationComponent } from '../editor/add-organization/add-organization.component'; -import { AddResearcherComponent } from '../editor/add-researcher/add-researcher.component'; -import { AvailableProfilesComponent } from '../editor/available-profiles/available-profiles.component'; -import { DmpEditorModel, DmpExtraFieldEditorModel } from '../editor/dmp-editor.model'; -import { ExtraPropertiesFormModel } from '../editor/general-tab/extra-properties-form.model'; -import { FunderFormModel } from '../editor/grant-tab/funder-form-model'; -import { GrantTabModel } from '../editor/grant-tab/grant-tab-model'; -import { ProjectFormModel } from '../editor/grant-tab/project-form-model'; -import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; -import { Reference } from '@app/core/model/reference/reference'; -import { ReferenceTypeEditorResolver } from '@app/ui/admin/reference-type/editor/reference-type-editor.resolver'; -import { LockTargetType } from '@app/core/common/enum/lock-target-type'; - -interface Visible { - value: boolean; - name: string; -} - -@Component({ - selector: 'app-dmp-editor-blueprint', - templateUrl: './dmp-editor-blueprint.component.html', - styleUrls: ['./dmp-editor-blueprint.component.scss'] -}) -export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent implements OnInit { - - canDeactivate(): boolean { - return !this.isDirty(); - } - - saving = false; - - isNew = true; - isUserOwner: boolean = true; - isNewVersion = false; - isFinalized = false; - isClone = false; - hasChanges = false; - isDiscarded = false; - - isCreateNew = false; - isCreateNewProject = false; - isCreateNewFunder = false; - - - dmp: DmpEditorModel; - dmpSectionIndex: number = 0; - formGroup: UntypedFormGroup = null; - formGroupRawValue: any; - datasets = new UntypedFormArray([]); - - associatedUsers: Array; - people: Array; - - lock: Lock; - lockPersist: LockPersist; - lockStatus: Boolean = false; - - step: number = 0; - stepsBeforeDatasets: number = 4; - maxStep: number = 4; - - scrollTop: number; - hintErrors: boolean = false; - - selectedDmpBlueprintDefinition: DmpBlueprintDefinition = null; - - sectionTemplates: Array> = new Array>(); - - private associates: UserModel[] = []; - - visibles: Visible[] = [ - { value: true, name: 'DMP-EDITOR.VISIBILITY.PUBLIC' }, - { value: false, name: 'DMP-EDITOR.VISIBILITY.RESTRICTED' } - ] - - licenseAutoCompleteConfiguration = this.referenceService.getSingleAutocompleteConfiguration([ReferenceType.Licenses]); - organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - 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) => item['name'], - titleFn: (item) => item['name'], - subtitleFn: (item) => 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')) - }; - researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - 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) => item['name'], - titleFn: (item) => item['name'], - subtitleFn: (item) => 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')) - }; - profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - - - - - - dmpBlueprintSectionFieldCategory = DmpBlueprintSectionFieldCategory; - dmpBlueprintSystemFieldType = DmpBlueprintSystemFieldType; - //public dmpBlueprintSystemFieldTypeEnum = this.enumUtils.getEnumValues(DmpBlueprintSystemFieldType); - dmpBlueprintExtraFieldDataType = DmpBlueprintExtraFieldDataType; - //public dmpBlueprintExtraFieldDataTypeEnum = this.enumUtils.getEnumValues(DmpBlueprintExtraFieldDataType); - - constructor( - private dmpBlueprintService: DmpBlueprintService, - private datasetService: DatasetService, - private authService: AuthService, - private route: ActivatedRoute, - private router: Router, - private configurationService: ConfigurationService, - private languageInfoService: LanguageInfoService, - private language: TranslateService, - private externalSourcesService: ExternalSourcesService, - private organizationService: OrganisationService, - private dmpService: DmpService, - private uiNotificationService: UiNotificationService, - private formService: FormService, - private dialog: MatDialog, - private lockService: LockService, - private matomoService: MatomoService, - private referenceService: ReferenceService - ) { - super(); - } - - ngOnInit(): void { - this.matomoService.trackPageView('DMP Editor'); - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - const itemId = params['id']; - - if (itemId != null) { - this.isNew = false; - this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(async data => { - this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { - this.lockStatus = lockStatus; - - this.dmp = new DmpEditorModel(); - this.dmp.grant = new GrantTabModel(); - this.dmp.project = new ProjectFormModel(); - this.dmp.funder = new FunderFormModel(); - this.dmp.extraProperties = new ExtraPropertiesFormModel(); - this.dmp.fromModel(data); - this.formGroup = this.dmp.buildForm(); - - this.datasets = this.formGroup.get('datasets') as UntypedFormArray; - - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.getSingle(Guid.parse(this.formGroup.get('profile').value), data => { - this.selectedDmpBlueprintDefinition = data.definition; - this.checkForGrant(); - this.checkForFunder(); - this.checkForProject(); - this.buildExtraFields(); - this.formGroup.get('profile').setValue(data); - this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; - this.step = 1; - this.addProfiles(this.dmp.profiles); - }); - } - this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; - - this.setIsUserOwner(); - if (!this.isUserOwner) { - - if (this.isUserMember()) { - this.router.navigate(['plans', 'overview', itemId]); - return; - } - this.isFinalized = true; - this.formGroup.disable(); - } - - if (this.dmp.status === DmpStatus.Finalized || lockStatus) { - this.isFinalized = true; - this.formGroup.disable(); - } - - if (this.authService.currentAccountIsAuthenticated()) { - if (!lockStatus) { - const persist : LockPersist = null; - persist.target = Guid.parse(data.id); - persist.targetType = LockTargetType.Dmp; - persist.lockedBy = this.getUserFromDMP(); - // this.lock = new LockModel(data.id, this.getUserFromDMP()); - - this.lockService.persist(persist).pipe(takeUntil(this._destroyed)).subscribe(async result => { - this.lock = result; - interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); - }); - } - } - - this.associatedUsers = data.associatedUsers; - this.people = data.users; - this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - if (this.lockStatus) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DMP-EDITOR.LOCKED.TITLE'), - message: this.language.instant('DMP-EDITOR.LOCKED.MESSAGE') - }, maxWidth: '30em' - }); - } - }); - }); - } - else { - this.dmp = new DmpEditorModel(); - this.dmp.grant = new GrantTabModel(); - this.dmp.project = new ProjectFormModel(); - this.dmp.funder = new FunderFormModel(); - this.dmp.extraProperties = new ExtraPropertiesFormModel(); - this.dmp.extraProperties.visible = false; - this.dmp.extraProperties.contact = this.authService.userId()?.toString(); - this.formGroup = this.dmp.buildForm(); - - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.getSingle(Guid.parse(this.formGroup.get('profile').value), data => { - this.selectedDmpBlueprintDefinition = data.definition; - this.checkForGrant(); - this.checkForFunder(); - this.checkForProject(); - this.buildExtraFields(); - this.formGroup.get('profile').setValue(data); - this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; - this.step = 1; - this.addProfiles(); - }); - } - this.registerFormEventsForDmpBlueprint(); - - if (!this.isUserOwner) { - this.formGroup.disable(); - } - if (isNullOrUndefined(this.formGroup.get('extraProperties').get('publicDate').value)) { - this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date()); - } - - let associate: UserModel = { - id: this.authService.userId()?.toString(), - name: this.authService.getPrincipalName(), - appRoles: this.authService.getRoles(), - email: this.authService.getUserProfileEmail() - }; - this.associates.push(associate); - if (isNullOrUndefined(this.formGroup.get('extraProperties').get('contact').value)) { - this.formGroup.get('extraProperties').get('contact').patchValue(associate.id); - } - if (isNullOrUndefined(this.formGroup.get('extraProperties').get('language').value)) { - this.formGroup.get('extraProperties').get('language').patchValue('en'); - } - - try { - const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; - profiles.sort((a, b) => a.label.localeCompare(b.label)); - } catch { - console.info('Could not sort profiles'); - } - } - }); - - - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'], - popupItemActionIcon: 'visibility' - }; - } - - extraFieldsArray(): UntypedFormArray { - return this.formGroup.get('extraFields') as UntypedFormArray; - } - - setIsUserOwner() { - if (this.dmp) { - const principalId: string = this.authService.userId()?.toString(); - this.isUserOwner = !!this.dmp.users.find(x => (x.role === Role.Owner) && (x.id === principalId)); - } - } - - isUserMember(): boolean { - try { - const principalId: string = this.authService.userId()?.toString(); - return !!this.dmp.users.find(x => (x.role === Role.Member) && (x.id === principalId)); - } catch { - return false; - } - } - - getUserFromDMP(): any { - if (this.dmp) { - const principalId: string = this.authService.userId()?.toString(); - return this.dmp.users.find(x => x.id === principalId); - } - } - - private pumpLock() { - this.lock.touchedAt = new Date(); - //his.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => this.lock.id = Guid.parse(result)); - } - - public isDirty(): boolean { - return this.formGroup && this.formGroup.dirty && this.hasChanges; - } - - public discard() { - let messageText = ""; - let confirmButtonText = ""; - let cancelButtonText = ""; - if (this.isNew) { - messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE'); - confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM'); - cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY'); - } else { - messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE'); - confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM'); - cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-DENY'); - } - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: messageText, - confirmButton: confirmButtonText, - cancelButton: cancelButtonText, - isDeleteConfirmation: true - }, - maxWidth: '40em' - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - // this.backToDmp(this.formGroup.get('dmp').value.id) - setTimeout(x => { - this.discardChanges(); - }); - } - }); - } - - public discardChanges() { - this.isDiscarded = true; - this.hasChanges = false; - if (!this.isNew) { - let grantControl; - if (this.formGroup.get('grant').get('existGrant')) { - grantControl = new GrantTabModel(); - grantControl.fromModel(this.formGroup.get('grant').get('existGrant').value); - } else { - // TODO: Commented in refactor - //grantControl = new GrantEditorModel(); - //grantControl.fromModel(this.formGroup.get('grant').value); - } - grantControl.buildForm() - - this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue))); - - if (this.formGroup.get('grant').get('existGrant')) { - this.formGroup.get('grant').get('existGrant').setValue(grantControl.existGrant); - } else { - this.formGroup.get('grant').setValue(grantControl); - } - } else { - this.formGroup.reset(); - this.formGroup.get("status").setValue(DmpStatus.Draft); - this.formGroup.get('extraProperties').get('visible').setValue(false); - this.formGroup.get('extraProperties').get('contact').setValue(this.authService.userId()?.toJSON()); - this.formGroup.get('associatedUsers').setValue([]); - } - this.isDiscarded = false; - } - - save() { - this.formSubmit(false); - } - - formSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void { - this.saving = true; - this.formService.touchAllFormFields(this.formGroup); - - if (!this._isDMPDescriptionValid()) { - const errmess = this._buildDMPDescriptionErrorMessages(); - this.showValidationErrorsDialog(undefined, errmess); - this.hintErrors = true; - this.saving = false; - return; - } - this.onSubmit(addNew, showAddDatasetDialog); - } - - public formChanged() { - if (!this.isDiscarded) { - this.hasChanges = true; - } - } - - selectDefaultBlueprint() { - this.getSingle(this.configurationService.defaultBlueprintId, data => { - this.selectedDmpBlueprintDefinition = data.definition; - this.formGroup.get('profile').setValue(data.id); - this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; - this.nextStep(); - }); - } - - selectBlueprint() { - this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; - this.nextStep(); - } - - nextStep() { - this.step = this.step < this.maxStep ? this.step + 1 : this.step; - this.resetScroll(); - // if (this.step >= this.stepsBeforeDatasets) { - // this.datasetId = this.datasets.at(this.step - this.stepsBeforeDatasets).get('id').value; - // } - } - - previousStep() { - this.step = this.step !== 1 ? this.step - 1 : this.step; - this.resetScroll(); - // if (this.step >= this.stepsBeforeDatasets) { - // this.datasetId = this.datasets.at(this.step - this.stepsBeforeDatasets).get('id').value; - // } - } - - changeStep(index: number, dataset?: UntypedFormControl) { - this.step = index; - this.resetScroll(); - // if (dataset) { this.datasetId = dataset.get('id').value }; - } - - private resetScroll() { - document.getElementById('editor-form').scrollTop = 0; - } - - hasProfile(sectionIndex: number): boolean { - return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.some(x => x.data.dmpSectionIndex.includes(sectionIndex)); - } - - addDataset(dmpSectionIndex: number) { - this.saving = true; - - if (!this._isDMPDescriptionValid()) { - const errmess = this._buildDMPDescriptionErrorMessages(); - this.showValidationErrorsDialog(undefined, errmess); - this.hintErrors = true; - this.saving = false; - return; - } - - - // const showDialog = this.hasProfile() && this.isNew; - this.dmpSectionIndex = dmpSectionIndex; - this.onSubmit(true, false); - // this.formSubmit(true, false); - - - - - // Add dataset to list - // if (!this.formGroup.get('datasets')) { - // this.formGroup.addControl('datasets', new FormBuilder().array(new Array())); - // } - // this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm()); - // this.datasets = this.formGroup.get('datasets') as FormArray; - // this.step = this.stepsBeforeDatasets + this.formGroup.get('datasets')['controls'].length - 1; - // this.maxStep = this.maxStep + this.formGroup.get('datasets')['controls'].length - 1; - } - - onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void { - this.scrollTop = document.getElementById('editor-form').scrollTop; - // return; - this.dmpService.createDmp(this.formGroup.getRawValue()) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.formGroup.get('id').setValue(complete.id); - this.formGroup.get('modified').setValue(complete.modified); - this.hasChanges = false; - if (showAddDatasetDialog) { - this.addDatasetOpenDialog(complete); - } - if (addNew) { - this.onCallbackSuccessAddNew(complete); - } - else { this.onCallbackSuccess(complete) } - }, - error => { - this.formGroup.get('status').setValue(DmpStatus.Draft); - this.onCallbackError(error); - } - ); - // this.dmpService.createDmpWithDatasets(this.formGroup.getRawValue()) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => { - // if (showAddDatasetDialog) { - // this.addDatasetOpenDialog(complete); - // } - // else if (this.step < this.stepsBeforeDatasets) { this.onCallbackSuccess(complete) } - // else { this.onCallbackSuccess(complete, this.datasetId) } - // }, - // error => { - // this.formGroup.get('status').setValue(DmpStatus.Draft); - // this.onCallbackError(error); - // } - // ) - } - - addDatasetOpenDialog(dmp: DmpModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '500px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ADD-DATASET'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.NO'), - isDeleteConfirmation: false - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - // this.router.navigate(['datasets/new/' + id]); - this.addDataset(this.dmpSectionIndex); - } else { - dmp.id != null ? this.router.navigate(['/plans', 'edit', dmp.id]) : this.router.navigate(['/plans']); - } - }); - } - - onCallbackSuccess(dmp?: DmpModel, datasetId?: string): void { - - // On save keep editor position - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - if (dmp) { - if (this.isNew) { - this.router.navigate(['/plans', 'edit', dmp.id]); - } - let dmpEditorModel: DmpEditorModel; - dmpEditorModel = new DmpEditorModel(); - dmpEditorModel.grant = new GrantTabModel(); - dmpEditorModel.project = new ProjectFormModel(); - dmpEditorModel.funder = new FunderFormModel(); - dmpEditorModel.extraProperties = new ExtraPropertiesFormModel(); - dmpEditorModel.fromModel(dmp); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.associatedUsers = dmp.associatedUsers; - this.people = dmp.users; - - setTimeout(() => { this.formGroup = null; }); - setTimeout(() => { - this.formGroup = dmpEditorModel.buildForm(); - this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - }); - setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; }); - this.saving = false; - this.isNew = false; - } else { - this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); }); - } - - // Uncomment to not keep editor position on save - // if (dmp.id != null) { - // datasetId ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', dmp.id], { queryParams: { dataset: datasetId } }); }) : this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans', 'edit', dmp.id]); }) - // } else { - // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); }); - // } - } - - onCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); - this.setErrorModel(error.error); - this.saving = false; - //this.validateAllFormFields(this.formGroup); - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.dmp.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - onCallbackSuccessAddNew(dmp?: DmpModel) { - // this.editDataset(dmp.id, true, this.isNew && !this.formGroup.get('datasets').value.length); - this.editDataset(dmp.id, true, false); - this.saving = false; - } - - editDataset(id: string, isNew: boolean, showModal: boolean = false) { - - - if (showModal) { - const dialogRef = this.dialog.open(DmpToDatasetDialogComponent, { - width: '500px', - autoFocus: false, - restoreFocus: false, - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (isNew) { - this.router.navigate(['/datasets', 'new', id, this.dmpSectionIndex]); - } else { - this.router.navigate(['/datasets', 'edit', id]); - } - } - }); - } else { - if (isNew) { - this.router.navigate(['/datasets', 'new', id, this.dmpSectionIndex]); - } else { - this.router.navigate(['/datasets', 'edit', id]); - } - - } - - - } - - public removeDataset(datasetId: string, index: number) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (datasetId) { - this.datasetService.delete(datasetId) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onDeleteCallbackSuccess(); - }, - error => this.onDeleteCallbackError(error) - ); - } - this.formGroup.get('datasets')['controls'].splice(index, 1); - this.step = 0; - } - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.dmp.id != null ? this.router.navigate(['/reload']).then(() => this.router.navigate(['/plans', 'edit', this.dmp.id])) : this.router.navigate(['/plans']); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - //checks if the dpm is valid not taking into account the datasets validity - private _isDMPDescriptionValid(): boolean { - - const form: UntypedFormGroup = this.formGroup; - if (form.controls) { - return Object.keys(form.controls) - .map(controlName => {//get validity of each control - if (controlName === 'datasets') {//we dont care if datasets are valid - return true; - } - return !form.get(controlName).invalid;//!! in case the control is disabled, we consider it valid - }) - .reduce((isFormValid, isControlValid) => {//aggregate validities - return isControlValid && isFormValid; - }, true); - } - return true; - } - - private showValidationErrorsDialog(projectOnly?: boolean, errmess?: string[]) { - - if (errmess) { - - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - errorMessages: errmess, - projectOnly: projectOnly - }, - }); - } else { - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - formGroup: this.formGroup, - projectOnly: projectOnly - }, - }); - } - - } - - private _buildDMPDescriptionErrorMessages(): string[] {//not including datasets - const errmess: string[] = []; - Object.keys(this.formGroup.controls).forEach(controlName => { - if (controlName != 'datasets' && this.formGroup.get(controlName).invalid) { - errmess.push(...this._buildErrorMessagesForAbstractControl(this.formGroup.get(controlName), controlName)); - } - }) - - return errmess; - } - - // takes as an input an abstract control and gets its error messages[] - private _buildErrorMessagesForAbstractControl(aControl: AbstractControl, controlName: string): string[] { - const errmess: string[] = []; - - if (aControl.invalid) { - - if (aControl.errors) { - //check if has placeholder - if ((aControl).nativeElement !== undefined && (aControl).nativeElement !== null) { - const placeholder = this._getPlaceHolder(aControl); - if (placeholder) { - controlName = placeholder; - } - } - const errorMessage = this._getErrorMessage(aControl, controlName); - - errmess.push(...errorMessage); - } - /*in case the aControl is FormControl then the it should have provided its error messages above. - No need to check case of FormControl below*/ - - if (aControl instanceof UntypedFormGroup) { - - const fg = aControl as UntypedFormGroup; - //check children - Object.keys(fg.controls).forEach(controlName => { - errmess.push(...this._buildErrorMessagesForAbstractControl(fg.get(controlName), controlName)); - }); - } else if (aControl instanceof UntypedFormArray) { - - const fa = aControl as UntypedFormArray; - - fa.controls.forEach((control, index) => { - errmess.push(... this._buildErrorMessagesForAbstractControl(control, `${controlName} --> ${index + 1}`)); - }); - - } - - } - - return errmess; - } - - private _getErrorMessage(formControl: AbstractControl, name: string): string[] { - const errors: string[] = []; - Object.keys(formControl.errors).forEach(key => { - if (key === 'required') { errors.push(this.language.instant(name + ": " + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED'))); } - // if (key === 'required') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + this.getPlaceHolder(formControl) + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED')); } - else if (key === 'email') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.EMAIL')); } - else if (key === 'min') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MIN-VALUE', { 'min': formControl.getError('min').min })); } - else if (key === 'max') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MAX-VALUE', { 'max': formControl.getError('max').max })); } - else { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + formControl.errors[key].message); } - }); - return errors; - } - - private _getPlaceHolder(formControl: any): string { - if (formControl.nativeElement.localName === 'input' || formControl.nativeElement.localName === 'textarea' - || formControl.nativeElement.localName === 'richTextarea') { - return formControl.nativeElement.getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'mat-select') { - return formControl.nativeElement.getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'app-single-auto-complete') { - return (Array.from(formControl.nativeElement.firstChild.children).filter((x: any) => x.localName === 'input')[0] as any).getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'app-multiple-auto-complete') { - return (Array.from(formControl.nativeElement.firstChild.firstChild.firstChild.children).filter((x: any) => x.localName === 'input')[0] as any).getAttribute('placeholder'); - } - } - - filterProfiles(value: string): Observable { - const request = new DataTableRequest(null, null, { fields: ['+label'] }); - const criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this.dmpService.searchDmpBlueprints(request); - } - - private getSingle(blueprintId: Guid, successFunction) { - this.dmpBlueprintService.getSingle(blueprintId, [ - nameof(x => x.id), - nameof(x => x.label), - nameof(x => x.status), - nameof(x => x.description), - nameof(x => x.status), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [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.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - nameof(x => x.createdAt), - nameof(x => x.hash), - nameof(x => x.isActive) - ] - ) - .pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed)) - .subscribe( - data => successFunction(data), - error => this.onCallbackError(error) - ); - } - - registerFormEventsForDmpBlueprint(): void { - this.formGroup.get('profile').valueChanges - .pipe( - takeUntil(this._destroyed)) - .subscribe(blueprintIdString => { - const blueprintId = Guid.parse(blueprintIdString); - if (blueprintId) { - this.getSingle(blueprintId, data => { - this.selectedDmpBlueprintDefinition = data.definition; - this.checkForGrant(); - this.checkForFunder(); - this.checkForProject(); - this.buildExtraFields(); - this.addProfiles(); - }); - } - else { - this.selectedDmpBlueprintDefinition = null; - } - }) - } - - private buildExtraFields(): void { - const extraFields = new Array(); - this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach(field => { - if (field.category as unknown == DmpBlueprintSectionFieldCategory.EXTRA) { - let extraField = new DmpExtraFieldEditorModel(); - extraField.id = field.id.toString(); - if (!isNullOrUndefined(this.dmp.extraFields)) { - let found = this.dmp.extraFields.find(f => Guid.parse(f.id) === field.id); - if (found !== undefined) { - extraField.value = found.value; - } - } - extraFields.push(extraField.buildForm()); - } - })); - this.formGroup.setControl('extraFields', new UntypedFormBuilder().array(extraFields)); - } - - getExtraFieldIndex(id: string): string { - let foundFieldIndex: number; - (this.formGroup.get('extraFields') as UntypedFormArray).controls.forEach((element, index) => { - if (element.value.id === id) { - foundFieldIndex = index; - } - }); - return foundFieldIndex.toString(); - } - - private checkForGrant() { - let hasGrant = false; - this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { - hasGrant = true; - } - } - )); - if (!hasGrant) { - this.formGroup.removeControl('grant'); - } - } - - private checkForFunder() { - let hasFunder = false; - this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { - hasFunder = true; - } - } - )); - if (!hasFunder) { - this.formGroup.removeControl('funder'); - } - } - - private checkForProject() { - let hasProject = false; - this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { - hasProject = true; - } - } - )); - if (!hasProject) { - this.formGroup.removeControl('project'); - } - } - - private addProfiles(profiles?: DmpDatasetProfile[]) { - for (let i = 0; i < this.selectedDmpBlueprintDefinition.sections.length; i++) { - this.sectionTemplates.push(new Array()); - } - const templates: Array = new Array(); - this.selectedDmpBlueprintDefinition.sections.forEach(section => { - if (profiles !== undefined) { - profiles.filter(profile => profile.data.dmpSectionIndex.includes(section.ordinal - 1)).forEach(profile => this.sectionTemplates[section.ordinal - 1].push({ id: profile.descriptionTemplateId, label: profile.label, description: "" })); - } - else { - section.descriptionTemplates.forEach(template => { - this.sectionTemplates[section.ordinal - 1].push({ id: template.descriptionTemplateId.toString(), label: template.label, description: "" }) - let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => Guid.parse(dmpDatasetProfile.descriptionTemplateId) == template.descriptionTemplateId); - if (found === undefined) { - let data: DmpDatasetProfileSectionsFormModel = new DmpDatasetProfileSectionsFormModel(); - data.dmpSectionIndex.push(section.ordinal - 1); - let id = null; - if (profiles !== undefined) { - let existedProfile = profiles.find(profile => Guid.parse(profile.descriptionTemplateId) == template.descriptionTemplateId); - if (existedProfile !== undefined) { - id = existedProfile.id; - } - } - let profile: DmpDatasetProfile = { - id: id, - descriptionTemplateId: template.descriptionTemplateId.toString(), - label: template.label, - data: data - }; - templates.push(profile); - } - else { - found.data.dmpSectionIndex.push(section.ordinal - 1); - } - }); - } - }); - (profiles !== undefined) ? this.formGroup.get('profiles').setValue(profiles) : this.formGroup.get('profiles').setValue(templates); - - } - - getLanguageInfos(): LanguageInfo[] { - return this.languageInfoService.getLanguageInfoValues(); - } - - getAssociates(): UserModel[] { - let associates: UserModel[]; - if (this.formGroup.get('associatedUsers').value && this.formGroup.get('associatedUsers').value.length > 0) { - associates = []; - } else { - associates = this.associates; - } - //associates = (this.formGroup.get('researchers').value as any[]); - associates = associates.concat(this.formGroup.get('associatedUsers').value); - return associates; - } - - - - // Researchers - filterResearchers(value: string): Observable { - //return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }); - // const lookup = new ReferenceSearchLookup(); - // lookup.like = value; - // lookup.key = ''; - // lookup.type = ReferenceType.Researcher; - // return this.referenceService.search(lookup); - const lookup = new ReferenceSearchDefinitionLookup(); - //lookup.like=''; - //lookup.page.size = 1; - lookup.key = ''; - //from reference type db hardcoded - lookup.referenceTypeId = Guid.parse('51225b6a-86a6-48ac-9192-f15096dbcb8a'); - const fields = [ - ...ReferenceTypeEditorResolver.lookupFields() - ]; - lookup.project.fields = fields; - - return this.referenceService.searchWithDefinition(lookup); - } - - addResearcher(event: MouseEvent) { - event.stopPropagation(); - const dialogRef = this.dialog.open(AddResearcherComponent, { - data: this.formGroup.get('researchers') - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - const fullName = result.firstName + " " + result.lastName; - const newItem = { - label: null, - name: fullName, - id: null, - status: 0, - key: "Internal", - reference: result.reference - }; - const researchersArray = this.formGroup.get('researchers').value || []; - researchersArray.push(newItem); - this.formGroup.get('researchers').setValue(researchersArray); - } - }); - } - - // Organizations - showOrganizationCreator(): boolean { - return this.configurationService.allowOrganizationCreator; - } - - filterOrganisations(value: string): Observable { - return this.organizationService.searchGeneralOrganisations({ criteria: { labelLike: value } }); - } - - cantAddOrganizations(): boolean { - if (!isNullOrUndefined(this.formGroup.get('organizations'))) { - return this.formGroup.get('organiztions').disabled; - } else { - return false; - } - } - - addOrganization(event: MouseEvent) { - event.stopPropagation(); - const dialogRef = this.dialog.open(AddOrganizationComponent, { - data: this.formGroup.get('organisations') - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - const fullName = result.name; - const newItem = { - label: null, - name: fullName, - id: null, - status: 0, - key: "Internal", - reference: result.reference - }; - const organizationsArray = this.formGroup.get('organisations').value || []; - organizationsArray.push(newItem); - this.formGroup.get('organisations').setValue(organizationsArray); - } - }); - } - - showToggleButton() { - return (!this.isFinalized && this.isUserOwner) || this.isClone; - } - - allAvailableProfiles(event: MouseEvent) { - event.stopPropagation(); - const dialogRef = this.dialog.open(AvailableProfilesComponent, { - data: { - profiles: this.formGroup.get('profiles') - } - }); - - return false; - } - - onRemoveTemplate(event, sectionIndex: number) { - let found = false; - let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; - this.formGroup.get('datasets')['controls'].forEach(element => { - if ((element.get('profile').value.id === event.id) && (element.get('dmpSectionIndex').value === sectionIndex)) { - found = true; - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success); - } - }); - if (found) { - this.formGroup.get('profiles').setValue(profiles); - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'], - popupItemActionIcon: 'visibility' - }; - - } - else { - this.sectionTemplates[sectionIndex] = this.sectionTemplates[sectionIndex].filter(sectionProfile => sectionProfile.id !== event.id); - profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id); - this.formGroup.get('profiles').setValue(profiles); - } - } - - addProfile(event, sectionIndex: number) { - const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; - let found = profiles.find((value) => value.id === event.id); - if (found !== undefined) { - if (found.data.dmpSectionIndex.indexOf(sectionIndex) === -1) { - found.data.dmpSectionIndex.push(sectionIndex); - } - else { - this.sectionTemplates[sectionIndex].pop(); - } - } - else { - let dmpDatasetProfileSection: DmpDatasetProfileSectionsFormModel = new DmpDatasetProfileSectionsFormModel(); - dmpDatasetProfileSection.dmpSectionIndex = [sectionIndex]; - profiles.push({ id: null, descriptionTemplateId: event.id, label: event.label, data: dmpDatasetProfileSection }); - } - this.formGroup.get('profiles').setValue(profiles); - } - - onPreviewTemplate(event, sectionIndex: number) { - const dialogRef = this.dialog.open(DatasetPreviewDialogComponent, { - width: '590px', - minHeight: '200px', - restoreFocus: false, - data: { - template: event - }, - panelClass: 'custom-modalbox' - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.addProfile(event, sectionIndex); - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'], - popupItemActionIcon: 'visibility' - }; - } - }); - } - onOptionSelected(event, sectionIndex: number) { - try { - this.addProfile(event, sectionIndex); - // const profileCounts: Map = new Map(); - // profiles.forEach((value) => profileCounts.set(value.id, (profileCounts.get(value.id) !== undefined ? profileCounts.get(value.id): 0 ) + 1)); - // const duplicateProfiles = profiles.filter((value) => { - // let isOk = profileCounts.get(value.id) > 1; - // if (isOk) { - // profileCounts.set(value.id, 0); - // } - // return isOk; - // }); - // duplicateProfiles.forEach((value) => profiles.splice(profiles.lastIndexOf(value), 1)); - // profiles.sort((a,b)=> a.label.localeCompare(b.label)); - } catch { - console.info('Could not sort Dataset Templates') - } - } - -} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html similarity index 65% rename from dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html rename to dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html index 962e7cf99..1f09c0cee 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html @@ -1,19 +1,15 @@
-
- -
+
+
-
{{'DMP-EDITOR.TITLE.EDIT-DMP' | translate}}
-
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
+
{{'DMP-EDITOR.TITLE-EDIT' | translate}}
+
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.UNSAVED-CHANGES' | translate}})
-
- +
@@ -38,21 +34,19 @@
-
{{'DMP-EDITOR.FIELDS.NAME' | translate}} *
+
{{'DMP-EDITOR.FIELDS.TITLE' | translate}} *
- {{'DMP-EDITOR.FIELDS.NAME' | translate}} + {{'DMP-EDITOR.FIELDS.TITLE' | translate}} - + {{formGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
+
{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}} *
-
{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}} *
@@ -61,15 +55,15 @@
{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}} *
{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}} - +
- +
-
+

{{'DMP-EDITOR.ACTIONS.OR-CONTINUE-WITH' | translate}}

@@ -85,26 +79,26 @@
-
DMP Blueprint
+
{{'DMP-EDITOR.TITLE' | translate}}
    - -
    -
    +
    + +
  1. {{section.label}}
    1. -
    2. +
    3. -
      {{'DMP-EDITOR.STEPPER.DATASET' | translate}}: {{ dataset.get('label').value }}
      - close - check +
      {{'DMP-EDITOR.DESCRIPTION' | translate}}: {{ description.label }}
      + close + check
    -
      + @@ -115,27 +109,21 @@
      -
      -
      {{'DMP-EDITOR.STEPPER.NEXT' | translate}}
      +
      +
      {{'DMP-EDITOR.ACTIONS.NEXT-STEP' | translate}}
      chevron_right
      - - - -
      - +
      -
      - {{formGroup.value | json}} -
      +
      +
      -
      +
      -->
      @@ -85,8 +79,6 @@
      -
      @@ -193,134 +185,4 @@
      -
      - - - +
      \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index d9c547946..5091cfe19 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -1,38 +1,31 @@ +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { Component, OnDestroy, OnInit } from '@angular/core'; -import { UntypedFormArray, FormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; +import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; +import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; import { CultureInfo } from '@app/core/model/culture-info'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { UserListingModel } from '@app/core/model/user/user-listing'; +import { Reference } from '@app/core/model/reference/reference'; +import { User } from '@app/core/model/user/user'; import { AuthService } from '@app/core/services/auth/auth.service'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { CultureService } from '@app/core/services/culture/culture-service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; +import { LanguageService } from '@app/core/services/language/language.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 { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component"; import { BaseComponent } from '@common/base/base.component'; +import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; +import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { TranslateService } from '@ngx-translate/core'; import * as moment from 'moment-timezone'; import { Observable, of } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; -import { LanguageService } from '@app/core/services/language/language.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { UserProfileEditorModel } from './user-profile-editor.model'; -import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { AddAccountDialogComponent } from './add-account/add-account-dialog.component'; -import { MatDialog } from '@angular/material/dialog'; -import { UserCredentialModel } from '@app/core/model/user/user-credential'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { MergeEmailConfirmationService } from '@app/core/services/merge-email-confirmation/merge-email-confirmation.service'; -import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component"; -import { UnlinkAccountRequestModel } from '@app/core/model/unlink-account/unlink-account'; -import { UnlinkAccountEmailConfirmationService } from '@app/core/services/unlink-account-email-confirmation/unlink-account-email-confirmation.service'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import { UserProfileEditorModel } from './user-profile-editor.model'; @Component({ selector: 'app-user-profile', @@ -42,16 +35,15 @@ import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog export class UserProfileComponent extends BaseComponent implements OnInit, OnDestroy { userProfileEditorModel: UserProfileEditorModel; - user: Observable; - userCredentials: UserCredentialModel[]; + user: Observable; + //TODO: refactor + // userCredentials: UserCredentialModel[]; currentUserId: string; cultures: Observable; timezones: Observable; editMode = false; languages = []; roleOrganizationEnum = RoleOrganizationType; - authProviderEnum = AuthProvider; - private oauthLock: boolean; errorMessages = []; nestedCount = []; nestedIndex = 0; @@ -66,21 +58,18 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes formGroup: UntypedFormGroup; constructor( - private userService: UserServiceOld, + private userService: UserService, private route: ActivatedRoute, private router: Router, private authService: AuthService, private language: TranslateService, private cultureService: CultureService, - private externalSourcesService: ExternalSourcesService, private authentication: AuthService, private languageService: LanguageService, private configurationService: ConfigurationService, private uiNotificationService: UiNotificationService, private dialog: MatDialog, public enumUtils: EnumUtils, - private mergeEmailConfirmation: MergeEmailConfirmationService, - private unlinkAccountEmailConfirmation: UnlinkAccountEmailConfirmationService, private httpClient: HttpClient, private matomoService: MatomoService ) { @@ -95,7 +84,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes .subscribe((params: Params) => { this.currentUserId = this.authService.userId()?.toString(); const userId = !params['id'] ? 'me' : params['id']; - this.user = this.userService.getUser(userId).pipe(map(result => { + this.user = this.userService.getSingle(userId).pipe(map(result => { //result['additionalinfo'] = JSON.parse(result['additionalinfo']); this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result); @@ -118,14 +107,16 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes return result; })); - this.userService.getEmails(userId).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.user.subscribe(x => { - const mainEmail = result.filter(el => el.email === x.email) - const otherEmails = result.filter(el => el.email !== x.email) - this.userCredentials = [...mainEmail, ...otherEmails]; - } - )}); + //TODO: refactor + // this.userService.getEmails(userId).pipe(takeUntil(this._destroyed)) + // .subscribe(result => { + // this.user.subscribe(x => { + // const mainEmail = result.filter(el => el.email === x.email) + // const otherEmails = result.filter(el => el.email !== x.email) + // this.userCredentials = [...mainEmail, ...otherEmails]; + // } + // ) + // }); }); } @@ -133,28 +124,10 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes ngOnDestroy(): void { } - logout(): void { - this.router.navigate(['/logout']); - } - - getUserRole(dmp: DmpModel) { - if (dmp.creator.id === this.currentUserId) { - return this.language.instant('USER-PROFILE.DMPS.CREATOR'); - } else if (dmp.associatedUsers.map(x => x.id).indexOf(this.currentUserId) !== -1) { - return this.language.instant('USER-PROFILE.DMPS.MEMBER'); - } - } - - showAllDmps() { - this.router.navigate(['/plans']); - } - - navigateToDmp(dmp: DmpModel) { - this.router.navigate(['/plans/edit/' + dmp.id]); - } - - private filterOrganisations(value: string): Observable { - return this.externalSourcesService.searchDMPOrganizations(value); + private filterOrganisations(value: string): Observable { + //TODO: refactor + // return this.externalSourcesService.searchDMPOrganizations(value); + return null; } private _filterTimezone(value: string): Observable { @@ -180,31 +153,32 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes } save() { - if (!this.formGroup.valid) { - this.printErrors(this.formGroup); - this.showValidationErrorsDialog(); - this.nestedCount = []; - this.nestedIndex = 0; - this.errorMessages = []; - return; - } - this.userService.updateUserSettings(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - x => { - this.editMode = false; - this.languageService.changeLanguage(this.formGroup.value.language.value); - this.authService.refresh() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/profile']); - }); - // .subscribe(result => window.location.reload()); - }, - error => { - console.log(error); - }); + //TODO: refactor + // if (!this.formGroup.valid) { + // this.printErrors(this.formGroup); + // this.showValidationErrorsDialog(); + // this.nestedCount = []; + // this.nestedIndex = 0; + // this.errorMessages = []; + // return; + // } + // this.userService.updateUserSettings(this.formGroup.value) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // x => { + // this.editMode = false; + // this.languageService.changeLanguage(this.formGroup.value.language.value); + // this.authService.refresh() + // .pipe(takeUntil(this._destroyed)) + // .subscribe(result => { + // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + // this.router.navigate(['/profile']); + // }); + // // .subscribe(result => window.location.reload()); + // }, + // error => { + // console.log(error); + // }); } public unlock() { @@ -218,21 +192,22 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes public lock() { if (!this.formGroup.valid) { return; } - this.userService.updateUserSettings(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - x => { - this.editMode = false; - this.languageService.changeLanguage(this.formGroup.value.language.value); - this.formGroup.disable(); - this.authService.refresh() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => this.router.navigate(['/profile'])); - // .subscribe(result => window.location.reload()); - }, - error => { - console.log(error); - }); + //TODO: refactor + // this.userService.updateUserSettings(this.formGroup.value) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // x => { + // this.editMode = false; + // this.languageService.changeLanguage(this.formGroup.value.language.value); + // this.formGroup.disable(); + // this.authService.refresh() + // .pipe(takeUntil(this._destroyed)) + // .subscribe(result => this.router.navigate(['/profile'])); + // // .subscribe(result => window.location.reload()); + // }, + // error => { + // console.log(error); + // }); } private showValidationErrorsDialog(projectOnly?: boolean) { @@ -251,36 +226,37 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes (ev.target as HTMLImageElement).src = 'assets/images/profile-placeholder.png'; } - public removeAccount(userCredential :UserCredentialModel) { + public removeAccount(userCredential: any) { this.dialog.open(ConfirmationDialogComponent, { - data:{ + data: { message: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT-DIALOG.MESSAGE'), confirmButton: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT-DIALOG.CONFIRM'), cancelButton: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT-DIALOG.CANCEL') }, - maxWidth:'35em' + maxWidth: '35em' }) - .afterClosed() - .subscribe(confirm=>{ - if(confirm){ - const unlinkAccountModel: UnlinkAccountRequestModel = { - userId: this.currentUserId, - email: userCredential.email, - provider: userCredential.provider - }; - this.unlinkAccountEmailConfirmation.sendConfirmationEmail(unlinkAccountModel).pipe(takeUntil(this._destroyed)).subscribe( - result => { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.TITLE'), - message: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.MESSAGE', {'accountToBeUnlinked': userCredential.email}) - }, maxWidth: '35em' - }); - }, - error => { this.onCallbackError(error); } - ); - } - }); + .afterClosed() + .subscribe(confirm => { + if (confirm) { + //TODO: refactor + // const unlinkAccountModel: UnlinkAccountRequestModel = { + // userId: this.currentUserId, + // email: userCredential.email, + // provider: userCredential.provider + // }; + // this.unlinkAccountEmailConfirmation.sendConfirmationEmail(unlinkAccountModel).pipe(takeUntil(this._destroyed)).subscribe( + // result => { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.TITLE'), + // message: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.MESSAGE', { 'accountToBeUnlinked': userCredential.email }) + // }, maxWidth: '35em' + // }); + // }, + // error => { this.onCallbackError(error); } + // ); + } + }); } onCallbackError(errorResponse: HttpErrorResponse) { @@ -298,15 +274,16 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - this.mergeEmailConfirmation.sendConfirmationEmail(result).pipe(takeUntil(this._destroyed)) - .subscribe(res => { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.TITLE'), - message: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - }, err => { }); + //TODO refactor + // this.mergeEmailConfirmation.sendConfirmationEmail(result).pipe(takeUntil(this._destroyed)) + // .subscribe(res => { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.TITLE'), + // message: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.MESSAGE') + // }, maxWidth: '30em' + // }); + // }, err => { }); } }); } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 05f31f3ef..6cff527c2 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -242,13 +242,13 @@ "EDIT-DMP-BLUEPRINT": "Edit", "NEW-DESCRIPTION-TEMPLATES": "New", "EDIT-DESCRIPTION-TEMPLATES": "Edit", - "REFERENCE-TYPES":"Reference Types", + "REFERENCE-TYPES": "Reference Types", "NEW-REFERENCE-TYPE": "New", "EDIT-REFERENCE-TYPE": "Edit", - "TENANTS":"Tenants", + "TENANTS": "Tenants", "NEW-TENANT": "New", "EDIT-TENANT": "Edit", - "REFERENCES":"References", + "REFERENCES": "References", "NEW-REFERENCE": "New", "EDIT-REFERENCE": "Edit", "LANGUAGES": "Languages", @@ -349,12 +349,12 @@ "SUPPORT": "Support", "FEEDBACK": "Send feedback", "SUPPORTIVE-MATERIAL": "Supportive Material", - "REFERENCE-TYPES":"Reference Types", + "REFERENCE-TYPES": "Reference Types", "TENANTS": "Tenants", "REFERENCES": "References", "LANGUAGES": "Languages", "MAINTENANCE": "Maintenance", - "NOTIFICATION-TEMPLATES":"Notification Templates" + "NOTIFICATION-TEMPLATES": "Notification Templates" }, "DESCRIPTION-TEMPLATE-EDITOR": { "TITLE": { @@ -878,7 +878,7 @@ "TITLE": "DMP", "PUBLIC": "Public", "LOCKED": "Locked", - "VERSION":"Version", + "VERSION": "Version", "EDITED": "Edited", "FINALISED": "Finalized", "GRANT": "Grant", @@ -889,22 +889,20 @@ "DMP-AUTHORS": "DΜP Authors", "YOU": "you", "ACTIONS": { - "BACK":"Back", - "EDIT":"Edit", - "CLONE":"Clone", - "DELETE":"Delete", + "BACK": "Back", + "EDIT": "Edit", + "CLONE": "Clone", + "DELETE": "Delete", "ADD-DESCRIPTION": "Add Description", - "COPY":"Copy", - "FINALIZE":"Finalize", + "COPY": "Copy", + "FINALIZE": "Finalize", "VISIT-WEBSITE": "Visit Website", - "REVERSE":"Undo Finalization", - "EXPORT":"Export", - "NEW-VERSION":"Start new version", + "REVERSE": "Undo Finalization", + "EXPORT": "Export", + "NEW-VERSION": "Start new version", "INVITE-SHORT": "Invite", "REMOVE-AUTHOR": "Remove" }, - - "COLLABORATORS": "Collaborators", "PRIVATE": "Private", "UNLOCKED": "Unlocked", @@ -956,13 +954,13 @@ "FORBIDEN-DATASET": "You are not allowed to access this dataset" }, "ACTIONS": { - "BACK":"Back", - "EDIT":"Edit", - "CLONE":"Clone", - "DELETE":"Delete", - "FINALIZE":"Finalize", - "REVERSE":"Undo Finalization", - "EXPORT":"Export", + "BACK": "Back", + "EDIT": "Edit", + "CLONE": "Clone", + "DELETE": "Delete", + "FINALIZE": "Finalize", + "REVERSE": "Undo Finalization", + "EXPORT": "Export", "INVITE-SHORT": "Invite", "REMOVE-AUTHOR": "Remove" }, @@ -992,7 +990,7 @@ "LINK-PUBLIC-DATASETS": "Public Datasets", "TEXT-INFO-PAR": "New datasets can be added to existing DMPs at any time and be described with more than one template. Datasets can also be cloned and re-used in other DMPs as well as be deleted without negatively affecting the DMP as a whole.", "DESCRIPTION": "Description", - "GRANT":"Grant", + "GRANT": "Grant", "LOCKED": "Dataset is Locked by another user", "ACTIONS": { "ADD-DESCRIPTION": "Add Description", @@ -1017,6 +1015,42 @@ "DMP": "DMP", "EMPTY-LIST": "Nothing here yet." }, + "DESCRIPTION-EDITOR": { + "TITLE-ADD-DESCRIPTION": "Adding dataset", + "TITLE-EDIT-DESCRIPTION": "Editing Description", + "TITLE-PREVIEW-DESCRIPTION": "Previewing Description", + "TO-DMP": "Previewing Description", + "DMP": "DMP", + "TOC": { + "TITLE": "Guide steps", + "MAIN-INFO": "Main info", + "PREVIOUS": "Previous", + "NEXT": "Next" + }, + "BASE-INFO": { + "INTRO": "You are using the Description editor. Answer here questions that describe your data management activities.", + "INTRO-TIP": "Tip: Add new descriptions to describe different types of data or disciplinary data to avoid mixing information.", + "FIELDS": { + "TITLE": "Title of Description", + "DESCRIPTION": "Description", + "TAGS": "Tags", + "TAGS-PLACEHOLDER": "New Tag...", + "DESCRIPTION-HINT": "Briefly describe the context and purpose of the Description", + "DESCRIPTION-TEMPLATE": "Template", + "DESCRIPTION-TEMPLATE-PLACEHOLDER": "Description Template" + } + }, + "ACTIONS": { + "BACK-TO": "Back to", + "EXPORT": "Export", + "SAVE": "Save", + "SAVE-AND-CONTINUE": "Save & Continue", + "SAVE-AND-ADD-NEW": "Save & Add New", + "SAVE-AND-CLOSE": "Save & Close", + "FINALIZE": "Finalize", + "DISCARD": "Discard" + } + }, "DATASET-PUBLIC-LISTING": { "TITLE": "Published Datasets", "TOOLTIP": { @@ -1032,12 +1066,12 @@ "CREATE-DESCRIPTION-TEMPLATE": "Create Description Template", "FIELDS": { "NAME": "Name", - "DESCRIPTION":"Description", + "DESCRIPTION": "Description", "STATUS": "Status", "UPDATED-AT": "Updated", "CREATED-AT": "Created", "PUBLISHED-AT": "Published", - "IS-ACTIVE":"Is Active" + "IS-ACTIVE": "Is Active" }, "FILTER": { "TITLE": "Filters", @@ -1219,18 +1253,18 @@ "TITLE": "Notification Templates", "CREATE": "Create Notification Template", "FIELDS": { - "LANGUAGE":"Language", - "KIND":"Kind", - "CHANNEL":"Channel", + "LANGUAGE": "Language", + "KIND": "Kind", + "CHANNEL": "Channel", "UPDATED-AT": "Updated", "CREATED-AT": "Created", - "IS-ACTIVE":"Is Active" + "IS-ACTIVE": "Is Active" }, "FILTER": { "TITLE": "Filters", "IS-ACTIVE": "Is Active", - "KIND":"Kind", - "CHANNEL":"Channel", + "KIND": "Kind", + "CHANNEL": "Channel", "CANCEL": "Cancel", "APPLY-FILTERS": "Apply filters" }, @@ -1294,7 +1328,7 @@ } }, "NOTIFICATION-SERVICE": { - "NOTIFICATION-TEMPLATE-EDITOR":{ + "NOTIFICATION-TEMPLATE-EDITOR": { "NEW": "New Notification Template", "FIELDS": { "LANGUAGE": "Language", @@ -1302,9 +1336,9 @@ "KIND": "Kind", "OPTIONAL-TITLE": "Optional Fields", "FIELD": "Field", - "KEY":"Key", - "DATA-TYPE":"Data Type", - "VALUE":"Value", + "KEY": "Key", + "DATA-TYPE": "Data Type", + "VALUE": "Value", "SUBJECT-SECTION": "Subject Section", "SUBJECT-TEXT": "Subject Text", "SUBJECT-KEY": "Subject Key", @@ -1384,7 +1418,6 @@ "PROPERTIES": "Properties", "PROPERTY": "Property", "TARGET": "Target" - }, "ACTIONS": { "SAVE": "Save", @@ -1414,16 +1447,16 @@ "CODE": "Code", "DESCRIPTION": "Description", "DESCRIPTION-PLACEHOLDER": "Tenant description", - "DEPOSIT":"Deposit", + "DEPOSIT": "Deposit", "SOURCE": "Source", - "URL":"Url", + "URL": "Url", "CODES": "Codes", "CODES-PLACEHOLDER": "New code ..", "ISSUER-URL": "Issuer Url", "CLIENT-ID": "Client ID", "CLIENT-SECRET": "Client Secret", "SCOPE": "Scope", - "FILE-TRANSFORMERS":"File transformers" + "FILE-TRANSFORMERS": "File transformers" }, "ACTIONS": { "SAVE": "Save", @@ -1447,15 +1480,15 @@ "TYPE": "Type", "DESCRIPTION": "Description", "DESCRIPTION-PLACEHOLDER": "Reference description", - "REFERENCE":"reference", + "REFERENCE": "reference", "ABBREVIATION": "abbreviation", "SOURCE": "source", - "SOURCE-TYPE":"Source Type", - "FIELDS":"Fields", - "FIELD":"Field", - "CODE":"Code", - "DATA-TYPE":"Data Type", - "VALUE":"Value" + "SOURCE-TYPE": "Source Type", + "FIELDS": "Fields", + "FIELD": "Field", + "CODE": "Code", + "DATA-TYPE": "Data Type", + "VALUE": "Value" }, "ACTIONS": { "SAVE": "Save", @@ -1546,7 +1579,33 @@ } }, "DMP-EDITOR": { - "TITLE": { + "TITLE-EDIT": "Editing DMP", + "TITLE": "DMP Blueprint", + "UNSAVED-CHANGES": "unsaved changes", + "LOCKED": "Locked", + "DESCRIPTION": "Description", + "NO-TEMPLATE-MESSAGE": "If you can't find a template or if you want to create a personalized template for your institution, research community or training needs, please contact us.", + "FIELDS": { + "TITLE": "Title of DMP", + "DESCRIPTION": "Description", + "BLUEPRINT": "Blueprint", + "LICENSE": "License", + "ACCESS-TYPE": "Access Rights", + "CONTACT": "Contact", + "DESCRIPTION-TEMPLATES": "Description templates", + "DESCRIPTION-TEMPLATES-HINT": "Select a template to describe your descriptions" + }, + "ACTIONS": { + "DISCARD": "Discard", + "SAVE": "Save", + "DELETE": "Delete", + "ADD-DESCRIPTION-IN-SECTION": "Add Description", + "PREVIOUS-STEP": "Previous", + "NEXT-STEP": "Next", + "DEFAULT-BLUEPRINT": "Default Blueprint", + "OR-CONTINUE-WITH": "or continue with" + }, + "TITLE1": { "NEW": "New Data Management Plan", "EDIT": "Edit", "EDIT-DMP": "Editing DMP", @@ -1558,7 +1617,7 @@ "SUBTITLE": "DOI provided by", "PREVIEW-DATASET": "Previewing Dataset" }, - "FIELDS": { + "FIELDS1": { "NAME": "Title of DMP", "RELATED-GRANT": "Related Grant", "DESCRIPTION": "Description", @@ -1595,10 +1654,8 @@ "COST": "Costs", "DESCRIPTIONS": "Descriptions" }, - "ACTIONS": { + "ACTIONS1": { "GO-TO-GRANT": "Go To DMP Grant", - "DEFAULT-BLUEPRINT": "Default Blueprint", - "OR-CONTINUE-WITH": "or continue with", "GO-TO-DATASETS": "Go To Datasets", "SAVE-CHANGES": "Save Changes", "SAVE": "Save", @@ -1679,17 +1736,61 @@ "DATASET-DESCRIPTION": { "INTRO": "In general terms, your research data should be 'fair', that is findable, accessible, interoperable and re-usable. these principles precede implementation choices and do not necessarily suggest any specific technology, standard, or implementation-solution. this template is not intended as a strict technical implementation of the fair principles, it is rather inspired by fair as a general concept." }, - "CHANGES": "unsaved changes", "CLONE-DIALOG": { "CLONE": "Clone", "SAVE": "Save", "CANCEL": "Cancel" }, - "LOCKED": { + "LOCKED1": { "TITLE": "DMP is locked", "MESSAGE": "Somebody else is modifying the DMP at this moment. You may view the dataset but you cannot make any changes." } }, + "DMP-CLONE-DIALOG": { + "TITLE": "Clone", + "FIELDS": { + "LABEL": "Title of DMP", + "DESCRIPTION": "Description", + "DESCRIPTION-HINT": "A brief description of what the DMP is about, it’s scope and objectives.", + "DESCRIPTION-PLACEHOLDER": "Fill with Description", + "DESCRIPTIONS": "Descriptions", + "DESCRIPTIONS-HINT": "Select which descriptions to include in the new DMP. Selected descriptions will be editable." + }, + "NO-DESCRIPTIONS": "Not available Descriptions for this DMP.", + "ACTIONS": { + "CANCEL": "Cancel", + "CLONE": "Clone" + } + }, + "DMP-NEW-VERSION-DIALOG": { + "TITLE": "New Version", + "FIELDS": { + "LABEL": "Title of DMP", + "DESCRIPTION": "Description", + "DESCRIPTION-HINT": "A brief description of what the DMP is about, it’s scope and objectives.", + "DESCRIPTION-PLACEHOLDER": "Fill with Description", + "DESCRIPTIONS": "Descriptions", + "DESCRIPTIONS-HINT": "Select which descriptions to include in the new DMP. Selected descriptions will be editable.", + "BLUEPRINT": "DMP Blueprint", + "BLUEPRINT-PLACEHOLDER": "DMP Blueprint" + }, + "NO-DESCRIPTIONS": "Not available Descriptions for this DMP.", + "ACTIONS": { + "CANCEL": "Cancel", + "NEW-VERSION": "Create New Version" + } + }, + "DMP-USER-INVITATION-DIALOG": { + "TITLE": "Invite authors", + "FIELDS": { + "USERS": "Kat or kat@example.com", + "USERS-PLACEHOLDER": "Kat or kat@example.com", + "USERS-HINT": "Press comma or enter between authors" + }, + "ACTIONS": { + "INVITE": "Invite" + } + }, "DMP-BLUEPRINT-LISTING": { "TITLE": "DMP Blueprints", "CREATE-DMP-BLUEPRINT": "Create DMP Blueprint", @@ -1699,7 +1800,7 @@ "UPDATED-AT": "Updated", "CREATED-AT": "Created", "PUBLISHED-AT": "Published", - "IS-ACTIVE":"Is Active" + "IS-ACTIVE": "Is Active" }, "FILTER": { "TITLE": "Filters", @@ -1933,9 +2034,9 @@ "MANAGER": "Manager", "DESCRIPTION-TEMPLATE-EDITOR": "Description Template Editor" }, - "IS-ACTIVE":{ - "ACTIVE":"Active", - "INACTIVE":"Inactive" + "IS-ACTIVE": { + "ACTIVE": "Active", + "INACTIVE": "Inactive" }, "DMP-PROFILE-FIELD": { "DATA-TYPE": { @@ -2106,19 +2207,19 @@ "TEXT": "Text", "EXTERNAL-AUTOCOMPLETE": "External AutoComplete" }, - "REFERENCE-FIELD-DATA-TYPE":{ + "REFERENCE-FIELD-DATA-TYPE": { "TEXT": "Text", "DATE": "Date" }, - "REFERENCE-TYPE-SOURCE-TYPE":{ + "REFERENCE-TYPE-SOURCE-TYPE": { "API": "API", "STATIC": "Static" }, - "REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE":{ + "REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE": { "GET": "GET", "POST": "POST" }, - "REFERENCE-TYPE":{ + "REFERENCE-TYPE": { "TAXONOMY": "Taxonomy", "LICENCE": "License", "PUBLICATION": "Publication", @@ -2134,28 +2235,28 @@ "GRANT": "Grant", "RESEARCHER": "Researcher" }, - "REFERENCE-SOURCE-TYPE":{ + "REFERENCE-SOURCE-TYPE": { "INTERNAL": "Internal", "EXTERNAL": "External" }, - "NOTIFICATION-TEMPLATE-KIND":{ + "NOTIFICATION-TEMPLATE-KIND": { "DRAFT": "Draft", "SECONDARY": "Secondary", "PRIMARY": "Primary", "DEFAULT": "Default" }, - "NOTIFICATION-TEMPLATE-CHANNEL":{ + "NOTIFICATION-TEMPLATE-CHANNEL": { "EMAIL": "Email", "INAPP": "In App" }, - "NOTIFICATION-TEMPLATE-DATA-TYPE":{ + "NOTIFICATION-TEMPLATE-DATA-TYPE": { "INTEGER": "Integer", "DEMICAL": "Demical", "DOUBLE": "Double", "DATE-TIME": "Date Time", "STRING": "String" }, - "NOTIFICATION-TEMPLATE-EMAIL-OVERRIDE-MODE":{ + "NOTIFICATION-TEMPLATE-EMAIL-OVERRIDE-MODE": { "NOT": "Not Override", "ADDITIVE": "Additive", "REPLACE": "Replace" @@ -2603,4 +2704,4 @@ "FINALIZED": "Finalized", "DELETED": "Deleted" } -} +} \ No newline at end of file diff --git a/dmp-frontend/src/assets/scss/blue-theme.scss b/dmp-frontend/src/assets/scss/blue-theme.scss index 1c770e3e2..f7fd23ce1 100644 --- a/dmp-frontend/src/assets/scss/blue-theme.scss +++ b/dmp-frontend/src/assets/scss/blue-theme.scss @@ -1,5 +1,4 @@ @use '@angular/material' as mat; -@import "app/ui/misc/navigation/navigation.component.scss"; @import "@angular/material/theming"; // @import '../../../node_modules/@angular/material/theming'; $app-blue-theme-primary-palette: ( @@ -134,7 +133,6 @@ $custom-typography: mat.define-legacy-typography-config( @include mat.legacy-core(); @include mat.all-legacy-component-themes($custom-theme); - @include navigation-component-theme($custom-theme); // Override typography CSS classes (e.g., mat-h1, mat-display-1, mat-typography, etc.). @include mat.legacy-typography-hierarchy($custom-typography); diff --git a/dmp-frontend/src/assets/scss/green-theme.scss b/dmp-frontend/src/assets/scss/green-theme.scss index e61bf71f9..84da95ce6 100644 --- a/dmp-frontend/src/assets/scss/green-theme.scss +++ b/dmp-frontend/src/assets/scss/green-theme.scss @@ -1,5 +1,4 @@ @use '@angular/material' as mat; -@import "app/ui/misc/navigation/navigation.component.scss"; @import "@angular/material/theming"; // @import '../../../node_modules/@angular/material/theming'; $app-green-theme-primary-palette: ( @@ -134,7 +133,6 @@ $custom-typography: mat.define-legacy-typography-config( @include mat.legacy-core(); @include mat.all-legacy-component-themes($custom-theme); - @include navigation-component-theme($custom-theme); // Override typography CSS classes (e.g., mat-h1, mat-display-1, mat-typography, etc.). @include mat.legacy-typography-hierarchy($custom-typography); diff --git a/dmp-frontend/src/common/base/base-entity.model.ts b/dmp-frontend/src/common/base/base-entity.model.ts index 11994812e..04dfd1b29 100644 --- a/dmp-frontend/src/common/base/base-entity.model.ts +++ b/dmp-frontend/src/common/base/base-entity.model.ts @@ -2,14 +2,14 @@ import { IsActive } from '@app/core/common/enum/is-active.enum'; import { Guid } from '@common/types/guid'; export interface BaseEntity { - id: Guid; - isActive: IsActive; - createdAt: Date; - updatedAt: Date; - hash: string; + id?: Guid; + isActive?: IsActive; + createdAt?: Date; + updatedAt?: Date; + hash?: string; } export interface BaseEntityPersist { - id: Guid; - hash: string; + id?: Guid; + hash?: string; }