From 72147451625c83ffb840ae82b14694b09d71394b Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Fri, 27 Oct 2023 18:56:19 +0300 Subject: [PATCH] frontend dmp changes --- .../src/main/java/eu/eudat/model/Dmp.java | 18 --- .../dmpblueprintdefinition/FieldPersist.java | 1 - .../dmpblueprint/DmpBlueprintServiceImpl.java | 1 + dmp-backend/web/pom.xml | 5 + dmp-frontend/angular.json | 1 + .../core/common/enum/description-status.ts | 4 + .../src/app/core/common/enum/dmp-status.ts | 3 +- .../src/app/core/core-service.module.ts | 6 +- .../field-data/field-data.ts | 2 +- .../description-template.ts | 81 ++++++++++++++ .../description/description-reference.ts | 21 ++++ .../app/core/model/description/description.ts | 37 +++++++ .../src/app/core/model/dmp/dmp-reference.ts | 21 ++++ dmp-frontend/src/app/core/model/dmp/dmp.ts | 35 ++++++ .../src/app/core/model/reference/reference.ts | 88 +++++++-------- .../src/app/core/query/reference.lookup.ts | 27 +++++ .../services/dmp/dmp-blueprint.service.ts | 2 +- .../services/reference/reference.service.ts | 103 ++++++++++++++++++ ...ets-autocomplete-field-data-editor-mode.ts | 12 +- ...ps-autocomplete-field-data-editor-model.ts | 2 +- .../field-data-option-editor-model.ts | 3 - ...s-auto-complete-field-data-editor-model.ts | 2 +- .../researchers-data-editor-models.ts | 5 +- .../dmp-blueprint/dmp-blueprint.routing.ts | 12 +- .../dmp-blueprint-editor.component.html | 42 +++---- .../dmp-blueprint-editor.component.scss | 5 - .../editor/dmp-blueprint-editor.component.ts | 11 +- .../editor/dmp-blueprint-editor.model.ts | 2 +- .../editor/dmp-blueprint-editor.resolver.ts | 8 +- .../dmp-blueprint-listing.component.html | 6 +- .../ui/dashboard/drafts/drafts.component.ts | 7 +- .../recent-edited-activity.component.ts | 7 +- .../recent-edited-dmp-activity.component.ts | 7 +- .../app/ui/dmp/clone/dmp-clone.component.ts | 7 +- .../dmp-editor-blueprint.component.html | 27 ++--- .../dmp-editor-blueprint.component.ts | 73 ++++--------- .../dmp-listing-item.component.ts | 7 +- .../ui/dmp/overview/dmp-overview.component.ts | 7 +- .../start-new-dmp-dialog.component.html | 52 +++++---- .../app/ui/dmp/wizard/dmp-wizard.component.ts | 10 +- dmp-frontend/src/styles.scss | 2 - 41 files changed, 542 insertions(+), 230 deletions(-) create mode 100644 dmp-frontend/src/app/core/common/enum/description-status.ts create mode 100644 dmp-frontend/src/app/core/model/description-template/description-template.ts create mode 100644 dmp-frontend/src/app/core/model/description/description-reference.ts create mode 100644 dmp-frontend/src/app/core/model/description/description.ts create mode 100644 dmp-frontend/src/app/core/model/dmp/dmp-reference.ts create mode 100644 dmp-frontend/src/app/core/query/reference.lookup.ts create mode 100644 dmp-frontend/src/app/core/services/reference/reference.service.ts diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java b/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java index 7ad6d86d6..9e908918b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/Dmp.java @@ -10,75 +10,57 @@ import java.util.UUID; public class Dmp { private UUID id; - public static final String _id = "id"; private String label; - public static final String _label = "label"; private Integer version; - public static final String _version = "version"; private DmpStatus status; - public static final String _status = "status"; private String properties; - public static final String _properties = "properties"; private String dmpProperties; - public static final String _dmpProperties = "dmpProperties"; private UUID groupId; - public static final String _groupId = "groupId"; private String description; - public static final String _description = "description"; private boolean isPublic; - public static final String _isPublic = "isPublic"; private String extraProperties; - public static final String _extraProperties = "extraProperties"; private Instant createdAt; - public static final String _createdAt = "createdAt"; private Instant updatedAt; - public static final String _updatedAt = "updatedAt"; private IsActive isActive; - public static final String _isActive = "isActive"; private Instant finalizedAt; - public static final String _finalizedAt = "finalizedAt"; private Instant publishedAt; - public static final String _publishedAt = "publishedAt"; private UUID creator; - public static final String _creator = "creator"; private String hash; - public static final String _hash = "hash"; private List dmpDescriptions; - public static final String _dmpDescriptions = "dmpDescriptions"; public static final String _dmpReferences = "dmpReferences"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java index c43857531..4b4c5363b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java @@ -32,7 +32,6 @@ public abstract class FieldPersist { @NotEmpty(message = "{validation.empty}") private String label = null; - @NotNull(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}") private String placeholder = null; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java index 847cc40cc..4a6ce4c23 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -249,6 +249,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { model.setLabel(model.getLabel() + " new "); model.setId(null); model.setHash(null); + model.setStatus(DmpBlueprintStatus.Draft); this.reassignDefinition(model.getDefinition()); return model; diff --git a/dmp-backend/web/pom.xml b/dmp-backend/web/pom.xml index b46410b8c..e8d5643dd 100644 --- a/dmp-backend/web/pom.xml +++ b/dmp-backend/web/pom.xml @@ -199,6 +199,11 @@ cors-web 2.1.0 + + gr.cite + exceptions-web + 1.0.0 + diff --git a/dmp-frontend/angular.json b/dmp-frontend/angular.json index c33c8f5c2..eb97c4bba 100644 --- a/dmp-frontend/angular.json +++ b/dmp-frontend/angular.json @@ -22,6 +22,7 @@ { "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" } ], "styles": [ + "node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.scss", "src/assets/scss/material-dashboard.scss", "src/assets/css/demo.css", diff --git a/dmp-frontend/src/app/core/common/enum/description-status.ts b/dmp-frontend/src/app/core/common/enum/description-status.ts new file mode 100644 index 000000000..6055bf5db --- /dev/null +++ b/dmp-frontend/src/app/core/common/enum/description-status.ts @@ -0,0 +1,4 @@ +export enum DescriptionStatus { + Draft = 0, + Finalized = 1 +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/dmp-status.ts b/dmp-frontend/src/app/core/common/enum/dmp-status.ts index d96227198..3a836657e 100644 --- a/dmp-frontend/src/app/core/common/enum/dmp-status.ts +++ b/dmp-frontend/src/app/core/common/enum/dmp-status.ts @@ -1,5 +1,4 @@ export enum DmpStatus { Draft = 0, - Finalized = 1, - Deleted = 99 + Finalized = 1 } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/core-service.module.ts b/dmp-frontend/src/app/core/core-service.module.ts index 7de195b04..13f9df1c8 100644 --- a/dmp-frontend/src/app/core/core-service.module.ts +++ b/dmp-frontend/src/app/core/core-service.module.ts @@ -51,11 +51,12 @@ import { SpecialAuthGuard } from './special-auth-guard.service'; import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; import { FilterService } from '@common/modules/text-filter/filter-service'; import { PrincipalService } from './services/http/principal.service'; +import { ReferenceService } from './services/reference/reference.service'; import { SupportiveMaterialService } from './services/supportive-material/supportive-material.service'; import { UserSettingsHttpService } from './services/user-settings/user-settings-http.service'; import { UserSettingsService } from './services/user-settings/user-settings.service'; -import { QueryParamsService } from './services/utilities/query-params.service'; import { FileUtils } from './services/utilities/file-utils.service'; +import { QueryParamsService } from './services/utilities/query-params.service'; // // // This is shared module that provides all the services. Its imported only once on the AppModule. @@ -130,7 +131,8 @@ export class CoreServiceModule { UserSettingsService, UserSettingsHttpService, FilterService, - FileUtils + FileUtils, + ReferenceService ], }; } diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts index c66d04173..6225f46bc 100644 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts +++ b/dmp-frontend/src/app/core/model/dataset-profile-definition/field-data/field-data.ts @@ -130,7 +130,7 @@ export interface TagsFieldData extends FieldData { } export interface ResearchersFieldData extends FieldData { - + multiAutoComplete: boolean; } export interface OrganizationsFieldData extends AutoCompleteFieldData { diff --git a/dmp-frontend/src/app/core/model/description-template/description-template.ts b/dmp-frontend/src/app/core/model/description-template/description-template.ts new file mode 100644 index 000000000..4847dd37c --- /dev/null +++ b/dmp-frontend/src/app/core/model/description-template/description-template.ts @@ -0,0 +1,81 @@ +import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; +import { Guid } from "@common/types/guid"; + + +export interface DescriptionTemplate extends BaseEntity { + label: string; + definition: DescriptionTemplateDefinition; + description: string; +} + +export interface DescriptionTemplateDefinition { + sections?: DescriptionTemplateDefinitionSection[]; +} + + +export interface DescriptionTemplateDefinitionSection { + id: Guid; + label: string; + description: string; + ordinal: number; + fields: FieldInSection[]; + hasTemplates: boolean; + descriptionTemplates?: DescriptionTemplatesInSection[]; +} + +export interface DescriptionTemplatesInSection { + id: Guid; + descriptionTemplateId: Guid; + label: string; + minMultiplicity: number; + maxMultiplicity: number; +} + +export interface FieldInSection { + id: Guid; + label: string; + placeholder: string; + description: string; + required: boolean; + ordinal: number; +} + +// +// Persist +// +export interface DescriptionTemplatePersist extends BaseEntityPersist { + label: string; + definition: DescriptionTemplateDefinitionPersist; + description: string; +} + +export interface DescriptionTemplateDefinitionPersist { + sections?: DescriptionTemplateDefinitionSectionPersist[]; +} + +export interface DescriptionTemplateDefinitionSectionPersist { + id: Guid; + label: string; + description: string; + ordinal: number; + fields: FieldInSectionPersist[]; + hasTemplates: boolean; + descriptionTemplates?: DescriptionTemplatesInSectionPersist[]; +} + +export interface DescriptionTemplatesInSectionPersist { + id: Guid; + descriptionTemplateId: Guid; + label: string; + minMultiplicity: number; + maxMultiplicity: number; +} + +export interface FieldInSectionPersist { + id: Guid; + label: string; + placeholder: string; + description: string; + required: boolean; + ordinal: number; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/description/description-reference.ts b/dmp-frontend/src/app/core/model/description/description-reference.ts new file mode 100644 index 000000000..f63a3c8e2 --- /dev/null +++ b/dmp-frontend/src/app/core/model/description/description-reference.ts @@ -0,0 +1,21 @@ +import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; +import { Guid } from "@common/types/guid"; +import { Reference } from "../reference/reference"; +import { Description } from "./description"; + + + +export interface DescriptionReference extends BaseEntity { + description?: Description; + reference?: Reference; + data: String; +} + +// +// Persist +// +export interface DescriptionPersist extends BaseEntityPersist { + descriptionId: Guid; + referenceId: Guid; + data: String; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/description/description.ts b/dmp-frontend/src/app/core/model/description/description.ts new file mode 100644 index 000000000..fb64949f9 --- /dev/null +++ b/dmp-frontend/src/app/core/model/description/description.ts @@ -0,0 +1,37 @@ +import { DescriptionStatus } from "@app/core/common/enum/description-status"; +import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; +import { Guid } from "@common/types/guid"; +import { Dmp } from "../dmp/dmp"; +import { DescriptionTemplate } from "../description-template/description-template"; +import { DescriptionReference } from "./description-reference"; + + + +export interface Description extends BaseEntity { + label: string; + description?: String; + dmp: Dmp; + uri: String; + status: DescriptionStatus + finalizedAt: Date; + dmpSectionIndex?: number; + template: DescriptionTemplate; + descriptionReferences: DescriptionReference[]; + + + + // registries?: RegistryModel[]; + // services?: ServiceModel[]; + // dataRepositories?: DataRepositoryModel[]; + // tags?: TagModel[]; + // externalDatasets?: ExternalDatasetModel[]; + // isProfileLatestVersion?: Boolean; + // modified?: Date; +} + +// +// Persist +// +export interface DescriptionPersist extends BaseEntityPersist { + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts b/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts new file mode 100644 index 000000000..bf74fd1e3 --- /dev/null +++ b/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts @@ -0,0 +1,21 @@ +import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; +import { Guid } from "@common/types/guid"; +import { Reference } from "../reference/reference"; +import { Dmp } from "./dmp"; + + + +export interface DmpReference extends BaseEntity { + dmp?: Dmp; + reference?: Reference; + data: String; +} + +// +// Persist +// +export interface DmpPersist extends BaseEntityPersist { + dmpId: Guid; + referenceId: Guid; + data: String; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 9fb11b66e..31b20d191 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -10,6 +10,8 @@ import { UserInfoListingModel } from "../user/user-info-listing"; import { DmpDatasetProfile } from "./dmp-dataset-profile/dmp-dataset-profile"; import { DmpDynamicField } from "./dmp-dynamic-field"; import { DmpExtraField } from "./dmp-extra-field"; +import { BaseEntity } from '@common/base/base-entity.model'; +import { Description } from '../description/description'; export interface DmpModel { id: string; @@ -42,4 +44,37 @@ export interface DmpModel { export interface DmpBlueprint { id: string; label: string; +} + +export interface Dmp extends BaseEntity { + label: string; + description: String; + version: number; + status: DmpStatus; + groupId: String; + + + finalizedAt: Date; + blueprint: DmpBlueprint; + dmpDescriptions: Description[]; + + + lockable: boolean; + grant: GrantListingModel; + project: ProjectModel; + funder: FunderModel; + + datasets: DatasetWizardModel[]; + datasetsToBeFinalized: string[]; + profiles: DmpDatasetProfile[]; + organisations: OrganizationModel[]; + researchers: ResearcherModel[]; + associatedUsers: UserModel[]; + users: UserInfoListingModel[]; + creator: UserModel; + extraFields: Array; + dynamicFields: Array; + modified: Date; + extraProperties: Map; + language: String; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/reference/reference.ts b/dmp-frontend/src/app/core/model/reference/reference.ts index 0fdf421a7..b331f65f6 100644 --- a/dmp-frontend/src/app/core/model/reference/reference.ts +++ b/dmp-frontend/src/app/core/model/reference/reference.ts @@ -1,24 +1,24 @@ -import { ReferenceType } from "@app/core/common/enum/reference-type"; import { IsActive } from "@app/core/common/enum/is-active.enum"; +import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type"; +import { ReferenceType } from "@app/core/common/enum/reference-type"; import { SourceType } from "@app/core/common/enum/source-type"; import { UUID } from "crypto"; import { DmpModel } from "../dmp/dmp"; -import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type"; export interface Reference { id: UUID; - label: string; - type: ReferenceType; - description: string; - definition: Definition; - reference: string; - abbreviation: string; - source: string; - sourceType: SourceType; - isActive: IsActive; - createdAt: Date; - updatedAt: Date; - dmpReferences: DmpReference[]; + label: string; + type: ReferenceType; + description: string; + definition: Definition; + reference: string; + abbreviation: string; + source: string; + sourceType: SourceType; + isActive: IsActive; + createdAt: Date; + updatedAt: Date; + dmpReferences: DmpReference[]; } export interface Definition { @@ -27,35 +27,35 @@ export interface Definition { export interface Field { code: string; - dataType: ReferenceFieldDataType; - value: string; + dataType: ReferenceFieldDataType; + value: string; } export interface DmpReference { id: UUID; - dmp: DmpModel; - reference: Reference; - data: string; - createdAt: Date; - updatedAt: Date; + dmp: DmpModel; + reference: Reference; + data: string; + createdAt: Date; + updatedAt: Date; } // old fetcher export interface FetcherReference { id: string; - name: string; - pid: string; - pidTypeField: string; - uri: string; - description: string; - source: string; - count: string; - path: string; - host: string; - types: string; - firstName: string; - lastName: string; - tag: string; + name: string; + pid: string; + pidTypeField: string; + uri: string; + description: string; + source: string; + count: string; + path: string; + host: string; + types: string; + firstName: string; + lastName: string; + tag: string; } @@ -63,14 +63,14 @@ export interface FetcherReference { export interface ReferencePersist { id: UUID; - label: string; - type: ReferenceType; - description: string; - definition: DefinitionPersist; - reference: string; - abbreviation: string; - source: string; - sourceType: SourceType; + label: string; + type: ReferenceType; + description: string; + definition: DefinitionPersist; + reference: string; + abbreviation: string; + source: string; + sourceType: SourceType; } export interface DefinitionPersist { @@ -79,6 +79,6 @@ export interface DefinitionPersist { export interface FieldPersist { code: string; - dataType: ReferenceFieldDataType; - value: string; + dataType: ReferenceFieldDataType; + value: string; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/reference.lookup.ts b/dmp-frontend/src/app/core/query/reference.lookup.ts new file mode 100644 index 000000000..3d0e7db0d --- /dev/null +++ b/dmp-frontend/src/app/core/query/reference.lookup.ts @@ -0,0 +1,27 @@ +import { Lookup } from '@common/model/lookup'; +import { Guid } from '@common/types/guid'; +import { IsActive } from '../common/enum/is-active.enum'; +import { ReferenceType } from '../common/enum/reference-type'; +import { SourceType } from '../common/enum/source-type'; + +export class ReferenceLookup extends Lookup implements ReferenceFilter { + ids: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + sourceTypes: SourceType[]; + referenceTypes: ReferenceType[]; + + constructor() { + super(); + } +} + +export interface ReferenceFilter { + ids: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + sourceTypes: SourceType[]; + referenceTypes: ReferenceType[]; +} diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts index 39a0017db..30662946d 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts @@ -62,7 +62,7 @@ export class DmpBlueprintService { catchError((error: any) => throwError(error))); } - clone(id: string, reqFields: string[] = []): Observable { + clone(id: Guid, reqFields: string[] = []): Observable { const url = `${this.apiBase}/clone/${id}`; const options = { params: { f: reqFields } }; diff --git a/dmp-frontend/src/app/core/services/reference/reference.service.ts b/dmp-frontend/src/app/core/services/reference/reference.service.ts new file mode 100644 index 000000000..aa144c17e --- /dev/null +++ b/dmp-frontend/src/app/core/services/reference/reference.service.ts @@ -0,0 +1,103 @@ +import { Injectable } from '@angular/core'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { ReferenceType } from '@app/core/common/enum/reference-type'; +import { SourceType } from '@app/core/common/enum/source-type'; +import { Reference, ReferencePersist } from '@app/core/model/reference/reference'; +import { ReferenceLookup } from '@app/core/query/reference.lookup'; +import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; +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 ReferenceService { + + constructor( + private http: BaseHttpV2Service, + private configurationService: ConfigurationService, + private filterService: FilterService + ) { + } + + private get apiBase(): string { return `${this.configurationService.server}reference`; } + + query(q: ReferenceLookup): Observable> { + const url = `${this.apiBase}/query`; + return this.http.post>(url, q).pipe(catchError((error: any) => throwError(error))); + } + + getSingle(id: Guid, reqFields: string[] = []): Observable { + const url = `${this.apiBase}/${id}`; + const options = { params: { f: reqFields } }; + + return this.http + .get(url, options).pipe( + catchError((error: any) => throwError(error))); + } + + persist(item: ReferencePersist): Observable { + const url = `${this.apiBase}/persist`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + + delete(id: Guid): Observable { + const url = `${this.apiBase}/${id}`; + + return this.http + .delete(url).pipe( + catchError((error: any) => throwError(error))); + } + + // + // Autocomplete Commons + // + public getSingleAutocompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: SourceType[]): SingleAutoCompleteConfiguration { + return { + initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, [selectedItem])).pipe(map(x => x.items[0])), + displayFn: (item: Reference) => item.label, + titleFn: (item: Reference) => item.label, + valueAssign: (item: Reference) => item.id, + }; + }; + + public getMultipleAutoCompleteConfiguration(referenceTypes?: ReferenceType[], sourceTypes?: SourceType[]): MultipleAutoCompleteConfiguration { + return { + initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, searchQuery, excludedItems)).pipe(map(x => x.items)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(referenceTypes, sourceTypes, null, null, selectedItems)).pipe(map(x => x.items)), + displayFn: (item: Reference) => item.label, + titleFn: (item: Reference) => item.label, + valueAssign: (item: Reference) => item.id, + }; + } + + private buildAutocompleteLookup(referenceTypes?: ReferenceType[], sourceTypes?: SourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup { + const lookup: ReferenceLookup = new ReferenceLookup(); + lookup.page = { size: 100, offset: 0 }; + if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } + if (ids && ids.length > 0) { lookup.ids = ids; } + lookup.isActive = [IsActive.Active]; + lookup.project = { + fields: [ + nameof(x => x.id), + nameof(x => x.label) + ] + }; + if (referenceTypes && referenceTypes.length > 0) { lookup.referenceTypes = referenceTypes; } + if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; } + lookup.order = { items: [nameof(x => x.label)] }; + if (like) { lookup.like = this.filterService.transformLike(like); } + return lookup; + } +} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts index 8ea85c261..32f65bfea 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts @@ -1,21 +1,18 @@ -import { FieldDataEditorModel } from "./field-data-editor-model"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { FieldDataOptionEditorModel } from "./field-data-option-editor-model"; -import { DatasetsAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; import { UntypedFormGroup } from "@angular/forms"; +import { DatasetProfileInternalDmpEntitiesType } from "../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; +import { DatasetsAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; +import { FieldDataEditorModel } from "./field-data-editor-model"; export class DatasetsAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Datasets; public multiAutoComplete: boolean = false; - public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - public autoCompleteType: number; + //public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { const formGroup = this.formBuilder.group({ label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.label')) }], type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.type')) }], multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.multiAutoComplete')) }], - autoCompleteType: [{ value: this.autoCompleteType, disabled: (disabled && !skipDisable.includes('DatasetsAutoCompleteFieldDataEditorModel.autoCompleteType')) }] }) return formGroup; } @@ -24,7 +21,6 @@ export class DatasetsAutoCompleteFieldDataEditorModel extends FieldDataEditorMod this.label = item.label; this.type = item.type; this.multiAutoComplete = item.multiAutoComplete; - this.autoCompleteType = item.autoCompleteType; return this; } } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts index 42f310438..24bf7d582 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts @@ -7,7 +7,7 @@ import { UntypedFormGroup } from "@angular/forms"; export class DmpsAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Dmps; public multiAutoComplete: boolean = false; - public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); + //public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { const formGroup = this.formBuilder.group({ diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts index 8296ba864..991f4fc72 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts @@ -5,13 +5,11 @@ import { FieldDataEditorModel } from './field-data-editor-model'; export class FieldDataOptionEditorModel extends FieldDataEditorModel { public label: string; public value: string; - public source: string; buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { return new UntypedFormBuilder().group({ label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.label')) },[Validators.required]], value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.value')) },[Validators.required]], - source: [{ value: this.source, disabled: (disabled && !skipDisable.includes('FieldDataOptionEditorModel.source')) }] }); } @@ -19,7 +17,6 @@ export class FieldDataOptionEditorModel extends FieldDataEditorModel = []): UntypedFormGroup { const formGroup = this.formBuilder.group({ diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts index 7966ef9ec..27f9abc12 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts @@ -4,16 +4,19 @@ import { ResearchersFieldData } from '../../../../../core/model/dataset-profile- export class ResearchersDataEditorModel extends FieldDataEditorModel { public label: string; + public multiAutoComplete: boolean = false; buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ResearchersDataEditorModel.label')) }] + label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ResearchersDataEditorModel.label')) }], + multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] }); return formGroup; } fromModel(item: ResearchersFieldData): ResearchersDataEditorModel { this.label = item.label; + this.multiAutoComplete = item.multiAutoComplete; return this; } } diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts index 3606b96cd..8eeacd3d3 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts @@ -18,16 +18,16 @@ const routes: Routes = [ { path: 'new', canActivate: [AuthGuard], + component: DmpBlueprintEditorComponent, + canDeactivate: [PendingChangesGuard], data: { authContext: { permissions: [AppPermission.EditDmpBlueprint] }, ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.NEW-DESCRIPTION-TEMPLATE-TYPE' + title: 'BREADCRUMBS.NEW-DMP-BLUEPRINT' }) - }, - component: DmpBlueprintEditorComponent, - canDeactivate: [PendingChangesGuard], + } }, { path: 'clone/:cloneid', @@ -39,7 +39,7 @@ const routes: Routes = [ }, data: { ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.EDIT-DESCRIPTION-TEMPLATE-TYPE' + title: 'BREADCRUMBS.EDIT-DMP-BLUEPRINT' }), authContext: { permissions: [AppPermission.EditDmpBlueprint] @@ -57,7 +57,7 @@ const routes: Routes = [ }, data: { ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.EDIT-DESCRIPTION-TEMPLATE-TYPE' + title: 'BREADCRUMBS.EDIT-DMP-BLUEPRINT' }), authContext: { permissions: [AppPermission.EditDmpBlueprint] diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html index 5527b1612..765abfb72 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html @@ -46,7 +46,7 @@

{{'DMP-BLUEPRINT-EDITOR.FIELDS.SECTIONS' | translate}}

-
+
@@ -55,8 +55,11 @@ {{'DMP-BLUEPRINT-EDITOR.FIELDS.SECTION-PREFIX' | translate}} {{sectionIndex + 1}}
drag_indicator
-
- delete + +
+
@@ -81,7 +84,7 @@
{{'DMP-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELDS' | translate}} - + {{enumUtils.toDmpBlueprintSystemFieldTypeString(systemFieldType)}}