diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java b/backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java index f74a633c2..a8c8e252b 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/DmpUserRole.java @@ -21,7 +21,7 @@ public enum DmpUserRole implements DatabaseEnum { @Override @JsonValue public Short getValue() { - return value; + return this.value; } private static final Map map = EnumUtils.getEnumValueMap(DmpUserRole.class); diff --git a/backend/core/src/main/java/org/opencdmp/model/description/PropertyDefinitionFieldSetItem.java b/backend/core/src/main/java/org/opencdmp/model/description/PropertyDefinitionFieldSetItem.java index ca7a69d0e..560f9ec83 100644 --- a/backend/core/src/main/java/org/opencdmp/model/description/PropertyDefinitionFieldSetItem.java +++ b/backend/core/src/main/java/org/opencdmp/model/description/PropertyDefinitionFieldSetItem.java @@ -14,7 +14,7 @@ public class PropertyDefinitionFieldSetItem { private Integer ordinal; public Map getFields() { - return fields; + return this.fields; } public void setFields(Map fields) { @@ -22,7 +22,7 @@ public class PropertyDefinitionFieldSetItem { } public String getComment() { - return comment; + return this.comment; } public void setComment(String comment) { @@ -30,7 +30,7 @@ public class PropertyDefinitionFieldSetItem { } public Integer getOrdinal() { - return ordinal; + return this.ordinal; } public void setOrdinal(Integer ordinal) { diff --git a/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java index 32fc4ad14..d8b4e7ecb 100644 --- a/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/prefillingsource/PrefillingSourceServiceImpl.java @@ -422,10 +422,10 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { List issuedFieldEntities = definition.getAllField().stream().filter(x -> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList(); if (!this.conventionService.isListNullOrEmpty(issuedFieldEntities)) { String issuedIdNode = issuedFieldEntities.getFirst().getId(); - String issuedValue = this.conventionService.isNullOrEmpty(issuedIdNode) ? null : description.getProperties().getFieldSets().values().stream().map(PropertyDefinitionFieldSet::getItems).flatMap(List::stream) - .filter(x -> x.getFields() != null && x.getFields().containsKey(issuedIdNode)).map(x -> x.getFields().get(issuedIdNode).getTextValue()).filter(Objects::nonNull).findFirst().orElse(null); + Instant issuedValue = this.conventionService.isNullOrEmpty(issuedIdNode) ? null : description.getProperties().getFieldSets().values().stream().map(PropertyDefinitionFieldSet::getItems).flatMap(List::stream) + .filter(x -> x.getFields() != null && x.getFields().containsKey(issuedIdNode)).map(x -> x.getFields().get(issuedIdNode).getDateValue()).filter(Objects::nonNull).findFirst().orElse(null); - if (!this.conventionService.isNullOrEmpty(issuedValue)) { + if (issuedValue != null) { List licStartFieldSetsEntities = definition.getAllFieldSets().stream().filter(x -> x.getAllField() != null && x.getAllField().stream().anyMatch(y -> y.getSchematics() != null && y.getSchematics().contains("rda.dataset.distribution.license.start_date"))).toList(); for (FieldSetEntity licStartFieldSetEntity : licStartFieldSetsEntities) { List licStartEntities = licStartFieldSetEntity.getAllField().stream().filter(x -> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.distribution.license.start_date")).toList(); @@ -433,7 +433,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { this.ensureFieldSetEntity(description, licStartFieldSetEntity); for (FieldEntity licStartDateNode : licStartEntities) { - description.getProperties().getFieldSets().get(licStartFieldSetEntity.getId()).getItems().getFirst().getFields().put(licStartDateNode.getId(), this.buildPropertyDefinitionFieldItemValue(descriptionReferences,licStartDateNode, semanticTarget, issuedValue, type)); + description.getProperties().getFieldSets().get(licStartFieldSetEntity.getId()).getItems().getFirst().getFields().put(licStartDateNode.getId(), this.buildPropertyDefinitionFieldItemValue(descriptionReferences,licStartDateNode, semanticTarget, issuedValue.toString(), type)); } } } @@ -497,7 +497,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { if (fieldEntity == null || fieldEntity.getData() == null || fieldEntity.getData().getFieldType() == null || this.conventionService.isNullOrEmpty(value)) return field; try{ switch (fieldEntity.getData().getFieldType()){ - case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> field.setTextValue(value.toLowerCase(Locale.ROOT)); + case FREE_TEXT, TEXT_AREA, RICH_TEXT_AREA, RADIO_BOX -> field.setTextValue(value); case CHECK_BOX, BOOLEAN_DECISION ->{ if (!this.conventionService.isNullOrEmpty(value)) { field.setBooleanValue("true".equals(value.trim().toLowerCase(Locale.ROOT))); diff --git a/dmp-frontend/src/app/core/query/default-user-locale.lookup.ts b/dmp-frontend/src/app/core/query/default-user-locale.lookup.ts index 0a7d189b6..3856cd544 100644 --- a/dmp-frontend/src/app/core/query/default-user-locale.lookup.ts +++ b/dmp-frontend/src/app/core/query/default-user-locale.lookup.ts @@ -12,7 +12,7 @@ export class DefaultUserLocaleTimezoneLookup extends Lookup { export class DefaultUserLocaleCultureLookup extends Lookup { like: string; - selectedItem: CultureInfo; + selectedItem: string; constructor() { super(); diff --git a/dmp-frontend/src/app/core/services/default-user-locale/default-user-locale.service.ts b/dmp-frontend/src/app/core/services/default-user-locale/default-user-locale.service.ts index c3c8c9c8c..8554200ad 100644 --- a/dmp-frontend/src/app/core/services/default-user-locale/default-user-locale.service.ts +++ b/dmp-frontend/src/app/core/services/default-user-locale/default-user-locale.service.ts @@ -40,18 +40,42 @@ export class DefaultUserLocaleService { return timezones; } - queryCulture(q: DefaultUserLocaleCultureLookup): Observable { + queryCulture(q: DefaultUserLocaleCultureLookup) { let cultures = of(this.cultureService.getCultureValues().sort((x, y) => x.displayName.localeCompare(y.displayName))); if (q.like) { let likeValue = q.like.toLowerCase(); cultures = cultures.pipe(map((items: CultureInfo[]) => { - let filteredItems = items.filter(i => this.getCultureDisplayFn(i).toLowerCase().includes(likeValue)); + let filteredItems = items.filter(i => { + const displayValue = `${i?.displayName} - ${i?.nativeName}`; + if (displayValue.toLowerCase().includes(likeValue)) { + return true; + } else { + return false; + } + }); if (filteredItems != null && filteredItems?.length > 0) return filteredItems; else return null; })); } + if (q.selectedItem) { + let selectedItemValue = q.selectedItem.toLowerCase(); + cultures = cultures.pipe(map((items: CultureInfo[]) => { + let selected = items.find(i => { + if (i.name.toLowerCase().includes(selectedItemValue)) { + return true; + } else { + return false; + } + }); + if (selected != null) { + return [selected]; + } + else return null; + })); + } + return cultures; } @@ -63,7 +87,7 @@ export class DefaultUserLocaleService { initialItems: (data?: any) => this.queryTimezone(this.buildTimezoneAutocompleteLookup(null)), filterFn: (searchQuery: string, data?: any) => this.queryTimezone(this.buildTimezoneAutocompleteLookup(searchQuery)), getSelectedItem: (selectedItem: string) => this.queryTimezone(this.buildTimezoneAutocompleteLookup(null, selectedItem)), - displayFn: (item: string) => this.timezoneInfoDisplayPipe.transform(item), + displayFn: (item: string) => this.getTimezoneDisplayFn(item), titleFn: (item: string) => this.timezoneInfoDisplayPipe.transform(item), valueAssign: (item: string) => item, }; @@ -76,25 +100,37 @@ export class DefaultUserLocaleService { return lookup; } + getTimezoneDisplayFn(value: any) { + return Array.isArray(value) ? this.timezoneInfoDisplayPipe.transform(value[0]) : this.timezoneInfoDisplayPipe.transform(value); + } + singleCultureAutocompleteConfiguration: SingleAutoCompleteConfiguration = { initialItems: (data?: any) => this.queryCulture(this.buildCultureAutocompleteLookup(null)), filterFn: (searchQuery: string, data?: any) => this.queryCulture(this.buildCultureAutocompleteLookup(searchQuery)), - getSelectedItem: (selectedItem: CultureInfo) => this.queryCulture(this.buildCultureAutocompleteLookup(null, selectedItem)), - displayFn: (item: CultureInfo) => this.getCultureDisplayFn(item), - titleFn: (item: CultureInfo) => this.getCultureDisplayFn(item), + getSelectedItem: (selectedItem: string) =>this.queryCulture(this.buildCultureAutocompleteLookup(null, selectedItem)), + displayFn: (item: any) => this.getCultureDisplayFn(item), + titleFn: (item: CultureInfo) => this.getCultureTitleFn(item), valueAssign: (item: CultureInfo) => item.name, }; - private buildCultureAutocompleteLookup(like?: string, selectedItem?: CultureInfo): DefaultUserLocaleCultureLookup { + private buildCultureAutocompleteLookup(like?: string, selectedItem?: string): DefaultUserLocaleCultureLookup { const lookup: DefaultUserLocaleCultureLookup = new DefaultUserLocaleCultureLookup(); lookup.page = { size: 100, offset: 0 }; if (like) { lookup.like = like; } if (selectedItem) { lookup.selectedItem = selectedItem } return lookup; } - - private getCultureDisplayFn(culture: CultureInfo): string { + + private getCultureTitleFn(culture: any): string { return `${culture?.displayName} - ${culture?.nativeName}`; } + + private getCultureDisplayFn(culture: any): string { + if (Array.isArray(culture)) { + return this.getCultureTitleFn(culture[0]); + } else { + return this.getCultureTitleFn(culture); + } + } } diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html index de031c531..6b7dafd9e 100644 --- a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html @@ -9,7 +9,7 @@ diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts index 27b984825..f257ee2c5 100644 --- a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts @@ -153,6 +153,7 @@ export class TableOfContentsInternal implements OnInit, OnDestroy { navigateToFieldSet(entry: ToCEntry, event) { if (entry.type === ToCEntryType.FieldSet) { + this.onScrollStarted(entry); const fieldSetId = entry.id; const element = document.getElementById(fieldSetId); diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts index 49977bda9..48ba44ca9 100644 --- a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts @@ -210,7 +210,7 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O const options = { root: null, - rootMargin: '-38% 0px -60% 0px', + rootMargin: '20% 0px -30% 0px', threshold: 0 } @@ -220,8 +220,6 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O } entries.forEach(ie => { - if (this.isScrolling) return; - if (ie.isIntersecting) { try { if(!this.isScrolling) { @@ -229,6 +227,8 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O if (this.visibilityRulesService.isVisibleMap[target_id] ?? true) { this.onToCentrySelected(this._findTocEntryById(target_id, this.tocentries)); } + } else { + console.log('cannot scroll'); } } catch { } @@ -445,10 +445,12 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O } onScrollStarted(entry: ToCEntry) { + this.console.log('started'); this.isScrolling = true; } - + onScrollFinished(entry: ToCEntry) { + this.console.log('finished'); this.isScrolling = false; } diff --git a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html index 1d539e3b7..8ae3e02ca 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html @@ -5,7 +5,7 @@ {{form.getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{hint}} - + {{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}} {{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}} @@ -17,7 +17,7 @@ {{form.getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{hint}} - + {{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}} {{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}}