diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpproperties/DmpContactBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpproperties/DmpContactBuilder.java index cdaee4b48..6c724b775 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpproperties/DmpContactBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpproperties/DmpContactBuilder.java @@ -3,11 +3,10 @@ package eu.eudat.model.builder.dmpproperties; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.dmp.DmpContactEntity; import eu.eudat.convention.ConventionService; -import eu.eudat.data.DmpUserEntity; -import eu.eudat.model.DmpUser; +import eu.eudat.model.DmpAssociatedUser; import eu.eudat.model.User; import eu.eudat.model.builder.BaseBuilder; -import eu.eudat.model.builder.UserBuilder; +import eu.eudat.model.builder.DmpAssociatedUserBuilder; import eu.eudat.model.dmpproperties.DmpContact; import eu.eudat.query.UserQuery; import gr.cite.tools.data.builder.BuilderFactory; @@ -57,7 +56,7 @@ public class DmpContactBuilder extends BaseBuilder //Not Bulk Build because is XML no interaction with db FieldSet userFields = fields.extractPrefixed(this.asPrefix(DmpContact._user)); - Map userItemsMap = this.collectUsers(userFields, data); + Map userItemsMap = this.collectUsers(userFields, data); List models = new ArrayList<>(); for (DmpContactEntity d : data) { @@ -72,25 +71,25 @@ public class DmpContactBuilder extends BaseBuilder return models; } - private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { + private Map collectUsers(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", User.class.getSimpleName()); - Map itemMap; - if (!fields.hasOtherField(this.asIndexer(User._id))) { + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(DmpAssociatedUser._id))) { itemMap = this.asEmpty( data.stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().collect(Collectors.toList()), x -> { - User item = new User(); + DmpAssociatedUser item = new DmpAssociatedUser(); item.setId(x); return item; }, - User::getId); + DmpAssociatedUser::getId); } else { FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(User._id); UserQuery q = this.queryFactory.query(UserQuery.class).authorize(this.authorize).ids(data.stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(UserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, User::getId); + itemMap = this.builderFactory.builder(DmpAssociatedUserBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DmpAssociatedUser::getId); } if (!fields.hasField(User._id)) { itemMap.forEach((id, item) -> { diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpproperties/DmpContact.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpproperties/DmpContact.java index fbb4aca4f..0aebbdbe6 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/dmpproperties/DmpContact.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpproperties/DmpContact.java @@ -1,10 +1,10 @@ package eu.eudat.model.dmpproperties; -import eu.eudat.model.User; +import eu.eudat.model.DmpAssociatedUser; public class DmpContact { - private User user; + private DmpAssociatedUser user; public static final String _user = "user"; private String firstName; @@ -39,11 +39,11 @@ public class DmpContact { this.email = email; } - public User getUser() { + public DmpAssociatedUser getUser() { return user; } - public void setUser(User user) { + public void setUser(DmpAssociatedUser user) { this.user = user; } } diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 23940da88..24183d23a 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -9,7 +9,7 @@ import { Description } from '../description/description'; import { DmpBlueprint } from '../dmp-blueprint/dmp-blueprint'; import { EntityDoi } from '../entity-doi/entity-doi'; import { ReferencePersist } from '../reference/reference'; -import { User } from "../user/user"; +import { DmpAssociatedUser, User } from "../user/user"; import { DmpReference } from './dmp-reference'; export interface Dmp extends BaseEntity { @@ -45,7 +45,7 @@ export interface DmpBlueprintValue { } export interface DmpContact { - user?: User; + user?: DmpAssociatedUser; firstName: string; lastName: string; email: string; diff --git a/dmp-frontend/src/app/core/services/user/user.service.ts b/dmp-frontend/src/app/core/services/user/user.service.ts index ba382f705..988bbb8e8 100644 --- a/dmp-frontend/src/app/core/services/user/user.service.ts +++ b/dmp-frontend/src/app/core/services/user/user.service.ts @@ -122,6 +122,16 @@ export class UserService { valueAssign: (item: User) => item.id, }; + singleAutoCompleteDmpAssociatedUserConfiguration: SingleAutoCompleteConfiguration = { + initialItems: (data?: any) => this.queryDmpAssociated(this.buildAutocompleteLookup()).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.queryDmpAssociated(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.queryDmpAssociated(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), + displayFn: (item: DmpAssociatedUser) => item.name, + subtitleFn: (item: DmpAssociatedUser) => item.email, + titleFn: (item: DmpAssociatedUser) => item.name, + valueAssign: (item: DmpAssociatedUser) => item.id, + }; + private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): UserLookup { const lookup: UserLookup = new UserLookup(); lookup.page = { size: 100, offset: 0 }; diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html index c7cfb2414..fd0a30ec6 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html @@ -147,30 +147,30 @@
- +
- +
- +
- +
- +
- +
- +
- + {{ lang.name }} @@ -198,7 +198,7 @@
{{'DMP-EDITOR.FIELDS1.USER' | translate}} - + {{contact.get('userId').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -250,7 +250,7 @@
- + {{enumUtils.toDmpAccessTypeString(dmpAccessType)}} @@ -322,4 +322,4 @@
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts index 0ca8c6a7f..32b7caedc 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts @@ -5,7 +5,7 @@ import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, Dm import { Dmp, DmpBlueprintValue, DmpContact, DmpDescriptionTemplate, DmpProperties } from '@app/core/model/dmp/dmp'; import { DmpReference, DmpReferenceData } from '@app/core/model/dmp/dmp-reference'; import { Reference } from '@app/core/model/reference/reference'; -import { User } from '@app/core/model/user/user'; +import { DmpAssociatedUser, User } from '@app/core/model/user/user'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; @@ -38,7 +38,7 @@ export class DmpEditorResolver extends BaseEditorResolver { [nameof(x => x.properties), nameof(x => x.dmpBlueprintValues), nameof(x => x.fieldId)].join('.'), [nameof(x => x.properties), nameof(x => x.dmpBlueprintValues), nameof(x => x.fieldValue)].join('.'), - [nameof(x => x.properties), nameof(x => x.contacts), nameof(x => x.user), nameof(x => x.id)].join('.'), + [nameof(x => x.properties), nameof(x => x.contacts), nameof(x => x.user), nameof(x => x.id)].join('.'), [nameof(x => x.properties), nameof(x => x.contacts), nameof(x => x.firstName)].join('.'), [nameof(x => x.properties), nameof(x => x.contacts), nameof(x => x.lastName)].join('.'), [nameof(x => x.properties), nameof(x => x.contacts), nameof(x => x.email)].join('.'), 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 e7cfc285f..296e9d7ca 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html @@ -1,6 +1,11 @@ - {{'REFERENCE-FIELD.PLACEHOLDER' | translate}} {{enumUtils.toReferenceTypeString(referenceType)}} - + + {{label}} + + + {{'REFERENCE-FIELD.PLACEHOLDER' | translate}} {{enumUtils.toReferenceTypeString(referenceType)}} + + {{form.getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts index 148f6c3d8..ce35d8dae 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts @@ -15,6 +15,8 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit { @Input() referenceType: ReferenceType = null; @Input() form: UntypedFormGroup = null; + @Input() label: string = null; + @Input() placeholder: string = "Enter text"; multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration;