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

# Conflicts:
#	dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/datasetProfileXml/ExportXmlBuilderDatasetProfile.java
This commit is contained in:
Efstratios Giannopoulos 2024-02-08 11:07:37 +02:00
commit 9d4e814d1c
23 changed files with 215 additions and 188 deletions

View File

@ -7,16 +7,16 @@ import java.util.Map;
public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> { public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> {
Text((short)0), Text((short)0), //TODO: Rename to "Title"
HtmlText((short)1), HtmlText((short)1), //TODO: Rename to "Description"
Researchers((short)2), Researchers((short)2), //TODO: replace by reference type
Organizations((short)3), Organizations((short)3), //TODO: replace by reference type
Language((short)4), Language((short)4),
Contact((short)5), Contact((short)5),
Funder((short)6), Funder((short)6), //TODO: replace by reference type
Grant((short)7), Grant((short)7), //TODO: replace by reference type
Project((short)8), Project((short)8), //TODO: replace by reference type
License((short)9), License((short)9), //TODO: replace by reference type
AccessRights((short)10); AccessRights((short)10);
private final Short value; private final Short value;

View File

@ -6,31 +6,31 @@ import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum FieldType implements DatabaseEnum<String> { public enum FieldType implements DatabaseEnum<String> {
EXTERNAL_SELECT(Names.ExternalSelect), EXTERNAL_SELECT(Names.ExternalSelect), //TODO: remove
SELECT(Names.Select), SELECT(Names.Select),
BOOLEAN_DECISION(Names.BooleanDecision), BOOLEAN_DECISION(Names.BooleanDecision),
RADIO_BOX(Names.RadioBox), RADIO_BOX(Names.RadioBox),
INTERNAL_DMP_ENTRIES_RESEARCHERS(Names.InternalDmpResearchers), INTERNAL_DMP_ENTRIES_RESEARCHERS(Names.InternalDmpResearchers), //TODO: remove
INTERNAL_DMP_ENTRIES_DMPS(Names.InternalDmpDmps), INTERNAL_DMP_ENTRIES_DMPS(Names.InternalDmpDmps), //TODO: rename InternalEntitiesDmps
INTERNAL_ENTRIES_DESCRIPTIONS(Names.InternalDmpDescriptions), INTERNAL_DMP_ENTRIES_DATASETS(Names.InternalDmpDescriptions),
CHECK_BOX(Names.CheckBox), CHECK_BOX(Names.CheckBox),
FREE_TEXT(Names.FreeText), FREE_TEXT(Names.FreeText),
TEXT_AREA(Names.TextArea), TEXT_AREA(Names.TextArea),
RICH_TEXT_AREA(Names.RichTextarea), RICH_TEXT_AREA(Names.RichTextarea),
UPLOAD(Names.Upload), UPLOAD(Names.Upload),
DATE_PICKER(Names.DatePicker), DATE_PICKER(Names.DatePicker),
EXTERNAL_DATASETS(Names.ExternalDatasets), EXTERNAL_DATASETS(Names.ExternalDatasets), //TODO: replace with reference type
DATA_REPOSITORIES(Names.DataRepositories), DATA_REPOSITORIES(Names.DataRepositories), //TODO: replace with reference type
JOURNAL_REPOSITORIES(Names.JournalRepositories), JOURNAL_REPOSITORIES(Names.JournalRepositories), //TODO: replace with reference type
PUB_REPOSITORIES(Names.PubRepositories), PUB_REPOSITORIES(Names.PubRepositories), //TODO: replace with reference type
LICENSES(Names.Licenses), LICENSES(Names.Licenses), //TODO: replace with reference type
TAXONOMIES(Names.Taxonomies), TAXONOMIES(Names.Taxonomies), //TODO: replace with reference type
PUBLICATIONS(Names.Publications), PUBLICATIONS(Names.Publications), //TODO: replace with reference type
REGISTRIES(Names.Registries), REGISTRIES(Names.Registries), //TODO: replace with reference type
SERVICES(Names.Services), SERVICES(Names.Services), //TODO: replace with reference type
TAGS(Names.Tags), TAGS(Names.Tags),
RESEARCHERS(Names.Researchers), RESEARCHERS(Names.Researchers), //TODO: replace with reference type
ORGANIZATIONS(Names.Organizations), ORGANIZATIONS(Names.Organizations), //TODO: replace with reference type
DATASET_IDENTIFIER(Names.DatasetIdentifier), DATASET_IDENTIFIER(Names.DatasetIdentifier),
CURRENCY(Names.Currency), CURRENCY(Names.Currency),
VALIDATION(Names.Validation); VALIDATION(Names.Validation);
@ -43,7 +43,7 @@ public enum FieldType implements DatabaseEnum<String> {
public static final String RadioBox = "radiobox"; public static final String RadioBox = "radiobox";
public static final String InternalDmpResearchers = "internalDmpResearchers"; public static final String InternalDmpResearchers = "internalDmpResearchers";
public static final String InternalDmpDmps = "internalDmpDmps"; public static final String InternalDmpDmps = "internalDmpDmps";
public static final String InternalDmpDescriptions = "internalDmpDescriptions"; public static final String InternalDmpDescriptions = "internalDmpDatasets";
public static final String CheckBox = "checkBox"; public static final String CheckBox = "checkBox";
public static final String FreeText = "freetext"; public static final String FreeText = "freetext";
public static final String TextArea = "textarea"; public static final String TextArea = "textarea";
@ -101,7 +101,7 @@ public enum FieldType implements DatabaseEnum<String> {
public static boolean isTextListType(FieldType fieldType){ public static boolean isTextListType(FieldType fieldType){
return fieldType.equals(FieldType.SELECT) || fieldType.equals(FieldType.TAGS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) || return fieldType.equals(FieldType.SELECT) || fieldType.equals(FieldType.TAGS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) ||
fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS); fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
} }
public static boolean isDateType(FieldType fieldType){ public static boolean isDateType(FieldType fieldType){

View File

@ -86,7 +86,7 @@ public class DescriptionFieldDepositBuilder extends BaseDepositBuilder<Descripti
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX); case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
case INTERNAL_DMP_ENTRIES_RESEARCHERS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS); case INTERNAL_DMP_ENTRIES_RESEARCHERS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS);
case INTERNAL_DMP_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS); case INTERNAL_DMP_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS);
case INTERNAL_ENTRIES_DESCRIPTIONS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS); case INTERNAL_DMP_ENTRIES_DATASETS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX); case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT); case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA); case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);

View File

@ -173,49 +173,49 @@ public class DescriptionPersist {
DescriptionTemplateEntity descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId()) : null; DescriptionTemplateEntity descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId()) : null;
DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, descriptionTemplate.getDefinition()); DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, descriptionTemplate.getDefinition());
return Arrays.asList( return Arrays.asList(
this.spec() // this.spec()
.iff(() -> this.isValidGuid(item.getId())) // .iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash())) // .must(() -> this.isValidHash(item.getHash()))
.failOn(DescriptionPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._hash}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._hash}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.iff(() -> !this.isValidGuid(item.getId())) // .iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash())) // .must(() -> !this.isValidHash(item.getHash()))
.failOn(DescriptionPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.must(() -> !this.isEmpty(item.getLabel())) // .must(() -> !this.isEmpty(item.getLabel()))
.failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.iff(() -> !this.isEmpty(item.getLabel())) // .iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqualLength(item.getLabel(), DescriptionEntity._labelLength)) // .must(() -> this.lessEqualLength(item.getLabel(), DescriptionEntity._labelLength))
.failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.must(() -> this.isValidGuid(item.getDmpId())) // .must(() -> this.isValidGuid(item.getDmpId()))
.failOn(DescriptionPersist._dmpId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpId}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._dmpId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpId}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) // .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> this.isValidGuid(item.getDescriptionTemplateId())) // .must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) // .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> this.isValidGuid(item.getDmpDescriptionTemplateId())) // .must(() -> this.isValidGuid(item.getDmpDescriptionTemplateId()))
.failOn(DescriptionPersist._dmpDescriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpDescriptionTemplateId}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._dmpDescriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._dmpDescriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.must(() -> !this.isNull(item.getStatus())) // .must(() -> !this.isNull(item.getStatus()))
.failOn(DescriptionPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())),
this.spec() // this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) // .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> !this.isListNullOrEmpty(item.getTags())) // .must(() -> !this.isListNullOrEmpty(item.getTags()))
.failOn(DescriptionPersist._tags).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._tags}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._tags).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._tags}, LocaleContextHolder.getLocale())),
//
this.spec() // this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) // .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getProperties())) // .must(() -> !this.isNull(item.getProperties()))
.failOn(DescriptionPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())), // .failOn(DescriptionPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())),
this.refSpec() // this.refSpec()
.iff(() -> !this.isNull(item.getProperties())) // .iff(() -> !this.isNull(item.getProperties()))
.on(DescriptionPersist._properties) // .on(DescriptionPersist._properties)
.over(item.getProperties()) // .over(item.getProperties())
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition)) // .using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition))
); );
} }
} }

View File

@ -130,7 +130,7 @@ public class FieldPersist {
.must(() -> this.isUUID(item.getTextValue())) .must(() -> this.isUUID(item.getTextValue()))
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())), .failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.iff(()-> !this.isNull(item.getTextListValue()) && (fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS))) .iff(()-> !this.isNull(item.getTextListValue()) && (fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DATASETS)))
.must(() -> item.getTextListValue().stream().allMatch(this::isUUID)) .must(() -> item.getTextListValue().stream().allMatch(this::isUUID))
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())), .failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()

View File

@ -154,7 +154,11 @@ public class FieldPersist {
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() != null) .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() != null)
.on(FieldPersist._data) .on(FieldPersist._data)
.over(item.getData()) .over(item.getData())
.using(() -> this.fieldDataHelperServiceProvider.get(item.getData().getFieldType()).getPersistModelValidator()) .using(() -> this.fieldDataHelperServiceProvider.get(item.getData().getFieldType()).getPersistModelValidator()),
this.spec()
.iff(() -> !this.isNull(item.getData()))
.must(() -> !this.isNull(item.getData().getFieldType()))
.failOn(FieldPersist._data + '.' + BaseFieldDataPersist._fieldType).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._fieldType}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -18,7 +18,8 @@ import java.util.List;
use = JsonTypeInfo.Id.NAME, use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY, include = JsonTypeInfo.As.PROPERTY,
property = "fieldType", property = "fieldType",
visible = true) visible = true,
defaultImpl = LabelDataPersist.class)
@JsonSubTypes({ @JsonSubTypes({
@JsonSubTypes.Type(value = ExternalSelectDataPersist.class, name = FieldType.Names.ExternalSelect), @JsonSubTypes.Type(value = ExternalSelectDataPersist.class, name = FieldType.Names.ExternalSelect),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.BooleanDecision), @JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.BooleanDecision),

View File

@ -155,12 +155,13 @@ public class DescriptionServiceImpl implements DescriptionService {
data.setId(UUID.randomUUID()); data.setId(UUID.randomUUID());
data.setIsActive(IsActive.Active); data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now()); data.setCreatedAt(Instant.now());
data.setCreatedById(this.userScope.getUserId());
data.setDmpId(model.getDmpId()); data.setDmpId(model.getDmpId());
data.setDmpDescriptionTemplateId(model.getDmpDescriptionTemplateId()); data.setDmpDescriptionTemplateId(model.getDmpDescriptionTemplateId());
} }
DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDescriptionTemplateId()); DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDmpDescriptionTemplateId());
if (dmpDescriptionTemplate == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (dmpDescriptionTemplate == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId()); DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -385,6 +386,8 @@ public class DescriptionServiceImpl implements DescriptionService {
PropertyDefinitionFieldSetItemEntity data = new PropertyDefinitionFieldSetItemEntity(); PropertyDefinitionFieldSetItemEntity data = new PropertyDefinitionFieldSetItemEntity();
if (persist == null) return data; if (persist == null) return data;
if (persist.getFields() != null && !persist.getFields().isEmpty()){ if (persist.getFields() != null && !persist.getFields().isEmpty()){
data.setOrdinal(persist.getOrdinal());
data.setComment(persist.getComment());
data.setFields(new HashMap<>()); data.setFields(new HashMap<>());
for (String key: persist.getFields().keySet()) { for (String key: persist.getFields().keySet()) {
eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getAllField().stream().findFirst().orElse(null) : null; eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getAllField().stream().findFirst().orElse(null) : null;
@ -400,7 +403,7 @@ public class DescriptionServiceImpl implements DescriptionService {
if (persist == null) return data; if (persist == null) return data;
if (FieldType.isTextType(fieldType)) { if (FieldType.isTextType(fieldType)) {
if (FieldType.UPLOAD.equals(fieldType)){ if (FieldType.UPLOAD.equals(fieldType) && !this.conventionService.isNullOrEmpty(persist.getTextValue())){
StorageFile storageFile = this.storageFileService.copyToStorage(UUID.fromString(persist.getTextValue()), StorageType.Main, true, new BaseFieldSet().ensure(StorageFile._id)); StorageFile storageFile = this.storageFileService.copyToStorage(UUID.fromString(persist.getTextValue()), StorageType.Main, true, new BaseFieldSet().ensure(StorageFile._id));
this.storageFileService.updatePurgeAt(storageFile.getId(), null); this.storageFileService.updatePurgeAt(storageFile.getId(), null);
data.setTextValue(storageFile.getId().toString()); data.setTextValue(storageFile.getId().toString());
@ -415,7 +418,7 @@ public class DescriptionServiceImpl implements DescriptionService {
for (UUID id : ids){ for (UUID id : ids){
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
} }
} if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){ } if (FieldType.INTERNAL_DMP_ENTRIES_DATASETS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList(); List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet()); Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet());
for (UUID id : ids){ for (UUID id : ids){

View File

@ -24,7 +24,7 @@ public class FieldDataHelperServiceProvider {
case REGISTRIES: case REGISTRIES:
case SERVICES: case SERVICES:
case RESEARCHERS: case RESEARCHERS:
case INTERNAL_ENTRIES_DESCRIPTIONS: case INTERNAL_DMP_ENTRIES_DATASETS:
case INTERNAL_DMP_ENTRIES_DMPS: case INTERNAL_DMP_ENTRIES_DMPS:
case INTERNAL_DMP_ENTRIES_RESEARCHERS: case INTERNAL_DMP_ENTRIES_RESEARCHERS:
case ORGANIZATIONS: { case ORGANIZATIONS: {

View File

@ -1,15 +1,17 @@
<div class="row" *ngIf="form.get('data')"> <div class="row" *ngIf="form.get('data')">
<div class="col-12"> <div class="col-12">
<h5 style="font-weight: bold; display: inline-block; margin-right: 2em;">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE' <h5 style="font-weight: bold; display: inline-block; margin-right: 2em;">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE'
| translate}}</h5> | translate}}</h5>
<ng-container *ngIf="form.get('data').errors?.emptyArray && form.get('data').touched"> <ng-container *ngIf="form.get('data').errors?.emptyArray && form.get('data').touched">
<mat-icon class="text-danger translateY-3">warning_amber</mat-icon> <mat-icon class="text-danger translateY-3">warning_amber</mat-icon>
<small class="text-danger">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}}</small> <small class="text-danger">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}}</small>
</ng-container> </ng-container>
<mat-error *ngIf="form.get('data').get('options').dirty && form.get('data').get('options').hasError('required')">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('data').get('options').hasError('backendError')">{{form.get('data').get('options').getError('backendError').message}}</mat-error>
</div> </div>
<!-- <mat-form-field class="col-12"> <!-- <mat-form-field class="col-12">
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-PLACEHOLDER' | translate}}</mat-label> <mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-PLACEHOLDER' | translate}}</mat-label>
<input matInput type="string" <input matInput type="string"
[formControl]="form.get('data').get('label')"> [formControl]="form.get('data').get('label')">
</mat-form-field> --> </mat-form-field> -->
@ -17,14 +19,16 @@
<div class="col-12"> <div class="col-12">
<div *ngFor="let option of form.get('data').get('options')['controls'] index as i" class="row"> <div *ngFor="let option of form.get('data').get('options')['controls'] index as i" class="row">
<mat-form-field class="col"> <mat-form-field class="col">
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}}</mat-label> <mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}}</mat-label>
<input matInput type="string" [formControl]="option.get('label')"> <input matInput type="string" [formControl]="option.get('label')" required="true">
<mat-error *ngIf="option.get('label').hasError('backendError')">{{option.get('label').getError('backendError').message}}</mat-error> <mat-error *ngIf="option.get('label').hasError('backendError')">{{option.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="option.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field class="col"> <mat-form-field class="col">
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}}</mat-label> <mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}}</mat-label>
<input matInput type="string" [formControl]="option.get('value')"> <input matInput type="string" [formControl]="option.get('value')" required="true">
<mat-error *ngIf="option.get('value').hasError('backendError')">{{option.get('value').getError('backendError').message}}</mat-error> <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> </mat-form-field>
<button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button" <button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button"
[disabled]="this.form.disabled"> [disabled]="this.form.disabled">

View File

@ -9,7 +9,7 @@
</ng-container> </ng-container>
</div> </div>
<mat-checkbox class="col-auto" [formControl]="this.form.get('data').get('multipleSelect')"> <mat-checkbox class="col-auto" [formControl]="this.form.get('data').get('multipleSelect')">
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-SELECT' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-WORDLIST' | translate}}
<mat-error *ngIf="form.get('data').get('multipleSelect').hasError('backendError')">{{form.get('data').get('multipleSelect').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('data').get('multipleSelect').hasError('backendError')">{{form.get('data').get('multipleSelect').getError('backendError').message}}</mat-error>
</mat-checkbox> </mat-checkbox>
@ -36,6 +36,8 @@
</button> </button>
</div> </div>
</div> </div>
<mat-error *ngIf="form.get('data').get('options').dirty && form.get('data').get('options').hasError('required')">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('data').get('options').hasError('backendError')">{{form.get('data').get('options').getError('backendError').message}}</mat-error>
<div class="col-auto"><button mat-icon-button (click)="addNewRow()"> <div class="col-auto"><button mat-icon-button (click)="addNewRow()">
<mat-icon>add</mat-icon> <mat-icon>add</mat-icon>
</button></div> </button></div>

View File

@ -65,7 +65,7 @@
[hasFocus]="fieldset.get('id').value === selectedFieldSetId" [hasFocus]="fieldset.get('id').value === selectedFieldSetId"
[datasetProfileId]="datasetProfileId" [datasetProfileId]="datasetProfileId"
[validationErrorModel]="validationErrorModel" [validationErrorModel]="validationErrorModel"
[rootPath]="rootPath"> [rootPath]="rootPath + 'fieldSets[' + i + '].'">
</app-description-template-editor-composite-field-component> </app-description-template-editor-composite-field-component>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>

View File

@ -616,6 +616,10 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
section.ordinal = sectionsArray.length; section.ordinal = sectionsArray.length;
} }
//store rootPath for next levels/components
this.rootPath = 'definition.pages['+ pageIndex +'].sections[' + sectionsArray.length + '].';
sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].sections[' + sectionsArray.length + '].' })); sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].sections[' + sectionsArray.length + '].' }));
// this.form.updateValueAndValidity(); // this.form.updateValueAndValidity();
@ -634,7 +638,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
sectionIndexes.forEach(index => { sectionIndexes.forEach(index => {
parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].' parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].'
}); });
}
sectionsArray = parent.form.get('sections') as UntypedFormArray; sectionsArray = parent.form.get('sections') as UntypedFormArray;
@ -646,9 +649,13 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
section.ordinal = sectionsArray.length; section.ordinal = sectionsArray.length;
} }
//store rootPath for next levels/components
this.rootPath = 'definition.pages['+ pageIndex +'].'+ parentSectionRootPath;
sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' })); sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' }));
// (child.form.parent as FormArray).push(section.buildForm()); // (child.form.parent as FormArray).push(section.buildForm());
}
} else { } else {
console.error('Section can only be child of a page or another section'); console.error('Section can only be child of a page or another section');
} }
@ -687,8 +694,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
field.ordinal = 0;//first filed in the fields list field.ordinal = 0;//first filed in the fields list
const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray
//store rootPath for next levels/components
this.rootPath = 'definition.pages['+ pageIndex +'].'+ parentSectionRootPath+ 'fieldSets[' + fieldSetsArray.length + '].';
const fieldForm = field.buildForm({ rootPath: this.rootPath+ 'fields[' + 0 + '].'}); const fieldForm = field.buildForm({ rootPath: this.rootPath+ 'fields[' + 0 + '].'});
//give fieldset id and ordinal //give fieldset id and ordinal

View File

@ -60,8 +60,8 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `users[${index}].` rootPath: `users[${index}].`
}), context.getValidation('users') })
) ), context.getValidation('users').validators
), ),
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators] hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
}); });
@ -1233,8 +1233,9 @@ export class DescriptionTemplateExternalSelectDataEditorModel extends Descriptio
(this.sources ?? []).map( (this.sources ?? []).map(
(item, index) => item.buildForm({ (item, index) => item.buildForm({
rootPath: `${rootPath}sources[${index}].` rootPath: `${rootPath}sources[${index}].`
}), context.getValidation('sources') })
))); ), context.getValidation('sources').validators
));
return formGroup; return formGroup;
} }
@ -1583,8 +1584,9 @@ export class DescriptionTemplateRadioBoxDataEditorModel extends DescriptionTempl
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}options[${index}].` rootPath: `${rootPath}options[${index}].`
}), context.getValidation('options') })
))); ), context.getValidation('options').validators
));
return formGroup; return formGroup;
} }
@ -1729,8 +1731,9 @@ export class DescriptionTemplateSelectDataEditorModel extends DescriptionTemplat
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}options[${index}].` rootPath: `${rootPath}options[${index}].`
}), context.getValidation('options') })
))); ), context.getValidation('options').validators
));
return formGroup; return formGroup;
} }

View File

@ -128,7 +128,9 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
this.matomoService.trackPageView('Admin: DMP Blueprints'); this.matomoService.trackPageView('Admin: DMP Blueprints');
super.ngOnInit(); super.ngOnInit();
this.initModelFlags(this.route.snapshot.data['action']); this.initModelFlags(this.route.snapshot.data['action']);
this.route.data.subscribe(d => this.initModelFlags(d['action'])); this.route.data.subscribe(d => {
this.initModelFlags(d['action']);
});
} }
private initModelFlags(action: string): void { private initModelFlags(action: string): void {

View File

@ -90,20 +90,20 @@
<mat-icon>more_horiz</mat-icon> <mat-icon>more_horiz</mat-icon>
</button> </button>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="[row.id]"> <button mat-menu-item [routerLink]="['/dmp-blueprints/', row.id]">
<mat-icon>edit</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.EDIT' | translate}} <mat-icon>edit</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.EDIT' | translate}}
</button> </button>
<button mat-menu-item [routerLink]="['new-version' , row.id]"> <button mat-menu-item [routerLink]="['/dmp-blueprints/new-version' , row.id]">
<mat-icon>queue</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.NEW-VERSION' | translate}} <mat-icon>queue</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.NEW-VERSION' | translate}}
</button> </button>
<button mat-menu-item [routerLink]="['clone' , row.id]"> <button mat-menu-item [routerLink]="['/dmp-blueprints/clone' , row.id]">
<mat-icon>content_copy</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.CLONE' | translate}} <mat-icon>content_copy</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.CLONE' | translate}}
</button> </button>
<button mat-menu-item [routerLink]="['versions' , row.groupId]"> <button mat-menu-item [routerLink]="['/dmp-blueprints/versions' , row.groupId]">
<mat-icon>library_books</mat-icon> <mat-icon>library_books</mat-icon>
{{'DMP-BLUEPRINT-LISTING.ACTIONS.VIEW-VERSIONS' | translate}} {{'DMP-BLUEPRINT-LISTING.ACTIONS.VIEW-VERSIONS' | translate}}
</button> </button>
<button mat-menu-item (click)="export(row.id)" [routerLink]="[row.id]"> <button mat-menu-item (click)="export(row.id)" [routerLink]="['/dmp-blueprints/', row.id]">
<mat-icon>download</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.DOWNLOAD-XML' | translate}} <mat-icon>download</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.DOWNLOAD-XML' | translate}}
</button> </button>
<button mat-menu-item (click)="delete(row.id)"> <button mat-menu-item (click)="delete(row.id)">

View File

@ -784,9 +784,12 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionTemplateService.getSingle(descriptionTemplateId, DescriptionEditorResolver.descriptionTemplateLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(descriptionTemplate => { this.descriptionTemplateService.getSingle(descriptionTemplateId, DescriptionEditorResolver.descriptionTemplateLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(descriptionTemplate => {
this.editorModel.properties = new DescriptionPropertyDefinitionEditorModel().fromModel(null, descriptionTemplate, null); this.editorModel.properties = new DescriptionPropertyDefinitionEditorModel().fromModel(null, descriptionTemplate, null);
this.formGroup.removeControl('properties'); this.formGroup.setControl('properties', this.editorModel.buildProperties());
this.formGroup.addControl('properties', this.editorModel.buildProperties());
this.item.descriptionTemplate = descriptionTemplate; this.item.descriptionTemplate = descriptionTemplate;
const sectionId = this.item.dmpDescriptionTemplate.sectionId;
this.item.dmpDescriptionTemplate = this.item.dmp.dmpDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == descriptionTemplate.groupId);
this.formGroup.get('dmpDescriptionTemplateId').setValue(this.item.dmpDescriptionTemplate.id);
}); });
// this.formGroup.removeControl('descriptionProfileDefinition'); // this.formGroup.removeControl('descriptionProfileDefinition');
// this.getDefinition(profiledId); // this.getDefinition(profiledId);

View File

@ -34,7 +34,7 @@ export class DescriptionEditorModel extends BaseEditorModel implements Descripti
this.dmpId = item.dmp?.id; this.dmpId = item.dmp?.id;
this.dmpDescriptionTemplateId = item.dmpDescriptionTemplate?.id; this.dmpDescriptionTemplateId = item.dmpDescriptionTemplate?.id;
this.descriptionTemplateId = item.descriptionTemplate?.id; this.descriptionTemplateId = item.descriptionTemplate?.id;
this.status = item.status; this.status = item.status ?? DescriptionStatus.Draft;
this.description = item.description; this.description = item.description;
this.tags = item.descriptionTags?.map(x => x.tag?.label); this.tags = item.descriptionTags?.map(x => x.tag?.label);
this.properties = new DescriptionPropertyDefinitionEditorModel().fromModel(item.properties, descriptionTemplate, item.descriptionReferences); this.properties = new DescriptionPropertyDefinitionEditorModel().fromModel(item.properties, descriptionTemplate, item.descriptionReferences);

View File

@ -68,6 +68,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.label)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.version)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.version)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.groupId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.ordinal)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.ordinal)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.title)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.title)].join('.'),
@ -121,6 +122,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
// (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'), // (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
// (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'), // (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'),

View File

@ -1,10 +1,12 @@
<div *ngFor="let entry of tocentries; index as idx"> <div *ngFor="let entry of tocentries; index as idx">
<!-- check if is visible --> <!-- check if is visible -->
<!-- <ng-container *ngIf="!hiddenEntries.includes(entry.id)"> -->
<ng-container *ngIf="!hiddenEntries.includes(entry.id)"> <ng-container *ngIf="!hiddenEntries.includes(entry.id)">
<!-- Is fieldset and has no visible inputs --> <!-- Is fieldset and has no visible inputs -->
<!-- <ng-container *ngIf="!(entry.type === tocEntryTypeEnum.FieldSet && !visibilityRulesService.scanIfChildsOfCompositeFieldHasVisibleItems(entry.form))"> TODO: add this bellow --> <!-- <ng-container *ngIf="!(entry.type === tocEntryTypeEnum.FieldSet && !visibilityRulesService.scanIfChildsOfCompositeFieldHasVisibleItems(entry.form))"> TODO: add this bellow -->
<ng-container *ngIf="!(entry.type === tocEntryTypeEnum.FieldSet)"> <!-- <ng-container *ngIf="!(entry.type === tocEntryTypeEnum.FieldSet)"> -->
<ng-container >
<span class="table-entry" <span class="table-entry"
(click)="toggleExpand(idx);navigateToFieldSet(entry, $event); onEntrySelected(entry)" (click)="toggleExpand(idx);navigateToFieldSet(entry, $event); onEntrySelected(entry)"

View File

@ -29,7 +29,7 @@ export class TableOfContentsInternal implements OnInit {
constructor() { constructor() {
} }
ngOnInit(): void { ngOnInit(): void {
// console.log('component created'); console.log('component created' + JSON.stringify(this.tocentries));
if (this.tocentries) { if (this.tocentries) {
this.expandChildren = this.tocentries.map(() => false); this.expandChildren = this.tocentries.map(() => false);
if (this.selected) { if (this.selected) {
@ -73,13 +73,14 @@ export class TableOfContentsInternal implements OnInit {
if (entry.type === ToCEntryType.FieldSet) { if (entry.type === ToCEntryType.FieldSet) {
const fieldSetId = entry.id; const fieldSetId = entry.id;
const element = document.getElementById(this.TOCENTRY_ID_PREFIX + fieldSetId); // const element = document.getElementById(this.TOCENTRY_ID_PREFIX + fieldSetId);
const element = document.getElementById(fieldSetId);
if (element) { if (element) {
element.click();//open mat expansion panel element.click();//open mat expansion panel
//scroll asyn in 200 ms so the expansion panel is expanded and the element coordinates are updated //scroll asyn in 200 ms so the expansion panel is expanded and the element coordinates are updated
setTimeout(() => { setTimeout(() => {
const element = document.getElementById(this.TOCENTRY_ID_PREFIX + fieldSetId); const element = document.getElementById(fieldSetId);
if (element) { if (element) {
element.scrollIntoView({ behavior: 'smooth' }); element.scrollIntoView({ behavior: 'smooth' });
} }

View File

@ -83,9 +83,9 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
if (this.descriptionTemplate) { if (this.descriptionTemplate) {
this.tocentries = this.getTocEntries(this.descriptionTemplate); this.tocentries = this.getTocEntries(this.descriptionTemplate);
if (this.visibilityRulesService) { // if (this.visibilityRulesService) {
this.hiddenEntries = this._findHiddenEntries(this.tocentries); // this.hiddenEntries = this._findHiddenEntries(this.tocentries);
} // }
} else { } else {
@ -96,57 +96,57 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
this.linksSubject.next(headers); this.linksSubject.next(headers);
}); });
if (!this.links || this.links.length === 0) { // if (!this.links || this.links.length === 0) {
this.linksSubject.asObservable() // this.linksSubject.asObservable()
.pipe(distinctUntilChanged((p: HTMLElement[], q: HTMLElement[]) => JSON.stringify(p) == JSON.stringify(q))) // .pipe(distinctUntilChanged((p: HTMLElement[], q: HTMLElement[]) => JSON.stringify(p) == JSON.stringify(q)))
.subscribe(headers => { // .subscribe(headers => {
const links: Array<Link> = []; // const links: Array<Link> = [];
if (headers.length) { // if (headers.length) {
let page; // let page;
let section; // let section;
let show // let show
for (const header of headers) { // for (const header of headers) {
let name; // let name;
let id; // let id;
if (header.classList.contains('toc-page-header')) { // deprecated after removing stepper // if (header.classList.contains('toc-page-header')) { // deprecated after removing stepper
name = header.innerText.trim().replace(/^link/, ''); // name = header.innerText.trim().replace(/^link/, '');
id = header.id; // id = header.id;
page = header.id.split('_')[1]; // page = header.id.split('_')[1];
section = undefined; // section = undefined;
show = true; // show = true;
} else if (header.classList.contains('toc-section-header')) { // } else if (header.classList.contains('toc-section-header')) {
name = header.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue.trim().replace(/^link/, ''); // name = header.childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0].nodeValue.trim().replace(/^link/, '');
id = header.id; // id = header.id;
page = header.id.split('.')[1]; // page = header.id.split('.')[1];
section = header.id; // section = header.id;
if (header.id.split('.')[4]) { show = false; } // if (header.id.split('.')[4]) { show = false; }
else { show = true; } // else { show = true; }
} else if (header.classList.contains('toc-compositeField-header')) { // } else if (header.classList.contains('toc-compositeField-header')) {
name = (header.childNodes[0]).nodeValue.trim().replace(/^link/, ''); // name = (header.childNodes[0]).nodeValue.trim().replace(/^link/, '');
id = header.id; // id = header.id;
// id = header.parentElement.parentElement.parentElement.id; // // id = header.parentElement.parentElement.parentElement.id;
show = false; // show = false;
} // }
const { top } = header.getBoundingClientRect(); // const { top } = header.getBoundingClientRect();
links.push({ // links.push({
name, // name,
id, // id,
type: header.tagName.toLowerCase(), // type: header.tagName.toLowerCase(),
top: top, // top: top,
active: false, // active: false,
page: page, // page: page,
section: section, // section: section,
show: show, // show: show,
selected: false // selected: false
}); // });
} // }
} // }
this.links = links; // this.links = links;
// Initialize selected for button next on dataset wizard component editor // // Initialize selected for button next on dataset wizard component editor
this.links.length > 0 ? this.links[0].selected = true : null; // this.links.length > 0 ? this.links[0].selected = true : null;
}) // })
} // }
} }
} }
@ -201,9 +201,9 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
} }
if (changes['descriptionTemplate'] && changes.descriptionTemplate != null) { if (changes['descriptionTemplate'] && changes.descriptionTemplate != null) {
this.tocentries = this.getTocEntries(this.descriptionTemplate); this.tocentries = this.getTocEntries(this.descriptionTemplate);
if (this.visibilityRulesService) { // if (this.visibilityRulesService) {
this.hiddenEntries = this._findHiddenEntries(this.tocentries); // this.hiddenEntries = this._findHiddenEntries(this.tocentries);
} // }
} }
if ('visibilityRulesService') { if ('visibilityRulesService') {
@ -365,7 +365,7 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
id: item.id, id: item.id,
label: item.title, label: item.title,
numbering: 's', numbering: 's',
subEntries: tempResult, subEntries: null,
subEntriesType: ToCEntryType.Field, subEntriesType: ToCEntryType.Field,
type: ToCEntryType.FieldSet, type: ToCEntryType.FieldSet,
ordinal: item.ordinal ordinal: item.ordinal
@ -383,7 +383,7 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
subEntriesType: null, subEntriesType: null,
type: ToCEntryType.Field, type: ToCEntryType.Field,
ordinal: item.ordinal, ordinal: item.ordinal,
hidden: true hidden: false
}; };
} }

View File

@ -1,10 +1,5 @@
<mat-form-field class="w-100" *ngIf="multipleAutoCompleteSearchConfiguration"> <mat-form-field class="w-100" *ngIf="multipleAutoCompleteSearchConfiguration">
<ng-container *ngIf="label"> <mat-label>{{label ?? enumUtils.toReferenceTypeString(referenceType)}}</mat-label>
<mat-label>{{label}}</mat-label>
</ng-container>
<ng-container *ngIf="!label">
<mat-label>{{'REFERENCE-FIELD.PLACEHOLDER' | translate}} {{enumUtils.toReferenceTypeString(referenceType)}}</mat-label>
</ng-container>
<app-multiple-auto-complete placeholder = "{{ placeholder ?? enumUtils.toReferenceTypeString(referenceType)}}" [formControl]="form" [configuration]="multipleAutoCompleteSearchConfiguration"> <app-multiple-auto-complete placeholder = "{{ placeholder ?? enumUtils.toReferenceTypeString(referenceType)}}" [formControl]="form" [configuration]="multipleAutoCompleteSearchConfiguration">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error> <mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error>