Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Efstratios Giannopoulos 2024-02-28 18:49:24 +02:00
commit ef50193175
104 changed files with 4096 additions and 1708 deletions

View File

@ -6,14 +6,14 @@ import jakarta.xml.bind.annotation.XmlEnumValue;
import java.util.Map;
public enum ReferenceTypeExternalApiHTTPMethodType implements DatabaseEnum<Short> {
public enum ExternalFetcherApiHTTPMethodType implements DatabaseEnum<Short> {
@XmlEnumValue(value = "0")
GET((short) 0),
@XmlEnumValue(value = "1")
POST((short) 1);
private final Short value;
ReferenceTypeExternalApiHTTPMethodType(Short value) {
ExternalFetcherApiHTTPMethodType(Short value) {
this.value = value;
}
@ -22,9 +22,9 @@ public enum ReferenceTypeExternalApiHTTPMethodType implements DatabaseEnum<Short
return value;
}
private static final Map<Short, ReferenceTypeExternalApiHTTPMethodType> map = EnumUtils.getEnumValueMap(ReferenceTypeExternalApiHTTPMethodType.class);
private static final Map<Short, ExternalFetcherApiHTTPMethodType> map = EnumUtils.getEnumValueMap(ExternalFetcherApiHTTPMethodType.class);
public static ReferenceTypeExternalApiHTTPMethodType of(Short i) {
public static ExternalFetcherApiHTTPMethodType of(Short i) {
return map.get(i);
}
}

View File

@ -3,11 +3,10 @@ package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import jakarta.xml.bind.annotation.XmlValue;
import java.util.Map;
public enum ReferenceTypeSourceType implements DatabaseEnum<Short> {
public enum ExternalFetcherSourceType implements DatabaseEnum<Short> {
@XmlEnumValue(value = "0")
API((short) 0),
@XmlEnumValue(value = "1")
@ -19,7 +18,7 @@ public enum ReferenceTypeSourceType implements DatabaseEnum<Short> {
public static final String STATIC = "static";
}
ReferenceTypeSourceType(Short value) {
ExternalFetcherSourceType(Short value) {
this.value = value;
}
@ -28,9 +27,9 @@ public enum ReferenceTypeSourceType implements DatabaseEnum<Short> {
return value;
}
private static final Map<Short, ReferenceTypeSourceType> map = EnumUtils.getEnumValueMap(ReferenceTypeSourceType.class);
private static final Map<Short, ExternalFetcherSourceType> map = EnumUtils.getEnumValueMap(ExternalFetcherSourceType.class);
public static ReferenceTypeSourceType of(Short i) {
public static ExternalFetcherSourceType of(Short i) {
return map.get(i);
}
}

View File

@ -37,6 +37,10 @@ public class SectionEntity {
@XmlElement(name = "descriptionTemplate")
private List<DescriptionTemplateEntity> descriptionTemplates;
@XmlElementWrapper(name = "prefillingSourcesIds")
@XmlElement(name = "id")
private List<UUID> prefillingSourcesIds;
public UUID getId() {
return id;
}
@ -86,6 +90,14 @@ public class SectionEntity {
this.descriptionTemplates = descriptionTemplates;
}
public List<UUID> getPrefillingSourcesIds() {
return prefillingSourcesIds;
}
public void setPrefillingSourcesIds(List<UUID> prefillingSourcesIds) {
this.prefillingSourcesIds = prefillingSourcesIds;
}
public List<FieldEntity> getAllField(){
return this.getFields() != null ? this.getFields() : new ArrayList<>();
}

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
import eu.eudat.service.externalfetcher.config.entities.AuthenticationConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
@ -8,7 +8,7 @@ public class AuthenticationConfigurationEntity implements AuthenticationConfigur
private Boolean enabled;
private String authUrl;
private ReferenceTypeExternalApiHTTPMethodType authMethod;
private ExternalFetcherApiHTTPMethodType authMethod;
private String authTokenPath;
private String authRequestBody;
private String type;
@ -31,12 +31,12 @@ public class AuthenticationConfigurationEntity implements AuthenticationConfigur
this.authUrl = authUrl;
}
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
public ExternalFetcherApiHTTPMethodType getAuthMethod() {
return authMethod;
}
@XmlElement(name = "authUrlMethod")
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
public void setAuthMethod(ExternalFetcherApiHTTPMethodType authMethod) {
this.authMethod = authMethod;
}

View File

@ -1,7 +1,7 @@
package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
import eu.eudat.service.externalfetcher.config.entities.SourceExternalApiConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
@ -14,7 +14,7 @@ public class ExternalFetcherApiSourceConfigurationEntity extends ExternalFetcher
private String paginationPath;
private String contentType;
private String firstPage;
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
private ExternalFetcherApiHTTPMethodType httpMethod;
private String requestBody = "";
private String filterType = "remote";
private AuthenticationConfigurationEntity auth;
@ -62,12 +62,12 @@ public class ExternalFetcherApiSourceConfigurationEntity extends ExternalFetcher
this.firstPage = firstPage;
}
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
public ExternalFetcherApiHTTPMethodType getHttpMethod() {
return httpMethod;
}
@XmlElement(name = "requestHttpMethod")
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
this.httpMethod = httpMethod != null ? httpMethod : ReferenceTypeExternalApiHTTPMethodType.GET;
public void setHttpMethod(ExternalFetcherApiHTTPMethodType httpMethod) {
this.httpMethod = httpMethod != null ? httpMethod : ExternalFetcherApiHTTPMethodType.GET;
}
public String getRequestBody() {
return requestBody;

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
@ -15,10 +15,10 @@ public abstract class ExternalFetcherBaseSourceConfigurationEntity implements So
private String label;
private Integer ordinal;
private ReferenceTypeSourceType type;
private ExternalFetcherSourceType type;
private List<UUID> referenceTypeDependencyIds;
public ReferenceTypeSourceType getType() {
public ExternalFetcherSourceType getType() {
return type;
}
@ -50,7 +50,7 @@ public abstract class ExternalFetcherBaseSourceConfigurationEntity implements So
}
@XmlElement(name = "type")
public void setType(ReferenceTypeSourceType type) {
public void setType(ExternalFetcherSourceType type) {
this.type = type;
}

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.referencetype;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherBaseSourceConfigurationEntity;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
@ -17,8 +17,8 @@ public class ReferenceTypeDefinitionEntity {
@XmlElementWrapper(name = "sources")
@XmlElements({
@XmlElement(name = ReferenceTypeSourceType.Names.API, type = ExternalFetcherApiSourceConfigurationEntity.class),
@XmlElement(name = ReferenceTypeSourceType.Names.STATIC, type = ExternalFetcherStaticOptionSourceConfigurationEntity.class),
@XmlElement(name = ExternalFetcherSourceType.Names.API, type = ExternalFetcherApiSourceConfigurationEntity.class),
@XmlElement(name = ExternalFetcherSourceType.Names.STATIC, type = ExternalFetcherStaticOptionSourceConfigurationEntity.class),
})
private List<ExternalFetcherBaseSourceConfigurationEntity> sources;

View File

@ -3,7 +3,9 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.tenant.TenantScopedBaseEntity;
import eu.eudat.data.types.SQLXMLType;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant;
import java.util.UUID;
@ -22,7 +24,8 @@ public class PrefillingSourceEntity extends TenantScopedBaseEntity {
public static final String _label = "label";
public static final int _labelLength = 250;
@Column(name = "definition")
@Type(value = SQLXMLType.class)
@Column(name = "definition", nullable = false, columnDefinition = "xml")
private String definition;
public static final String _definition = "definition";

View File

@ -4,9 +4,13 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
import eu.eudat.commons.types.dmpblueprint.*;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.builder.PrefillingSourceBuilder;
import eu.eudat.model.dmpblueprintdefinition.Section;
import eu.eudat.query.PrefillingSourceQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
@ -24,13 +28,15 @@ import java.util.*;
public class SectionBuilder extends BaseBuilder<Section, SectionEntity> {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public SectionBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(SectionBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
}
public SectionBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -48,6 +54,7 @@ public class SectionBuilder extends BaseBuilder<Section, SectionEntity> {
//Not Bulk Build because is XML no interaction with db
FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Section._descriptionTemplates));
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(Section._fields));
FieldSet prefillingSourcesFields = fields.extractPrefixed(this.asPrefix(Section._prefillingSources));
List<Section> models = new ArrayList<>();
for (SectionEntity d : data) {
@ -67,6 +74,10 @@ public class SectionBuilder extends BaseBuilder<Section, SectionEntity> {
List<ReferenceTypeFieldEntity> referenceFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList();
m.getFields().addAll(this.builderFactory.builder(ReferenceFieldBuilder.class).authorize(this.authorize).build(fieldsFields, referenceFieldEntities));
}
if (!prefillingSourcesFields.isEmpty() && d.getPrefillingSourcesIds() != null) {
List<PrefillingSourceEntity> prefillingSourceEntities = this.queryFactory.query(PrefillingSourceQuery.class).authorize(this.authorize).ids(d.getPrefillingSourcesIds()).collectAs(prefillingSourcesFields);
m.setPrefillingSources(this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(this.authorize).build(prefillingSourcesFields, prefillingSourceEntities));
}
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -5,6 +5,7 @@ import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.builder.externalfetcher.ExternalFetcherApiSourceConfigurationBuilder;
import eu.eudat.model.externalfetcher.ExternalFetcherApiSourceConfiguration;
import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException;
@ -53,6 +54,12 @@ public class PrefillingSourceDefinitionBuilder extends BaseBuilder<PrefillingSou
for (PrefillingSourceDefinitionEntity d : data) {
PrefillingSourceDefinition m = new PrefillingSourceDefinition();
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(PrefillingSourceDefinitionFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
if (!searchConfigurationFields.isEmpty() && d.getSearchConfiguration() != null) {
m.setSearchConfiguration((ExternalFetcherApiSourceConfiguration) this.builderFactory.builder(ExternalFetcherApiSourceConfigurationBuilder.class).authorize(this.authorize).build(searchConfigurationFields, d.getSearchConfiguration()));
}
if (!getConfigurationFields.isEmpty() && d.getGetConfiguration() != null) {
m.setGetConfiguration((ExternalFetcherApiSourceConfiguration) this.builderFactory.builder(ExternalFetcherApiSourceConfigurationBuilder.class).authorize(this.authorize).build(searchConfigurationFields, d.getGetConfiguration()));
}
models.add(m);
}

View File

@ -1,7 +1,7 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
@ -58,8 +58,8 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDef
ReferenceTypeDefinition m = new ReferenceTypeDefinition();
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceTypeFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
if (!sourcesFields.isEmpty() && d.getSources() != null) {
List<ExternalFetcherApiSourceConfigurationEntity> externalApiConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList();
List<ExternalFetcherStaticOptionSourceConfigurationEntity> staticOptionConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.STATIC.equals(x.getType())).map(x-> (ExternalFetcherStaticOptionSourceConfigurationEntity)x).toList();
List<ExternalFetcherApiSourceConfigurationEntity> externalApiConfigEntities = d.getSources().stream().filter(x-> ExternalFetcherSourceType.API.equals(x.getType())).map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList();
List<ExternalFetcherStaticOptionSourceConfigurationEntity> staticOptionConfigEntities = d.getSources().stream().filter(x-> ExternalFetcherSourceType.STATIC.equals(x.getType())).map(x-> (ExternalFetcherStaticOptionSourceConfigurationEntity)x).toList();
m.setSources(new ArrayList<>());
m.getSources().addAll(this.builderFactory.builder(ExternalFetcherApiSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities));
m.getSources().addAll(this.builderFactory.builder(ExternalFetcherStaticOptionSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities));

View File

@ -1,6 +1,8 @@
package eu.eudat.model.dmpblueprintdefinition;
import eu.eudat.model.PrefillingSource;
import java.util.List;
import java.util.UUID;
@ -27,6 +29,9 @@ public class Section {
public final static String _descriptionTemplates = "descriptionTemplates";
private List<DescriptionTemplate> descriptionTemplates;
public final static String _prefillingSources = "prefillingSources";
private List<PrefillingSource> prefillingSources;
public UUID getId() {
return id;
}
@ -82,6 +87,14 @@ public class Section {
public void setDescriptionTemplates(List<DescriptionTemplate> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
public List<PrefillingSource> getPrefillingSources() {
return prefillingSources;
}
public void setPrefillingSources(List<PrefillingSource> prefillingSources) {
this.prefillingSources = prefillingSources;
}
}

View File

@ -1,6 +1,6 @@
package eu.eudat.model.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
public class AuthenticationConfiguration {
@ -11,7 +11,7 @@ public class AuthenticationConfiguration {
private String authUrl;
public final static String _authMethod = "authMethod";
private ReferenceTypeExternalApiHTTPMethodType authMethod;
private ExternalFetcherApiHTTPMethodType authMethod;
public final static String _authTokenPath = "authTokenPath";
private String authTokenPath;
@ -39,12 +39,12 @@ public class AuthenticationConfiguration {
this.authUrl = authUrl;
}
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
public ExternalFetcherApiHTTPMethodType getAuthMethod() {
return authMethod;
}
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
public void setAuthMethod(ExternalFetcherApiHTTPMethodType authMethod) {
this.authMethod = authMethod;
}

View File

@ -1,7 +1,7 @@
package eu.eudat.model.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
import java.util.List;
public class ExternalFetcherApiSourceConfiguration extends ExternalFetcherBaseSourceConfiguration {
@ -23,7 +23,7 @@ public class ExternalFetcherApiSourceConfiguration extends ExternalFetcherBaseSo
private String firstPage;
public final static String _httpMethod = "httpMethod";
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
private ExternalFetcherApiHTTPMethodType httpMethod;
public final static String _requestBody = "requestBody";
private String requestBody = "";
@ -78,11 +78,11 @@ public class ExternalFetcherApiSourceConfiguration extends ExternalFetcherBaseSo
this.firstPage = firstPage;
}
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
public ExternalFetcherApiHTTPMethodType getHttpMethod() {
return httpMethod;
}
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
public void setHttpMethod(ExternalFetcherApiHTTPMethodType httpMethod) {
this.httpMethod = httpMethod;
}

View File

@ -1,6 +1,6 @@
package eu.eudat.model.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.model.ReferenceType;
import java.util.List;
@ -18,16 +18,16 @@ public abstract class ExternalFetcherBaseSourceConfiguration {
private Integer ordinal;
public final static String _type = "type";
private ReferenceTypeSourceType type;
private ExternalFetcherSourceType type;
public final static String _referenceTypeDependencies = "referenceTypeDependencies";
private List<ReferenceType> referenceTypeDependencies;
public ReferenceTypeSourceType getType() {
public ExternalFetcherSourceType getType() {
return type;
}
public void setType(ReferenceTypeSourceType type) {
public void setType(ExternalFetcherSourceType type) {
this.type = type;
}

View File

@ -45,6 +45,10 @@ public class SectionPersist {
public static final String _descriptionTemplates = "descriptionTemplates";
private List<UUID> prefillingSourcesIds= null;
public static final String _prefillingSourcesIds = "prefillingSourcesIds";
public UUID getId() {
return id;
}
@ -101,6 +105,14 @@ public class SectionPersist {
this.descriptionTemplates = descriptionTemplates;
}
public List<UUID> getPrefillingSourcesIds() {
return prefillingSourcesIds;
}
public void setPrefillingSourcesIds(List<UUID> prefillingSourcesIds) {
this.prefillingSourcesIds = prefillingSourcesIds;
}
@Component(SectionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class SectionPersistValidator extends BaseValidator<SectionPersist> {

View File

@ -1,6 +1,6 @@
package eu.eudat.model.persist.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
import eu.eudat.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
@ -24,7 +24,7 @@ public class AuthenticationConfigurationPersist {
public static final String _authUrl = "authUrl";
private ReferenceTypeExternalApiHTTPMethodType authMethod;
private ExternalFetcherApiHTTPMethodType authMethod;
public static final String _authMethod = "authMethod";
@ -56,11 +56,11 @@ public class AuthenticationConfigurationPersist {
this.authUrl = authUrl;
}
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
public ExternalFetcherApiHTTPMethodType getAuthMethod() {
return authMethod;
}
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
public void setAuthMethod(ExternalFetcherApiHTTPMethodType authMethod) {
this.authMethod = authMethod;
}

View File

@ -1,6 +1,6 @@
package eu.eudat.model.persist.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.validation.ValidatorFactory;
@ -36,13 +36,13 @@ public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetche
public static final String _firstPage = "firstPage";
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
private ExternalFetcherApiHTTPMethodType httpMethod;
public static final String _httpMethod = "httpMethod";
private String requestBody = "";
private String requestBody;
private String filterType = "remote";
private String filterType;
private AuthenticationConfigurationPersist auth;
@ -92,11 +92,11 @@ public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetche
this.firstPage = firstPage;
}
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
public ExternalFetcherApiHTTPMethodType getHttpMethod() {
return httpMethod;
}
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
public void setHttpMethod(ExternalFetcherApiHTTPMethodType httpMethod) {
this.httpMethod = httpMethod;
}
@ -132,13 +132,13 @@ public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetche
this.queries = queries;
}
@Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName)
@Component(ExternalFetcherApiSourceConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ExternalFetcherApiSourceConfigurationPersist> {
public static class ExternalFetcherApiSourceConfigurationPersistValidator extends ExternalFetcherBaseSourceConfigurationPersistValidator<ExternalFetcherApiSourceConfigurationPersist> {
public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator";
public static final String ValidatorName = "ExternalFetcherApiSourceConfigurationPersistValidator";
protected ReferenceTypeSourceExternalApiConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
protected ExternalFetcherApiSourceConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors, messageSource, validatorFactory);
}
@ -160,9 +160,6 @@ public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetche
this.spec()
.must(() -> !this.isEmpty(item.getContentType()))
.failOn(ExternalFetcherApiSourceConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._contentType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getFirstPage()))
.failOn(ExternalFetcherApiSourceConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getHttpMethod()))
.failOn(ExternalFetcherApiSourceConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())),

View File

@ -2,7 +2,7 @@ package eu.eudat.model.persist.externalfetcher;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
@ -39,7 +39,7 @@ public abstract class ExternalFetcherBaseSourceConfigurationPersist {
public static final String _ordinal = "ordinal";
private ReferenceTypeSourceType type;
private ExternalFetcherSourceType type;
public static final String _type = "type";
@ -71,11 +71,11 @@ public abstract class ExternalFetcherBaseSourceConfigurationPersist {
this.ordinal = ordinal;
}
public ReferenceTypeSourceType getType() {
public ExternalFetcherSourceType getType() {
return type;
}
public void setType(ReferenceTypeSourceType type) {
public void setType(ExternalFetcherSourceType type) {
this.type = type;
}
@ -87,13 +87,13 @@ public abstract class ExternalFetcherBaseSourceConfigurationPersist {
this.referenceTypeDependencyIds = referenceTypeDependencyIds;
}
public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator<T extends ExternalFetcherBaseSourceConfigurationPersist> extends BaseValidator<T> {
public static abstract class ExternalFetcherBaseSourceConfigurationPersistValidator<T extends ExternalFetcherBaseSourceConfigurationPersist> extends BaseValidator<T> {
protected final MessageSource messageSource;
protected final ValidatorFactory validatorFactory;
protected ReferenceTypeSourceBaseConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
protected ExternalFetcherBaseSourceConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;

View File

@ -25,13 +25,13 @@ public class ExternalFetcherStaticOptionSourceConfigurationPersist extends Exter
this.options = options;
}
@Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName)
@Component(ExternalFetcherStaticOptionSourceConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ExternalFetcherStaticOptionSourceConfigurationPersist> {
public static class ExternalFetcherStaticOptionSourceConfigurationPersistValidator extends ExternalFetcherBaseSourceConfigurationPersistValidator<ExternalFetcherStaticOptionSourceConfigurationPersist> {
public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator";
public static final String ValidatorName = "ExternalFetcherStaticOptionSourceConfigurationPersistValidator";
protected ReferenceTypeSourceStaticOptionConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
protected ExternalFetcherStaticOptionSourceConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors, messageSource, validatorFactory);
}

View File

@ -91,7 +91,11 @@ public class PrefillingSourceDefinitionFieldPersist {
@Override
protected List<Specification> specifications(PrefillingSourceDefinitionFieldPersist item) {
return Arrays.asList();
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getCode()))
.failOn(PrefillingSourceDefinitionFieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFieldPersist._code}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -23,6 +23,9 @@ public class PrefillingSourceDefinitionPersist {
private ExternalFetcherApiSourceConfigurationPersist getConfiguration;
public static final String _getConfiguration = "getConfiguration";
private Boolean getEnabled;
public static final String _getEnabled = "getEnabled";
private List<PrefillingSourceDefinitionFieldPersist> fields;
public static final String _fields = "fields";
@ -42,6 +45,14 @@ public class PrefillingSourceDefinitionPersist {
this.getConfiguration = getConfiguration;
}
public Boolean getGetEnabled() {
return getEnabled;
}
public void setGetEnabled(Boolean getEnabled) {
this.getEnabled = getEnabled;
}
public List<PrefillingSourceDefinitionFieldPersist> getFields() {
return fields;
}
@ -81,12 +92,12 @@ public class PrefillingSourceDefinitionPersist {
.iff(() -> !this.isNull(item.getSearchConfiguration()))
.on(PrefillingSourceDefinitionPersist._searchConfiguration)
.over(item.getSearchConfiguration())
.using(() -> this.validatorFactory.validator(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.class)),
.using(() -> this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ExternalFetcherApiSourceConfigurationPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getGetConfiguration()))
.iff(() -> !this.isNull(item.getGetConfiguration()) && item.getGetEnabled())
.on(PrefillingSourceDefinitionPersist._getConfiguration)
.over(item.getGetConfiguration())
.using(() -> this.validatorFactory.validator(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.class)),
.using(() -> this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ExternalFetcherApiSourceConfigurationPersistValidator.class)),
this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(PrefillingSourceDefinitionPersist._fields)

View File

@ -1,6 +1,6 @@
package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.model.persist.externalfetcher.ExternalFetcherBaseSourceConfigurationPersist;
import eu.eudat.model.persist.externalfetcher.ExternalFetcherApiSourceConfigurationPersist;
@ -80,7 +80,7 @@ public class ReferenceTypeDefinitionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getSources()))
.on(ReferenceTypeDefinitionPersist._sources)
.over(item.getSources())
.using((itm) -> ((ExternalFetcherBaseSourceConfigurationPersist) itm).getType() == ReferenceTypeSourceType.STATIC? this.validatorFactory.validator(ExternalFetcherStaticOptionSourceConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class): this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class))
.using((itm) -> ((ExternalFetcherBaseSourceConfigurationPersist) itm).getType() == ExternalFetcherSourceType.STATIC? this.validatorFactory.validator(ExternalFetcherStaticOptionSourceConfigurationPersist.ExternalFetcherStaticOptionSourceConfigurationPersistValidator.class): this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ExternalFetcherApiSourceConfigurationPersistValidator.class))
);
}
}

View File

@ -216,6 +216,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
data.setLabel(persist.getLabel());
data.setOrdinal(persist.getOrdinal());
data.setHasTemplates(persist.getHasTemplates());
data.setPrefillingSourcesIds(persist.getPrefillingSourcesIds());
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
data.setFields(new ArrayList<>());
for (FieldPersist fieldPersist : persist.getFields()) {

View File

@ -6,7 +6,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.model.Reference;
@ -85,7 +85,7 @@ public class ExternalFetcherServiceImpl implements ExternalFetcherService {
if (this.conventionService.isListNullOrEmpty(sources)) return new ExternalDataResult();
for (SourceBaseConfiguration source : sources) {
if (source.getType() == null || source.getType().equals(ReferenceTypeSourceType.API)) {
if (source.getType() == null || source.getType().equals(ExternalFetcherSourceType.API)) {
try {
SourceExternalApiConfiguration<ResultsConfiguration<ResultFieldsMappingConfiguration>, AuthenticationConfiguration, QueryConfig<QueryCaseConfig>> apiSource = (SourceExternalApiConfiguration)source;
// this.applyFunderToQuery(apiSource, externalReferenceCriteria);
@ -98,7 +98,7 @@ public class ExternalFetcherServiceImpl implements ExternalFetcherService {
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
} else if (source.getType() != null && source.getType().equals(ReferenceTypeSourceType.STATIC)) {
} else if (source.getType() != null && source.getType().equals(ExternalFetcherSourceType.STATIC)) {
SourceStaticOptionConfiguration<StaticOption> staticSource = (SourceStaticOptionConfiguration)source;
results.addAll(queryStaticData(staticSource, externalReferenceCriteria));
}

View File

@ -1,37 +0,0 @@
package eu.eudat.service.externalfetcher;
import eu.eudat.service.externalfetcher.config.ExternalUrls;
import eu.eudat.service.storage.StorageFileService;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
@Service
public class ExternalUrlConfigProvider {
private static final Logger logger = LoggerFactory.getLogger(ExternalUrlConfigProvider.class);
private ExternalUrls externalUrls;
private final StorageFileService storageFileService;
public ExternalUrlConfigProvider(StorageFileService storageFileService) {
this.storageFileService = storageFileService;
}
public ExternalUrls getExternalUrls() {
if (externalUrls == null) {
byte[] bytes = this.storageFileService.getExternalUrlsFile();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(bytes));
} catch (Exception ex) {
logger.error("Cannot find resource", ex);
}
}
return externalUrls;
}
}

View File

@ -1,31 +0,0 @@
package eu.eudat.service.externalfetcher.config;
import eu.eudat.service.externalfetcher.config.prefilling.PrefillingConfigMapAdapter;
import eu.eudat.service.externalfetcher.config.entities.*;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.util.Map;
@XmlRootElement
public class ExternalUrls implements Serializable {
private static final long serialVersionUID = -5076364662014107275L;
Map<String, PrefillingConfig> prefillings;
public Map<String, PrefillingConfig> getPrefillings() {
return prefillings;
}
@XmlJavaTypeAdapter(PrefillingConfigMapAdapter.class)
@XmlElement(name = "prefillings")
public void setPrefillings(Map<String, PrefillingConfig> prefillings) {
this.prefillings = prefillings;
}
}

View File

@ -1,7 +1,7 @@
package eu.eudat.service.externalfetcher.config;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
public class UrlConfiguration implements SourceBaseConfiguration {
@ -9,7 +9,7 @@ public class UrlConfiguration implements SourceBaseConfiguration {
private String key;
private String label;
private Integer ordinal;
private ReferenceTypeSourceType type;
private ExternalFetcherSourceType type;
public String getKey() {
return key;
@ -35,11 +35,11 @@ public class UrlConfiguration implements SourceBaseConfiguration {
this.ordinal = ordinal;
}
public ReferenceTypeSourceType getType() {
public ExternalFetcherSourceType getType() {
return type;
}
public void setType(ReferenceTypeSourceType type) {
public void setType(ExternalFetcherSourceType type) {
this.type = type;
}
}

View File

@ -1,6 +1,6 @@
package eu.eudat.service.externalfetcher.config.entities;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
public interface AuthenticationConfiguration {
@ -8,7 +8,7 @@ public interface AuthenticationConfiguration {
String getAuthUrl();
ReferenceTypeExternalApiHTTPMethodType getAuthMethod();
ExternalFetcherApiHTTPMethodType getAuthMethod();
String getAuthTokenPath();

View File

@ -1,10 +1,10 @@
package eu.eudat.service.externalfetcher.config.entities;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
public interface SourceBaseConfiguration {
String getKey();
String getLabel();
Integer getOrdinal();
ReferenceTypeSourceType getType();
ExternalFetcherSourceType getType();
}

View File

@ -1,6 +1,6 @@
package eu.eudat.service.externalfetcher.config.entities;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.enums.ExternalFetcherApiHTTPMethodType;
import java.util.List;
@ -15,7 +15,7 @@ public interface SourceExternalApiConfiguration<RsConfig extends ResultsConfigur
String getFirstPage();
ReferenceTypeExternalApiHTTPMethodType getHttpMethod();
ExternalFetcherApiHTTPMethodType getHttpMethod();
String getRequestBody();

View File

@ -18,7 +18,6 @@ import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
import eu.eudat.service.externalfetcher.ExternalUrlConfigProvider;
import eu.eudat.service.externalfetcher.config.entities.*;
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.data.builder.BuilderFactory;
@ -59,7 +58,6 @@ public class PrefillingServiceImpl implements PrefillingService {
private final BuilderFactory builderFactory;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final ExternalUrlConfigProvider externalUrlConfigProvider;
private final XmlHandlingService xmlHandlingService;
private final ValidatorFactory validatorFactory;
@Autowired
@ -68,14 +66,12 @@ public class PrefillingServiceImpl implements PrefillingService {
BuilderFactory builderFactory,
ConventionService conventionService,
MessageSource messageSource,
ExternalUrlConfigProvider externalUrlConfigProvider,
XmlHandlingService xmlHandlingService,
ValidatorFactory validatorFactory) {
this.entityManager = entityManager;
this.builderFactory = builderFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.externalUrlConfigProvider = externalUrlConfigProvider;
this.xmlHandlingService = xmlHandlingService;
this.validatorFactory = validatorFactory;
}
@ -88,7 +84,6 @@ public class PrefillingServiceImpl implements PrefillingService {
externalReferenceCriteria.setLike(lookup.getLike());
List<PrefillingEntity> prefillings = new ArrayList<>();
List<Map<String, String>> map;
Map<String, PrefillingConfig> prefillingConfigs = this.externalUrlConfigProvider.getExternalUrls().getPrefillings();
// for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {//TODO new reference logic
// map = remoteFetcherService.getExternalData(prefillingConfig.getPrefillingSearch().getUrls(), externalReferenceCriteria, prefillingConfig.getPrefillingSearch().getFetchMode());
// prefillings.addAll(map.stream().map(submap -> PrefillingEntity.build(submap, this.jsonHandlingService)).toList());
@ -105,7 +100,7 @@ public class PrefillingServiceImpl implements PrefillingService {
@Override
public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(model.getConfigId());
PrefillingConfig prefillingConfig = null;
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
Map<String, Object> prefillingEntity = getSinglePrefillingData(prefillingGet.getUrl(), model.getPrefillId());
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
@ -129,7 +124,7 @@ public class PrefillingServiceImpl implements PrefillingService {
@Override
public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(model.getConfigId());
PrefillingConfig prefillingConfig = null;
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());

View File

@ -114,6 +114,12 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
data.getFields().add(this.buildFieldEntity(fieldPersist));
}
}
if (persist.getSearchConfiguration() != null ) {
data.setSearchConfiguration(this.buildExternalFetcherApiConfigEntity(persist.getSearchConfiguration()));
}
if (persist.getGetConfiguration() != null && persist.getGetEnabled()) {
data.setGetConfiguration(this.buildExternalFetcherApiConfigEntity(persist.getGetConfiguration()));
}
return data;
}
@ -141,6 +147,11 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
if (persist.getResults() != null ) {
data.setResults(this.buildResultsConfigEntity(persist.getResults()));
}
data.setKey(persist.getKey());
data.setLabel(persist.getLabel());
data.setOrdinal(persist.getOrdinal());
data.setType(persist.getType());
data.setReferenceTypeDependencyIds(persist.getReferenceTypeDependencyIds());
data.setPaginationPath(persist.getPaginationPath());
data.setContentType(persist.getContentType());
data.setFirstPage(persist.getFirstPage());

View File

@ -4,7 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.enums.ExternalFetcherSourceType;
import eu.eudat.commons.types.externalfetcher.*;
import eu.eudat.commons.types.referencetype.*;
import eu.eudat.convention.ConventionService;
@ -141,7 +141,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
ExternalFetcherBaseSourceConfigurationEntity data;
if (ReferenceTypeSourceType.API.equals(persist.getType())) {
if (ExternalFetcherSourceType.API.equals(persist.getType())) {
ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity();
apiEntity.setUrl(((ExternalFetcherApiSourceConfigurationPersist) persist).getUrl());

View File

@ -33,8 +33,6 @@ public interface StorageFileService extends ApplicationListener<ApplicationReady
byte[] getSemanticsFile();
byte[] getExternalUrlsFile();
byte[] getPidLinksFile();
byte[] getH2020TemplateFile();

View File

@ -333,16 +333,6 @@ public class StorageFileServiceImpl implements StorageFileService {
}
}
@Override
public byte[] getExternalUrlsFile() {
try {
return this.readFileBytes(this.config.getStaticFiles().getExternalUrls());
}
catch (Exception ex) {
logger.warn("problem reading ExternalUrls file", ex);
return null;
}
}
@Override
public byte[] getPidLinksFile() {

View File

@ -1,21 +1,27 @@
import { IsActive } from "@app/core/common/enum/is-active.enum";
import { AnnotationProtectionType } from "@app/core/common/enum/annotation-protection-type.enum";
import { User } from "@app/core/model/user/user";
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
import { Guid } from "@common/types/guid";
export interface Annotation {
id: Guid;
export interface Annotation extends BaseEntity {
entityId: Guid;
entityType: string;
anchor?: string;
payload: string;
createdAt: Date;
updatedAt: Date;
isActive: IsActive;
timeStamp: Date;
author: User;
threadId: Guid;
parent: Annotation;
protection: AnnotationProtectionType;
}
export interface AnnotationPersist {
export interface AnnotationPersist extends BaseEntityPersist {
subjectId: Guid;
entityId: Guid;
entityType: string;
anchor: string;
payload: string;
threadId?: Guid;
parentId?: Guid;
protection: AnnotationProtectionType;
}

View File

@ -25,4 +25,5 @@ export interface AnnotationFilter {
isActive: IsActive;
entityIds: Guid[];
entityTypes: string[];
anchors: string[];
}

View File

@ -10,7 +10,7 @@ import { catchError } from "rxjs/operators";
@Injectable()
export class AnnotationService {
private get apiBase(): string { return `${this.installationConfiguration.annotationServiceAddress}api/annotation`; }
private get apiBase(): string { return `${this.installationConfiguration.annotationServiceAddress}/annotation`; }
constructor(
private installationConfiguration: ConfigurationService,

View File

@ -258,6 +258,18 @@ const appRoutes: Routes = [
})
},
},
{
path: 'prefilling-sources',
loadChildren: () => import('./ui/admin/prefilling-source/prefilling-source.module').then(m => m.PrefillingSourceModule),
data: {
authContext: {
permissions: [AppPermission.ViewPrefillingSourcePage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.PREFILLING-SOURCES'
})
},
},
{
path: 'tenants',
loadChildren: () => import('./ui/admin/tenant/tenant.module').then(m => m.TenantModule),

View File

@ -0,0 +1,4 @@
export enum AnnotationEntityType {
Description = "description",
Dmp = "dmp"
}

View File

@ -0,0 +1,4 @@
export enum AnnotationProtectionType {
Private = 0,
EntityAccessors = 1
}

View File

@ -0,0 +1,4 @@
export enum ExternalFetcherApiHTTPMethodType {
GET = 0,
POST = 1
}

View File

@ -0,0 +1,4 @@
export enum ExternalFetcherSourceType {
API = 0,
STATIC = 1
}

View File

@ -36,6 +36,7 @@ export enum AppPermission {
ViewNotificationTemplatePage = "ViewNotificationTemplatePage",
ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage",
ViewNotificationPage = "ViewNotificationPage",
ViewPrefillingSourcePage = "ViewPrefillingSourcePage",
//ReferenceType
BrowseReferenceType = "BrowseReferenceType",
@ -67,5 +68,10 @@ export enum AppPermission {
BrowseNotificationTemplate = "BrowseNotificationTemplate",
EditNotificationTemplate = "EditNotificationTemplate",
DeleteNotificationTemplate = "DeleteNotificationTemplate",
//Prefilling Source
BrowsePrefillingSource= "BrowsePrefillingSource",
EditPrefillingSource = "EditPrefillingSource",
DeletePrefillingSource = "DeletePrefillingSource",
}

View File

@ -0,0 +1,5 @@
export enum PrefillingSourceSystemTargetType {
Label = "label",
Description = "description",
Tags= "descriptionTags"
}

View File

@ -1,4 +0,0 @@
export enum ReferenceTypeExternalApiHTTPMethodType {
GET = 0,
POST = 1
}

View File

@ -1,4 +0,0 @@
export enum ReferenceTypeSourceType {
API = 0,
STATIC = 1
}

View File

@ -47,6 +47,7 @@ import { FileTransformerHttpService } from './services/file-transformer/file-tra
import { InAppNotificationService } from './services/inapp-notification/inapp-notification.service';
import { NotificationService } from './services/notification/notification-service';
import { SemanticsService } from './services/semantic/semantics.service';
import { PrefillingSourceService } from './services/prefilling-source/prefilling-source.service';
//
//
// This is shared module that provides all the services. Its imported only once on the AppModule.
@ -112,7 +113,8 @@ export class CoreServiceModule {
FileTransformerHttpService,
InAppNotificationService,
NotificationService,
SemanticsService
SemanticsService,
PrefillingSourceService
],
};
}

View File

@ -5,6 +5,7 @@ import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
import { Guid } from "@common/types/guid";
import { ReferenceType } from "../reference-type/reference-type";
import { PrefillingSource } from "../prefilling-source/prefilling-source";
export interface DmpBlueprint extends BaseEntity {
@ -28,6 +29,7 @@ export interface DmpBlueprintDefinitionSection {
fields: FieldInSection[];
hasTemplates: boolean;
descriptionTemplates?: DescriptionTemplatesInSection[];
prefillingSources: PrefillingSource[];
}
export interface DescriptionTemplatesInSection {
@ -87,6 +89,7 @@ export interface DmpBlueprintDefinitionSectionPersist {
fields: FieldInSectionPersist[];
hasTemplates: boolean;
descriptionTemplates?: DescriptionTemplatesInSectionPersist[];
prefillingSourcesIds: Guid[];
}
export interface DescriptionTemplatesInSectionPersist {

View File

@ -0,0 +1,136 @@
import { ExternalFetcherApiHTTPMethodType } from "@app/core/common/enum/external-fetcher-api-http-method-type";
import { ReferenceType } from "../reference-type/reference-type";
import { ExternalFetcherSourceType } from "@app/core/common/enum/external-fetcher-source-type";
import { Guid } from "@common/types/guid";
export interface ExternalFetcherBaseSourceConfiguration extends ExternalFetcherApiSourceConfiguration, ExternalFetcherStaticOptionSourceConfiguration{
type: ExternalFetcherSourceType;
key: string;
label: string;
ordinal: number;
referenceTypeDependencies?: ReferenceType[];
}
export interface ExternalFetcherApiSourceConfiguration{
url: string;
results: ResultsConfiguration;
paginationPath: string;
contentType: string;
firstPage: string;
httpMethod: ExternalFetcherApiHTTPMethodType;
requestBody?: string;
filterType?: string;
auth: AuthenticationConfiguration;
queries?: QueryConfig[];
}
export interface ResultsConfiguration{
resultsArrayPath: string;
fieldsMapping: ResultFieldsMappingConfiguration[];
}
export interface ResultFieldsMappingConfiguration{
code: string;
responsePath: string;
}
export interface AuthenticationConfiguration{
enabled: boolean;
authUrl: string;
authMethod: ExternalFetcherApiHTTPMethodType;
authTokenPath: string;
authRequestBody: string;
type: string;
}
export interface QueryConfig{
name: string;
defaultValue: string;
cases: QueryCaseConfig[];
}
export interface QueryCaseConfig{
likePattern: string,
separator: string;
value: string;
referenceType?: ReferenceType;
referenceTypeSourceKey: string
}
export interface ExternalFetcherStaticOptionSourceConfiguration{
options: StaticOption[];
}
export interface StaticOption{
code: string;
value: string;
}
//
// Persist
//
export interface ExternalFetcherBaseSourceConfigurationPersist extends ExternalFetcherApiSourceConfigurationPersist, ExternalFetcherStaticOptionSourceConfigurationPersist{
type: ExternalFetcherSourceType;
key: string;
label: string;
ordinal: number;
referenceTypeDependencyIds?: Guid[];
}
export interface ExternalFetcherApiSourceConfigurationPersist{
url: string;
results: ResultsConfigurationPersist;
paginationPath: string;
contentType: string;
firstPage: string;
httpMethod: ExternalFetcherApiHTTPMethodType;
requestBody?: string;
filterType?: string;
auth: AuthenticationConfigurationPersist;
queries?: QueryConfigPersist[];
}
export interface ResultsConfigurationPersist{
resultsArrayPath: string;
fieldsMapping: ResultFieldsMappingConfigurationPersist[];
}
export interface ResultFieldsMappingConfigurationPersist{
code: string;
responsePath: string;
}
export interface AuthenticationConfigurationPersist{
enabled: boolean;
authUrl: string;
authMethod: ExternalFetcherApiHTTPMethodType;
authTokenPath: string;
authRequestBody: string;
type: string;
}
export interface QueryConfigPersist{
name: string;
defaultValue: string;
cases: QueryCaseConfigPersist[];
}
export interface QueryCaseConfigPersist{
likePattern: string,
separator: string;
value: string;
referenceTypeId: Guid;
referenceTypeSourceKey: string
}
export interface ExternalFetcherStaticOptionSourceConfigurationPersist {
options: StaticOptionPersist[];
}
export interface StaticOptionPersist{
code: string;
value: string;
}

View File

@ -0,0 +1,43 @@
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
import { ExternalFetcherBaseSourceConfiguration, ExternalFetcherBaseSourceConfigurationPersist} from "../external-fetcher/external-fetcher";
export interface PrefillingSource extends BaseEntity{
label: string;
definition: PrefillingSourceDefinition;
}
export interface PrefillingSourceDefinition{
fields: PrefillingSourceDefinitionField[];
searchConfiguration: ExternalFetcherBaseSourceConfiguration;
getConfiguration: ExternalFetcherBaseSourceConfiguration;
}
export interface PrefillingSourceDefinitionField {
code: string;
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
}
// Persist
export interface PrefillingSourcePersist extends BaseEntityPersist{
label: string;
definition: PrefillingSourceDefinitionPersist;
}
export interface PrefillingSourceDefinitionPersist{
fields: PrefillingSourceDefinitionFieldPersist[];
searchConfiguration: ExternalFetcherBaseSourceConfigurationPersist;
getConfiguration: ExternalFetcherBaseSourceConfigurationPersist;
}
export interface PrefillingSourceDefinitionFieldPersist {
code: string;
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
}

View File

@ -1,8 +1,6 @@
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-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 { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
import { Guid } from "@common/types/guid";
import { ExternalFetcherBaseSourceConfiguration, ExternalFetcherBaseSourceConfigurationPersist } from "../external-fetcher/external-fetcher";
export interface ReferenceType extends BaseEntity{
name: string;
@ -12,7 +10,7 @@ export interface ReferenceType extends BaseEntity{
export interface ReferenceTypeDefinition{
fields: ReferenceTypeField[];
sources: ReferenceTypeSourceBaseConfiguration[];
sources: ExternalFetcherBaseSourceConfiguration[];
}
export interface ReferenceTypeField {
@ -22,69 +20,7 @@ export interface ReferenceTypeField {
dataType: ReferenceFieldDataType;
}
export interface ReferenceTypeSourceBaseConfiguration extends ReferenceTypeSourceExternalApiConfiguration, ReferenceTypeSourceStaticOptionConfiguration{
type: ReferenceTypeSourceType;
key: string;
label: string;
ordinal: number;
referenceTypeDependencies?: ReferenceType[];
}
export interface ReferenceTypeSourceExternalApiConfiguration{
url: string;
results: ResultsConfiguration;
paginationPath: string;
contentType: string;
firstPage: string;
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
requestBody?: string;
filterType?: string;
auth: AuthenticationConfiguration;
queries?: QueryConfig[];
}
export interface ResultsConfiguration{
resultsArrayPath: string;
fieldsMapping: ResultFieldsMappingConfiguration[];
}
export interface ResultFieldsMappingConfiguration{
code: string;
responsePath: string;
}
export interface AuthenticationConfiguration{
enabled: boolean;
authUrl: string;
authMethod: ReferenceTypeExternalApiHTTPMethodType;
authTokenPath: string;
authRequestBody: string;
type: string;
}
export interface QueryConfig{
name: string;
defaultValue: string;
cases: QueryCaseConfig[];
}
export interface QueryCaseConfig{
likePattern: string,
separator: string;
value: string;
referenceType?: ReferenceType;
referenceTypeSourceKey: string
}
export interface ReferenceTypeSourceStaticOptionConfiguration{
options: ReferenceTypeStaticOption[];
}
export interface ReferenceTypeStaticOption{
code: string;
value: string;
}
// Persist
@ -96,7 +32,7 @@ export interface ReferenceTypePersist extends BaseEntityPersist{
export interface ReferenceTypeDefinitionPersist{
fields?: ReferenceTypeFieldPersist[];
sources: ReferenceTypeSourceBaseConfigurationPersist[];
sources: ExternalFetcherBaseSourceConfigurationPersist[];
}
export interface ReferenceTypeFieldPersist {
@ -105,68 +41,3 @@ export interface ReferenceTypeFieldPersist {
description: string;
dataType: ReferenceFieldDataType;
}
export interface ReferenceTypeSourceBaseConfigurationPersist extends ReferenceTypeSourceExternalApiConfigurationPersist, ReferenceTypeSourceStaticOptionConfigurationPersist{
type: ReferenceTypeSourceType;
key: string;
label: string;
ordinal: number;
referenceTypeDependencyIds?: Guid[];
}
export interface ReferenceTypeSourceExternalApiConfigurationPersist{
url: string;
results: ResultsConfigurationPersist;
paginationPath: string;
contentType: string;
firstPage: string;
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
requestBody?: string;
filterType?: string;
auth: AuthenticationConfigurationPersist;
queries?: QueryConfigPersist[];
}
export interface ResultsConfigurationPersist{
resultsArrayPath: string;
fieldsMapping: ResultFieldsMappingConfigurationPersist[];
}
export interface ResultFieldsMappingConfigurationPersist{
code: string;
responsePath: string;
}
export interface AuthenticationConfigurationPersist{
enabled: boolean;
authUrl: string;
authMethod: ReferenceTypeExternalApiHTTPMethodType;
authTokenPath: string;
authRequestBody: string;
type: string;
}
export interface QueryConfigPersist{
name: string;
defaultValue: string;
cases: QueryCaseConfigPersist[];
}
export interface QueryCaseConfigPersist{
likePattern: string,
separator: string;
value: string;
referenceTypeId: Guid;
referenceTypeSourceKey: string
}
export interface ReferenceTypeSourceStaticOptionConfigurationPersist {
options: ReferenceTypeStaticOptionPersist[];
}
export interface ReferenceTypeStaticOptionPersist{
code: string;
value: string;
}

View File

@ -0,0 +1,21 @@
import { Lookup } from "@common/model/lookup";
import { Guid } from "@common/types/guid";
import { IsActive } from "../common/enum/is-active.enum";
export class PrefillingSourceLookup extends Lookup implements PrefillingSourceFilter {
ids: Guid[];
excludedIds: Guid[];
like: string;
isActive: IsActive[];
constructor() {
super();
}
}
export interface PrefillingSourceFilter {
ids: Guid[];
excludedIds: Guid[];
like: string;
isActive: IsActive[];
}

View File

@ -120,12 +120,12 @@ export class ConfigurationService extends BaseComponent {
private _annotationServiceAddress: string;
get annotationServiceAddress(): string {
return this._notificationServiceAddress || './';
return this._annotationServiceAddress || './';
}
private _annotationServiceEnabled: boolean;
get annotationServiceEnabled(): boolean {
return this._notificationServiceEnabled;
return this._annotationServiceEnabled;
}
private _inAppNotificationsCountInterval: number;

View File

@ -0,0 +1,97 @@
import { Injectable } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { PrefillingSource, PrefillingSourcePersist } from '@app/core/model/prefilling-source/prefilling-source';
import { PrefillingSourceLookup } from '@app/core/query/prefilling-source.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 PrefillingSourceService {
constructor(
private http: BaseHttpV2Service,
private configurationService: ConfigurationService,
private filterService: FilterService
) {
}
private get apiBase(): string { return `${this.configurationService.server}prefilling-source`; }
query(q: PrefillingSourceLookup): Observable<QueryResult<PrefillingSource>> {
const url = `${this.apiBase}/query`;
return this.http.post<QueryResult<PrefillingSource>>(url, q).pipe(catchError((error: any) => throwError(error)));
}
getSingle(id: Guid, reqFields: string[] = []): Observable<PrefillingSource> {
const url = `${this.apiBase}/${id}`;
const options = { params: { f: reqFields } };
return this.http
.get<PrefillingSource>(url, options).pipe(
catchError((error: any) => throwError(error)));
}
persist(item: PrefillingSourcePersist): Observable<PrefillingSource> {
const url = `${this.apiBase}/persist`;
return this.http
.post<PrefillingSource>(url, item).pipe(
catchError((error: any) => throwError(error)));
}
delete(id: Guid): Observable<PrefillingSource> {
const url = `${this.apiBase}/${id}`;
return this.http
.delete<PrefillingSource>(url).pipe(
catchError((error: any) => throwError(error)));
}
//
// Autocomplete Commons
//
//
public 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: PrefillingSource) => item.label,
titleFn: (item: PrefillingSource) => item.label,
valueAssign: (item: PrefillingSource) => item.id,
};
public 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: PrefillingSource) => item.label,
titleFn: (item: PrefillingSource) => item.label,
valueAssign: (item: PrefillingSource) => item.id,
};
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): PrefillingSourceLookup {
const lookup: PrefillingSourceLookup = new PrefillingSourceLookup();
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<PrefillingSource>(x => x.id),
nameof<PrefillingSource>(x => x.label)
]
};
lookup.order = { items: [nameof<PrefillingSource>(x => x.label)] };
if (like) { lookup.like = this.filterService.transformLike(like); }
return lookup;
}
}

View File

@ -7,6 +7,7 @@ import { catchError, map } from 'rxjs/operators';
import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { SemanticsLookup } from '@app/core/query/semantic.lookup';
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
@Injectable()
export class SemanticsService {
@ -26,6 +27,15 @@ export class SemanticsService {
// Autocomplete
singleAutocompleteConfiguration: SingleAutoCompleteConfiguration = {
initialItems: (data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup()).pipe(map(x => x)),
filterFn: (searchQuery: string, data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup(searchQuery)).pipe(map(x => x)),
displayFn: (item) => item,
titleFn: (item) => item,
valueAssign: (item) => item,
};
multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
initialItems: (data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup()).pipe(map(x => x)),
filterFn: (searchQuery: string, data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup(searchQuery)).pipe(map(x => x)),

View File

@ -24,8 +24,8 @@ import { NotificationType } from '@app/core/common/enum/notification-type';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
import { 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 { ExternalFetcherApiHTTPMethodType } from '@app/core/common/enum/external-fetcher-api-http-method-type';
import { ExternalFetcherSourceType } from '@app/core/common/enum/external-fetcher-source-type';
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';
@ -38,6 +38,7 @@ import { ValidationType } from '../../common/enum/validation-type';
import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type';
import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category';
import { DmpUserType } from '@app/core/common/enum/dmp-user-type';
import { PrefillingSourceSystemTargetType } from '@app/core/common/enum/prefilling-source-system-target-type';
@Injectable()
export class EnumUtils {
@ -174,10 +175,10 @@ export class EnumUtils {
}
}
toReferenceTypeSourceTypeString(status: ReferenceTypeSourceType): string {
toExternalFetcherSourceTypeString(status: ExternalFetcherSourceType): string {
switch (status) {
case ReferenceTypeSourceType.API: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.API');
case ReferenceTypeSourceType.STATIC: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.STATIC');
case ExternalFetcherSourceType.API: return this.language.instant('TYPES.EXTERNAL-FETCHER-SOURCE-TYPE.API');
case ExternalFetcherSourceType.STATIC: return this.language.instant('TYPES.EXTERNAL-FETCHER-SOURCE-TYPE.STATIC');
}
}
@ -189,10 +190,10 @@ export class EnumUtils {
}
toReferenceTypeExternalApiHTTPMethodTypeString(status: ReferenceTypeExternalApiHTTPMethodType): string {
toExternalFetcherApiHTTPMethodTypeString(status: ExternalFetcherApiHTTPMethodType): string {
switch (status) {
case ReferenceTypeExternalApiHTTPMethodType.GET: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.GET');
case ReferenceTypeExternalApiHTTPMethodType.POST: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.POST');
case ExternalFetcherApiHTTPMethodType.GET: return this.language.instant('TYPES.EXTERNAL-FETCHER-API-HTTP-METHOD-TYPE.GET');
case ExternalFetcherApiHTTPMethodType.POST: return this.language.instant('TYPES.EXTERNAL-FETCHER-API-HTTP-METHOD-TYPE.POST');
}
}
@ -398,5 +399,13 @@ export class EnumUtils {
}
}
public toPrefillingSourceSystemTargetTypeString(value: PrefillingSourceSystemTargetType): string {
switch (value) {
case PrefillingSourceSystemTargetType.Label: return this.language.instant('TYPES.PREFILLING-SOURCE-SYSTEM-TARGET-TYPE.LABEL');
case PrefillingSourceSystemTargetType.Description: return this.language.instant('TYPES.PREFILLING-SOURCE-SYSTEM-TARGET-TYPE.DESCRIPTION');
case PrefillingSourceSystemTargetType.Tags: return this.language.instant('TYPES.PREFILLING-SOURCE-SYSTEM-TARGET-TYPE.TAGS');
}
}
}

View File

@ -247,6 +247,13 @@
</div>
<mat-error *ngIf="section.get('descriptionTemplates').hasError('backendError')">{{section.get('descriptionTemplates').getError('backendError').message}}</mat-error>
</div>
<div *ngIf="section.get('hasTemplates').value == true">
<mat-form-field class="col-6">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.PREFILLING-SOURCES' | translate}}</mat-label>
<app-multiple-auto-complete [formControl]="section.get('prefillingSourcesIds')" [configuration]="prefillingSourceService.multipleAutocompleteConfiguration"></app-multiple-auto-complete>
<mat-error *ngIf="section.get('prefillingSourcesIds').hasError('backendError')">{{section.get('prefillingSourcesIds').getError('backendError').message}}</mat-error>
</mat-form-field>
</div>
</mat-card>
</div>

View File

@ -42,6 +42,7 @@ import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver';
import { DmpBlueprintEditorService } from './dmp-blueprint-editor.service';
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
@Component({
@ -124,7 +125,8 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
private matomoService: MatomoService,
public descriptionTemplateService: DescriptionTemplateService,
public referenceTypeService: ReferenceTypeService,
public semanticsService: SemanticsService
public semanticsService: SemanticsService,
public prefillingSourceService: PrefillingSourceService
) {
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
}
@ -223,7 +225,6 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
formSubmit(): void {
this.formService.touchAllFormFields(this.formGroup);
console.log(this.formGroup);
if (!this.isFormValid()) {
return;
}

View File

@ -173,6 +173,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
fields: FieldInSectionEditorModel[] = [];
hasTemplates: boolean;
descriptionTemplates?: DescriptionTemplatesInSectionEditorModel[] = [];
prefillingSourcesIds: Guid[]= [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -189,6 +190,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
this.hasTemplates = item.hasTemplates;
if (item.fields) { item.fields.map(x => this.fields.push(new FieldInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.descriptionTemplates) { item.descriptionTemplates.map(x => this.descriptionTemplates.push(new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.prefillingSources) this.prefillingSourcesIds = item.prefillingSources.map(x => x.id);
}
return this;
}
@ -227,7 +229,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
disabled: disabled
})
), context.getValidation('descriptionTemplates').validators
)
),
prefillingSourcesIds: [{ value: this.prefillingSourcesIds, disabled: disabled }, context.getValidation('prefillingSourcesIds').validators],
});
}
@ -246,6 +249,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
baseValidationArray.push({ key: 'hasTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasTemplates`)] });
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseValidationArray.push({ key: 'descriptionTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplates`)] });
baseValidationArray.push({ key: 'prefillingSourcesIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}prefillingSourcesIds`)] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseContext.validation = baseValidationArray;
@ -263,7 +267,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
validationErrorModel
});
['id', 'label', 'ordinal', 'description', 'hasTemplates', 'hash'].forEach(keyField => {
['id', 'label', 'ordinal', 'description', 'hasTemplates', 'prefillingSourcesIds', 'hash'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);

View File

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, ExtraFieldInSection, FieldInSection, ReferenceTypeFieldInSection, SystemFieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source';
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
@ -46,6 +47,10 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.prefillingSources), nameof<PrefillingSource>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.prefillingSources), nameof<PrefillingSource>(x => x.label)].join('.'),
nameof<DmpBlueprint>(x => x.createdAt),
nameof<DmpBlueprint>(x => x.hash),
nameof<DmpBlueprint>(x => x.isActive)

View File

@ -0,0 +1,135 @@
<div class="prefilling-source-editor">
<div class="col-md-8 offset-md-2 colums-gapped" *ngIf="formGroup">
<div class="row justify-content-between align-items-center">
<div class="col">
<h3 *ngIf="isNew">{{'PREFILLING-SOURCE-EDITOR.NEW' | translate}}</h3>
<app-navigation-breadcrumb />
</div>
<div class="col-auto">
<button mat-button class="action-btn" (click)="cancel()" type="button">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.CANCEL' | translate}}</button>
</div>
<div class="col-auto" *ngIf="canDelete">
<button mat-button class="action-btn" type="button" (click)="delete()">
<mat-icon>delete</mat-icon>
{{'PREFILLING-SOURCE-EDITOR.ACTIONS.DELETE' | translate}}
</button>
</div>
<div class="col-auto" *ngIf="canSave">
<button mat-button class="action-btn" (click)="formSubmit()">
<mat-icon>save</mat-icon>
{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SAVE' | translate}}
</button>
</div>
</div>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()">
<mat-card appearance="outlined">
<mat-card-header>
<mat-card-title *ngIf="isNew">{{'PREFILLING-SOURCE-EDITOR.NEW' | translate}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-12">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
<input matInput type="text" name="label" [formControl]="formGroup.get('label')" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- Fields -->
<div class="col-12">
<div *ngFor="let field of formGroup.get('definition').get('fields').controls; let fieldIndex=index;" class="row mb-3">
<div class="col-12">
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<mat-card-title>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'PREFILLING-SOURCE-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeField(fieldIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
<div class="row" >
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" name="code" [formControl]="field.get('code')">
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SYSTEM-TARGET' | translate}}</mat-label>
<mat-select [formControl]="field.get('systemFieldTarget')">
<mat-option *ngFor="let systemFieldTarget of prefillingSourceSystemTargetTypeEnumValues" [value]="systemFieldTarget">{{enumUtils.toPrefillingSourceSystemTargetTypeString(systemFieldTarget)}}</mat-option>
</mat-select>
<mat-error *ngIf="field.get('systemFieldTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-12">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}</mat-label>
<app-single-auto-complete placeholder="{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}" [formControl]="field.get('semanticTarget')" [configuration]="semanticsService.singleAutocompleteConfiguration"> </app-single-auto-complete>
<mat-error *ngIf="field.get('semanticTarget').hasError('backendError')">{{field.get('semanticTarget').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('semanticTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.TRIM-REGEX' | translate}}</mat-label>
<input matInput type="text" name="trimRegex" [formControl]="field.get('trimRegex')">
<mat-error *ngIf="field.get('trimRegex').hasError('backendError')">{{field.get('trimRegex').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('trimRegex').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIXED-VALUE' | translate}}</mat-label>
<input matInput type="text" name="fixedValue" [formControl]="field.get('fixedValue')">
<mat-error *ngIf="field.get('fixedValue').hasError('backendError')">{{field.get('fixedValue').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('fixedValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</div>
</div>
<button mat-button class="action-btn" type="button" (click)="addField()" [disabled]="formGroup.disabled">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
</div>
</div>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined">
<mat-card-header>
<mat-card-title >{{'PREFILLING-SOURCE-EDITOR.FIELDS.SOURCE-CONFIGURATION' | translate}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<app-external-fetcher-source-component [formGroup]="formGroup.get('definition').get('searchConfiguration')" [validationErrorModel]="editorModel.validationErrorModel" [validationRootPath]="'definition.searchConfiguration.'"></app-external-fetcher-source-component>
<div>
<mat-checkbox [formControl]="formGroup.get('definition').get('getEnabled')" (change)="getEnabledChanged($event)">
{{'PREFILLING-SOURCE-EDITOR.FIELDS.GET-SOURCE-CONFIGURATION' | translate}}
<mat-error *ngIf="formGroup.get('definition').get('getEnabled').hasError('backendError')">{{formGroup.get('definition').get('getEnabled').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('getEnabled').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-checkbox>
</div>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined" *ngIf="formGroup.get('definition').get('getEnabled').value == true">
<mat-card-header>
<mat-card-title >{{'PREFILLING-SOURCE-EDITOR.FIELDS.GET-SOURCE-CONFIGURATION' | translate}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<app-external-fetcher-source-component [formGroup]="formGroup.get('definition').get('getConfiguration')" [validationErrorModel]="editorModel.validationErrorModel" [validationRootPath]="'definition.getConfiguration.'"></app-external-fetcher-source-component>
</mat-card-content>
</mat-card>
</form>
</div>
</div>

View File

@ -0,0 +1,43 @@
.prefilling-source-editor {
margin-top: 1.3rem;
margin-left: 1em;
margin-right: 3em;
.remove {
background-color: white;
color: black;
}
.add {
background-color: white;
color: #009700;
}
}
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background {
background-color: var(--primary-color-3);
// background-color: #0070c0;
}
::ng-deep .mat-checkbox-disabled.mat-checkbox-checked .mat-checkbox-background, .mat-checkbox-disabled.mat-checkbox-indeterminate .mat-checkbox-background {
background-color: #b0b0b0;
}
.action-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;
&:disabled{
background-color: #CBCBCB;
color: #FFF;
border: 0px;
}
}

View File

@ -0,0 +1,279 @@
import { Component, OnInit } from '@angular/core';
import { FormArray, FormGroup, UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
import { DatePipe } from '@angular/common';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { PrefillingSource, PrefillingSourcePersist } from '@app/core/model/prefilling-source/prefilling-source';
import { AuthService } from '@app/core/services/auth/auth.service';
import { LoggingService } from '@app/core/services/logging/logging-service';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
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 { PrefillingSourceEditorResolver } from './prefilling-source-editor.resolver';
import { PrefillingSourceEditorService } from './prefilling-source-editor.service';
import { PrefillingSourceDefinitionEditorModel, PrefillingSourceEditorModel } from './prefilling-source-editor.model';
import { ResultFieldsMappingConfigurationEditorModel } from '@app/ui/external-fetcher/external-fetcher-source-editor.model';
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { PrefillingSourceSystemTargetType } from '@app/core/common/enum/prefilling-source-system-target-type';
@Component({
selector: 'app-prefilling-source-editor-component',
templateUrl: 'prefilling-source-editor.component.html',
styleUrls: ['./prefilling-source-editor.component.scss'],
providers: [PrefillingSourceEditorService]
})
export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSourceEditorModel, PrefillingSource> implements OnInit {
isNew = true;
isDeleted = false;
formGroup: UntypedFormGroup = null;
showInactiveDetails = false;
prefillingSourceSystemTargetTypeEnumValues = this.enumUtils.getEnumValues<PrefillingSourceSystemTargetType>(PrefillingSourceSystemTargetType);
protected get canDelete(): boolean {
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeletePrefillingSource);
}
protected get canSave(): boolean {
return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditPrefillingSource);
}
private hasPermission(permission: AppPermission): boolean {
return this.authService.hasPermission(permission) || this.editorModel?.permissions?.includes(permission);
}
constructor(
// BaseFormEditor injected dependencies
protected dialog: MatDialog,
protected language: TranslateService,
protected formService: FormService,
protected router: Router,
protected uiNotificationService: UiNotificationService,
protected httpErrorHandlingService: HttpErrorHandlingService,
protected filterService: FilterService,
protected datePipe: DatePipe,
protected route: ActivatedRoute,
protected queryParamsService: QueryParamsService,
// Rest dependencies. Inject any other needed deps here:
public authService: AuthService,
public enumUtils: EnumUtils,
private prefillingSourceService: PrefillingSourceService,
private logger: LoggingService,
private prefillingSourceEditorService: PrefillingSourceEditorService,
public semanticsService: SemanticsService,
private matomoService: MatomoService
) {
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
}
ngOnInit(): void {
this.matomoService.trackPageView('Admin: PrefillingSources');
super.ngOnInit();
}
getItem(itemId: Guid, successFunction: (item: PrefillingSource) => void) {
this.prefillingSourceService.getSingle(itemId, PrefillingSourceEditorResolver.lookupFields())
.pipe(map(data => data as PrefillingSource), takeUntil(this._destroyed))
.subscribe(
data => successFunction(data),
error => this.onCallbackError(error)
);
}
prepareForm(data: PrefillingSource) {
try {
this.editorModel = data ? new PrefillingSourceEditorModel().fromModel(data) : new PrefillingSourceEditorModel();
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.buildForm();
} catch (error) {
this.logger.error('Could not parse PrefillingSource item: ' + data + error);
this.uiNotificationService.snackBarNotification(this.language.instant('COMMONS.ERRORS.DEFAULT'), SnackBarNotificationLevel.Error);
}
}
buildForm() {
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditPrefillingSource));
this.prefillingSourceEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
this.addFieldMapping("prefilling_id", "searchConfiguration");
this.addFieldMapping("label", "searchConfiguration");
this.addFieldMapping("description", "searchConfiguration");
}
refreshData(): void {
this.getItem(this.editorModel.id, (data: PrefillingSource) => this.prepareForm(data));
}
refreshOnNavigateToData(id?: Guid): void {
this.formGroup.markAsPristine();
let route = [];
if (id === null) {
route.push('../..');
} else if (this.isNew) {
route.push('../' + id);
} else {
route.push('..');
}
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
}
persistEntity(onSuccess?: (response) => void): void {
const formData = this.formService.getValue(this.formGroup.value) as PrefillingSourcePersist;
this.prefillingSourceService.persist(formData)
.pipe(takeUntil(this._destroyed)).subscribe(
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error)
);
}
formSubmit(): void {
PrefillingSourceEditorModel.reApplyDefinitionValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
)
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
this.persistEntity();
}
public delete() {
const value = this.formGroup.value;
if (value.id) {
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.CONFIRM'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.prefillingSourceService.delete(value.id).pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
});
}
}
clearErrorModel() {
this.editorModel.validationErrorModel.clear();
this.formService.validateAllFormFields(this.formGroup);
}
getEnabledChanged(event: MatCheckboxChange){
if(event.checked == true){
const definition = new PrefillingSourceDefinitionEditorModel(this.editorModel.validationErrorModel);
definition.buildGetConfiguration(this.formGroup.get('definition') as UntypedFormGroup, "definition.");
this.submitFields();
}
}
//
//
// fields
//
//
addField(): void {
(this.formGroup.get('definition').get('fields') as FormArray).push(this.editorModel.createChildField((this.formGroup.get('definition').get('fields') as FormArray).length));
}
removeField(fieldIndex: number): void {
const fieldForm = this.formGroup.get('definition').get('fields') as FormArray;
const fieldCode = fieldForm.at(fieldIndex).get('code').value;
fieldForm.removeAt(fieldIndex);
//Reapply validators
PrefillingSourceEditorModel.reApplyDefinitionValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
)
fieldForm.markAsDirty();
// this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode);
if(this.formGroup.get('definition').get('getEnabled').value == true) this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), fieldCode);
}
submitFields(): void {
const fieldsFormArray = (this.formGroup.get('definition').get('fields') as FormArray);
if (fieldsFormArray.valid) {
for (let i = 0; i < fieldsFormArray.length; i++) {
const code = fieldsFormArray.at(i).get('code').value;
// this.addFieldMapping(code, "searchConfiguration");
if(this.formGroup.get('definition').get('getEnabled').value == true) this.addFieldMapping(code, "getConfiguration");
}
}
}
//
//
// resultFieldsMapping
//
//
addFieldMapping(code: string, controlName: string): void {
const formArray = (this.formGroup.get('definition').get(controlName).get('results').get('fieldsMapping') as FormArray);
const fieldMappingSize = formArray.length;
if (fieldMappingSize > 0) {
for (let i = 0; i < fieldMappingSize; i++) {
if (formArray.at(i).get('code').getRawValue() == code) {
return;
}
}
}
const fieldsMapping = new ResultFieldsMappingConfigurationEditorModel(this.editorModel.validationErrorModel);
fieldsMapping.code = code;
formArray.push(fieldsMapping.buildForm({rootPath: "definition." + controlName + ".results.fieldsMapping[" + fieldMappingSize + "]."}));
}
removeFieldMapping(baseFormGroup: any, fieldCode: string){
if(baseFormGroup){
const fieldMappingFormArray = (baseFormGroup.get('results').get('fieldsMapping') as FormArray);
for (let j = 0; j < fieldMappingFormArray.length; j++) {
if (fieldCode == fieldMappingFormArray.at(j).get('code').getRawValue()) {
fieldMappingFormArray.removeAt(j);
PrefillingSourceEditorModel.reApplyDefinitionValidators({
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
);
}
}
}
}
}

View File

@ -0,0 +1,273 @@
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField, PrefillingSourceDefinitionFieldPersist, PrefillingSourceDefinitionPersist, PrefillingSourcePersist } from "@app/core/model/prefilling-source/prefilling-source";
import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel } from "@app/ui/external-fetcher/external-fetcher-source-editor.model";
import { BaseEditorModel } from "@common/base/base-form-editor-model";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
export class PrefillingSourceEditorModel extends BaseEditorModel implements PrefillingSourcePersist {
label: string;
definition: PrefillingSourceDefinitionEditorModel = new PrefillingSourceDefinitionEditorModel(this.validationErrorModel);
permissions: string[];
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor() { super(); }
public fromModel(item: PrefillingSource): PrefillingSourceEditorModel {
if (item) {
super.fromModel(item);
this.label = item.label;
if (item.definition) this.definition = new PrefillingSourceDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
}
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],
definition: this.definition.buildForm({
rootPath: `definition.`,
}),
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
});
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
baseValidationArray.push({ key: 'definition', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'definition')] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reApplyDefinitionValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
}): void {
const { formGroup, validationErrorModel } = params;
PrefillingSourceDefinitionEditorModel.reapplyValidators({
formGroup: formGroup?.get('definition') as UntypedFormGroup,
rootPath: `definition.`,
validationErrorModel: validationErrorModel
});
}
createChildField(index: number): UntypedFormGroup {
const field: PrefillingSourceDefinitionFieldEditorModel = new PrefillingSourceDefinitionFieldEditorModel(this.validationErrorModel);
return field.buildForm({ rootPath: 'definition.fields[' + index + '].' });
}
}
export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDefinitionPersist {
fields: PrefillingSourceDefinitionFieldEditorModel[] = [];
searchConfiguration: ExternalFetcherBaseSourceConfigurationEditorModel = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel);
getConfiguration: ExternalFetcherBaseSourceConfigurationEditorModel;
getEnabled = false;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: PrefillingSourceDefinition): PrefillingSourceDefinitionEditorModel {
if (item) {
if (item.fields) { item.fields.map(x => this.fields.push(new PrefillingSourceDefinitionFieldEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.searchConfiguration) this.searchConfiguration = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(item.searchConfiguration);
if (item.getConfiguration) {
this.getConfiguration = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(item.getConfiguration);
this.getEnabled = true;
}
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = PrefillingSourceDefinitionEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
const form: UntypedFormGroup = this.formBuilder.group({
fields: this.formBuilder.array(
(this.fields ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields')
)
),
searchConfiguration: this.searchConfiguration.buildForm({
rootPath: `${rootPath}searchConfiguration.`
}),
getEnabled: [{ value: this.getEnabled, disabled: disabled }, context.getValidation('getEnabled').validators],
});
if (this.getEnabled == true) {
form.addControl('getConfiguration', this.getConfiguration.buildForm({
rootPath: `${rootPath}getConfiguration.`
}));
}
return form;
}
buildGetConfiguration(
form: UntypedFormGroup,
rootPath?: string
){
form.addControl('getConfiguration', new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel)
.buildForm({
rootPath: `${rootPath}getConfiguration.`
}));
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseValidationArray.push({ key: 'searchConfiguration', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}searchConfiguration`)] });
baseValidationArray.push({ key: 'getConfiguration', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}getConfiguration`)] });
baseValidationArray.push({ key: 'getEnabled', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}getConfiguration`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { validationErrorModel, rootPath, formGroup } = params;
(formGroup.get('fields') as UntypedFormArray).controls?.forEach(
(control, index) => PrefillingSourceDefinitionFieldEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}fields[${index}].`,
validationErrorModel: validationErrorModel
})
);
ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({
formGroup: formGroup.get('searchConfiguration') as UntypedFormGroup,
rootPath: `${rootPath}searchConfiguration.`,
validationErrorModel: validationErrorModel
});
if(formGroup.get('getEnabled').value == true){
ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({
formGroup: formGroup.get('getConfiguration') as UntypedFormGroup,
rootPath: `${rootPath}getConfiguration.`,
validationErrorModel: validationErrorModel
});
}
}
}
export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSourceDefinitionFieldPersist {
code: string;
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: PrefillingSourceDefinitionField): PrefillingSourceDefinitionFieldEditorModel {
if (item) {
this.code = item.code;
this.systemFieldTarget = item.systemFieldTarget;
this.semanticTarget = item.semanticTarget;
this.trimRegex = item.trimRegex;
this.fixedValue = item.fixedValue;
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = PrefillingSourceDefinitionFieldEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
systemFieldTarget: [{ value: this.systemFieldTarget, disabled: disabled }, context.getValidation('systemFieldTarget').validators],
semanticTarget: [{ value: this.semanticTarget, disabled: disabled }, context.getValidation('semanticTarget').validators],
trimRegex: [{ value: this.trimRegex, disabled: disabled }, context.getValidation('trimRegex').validators],
fixedValue: [{ value: this.fixedValue, disabled: disabled }, context.getValidation('fixedValue').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
baseValidationArray.push({ key: 'systemFieldTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldTarget`)] });
baseValidationArray.push({ key: 'semanticTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semanticTarget`)] });
baseValidationArray.push({ key: 'trimRegex', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}trimRegex`)] });
baseValidationArray.push({ key: 'fixedValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}clientSecret`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = PrefillingSourceDefinitionFieldEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['code', 'systemFieldTarget', 'semanticTarget', 'trimRegex', 'fixedValue'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}

View File

@ -0,0 +1,101 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AuthenticationConfiguration, ExternalFetcherBaseSourceConfiguration, QueryCaseConfig, QueryConfig, ResultFieldsMappingConfiguration, ResultsConfiguration } from '@app/core/model/external-fetcher/external-fetcher';
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField } from '@app/core/model/prefilling-source/prefilling-source';
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.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 PrefillingSourceEditorResolver extends BaseEditorResolver {
constructor(private prefillingSourceService: PrefillingSourceService, private breadcrumbService: BreadcrumbService) {
super();
}
public static lookupFields(): string[] {
return [
...BaseEditorResolver.lookupFields(),
nameof<PrefillingSource>(x => x.id),
nameof<PrefillingSource>(x => x.label),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.code)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.systemFieldTarget)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.semanticTarget)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.trimRegex)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.fixedValue)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.label)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.ordinal)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.url)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.paginationPath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.contentType)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.firstPage)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.httpMethod)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.requestBody)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.filterType)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.name)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.defaultValue)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.label)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.ordinal)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.url)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.paginationPath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.contentType)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.firstPage)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.httpMethod)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.requestBody)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.filterType)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth), nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.name)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.defaultValue)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.getConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries), nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
nameof<PrefillingSource>(x => x.createdAt),
nameof<PrefillingSource>(x => x.updatedAt),
nameof<PrefillingSource>(x => x.hash),
nameof<PrefillingSource>(x => x.isActive)
]
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const fields = [
...PrefillingSourceEditorResolver.lookupFields()
];
const id = route.paramMap.get('id');
if (id != null) {
return this.prefillingSourceService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed));
}
}
}

View File

@ -0,0 +1,15 @@
import { Injectable } from "@angular/core";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
@Injectable()
export class PrefillingSourceEditorService {
private validationErrorModel: ValidationErrorModel;
public setValidationErrorModel(validationErrorModel: ValidationErrorModel): void {
this.validationErrorModel = validationErrorModel;
}
public getValidationErrorModel(): ValidationErrorModel {
return this.validationErrorModel;
}
}

View File

@ -0,0 +1,36 @@
<div class="d-flex align-items-center gap-1-rem">
<button mat-flat-button [matMenuTriggerFor]="filterMenu" #filterMenuTrigger="matMenuTrigger" (click)="updateFilters()" class="filter-button">
<mat-icon aria-hidden="false" [matBadgeHidden]="!appliedFilterCount" [matBadge]="appliedFilterCount" matBadgeColor="warn" matBadgeSize="small">filter_alt</mat-icon>
{{'COMMONS.LISTING-COMPONENT.SEARCH-FILTER-BTN' | translate}}
</button>
<mat-menu #filterMenu>
<div class="p-3" (click)="$event?.stopPropagation?.()">
<div class="search-listing-filters-container">
<div class="d-flex align-items-center justify-content-between">
<h4>{{'PREFILLING-SOURCE-LISTING.FILTER.TITLE' | translate}}</h4>
<button color="accent" mat-button (click)="clearFilters()">
{{'COMMONS.LISTING-COMPONENT.CLEAR-ALL-FILTERS' | translate}}
</button>
</div>
<mat-slide-toggle labelPosition="before" [(ngModel)]="internalFilters.isActive">
{{'PREFILLING-SOURCE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'PREFILLING-SOURCE-LISTING.FILTER.CANCEL' | translate}}
</button>
<button mat-raised-button color="primary" (click)="filterMenuTrigger.closeMenu(); applyFilters();">
{{'PREFILLING-SOURCE-LISTING.FILTER.APPLY-FILTERS' | translate}}
</button>
</div>
</div>
</div>
</mat-menu>
<app-expandable-search-field [(value)]=internalFilters.like (valueChange)="onSearchTermChange($event)" />
</div>

View File

@ -0,0 +1,25 @@
.prefilling-source-listing-filters {
}
::ng-deep.mat-mdc-menu-panel {
max-width: 100% !important;
height: 100% !important;
}
:host::ng-deep.mat-mdc-menu-content:not(:empty) {
padding-top: 0 !important;
}
.filter-button{
padding-top: .6rem;
padding-bottom: .6rem;
// .mat-icon{
// font-size: 1.5em;
// width: 1.2em;
// height: 1.2em;
// }
}

View File

@ -0,0 +1,94 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { PrefillingSourceFilter } from '@app/core/query/prefilling-source.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
import { nameof } from 'ts-simple-nameof';
@Component({
selector: 'app-prefilling-source-listing-filters',
templateUrl: './prefilling-source-listing-filters.component.html',
styleUrls: ['./prefilling-source-listing-filters.component.scss']
})
export class PrefillingSourceListingFiltersComponent extends BaseComponent implements OnInit, OnChanges {
@Input() readonly filter: PrefillingSourceFilter;
@Output() filterChange = new EventEmitter<PrefillingSourceFilter>();
// * State
internalFilters: PrefillingSourceListingFilters = this._getEmptyFilters();
protected appliedFilterCount: number = 0;
constructor(
public enumUtils: EnumUtils,
) { super(); }
ngOnInit() {
}
ngOnChanges(changes: SimpleChanges): void {
const filterChange = changes[nameof<PrefillingSourceListingFiltersComponent>(x => x.filter)]?.currentValue as PrefillingSourceFilter;
if (filterChange) {
this.updateFilters()
}
}
onSearchTermChange(searchTerm: string): void {
this.applyFilters()
}
protected updateFilters(): void {
this.internalFilters = this._parseToInternalFilters(this.filter);
this.appliedFilterCount = this._computeAppliedFilters(this.internalFilters);
}
protected applyFilters(): void {
const { isActive, like } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
})
}
private _parseToInternalFilters(inputFilter: PrefillingSourceFilter): PrefillingSourceListingFilters {
if (!inputFilter) {
return this._getEmptyFilters();
}
let { excludedIds, ids, isActive, like } = inputFilter;
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
like: like
}
}
private _getEmptyFilters(): PrefillingSourceListingFilters {
return {
isActive: true,
like: null,
}
}
private _computeAppliedFilters(filters: PrefillingSourceListingFilters): number {
let count = 0;
if (filters?.isActive) {
count++
}
return count;
}
clearFilters() {
this.internalFilters = this._getEmptyFilters();
}
}
interface PrefillingSourceListingFilters {
isActive: boolean;
like: string;
}

View File

@ -0,0 +1,96 @@
<div class="row prefilling-source-listing">
<div class="col-md-8 offset-md-2">
<div class="row mb-4 mt-3">
<div class="col">
<h4>{{'PREFILLING-SOURCE-LISTING.TITLE' | translate}}</h4>
<app-navigation-breadcrumb />
</div>
<div class="col-auto">
<button mat-raised-button class="create-btn"
*ngIf="authService.hasPermission(authService.permissionEnum.EditPrefillingSource)"
[routerLink]="['/prefilling-sources/new']">
<mat-icon>add</mat-icon>
{{'PREFILLING-SOURCE-LISTING.CREATE' | translate}}
</button>
</div>
</div>
<app-hybrid-listing [rows]="gridRows" [columns]="gridColumns" [visibleColumns]="visibleColumns"
[count]="totalElements" [offset]="currentPageNumber" [limit]="lookup.page.size"
[defaultSort]="lookup.order?.items" [externalSorting]="true" (rowActivated)="onRowActivated($event)"
(pageLoad)="alterPage($event)" (columnSort)="onColumnSort($event)"
(columnsChanged)="onColumnsChanged($event)" [listItemTemplate]="listItemTemplate">
<app-prefilling-source-listing-filters hybrid-listing-filters [(filter)]="lookup"
(filterChange)="filterChanged($event)" />
<app-user-settings-picker [key]="userSettingsKey" [userPreference]="lookup"
(onSettingSelected)="changeSetting($event)" [autoSelectUserSettings]="autoSelectUserSettings"
user-preference-settings />
</app-hybrid-listing>
</div>
</div>
<ng-template #listItemTemplate let-item="item" let-isColumnSelected="isColumnSelected">
<div class="d-flex align-items-center p-3 gap-1-rem">
<div class="row">
<ng-container *ngIf="isColumnSelected('name')">
<a class="buttonLinkClass" [routerLink]="'./' + item?.id" class="col-12"
(click)="$event.stopPropagation()">{{item?.name | nullifyValue}}</a>
<br />
</ng-container>
<ng-container *ngIf="isColumnSelected('label')">
<span class="col-12">
{{'PREFILLING-SOURCE-LISTING.FIELDS.CODE' | translate}}:
<small>
{{item?.code | nullifyValue}}
</small>
</span>
<br>
</ng-container>
<ng-container *ngIf="isColumnSelected('createdAt')">
<span class="col-12">
{{'PREFILLING-SOURCE-LISTING.FIELDS.CREATED-AT' | translate}}:
<small>
{{item?.createdAt | dateTimeFormatter : 'short' | nullifyValue}}
</small>
</span>
<br>
</ng-container>
<ng-container *ngIf="isColumnSelected('updatedAt')">
<span class="col-12">
{{'PREFILLING-SOURCE-LISTING.FIELDS.UPDATED-AT' | translate}}:
<small>
{{item?.updatedAt | dateTimeFormatter : 'short' | nullifyValue}}
</small>
</span>
</ng-container>
</div>
</div>
</ng-template>
<ng-template #actions let-row="row" let-item>
<div class="row" (click)="$event.stopPropagation()">
<div class="col-auto">
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="['/prefilling-sources/' + row.id]">
<mat-icon>edit</mat-icon>{{'PREFILLING-SOURCE-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button mat-menu-item (click)="deleteType(row.id)">
<mat-icon>delete</mat-icon>
{{'PREFILLING-SOURCE-LISTING.ACTIONS.DELETE' | translate}}
</button>
</mat-menu>
</div>
</div>
</ng-template>

View File

@ -0,0 +1,83 @@
.mat-table {
margin-top: 47px;
border-radius: 4px;
}
.prefilling-source-listing {
margin-top: 1.3rem;
margin-left: 1rem;
margin-right: 2rem;
.mat-header-row {
background: #f3f5f8;
}
.mat-card {
margin: 16px 0;
padding: 0px;
}
.mat-row {
cursor: pointer;
min-height: 4.5em;
}
mat-row:hover {
background-color: #eef5f6;
}
.mat-fab-bottom-right {
float: right;
z-index: 5;
}
}
// PAGINATOR
:host ::ng-deep .mat-paginator-container {
flex-direction: row-reverse !important;
justify-content: space-between !important;
background-color: #f6f6f6;
align-items: center;
}
.create-btn {
border-radius: 30px;
background-color: var(--secondary-color);
padding-left: 2em;
padding-right: 2em;
// color: #000;
.button-text {
display: inline-block;
}
}
.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;
}
.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;
}

View File

@ -0,0 +1,171 @@
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source';
import { PrefillingSourceLookup } from '@app/core/query/prefilling-source.lookup';
import { AuthService } from '@app/core/services/auth/auth.service';
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
import { BaseListingComponent } from '@common/base/base-listing-component';
import { PipeService } from '@common/formatting/pipe.service';
import { DataTableDateTimeFormatPipe } from '@common/formatting/pipes/date-time-format.pipe';
import { QueryResult } from '@common/model/query-result';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
import { ColumnDefinition, ColumnsChangedEvent, HybridListingComponent, PageLoadEvent } from '@common/modules/hybrid-listing/hybrid-listing.component';
import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
@Component({
templateUrl: './prefilling-source-listing.component.html',
styleUrls: ['./prefilling-source-listing.component.scss']
})
export class PrefillingSourceListingComponent extends BaseListingComponent<PrefillingSource, PrefillingSourceLookup> implements OnInit {
publish = false;
userSettingsKey = { key: 'PrefillingSourceListingUserSettings' };
propertiesAvailableForOrder: ColumnDefinition[];
// @ViewChild('PrefillingSourceStatus', { static: true }) PrefillingSourceStatus?: TemplateRef<any>;
@ViewChild('actions', { static: true }) actions?: TemplateRef<any>;
@ViewChild(HybridListingComponent, { static: true }) hybridListingComponent: HybridListingComponent;
private readonly lookupFields: string[] = [
nameof<PrefillingSource>(x => x.id),
nameof<PrefillingSource>(x => x.label),
nameof<PrefillingSource>(x => x.updatedAt),
nameof<PrefillingSource>(x => x.createdAt),
nameof<PrefillingSource>(x => x.hash),
nameof<PrefillingSource>(x => x.isActive)
];
rowIdentity = x => x.id;
constructor(
protected router: Router,
protected route: ActivatedRoute,
protected uiNotificationService: UiNotificationService,
protected httpErrorHandlingService: HttpErrorHandlingService,
protected queryParamsService: QueryParamsService,
private PrefillingSourceService: PrefillingSourceService,
public authService: AuthService,
private pipeService: PipeService,
public enumUtils: EnumUtils,
private language: TranslateService,
private dialog: MatDialog
) {
super(router, route, uiNotificationService, httpErrorHandlingService, queryParamsService);
// Lookup setup
// Default lookup values are defined in the user settings class.
this.lookup = this.initializeLookup();
}
ngOnInit() {
super.ngOnInit();
}
protected initializeLookup(): PrefillingSourceLookup {
const lookup = new PrefillingSourceLookup();
lookup.metadata = { countAll: true };
lookup.page = { offset: 0, size: this.ITEMS_PER_PAGE };
lookup.isActive = [IsActive.Active];
lookup.order = { items: [this.toDescSortField(nameof<PrefillingSource>(x => x.createdAt))] };
this.updateOrderUiFields(lookup.order);
lookup.project = {
fields: this.lookupFields
};
return lookup;
}
protected setupColumns() {
this.gridColumns.push(...[{
prop: nameof<PrefillingSource>(x => x.label),
sortable: true,
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.LABEL'
},
{
prop: nameof<PrefillingSource>(x => x.createdAt),
sortable: true,
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.CREATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<PrefillingSource>(x => x.updatedAt),
sortable: true,
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.UPDATED-AT',
pipe: this.pipeService.getPipe<DataTableDateTimeFormatPipe>(DataTableDateTimeFormatPipe).withFormat('short')
},
{
prop: nameof<PrefillingSource>(x => x.isActive),
sortable: true,
languageName: 'PREFILLING-SOURCE-LISTING.FIELDS.IS-ACTIVE',
pipe: this.pipeService.getPipe<IsActiveTypePipe>(IsActiveTypePipe)
},
{
alwaysShown: true,
cellTemplate: this.actions,
maxWidth: 120
}
]);
this.propertiesAvailableForOrder = this.gridColumns.filter(x => x.sortable);
}
//
// Listing Component functions
//
onColumnsChanged(event: ColumnsChangedEvent) {
super.onColumnsChanged(event);
this.onColumnsChangedInternal(event.properties.map(x => x.toString()));
}
private onColumnsChangedInternal(columns: string[]) {
// Here are defined the projection fields that always requested from the api.
const fields = new Set(this.lookupFields);
this.gridColumns.map(x => x.prop)
.filter(x => !columns?.includes(x as string))
.forEach(item => {
fields.delete(item as string)
});
this.lookup.project = { fields: [...fields] };
this.onPageLoad({ offset: 0 } as PageLoadEvent);
}
protected loadListing(): Observable<QueryResult<PrefillingSource>> {
return this.PrefillingSourceService.query(this.lookup);
}
public deleteType(id: Guid) {
if (id) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
isDeleteConfirmation: true,
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')
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.PrefillingSourceService.delete(id).pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
});
}
}
onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
this.refresh();
}
}

View File

@ -0,0 +1,40 @@
import { DragDropModule } from '@angular/cdk/drag-drop';
import { NgModule } from "@angular/core";
import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.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';
import { HybridListingModule } from "@common/modules/hybrid-listing/hybrid-listing.module";
import { TextFilterModule } from "@common/modules/text-filter/text-filter.module";
import { UserSettingsModule } from "@common/modules/user-settings/user-settings.module";
import { CommonUiModule } from '@common/ui/common-ui.module';
import { NgxDropzoneModule } from "ngx-dropzone";
import { PrefillingSourceRoutingModule } from './prefilling-source.routing';
import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module';
import { PrefillingSourceListingComponent } from './listing/prefilling-source-listing.component';
import { PrefillingSourceListingFiltersComponent } from './listing/filters/prefilling-source-listing-filters.component';
import { PrefillingSourceEditorComponent } from './editor/prefilling-source-editor.component';
import { ExternalFetcherSourceModule } from '@app/ui/external-fetcher/external-fetcher-source.module';
@NgModule({
imports: [
CommonUiModule,
CommonFormsModule,
ConfirmationDialogModule,
PrefillingSourceRoutingModule,
NgxDropzoneModule,
DragDropModule,
AutoCompleteModule,
HybridListingModule,
TextFilterModule,
UserSettingsModule,
CommonFormattingModule,
RichTextEditorModule,
ExternalFetcherSourceModule
],
declarations: [
PrefillingSourceEditorComponent,
PrefillingSourceListingComponent,
PrefillingSourceListingFiltersComponent ]
})
export class PrefillingSourceModule { }

View File

@ -0,0 +1,58 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AdminAuthGuard } from '@app/core/admin-auth-guard.service';
import { PrefillingSourceEditorComponent } from './editor/prefilling-source-editor.component';
import { PrefillingSourceListingComponent } from './listing/prefilling-source-listing.component';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { AuthGuard } from '@app/core/auth-guard.service';
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service';
import { PrefillingSourceEditorResolver } from './editor/prefilling-source-editor.resolver';
const routes: Routes = [
{
path: '',
component: PrefillingSourceListingComponent,
canActivate: [AuthGuard]
},
{
path: 'new',
canActivate: [AuthGuard],
component: PrefillingSourceEditorComponent,
canDeactivate: [PendingChangesGuard],
data: {
authContext: {
permissions: [AppPermission.EditPrefillingSource]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.NEW-PREFILLING-SOURCE'
})
}
},
{
path: ':id',
canActivate: [AuthGuard],
component: PrefillingSourceEditorComponent,
canDeactivate: [PendingChangesGuard],
resolve: {
'entity': PrefillingSourceEditorResolver
},
data: {
...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.EDIT-PREFILLING-SOURCE'
}),
authContext: {
permissions: [AppPermission.EditPrefillingSource]
}
}
},
{ path: '**', loadChildren: () => import('@common/modules/page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: [PrefillingSourceEditorResolver]
})
export class PrefillingSourceRoutingModule { }

View File

@ -123,7 +123,7 @@
</div>
</div>
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">Submit</button>
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'REFERENCE-TYPE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
</div>
</form>
</mat-card-content>
@ -153,360 +153,14 @@
</button>
</div>
</div>
<div class="row" >
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput type="text" name="key" [formControl]="source.get('key')" required>
<mat-error *ngIf="source.get('key').hasError('backendError')">{{source.get('key').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('key').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
<input matInput type="text" name="label" [formControl]="source.get('label')" required>
<mat-error *ngIf="source.get('label').hasError('backendError')">{{source.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
<input matInput type="number" name="ordinal" [formControl]="source.get('ordinal')" required>
<mat-error *ngIf="source.get('ordinal').hasError('backendError')">{{source.get('ordinal').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('ordinal').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCIES' | translate}}</mat-label>
<app-multiple-auto-complete [formControl]="source.get('referenceTypeDependencyIds')" [configuration]="referenceTypeService.multipleAutocompleteConfiguration"></app-multiple-auto-complete>
<mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('backendError')">{{source.get('referenceTypeDependencyIds').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-TYPE' | translate}}</mat-label>
<mat-select name="type" [formControl]="source.get('type')" required>
<mat-option *ngFor="let sourceType of referenceTypeSourceTypeEnum" [value]="sourceType">
{{enumUtils.toReferenceTypeSourceTypeString(sourceType)}}
</mat-option>
</mat-select>
<mat-error *ngIf="source.get('type').hasError('backendError')">{{source.get('type').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row" *ngIf="source.get('type').value == referenceTypeSourceType.API">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
<input matInput type="text" name="ordinal" [formControl]="source.get('url')">
<mat-error *ngIf="source.get('url').hasError('backendError')">{{source.get('url').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.PAGINATION-PATH' | translate}}</mat-label>
<input matInput type="text" name="paginationPath" [formControl]="source.get('paginationPath')">
<mat-error *ngIf="source.get('paginationPath').hasError('backendError')">{{source.get('paginationPath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('paginationPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CONTENT-TYPE' | translate}}</mat-label>
<input matInput type="text" name="contentType" [formControl]="source.get('contentType')">
<mat-error *ngIf="source.get('contentType').hasError('backendError')">{{source.get('contentType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('contentType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.FIRST-PAGE' | translate}}</mat-label>
<input matInput type="text" name="firstPage" [formControl]="source.get('firstPage')">
<mat-error *ngIf="source.get('firstPage').hasError('backendError')">{{source.get('firstPage').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('firstPage').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
<mat-select name="httpMethod" [formControl]="source.get('httpMethod')">
<mat-option *ngFor="let httpMethod of referenceTypeExternalApiHTTPMethodTypeEnum" [value]="httpMethod">
{{enumUtils.toReferenceTypeExternalApiHTTPMethodTypeString(httpMethod)}}
</mat-option>
</mat-select>
<mat-error *ngIf="source.get('httpMethod').hasError('backendError')">{{source.get('httpMethod').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('httpMethod').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="source.get('httpMethod').value == referenceTypeExternalApiHTTPMethodType.POST" >
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
<input matInput type="text" name="requestBody" [formControl]="source.get('requestBody')">
<mat-error *ngIf="source.get('requestBody').hasError('backendError')">{{source.get('requestBody').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('requestBody').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.FILTER-TYPE' | translate}}</mat-label>
<input matInput type="text" name="filterType" [formControl]="source.get('filterType')">
<mat-error *ngIf="source.get('filterType').hasError('backendError')">{{source.get('filterType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('filterType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- Results info -->
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS' | translate}}</h3>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS-PATH' | translate}}</mat-label>
<input matInput type="text" name="resultsArrayPath" [formControl]="source.get('results').get('resultsArrayPath')">
<mat-error *ngIf="source.get('results').get('resultsArrayPath').hasError('backendError')">{{source.get('results').get('resultsArrayPath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('results').get('resultsArrayPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- fields mapping -->
<div class="col-12">
<div *ngFor="let field of source.get('results').get('fieldsMapping').controls; let fieldMappingIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD-MAPPING' | translate}} {{fieldMappingIndex + 1}}</h4>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" [readonly]="field.get('code').disabled" name="code" [formControl]="field.get('code')">
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
<mat-error *ngIf="field.get('responsePath').hasError('backendError')">{{field.get('responsePath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('responsePath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
</div>
</div>
<!-- Auth info -->
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}
<mat-checkbox [formControl]="source.get('auth').get('enabled')"></mat-checkbox>
</h3>
<div class="row" *ngIf="source.get('auth').get('enabled').value == true">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
<input matInput type="text" name="authUrl" [formControl]="source.get('auth').get('authUrl')">
<mat-error *ngIf="source.get('auth').get('authUrl').hasError('backendError')">{{source.get('auth').get('authUrl').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('auth').get('authUrl').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
<mat-select name="httpMethod" [formControl]="source.get('auth').get('authMethod')">
<mat-option *ngFor="let httpMethod of referenceTypeExternalApiHTTPMethodTypeEnum" [value]="httpMethod">
{{enumUtils.toReferenceTypeExternalApiHTTPMethodTypeString(httpMethod)}}
</mat-option>
</mat-select>
<mat-error *ngIf="source.get('auth').get('authMethod').hasError('backendError')">{{source.get('auth').get('authMethod').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('auth').get('authMethod').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TOKEN-PATH' | translate}}</mat-label>
<input matInput type="text" name="authTokenPath" [formControl]="source.get('auth').get('authTokenPath')">
<mat-error *ngIf="source.get('auth').get('authTokenPath').hasError('backendError')">{{source.get('auth').get('authTokenPath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('auth').get('authTokenPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
<input matInput type="text" name="authRequestBody" [formControl]="source.get('auth').get('authRequestBody')">
<mat-error *ngIf="source.get('auth').get('authRequestBody').hasError('backendError')">{{source.get('auth').get('authRequestBody').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('auth').get('authRequestBody').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TYPE' | translate}}</mat-label>
<input matInput type="text" name="type" [formControl]="source.get('auth').get('type')">
<mat-error *ngIf="source.get('auth').get('type').hasError('backendError')">{{source.get('auth').get('type').getError('backendError').message}}</mat-error>
<mat-error *ngIf="source.get('auth').get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
<!-- Queries info -->
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
<button mat-button type="button" class="action-btn" (click)="addQuery(sourceIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
</h3>
<div class="col-12">
<div *ngFor="let query of source.get('queries').controls; let queryIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERY' | translate}} {{queryIndex + 1}}</h4>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-QUERY' | translate}}" (click)="removeQuery(sourceIndex, queryIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
<div class="col-auto">
<button mat-button class="action-btn" type="button" (click)="addCase(sourceIndex, queryIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-CASE' | translate}}</button>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.NAME' | translate}}</mat-label>
<input matInput type="text" name="name" [formControl]="query.get('name')" required>
<mat-error *ngIf="query.get('name').hasError('backendError')">{{query.get('name').getError('backendError').message}}</mat-error>
<mat-error *ngIf="query.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEFAULT-VALUE' | translate}}</mat-label>
<input matInput type="text" name="defaultValue" [formControl]="query.get('defaultValue')">
<mat-error *ngIf="query.get('defaultValue').hasError('backendError')">{{query.get('defaultValue').getError('backendError').message}}</mat-error>
<mat-error *ngIf="query.get('defaultValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
<!-- Query Cases -->
<div *ngFor="let case of query.get('cases').controls; let caseIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.CASE' | translate}} {{caseIndex + 1}}</h4>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-CASE' | translate}}" (click)="removeCase(sourceIndex, queryIndex, caseIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LIKE-PATTERN' | translate}}</mat-label>
<input matInput type="text" name="likePattern" [formControl]="case.get('likePattern')">
<mat-error *ngIf="case.get('likePattern').hasError('backendError')">{{case.get('likePattern').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('likePattern').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SEPARATOR' | translate}}</mat-label>
<input matInput type="text" name="separator" [formControl]="case.get('separator')">
<mat-error *ngIf="case.get('separator').hasError('backendError')">{{case.get('separator').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('separator').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput type="text" name="value" [formControl]="case.get('value')">
<mat-error *ngIf="case.get('value').hasError('backendError')">{{case.get('value').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
<mat-select (selectionChange)="selectedReferenceTypeChanged($event.value)" name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.id">
{{referenceType.code}}
</mat-option>
</mat-select>
<mat-error *ngIf="case.get('referenceTypeId').hasError('backendError')">{{case.get('referenceTypeId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="case.get('referenceTypeId').value">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-KEY' | translate}}</mat-label>
<mat-select name = 'referenceTypeSourceKey' [formControl]="case.get('referenceTypeSourceKey')">
<mat-option *ngFor="let sourceKey of sourceKeysMap.get(case.get('referenceTypeId').value)" [value]="sourceKey">
{{sourceKey}}
</mat-option>
</mat-select>
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('backendError')">{{case.get('referenceTypeSourceKey').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
</div>
</div>
</div>
</div>
<!-- Options -->
<div class="row" *ngIf="source.get('type').value == referenceTypeSourceType.STATIC">
<div class="col-12">
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTIONS' | translate}}</h3>
<div *ngFor="let option of source.get('options').controls; let optionsIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTION' | translate}} {{optionsIndex + 1}}</h4>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" [readonly]="option.get('code').disabled" name="code" [formControl]="option.get('code')">
<mat-error *ngIf="option.get('code').hasError('backendError')">{{option.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="option.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput type="text" name="value" [formControl]="option.get('value')">
<mat-error *ngIf="option.get('value').hasError('backendError')">{{option.get('value').getError('backendError').message}}</mat-error>
<mat-error *ngIf="option.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
</div>
</div>
</div>
</div>
<app-external-fetcher-source-component
[formGroup]="source"
[validationErrorModel]="editorModel.validationErrorModel"
[validationRootPath]="'definition.sources[' + sourceIndex + '].'"
[referenceTypeSourceIndex]="sourceIndex"
[referenceTypes]="referenceTypes"
[sourceKeysMap]="sourceKeysMap">
</app-external-fetcher-source-component>
</mat-card-content>
</div>
</div>
@ -514,7 +168,6 @@
<mat-error *ngIf="formGroup.get('definition').get('sources').hasError('backendError')">{{formGroup.get('definition').get('sources').getError('backendError').message}}</mat-error>
</div>
</form>
{{formGroup.value | json}}
</mat-card-content>
</mat-card>

View File

@ -11,8 +11,8 @@ import { DatePipe } from '@angular/common';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
import { 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 { ExternalFetcherApiHTTPMethodType } from '@app/core/common/enum/external-fetcher-api-http-method-type';
import { ExternalFetcherSourceType } from '@app/core/common/enum/external-fetcher-source-type';
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type';
import { AuthService } from '@app/core/services/auth/auth.service';
import { LoggingService } from '@app/core/services/logging/logging-service';
@ -42,11 +42,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
isDeleted = false;
formGroup: UntypedFormGroup = null;
showInactiveDetails = false;
referenceTypeSourceType = ReferenceTypeSourceType;
referenceTypeExternalApiHTTPMethodType = ReferenceTypeExternalApiHTTPMethodType;
public referenceTypeSourceTypeEnum = this.enumUtils.getEnumValues<ReferenceTypeSourceType>(ReferenceTypeSourceType);
referenceTypeSourceType = ExternalFetcherSourceType;
referenceTypeExternalApiHTTPMethodType = ExternalFetcherApiHTTPMethodType;
public referenceTypeSourceTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherSourceType>(ExternalFetcherSourceType);
public referenceFieldDataTypeEnum = this.enumUtils.getEnumValues<ReferenceFieldDataType>(ReferenceFieldDataType);
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ReferenceTypeExternalApiHTTPMethodType>(ReferenceTypeExternalApiHTTPMethodType);
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherApiHTTPMethodType>(ExternalFetcherApiHTTPMethodType);
referenceTypes: ReferenceType[] = null;
sourceKeysMap: Map<Guid, string[]> = new Map<Guid, string[]>();
@ -111,14 +111,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
this.getReferenceTypes(this.editorModel.id);
if (data) {
data.definition.sources?.forEach(source => source.queries?.forEach(query => {
query?.cases?.forEach(queryCase => {
if(queryCase.referenceType && queryCase.referenceType.id) this.selectedReferenceTypeChanged(queryCase.referenceType.id);
})
}));
}
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.buildForm();
} catch (error) {
@ -163,9 +155,9 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
formSubmit(): void {
this.formService.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) {
return;
}
// if (!this.isFormValid()) {
// return;
// }
this.persistEntity();
}
@ -330,49 +322,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
}
//
//
// queries
//
//
addQuery(sourceIndex: number): void {
const queryArray= ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray);
queryArray.push(this.editorModel.createQuery(sourceIndex, queryArray.length));
}
removeQuery(sourceIndex: number, queryIndex: number): void {
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray);
formArray.removeAt(queryIndex);
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
);
formArray.markAsDirty();
}
// cases
addCase(sourceIndex: number, queryIndex: number): void {
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
formArray.push(this.editorModel.createCase(sourceIndex, queryIndex, formArray.length));
}
removeCase(sourceIndex: number, queryIndex: number, index: number): void {
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
formArray.removeAt(index);
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
);
formArray.markAsDirty();
}
// Options
addOption(sourceIndex: number, code: string): void {
@ -404,6 +353,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
}
private getReferenceTypes(excludedId?: Guid): void {
let sourceKeys: string[] = [];
const lookup = ReferenceTypeService.DefaultReferenceTypeLookup();
if (excludedId) lookup.excludedIds = [excludedId];
@ -413,7 +363,8 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
.subscribe(response => {
this.referenceTypes = response.items as ReferenceType[];
this.referenceTypes.forEach(referenceType => {
this.sourceKeysMap.set(referenceType.id, []);
sourceKeys = referenceType.definition.sources.map(x => x.key);
this.sourceKeysMap.set(referenceType.id, sourceKeys);
})
});
}

View File

@ -1,13 +1,11 @@
import { FormArray, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-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 { AuthenticationConfiguration, AuthenticationConfigurationPersist, QueryCaseConfig, QueryCaseConfigPersist, QueryConfig, QueryConfigPersist, ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypeField, ReferenceTypeFieldPersist, ReferenceTypePersist, ReferenceTypeSourceBaseConfiguration, ReferenceTypeSourceBaseConfigurationPersist, ReferenceTypeStaticOption, ReferenceTypeStaticOptionPersist, ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultsConfigurationPersist } from "@app/core/model/reference-type/reference-type";
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypeField, ReferenceTypeFieldPersist, ReferenceTypePersist } from "@app/core/model/reference-type/reference-type";
import { BaseEditorModel } from "@common/base/base-form-editor-model";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
import { Guid } from "@common/types/guid";
import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel, ResultFieldsMappingConfigurationEditorModel, StaticOptionEditorModel } from "@app/ui/external-fetcher/external-fetcher-source-editor.model";
export class ReferenceTypeEditorModel extends BaseEditorModel implements ReferenceTypePersist {
name: string;
@ -66,7 +64,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
}
createChildSource(index: number): UntypedFormGroup {
const source: ReferenceTypeSourceBaseConfigurationEditorModel = new ReferenceTypeSourceBaseConfigurationEditorModel(this.validationErrorModel);
const source: ExternalFetcherBaseSourceConfigurationEditorModel = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel);
return source.buildForm({ rootPath: 'definition.sources[' + index + '].' });
}
@ -76,7 +74,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
}
createOptions(sourceIndex: number, index: number): UntypedFormGroup {
const fieldMapping: ReferenceTypeStaticOptionEditorModel = new ReferenceTypeStaticOptionEditorModel(this.validationErrorModel);
const fieldMapping: StaticOptionEditorModel = new StaticOptionEditorModel(this.validationErrorModel);
return fieldMapping.buildForm({ rootPath: 'definition.sources[' + sourceIndex + '].options[' + index + '].'});
}
@ -121,7 +119,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefinitionPersist {
fields: ReferenceTypeFieldEditorModel[] = [];
sources: ReferenceTypeSourceBaseConfigurationEditorModel[] = [];
sources: ExternalFetcherBaseSourceConfigurationEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -132,7 +130,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel {
if (item) {
if (item.fields) { item.fields.map(x => this.fields.push(new ReferenceTypeFieldEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.sources) { item.sources.map(x => this.sources.push(new ReferenceTypeSourceBaseConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.sources) { item.sources.map(x => this.sources.push(new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
}
return this;
}
@ -207,7 +205,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
}): void {
const { validationErrorModel, rootPath, formArray } = params;
formArray?.controls?.forEach(
(control, index) => ReferenceTypeSourceBaseConfigurationEditorModel.reapplyValidators({
(control, index) => ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}sources[${index}].`,
validationErrorModel: validationErrorModel
@ -296,693 +294,3 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
})
}
}
export class ReferenceTypeSourceBaseConfigurationEditorModel implements ReferenceTypeSourceBaseConfigurationPersist {
type: ReferenceTypeSourceType;
key: string;
label: string;
ordinal: number;
url: string;
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel(this.validationErrorModel);
paginationPath: string;
contentType: string;
firstPage: string;
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
requestBody?: string;
filterType?: string;
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel(this.validationErrorModel);
queries?: QueryConfigEditorModel[] = [];
options: ReferenceTypeStaticOptionEditorModel[] = [];
referenceTypeDependencyIds: Guid[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: ReferenceTypeSourceBaseConfiguration): ReferenceTypeSourceBaseConfigurationEditorModel {
if (item) {
this.type = item.type;
this.key = item.key;
this.label = item.label;
this.ordinal = item.ordinal;
if (item.url) this.url = item.url;
if (item.results) this.results = new ResultsConfigurationEditorModel(this.validationErrorModel).fromModel(item.results);
if (item.paginationPath) this.paginationPath = item.paginationPath;
if (item.contentType) this.contentType = item.contentType;
if (item.firstPage) this.firstPage = item.firstPage;
if (item.httpMethod != null) this.httpMethod = item.httpMethod;
if (item.requestBody) this.requestBody = item.requestBody;
if (item.filterType) this.filterType = item.filterType;
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
if (item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.options) {
item.options.map(x => this.options.push(new ReferenceTypeStaticOptionEditorModel(this.validationErrorModel).fromModel(x)));
} else {
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'reference_id', value: undefined }));
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'label', value: undefined }));
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'description', value: undefined }));
}
if (item.referenceTypeDependencies) { item.referenceTypeDependencies.forEach(referenceType => this.referenceTypeDependencyIds.push(referenceType.id))}
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ReferenceTypeSourceBaseConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
results: this.results.buildForm({
rootPath: `${rootPath}results.`,
}),
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
firstPage: [{ value: this.firstPage, disabled: disabled }, context.getValidation('firstPage').validators],
httpMethod: [{ value: this.httpMethod, disabled: disabled }, context.getValidation('httpMethod').validators],
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
auth: this.auth.buildForm({
rootPath: `${rootPath}auth.`
}),
queries: this.formBuilder.array(
(this.queries ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}queries[${index}].`
})
), context.getValidation('queries').validators
),
options: this.formBuilder.array(
(this.options ?? []).map(
(item, index) => new ReferenceTypeStaticOptionEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
rootPath: `${rootPath}options[${index}].`
})
), context.getValidation('options').validators
),
referenceTypeDependencyIds: [{ value: this.referenceTypeDependencyIds, disabled: disabled }, context.getValidation('referenceTypeDependencyIds').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
baseValidationArray.push({ key: 'contentType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
baseValidationArray.push({ key: 'firstPage', validators: [Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
baseValidationArray.push({ key: 'httpMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}httpMethod`)] });
baseValidationArray.push({ key: 'requestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestBody`)] });
baseValidationArray.push({ key: 'filterType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}filterType`)] });
baseValidationArray.push({ key: 'results', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}results`)] });
baseValidationArray.push({ key: 'queries', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}queries`)] });
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
baseValidationArray.push({ key: 'referenceTypeDependencyIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeDependencyIds`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ReferenceTypeSourceBaseConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['type', 'key', 'label', 'ordinal', 'url', 'paginationPath', 'contentType', 'firstPage', 'httpMethod', 'requestBody','filterType', 'referenceTypeDependencyIds'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
AuthenticationConfigurationEditorModel.reapplyAuthValidators({
formGroup: formGroup?.get('auth') as UntypedFormGroup,
rootPath: `${rootPath}auth.`,
validationErrorModel: validationErrorModel
});
ResultsConfigurationEditorModel.reapplyValidators({
formGroup: formGroup?.get('results') as UntypedFormGroup,
rootPath: `${rootPath}results.`,
validationErrorModel: validationErrorModel
});
(formGroup.get('options') as FormArray).controls?.forEach(
(control, index) => ReferenceTypeStaticOptionEditorModel.reapplyStaticOptionsValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}options[${index}].`,
validationErrorModel: validationErrorModel
}
)
);
(formGroup.get('queries') as FormArray).controls?.forEach(
(control, index) => QueryConfigEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}queries[${index}].`,
validationErrorModel: validationErrorModel
})
);
}
}
export class ResultsConfigurationEditorModel implements ResultsConfigurationPersist {
public resultsArrayPath: string;
public fieldsMapping: ResultFieldsMappingConfigurationEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: ResultsConfiguration): ResultsConfigurationEditorModel {
this.resultsArrayPath = item.resultsArrayPath;
if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
else {
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'reference_id', responsePath: undefined }));
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'label', responsePath: undefined }));
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'description', responsePath: undefined }));
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ResultsConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
resultsArrayPath: [{ value: this.resultsArrayPath, disabled: disabled }, context.getValidation('resultsArrayPath').validators],
fieldsMapping: this.formBuilder.array(
(this.fieldsMapping ?? []).map(
(item, index) => new ResultFieldsMappingConfigurationEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
rootPath: `${rootPath}fieldsMapping[${index}].`
})
), context.getValidation('fieldsMapping').validators
)
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'resultsArrayPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
baseValidationArray.push({ key: 'fieldsMapping', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ResultsConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['resultsArrayPath'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
(formGroup.get('fieldsMapping') as FormArray).controls?.forEach(
(control, index) => ResultFieldsMappingConfigurationEditorModel.reapplyFieldsMappingValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}fieldsMapping[${index}].`,
validationErrorModel: validationErrorModel
}
)
);
}
}
export class ResultFieldsMappingConfigurationEditorModel implements ResultFieldsMappingConfigurationPersist {
public code: string;
public responsePath: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: ResultFieldsMappingConfiguration): ResultFieldsMappingConfigurationEditorModel {
this.code = item.code;
this.responsePath = item.responsePath;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
baseValidationArray.push({ key: 'responsePath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyFieldsMappingValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['code', 'responsePath'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
}
}
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
public enabled: boolean = false;
public authUrl: string;
public authMethod: ReferenceTypeExternalApiHTTPMethodType;
public authTokenPath: string;
public authRequestBody: string;
public type: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: AuthenticationConfiguration): AuthenticationConfigurationEditorModel {
this.enabled = item.enabled;
this.authUrl = item.authUrl;
this.authMethod = item.authMethod;
this.authTokenPath = item.authTokenPath;
this.authRequestBody = item.authRequestBody;
this.type = item.type;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = AuthenticationConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
enabled: [{ value: this.enabled, disabled: disabled }, context.getValidation('enabled').validators],
authUrl: [{ value: this.authUrl, disabled: disabled }, context.getValidation('authUrl').validators],
authMethod: [{ value: this.authMethod, disabled: disabled }, context.getValidation('authMethod').validators],
authTokenPath: [{ value: this.authTokenPath, disabled: disabled }, context.getValidation('authTokenPath').validators],
authRequestBody: [{ value: this.authRequestBody, disabled: disabled }, context.getValidation('authRequestBody').validators],
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'enabled', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}enabled`)] });
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
baseValidationArray.push({ key: 'authRequestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyAuthValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = AuthenticationConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['enabled', 'authUrl', 'authMethod', 'authTokenPath', 'authRequestBody', 'type'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
export class QueryConfigEditorModel implements QueryConfigPersist {
public name: string;
public defaultValue: string;
public cases: QueryCaseConfigEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: QueryConfig): QueryConfigEditorModel {
this.name = item.name;
this.defaultValue = item.defaultValue;
if (item.cases) { item.cases.map(x => this.cases.push(new QueryCaseConfigEditorModel(this.validationErrorModel).fromModel(x))); }
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = QueryConfigEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators],
defaultValue: [{ value: this.defaultValue, disabled: disabled }, context.getValidation('defaultValue').validators],
cases: this.formBuilder.array(
(this.cases ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}cases[${index}].`
})
), context.getValidation('cases').validators
)
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}name`)] });
baseValidationArray.push({ key: 'defaultValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultValue`)] });
baseValidationArray.push({ key: 'cases', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}cases`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = QueryConfigEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['name', 'defaultValue'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
(formGroup.get('cases') as FormArray).controls?.forEach(
(control, index) => QueryCaseConfigEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}cases[${index}].`,
validationErrorModel: validationErrorModel
}
)
);
}
}
export class QueryCaseConfigEditorModel implements QueryCaseConfigPersist {
public likePattern: string;
public separator: string;
public value: string;
public referenceTypeId: Guid;
public referenceTypeSourceKey: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: QueryCaseConfig): QueryCaseConfigEditorModel {
this.likePattern = item.likePattern;
this.separator = item.separator;
this.value = item.value;
if(item?.referenceType?.id) this.referenceTypeId = item.referenceType.id;
this.referenceTypeSourceKey = item.referenceTypeSourceKey;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = QueryCaseConfigEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
likePattern: [{ value: this.likePattern, disabled: disabled }, context.getValidation('likePattern').validators],
separator: [{ value: this.separator, disabled: disabled }, context.getValidation('separator').validators],
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
referenceTypeSourceKey: [{ value: this.referenceTypeSourceKey, disabled: disabled }, context.getValidation('referenceTypeSourceKey').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'likePattern', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}likePattern`)] });
baseValidationArray.push({ key: 'separator', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}separator`)] });
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
baseValidationArray.push({ key: 'referenceTypeSourceKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeSourceKey`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = QueryCaseConfigEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['likePattern', 'separator', 'value', 'referenceTypeId', 'referenceTypeSourceKey'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
export class ReferenceTypeStaticOptionEditorModel implements ReferenceTypeStaticOptionPersist {
public code: string;
public value: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: ReferenceTypeStaticOption): ReferenceTypeStaticOptionEditorModel {
this.code = item.code;
this.value = item.value;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ReferenceTypeStaticOptionEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
baseValidationArray.push({ key: 'value', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyStaticOptionsValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ReferenceTypeStaticOptionEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['code', 'value'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
}
}

View File

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AuthenticationConfiguration, QueryConfig, ReferenceType, ReferenceTypeDefinition, ReferenceTypeField, ReferenceTypeSourceBaseConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeStaticOption, QueryCaseConfig } from '@app/core/model/reference-type/reference-type';
import { AuthenticationConfiguration, ExternalFetcherBaseSourceConfiguration, QueryCaseConfig, QueryConfig, ResultFieldsMappingConfiguration, ResultsConfiguration, StaticOption } from '@app/core/model/external-fetcher/external-fetcher';
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeField } from '@app/core/model/reference-type/reference-type';
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
@ -27,45 +28,45 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.description)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.dataType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.type)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.key)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.label)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.ordinal)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.name)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.label)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.ordinal)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.name)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.url)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.url)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.paginationPath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.contentType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.firstPage)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.httpMethod)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.requestBody)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.filterType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.paginationPath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.contentType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.firstPage)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.httpMethod)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.requestBody)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.filterType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.name)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.defaultValue)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.name)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceTypeSourceKey)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.name)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.defaultValue)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.name)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceTypeSourceKey)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.code)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.value)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.options),nameof<StaticOption>(x => x.code)].join('.'),
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.options),nameof<StaticOption>(x => x.value)].join('.'),
nameof<ReferenceType>(x => x.createdAt),
nameof<ReferenceType>(x => x.updatedAt),

View File

@ -15,6 +15,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
import { CommonFormattingModule } from '@common/formatting/common-formatting.module';
import { ReferenceTypeListingComponent } from './listing/reference-type-listing.component';
import { ExternalFetcherSourceModule } from '@app/ui/external-fetcher/external-fetcher-source.module';
@NgModule({
@ -36,7 +37,8 @@ import { ReferenceTypeListingComponent } from './listing/reference-type-listing.
NgxDropzoneModule,
DragDropModule,
AutoCompleteModule,
CommonFormattingModule
CommonFormattingModule,
ExternalFetcherSourceModule
]
})
export class ReferenceTypeModule { }

View File

@ -0,0 +1,149 @@
<div class="container form-container">
<div class="annotation-viewer row">
<!-- Create New Thread -->
<!-- <div *ngIf="this.canEdit && !this.isDeleted" class="col-12"> -->
<div class="col-12">
<form class="row p-2 mt-2 mb-3 ml-0 pr-3 mr-0 new-thread" [formGroup]="threadFormGroup">
<mat-form-field class="col msg-input">
<textarea matInput matTextareaAutosize matAutosizeMinRows="1" name="thread-text" formControlName="text" placeholder="{{'APP.ANNOTATION.THREADS.NEW-THREAD' | translate}}" required></textarea>
<mat-error *ngIf="threadFormGroup.get('text').hasError('backendError')">{{threadFormGroup.get('text').getError('backendError')?.message}}</mat-error>
<mat-error *ngIf="threadFormGroup.get('text').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- <mat-form-field class="col-auto pl-0 pr-0 protection-input">
<mat-label>{{'APP.ANNOTATION.THREADS.PROTECTION.TITLE' | translate}}</mat-label>
<mat-select name="thread-annotationProtectionType" formControlName="annotationProtectionType" required>
<mat-option *ngFor="let enumValue of annotationProtectionTypeEnumValues" [value]="enumValue">{{enumUtils.toAnnotationProtectionTypeString(enumValue)}}</mat-option>
</mat-select>
<mat-error *ngIf="threadFormGroup.get('annotationProtectionType').hasError('backendError')">{{threadFormGroup.get('annotationProtectionType').getError('backendError')?.message}}</mat-error>
<mat-error *ngIf="threadFormGroup.get('annotationProtectionType').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> -->
<div class="col-auto send-msg">
<button mat-raised-button type="button" (click)="createThread()">
<i class="fa fa-paper-plane"></i> {{'APP.ANNOTATION.THREADS.SEND' | translate}}
</button>
</div>
</form>
</div>
<div class="col-12 mb-3 pt-2 gr-color" *ngIf="threads?.length > 0">{{'APP.ANNOTATION.TITLE' | translate}}</div>
<div class="col-12">
<div *ngFor="let thread of threads" class="row">
<!-- Parent Thread -->
<div class="col-12">
<div class="row parent-thread m-0 h-100">
<div class="col-auto pr-0 pl-0">
<div class="side-color"></div>
</div>
<div class="col">
<div class="row reply-content">
<div class="col-12">
<div class="row h-100">
<div class="col annotation-time">{{thread.timeStamp | date:'EEEE, MMMM d, y, h:mm a'}}</div>
<div class="col-auto" *ngIf="thread.protection === 0" matTooltip="{{'APP.ANNOTATION.PROTECTION.PRIVATE' | translate}}"><i class="material-icons protection-icon icon-{{getAnnotationProtectionType(thread)}}">{{getAnnotationProtectionType(thread)}}</i></div>
<div class="col-auto" *ngIf="thread.protection === 1" matTooltip="{{'APP.ANNOTATION.PROTECTION.UNIT' | translate}}"><i class="material-icons protection-icon icon-{{getAnnotationProtectionType(thread)}}">{{getAnnotationProtectionType(thread)}}</i></div>
<div class="col-auto" *ngIf="thread.protection === 65535" matTooltip="{{'APP.ANNOTATION.PROTECTION.PUBLIC' | translate}}"><i class="material-icons protection-icon icon-{{getAnnotationProtectionType(thread)}}">{{getAnnotationProtectionType(thread)}}</i></div>
<div class="col-md-12 annotation-full-text">{{thread.text}}</div>
<div class="col-md-12">
<em class="user">{{'APP.ANNOTATION.THREADS.FROM-USER' | translate}} {{thread.author.name}}</em>
<!-- <em>{{thread.author.name}}</em> -->
<!-- |
<em class="gr-color">{{'APP.ANNOTATION.THREADS.UNIT' | translate}}</em> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Previous Replies -->
<div class="col-12">
<div *ngFor="let annotation of annotationsPerThread[thread.threadId]; let i = index;" class="row replies">
<div class="col-auto pr-0">
<div class="col reply child"></div>
<div class="col reply child dummy-for-next-child" *ngIf="i != annotationsPerThread[thread.threadId].length - 1"></div>
</div>
<div class="col pl-0 pt-1">
<div class="parent row m-0">
<div class="col-auto pl-0 pr-0">
<div class="side-soft-color"></div>
</div>
<div class="col reply-content">
<div class="row h-100">
<div class="col-md-12 annotation-time">{{annotation.timeStamp | date:'EEEE, MMMM d, y, h:mm a'}}</div>
<div class="col-md-12 annotation-full-text">{{annotation.text}}</div>
<div class="col-md-12">
<em class="gr-color">{{'APP.ANNOTATION.THREADS.FROM-USER' | translate}}</em>
{{annotation.author.name}}
<!-- |
<em class="gr-color">{{'APP.ANNOTATION.THREADS.UNIT' | translate}}</em> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Type reply in thread -->
<div *ngIf="this.canEdit && !this.isDeleted" class="col-12">
<div class="row new-reply mr-0">
<mat-form-field class="col pt-2 pb-2 pr-0">
<textarea matInput matTextareaAutosize matAutosizeMinRows="1" [formControl]="this.threadReplyTextsFG[thread.id.toString()].get('replyText')" placeholder="{{'APP.ANNOTATION.THREADS.REPLY' | translate}}"></textarea>
<mat-error *ngIf="this.threadReplyTextsFG[thread.id.toString()]?.get('replyText')?.hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-auto send-msg">
<button class="form-field-margin" mat-icon-button type="button" color="accent" (click)="replyThread(thread.threadId, thread.protection)" matTooltip="{{'APP.ANNOTATION.THREADS.REPLY' | translate}}">
<i class="fa fa-paper-plane"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row d-flex justify-content-between align-items-center m-0">
<div class="col-auto"><a class="logo"><img class="logo" src="../../../assets/images/new-dmp-logo.png" onerror="this.style.display='none'"></a></div>
<div class="col-auto ml-auto close-btn" (click)="close()">
<mat-icon class="close-icon">close</mat-icon>
</div>
</div>
<div class="row content">
<!-- {{annotations | json}} -->
<div class="col-12">
<h1 mat-dialog-title class="title p-0">{{'NAV-BAR.START-NEW-DMP' | translate}}</h1>
</div>
<div class="col-12">
<p class="text">{{'NAV-BAR.START-NEW-DMP-TXT' | translate}}</p>
</div>
<div class="col-12">
<div class="row d-flex justify-content-between align-items-center">
<div class="col-auto">
<!-- <button type="button" class="normal-btn upload-btn d-flex flex-row align-items-center" (click)="uploadFile($event)">
<mat-icon class="pr-2">file_upload</mat-icon>
{{ 'NAV-BAR.IMPORT-FROM-FILE' | translate }}
</button> -->
</div>
<div class="col-auto pl-0 pr-0">
<p class="">{{ 'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate }}</p>
</div>
<div class="col-auto">
<!-- <button type="button" class="normal-btn font-weight-bold d-flex flex-row align-items-center" (click)="startWizard()">
<mat-icon>chevron_right</mat-icon>
{{ 'NAV-BAR.START-WIZARD' | translate }}
</button> -->
</div>
</div>
</div>
</div>
<div class="row m-0 pt-4">
<div class="col-auto">
<mat-icon class="material-icons-outlined warn">info</mat-icon>
</div>
<span class="col">
<b>{{'GENERAL.START-NEW-DMP-DIALOG.IMPORT' | translate }}</b> {{'GENERAL.START-NEW-DMP-DIALOG.FUNCTION-SUPPORTS' | translate }}
<b>{{'GENERAL.START-NEW-DMP-DIALOG.JSON-FILES' | translate }}</b> {{'GENERAL.START-NEW-DMP-DIALOG.PRODUCED' | translate }}
<b><a href="https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard" target="_blank">{{'GENERAL.START-NEW-DMP-DIALOG.RDA-SPECIFICATIONS' | translate }}</a></b>
{{'GENERAL.START-NEW-DMP-DIALOG.MACHINE-ACTIONABLE' | translate }}
</span>
</div>
</div>

View File

@ -0,0 +1,68 @@
::ng-deep .mat-dialog-container {
border-radius: 8px;
}
.form-container {
width: 33rem;
min-height: 14rem;
padding: 0.28rem 0.34rem 0.875rem 0.625rem;
}
.logo {
width: 8.44rem;
}
.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%;
}
.content {
margin: 2.17rem 2.304rem 1.1875rem 3.065rem;
}
.title,
.text {
font-size: 1.25rem;
font-weight: lighter;
color: #000000;
opacity: 0.8;
}
.title {
font-size: 2.375rem;
margin-bottom: 1.1875rem;
}
.text {
margin-bottom: 2.9375rem;
line-height: 1.9rem;
}
.upload-btn {
background-color: white;
color: #212121;
font-weight: bold;
box-shadow: 0px 3px 6px #1e202029;
border: 2px solid #212121;
}
.actions {
width: 26.667rem;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.warn {
color: #f16868;
}

View File

@ -0,0 +1,197 @@
import { HttpClient } from '@angular/common/http';
import { Component, Inject } from '@angular/core';
import { FormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { Annotation, AnnotationPersist } from '@annotation-service/core/model/annotation.model';
import { AnnotationLookup } from '@annotation-service/core/query/annotation.lookup';
import { AnnotationService } from '@annotation-service/services/http/annotation.service';
import { AnnotationProtectionType } from '@app/core/common/enum/annotation-protection-type.enum';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
import { BaseComponent } from '@common/base/base.component';
import { FormService } from '@common/forms/form-service';
import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
@Component({
selector: 'app-start-new-dmp',
templateUrl: './annotation-dialog.component.html',
styleUrls: ['./annotation-dialog.component.scss']
})
export class AnnotationDialogComponent extends BaseComponent {
private entityId: Guid;
private anchor: string;
private entityType: string;
// public annotations: Array<Annotation> = [];
public threads = new Array<Annotation>();
public annotationsPerThread = {};
threadReplyTextsFG: Array<UntypedFormGroup>;
threadFormGroup: UntypedFormGroup;
private formBuilder: FormBuilder = new FormBuilder();
constructor(
public dialogRef: MatDialogRef<AnnotationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private router: Router,
public dialog: MatDialog,
private uiNotificationService: UiNotificationService,
private language: TranslateService,
private annotationService: AnnotationService,
private formService: FormService
) {
super();
this.entityId = data.entityId;
this.anchor = data.anchor;
this.entityType = data.entityType;
}
ngOnInit(): void {
// this.threadFormGroup = new UntypedFormGroup({
// text: new FormControl(null, [Validators.required]),
// annotationProtectionType: new FormControl(AnnotationProtectionType.Public, [Validators.required])
// });
// if (this.entityId != null) {
// this.loadThreads();
// }
}
createThread() {
// this.formService.removeAllBackEndErrors(this.threadFormGroup);
// this.formService.touchAllFormFields(this.threadFormGroup);
// if (!this.isFormValid(this.threadFormGroup)) {
// return;
// }
// const threadToCreate: AnnotationPersist = {
// payload: this.threadFormGroup.get('text').value,
// protection: this.threadFormGroup.get('annotationProtectionType').value,
// referenceId: this.referenceId
// };
// this.annotationService.persist(threadToCreate).pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
}
replyThread(threadId: Guid, threadProtection: AnnotationProtectionType) {
// // if (!this.threadReplyTexts[threadId.toString()] || this.threadReplyTexts[threadId.toString()].length === 0) { return; }
// this.formService.removeAllBackEndErrors(this.threadReplyTextsFG[threadId.toString()]);
// this.formService.touchAllFormFields(this.threadReplyTextsFG[threadId.toString()]);
// if (!this.isFormValid(this.threadReplyTextsFG[threadId.toString()])) {
// return;
// }
// const replyToCreate: AnnotationPersist = {
// threadId: threadId,
// text: this.threadReplyTextsFG[threadId.toString()].get('replyText').value,
// protection: threadProtection,
// referenceId: this.referenceId
// };
// this.annotationService.persist(replyToCreate).pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
}
private refreshAnnotations() {
// this.threadReplyTextsFG.forEach(element => {
// element.reset();
// });
this.loadThreads();
}
private loadThreads() {
const lookup: AnnotationLookup = new AnnotationLookup();
lookup.entityIds = [this.entityId];
// lookup.anchors = [this.anchor];
lookup.entityTypes = [this.entityType];
lookup.project = {
fields: [
nameof<Annotation>(x => x.id),
// nameof<Annotation>(x => x.threadId),
// nameof<Annotation>(x => x.threadId),
// nameof<Annotation>(x => x.timeStamp),
// nameof<Annotation>(x => x.author.name),
nameof<Annotation>(x => x.payload),
// nameof<Annotation>(x => x.protection),
]
};
this.annotationService.query(lookup)
.pipe(takeUntil(this._destroyed))
.subscribe(
data => {
// this.annotationsPerThread = {};
// this.threadReplyTextsFG = new Array<UntypedFormGroup>();
// this.resetFormGroup();
// this.threads = data.items.filter(item => item.id === item.threadId).sort((a1, a2) => new Date(a2.timeStamp).getTime() - new Date(a1.timeStamp).getTime());
// this.threads.forEach(element => {
// // this.threadReplyTextsFG.addControl(element.id.toString(), new FormControl(null));
// this.threadReplyTextsFG[element.id.toString()] = this.fb.group({ replyText: new FormControl(null, [Validators.required]) });
// this.annotationsPerThread[element.id.toString()] = data.items.filter(x => x.threadId === element.id && x.id !== element.id).sort((a1, a2) => new Date(a1.timeStamp).getTime() - new Date(a2.timeStamp).getTime());
// });
// // this.annotationsChanged.emit(this.threads);
},
error => this.onCallbackError(error),
);
}
resetFormGroup() {
this.threadFormGroup.reset();
this.threadFormGroup.get('annotationProtectionType').setValue(AnnotationProtectionType.EntityAccessors);
}
isValidText(text: string): boolean {
return !isNullOrUndefined(text) && text.length !== 0 && text !== '';
}
// ngOnInit() {
// const lookup: AnnotationLookup = new AnnotationLookup();
// lookup.entityIds = [this.entityId];
// // lookup.anchors = [this.anchor];
// lookup.entityTypes = [this.entityType];
// this.annotationService.query(lookup).pipe(takeUntil(this._destroyed))
// .subscribe(
// data => {
// this.annotations = data.items;
// },
// error => this.onCallbackError(error)
// );
// }
private onCallbackSuccess() {
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-UPLOAD.UPLOAD-SUCCESS'), SnackBarNotificationLevel.Success);
this.router.navigate(['/reload']).then(() => this.router.navigate(['/plans']));
// this.router.navigate(['/reload']).then(() => this.isPublic ? this.router.navigate(['/explore-plans']) : this.router.navigate(['/plans']));
}
private onCallbackError(error: any) {
this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error);
}
cancel() {
this.dialogRef.close();
}
send() {
this.dialogRef.close(this.data);
}
close() {
this.dialogRef.close(false);
}
startWizard() {
this.router.navigate(['/plans/new']);
this.close();
}
}

View File

@ -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 { AnnotationDialogComponent } from './annotation-dialog.component';
@NgModule({
imports: [
CommonUiModule,
CommonFormsModule,
FormattingModule,
],
declarations: [
AnnotationDialogComponent,
],
exports: [
AnnotationDialogComponent,
]
})
export class AnnotationDialogModule { }

View File

@ -1,26 +1,27 @@
import { DatePipe } from '@angular/common';
import { Component, OnInit, ViewChild } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { DescriptionStatus } from '@app/core/common/enum/description-status';
import { DmpStatus } from '@app/core/common/enum/dmp-status';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { Description, DescriptionPersist } from '@app/core/model/description/description';
import { AuthService } from '@app/core/services/auth/auth.service';
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { DescriptionService } from '@app/core/services/description/description.service';
import { DmpService } from '@app/core/services/dmp/dmp.service';
import { LockService } from '@app/core/services/lock/lock.service';
import { LoggingService } from '@app/core/services/logging/logging-service';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import {
SnackBarNotificationLevel,
UiNotificationService
} from '@app/core/services/notification/ui-notification-service';
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
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 { 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 { FileUtils } from '@app/core/services/utilities/file-utils.service';
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
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';
@ -34,12 +35,10 @@ import { map, takeUntil } from 'rxjs/operators';
import { DescriptionEditorModel, DescriptionPropertyDefinitionEditorModel } from './description-editor.model';
import { DescriptionEditorResolver } from './description-editor.resolver';
import { DescriptionEditorService } from './description-editor.service';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component';
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';
import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component';
@Component({
selector: 'app-description-editor-component',
@ -140,12 +139,18 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.route.params
.pipe(takeUntil(this._destroyed))
.subscribe((params: Params) => {
const isPublicDescription = params['public'];
const itemId = params['id'];
const dmpId = params['dmpId'];
const dmpSectionId = params['dmpSectionId'];
const isPublicDescription = params['public'];
const newDmpId = params['newDmpId'];
// const publicId = params['publicId'];
// this.dmpId = params['dmpId'];
// this.dmpSectionIndex = parseInt(params['dmpSectionIndex']);
@ -237,6 +242,29 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
// this.loadDescriptionProfiles();
// this.registerFormListeners();
});
} else if (dmpId != null && dmpSectionId != null) {
const dialogRef = this.dialog.open(PrefillDescriptionDialogComponent, {
width: '590px',
minHeight: '200px',
restoreFocus: false,
data: {
dmp: this.item.dmp,
dmpSectionId: dmpSectionId
},
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();
}
})
}
// if (this.itemId != null && this.newDmpId == null) {

View File

@ -12,6 +12,7 @@ import { DescriptionFormProgressIndicationModule } from './form-progress-indicat
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';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component';
@NgModule({
imports: [
@ -28,12 +29,13 @@ import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module';
],
declarations: [
DescriptionEditorComponent,
DescriptionBaseFieldsEditorComponent
DescriptionBaseFieldsEditorComponent,
PrefillDescriptionDialogComponent
],
exports: [
],
providers: [
VisibilityRulesService
VisibilityRulesService,
]
})
export class DescriptionEditorModule { }

View File

@ -18,5 +18,4 @@ export class DescriptionFormFieldSetTitleComponent implements OnInit {
ngOnInit() {
}
}

View File

@ -1,6 +1,9 @@
<div *ngIf="fieldSet" class="dynamic-form-composite-field row">
<div *ngIf="showTitle" class="col-12">
<app-description-form-field-set-title class="row" [fieldSet]="fieldSet" [path]="path" [isChild]="isChild"></app-description-form-field-set-title>
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(fieldSet.id)">
<mat-icon matTooltip="{{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.ANNOTATIONS' | translate}}">comment</mat-icon>
</button>
</div>
<div *ngIf="!fieldSet?.multiplicity?.tableView" class="col-12">
<div class="row" *ngFor="let fieldSetItemPropertiesControl of propertiesFormGroup?.get('items')?.controls">

View File

@ -6,3 +6,9 @@
width: 110px;
display: flex;
}
.annotation-icon{
margin-top: 1.625rem;
width: auto;
height: auto;
}

View File

@ -10,6 +10,9 @@ import { DescriptionPropertyDefinitionEditorModel, DescriptionPropertyDefinition
import { FormFieldSetEditorDialogComponent } from './dialog-editor/form-fieldset-editor-dialog.component';
import { cloneAbstractControl } from '@app/utilities/enhancers/utils';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Guid } from '@common/types/guid';
import { AnnotationDialogComponent } from '@app/ui/annotations/annotation-dialog-component/annotation-dialog.component';
import { AnnotationEntityType } from '@app/core/common/enum/annotation-entity-type';
@Component({
selector: 'app-description-form-field-set',
@ -21,6 +24,7 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
@Input() fieldSet: DescriptionTemplateFieldSet;
@Input() propertiesFormGroup: UntypedFormGroup;
@Input() descriptionId: Guid;
get isMultiplicityEnabled() {
return this.fieldSet.multiplicity != null && this.fieldSet.multiplicity.min != 0 && this.fieldSet.multiplicity.max != 0;
@ -114,6 +118,27 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
});
}
//
//
// Annotations
//
//
showAnnotations(fieldSetId: string) {
const dialogRef = this.dialog.open(AnnotationDialogComponent, {
width: '528px',
data: {
entityId: this.descriptionId,
anchor: fieldSetId,
entityType: AnnotationEntityType.Description
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result && result.success) {
//TODO refactor
}
});
}
// deleteCompositeFieldFormGroup() {

View File

@ -2,6 +2,7 @@ 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 { AnnotationDialogModule } from '@app/ui/annotations/annotation-dialog-component/annotation-dialog.module';
import { ReferenceFieldModule } from '@app/ui/reference/reference-field/reference-field.module';
import { CommonFormsModule } from '@common/forms/common-forms.module';
import { CommonUiModule } from '@common/ui/common-ui.module';
@ -22,7 +23,8 @@ import { DescriptionFormComponent } from './description-form.component';
RichTextEditorModule,
NgxDropzoneModule,
FormattingModule,
ReferenceFieldModule
ReferenceFieldModule,
AnnotationDialogModule
],
declarations: [
DescriptionFormComponent,

View File

@ -1,7 +1,7 @@
<div class="template-container">
<div mat-dialog-title class="row d-flex m-0 header">
<span class="template-title align-self-center">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.TITLE' | translate}}</span>
<span class="ml-auto align-self-center" (click)="closeDialog()"><mat-icon
<div mat-dialog-title class="row d-flex p-0 m-0 header">
<span class="col template-title align-self-center">{{'PREFILL-DESCRIPTION-DIALOG.TITLE' | translate}}</span>
<span class="col-auto d-flex ml-auto align-self-center" (click)="closeDialog()"><mat-icon
class="close-icon">close</mat-icon></span>
</div>
<div *ngIf="progressIndication" class="progress-bar">
@ -10,48 +10,48 @@
<div mat-dialog-content *ngIf="prefillForm" [formGroup]="prefillForm" class="definition-content">
<div class="row d-flex align-items-center justify-content-center">
<div class="pb-4 pl-4 pr-4">
{{'DATASET-CREATE-WIZARD.PREFILL-STEP.HINT' | translate}}
{{'PREFILL-DESCRIPTION-DIALOG.HINT' | translate}}
</div>
</div>
<div class="row d-flex align-items-center justify-content-center" [class.pb-4]="isPrefilled">
<div class="row d-flex align-items-center justify-content-center" [class.pb-4]="prefillSelected">
<button mat-raised-button type="button" class="empty-btn"
(click)="closeDialog()">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.MANUALLY' | translate}}</button>
<div class="ml-2 mr-2">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.OR' | translate}}</div>
(click)="closeDialog()">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.MANUALLY' | translate}}</button>
<div class="ml-2 mr-2">{{'PREFILL-DESCRIPTION-DIALOG.OR' | translate}}</div>
<button mat-raised-button type="button" class="prefill-btn"
(click)="isPrefilled = true">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILL' | translate}}</button>
(click)="prefillSelected = true">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.PREFILL' | translate}}</button>
</div>
<div *ngIf="isPrefilled" class="row">
<div *ngIf="prefillSelected" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE' | translate}}</h4>
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
<div (click)="checkMinMax($event, profile)">
{{profile.label}}
<mat-select placeholder="{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="descriptionTempalte">
<mat-option *ngFor="let descriptionTempalte of availableDescriptionTempaltes" [value]="descriptionTempalte.id">
<div>
{{descriptionTempalte.label}}
</div>
</mat-option>
</mat-select>
<mat-error *ngIf="prefillForm.get('profile').hasError('backendError')">{{prefillForm.get('profile').getError('backendError').message}}</mat-error>
<mat-error *ngIf="prefillForm.get('descriptionTempalte').hasError('backendError')">{{prefillForm.get('descriptionTempalte').getError('backendError').message}}</mat-error>
</mat-form-field>
</div>
<div *ngIf="isPrefilled" class="row">
<!-- <div *ngIf="prefillSelected" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILLED-DATASET' | translate}}</h4>
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefill')"
placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.SEARCH' | translate}}"
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
[configuration]="prefillAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>
</div>
</div> -->
</div>
<div *ngIf="isPrefilled">
<div *ngIf="prefillSelected">
<div class="col-auto d-flex pb-4 pt-2">
<button mat-raised-button type="button" class="prefill-btn ml-auto" [disabled]="prefillForm.invalid"
(click)="next()">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.NEXT' | translate}}</button>
(click)="next()">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.NEXT' | translate}}</button>
</div>
</div>
</div>

View File

@ -9,7 +9,7 @@
}
.template-title {
margin-left: 37px;
margin-left: 1em;
white-space: nowrap;
width: 480px;
overflow: hidden;

View File

@ -1,42 +1,46 @@
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 { DescriptionTemplate } from "@app/core/model/description-template/description-template";
import { Dmp } from "@app/core/model/dmp/dmp";
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";
import { UUID } from "crypto";
import { takeUntil } from "rxjs/operators";
@Component({
selector: 'prefill-dataset-component',
templateUrl: 'prefill-dataset.component.html',
styleUrls: ['prefill-dataset.component.scss']
selector: 'prefill-description-component',
templateUrl: 'prefill-description.component.html',
styleUrls: ['prefill-description.component.scss']
})
export class PrefillDatasetComponent extends BaseComponent implements OnInit {
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit {
progressIndication = false;
prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
isPrefilled: boolean = false;
// prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
prefillSelected: boolean = false;
prefillForm: UntypedFormGroup;
constructor(public dialogRef: MatDialogRef<PrefillDatasetComponent>,
private prefillingService: PrefillingService,
private dmpBlueprintService: DmpBlueprintService,
private dialog: MatDialog,
private language: TranslateService,
dmp: Dmp;
dmpSectionId: Guid;
availableDescriptionTempaltes: DescriptionTemplate[] = [];
constructor(public dialogRef: MatDialogRef<PrefillDescriptionDialogComponent>,
// 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();
this.dmp = data.dmp;
this.dmpSectionId = data.dmpSectionId;
this.availableDescriptionTempaltes = this.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.dmpSectionId).map(x => x.currentDescriptionTemplate);
}
ngOnInit() {
@ -45,153 +49,153 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
});
this.prefillForm = this.fb.group({
type: this.fb.control(false),
profile: this.fb.control('', Validators.required),
descriptionTempalte: 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']
};
// if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
// this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
// }
// this.prefillAutoCompleteConfiguration = {
// filterFn: this.searchDescriptions.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);
}
});
}
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
// 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);
}
});
}
// checkMinMax(event, profile: DescriptionProfileModel) {
// 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<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
// private getBlueprintDefinitionFields() {
// return [
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
]
}
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
// ]
// }
public compareWith(object1: any, object2: any) {
return object1 && object2 && object1.id === object2.id;
}
searchDatasets(query: string): Observable<Prefilling[]> {
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;
}
})));
}
// searchDescriptions(query: string): Observable<Prefilling[]> {
// 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();
}
// if (this.isPrefilled) {
// if (this.prefillForm.get('prefill').value.data == null) {
// this.prefillingService.getPrefillingDescription(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.getPrefillingDescriptionUsingData(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 {

View File

@ -162,7 +162,7 @@
<button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">add_to_photos</mat-icon>
</button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-OVERVIEW.OVERVIEW.NEW-VERSION' | translate }}
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-OVERVIEW.ACTIONS.NEW-VERSION' | translate }}
</p>
</div>
<mat-menu #exportMenu="matMenu" xPosition="before">

View File

@ -0,0 +1,697 @@
import { FormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ExternalFetcherApiHTTPMethodType } from "@app/core/common/enum/external-fetcher-api-http-method-type";
import { ExternalFetcherSourceType } from "@app/core/common/enum/external-fetcher-source-type";
import { AuthenticationConfiguration, AuthenticationConfigurationPersist, ExternalFetcherBaseSourceConfiguration, ExternalFetcherBaseSourceConfigurationPersist, QueryCaseConfig, QueryCaseConfigPersist, QueryConfig, QueryConfigPersist, ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultsConfigurationPersist, StaticOption, StaticOptionPersist } from "@app/core/model/external-fetcher/external-fetcher";
import { Guid } from "@common/types/guid";
export class ExternalFetcherBaseSourceConfigurationEditorModel implements ExternalFetcherBaseSourceConfigurationPersist {
type: ExternalFetcherSourceType = ExternalFetcherSourceType.API;
key: string;
label: string;
ordinal: number;
url: string;
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel(this.validationErrorModel);
paginationPath: string;
contentType: string;
firstPage: string;
httpMethod: ExternalFetcherApiHTTPMethodType;
requestBody?: string;
filterType?: string;
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel(this.validationErrorModel);
queries?: QueryConfigEditorModel[] = [];
options: StaticOptionEditorModel[] = [];
referenceTypeDependencyIds: Guid[];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: ExternalFetcherBaseSourceConfiguration): ExternalFetcherBaseSourceConfigurationEditorModel {
if (item) {
this.type = item.type;
this.key = item.key;
this.label = item.label;
this.ordinal = item.ordinal;
if (item.url) this.url = item.url;
if (item.results) this.results = new ResultsConfigurationEditorModel(this.validationErrorModel).fromModel(item.results);
if (item.paginationPath) this.paginationPath = item.paginationPath;
if (item.contentType) this.contentType = item.contentType;
if (item.firstPage) this.firstPage = item.firstPage;
if (item.httpMethod != null) this.httpMethod = item.httpMethod;
if (item.requestBody) this.requestBody = item.requestBody;
if (item.filterType) this.filterType = item.filterType;
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
if (item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.options) {
item.options.map(x => this.options.push(new StaticOptionEditorModel(this.validationErrorModel).fromModel(x)));
} else {
this.options.push(new StaticOptionEditorModel().fromModel({ code: 'reference_id', value: undefined }));
this.options.push(new StaticOptionEditorModel().fromModel({ code: 'label', value: undefined }));
this.options.push(new StaticOptionEditorModel().fromModel({ code: 'description', value: undefined }));
}
if (item.referenceTypeDependencies) { this.referenceTypeDependencyIds = item.referenceTypeDependencies.map(x => x.id)}
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ExternalFetcherBaseSourceConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
results: this.results.buildForm({
rootPath: `${rootPath}results.`,
}),
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
firstPage: [{ value: this.firstPage, disabled: disabled }, context.getValidation('firstPage').validators],
httpMethod: [{ value: this.httpMethod, disabled: disabled }, context.getValidation('httpMethod').validators],
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
auth: this.auth.buildForm({
rootPath: `${rootPath}auth.`
}),
queries: this.formBuilder.array(
(this.queries ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}queries[${index}].`
})
), context.getValidation('queries').validators
),
options: this.formBuilder.array(
(this.options ?? []).map(
(item, index) => new StaticOptionEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
rootPath: `${rootPath}options[${index}].`
})
), context.getValidation('options').validators
),
referenceTypeDependencyIds: [{ value: this.referenceTypeDependencyIds, disabled: disabled }, context.getValidation('referenceTypeDependencyIds').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
baseValidationArray.push({ key: 'contentType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
baseValidationArray.push({ key: 'firstPage', validators: [Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
baseValidationArray.push({ key: 'httpMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}httpMethod`)] });
baseValidationArray.push({ key: 'requestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestBody`)] });
baseValidationArray.push({ key: 'filterType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}filterType`)] });
baseValidationArray.push({ key: 'results', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}results`)] });
baseValidationArray.push({ key: 'queries', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}queries`)] });
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
baseValidationArray.push({ key: 'referenceTypeDependencyIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeDependencyIds`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ExternalFetcherBaseSourceConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['type', 'key', 'label', 'ordinal', 'url', 'paginationPath', 'contentType', 'firstPage', 'httpMethod', 'requestBody','filterType', 'referenceTypeDependencyIds'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
AuthenticationConfigurationEditorModel.reapplyAuthValidators({
formGroup: formGroup?.get('auth') as UntypedFormGroup,
rootPath: `${rootPath}auth.`,
validationErrorModel: validationErrorModel
});
ResultsConfigurationEditorModel.reapplyValidators({
formGroup: formGroup?.get('results') as UntypedFormGroup,
rootPath: `${rootPath}results.`,
validationErrorModel: validationErrorModel
});
(formGroup.get('options') as FormArray).controls?.forEach(
(control, index) => StaticOptionEditorModel.reapplyStaticOptionsValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}options[${index}].`,
validationErrorModel: validationErrorModel
}
)
);
(formGroup.get('queries') as FormArray).controls?.forEach(
(control, index) => QueryConfigEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}queries[${index}].`,
validationErrorModel: validationErrorModel
})
);
}
}
export class ResultsConfigurationEditorModel implements ResultsConfigurationPersist {
public resultsArrayPath: string;
public fieldsMapping: ResultFieldsMappingConfigurationEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: ResultsConfiguration): ResultsConfigurationEditorModel {
this.resultsArrayPath = item.resultsArrayPath;
if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
else {
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'reference_id', responsePath: undefined }));
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'label', responsePath: undefined }));
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'description', responsePath: undefined }));
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ResultsConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
resultsArrayPath: [{ value: this.resultsArrayPath, disabled: disabled }, context.getValidation('resultsArrayPath').validators],
fieldsMapping: this.formBuilder.array(
(this.fieldsMapping ?? []).map(
(item, index) => new ResultFieldsMappingConfigurationEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
rootPath: `${rootPath}fieldsMapping[${index}].`
})
), context.getValidation('fieldsMapping').validators
)
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'resultsArrayPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
baseValidationArray.push({ key: 'fieldsMapping', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ResultsConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['resultsArrayPath'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
(formGroup.get('fieldsMapping') as FormArray).controls?.forEach(
(control, index) => ResultFieldsMappingConfigurationEditorModel.reapplyFieldsMappingValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}fieldsMapping[${index}].`,
validationErrorModel: validationErrorModel
}
)
);
}
}
export class ResultFieldsMappingConfigurationEditorModel implements ResultFieldsMappingConfigurationPersist {
public code: string;
public responsePath: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: ResultFieldsMappingConfiguration): ResultFieldsMappingConfigurationEditorModel {
this.code = item.code;
this.responsePath = item.responsePath;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
baseValidationArray.push({ key: 'responsePath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyFieldsMappingValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = ResultFieldsMappingConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['code', 'responsePath'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
}
}
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
public enabled: boolean = false;
public authUrl: string;
public authMethod: ExternalFetcherApiHTTPMethodType;
public authTokenPath: string;
public authRequestBody: string;
public type: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: AuthenticationConfiguration): AuthenticationConfigurationEditorModel {
this.enabled = item.enabled;
this.authUrl = item.authUrl;
this.authMethod = item.authMethod;
this.authTokenPath = item.authTokenPath;
this.authRequestBody = item.authRequestBody;
this.type = item.type;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = AuthenticationConfigurationEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
enabled: [{ value: this.enabled, disabled: disabled }, context.getValidation('enabled').validators],
authUrl: [{ value: this.authUrl, disabled: disabled }, context.getValidation('authUrl').validators],
authMethod: [{ value: this.authMethod, disabled: disabled }, context.getValidation('authMethod').validators],
authTokenPath: [{ value: this.authTokenPath, disabled: disabled }, context.getValidation('authTokenPath').validators],
authRequestBody: [{ value: this.authRequestBody, disabled: disabled }, context.getValidation('authRequestBody').validators],
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'enabled', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}enabled`)] });
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
baseValidationArray.push({ key: 'authRequestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyAuthValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = AuthenticationConfigurationEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['enabled', 'authUrl', 'authMethod', 'authTokenPath', 'authRequestBody', 'type'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
export class QueryConfigEditorModel implements QueryConfigPersist {
public name: string;
public defaultValue: string;
public cases: QueryCaseConfigEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: QueryConfig): QueryConfigEditorModel {
this.name = item.name;
this.defaultValue = item.defaultValue;
if (item.cases) { item.cases.map(x => this.cases.push(new QueryCaseConfigEditorModel(this.validationErrorModel).fromModel(x))); }
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = QueryConfigEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators],
defaultValue: [{ value: this.defaultValue, disabled: disabled }, context.getValidation('defaultValue').validators],
cases: this.formBuilder.array(
(this.cases ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}cases[${index}].`
})
), context.getValidation('cases').validators
)
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}name`)] });
baseValidationArray.push({ key: 'defaultValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultValue`)] });
baseValidationArray.push({ key: 'cases', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}cases`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = QueryConfigEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['name', 'defaultValue'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
(formGroup.get('cases') as FormArray).controls?.forEach(
(control, index) => QueryCaseConfigEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}cases[${index}].`,
validationErrorModel: validationErrorModel
}
)
);
}
}
export class QueryCaseConfigEditorModel implements QueryCaseConfigPersist {
public likePattern: string;
public separator: string;
public value: string;
public referenceTypeId: Guid;
public referenceTypeSourceKey: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: QueryCaseConfig): QueryCaseConfigEditorModel {
this.likePattern = item.likePattern;
this.separator = item.separator;
this.value = item.value;
if(item?.referenceType?.id) this.referenceTypeId = item.referenceType.id;
this.referenceTypeSourceKey = item.referenceTypeSourceKey;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = QueryCaseConfigEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
likePattern: [{ value: this.likePattern, disabled: disabled }, context.getValidation('likePattern').validators],
separator: [{ value: this.separator, disabled: disabled }, context.getValidation('separator').validators],
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
referenceTypeSourceKey: [{ value: this.referenceTypeSourceKey, disabled: disabled }, context.getValidation('referenceTypeSourceKey').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'likePattern', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}likePattern`)] });
baseValidationArray.push({ key: 'separator', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}separator`)] });
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
baseValidationArray.push({ key: 'referenceTypeSourceKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeSourceKey`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = QueryCaseConfigEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['likePattern', 'separator', 'value', 'referenceTypeId', 'referenceTypeSourceKey'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
export class StaticOptionEditorModel implements StaticOptionPersist {
public code: string;
public value: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: StaticOption): StaticOptionEditorModel {
this.code = item.code;
this.value = item.value;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = StaticOptionEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
baseValidationArray.push({ key: 'value', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyStaticOptionsValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = StaticOptionEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['code', 'value'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
});
}
}

View File

@ -0,0 +1,358 @@
<div class="col-12">
<div class="row" >
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput type="text" name="key" [formControl]="formGroup.get('key')" required>
<mat-error *ngIf="formGroup.get('key').hasError('backendError')">{{formGroup.get('key').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('key').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
<input matInput type="text" name="label" [formControl]="formGroup.get('label')" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
<input matInput type="number" name="ordinal" [formControl]="formGroup.get('ordinal')" required>
<mat-error *ngIf="formGroup.get('ordinal').hasError('backendError')">{{formGroup.get('ordinal').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('ordinal').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="referenceTypeSourceIndex != null">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCIES' | translate}}</mat-label>
<mat-select multiple (selectionChange)="setReferenceTypeDependenciesMap($event.value, referenceTypeSourceIndex)" [formControl]="formGroup.get('referenceTypeDependencyIds')">
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.id">{{referenceType.name}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('referenceTypeDependencyIds').hasError('backendError')">{{formGroup.get('referenceTypeDependencyIds').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="referenceTypeSourceIndex != null">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-TYPE' | translate}}</mat-label>
<mat-select name="type" [formControl]="formGroup.get('type')" required>
<mat-option *ngFor="let sourceType of externalFetcherSourceTypeEnum" [value]="sourceType">
{{enumUtils.toExternalFetcherSourceTypeString(sourceType)}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('type').hasError('backendError')">{{formGroup.get('type').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row" *ngIf="formGroup.get('type').value == externalFetcherSourceType.API">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
<input matInput type="text" name="ordinal" [formControl]="formGroup.get('url')">
<mat-error *ngIf="formGroup.get('url').hasError('backendError')">{{formGroup.get('url').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.PAGINATION-PATH' | translate}}</mat-label>
<input matInput type="text" name="paginationPath" [formControl]="formGroup.get('paginationPath')">
<mat-error *ngIf="formGroup.get('paginationPath').hasError('backendError')">{{formGroup.get('paginationPath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('paginationPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CONTENT-TYPE' | translate}}</mat-label>
<input matInput type="text" name="contentType" [formControl]="formGroup.get('contentType')">
<mat-error *ngIf="formGroup.get('contentType').hasError('backendError')">{{formGroup.get('contentType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('contentType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.FIRST-PAGE' | translate}}</mat-label>
<input matInput type="text" name="firstPage" [formControl]="formGroup.get('firstPage')">
<mat-error *ngIf="formGroup.get('firstPage').hasError('backendError')">{{formGroup.get('firstPage').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('firstPage').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
<mat-select name="httpMethod" [formControl]="formGroup.get('httpMethod')">
<mat-option *ngFor="let httpMethod of externalFetcherApiHTTPMethodTypeEnum" [value]="httpMethod">
{{enumUtils.toExternalFetcherApiHTTPMethodTypeString(httpMethod)}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('httpMethod').hasError('backendError')">{{formGroup.get('httpMethod').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('httpMethod').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="formGroup.get('httpMethod').value == externalFetcherApiHTTPMethodType.POST" >
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
<input matInput type="text" name="requestBody" [formControl]="formGroup.get('requestBody')">
<mat-error *ngIf="formGroup.get('requestBody').hasError('backendError')">{{formGroup.get('requestBody').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('requestBody').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.FILTER-TYPE' | translate}}</mat-label>
<input matInput type="text" name="filterType" [formControl]="formGroup.get('filterType')">
<mat-error *ngIf="formGroup.get('filterType').hasError('backendError')">{{formGroup.get('filterType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('filterType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- Results info -->
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS' | translate}}</h3>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS-PATH' | translate}}</mat-label>
<input matInput type="text" name="resultsArrayPath" [formControl]="formGroup.get('results').get('resultsArrayPath')">
<mat-error *ngIf="formGroup.get('results').get('resultsArrayPath').hasError('backendError')">{{formGroup.get('results').get('resultsArrayPath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('results').get('resultsArrayPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- fields mapping -->
<div class="col-12">
<div *ngFor="let field of formGroup.get('results').get('fieldsMapping').controls; let fieldMappingIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD-MAPPING' | translate}} {{fieldMappingIndex + 1}}</h4>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" [readonly]="field.get('code').disabled" name="code" [formControl]="field.get('code')" [readOnly]="true">
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
<mat-error *ngIf="field.get('responsePath').hasError('backendError')">{{field.get('responsePath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('responsePath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
</div>
</div>
<!-- Auth info -->
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}
<mat-checkbox [formControl]="formGroup.get('auth').get('enabled')"></mat-checkbox>
</h3>
<div class="row" *ngIf="formGroup.get('auth').get('enabled').value == true">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
<input matInput type="text" name="authUrl" [formControl]="formGroup.get('auth').get('authUrl')">
<mat-error *ngIf="formGroup.get('auth').get('authUrl').hasError('backendError')">{{formGroup.get('auth').get('authUrl').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('auth').get('authUrl').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
<mat-select name="httpMethod" [formControl]="formGroup.get('auth').get('authMethod')">
<mat-option *ngFor="let httpMethod of externalFetcherApiHTTPMethodTypeEnum" [value]="httpMethod">
{{enumUtils.toExternalFetcherApiHTTPMethodTypeString(httpMethod)}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('auth').get('authMethod').hasError('backendError')">{{formGroup.get('auth').get('authMethod').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('auth').get('authMethod').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TOKEN-PATH' | translate}}</mat-label>
<input matInput type="text" name="authTokenPath" [formControl]="formGroup.get('auth').get('authTokenPath')">
<mat-error *ngIf="formGroup.get('auth').get('authTokenPath').hasError('backendError')">{{formGroup.get('auth').get('authTokenPath').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('auth').get('authTokenPath').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
<input matInput type="text" name="authRequestBody" [formControl]="formGroup.get('auth').get('authRequestBody')">
<mat-error *ngIf="formGroup.get('auth').get('authRequestBody').hasError('backendError')">{{formGroup.get('auth').get('authRequestBody').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('auth').get('authRequestBody').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TYPE' | translate}}</mat-label>
<input matInput type="text" name="type" [formControl]="formGroup.get('auth').get('type')">
<mat-error *ngIf="formGroup.get('auth').get('type').hasError('backendError')">{{formGroup.get('auth').get('type').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('auth').get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
<!-- Queries info -->
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
<button mat-button type="button" class="action-btn" (click)="addQuery()" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
</h3>
<div class="col-12">
<div *ngFor="let query of formGroup.get('queries').controls; let queryIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERY' | translate}} {{queryIndex + 1}}</h4>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-QUERY' | translate}}" (click)="removeQuery(queryIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
<div class="col-auto">
<button mat-button class="action-btn" type="button" (click)="addCase(queryIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-CASE' | translate}}</button>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.NAME' | translate}}</mat-label>
<input matInput type="text" name="name" [formControl]="query.get('name')" required>
<mat-error *ngIf="query.get('name').hasError('backendError')">{{query.get('name').getError('backendError').message}}</mat-error>
<mat-error *ngIf="query.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEFAULT-VALUE' | translate}}</mat-label>
<input matInput type="text" name="defaultValue" [formControl]="query.get('defaultValue')">
<mat-error *ngIf="query.get('defaultValue').hasError('backendError')">{{query.get('defaultValue').getError('backendError').message}}</mat-error>
<mat-error *ngIf="query.get('defaultValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
<!-- Query Cases -->
<div *ngFor="let case of query.get('cases').controls; let caseIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.CASE' | translate}} {{caseIndex + 1}}</h4>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-CASE' | translate}}" (click)="removeCase(queryIndex, caseIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LIKE-PATTERN' | translate}}</mat-label>
<input matInput type="text" name="likePattern" [formControl]="case.get('likePattern')">
<mat-error *ngIf="case.get('likePattern').hasError('backendError')">{{case.get('likePattern').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('likePattern').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SEPARATOR' | translate}}</mat-label>
<input matInput type="text" name="separator" [formControl]="case.get('separator')">
<mat-error *ngIf="case.get('separator').hasError('backendError')">{{case.get('separator').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('separator').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput type="text" name="value" [formControl]="case.get('value')">
<mat-error *ngIf="case.get('value').hasError('backendError')">{{case.get('value').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="formGroup.get('referenceTypeDependencyIds').value">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCY' | translate}}</mat-label>
<mat-select name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
<mat-option *ngFor="let referenceType of referenceTypeDependenciesMap.get(referenceTypeSourceIndex)" [value]="referenceType.id">
{{referenceType.code}}
</mat-option>
</mat-select>
<mat-error *ngIf="case.get('referenceTypeId').hasError('backendError')">{{case.get('referenceTypeId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6" *ngIf="case.get('referenceTypeId').value">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-KEY' | translate}}</mat-label>
<mat-select name = 'referenceTypeSourceKey' [formControl]="case.get('referenceTypeSourceKey')">
<mat-option *ngFor="let sourceKey of sourceKeysMap.get(case.get('referenceTypeId').value)" [value]="sourceKey">
{{sourceKey}}
</mat-option>
</mat-select>
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('backendError')">{{case.get('referenceTypeSourceKey').getError('backendError').message}}</mat-error>
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
</div>
</div>
</div>
</div>
<!-- Options -->
<div class="row" *ngIf="formGroup.get('type').value == externalFetcherSourceType.STATIC">
<div class="col-12">
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTIONS' | translate}}</h3>
<div *ngFor="let option of formGroup.get('options').controls; let optionsIndex=index;" class="row mb-3">
<div class="col-12">
<mat-card-header>
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTION' | translate}} {{optionsIndex + 1}}</h4>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" [readonly]="option.get('code').disabled" name="code" [formControl]="option.get('code')">
<mat-error *ngIf="option.get('code').hasError('backendError')">{{option.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="option.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput type="text" name="value" [formControl]="option.get('value')">
<mat-error *ngIf="option.get('value').hasError('backendError')">{{option.get('value').getError('backendError').message}}</mat-error>
<mat-error *ngIf="option.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card-content>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,118 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormArray, UntypedFormGroup } from '@angular/forms';
import { ExternalFetcherApiHTTPMethodType } from '@app/core/common/enum/external-fetcher-api-http-method-type';
import { ExternalFetcherSourceType } from '@app/core/common/enum/external-fetcher-source-type';
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel, StaticOptionEditorModel } from './external-fetcher-source-editor.model';
import { Guid } from '@common/types/guid';
@Component({
selector: 'app-external-fetcher-source-component',
templateUrl: 'external-fetcher-source.component.html',
styleUrls: ['./external-fetcher-source.component.scss']
})
export class ExternalFetcherSourceComponent extends BaseComponent implements OnInit {
@Input() formGroup: UntypedFormGroup = null;
@Input() validationErrorModel: ValidationErrorModel = null;
@Input() validationRootPath: string = null;
@Input() referenceTypeSourceIndex: number = null;
@Input() referenceTypes: ReferenceType[] = null;
@Input() sourceKeysMap: Map<Guid, string[]> = new Map<Guid, string[]>();
externalFetcherSourceType = ExternalFetcherSourceType;
externalFetcherApiHTTPMethodType = ExternalFetcherApiHTTPMethodType;
externalFetcherSourceTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherSourceType>(ExternalFetcherSourceType);
externalFetcherApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ExternalFetcherApiHTTPMethodType>(ExternalFetcherApiHTTPMethodType);
referenceTypeDependenciesMap: Map<number, ReferenceType[]> = new Map<number, ReferenceType[]>();
constructor(
public enumUtils: EnumUtils,
) { super(); }
ngOnInit() {
}
private reApplyValidators(){
ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.validationErrorModel,
rootPath: this.validationRootPath
}
)
}
//
//
// queries
//
//
addQuery(): void {
const formArray= this.formGroup.get('queries') as FormArray;
const query: QueryConfigEditorModel = new QueryConfigEditorModel(this.validationErrorModel);
formArray.push(query.buildForm({rootPath: this.validationRootPath + 'queries[' + formArray.length + '].'}));
}
removeQuery(queryIndex: number): void {
const formArray = (this.formGroup.get('queries') as FormArray);
formArray.removeAt(queryIndex);
this.reApplyValidators();
formArray.markAsDirty();
}
// cases
addCase(queryIndex: number): void {
const formArray = (this.formGroup.get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
const queryCase: QueryCaseConfigEditorModel = new QueryCaseConfigEditorModel(this.validationErrorModel);
formArray.push(queryCase.buildForm({rootPath: this.validationRootPath + 'queries[' + queryIndex + '].cases[' + formArray.length + '].'}));
}
removeCase(queryIndex: number, index: number): void {
const formArray = (this.formGroup.get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
formArray.removeAt(index);
this.reApplyValidators();
formArray.markAsDirty();
}
// Options
addOption(code: string): void {
const optionsSize = (this.formGroup.get('options') as FormArray).length;
if (optionsSize > 0) {
for (let i = 0; i < optionsSize; i++) {
if ((this.formGroup.get('options') as FormArray).at(i).get('code').getRawValue() == code) {
return;
}
}
}
const option = new StaticOptionEditorModel(this.validationErrorModel);
(this.formGroup.get('options') as FormArray).push(option.buildForm());
(this.formGroup.get('options') as FormArray).at(optionsSize).get('code').patchValue(code);
}
removeOption(optionIndex: number): void {
const formArray = (this.formGroup.get('options') as FormArray);
formArray.removeAt(optionIndex);
this.reApplyValidators();
formArray.markAsDirty();
}
setReferenceTypeDependenciesMap(ids: Guid[], index: number){
let mapValues :ReferenceType[] = [];
this.referenceTypes.forEach(x => {
if(ids.includes(x.id)){
mapValues.push(x);
}
})
this.referenceTypeDependenciesMap.set(index, mapValues);
}
}

Some files were not shown because too many files have changed in this diff Show More