From c6508a008244a1847137504e77e575ed8156cbef Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Wed, 20 Dec 2023 09:20:38 +0200 Subject: [PATCH 1/5] description editor refactor - WIP --- dmp-frontend/src/app/app-routing.module.ts | 19 +- dmp-frontend/src/app/app.module.ts | 4 +- .../src/app/core/core-service.module.ts | 2 - .../model/dataset-profile-definition/rule.ts | 1 - .../description-template-persist.ts | 8 +- .../description-template.ts | 8 +- .../quick-wizard/quick-wizard.service.ts | 26 - .../final-preview/final-preview.component.ts | 2 +- .../dataset-profile-editor.component.ts | 2 +- ...late-editor-composite-field.component.html | 5 +- ...mplate-editor-composite-field.component.ts | 4 +- .../final-preview/final-preview.component.ts | 2 +- ...plate-editor-section-fieldset.component.ts | 12 +- ...ption-template-editor-section.component.ts | 4 +- .../description-template-editor.component.ts | 8 +- .../description-template-editor.model.ts | 8 +- .../dataset-create-wizard.component.html | 37 - .../dataset-create-wizard.component.scss | 11 - .../dataset-create-wizard.component.ts | 163 ---- .../dataset-create-wizard.model.ts | 43 - .../dataset-create-wizard.module.ts | 37 - .../dataset-create-wizard.routing.ts | 32 - .../dataset-dmp-selector.component.html | 20 - .../dataset-dmp-selector.component.scss | 0 .../dataset-dmp-selector.component.ts | 104 --- .../dataset-wizard.component.ts | 2 +- .../dataset-listing-item.component.ts | 4 +- .../overview/dataset-overview.component.ts | 4 +- .../dataset-editor.component.html | 107 --- .../dataset-editor.component.ts | 145 ---- .../description-editor.component.html | 150 ---- .../description-editor.resolver.ts | 67 -- .../app/ui/description/description.module.ts | 65 -- .../app/ui/description/description.routing.ts | 135 +--- ...cription-base-fields-editor.component.html | 58 ++ ...ription-base-fields-editor.component.scss} | 2 +- ...escription-base-fields-editor.component.ts | 90 +++ .../editor/description-editor.component.html | 143 ++++ .../description-editor.component.scss | 0 .../description-editor.component.ts | 649 +++++++++++++-- .../description-editor.model.ts | 32 +- .../editor/description-editor.module.ts | 37 + .../editor/description-editor.resolver.ts | 112 +++ .../editor/description-editor.routing.ts | 101 +++ .../description-editor.service.ts | 0 ...form-composite-field-dialog.component.html | 15 + .../form-composite-field-dialog.component.ts | 31 + .../form-composite-title.component.html | 25 + .../form-composite-title.component.scss | 31 + .../form-composite-title.component.ts | 21 + .../form-field-set.component.html | 54 ++ .../form-field-set.component.scss | 17 + .../form-field-set.component.ts | 115 +++ .../form-field/form-field.component.html | 473 +++++++++++ .../form-field/form-field.component.scss | 105 +++ .../form-field/form-field.component.ts | 764 ++++++++++++++++++ .../form-section/form-section.component.html | 176 ++++ .../form-section/form-section.component.scss | 46 ++ .../form-section/form-section.component.ts | 266 ++++++ .../description-form.component.html | 54 ++ .../description-form.component.scss | 47 ++ .../description-form.component.ts | 371 +++++++++ .../description-form.module.ts | 41 + .../models/visibility-rule-source.ts | 4 + .../models/visibility-rule.ts | 6 + .../models/visibility-rules-context.ts | 47 ++ .../visibility-rules.service.ts | 453 +++++++++++ ...-external-references-editor.component.html | 0 ...-external-references-editor.component.scss | 0 ...et-external-references-editor.component.ts | 0 ...ta-repository-dialog-editor.component.html | 0 ...ta-repository-dialog-editor.component.scss | 0 ...data-repository-dialog-editor.component.ts | 0 ...ernal-dataset-dialog-editor.component.html | 0 ...ernal-dataset-dialog-editor.component.scss | 0 ...xternal-dataset-dialog-editor.component.ts | 0 ...rnal-registry-dialog-editor.component.html | 0 ...rnal-registry-dialog-editor.component.scss | 0 ...ternal-registry-dialog-editor.component.ts | 0 ...ernal-service-dialog-editor.component.html | 0 ...ernal-service-dialog-editor.component.scss | 0 ...xternal-service-dialog-editor.component.ts | 0 .../form-progress-indication.component.html | 5 + .../form-progress-indication.component.scss | 16 + .../form-progress-indication.component.ts | 211 +++++ .../form-progress-indication.module.ts | 18 + .../prefill-description.component.html} | 0 .../prefill-description.component.scss} | 0 .../prefill-description.component.ts} | 0 .../models/toc-entry-type.enum.ts | 6 + .../table-of-contents/models/toc-entry.ts | 14 + .../table-of-contents-internal.html | 50 ++ .../table-of-contents-internal.scss | 33 + .../table-of-contents-internal.ts | 168 ++++ .../table-of-contents.component.html | 24 + .../table-of-contents.component.scss | 80 ++ .../table-of-contents.component.ts | 514 ++++++++++++ .../table-of-contents.module.ts | 15 + .../listing/description-listing.module.ts | 27 + .../listing/description-listing.routing.ts | 30 + .../description-listing-item.component.ts | 4 +- .../description-overview.component.ts | 4 +- .../overview/description-overview.module.ts | 6 +- .../overview/description-overview.routing.ts | 29 + .../dmp-listing-item.component.html | 4 +- .../dmp/overview/dmp-overview.component.html | 2 +- .../ui/dmp/overview/dmp-overview.component.ts | 4 +- .../form-composite-field-dialog.component.ts | 2 +- .../form-composite-field.component.ts | 2 +- .../form-field/form-field.component.ts | 2 +- .../form-progress-indication.component.ts | 2 +- .../form-section-inner.component.ts | 2 +- .../form-section/form-section.component.ts | 8 +- .../dataset-description-form.component.ts | 2 +- .../dataset-description-form.module.ts | 2 +- .../dataset-description.component.ts | 2 +- .../form-focus/form-focus.service.ts | 2 +- .../table-of-contents-internal.ts | 2 +- .../table-of-contents.module.ts | 2 +- .../table-of-contents.ts | 194 ++--- .../visibility-rules.service.ts | 742 +++++++++-------- .../src/app/ui/navbar/navbar.component.html | 1 - .../dataset-editor-wizard-model.ts | 40 - .../dataset-editor-wizard.component.html | 64 -- .../dataset-editor-wizard.component.scss | 10 - .../dataset-editor-wizard.component.ts | 130 --- .../quick-wizard-dataset-description-model.ts | 20 - .../dmp-editor/dmp-editor-wizard-model.ts | 56 -- .../dmp-editor-wizard.component.html | 94 --- .../dmp-editor-wizard.component.scss | 4 - .../dmp-editor/dmp-editor-wizard.component.ts | 141 ---- .../funder-editor-wizard.component.html | 48 -- .../funder-editor-wizard.component.scss | 0 .../funder-editor-wizard.component.ts | 67 -- .../grant-editor/grant-editor-wizard-model.ts | 51 -- .../grant-editor-wizard.component.html | 65 -- .../grant-editor-wizard.component.scss | 0 .../grant-editor-wizard.component.ts | 151 ---- .../project-editor-wizard.component.html | 57 -- .../project-editor-wizard.component.scss | 0 .../project-editor-wizard.component.ts | 69 -- .../quick-wizard-editor.component.html | 68 -- .../quick-wizard-editor.component.scss | 11 - .../quick-wizard-editor.component.ts | 203 ----- .../quick-wizard-editor.model.ts | 70 -- .../ui/quick-wizard/quick-wizard.module.ts | 48 -- .../ui/quick-wizard/quick-wizard.routing.ts | 44 - .../src/app/ui/sidebar/sidebar.component.ts | 2 - 148 files changed, 6125 insertions(+), 3246 deletions(-) delete mode 100644 dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.model.ts delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.module.ts delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.routing.ts delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.ts delete mode 100644 dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html rename dmp-frontend/src/app/ui/description/{dataset-wizard/dataset-editor/dataset-editor.component.scss => editor/description-base-fields-editor/description-base-fields-editor.component.scss} (98%) create mode 100644 dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-editor.component.html rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/description-editor.component.scss (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/description-editor.component.ts (72%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/description-editor.model.ts (97%) create mode 100644 dmp-frontend/src/app/ui/description/editor/description-editor.module.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/description-editor.service.ts (100%) create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule-source.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/dataset-external-references-editor.component.html (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/dataset-external-references-editor.component.scss (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/dataset-external-references-editor.component.ts (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/service/dataset-external-service-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/service/dataset-external-service-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard => editor}/external-references/editors/service/dataset-external-service-dialog-editor.component.ts (100%) create mode 100644 dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts rename dmp-frontend/src/app/ui/description/{dataset-wizard/prefill-dataset/prefill-dataset.component.html => editor/prefill-description/prefill-description.component.html} (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard/prefill-dataset/prefill-dataset.component.scss => editor/prefill-description/prefill-description.component.scss} (100%) rename dmp-frontend/src/app/ui/description/{dataset-wizard/prefill-dataset/prefill-dataset.component.ts => editor/prefill-description/prefill-description.component.ts} (100%) create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.html create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.scss create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts create mode 100644 dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts create mode 100644 dmp-frontend/src/app/ui/description/listing/description-listing.module.ts create mode 100644 dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts create mode 100644 dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard-model.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dataset-editor/quick-wizard-dataset-description-model.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard-model.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard-model.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/quick-wizard.module.ts delete mode 100644 dmp-frontend/src/app/ui/quick-wizard/quick-wizard.routing.ts diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index c8c054f8d..88977f96b 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -71,16 +71,6 @@ const appRoutes: Routes = [ } }, - - - { - path: 'datasetcreatewizard', - loadChildren: () => import('./ui/dataset-create-wizard/dataset-create-wizard.module').then(m => m.DatasetCreateWizardModule), - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASETCREATEWIZARD' - } - }, { path: 'about', @@ -100,14 +90,7 @@ const appRoutes: Routes = [ // } // }, - { - path: 'quick-wizard', - loadChildren: () => import('./ui/quick-wizard/quick-wizard.module').then(m => m.OuickWizardModule), - data: { - breadcrumb: true, - title: "GENERAL.TITLES.QUICK-WIZARD" - } - }, + { path: 'dataset-profiles', loadChildren: () => import('./ui/admin/dataset-profile/dataset-profile.module').then(m => m.DatasetProfileModule), diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index c99d555bd..fe62ce072 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -1,5 +1,5 @@ import { OverlayModule } from '@angular/cdk/overlay'; -import { HttpClient, HttpClientModule } from '@angular/common/http'; +import { HttpClientModule } from '@angular/common/http'; import { APP_INITIALIZER, LOCALE_ID, NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MAT_MOMENT_DATE_FORMATS, MatMomentDateModule } from '@angular/material-moment-adapter'; @@ -12,7 +12,6 @@ import { AppComponent } from '@app/app.component'; import { CoreServiceModule } from '@app/core/core-service.module'; import { NotificationModule } from '@app/library/notification/notification.module'; import { LoginModule } from '@app/ui/auth/login/login.module'; -import { DatasetCreateWizardModule } from '@app/ui/dataset-create-wizard/dataset-create-wizard.module'; // import { BreadcrumbModule } from '@app/ui/misc/breadcrumb/breadcrumb.module'; import { HelpContentModule } from '@app/ui/misc/help-content/help-content.module'; import { NavigationModule } from '@app/ui/misc/navigation/navigation.module'; @@ -143,7 +142,6 @@ export function InstallationConfigurationFactory(appConfig: ConfigurationService HelpContentModule, ReactiveFormsModule, FormsModule, - DatasetCreateWizardModule, NavbarModule, SidebarModule, NgcCookieConsentModule.forRoot(cookieConfig), diff --git a/dmp-frontend/src/app/core/core-service.module.ts b/dmp-frontend/src/app/core/core-service.module.ts index deca49579..e8e34418b 100644 --- a/dmp-frontend/src/app/core/core-service.module.ts +++ b/dmp-frontend/src/app/core/core-service.module.ts @@ -39,7 +39,6 @@ import { UiNotificationService } from './services/notification/ui-notification-s import { OrganisationService } from './services/organisation/organisation.service'; import { ProgressIndicationService } from './services/progress-indication/progress-indication-service'; import { ProjectService } from './services/project/project.service'; -import { QuickWizardService } from './services/quick-wizard/quick-wizard.service'; import { SearchBarService } from './services/search-bar/search-bar.service'; import { TimezoneService } from './services/timezone/timezone-service'; import { UnlinkAccountEmailConfirmationService } from './services/unlink-account-email-confirmation/unlink-account-email-confirmation.service'; @@ -119,7 +118,6 @@ export class CoreServiceModule { UserServiceOld, DmpInvitationService, DatasetExternalAutocompleteService, - QuickWizardService, OrganisationService, EmailConfirmationService, ContactSupportService, diff --git a/dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts b/dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts index b17886989..9e60b6de8 100644 --- a/dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts +++ b/dmp-frontend/src/app/core/model/dataset-profile-definition/rule.ts @@ -2,5 +2,4 @@ export class Rule { sourceField: string; targetField: string; requiredValue: any; - type: string; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts index b70557e07..77addc8e2 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts @@ -30,13 +30,13 @@ export interface DescriptionTemplateDefinitionPersist { export interface DescriptionTemplatePagePersist { - id: Guid; + id: string; ordinal: number; title: string; } export interface DescriptionTemplateSectionPersist { - id: Guid; + id: string; ordinal: number; defaultVisibility: boolean; multiplicity: boolean; @@ -49,7 +49,7 @@ export interface DescriptionTemplateSectionPersist { } export interface DescriptionTemplateFieldSetPersist { - id: Guid; + id: string; ordinal: number; numbering: string; title: string; @@ -62,7 +62,7 @@ export interface DescriptionTemplateFieldSetPersist { } export interface DescriptionTemplateFieldPersist { - id: Guid; + id: string; ordinal: number; schematics: string[]; defaultValue: string; 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 index 19ceb9801..e652a7041 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template.ts @@ -34,13 +34,13 @@ export interface DescriptionTemplateDefinition { export interface DescriptionTemplatePage { - id: Guid; + id: string; ordinal: number; title: string; } export interface DescriptionTemplateSection { - id: Guid; + id: string; ordinal: number; defaultVisibility: boolean; multiplicity: boolean; @@ -55,7 +55,7 @@ export interface DescriptionTemplateSection { } export interface DescriptionTemplateFieldSet { - id: Guid; + id: string; ordinal: number; numbering: string; title: string; @@ -68,7 +68,7 @@ export interface DescriptionTemplateFieldSet { } export interface DescriptionTemplateField { - id: Guid; + id: string; ordinal: number; numbering?: string; schematics?: string[]; diff --git a/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts b/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts deleted file mode 100644 index 4a6d3579d..000000000 --- a/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { QuickWizardEditorWizardModel } from '../../../ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model'; -import { BaseHttpService } from '../http/base-http.service'; -import { DatasetCreateWizardModel } from '../../../ui/dataset-create-wizard/dataset-create-wizard.model'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class QuickWizardService { - private actionUrl: string; - private headers: HttpHeaders; - - constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'quick-wizard/'; - } - - createQuickWizard(quickWizard: QuickWizardEditorWizardModel): Observable { - return this.http.post(this.actionUrl, quickWizard, { headers: this.headers }); - } - - createQuickDatasetWizard(datasetCreateWizardModel: DatasetCreateWizardModel): Observable { - return this.http.post(this.actionUrl + 'datasetcreate', datasetCreateWizardModel, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts index 25afc4373..d2ba708e6 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit} from '@angular/core'; import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; @Component({ diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index 75a254984..3ba2002a4 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -33,7 +33,7 @@ import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FieldSetEditorModel } from '../admin/field-set-editor-model'; import { Guid } from '@common/types/guid'; import { FieldEditorModel } from '../admin/field-editor-model'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; import { CdkStep, StepperSelectionEvent } from '@angular/cdk/stepper'; import { DatasetDescriptionCompositeFieldEditorModel, DatasetDescriptionFieldEditorModel, DatasetDescriptionSectionEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; import { Rule } from '@app/core/model/dataset-profile-definition/rule'; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html index 4318649bd..89762f754 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html @@ -92,8 +92,9 @@
- - + +
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts index 7775b1e19..3b9a313f4 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts @@ -341,7 +341,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon addNewField() { const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create(); + field.id = Guid.create().toString(); field.ordinal = (this.form.get('fields') as UntypedFormArray).length; @@ -494,7 +494,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon } const field = { - id: Guid.create(), + id: Guid.create().toString(), ordinal: targetOrdinal, validations: [], includeInExport: true diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts index 25afc4373..d2ba708e6 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts @@ -1,6 +1,6 @@ import { Component, Input, OnInit} from '@angular/core'; import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; @Component({ diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts index 77a8e8e44..c3b1d5580 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts @@ -22,7 +22,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit @Input() datasetProfileId?: string; - @Output() selectedEntryId = new EventEmitter(); + @Output() selectedEntryId = new EventEmitter(); @Output() dataNeedsRefresh = new EventEmitter(); @Output() removeFieldSet = new EventEmitter(); @Output() addNewFieldSet = new EventEmitter(); @@ -101,11 +101,11 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit - private _selectedFieldSetId: Guid = null; + private _selectedFieldSetId: string = null; get selectedFieldSetId() { return this._selectedFieldSetId; } - set selectedFieldSetId(id: Guid) { + set selectedFieldSetId(id: string) { if (id === this._selectedFieldSetId) return; this._selectedFieldSetId = id; @@ -140,7 +140,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit } else { // console.warn('!not found numbering'); } - this._selectedFieldSetId = Guid.parse(this.tocentry.id); + this._selectedFieldSetId = this.tocentry.id; // this._scrollToElement(this.selectedFieldSetId); this.scroller.next(this.tocentry.id); @@ -194,13 +194,13 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit addFieldSetAfter(afterOrdinal: number, afterIndex: number): void { const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create(); + field.id = Guid.create().toString(); field.ordinal = 0;//first filed in the fields list const fieldForm = field.buildForm(); //give fieldset id and ordinal const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(); - const fieldSetId = Guid.create(); + const fieldSetId = Guid.create().toString(); fieldSet.id = fieldSetId; fieldSet.ordinal = afterOrdinal < 0 ? 0 : afterOrdinal; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts index 77df70aed..90d7edc70 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section/description-template-editor-section.component.ts @@ -28,10 +28,10 @@ export class DescriptionTemplateEditorSectionComponent extends BaseComponent imp fieldSet.ordinal = (this.form.get('fieldSets') as UntypedFormArray).length; const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); - field.id = Guid.create(); + field.id = Guid.create().toString(); field.ordinal = 0;//first field in fields fieldSet.fields.push(field); - fieldSet.id = Guid.create(); + fieldSet.id = Guid.create().toString(); const fieldsetsArray = this.form.get('fieldSets') as UntypedFormArray; fieldsetsArray.push(fieldSet.buildForm()); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index e75c7eaed..5d4848553 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -566,7 +566,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor -
-
-

{{ 'QUICKWIZARD.CREATE-ADD.ADD.DATASET-WIZARD' | translate }}

-

{{ 'QUICKWIZARD.CREATE-ADD.ADD.POST-SELECTION-INFO' | translate }}

- - - {{'DATASET-CREATE-WIZARD.FIRST-STEP.TITLE'| translate}} -
- - -
-
-
-
-
-
-
-
- - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}} - -
- - -
- -
-
-
-
- diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.scss b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.scss deleted file mode 100644 index ea2e9bba1..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.scss +++ /dev/null @@ -1,11 +0,0 @@ -.saveAndFinalizeButton{ - float:right; -} -.finalizeButton{ - float: right; - text-transform: uppercase; -} -.saveButton{ - float:right; - margin-right: 15px; -} diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts deleted file mode 100644 index 931cd2e2f..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts +++ /dev/null @@ -1,163 +0,0 @@ - -import { Component, OnInit, ViewChild } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatStepper } from '@angular/material/stepper'; -import { Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { QuickWizardService } from '@app/core/services/quick-wizard/quick-wizard.service'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { DatasetCreateWizardModel } from '@app/ui/dataset-create-wizard/dataset-create-wizard.model'; -import { DatasetEditorWizardComponent } from '@app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'dataset-create-wizard.component', - templateUrl: 'dataset-create-wizard.component.html', - styleUrls: ['./dataset-create-wizard.component.scss'], -}) -export class DatasetCreateWizard extends CheckDeactivateBaseComponent implements OnInit { //IBreadCrumbComponent - //breadCrumbs: Observable; - @ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent; - isLinear = false; - isNew = true; - isSubmitted = false; - formGroup: UntypedFormGroup; - - - datasetCreateWizardModel: DatasetCreateWizardModel; - @ViewChild('stepper', { static: true }) stepper: MatStepper; - - constructor( - private router: Router, - private formBuilder: UntypedFormBuilder, - public quickWizardService: QuickWizardService, - public language: TranslateService, - private uiNotificationService: UiNotificationService, - private dialog: MatDialog - ) { - super(); - } - - ngOnInit() { - this.datasetCreateWizardModel = new DatasetCreateWizardModel(); - this.formGroup = this.datasetCreateWizardModel.buildForm(); - this.language.get('NAV-BAR.DATASET-DESCRIPTION-WIZARD').pipe(takeUntil(this._destroyed)).subscribe(x => { - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: 'Dashboard', - // label: x, - // url: '/datasetcreatewizard' - // }] - // ); - }) - - } - - save() { - if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).length > 0) { - for (let control of (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).controls) { - control.get('status').setValue(DatasetStatus.Draft); - } - // this.onSubmitSave(); - const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id; - this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(dmpId) - ); - } else { - return; - } - } - - saveFinalize() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (!this.isFormValid()) { return; } - if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).length > 0) { - for (let control of (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).controls) { - control.get('status').setValue(DatasetStatus.Finalized); - } - this.onSubmitSaveAndFinalize(); - } else { - return; - } - } - }); - } - - // onSubmitSave() { - // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - // data: { - // message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'), - // confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - // cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE') - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // this.datasetEditorWizardComponent.addDataset(); - // } else if (result === false) { - // this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => this.onCallbackSuccess() - // ) - // } - // }); - // } - - onSubmitSaveAndFinalize() { - const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id; - this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(dmpId) - ); - } - - hasDatasets() { - if ((this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).length > 0) { - return true; - } else { - return false; - } - } - - public isFormValid() { - return this.formGroup.valid; - } - - onCallbackSuccess(dmpId: string): void { - this.isSubmitted = true; - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans/overview/' + dmpId]); - } - - isActive(step: string): boolean { - switch (step) { - case 'step1': - return this.stepper.selectedIndex == 0; - case 'step2': - return this.stepper.selectedIndex == 1; - } - } - - canDeactivate(): boolean { - return this.isSubmitted || !this.formGroup.dirty; - } -} diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.model.ts b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.model.ts deleted file mode 100644 index a331a0f01..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.model.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { DmpCreateWizardFormModel } from '@app/core/model/dmp/dmp-create-wizard/dmp-create-wizard-form.model'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { DatasetEditorWizardModel } from '@app/ui/quick-wizard/dataset-editor/dataset-editor-wizard-model'; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - - -export class DatasetCreateWizardModel { - public dmpMeta: DmpCreateWizardFormModel; - public datasets: DatasetEditorWizardModel; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - - fromModelDmp(item: DmpCreateWizardFormModel): DatasetCreateWizardModel { - this.dmpMeta.fromModel(item); - return this; - } - - fromModelDataset(item: DatasetWizardEditorModel[]): DatasetCreateWizardModel { - this.datasets.fromModel(item); - return this; - } - - buildForm(context: ValidationContext = null): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - const formBuilder = new UntypedFormBuilder(); - const formGroup = formBuilder.group({ - dmpMeta: new DmpCreateWizardFormModel().buildForm(), - datasets: new DatasetEditorWizardModel().buildForm() - }); - - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); - baseContext.validation.push({ key: 'status', validators: [BackendErrorValidator(this.validationErrorModel, 'status')] }); - - return baseContext; - } -} diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.module.ts b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.module.ts deleted file mode 100644 index 7bac0da77..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.module.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; -import { DatasetCreateWizard } from '@app/ui/dataset-create-wizard/dataset-create-wizard.component'; -import { DatasetCreateWizardRoutingModule } from '@app/ui/dataset-create-wizard/dataset-create-wizard.routing'; -import { DatasetDmpSelector } from '@app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component'; -import { DatasetDescriptionFormModule } from '@app/ui/misc/dataset-description-form/dataset-description-form.module'; -import { OuickWizardModule } from '@app/ui/quick-wizard/quick-wizard.module'; -import { QuickWizardRoutingModule } from '@app/ui/quick-wizard/quick-wizard.routing'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [ - DatasetCreateWizardRoutingModule, - CommonUiModule, - CommonFormsModule, - AutoCompleteModule, - FormattingModule, - UrlListingModule, - ConfirmationDialogModule, - QuickWizardRoutingModule, - DatasetDescriptionFormModule, - OuickWizardModule, - ], - declarations: [ - DatasetCreateWizard, - DatasetDmpSelector, - ], - providers: [ - CanDeactivateGuard - ] -}) -export class DatasetCreateWizardModule { } diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.routing.ts b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.routing.ts deleted file mode 100644 index 97f9a4fb8..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.routing.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { DatasetCreateWizard } from './dataset-create-wizard.component'; -import { DatasetDmpSelector } from './dmp-selector/dataset-dmp-selector.component'; -import { CanDeactivateGuard } from '../../library/deactivate/can-deactivate.guard'; -import { AuthGuard } from '@app/core/auth-guard.service'; - -const routes: Routes = [ - { - path: '', - component: DatasetCreateWizard, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - canDeactivate: [CanDeactivateGuard] - }, - { - path: '', - component: DatasetDmpSelector, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class DatasetCreateWizardRoutingModule { } diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.html b/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.html deleted file mode 100644 index 70f480dda..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
- -
- - - - -
-
- - - - {{datasetProfile.label}} - - - -
-
-
diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.scss b/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.ts b/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.ts deleted file mode 100644 index e16b96423..000000000 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dmp-selector/dataset-dmp-selector.component.ts +++ /dev/null @@ -1,104 +0,0 @@ - -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatStepper } from '@angular/material/stepper'; -import { ActivatedRoute, Router } from '@angular/router'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { DatePipe } from "@angular/common"; -import { TranslateService } from "@ngx-translate/core"; - -@Component({ - selector: 'dataset-dmp-selector-component', - templateUrl: 'dataset-dmp-selector.component.html', - styleUrls: ['./dataset-dmp-selector.component.scss'], -}) - -export class DatasetDmpSelector extends BaseComponent implements OnInit { - - dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - @Input() formGroup: UntypedFormGroup; - @Input() datasetFormGroup: UntypedFormGroup; - @Input() stepper: MatStepper; - formControl: UntypedFormControl; - availableProfiles: DatasetProfileModel[] = []; - - constructor( - public dmpService: DmpService, - private datasetWizardService: DatasetWizardService, - private language: TranslateService, - private datepipe: DatePipe - ) { - super(); - } - - ngOnInit() { - this.dmpAutoCompleteConfiguration = { - filterFn: this.searchDmp.bind(this), - initialItems: (extraData) => this.searchDmp(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => this.language.instant('QUICKWIZARD.CREATE-ADD.ADD.CREATED') + " " + this.datepipe.transform(item['creationTime'], 'yyyy-MM-dd') - }; - - this.formGroup.get('dmp').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (x) { this.loadDatasetProfiles(); } - else { - this.availableProfiles = []; - this.formGroup.get('datasetProfile').reset(); - } - }); - - this.formGroup.get('datasetProfile').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - (this.datasetFormGroup.get('datasetsList') as UntypedFormArray).controls.length = 0; - }); - } - - searchDmp(query: string): Observable { - const fields: Array = new Array(); - fields.push('-created'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.status = DmpStatus.Draft; - dmpDataTableRequest.criteria.like = query; - - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete").pipe( - map(y => y.data)); - } - - loadDatasetProfiles() { - const datasetProfileRequestItem: RequestItem = new RequestItem(); - datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - datasetProfileRequestItem.criteria.id = this.formGroup.get('dmp').value.id; - if (datasetProfileRequestItem.criteria.id) { - this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.availableProfiles = items; - if (this.availableProfiles.length === 1) { - this.formGroup.get('datasetProfile').patchValue(this.availableProfiles[0]); - this.stepper.next(); - } - }); - } - } - - datasetChanged($event) { - this.stepper.next(); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 0bc56e515..370100898 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -50,7 +50,7 @@ import { LinkToScroll, TableOfContents } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; -import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { FormService } from '@common/forms/form-service'; import { diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts index 2b3aded48..fa61a8994 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts @@ -85,11 +85,11 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit getItemLink(): string[] { // return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`]; - return this.isPublic ? ['/datasets/publicOverview/' + this.dataset.id] : ['/datasets/overview/' + this.dataset.id]; + return this.isPublic ? ['/datasets/overview/public/' + this.dataset.id] : ['/datasets/overview/' + this.dataset.id]; } getDmpLink(): string[] { - return this.isPublic ? [`/explore-plans/publicOverview/${this.dataset.dmpId}`] : [`/plans/edit/${this.dataset.dmpId}`]; + return this.isPublic ? [`/explore-plans/overview/public/${this.dataset.dmpId}`] : [`/plans/edit/${this.dataset.dmpId}`]; } downloadPDF(dataset: DatasetListingModel): void { diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts index 5fcb6c281..c2d7f854a 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts @@ -123,7 +123,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { this.users = this.dataset.dmp.users; // const breadCrumbs = []; // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); - // breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/publicOverview/' + this.dataset.id }); + // breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/overview/public/' + this.dataset.id }); // this.breadCrumbs = observableOf(breadCrumbs); }, (error: any) => { if (error.status === 404) { @@ -290,7 +290,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { dmpClicked(dmp: DmpOverviewModel) { if (this.isPublicView) { - this.router.navigate(['/explore-plans/publicOverview/' + dmp.id]); + this.router.navigate(['/explore-plans/overview/public/' + dmp.id]); } else { this.router.navigate(['/plans/overview/' + dmp.id]); } diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html deleted file mode 100644 index c56c214e4..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.html +++ /dev/null @@ -1,107 +0,0 @@ -
-
-

{{'DATASET-EDITOR.TITLE.INTRO' | translate}}

- {{'DATASET-EDITOR.TITLE.INTRO-TIP' | translate}} -
-
- -
-
-
1.1 {{'DATASET-EDITOR.FIELDS.TITLE' | translate}}*
- - -
- - - {{formGroup.get('label').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
- -
-
-
1.2 {{'DATASET-EDITOR.FIELDS.DESCRIPTION' | translate}}
- {{'DATASET-EDITOR.HINT.DESCRIPTION' | translate}} - -
- - -
- {{formGroup.get('description').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - - -
1.4 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
-
- - - -
- {{profile.label}} -
-
-
- {{formGroup.get('profile').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts deleted file mode 100644 index e9b339ad4..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { Router } from '@angular/router'; -import { BaseComponent } from '@common/base/base.component'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; -import { TranslateService } from '@ngx-translate/core'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { takeUntil } from 'rxjs/operators'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { MatDialog } from '@angular/material/dialog'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { Guid } from '@common/types/guid'; -import { nameof } from 'ts-simple-nameof'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; - -@Component({ - selector: 'app-dataset-editor-component', - templateUrl: 'dataset-editor.component.html', - styleUrls: ['./dataset-editor.component.scss'] -}) -export class DatasetEditorComponent extends BaseComponent { - - @Input() formGroup: UntypedFormGroup; - // @Input() formGroup: FormGroup = null; - @Input() availableProfiles: DatasetProfileModel[]; - @Input() dmpId: string; - showUri: boolean = false; - dmpText: string = null; - viewOnly = false; - - constructor( - private router: Router, - private dmpBlueprintService: DmpBlueprintService, - private dialog: MatDialog, - private guidedTourService: GuidedTourService, - private language: TranslateService - ) { super(); } - - public dashboardTourDmp: GuidedTour = { - tourId: 'only-dmp-tour', - useOrb: true, - steps: [ - { - title: this.dmpText, - content: 'Step 1', - orientation: Orientation.Bottom, - highlightPadding: 3, - isStepUnique: true, - customTopOffset: 8 - } - ] - }; - - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); - const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; - const blueprintId = this.formGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, - [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if(section.hasTemplates){ - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if(this.formGroup.get('dmp').value.datasets != null){ - for(let dataset of this.formGroup.get('dmp').value.datasets){ - if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ - count++; - } - } - if(count === foundTemplate.maxMultiplicity){ - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - } - else{ - this.formGroup.get('profile').setValue(profile); - } - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - }); - } - - getDmpText(): string { - return this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' + - this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' + - this.language.instant('DMP-LISTING.LINK-ZENODO') + ' ' + - this.language.instant('DMP-LISTING.GET-IDEA'); - } - - setDashboardTourDmp(label: string): void { - this.dashboardTourDmp.steps[0].title = this.getDmpText(); - this.dashboardTourDmp.steps[0].selector = '.dmp-tour-' + label; - } - - public restartTour(label: string): void { - this.setDashboardTourDmp(label); - this.guidedTourService.startTour(this.dashboardTourDmp); - - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - public compareWith(object1: any, object2: any) { - return object1 && object2 && object1.id === object2.id; - } -} diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html b/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html deleted file mode 100644 index 33a12bf33..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.html +++ /dev/null @@ -1,150 +0,0 @@ -
-
-
- - -
-
-
-
-
- -
{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}}
-
{{'DMP-EDITOR.TITLE.EDIT-DESCRIPTION' | translate}}
-
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
- -
{{'DMP-EDITOR.TITLE.PREVIEW-DATASET' | translate}}
-
-
-
{{'DATASET-LISTING.TOOLTIP.TO-DMP' | translate}}
-
: {{ formGroup.get('dmp').value.label }}
- -
-
-
-
- - - - - - -
- - - -
- -
-
- - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
- chevron_left - {{'DATASET-WIZARD.ACTIONS.BACK-TO' | translate}} -
-
{{'DATASET-LISTING.TOOLTIP.DMP' | translate}}
-
-
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
-
-
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
-
-
- -
-
-
-
- - -
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
-
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
- -
-
- -
-
-
- - -
-
-
-
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts deleted file mode 100644 index 633ed936d..000000000 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.resolver.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; -import { Description, DescriptionField, DescriptionReference, DescriptionTag, PropertyDefinition } from '@app/core/model/description/description'; -import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; -import { Reference } from '@app/core/model/reference/reference'; -import { Tag } from '@app/core/model/tag/tag'; -import { DescriptionService } from '@app/core/services/description/description.service'; -import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; -import { BaseEditorResolver } from '@common/base/base-editor.resolver'; -import { Guid } from '@common/types/guid'; -import { takeUntil, tap } from 'rxjs/operators'; -import { nameof } from 'ts-simple-nameof'; - -@Injectable() -export class DescriptionEditorResolver extends BaseEditorResolver { - - constructor(private descriptionService: DescriptionService, private breadcrumbService: BreadcrumbService) { - super(); - } - - public static lookupFields(): string[] { - return [ - ...BaseEditorResolver.lookupFields(), - nameof(x => x.id), - nameof(x => x.label), - nameof(x => x.status), - nameof(x => x.description), - nameof(x => x.status), - [nameof(x => x.dmp), nameof(x => x.id)].join('.'), - - [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), - - [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), - - [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.key)].join('.'), - [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.value)].join('.'), - - [nameof(x => x.descriptionTags), nameof(x => x.id),].join('.'), - [nameof(x => x.descriptionTags), nameof(x => x.tag), nameof(x => x.label)].join('.'), - - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), - [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), - nameof(x => x.createdAt), - nameof(x => x.hash), - nameof(x => x.isActive) - ] - } - - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - - const fields = [ - ...DescriptionEditorResolver.lookupFields() - ]; - const id = route.paramMap.get('id'); - // const cloneid = route.paramMap.get('cloneid'); - if (id != null) { - return this.descriptionService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); - } - //TODO: check this - // else if (cloneid != null) { - // return this.descriptionService.clone(Guid.parse(cloneid), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); - // } - } -} diff --git a/dmp-frontend/src/app/ui/description/description.module.ts b/dmp-frontend/src/app/ui/description/description.module.ts index 6d15033b4..d24d8bab1 100644 --- a/dmp-frontend/src/app/ui/description/description.module.ts +++ b/dmp-frontend/src/app/ui/description/description.module.ts @@ -1,84 +1,19 @@ import { NgModule } from '@angular/core'; import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; -import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; -// import { DescriptionEditorComponent } from '@app/ui/description/description-wizard/description-editor/description-editor.component'; -// import { DescriptionWizardComponent } from '@app/ui/description/description-wizard/description-wizard.component'; -// import { DescriptionExternalReferencesEditorComponent } from '@app/ui/description/description-wizard/external-references/description-external-references-editor.component'; -// import { DescriptionExternalDataRepositoryDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/data-repository/description-external-data-repository-dialog-editor.component'; -// import { DescriptionExternalDescriptionDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/external-description/description-external-description-dialog-editor.component'; -// import { DescriptionExternalRegistryDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/registry/description-external-registry-dialog-editor.component'; -// import { DescriptionExternalServiceDialogEditorComponent } from '@app/ui/description/description-wizard/external-references/editors/service/description-external-service-dialog-editor.component'; -// import { PrefillDescriptionComponent } from "@app/ui/description/description-wizard/prefill-description/prefill-description.component"; import { DescriptionRoutingModule } from '@app/ui/description/description.routing'; -// import { DescriptionCriteriaComponent } from '@app/ui/description/listing/criteria/description-criteria.component'; -// import { DescriptionUploadDialogue } from '@app/ui/description/listing/criteria/description-upload-dialogue/description-upload-dialogue.component'; -import { DescriptionListingComponent } from '@app/ui/description/listing/description-listing.component'; -import { DescriptionListingItemComponent } from '@app/ui/description/listing/listing-item/description-listing-item.component'; -// import { DescriptionDescriptionFormModule } from '@app/ui/misc/description-description-form/description-description-form.module'; -// import { TableOfContentsModule } from '@app/ui/misc/description-description-form/tableOfContentsMaterial/table-of-contents.module'; -import { ExternalSourcesModule } from '@app/ui/misc/external-sources/external-sources.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; -import { DescriptionCopyDialogModule } from './description-copy-dialog/description-copy-dialog.module'; -import { DescriptionOverviewModule } from './overview/description-overview.module'; -import { DescriptionEditorComponent } from './dataset-wizard/description-editor.component'; -// import { FormProgressIndicationModule } from '../misc/description-description-form/components/form-progress-indication/form-progress-indication.module'; -// import { DescriptionCopyDialogModule } from './description-wizard/description-copy-dialogue/description-copy-dialogue.module'; -// import { DescriptionCriteriaDialogComponent } from './listing/criteria/description-criteria-dialogue/description-criteria-dialog.component'; -// import { DescriptionOverviewModule } from './overview/description-overview.module'; @NgModule({ imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, FormattingModule, - ConfirmationDialogModule, - AutoCompleteModule, - ExternalSourcesModule, - ExportMethodDialogModule, - // DescriptionDescriptionFormModule, - // TableOfContentsModule, - AngularStickyThingsModule, DescriptionRoutingModule, - FormValidationErrorsDialogModule, - // DescriptionCopyDialogModule, - // DescriptionOverviewModule, - // FormProgressIndicationModule, - RichTextEditorModule, - - DescriptionCopyDialogModule, - DescriptionOverviewModule, ], declarations: [ - DescriptionListingComponent, - // DescriptionCriteriaComponent, - // DescriptionWizardComponent, - DescriptionEditorComponent, - // DescriptionExternalReferencesEditorComponent, - // DescriptionExternalDataRepositoryDialogEditorComponent, - // DescriptionExternalDescriptionDialogEditorComponent, - // DescriptionExternalRegistryDialogEditorComponent, - // DescriptionExternalServiceDialogEditorComponent, - // DescriptionUploadDialogue, - DescriptionListingItemComponent, - // DescriptionCriteriaDialogComponent, - // PrefillDescriptionComponent ], exports: [ - // DescriptionExternalReferencesEditorComponent, - // DescriptionExternalDataRepositoryDialogEditorComponent, - // DescriptionExternalDescriptionDialogEditorComponent, - // DescriptionExternalRegistryDialogEditorComponent, - // DescriptionExternalServiceDialogEditorComponent, - // DescriptionEditorComponent, - // DescriptionDescriptionFormModule ] }) export class DescriptionModule { } diff --git a/dmp-frontend/src/app/ui/description/description.routing.ts b/dmp-frontend/src/app/ui/description/description.routing.ts index 08f511956..2b2b32dc9 100644 --- a/dmp-frontend/src/app/ui/description/description.routing.ts +++ b/dmp-frontend/src/app/ui/description/description.routing.ts @@ -1,136 +1,35 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AuthGuard } from '../../core/auth-guard.service'; // import { DescriptionWizardComponent } from './description-wizard/description-wizard.component'; -import { DescriptionListingComponent } from './listing/description-listing.component'; -import { DescriptionOverviewComponent } from './overview/description-overview.component'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; -import { DescriptionEditorComponent } from './dataset-wizard/description-editor.component'; -import { AppPermission } from '@app/core/common/enum/permission.enum'; -import { DescriptionEditorResolver } from './dataset-wizard/description-editor.resolver'; -import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; // import { DescriptionOverviewComponent } from './overview/description-overview.component'; -import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; const routes: Routes = [ { - path: '', - component: DescriptionListingComponent, - // canActivate: [AuthGuard], + path: 'overview', + loadChildren: () => import('./overview/description-overview.module').then(m => m.DescriptionOverviewModule), data: { breadcrumb: true - }, - }, - { - path: 'dmp/:dmpId', - component: DescriptionListingComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, - { - path: 'overview/:id', - component: DescriptionOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - }, - { - path: 'publicOverview/:publicId', - component: DescriptionOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - }, - { - path: 'edit/:id', - canActivate: [AuthGuard], - component: DescriptionEditorComponent, - canDeactivate: [PendingChangesGuard], - resolve: { - 'entity': DescriptionEditorResolver - }, - data: { - ...BreadcrumbService.generateRouteDataConfiguration({ - title: 'BREADCRUMBS.EDIT-DESCRIPTION' - }), - authContext: { - permissions: [AppPermission.EditDescription] - } } }, - // { - // path: 'new/:dmpId/:dmpSectionIndex', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-NEW' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - - // { - // path: 'edit/:id/finalize', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // public: false, - // title: 'GENERAL.TITLES.DATASET-EDIT', - // finalize: true - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'publicEdit/:publicId', - // component: DescriptionWizardComponent, - // //canActivate: [AuthGuard], - // data: { - // public: true, - // title: 'GENERAL.TITLES.DATASET-PUBLIC-EDIT' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'new', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-NEW' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'copy/:id', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-COPY' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - // { - // path: 'profileupdate/:updateId', - // component: DescriptionWizardComponent, - // canActivate: [AuthGuard], - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.DATASET-UPDATE' - // }, - // canDeactivate:[CanDeactivateGuard] - // }, - + { + path: 'edit', + loadChildren: () => import('./editor/description-editor.module').then(m => m.DescriptionEditorModule), + data: { + breadcrumb: true + } + }, + { + path: '', + loadChildren: () => import('./listing/description-listing.module').then(m => m.DescriptionListingModule), + data: { + breadcrumb: true + }, + }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule], - providers: [DescriptionEditorResolver] + providers: [] }) export class DescriptionRoutingModule { } diff --git a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html new file mode 100644 index 000000000..db8d56585 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html @@ -0,0 +1,58 @@ +
+
+

{{'DATASET-EDITOR.TITLE.INTRO' | translate}}

+ {{'DATASET-EDITOR.TITLE.INTRO-TIP' | translate}} +
+
+ +
+
+
1.1 {{'DATASET-EDITOR.FIELDS.TITLE' | translate}}*
+
+ + + {{formGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+
+ +
+
+
1.2 {{'DATASET-EDITOR.FIELDS.DESCRIPTION' | translate}}
+ {{'DATASET-EDITOR.HINT.DESCRIPTION' | translate}} +
+ + +
+ {{formGroup.get('description').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+
+
+
+ + + + +
1.4 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
+ +
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.scss similarity index 98% rename from dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.scss index b006bc845..76fe2f2df 100644 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/dataset-editor/dataset-editor.component.scss +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.scss @@ -1,4 +1,4 @@ -.dataset-editor { +.description-base-fields-editor { .intro { text-align: left; font-weight: 400; diff --git a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts new file mode 100644 index 000000000..478f45437 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts @@ -0,0 +1,90 @@ +import { Component, Input } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { BaseComponent } from '@common/base/base.component'; + +@Component({ + selector: 'app-description-base-fields-editor-component', + templateUrl: 'description-base-fields-editor.component.html', + styleUrls: ['./description-base-fields-editor.component.scss'] +}) +export class DescriptionBaseFieldsEditorComponent extends BaseComponent { + + @Input() formGroup: UntypedFormGroup; + @Input() availableDescriptionTemplates: DescriptionTemplate[]; + @Input() dmpId: string; + viewOnly = false; //TODO: not used. + + constructor( + ) { super(); } + + checkMinMax(event, profile: DescriptionTemplate) { + //TODO: Add logic for validating description templates. + // event.stopPropagation(); + // const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; + // const blueprintId = this.formGroup.get('dmp').value.profile.id; + // this.dmpBlueprintService.getSingle(blueprintId, + // [ + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), + + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), + + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), + // ] + // ) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(result => { + // const section = result.definition.sections[dmpSectionIndex]; + // if(section.hasTemplates){ + // const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); + // if (foundTemplate !== undefined) { + // let count = 0; + // if(this.formGroup.get('dmp').value.datasets != null){ + // for(let dataset of this.formGroup.get('dmp').value.datasets){ + // if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ + // count++; + // } + // } + // if(count === foundTemplate.maxMultiplicity){ + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), + // message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') + // }, maxWidth: '30em' + // }); + // } + // else{ + // this.formGroup.get('profile').setValue(profile); + // } + // } + // } + // else { + // this.formGroup.get('profile').setValue(profile); + // } + // } + // else { + // this.formGroup.get('profile').setValue(profile); + // } + // }); + } + + public compareWith(object1: any, object2: any) { + return object1 && object2 && object1.id === object2.id; + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html new file mode 100644 index 000000000..209e71324 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html @@ -0,0 +1,143 @@ +
+
+
+ + +
+
+
+
+
+ +
{{'DESCRIPTION-EDITOR.TITLE.ADD-DATASET' | translate}}
+
{{'DESCRIPTION-EDITOR.TITLE.EDIT-DESCRIPTION' | translate}}
+
{{ formGroup.get('label').value }} ({{'DESCRIPTION-EDITOR.CHANGES' | translate}})
+
+ +
{{'DESCRIPTION-EDITOR.TITLE.PREVIEW-DATASET' | translate}}
+
+
+
{{'DESCRIPTION-EDITOR.TOOLTIP.TO-DMP' | translate}}
+
: {{ item.dmp.label }}
+ +
+
+
+
+ + + + + + +
+ + + +
+ +
+
+ + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+ chevron_left + {{'DESCRIPTION-EDITOR.ACTIONS.BACK-TO' | translate}} +
+
{{'DESCRIPTION-EDITOR.TOOLTIP.DMP' | translate}}
+
+
{{'DESCRIPTION-EDITOR.STEPPER.USER-GUIDE' | translate}}
+
+
+
0. {{'DESCRIPTION-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
+
0. {{'DESCRIPTION-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
+
+
+ +
+
+
+
+ + +
+
{{'DESCRIPTION-EDITOR.STEPPER.NEXT' | translate}}
+ chevron_right +
+
+
{{'DESCRIPTION-EDITOR.STEPPER.NEXT' | translate}}
+ chevron_right +
+ +
+
+ +
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/description-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/description-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts similarity index 72% rename from dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 371c917b2..cf2760644 100644 --- a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -1,27 +1,11 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; +import { UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute, Params, Router } from '@angular/router'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { SaveType } from '@app/core/common/enum/save-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { LockModel } from '@app/core/model/lock/lock.model'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { - ExternalSourcesConfigurationService -} from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { @@ -29,37 +13,34 @@ import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; // import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { FormService } from '@common/forms/form-service'; -import { - FormValidationErrorsDialogComponent -} from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { Observable, interval, of as observableOf } from 'rxjs'; -import { catchError, debounceTime, filter, map, takeUntil } from 'rxjs/operators'; -import { DescriptionEditorService } from './description-editor.service'; -import { BaseEditor } from '@common/base/base-editor'; -import { DescriptionEditorModel } from './description-editor.model'; -import { Description, DescriptionPersist } from '@app/core/model/description/description'; +import { DatePipe } from '@angular/common'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; -import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; -import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; -import { FilterService } from '@common/modules/text-filter/filter-service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { Rule } from '@app/core/model/dataset-profile-definition/rule'; +import { Description, DescriptionPersist } from '@app/core/model/description/description'; import { DescriptionService } from '@app/core/services/description/description.service'; import { LoggingService } from '@app/core/services/logging/logging-service'; +import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; +import { BaseEditor } from '@common/base/base-editor'; +import { FormService } from '@common/forms/form-service'; +import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; +import { FilterService } from '@common/modules/text-filter/filter-service'; +import { Guid } from '@common/types/guid'; +import { TranslateService } from '@ngx-translate/core'; +import { map, takeUntil } from 'rxjs/operators'; +import { DescriptionEditorModel } from './description-editor.model'; import { DescriptionEditorResolver } from './description-editor.resolver'; -import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { DatePipe } from '@angular/common'; +import { DescriptionEditorService } from './description-editor.service'; +import { ToCEntry } from './table-of-contents/models/toc-entry'; +import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component'; +import { ToCEntryType } from './table-of-contents/models/toc-entry-type.enum'; @Component({ selector: 'app-description-editor-component', @@ -72,6 +53,7 @@ export class DescriptionEditorComponent extends BaseEditor = []; // DescriptionSectionFieldCategory = DescriptionSectionFieldCategory; @@ -89,6 +71,14 @@ export class DescriptionEditorComponent extends BaseEditor { + const isPublicDescription = params['public']; + const itemId = params['id']; + const newDmpId = params['newDmpId']; + // const publicId = params['publicId']; + // this.dmpId = params['dmpId']; + // this.dmpSectionIndex = parseInt(params['dmpSectionIndex']); + // this.newDmpId = queryParams['newDmpId']; + // this.publicId = params['publicId']; + // this.profileUpdateId = params['updateId']; + // this.finalize = data.finalize; + // this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId + + this.viewOnly = isPublicDescription; + // if (itemId != null) { + // this.isNew = false; + // this.isPublicView = false; + // this.descriptionService.getSingle(itemId, this.lookupFields()) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.description = data; + // this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [ReferenceType.Researcher]); + // // this.users = this.description.dmp.users; + // this.checkLockStatus(this.description.id); + // this.setIsUserOwner(); + // }, (error: any) => { + // if (error.status === 404) { + // return this.onFetchingDeletedCallbackError('/descriptions/'); + // } + // if (error.status === 403) { + // return this.onFetchingForbiddenCallbackError('/descriptions/'); + // } + // }); + // } + // else if (publicId != null) { + // this.isNew = false; + // this.isFinalized = true; + // this.isPublicView = true; + // this.descriptionService.getPublicSingle(publicId, this.lookupFields()) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.description = data; + // this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [ReferenceType.Researcher]); + // // this.users = this.description.dmp.users; + // // const breadCrumbs = []; + // // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" }); + // // breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/public/' + this.description.id }); + // // this.breadCrumbs = observableOf(breadCrumbs); + // }, (error: any) => { + // if (error.status === 404) { + // return this.onFetchingDeletedCallbackError('/explore-descriptions'); + // } + // if (error.status === 403) { + // return this.onFetchingForbiddenCallbackError('/explore-descriptions'); + // } + // }); + // } + if (itemId != null && newDmpId == null) { + this.isNew = false; + this.lockService.checkLockStatus(itemId).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + this.lockStatus = lockStatus; + if (this.item.status === DescriptionStatus.Finalized || lockStatus) { + this.formGroup.disable(); + this.viewOnly = true; + } + if (lockStatus) { + this.dialog.open(PopupNotificationDialogComponent, { + data: { + title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'), + message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE') + }, maxWidth: '30em' + }); + } + + if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { + //TODO: lock it. + // const lockedBy: UserInfoListingModel = { + // email: this.authService.getUserProfileEmail(), + // id: this.authService.userId()?.toString(), + // name: this.authService.getPrincipalName(), + // role: 0 //TODO + // //role: this.authService.getRoles()?.at(0) + // } + // this.lock = new LockModel(data.id, lockedBy); + + // this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + // this.lock.id = Guid.parse(result); + // interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + // }); + } + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + }); + } + + // if (this.itemId != null && this.newDmpId == null) { + // this.isNew = false; + // this.descriptionService.getSingle(this.itemId) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + // this.lockStatus = lockStatus; + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.dmpSectionIndex = this.descriptionModel.dmpSectionIndex; + // this.needsUpdate(); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.label, + // // url: '/descriptions/edit/' + this.descriptionModel.id, + // // notFoundResolver: [ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS').toUpperCase(), + // // url: '/descriptions' + // // }, + // // ] + // // }]); + // this.formGroup = this.descriptionModel.buildForm(); + // let profiles = this.descriptionModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.descriptionModel.dmpSectionIndex)); + // for (var profile of profiles) { + // this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) + // } + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized || lockStatus) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { + // const lockedBy: UserInfoListingModel = { + // email: this.authService.getUserProfileEmail(), + // id: this.authService.userId()?.toString(), + // name: this.authService.getPrincipalName(), + // role: 0 //TODO + // //role: this.authService.getRoles()?.at(0) + // } + // this.lock = new LockModel(data.id, lockedBy); + + // this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + // this.lock.id = Guid.parse(result); + // interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + // }); + // } + // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + + // if (lockStatus) { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'), + // message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE') + // }, maxWidth: '30em' + // }); + // } + // if (this.finalize && !this.lockStatus && !this.viewOnly) { + // setTimeout(() => { + // this.saveFinalize(); + // }, 0); + // } + // // this.availableProfiles = this.descriptionModel.dmp.profiles; + // }); + // }, + // error => { + // switch (error.status) { + // case 403: + // this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-ALLOWED'), SnackBarNotificationLevel.Error); + // break; + // case 404: + // this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-FOUND'), SnackBarNotificationLevel.Error); + // break; + // default: + // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), SnackBarNotificationLevel.Error); + // } + // this.router.navigate(['/descriptions/']); + // return observableOf(null); + // }); + // } else if (this.dmpId != null) { + // this.isNew = true; + // this.dmpService.getSingle(this.dmpId).pipe(map(data => data as DmpModel)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.descriptionModel = new DescriptionEditorModel(); + // setTimeout(() => { + // this.descriptionModel.dmp = data; + // this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex; + // this.formGroup = this.descriptionModel.buildForm(); + // let profiles = this.descriptionModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.dmpSectionIndex)); + // for (var profile of profiles) { + // this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) + // } + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // this.formGroup.get('dmp').disable(); + // const dialogRef = this.dialog.open(PrefillDescriptionComponent, { + // width: '590px', + // minHeight: '200px', + // restoreFocus: false, + // data: { + // availableProfiles: this.availableDescriptionTemplates, + // descriptionFormGroup: this.formGroup + // }, + // panelClass: 'custom-modalbox' + // }); + // dialogRef.afterClosed().subscribe(result => { + // if (result) { + // this.descriptionModel = this.descriptionModel.fromModel(result); + // this.descriptionModel.dmp = data; + // this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex; + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.formGroup.get('dmp').disable(); + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + // } + // }) + // this.loadDescriptionProfiles(); + // this.registerFormListeners(); + // // this.availableProfiles = data.profiles; + + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), + // // url: '/descriptions', + // // notFoundResolver: [ + // // // { + // // // parentComponentName: null, + // // // label: this.descriptionModel.dmp.grant.label, + // // // url: '/grants/edit/' + this.descriptionModel.dmp.grant.id + // // // }, + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.dmp.label, + // // url: '/plans/edit/' + this.descriptionModel.dmp.id, + // // }] + // // }]); + // }); + // }); + // } else if (this.newDmpId != null) { + // this.isNew = false; + // this.isCopy = true; + // this.descriptionService.getSingle(this.itemId) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + // this.lockStatus = lockStatus; + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.dmpSectionIndex = this.descriptionModel.dmpSectionIndex; + // this.descriptionModel.status = 0; + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroup.get('id').setValue(null); + // this.dmpService.getSingleNoDescriptions(this.newDmpId).pipe(map(data => data as DmpModel)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // setTimeout(() => { + // this.descriptionModel.dmp = data; + // this.formGroup.get('dmp').setValue(this.descriptionModel.dmp); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + + // this.loadDescriptionProfiles(); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), + // // url: '/descriptions', + // // notFoundResolver: [ + // // // { + // // // parentComponentName: null, + // // // label: this.descriptionModel.dmp.grant.label, + // // // url: '/grants/edit/' + this.descriptionModel.dmp.grant.id + // // // }, + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.dmp.label, + // // url: '/plans/edit/' + this.descriptionModel.dmp.id, + // // } + // // ] + // // }]); + // }); + // }); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized || lockStatus) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { + // const lockedBy: UserInfoListingModel = { + // email: this.authService.getUserProfileEmail(), + // id: this.authService.userId()?.toString(), + // name: this.authService.getPrincipalName(), + // role: 0 //TODO + // //role: this.authService.getRoles()?.at(0) + // } + // this.lock = new LockModel(data.id, lockedBy); + + // this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + // this.lock.id = Guid.parse(result); + // interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + // }); + // } + // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.loadDescriptionProfiles(); + // // this.availableProfiles = data.dmp.profiles; + // }) + // }); + // } else if (this.publicId != null) { // For Finalized -> Public Descriptions + // this.isNew = false; + // this.descriptionService.getSinglePublic(this.publicId) + // .pipe(takeUntil(this._destroyed)).pipe( + // catchError((error: any) => { + // this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); + // this.router.navigate(['/descriptions/publicEdit/' + this.publicId]); + // return observableOf(null); + // })) + // .subscribe(data => { + // if (data) { + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.formGroup.disable(); + // this.viewOnly = true; + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // this.formGroup.get('dmp').setValue(this.descriptionModel.dmp); + // const breadcrumbs = []; + // breadcrumbs.push({ + // parentComponentName: null, + // label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), + // url: '/explore-descriptions' + // }); + // breadcrumbs.push({ + // parentComponentName: null, + // label: this.descriptionModel.label, + // url: '/descriptions/publicEdit/' + this.descriptionModel.id + // }); + // // this.breadCrumbs = observableOf(breadcrumbs); + // } + // }); + // this.publicMode = true; + // } else if (this.profileUpdateId != null) { + // this.descriptionService.updateDescriptionProfile(this.profileUpdateId) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.descriptionModel = new DescriptionEditorModel().fromModel(data); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + + // this.needsUpdate(); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), + // // url: '/descriptions', + // // notFoundResolver: [ + // // // { + // // // parentComponentName: null, + // // // label: this.descriptionModel.dmp.grant.label, + // // // url: '/grants/edit/' + this.descriptionModel.dmp.grant.id + // // // }, + // // { + // // parentComponentName: null, + // // label: this.descriptionModel.dmp.label, + // // url: '/plans/edit/' + this.descriptionModel.dmp.id, + // // }, + // // ] + // // }]); + // this.formGroup = this.descriptionModel.buildForm(); + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.loadDescriptionProfiles(); + // }); + + // } else { + // this.descriptionModel = new DescriptionEditorModel(); + // this.formGroup = this.descriptionModel.buildForm(); + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + + // this.editMode = this.descriptionModel.status === DescriptionStatus.Draft; + // if (this.descriptionModel.status === DescriptionStatus.Finalized) { + // this.formGroup.disable(); + // this.viewOnly = true; + // } + // //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Description edit like DMP. + // this.registerFormListeners(); + // this.dmpValueChanged(null); + // // this.breadCrumbs = observableOf([ + // // { + // // parentComponentName: null, + // // label: this.language.instant('DATASET-LISTING.ACTIONS.CREATE-NEW').toUpperCase(), + // // url: '/descriptions/new/' + // // }]); + // } + }); + } getItem(itemId: Guid, successFunction: (item: Description) => void) { @@ -148,6 +552,7 @@ export class DescriptionEditorComponent extends BaseEditor entry.id === fieldSet.id); + this.step = index + (selected.type === ToCEntryType.FieldSet ? 1 : 0.5); + } else { + this.step = 0; + this.resetScroll(); + } + } + } + + getFirstFieldSet(entry: ToCEntry): ToCEntry { + if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id.toString())) { + return entry; + } else { + let subEntries = entry.subEntries.filter(subEntry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === subEntry.id.toString())); + if (subEntries.length > 0) { + return this.getFirstFieldSet(subEntries[0]); + } else { + return null; + } + } + } + + private resetScroll() { + document.getElementById('description-editor-form').scrollTop = 0; + } + + get visibleFieldSets(): ToCEntry[] { + let fieldSets = []; + let arrays = this.table0fContents ? this.table0fContents.tocentries. + filter(entry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id.toString())).map(entry => { + return this.getEntryVisibleFieldSets(entry); + }) + : []; + arrays.forEach(array => { + fieldSets = fieldSets.concat(array); + }); + return fieldSets; + } + + getEntryVisibleFieldSets(entry: ToCEntry): ToCEntry[] { + let fieldSets = []; + if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id.toString())) { + fieldSets.push(entry); + } else if (entry.type !== ToCEntryType.FieldSet) { + entry.subEntries.forEach(subEntry => { + fieldSets = fieldSets.concat(this.getEntryVisibleFieldSets(subEntry)); + }); + } + return fieldSets; + } + + // registerFormListeners() { + // // const dmpSubscription = + // this.formGroup.get('dmp').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.dmpValueChanged(x); + // }); + // // const profileSubscription = + // this.formGroup.get('profile').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // if (x) { + // this.showtocentriesErrors = false; + // this.descriptionProfileValueChanged(x.id); + // this.formChanged(); + // } + // }); + // // const labelSubscription = + // this.formGroup.get('label').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // const descriptionSubscription = + // this.formGroup.get('description').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // const uriSubscription = + // this.formGroup.get('uri').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // const tagsSubscription = + // this.formGroup.get('tags').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // if (this.formGroup.get('descriptionProfileDefinition')) { + // // const descriptionProfileDefinitionSubscription = + // this.formGroup.get('descriptionProfileDefinition').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.formChanged(); + // }); + // // this._listenersSubscription.add(descriptionProfileDefinitionSubscription); + // } + + // // this._listenersSubscription.add(dmpSubscription); + // // this._listenersSubscription.add(profileSubscription); + // // this._listenersSubscription.add(labelSubscription); + // // this._listenersSubscription.add(descriptionSubscription); + // // this._listenersSubscription.add(uriSubscription); + // // this._listenersSubscription.add(tagsSubscription); + // } + // // // // // // Sections @@ -1167,13 +1716,7 @@ export class DescriptionEditorComponent extends BaseEditor new DescriptionFieldEditorModel( - this.validationErrorModel - ).fromModel(item).buildForm({ - rootPath: `${rootPath}fields[${index}].` - }), context.getValidation('fields') - ) - ), - }); + const formGroup = this.formBuilder.group({}); + (this.fields ?? []).map( + (item, index) => formGroup.addControl(item.key, new DescriptionFieldEditorModel( + this.validationErrorModel + ).fromModel(item).buildForm({ + rootPath: `${rootPath}fields[${index}].` + })), context.getValidation('fields') + ) + return formGroup; + + // return this.formBuilder.group({ + // fields: this.formBuilder.array( + // (this.fields ?? []).map( + // (item, index) => new DescriptionFieldEditorModel( + // this.validationErrorModel + // ).fromModel(item).buildForm({ + // rootPath: `${rootPath}fields[${index}].` + // }), context.getValidation('fields') + // ) + // ) + // }); } static createValidationContext(params: { diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts new file mode 100644 index 000000000..17d972825 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts @@ -0,0 +1,37 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DescriptionBaseFieldsEditorComponent } from './description-base-fields-editor/description-base-fields-editor.component'; +import { DescriptionEditorComponent } from './description-editor.component'; +import { DescriptionEditorRoutingModule } from './description-editor.routing'; +import { DescriptionFormModule } from './description-form/description-form.module'; +import { VisibilityRulesService } from './description-form/visibility-rules/visibility-rules.service'; +import { DescriptionFormProgressIndicationModule } from './form-progress-indication/form-progress-indication.module'; +import { TableOfContentsModule } from './table-of-contents/table-of-contents.module'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + UrlListingModule, + FormattingModule, + ConfirmationDialogModule, + TableOfContentsModule, + DescriptionFormProgressIndicationModule, + DescriptionFormModule, + DescriptionEditorRoutingModule + ], + declarations: [ + DescriptionEditorComponent, + DescriptionBaseFieldsEditorComponent + ], + exports: [ + ], + providers: [ + VisibilityRulesService + ] +}) +export class DescriptionEditorModule { } diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts new file mode 100644 index 000000000..62e5478c2 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -0,0 +1,112 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { Description, DescriptionField, DescriptionReference, DescriptionTag, PropertyDefinition } from '@app/core/model/description/description'; +import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; +import { Reference } from '@app/core/model/reference/reference'; +import { Tag } from '@app/core/model/tag/tag'; +import { DescriptionService } from '@app/core/services/description/description.service'; +import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; +import { BaseEditorResolver } from '@common/base/base-editor.resolver'; +import { Guid } from '@common/types/guid'; +import { takeUntil, tap } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; + +@Injectable() +export class DescriptionEditorResolver extends BaseEditorResolver { + + constructor(private descriptionService: DescriptionService, private breadcrumbService: BreadcrumbService) { + super(); + } + + public static lookupFields(): string[] { + return [ + ...BaseEditorResolver.lookupFields(), + nameof(x => x.id), + nameof(x => x.label), + nameof(x => x.status), + nameof(x => x.description), + nameof(x => x.status), + [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + + [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), + + [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.ordinal)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.title)].join('.'), + + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.defaultVisibility)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.multiplicity)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.numbering)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.page)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.title)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.extendedDescription)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), // TODO: need to sort based on that + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.sections)].join('.'), // TODO: it is recursive here + + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.numbering)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.title)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.description)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.extendedDescription)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.additionalInformation)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.hasCommentField)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.min)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.max)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.placeholder)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.tableView)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.id)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.numbering)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.schematics)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.fieldType)].join('.'), + // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.includeInExport)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.validations)].join('.'), + + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.target)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.visibilityRules), nameof(x => x.value)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.label)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.fieldType)].join('.'), + + + [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.key)].join('.'), + [nameof(x => x.properties), nameof(x => x.fields), nameof(x => x.value)].join('.'), + + [nameof(x => x.descriptionTags), nameof(x => x.id),].join('.'), + [nameof(x => x.descriptionTags), nameof(x => x.tag), nameof(x => x.label)].join('.'), + + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), + [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + nameof(x => x.createdAt), + nameof(x => x.hash), + nameof(x => x.isActive) + + ] + } + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + + const fields = [ + ...DescriptionEditorResolver.lookupFields() + ]; + const id = route.paramMap.get('id'); + // const cloneid = route.paramMap.get('cloneid'); + if (id != null) { + return this.descriptionService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); + } + //TODO: check this + // else if (cloneid != null) { + // return this.descriptionService.clone(Guid.parse(cloneid), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); + // } + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts new file mode 100644 index 000000000..7a513afba --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts @@ -0,0 +1,101 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +// import { DescriptionWizardComponent } from './description-wizard/description-wizard.component'; +import { AppPermission } from '@app/core/common/enum/permission.enum'; +import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; +// import { DescriptionOverviewComponent } from './overview/description-overview.component'; +import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; +import { DescriptionEditorComponent } from './description-editor.component'; +import { DescriptionEditorResolver } from './description-editor.resolver'; +import { AuthGuard } from '@app/core/auth-guard.service'; + +const routes: Routes = [ + { + path: ':id', + canActivate: [AuthGuard], + component: DescriptionEditorComponent, + canDeactivate: [PendingChangesGuard], + resolve: { + 'entity': DescriptionEditorResolver + }, + data: { + ...BreadcrumbService.generateRouteDataConfiguration({ + title: 'BREADCRUMBS.EDIT-DESCRIPTION' + }), + authContext: { + permissions: [AppPermission.EditDescription] + } + } + }, + // { + // path: 'new/:dmpId/:dmpSectionIndex', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-NEW' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + + // { + // path: 'edit/:id/finalize', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // public: false, + // title: 'GENERAL.TITLES.DATASET-EDIT', + // finalize: true + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'publicEdit/:publicId', + // component: DescriptionWizardComponent, + // //canActivate: [AuthGuard], + // data: { + // public: true, + // title: 'GENERAL.TITLES.DATASET-PUBLIC-EDIT' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'new', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-NEW' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'copy/:id', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-COPY' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + // { + // path: 'profileupdate/:updateId', + // component: DescriptionWizardComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.DATASET-UPDATE' + // }, + // canDeactivate:[CanDeactivateGuard] + // }, + +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [DescriptionEditorResolver] +}) +export class DescriptionEditorRoutingModule { } diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.service.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.service.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/description-editor.service.ts rename to dmp-frontend/src/app/ui/description/editor/description-editor.service.ts diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html new file mode 100644 index 000000000..567ff7d61 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html @@ -0,0 +1,15 @@ +
+
+
+ close +
+
+
+ +
+
+
+
+
+
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts new file mode 100644 index 000000000..ac15f6dff --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts @@ -0,0 +1,31 @@ +import {Component, Inject} from "@angular/core"; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import { VisibilityRulesService } from "../../visibility-rules/visibility-rules.service"; + +@Component({ + selector: 'app-form-composite-field-dialog', + templateUrl: 'form-composite-field-dialog.component.html' +}) +export class FormCompositeFieldDialogComponent { + + public visibilityRulesService: VisibilityRulesService; + + constructor( + private dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { + this.visibilityRulesService = data.visibilityRulesService; + } + + cancel() { + this.dialogRef.close(); + } + + save() { + this.dialogRef.close(this.data.formGroup); + } + + public close() { + this.dialogRef.close(false); + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html new file mode 100644 index 000000000..c6bebfe74 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html @@ -0,0 +1,25 @@ +
+
+
+ + + {{fieldSet.title}} +
+ info +
+
+ + +
+ +
+
+ {{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-MORE' | translate}} +
+
+
+ + {{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-LESS' | translate}} + +
+
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.scss new file mode 100644 index 000000000..356217a1e --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.scss @@ -0,0 +1,31 @@ +.compositeField { + // font-weight: bold; + // color: #3a3737; + // max-width: 100%; + // padding-top: 1em; + text-align: left; + font-weight: 700; + font-size: 18px; + letter-spacing: 0px; + color: #212121; + opacity: 0.81; + margin-top: 1.625rem; + margin-bottom: 0.625rem; +} + +.info-icon{ + margin-top: 1.625rem; +} + +h6 { + text-transform: none; + font-weight: 400; +} + +.more { + text-decoration: underline; + color: var(--secondary-color); + cursor: pointer; + font-size: 1rem; + font-weight: 400; +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts new file mode 100644 index 000000000..ef6c0d57f --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts @@ -0,0 +1,21 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { DescriptionTemplateFieldSet } from '@app/core/model/description-template/description-template'; + +@Component({ + selector: 'app-form-composite-title', + templateUrl: './form-composite-title.component.html', + styleUrls: ['./form-composite-title.component.scss'] +}) +export class DescriptionFormCompositeTitleComponent implements OnInit { + + @Input() fieldSet: DescriptionTemplateFieldSet; + @Input() isChild: Boolean = false; + + public showExtendedDescription: boolean = false; + + constructor() { } + + ngOnInit() { + } + +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html new file mode 100644 index 000000000..36d519d48 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -0,0 +1,54 @@ +
+
+
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
{{field.label}}
+
+ +
+
+
+
+ +
+
+
+
+ + + {{propertiesFormGroup.get(field.id).get('value').getRawValue() | fieldValue | translate}} + + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.scss new file mode 100644 index 000000000..a6df1bcca --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.scss @@ -0,0 +1,17 @@ +.compositeField { + padding-left: 0em !important; +// padding-top: 2em !important; +} + +// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { +// background: #fafafa !important; +// } + +// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { +// font-size: 1rem; +// padding: 0.6em 0 1em 0 !important; +// } + +.actions { + width: 110px; +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts new file mode 100644 index 000000000..ebb1ea80b --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts @@ -0,0 +1,115 @@ +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { MatDialog } from "@angular/material/dialog"; +import { DescriptionTemplateFieldSet } from '@app/core/model/description-template/description-template'; +import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from 'rxjs/operators'; +import { ToCEntry } from '../../../table-of-contents/models/toc-entry'; +import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; + +@Component({ + selector: 'app-form-field-set', + templateUrl: './form-field-set.component.html', + styleUrls: ['./form-field-set.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class DescriptionFormFieldSetComponent extends BaseComponent { + + @Input() fieldSet: DescriptionTemplateFieldSet; + @Input() propertiesFormGroup: UntypedFormGroup; + isVisibleByVisibilityService: boolean = true; + @Input() visibilityRulesService: VisibilityRulesService; + + + @Input() datasetProfileId: String; + // @Input() form: UntypedFormGroup; + @Input() isChild: Boolean = false; + @Input() showDelete: Boolean = false; + @Input() tocentry: ToCEntry; + @Input() tableRow: boolean = false; + @Input() showTitle: boolean = true; + @Input() placeholderTitle: boolean = false; + + constructor( + private dialog: MatDialog, + private changeDetector: ChangeDetectorRef + ) { + super(); + } + + ngOnInit() { + this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { + if (x.has(this.fieldSet.id)) { + this.isVisibleByVisibilityService = x.get(this.fieldSet.id); + // this.changeDetector.markForCheck(); + } + }); + // if (this.tocentry) { + // this.form = this.tocentry.form as UntypedFormGroup; + // } + } + + // editCompositeFieldInDialog() { + // const dialogRef = this.dialog.open(FormCompositeFieldDialogComponent, { + // width: '750px', + // disableClose: true, + // data: { + // formGroup: cloneAbstractControl(this.form), + // datasetProfileId: this.datasetProfileId, + // visibilityRulesService: this.visibilityRulesService + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { + // if (data) { + // this.form.patchValue(data.value); + // this.changeDetector.detectChanges(); + // } + // }); + // } + + // deleteCompositeField() { + // if (this.isChild) { + // this.deleteMultipeFieldFromCompositeFormGroup(); + // } else { + // this.deleteCompositeFieldFormGroup(); + // } + // } + + // deleteCompositeFieldFormGroup() { + + // const compositeFieldId = ((this.form.get('multiplicityItems') as UntypedFormArray).get('' + 0) as UntypedFormGroup).getRawValue().id; + // const fieldIds = (this.form.get('fields') as UntypedFormArray).controls.map(control => control.get('id').value) as string[]; + + // const numberOfItems = this.form.get('multiplicityItems').get('' + 0).get('fields').value.length; + // for (let i = 0; i < numberOfItems; i++) { + // const multiplicityItem = this.form.get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; + // this.form.get('fields').get('' + i).patchValue(multiplicityItem); + // } + // ((this.form.get('multiplicityItems'))).removeAt(0); + + + // this.visibilityRulesService.removeAllIdReferences(compositeFieldId); + // fieldIds.forEach(x => this.visibilityRulesService.removeAllIdReferences(x)); + // } + + // deleteMultipeFieldFromCompositeFormGroup() { + // const parent = this.form.parent; + // const index = (parent as UntypedFormArray).controls.indexOf(this.form); + + // const currentId = this.form.get('id').value; + // const fieldIds = (this.form.get('fields') as UntypedFormArray).controls.map(control => control.get('id').value) as string[]; + + + // this.visibilityRulesService.removeAllIdReferences(currentId); + // fieldIds.forEach(x => this.visibilityRulesService.removeAllIdReferences(x)); + + // (parent as UntypedFormArray).removeAt(index); + // (parent as UntypedFormArray).controls.forEach((control, i) => { + // try { + // control.get('ordinal').setValue(i); + // } catch { + // throw 'Could not find ordinal'; + // } + // }); + // } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html new file mode 100644 index 000000000..3d8f03f6f --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -0,0 +1,473 @@ +
+ +
{{fieldSet.title}}
+ info + +
{{fieldSet.description}} +
+
+ {{fieldSet.extendedDescription}} +
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{'GENERAL.VALIDATION.URL.MESSAGE' | translate}} + + +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + {{opt.label}} + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+ + {{field.data.label}} +
+ + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + +
+
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+
+
+ +
+ + + {{ propertiesFormGroup.get(field.id).get('value').value.name }} + + +
+
+ + + +
+
+
+ + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }} + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+ +
+ + {{option.label}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} * +
+ + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + +
+
+ +
+
+ + + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + + + + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} + +
+
+ +
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + + + {{ type.name }} + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+ +
+
+ + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+ +
+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + + + {{ type.name }} + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+ + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+ + {{validationIcon}} +
+
+
+
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.scss new file mode 100644 index 000000000..0213cb51f --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.scss @@ -0,0 +1,105 @@ +.dynamic-form-field { + .radio-button-item { + margin-right: 1em; + } + + .full-width { + width: 100%; + } + + .text-area { + box-sizing: content-box; + } + + .success { + color: green; + } + + .fail { + color: red; + } +} + +::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { + background: #fafafa !important; +} + +::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { + font-size: 1rem; + padding: 0.6em 0 1em 0 !important; +} + + +.attach-btn { + top: -20px; +} + +.attach-file-btn { + min-width: 156px; + height: 44px; + color: #ffffff; + background: var(--primary-color) 0% 0% no-repeat padding-box; + box-shadow: 0px 3px 6px #1e202029; + border-radius: 30px; +} + +.attach-file-btn:hover { + background-color: #ffffff; + border: 1px solid var(--primary-color); + color: var(--primary-color); +} + +.attach-file-btn.mdc-button-disabled, .attach-file-btn.mdc-button-disabled:hover { + background-color: #ffffff; + border: 1px solid darkgray; + color: darkgrey !important; +} +// +//.mdc-button-disabled .attach-file-btn > ::ng-deep mdc-button-wrapper:hover > * { +// color: darkgrey !important; +//} + +.drop-file { + background-color: #fafafa; + border: 1px dashed #d1d1d1; + border-radius: 4px; + //max-width: 480px; + height: 98px; + margin-top: 0.5rem; +} + +.file-preview { + height: auto !important; + width: auto !important; + max-width: 500px !important; + min-height: 1rem !important; + + background-color: #e0e0e0 !important; + background-image: none !important; + color: rgba(0, 0, 0, 0.87) !important; + font-weight: 500 !important; + border-radius: 24px !important; + line-height: 1.25 !important; +} + +.file-label { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 14px !important; +} + +::ng-deep ngx-dropzone-remove-badge { + opacity: 1 !important; + margin-left: .5rem !important; + position: initial !important; +} + +::ng-deep .upload-form .mat-form-field-appearance-outline .mat-form-field-outline { + background: #fafafa !important; +} + +::ng-deep .upload-form .mat-form-field-appearance-outline .mat-form-field-infix { + font-size: 1rem; + padding: 0.6em 0 1em 0 !important; +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts new file mode 100644 index 000000000..4ba26734f --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.ts @@ -0,0 +1,764 @@ + +import { COMMA, ENTER } from '@angular/cdk/keycodes'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges } from '@angular/core'; +import { FormControl, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; +import { MatDialog } from "@angular/material/dialog"; +import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; +import { ReferenceType } from '@app/core/common/enum/reference-type'; +import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; +import { DescriptionTemplateAutoCompleteData, DescriptionTemplateAutoCompleteSingleData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateUploadData, DescriptionTemplateWordListData } from '@app/core/model/description-template/description-template'; +import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; +import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; +import { FetcherReference, Reference } from '@app/core/model/reference/reference'; +import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '@app/core/query/dataset/daatset-external-autocomplete-criteria'; +import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; +import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; +import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; +import { RegistryCriteria } from '@app/core/query/registry/registry-criteria'; +import { RequestItem } from '@app/core/query/request-item'; +import { ResearcherCriteria } from '@app/core/query/researcher/researcher-criteria'; +import { ServiceCriteria } from '@app/core/query/service/service-criteria'; +import { TagCriteria } from '@app/core/query/tag/tag-criteria'; +import { TaxonomyCriteria } from "@app/core/query/taxonomy/taxonomy-criteria"; +import { CurrencyService } from '@app/core/services/currency/currency.service'; +import { DatasetExternalAutocompleteService } from '@app/core/services/dataset/dataset-external-autocomplete.service'; +import { DatasetService } from '@app/core/services/dataset/dataset.service'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; +import { FileService } from "@app/core/services/file/file.service"; +import { + SnackBarNotificationLevel, + UiNotificationService +} from "@app/core/services/notification/ui-notification-service"; +import { ReferenceService } from '@app/core/services/reference/reference.service'; +import { FileUtils } from '@app/core/services/utilities/file-utils.service'; +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 { ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; +import { BaseComponent } from '@common/base/base.component'; +import { TranslateService } from '@ngx-translate/core'; +import { Observable } from 'rxjs'; +import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators'; +import { DescriptionFieldEditorModel } from '../../../description-editor.model'; +import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type'; + +@Component({ + selector: 'app-form-field', + templateUrl: './form-field.component.html', + styleUrls: ['./form-field.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class DescriptionFormFieldComponent extends BaseComponent implements OnInit { + + @Input() field: DescriptionTemplateField; + @Input() fieldSet: DescriptionTemplateFieldSet; + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() visibilityRulesService: VisibilityRulesService; + isRequired: boolean = false; + + + // @Input() field: Field; + // @Input() form: UntypedFormGroup; + @Input() datasetProfileId: any; + @Input() isChild: Boolean = false; + autocompleteOptions: DescriptionTemplateAutoCompleteSingleData[]; + + visible: boolean = true; + + // change: Subscription; + // trackByFn = (index, item) => item ? item['id'] : null; + + descriptionTemplateFieldTypeEnum = DescriptionTemplateFieldType; + + + + public singleAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + public multipleAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + + externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + pubRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + journalRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + taxonomiesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + licensesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + publicationsAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + tagsAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + currencyAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + + readonly separatorKeysCodes: number[] = [ENTER, COMMA]; + + tags: ExternalTagEditorModel[] = []; + + datasetIdInitialized: boolean = false; + + validationIcon; + + readonly datasetIdTypes: any[] = [ + { name: 'Handle', value: 'handle' }, + { name: 'DOI', value: 'doi' }, + { name: 'Ark', value: 'ark' }, + { name: 'Url', value: 'url' }, + { name: 'Other', value: 'other' } + ]; + + + readonly validationTypes: any[] = [ + { name: 'Zenodo', value: 'zenodo' } + ]; + + filesToUpload: FileList; + + constructor( + private datasetExternalAutocompleteService: DatasetExternalAutocompleteService, + private externalSourcesService: ExternalSourcesService, + private language: TranslateService, + private datasetService: DatasetService, + private dmpService: DmpService, + private currencyService: CurrencyService, + private fileService: FileService, + private cdr: ChangeDetectorRef, + private uiNotificationService: UiNotificationService, + public dialog: MatDialog, + private fileUtils: FileUtils, + private referenceService: ReferenceService + ) { + super(); + } + + ngOnChanges(changes: SimpleChanges) { + if (changes['form']) { + } + } + + ngOnInit() { + + this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { + if (x.has(this.field.id)){ + this.visible = x.get(this.field.id); + } + }); + + //TODO: validate that this logic is correct. Validation contenxt path might need to be fixed. + if (this.propertiesFormGroup.get(this.field.id).get('value') == null) { + const item: DescriptionFieldEditorModel = new DescriptionFieldEditorModel(); + item.key = this.field.id; + this.propertiesFormGroup.addControl(this.field.id, item.buildForm()); + } + + if (this.propertiesFormGroup.get(this.field.id).get('value').value) { + this.visibilityRulesService.updateValueAndVisibility(this.field?.id, this.propertiesFormGroup.get(this.field.id).get('value').value); + } + + this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required); + + if (this.field?.data?.fieldType === DescriptionTemplateFieldType.WORD_LIST) { + if ((this.field.data as DescriptionTemplateWordListData).multiList) { + const originalValue = this.propertiesFormGroup.get(this.field.id).get('value').value; + if (originalValue !== null && typeof originalValue === 'string') { + let values = (this.propertiesFormGroup.get(this.field.id).get('value').value).slice(1, -1).split(', ').filter((value) => !value.includes('"')); + let specialValue = (this.propertiesFormGroup.get(this.field.id).get('value').value).split('"').filter((value) => !value.startsWith('[') && !value.endsWith(']') && !values.includes(value) && value !== ', '); + specialValue.forEach(value => values.push(value)); + if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) { + values = undefined; + values = [originalValue]; + } + this.propertiesFormGroup.get(this.field.id).get('value').patchValue(values); + values.forEach(element => { + this.visibilityRulesService.updateValueAndVisibility(this.field?.id, element); + }); + } + } + } + + // Setup autocomplete configuration if needed + if (this.field?.data?.fieldType === DescriptionTemplateFieldType.AUTO_COMPLETE) { + if (!((this.field.data as DescriptionTemplateAutoCompleteData).multiAutoComplete)) { + this.singleAutoCompleteConfiguration = { + filterFn: this.searchFromAutocomplete.bind(this), + initialItems: () => this.searchFromAutocomplete(''), + displayFn: (item) => { try { return (item != null && item.length > 1) ? JSON.parse(item).label : item['label'] } catch { return '' } }, + titleFn: (item) => { try { return item['label'] } catch { return '' } }, + valueAssign: (item) => { try { return JSON.stringify(item) } catch { return '' } }, + subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } } + }; + } + else { + this.multipleAutoCompleteConfiguration = { + filterFn: this.searchFromAutocomplete.bind(this), + initialItems: () => this.searchFromAutocomplete(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label'] } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label'] } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }, + subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } } + } + } + if (isNullOrUndefined(this.datasetProfileId)) { + this.autocompleteOptions = (this.field.data as DescriptionTemplateAutoCompleteData).autoCompleteSingleDataList; + } + } + + switch (this.field?.data?.fieldType) { + case DescriptionTemplateFieldType.EXTERNAL_DATASETS: + this.externalDatasetAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalDatasets.bind(this), + initialItems: () => this.searchDatasetExternalDatasets(''),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.DATA_REPOSITORIES: + this.dataRepositoriesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalDataRepositories.bind(this), + initialItems: () => this.searchDatasetExternalDataRepositories(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.PUB_REPOSITORIES: + this.pubRepositoriesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalPubRepositories.bind(this), + initialItems: () => this.searchDatasetExternalPubRepositories(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.JOURNAL_REPOSITORIES: + this.journalRepositoriesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalJournalRepositories.bind(this), + initialItems: () => this.searchDatasetExternalJournalRepositories(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.TAXONOMIES: + this.taxonomiesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalTaxonomies.bind(this), + initialItems: () => this.searchDatasetExternalTaxonomies(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.LICENSES: + this.licensesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalLicences.bind(this), + initialItems: () => this.searchDatasetExternalLicences(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.PUBLICATIONS: + this.publicationsAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalPublications.bind(this), + initialItems: () => this.searchDatasetExternalPublications(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.REGISTRIES: + this.registriesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalRegistries.bind(this), + initialItems: () => this.searchDatasetExternalRegistries(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.SERVICES: + this.servicesAutoCompleteConfiguration = { + filterFn: this.searchDatasetExternalServices.bind(this), + initialItems: () => this.searchDatasetExternalServices(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.TAGS: + this.tagsAutoCompleteConfiguration = { + filterFn: this.filterTags.bind(this), + initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + displayFn: (item) => { try { return this.showTag(item) } catch { return '' } }, + titleFn: (item) => { try { return item['name'] } catch { return '' } }, + valueAssign: (item) => { try { return this.addTag(item) } catch { return '' } } + }; + this.parseTags(); + break; + case DescriptionTemplateFieldType.RESEARCHERS: + this.researchersAutoCompleteConfiguration = { + filterFn: this.filterResearchers.bind(this), + initialItems: (excludedItems: any[]) => this.filterResearchers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.ORGANIZATIONS: + this.organisationsAutoCompleteConfiguration = { + filterFn: this.filterOrganisations.bind(this), + initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.DATASET_IDENTIFIER: + const value = this.propertiesFormGroup.get(this.field.id).get('value').value; + const disabled = this.propertiesFormGroup.get(this.field.id).disabled; + //TODO: Refactor this. + // this.form.removeControl('value'); + // this.form.addControl('value', new DatasetIdModel(value).buildForm()); + // if (disabled) { + // this.form.disable(); + // } + this.datasetIdInitialized = true; + break; + case DescriptionTemplateFieldType.CURRENCY: + this.currencyAutoCompleteConfiguration = { + filterFn: this.searchCurrency.bind(this), + initialItems: () => this.searchCurrency(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } + }; + break; + case DescriptionTemplateFieldType.VALIDATION: + const value1 = this.propertiesFormGroup.get(this.field.id).get('value').value; + const disabled1 = this.propertiesFormGroup.get(this.field.id).disabled; + //TODO: Refactor this. + // this.form.removeControl('value'); + // this.form.addControl('value', new DatasetIdModel(value1).buildForm()); + // if (disabled1) { + // this.form.disable(); + // } + break; + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS: + this.makeAutocompleteConfiguration(this.searchResearchers.bind(this), "name", "tag"); + break; + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DATASETS: + this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label"); + break; + case DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_DMPS: + this.makeAutocompleteConfiguration(this.searchDmps.bind(this), "label"); + break; + } + + // this.form = this.visibilityRulesService.getFormGroup(this.field.id); + this.propertiesFormGroup.get(this.field.id).get('value').valueChanges + .pipe( + takeUntil(this._destroyed), + distinctUntilChanged() + ) + .subscribe(item => { + // if (this.field?.data?.fieldType === DescriptionTemplateFieldType.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList && this.form.get('data').value.multiList) { + // item.forEach(element => { + // this.visibilityRulesService.updateValueAndVisibility(this.field?.id, element); + // }); + + // } else { + this.visibilityRulesService.updateValueAndVisibility(this.field?.id, item); + // } + }); + } + + // _optionRemove(event) { + // const array = JSON.parse(this.propertiesFormGroup.get(this.field.id).get('value').value); + // if (array) { + // const index = array.map(x => x.id).indexOf(event.id); + // if (index >= 0) { + // array.splice(index, 1); + // } + // this.propertiesFormGroup.get(this.field.id).get('value').patchValue(JSON.stringify(array)); + // } + // } + + searchFromAutocomplete(query: string) { + + if (this.autocompleteOptions) { + const autocompleteRequestItem: RequestItem = new RequestItem(); + autocompleteRequestItem.criteria = new DatasetExternalAutocompleteOptionsCriteria(); + //TODO: refactor this + //autocompleteRequestItem.criteria.autoCompleteSingleDataList = this.autocompleteOptions; + autocompleteRequestItem.criteria.like = query; + return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem); + } + else { + const autocompleteRequestItem: RequestItem = new RequestItem(); + autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria(); + let parseIdArray: string[] = this.field?.id.split('_'); + if (parseIdArray.length > 1) { + autocompleteRequestItem.criteria.fieldID = parseIdArray[parseIdArray.length - 1]; + } else { + autocompleteRequestItem.criteria.fieldID = this.field?.id; + } + if (typeof this.datasetProfileId === 'string') { + autocompleteRequestItem.criteria.profileID = this.datasetProfileId; + } + else if (this.datasetProfileId != null) { + autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id; + } + autocompleteRequestItem.criteria.like = query; + return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem); + } + } + + searchResearchers(query: string) { + const reasearcherAutocompleteRequestItem: RequestItem = new RequestItem(); + reasearcherAutocompleteRequestItem.criteria = new ResearcherCriteria; + reasearcherAutocompleteRequestItem.criteria.name = query; + return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem); + } + + searchDatasets(query: string) { + let fields: Array = new Array(); + const datasetsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); + datasetsAutocompleteRequestItem.criteria = new DatasetCriteria(); + datasetsAutocompleteRequestItem.criteria.like = query; + return this.datasetService.getPaged(datasetsAutocompleteRequestItem).pipe(map(item => item.data)); + } + + searchDmps(query: string) { + let fields: Array = new Array(); + const dmpsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); + dmpsAutocompleteRequestItem.criteria = new DmpCriteria(); + dmpsAutocompleteRequestItem.criteria.like = query; + return this.dmpService.getPaged(dmpsAutocompleteRequestItem).pipe(map(item => item.data)); + } + + makeAutocompleteConfiguration(myfunc: Function, title: string, subtitle?: string): void { + if (!((this.field.data as DescriptionTemplateAutoCompleteData).multiAutoComplete)) { + this.singleAutoCompleteConfiguration = { + filterFn: myfunc.bind(this), + initialItems: (extraData) => myfunc(''), + displayFn: (item) => { try { return (item != null && item.length > 1) ? JSON.parse(item)[title] : item[title] } catch { return '' } }, + titleFn: (item) => { try { return item[title] } catch { return '' } }, + valueAssign: (item) => JSON.stringify(item), + subtitleFn: (item) => { try { return item[subtitle] } catch { return '' } } + }; + } + else { + this.multipleAutoCompleteConfiguration = { + filterFn: myfunc.bind(this), + initialItems: (extraData) => myfunc(''), + displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)[title] : item[title] } catch { return '' } }, + titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)[title] : item[title] } catch { return '' } }, + valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }, + subtitleFn: (item) => { try { return item[subtitle] } catch { return '' } } + } + } + } + + searchDatasetExternalDatasets(query: string): Observable { + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new ExternalDatasetCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // //return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); + // return this.externalSourcesService.listExternal(ReferenceType.Datasets, requestItem.criteria.like, requestItem.criteria.type); + const lookup = new ReferenceSearchLookup(); + lookup.like = query; + lookup.key = ''; + lookup.type = ReferenceType.Datasets; + return this.referenceService.search(lookup); + } + + searchDatasetExternalDataRepositories(query: string): Observable { + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new DataRepositoryCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.listExternal(ReferenceType.DataRepositories, requestItem.criteria.like, requestItem.criteria.type); + const lookup = new ReferenceSearchLookup(); + lookup.like = query; + lookup.key = ''; + lookup.type = ReferenceType.DataRepositories; + return this.referenceService.search(lookup); + } + searchDatasetExternalPubRepositories(query: string): Observable { + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new DataRepositoryCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.listExternal(ReferenceType.PubRepositories, requestItem.criteria.like, requestItem.criteria.type); + const lookup = new ReferenceSearchLookup(); + lookup.like = query; + lookup.key = ''; + lookup.type = ReferenceType.PubRepositories; + return this.referenceService.search(lookup); + } + searchDatasetExternalJournalRepositories(query: string): Observable { + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new DataRepositoryCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.listExternal(ReferenceType.Journals, requestItem.criteria.like, requestItem.criteria.type); + const lookup = new ReferenceSearchLookup(); + lookup.like = query; + lookup.key = ''; + lookup.type = ReferenceType.Journals; + return this.referenceService.search(lookup); + } + searchDatasetExternalTaxonomies(query: string): Observable { + const requestItem: RequestItem = new RequestItem(); + requestItem.criteria = new TaxonomyCriteria(); + requestItem.criteria.like = query; + requestItem.criteria.type = ''; + return this.externalSourcesService.listExternal(ReferenceType.Taxonomies, requestItem.criteria.like, requestItem.criteria.type); + } + searchDatasetExternalLicences(query: string): Observable { + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new LicenseCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + // return this.externalSourcesService.listExternal(ReferenceType.Licenses, requestItem.criteria.like, requestItem.criteria.type); + const lookup = new ReferenceSearchLookup(); + lookup.like = query; + lookup.key = ''; + lookup.type = ReferenceType.Licenses; + return this.referenceService.search(lookup); + } + searchDatasetExternalPublications(query: string): Observable { + // const requestItem: RequestItem = new RequestItem(); + // requestItem.criteria = new PublicationCriteria(); + // requestItem.criteria.like = query; + // requestItem.criteria.type = ''; + //return this.externalSourcesService.listExternal(ReferenceType.Publications, requestItem.criteria.like, requestItem.criteria.type); + + const lookup = new ReferenceSearchLookup(); + lookup.like = query; + lookup.key = ''; + lookup.type = ReferenceType.Publications; + return this.referenceService.search(lookup); + } + + searchDatasetExternalRegistries(query: string): Observable { + const requestItem: RequestItem = new RequestItem(); + requestItem.criteria = new RegistryCriteria(); + requestItem.criteria.like = query; + requestItem.criteria.type = ''; + return this.externalSourcesService.listExternal(ReferenceType.Registries, requestItem.criteria.like, requestItem.criteria.type); + } + + searchDatasetExternalServices(query: string): Observable { + const requestItem: RequestItem = new RequestItem(); + requestItem.criteria = new ServiceCriteria(); + requestItem.criteria.like = query; + requestItem.criteria.type = ''; + return this.externalSourcesService.listExternal(ReferenceType.Services, requestItem.criteria.like, requestItem.criteria.type); + } + + searchDatasetTags(query: string): Observable { + const requestItem: RequestItem = new RequestItem(); + requestItem.criteria = new TagCriteria(); + requestItem.criteria.like = query; + requestItem.criteria.type = ''; + return this.externalSourcesService.searchDatasetTags(requestItem); + } + + parseTags() { + try { + + + let stringValue = this.propertiesFormGroup.get(this.field.id).get('value').value; + if (typeof stringValue === 'string') { + stringValue = (stringValue).replace(new RegExp('{', 'g'), '{"').replace(new RegExp('=', 'g'), '":"').replace(new RegExp(',', 'g'), '",').replace(new RegExp(', ', 'g'), ', "').replace(new RegExp('}', 'g'), '"}'); + stringValue = stringValue.replace(new RegExp('}"', 'g'), '}').replace(new RegExp('"{', 'g'), '{'); + } else if (stringValue instanceof Array) { + const tempArray = new Array(); + for (let stringTag of stringValue) { + tempArray.push(JSON.parse(stringTag)); + } + stringValue = JSON.stringify(tempArray); + } + const tagArray = JSON.parse(stringValue); + this.propertiesFormGroup.get(this.field.id).get('value').patchValue(tagArray); + } catch (e) { + console.warn('Could not parse tags'); + } + } + + filterTags(value: string): Observable { + const requestItem: RequestItem = new RequestItem(); + const criteria: TagCriteria = new TagCriteria(); + criteria.like = value; + requestItem.criteria = criteria; + return this.externalSourcesService.searchDatasetTags(requestItem); + } + + showTag(ev: any) { + if (typeof ev === 'string') { + return ev; + } else { + return ev.name; + } + } + + addTag(ev: any) { + let item: ExternalTagEditorModel; + //this.filteredTags = this.formGroup.get('tags').value; + if (typeof ev === 'string') { + item = new ExternalTagEditorModel('', ev); + } else { + item = ev; + } + if (item.name !== '') { + return item; + } + } + + filterOrganisations(value: string): Observable { + //return this.externalSourcesService.searchDMPOrganizations(value); + //return this.externalSourcesService.listExternal(ReferenceType.Organizations, value, ''); + const lookup = new ReferenceSearchLookup(); + lookup.like = value; + lookup.key = ''; + lookup.type = ReferenceType.Organizations; + return this.referenceService.search(lookup); + } + + filterResearchers(value: string): Observable { + //return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }); + //return this.externalSourcesService.listExternal(ReferenceType.Researcher, value, ''); + const lookup = new ReferenceSearchLookup(); + lookup.like = value; + lookup.key = ''; + lookup.type = ReferenceType.Researcher; + return this.referenceService.search(lookup); + } + + getDatasetIdControl(name: string): UntypedFormControl { + return this.propertiesFormGroup.get(this.field.id).get(name) as UntypedFormControl; + } + + searchCurrency(query: string): Observable { + return this.currencyService.get(query); + } + + validateId() { + const identifier = this.getDatasetIdControl('identifier').value; + const type = this.getDatasetIdControl('type').value; + this.validationIcon = 'loading'; + this.externalSourcesService.validateIdentifier(identifier, type).pipe(takeUntil(this._destroyed)).subscribe(result => { + this.validationIcon = result === true ? 'done' : 'clear'; + }); + + } + + public upload() { + //TODO: refactor this + // this.fileService.upload(this.filesToUpload[0], this.datasetProfileId.id, this.form.value.id).subscribe((fileId: string) => { + // this.form.get("value").patchValue( + // { "name": this.filesToUpload[0].name, "id": fileId + "", "type": this.filesToUpload[0].type }); + // this.cdr.detectChanges(); + // }, error => { + // this.onCallbackUploadFail(error.error); + // }) + } + + + private onCallbackUploadFail(error: any) { + this.makeFilesNull(); + this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); + } + + fileChangeEvent(fileInput: any, dropped: boolean = false) { + //TODO: refactor this + // if (this.form.value.value) { + // this.onRemove(false); + // } + + // if (dropped) { + // this.filesToUpload = fileInput.addedFiles; + // } else { + // this.filesToUpload = fileInput.target.files; + // } + + + // let messages: string[] = []; + // if (this.filesToUpload.length == 0) { + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.NO-FILES-SELECTED')); + // return; + // } else { + // let fileToUpload = this.filesToUpload[0]; + // if (this.form.get("data") && this.form.get("data").value.types + // && this.form.get("data").value.types.map(type => type.value).includes(fileToUpload.type) + // && this.form.get("data").value.maxFileSizeInMB + // && this.form.get("data").value.maxFileSizeInMB * 1048576 >= fileToUpload.size) { + // this.upload(); + // } else { + // this.filesToUpload = null; + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.LARGE-FILE-OR-UNACCEPTED-TYPE')); + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.MAX-FILE-SIZE', { 'maxfilesize': this.form.get("data").value.maxFileSizeInMB })); + // messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.ACCEPTED-FILE-TYPES') + this.form.get("data").value.types.map(type => type.value).join(", ")); + // } + + // if (messages && messages.length > 0) { + // this.dialog.open(FormValidationErrorsDialogComponent, { + // data: { + // errorMessages: messages + // } + // }) + // } + // } + } + + onRemove(makeFilesNull: boolean = true) { + //TODO: refactor this + // delete from tmp folder - subscribe call + // this.fileService.deleteFromTempFolder(this.form.value.value.id).subscribe(res => { + // if (makeFilesNull) { + // this.makeFilesNull(); + // } + // this.cdr.detectChanges(); + // }, error => { + // if (makeFilesNull) { + // this.makeFilesNull(); + // } + // }) + } + + makeFilesNull() { + //TODO: refactor this + // this.filesToUpload = null; + // this.form.value.value = null; + // this.form.get("value").patchValue(null); + } + + typesToString() { + return (this.field.data as DescriptionTemplateUploadData).types.map(type => type.value).toString(); + } + + download(): void { + //TODO: refactor this + // this.fileService.download(this.form.value.value.id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(response => { + // const blob = new Blob([response.body], { type: this.form.value.value.type }); + // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + + // FileSaver.saveAs(blob, filename); + // }); + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html new file mode 100644 index 000000000..2b853b6df --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html @@ -0,0 +1,176 @@ +
+ + + + + +
+
+ +
+ +
+ +
+
+ + +
+
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+
+ +
+
+ + + + + + + + + + + + + + +
{{fieldFormGroup.get('data').value.label}}
+ + + {{fieldsetEntry.form.get('multiplicity').value.placeholder}} + {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (fieldsetEntry.form.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} + +
+
+
+ +
+
+
+
+ +
+
+
+ + + {{fieldsetEntry.form.get('multiplicity').value.placeholder}} + {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (fieldsetEntry.form.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} + +
+
+ + +
+
+
+ +
+
+ +
+ + + + +
+ +
+ +
+
+
+
+ +
+ +
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.scss new file mode 100644 index 000000000..cb676cf4c --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.scss @@ -0,0 +1,46 @@ +.dynamic-form-section { + .expansion-panel { + // background-color: #eeeeee54; + background-color: white; + margin-top: 1em; + margin-bottom: 1em; + // margin-bottom: 1em; + } + .addOneFieldButton { + margin-top: -15px; + margin-left: -11px; + color: var(--primary-color); + } + .panel-title, + .panel-desc { + text-align: left; + font-weight: 700; + font-size: 1rem; + letter-spacing: 0px; + color: #212121; + opacity: 0.81; + margin-top: 1.625rem; + margin-bottom: 0.625rem; + } + + .panel-desc { + // text-transform: capitalize; + text-transform: none; + font-weight: 400; + margin-top: .5rem; + } +} +.styleBorder { + border: 0.2em solid lightgray; + border-radius: 0.5em; + margin-bottom: 0.5em; +} +.mat-expansion-panel-header-description { + padding-bottom: 18px; + color: black; +} + +::ng-deep .mat-expansion-panel-header { + height: auto !important; + min-height: 48px; +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts new file mode 100644 index 000000000..068dd0729 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts @@ -0,0 +1,266 @@ +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + EventEmitter, + Input, + OnChanges, + OnInit, + Output, + SimpleChanges +} from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from 'rxjs/operators'; +import { DescriptionFieldEditorModel } from '../../../description-editor.model'; +import { ToCEntry } from '../../../table-of-contents/models/toc-entry'; +import { ToCEntryType } from '../../../table-of-contents/models/toc-entry-type.enum'; +import { LinkToScroll } from '../../../table-of-contents/table-of-contents.component'; +import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; + + +@Component({ + selector: 'app-form-section', + templateUrl: './form-section.component.html', + styleUrls: ['./form-section.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class DescriptionFormSectionComponent extends BaseComponent implements OnInit, OnChanges { + + @Input() section: DescriptionTemplateSection; + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() visibilityRulesService: VisibilityRulesService; + + // @Input() datasetProfileId: String; + // @Input() form: UntypedFormGroup; + @Input() tocentry: ToCEntry; + @Input() pathName: string; + @Input() path: string; + @Input() linkToScroll: LinkToScroll; + @Input() hiddenEntriesIds: string[] = []; + panelExpanded = true; + subsectionLinkToScroll: LinkToScroll; + @Output() askedToScroll = new EventEmitter(); + tocentriesType = ToCEntryType; + @Input() TOCENTRY_ID_PREFIX = ""; + + constructor( + private changeDetector: ChangeDetectorRef + ) { + super(); + + } + + ngOnInit() { + + this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { + this.changeDetector.markForCheck(); + }); + // Set comment fields to properties + this.section.fieldSets.forEach(fieldSet => { + if (fieldSet.hasCommentField && !this.propertiesFormGroup.contains('commentFieldValue' + fieldSet.id)) { + const item: DescriptionFieldEditorModel = new DescriptionFieldEditorModel(); + item.key = 'commentFieldValue' + fieldSet.id; + this.propertiesFormGroup.addControl('commentFieldValue' + fieldSet.id, item.buildForm()); + } + }); + + //TODO uncomment + // if (this.tocentry) {//maybe not needed as well + // this.form = this.tocentry.form as UntypedFormGroup; + // } + // this.initMultipleFieldsVisibility(); + } + + ngOnChanges(changes: SimpleChanges) { + + if (changes['linkToScroll']) { + if (changes['linkToScroll'].currentValue && changes['linkToScroll'].currentValue.section) { + + if (this.pathName === changes['linkToScroll'].currentValue.section) { + this.panelExpanded = true; + } else if (changes['linkToScroll'].currentValue.section.includes(this.pathName)) { + this.subsectionLinkToScroll = changes['linkToScroll'].currentValue; + this.panelExpanded = true; + } + } + } + } + + // setMultipleFieldVisibility(parentCompositeField, compositeField: DatasetDescriptionCompositeFieldEditorModel, idMappings: { old: string, new: string }[]) { + // // ** COMPOSITE FIELD IS SHOWN OR HIDDEN FROM ANOTHER ELEMENT + // const compositeFieldVisibilityDependencies = this.visibilityRulesService.getVisibilityDependency(parentCompositeField); + // if (compositeFieldVisibilityDependencies && compositeFieldVisibilityDependencies.length) { + + // compositeFieldVisibilityDependencies.forEach(x => { + // const visRule: Rule = { + // targetField: compositeField.id, + // sourceField: x.sourceControlId, + // requiredValue: x.sourceControlValue + // } + // this.visibilityRulesService.addNewRule(visRule); + // }); + // } + + // // console.log('idMappings ', idMappings); + // parentCompositeField.fields.forEach(element => { + // // console.log(this.visibilityRulesService.getVisibilityDependency(element.id)); + // const dependency = this.visibilityRulesService.getVisibilityDependency(element.id); + // if (dependency && dependency.length) { + // // * INNER VISIBILITY DEPENDENCIES + // // * IF INNER INPUT HIDES ANOTHER INNER INPUT + // const innerDependency = parentCompositeField.fields.reduce((innerD, currentElement) => { + // const innerDependecies = dependency.filter(d => d.sourceControlId === currentElement.id); + // return [...innerD, ...innerDependecies]; + // }, []) as VisibilityRuleSource[]; + // if (innerDependency.length) { + // //Build visibility source + // const updatedRules = innerDependency.map(x => { + // const newId = idMappings.find(y => y.old === x.sourceControlId); + // return { ...x, sourceControlId: newId.new }; + // }); + // // const visRule: VisibilityRule = { + // // targetControlId: idMappings.find(x => x.old === element.id).new, + // // sourceVisibilityRules: updatedRules + // // } + + + // const rules = updatedRules.map(x => { + // return { + // requiredValue: x.sourceControlValue, + // sourceField: x.sourceControlId, + // targetField: idMappings.find(l => l.old === element.id).new, + // type: '' + // } as Rule; + // }); + + // rules.forEach(rule => { + // this.visibilityRulesService.addNewRule(rule); + // }) + + // // this.visibilityRulesService.appendVisibilityRule(visRule); + // } + + // } + + + // // * OUTER DEPENDENCIES + + // // * IF INNER INPUT HIDES OUTER INPUTS + // const innerIds = idMappings.map(x => x.old) as string[]; + + // const outerTargets = this.visibilityRulesService.getVisibilityTargets(element.id).filter(x => !innerIds.includes(x)); + + // outerTargets.forEach(target => { + + // const outerRules = (this.visibilityRulesService.getVisibilityDependency(target) as VisibilityRuleSource[]).filter(x => x.sourceControlId === element.id); + // const updatedRules = outerRules.map(x => { + // return { ...x, sourceControlId: idMappings.find(y => y.old === element.id).new }; + // }); + + // // const visRule: VisibilityRule = { + // // targetControlId: target, + // // sourceVisibilityRules: updatedRules + // // } + + + // const rules = updatedRules.map(x => { + // return { + // requiredValue: x.sourceControlValue, + // sourceField: x.sourceControlId, + // targetField: target, + // type: '' + // } as Rule; + // }) + // rules.forEach(rule => { + // this.visibilityRulesService.addNewRule(rule); + // }) + // // this.visibilityRulesService.appendVisibilityRule(visRule); + // }); + // // * IF INNER INPUT IS HIDDEN BY OUTER INPUT + // if (dependency && dependency.length) { + // const fieldsThatHideInnerElement = dependency.filter(x => !innerIds.includes(x.sourceControlId)); + // if (fieldsThatHideInnerElement.length) { + // fieldsThatHideInnerElement.forEach(x => { + // const visRule: Rule = { + // targetField: idMappings.find(l => l.old === element.id).new, + // sourceField: x.sourceControlId, + // requiredValue: x.sourceControlValue + // } + // const shouldBeVisibile = this.visibilityRulesService.checkTargetVisibilityProvidedBySource(x.sourceControlId, element.id); + // this.visibilityRulesService.addNewRule(visRule, shouldBeVisibile); + // }); + // } + // } + // // console.log(`for ${element.id} targets are`, outerTargets); + // }); + // } + + // initMultipleFieldsVisibility() { + // (this.form.get('compositeFields') as UntypedFormArray).controls.forEach(control => { + // let parentCompositeField = (control as UntypedFormGroup).getRawValue(); + // if (parentCompositeField.multiplicityItems && parentCompositeField.multiplicityItems.length > 0) { + // parentCompositeField.multiplicityItems.forEach(compositeField => { + // let idMappings: { old: string, new: string }[] = [{ old: parentCompositeField.id, new: compositeField.id }]; + // parentCompositeField.fields.forEach((field, index) => { + // idMappings.push({ old: field.id, new: compositeField.fields[index].id }); + // }); + // this.setMultipleFieldVisibility(parentCompositeField, compositeField, idMappings); + // }) + // } + // }); + // } + + // addMultipleField(fieldsetIndex: number) { + // if (this.form.get('compositeFields').get('' + fieldsetIndex).disabled) { + // return; + // } + // const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as UntypedFormGroup).getRawValue(); + // const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))); + + // const ordinal = multiplicityItemsArray.length ? multiplicityItemsArray.controls.reduce((ordinal, currentControl) => { + // const currentOrdinal = currentControl.get('ordinal').value as number; + + // if (currentOrdinal >= ordinal) { + // return currentOrdinal + 1; + // } + // return ordinal as number; + // }, 0) : 0; + // const idMappings = [] as { old: string, new: string }[]; + // const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, ordinal, idMappings); + + // this.setMultipleFieldVisibility(compositeFieldToBeCloned, compositeField, idMappings); + // multiplicityItemsArray.push(compositeField.buildForm()); + // } + + // deleteCompositeFieldFormGroup(compositeFildIndex: number) { + // const numberOfItems = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').value.length; + // for (let i = 0; i < numberOfItems; i++) { + // const multiplicityItem = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; + // this.form.get('compositeFields').get('' + compositeFildIndex).get('fields').get('' + i).patchValue(multiplicityItem); + // } + // ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(0); + // } + + // deleteMultipeFieldFromCompositeFormGroup(compositeFildIndex: number, fildIndex: number) { + // const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))); + // multiplicityItemsArray.removeAt(fildIndex); + // multiplicityItemsArray.controls.forEach((control, i) => { + // try { + // control.get('ordinal').setValue(i); + // } catch { + // throw 'Could not find ordinal'; + // } + // }); + // } + + // onAskedToScroll(id: string) { + // this.panelExpanded = true; + // this.askedToScroll.emit(id); + // } + + // visibleControls(controls: any[]) { + // return controls.filter(control => this.visibilityRulesService.isVisibleMap[control.get('id').value)); + // } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html new file mode 100644 index 000000000..407d1d64b --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html @@ -0,0 +1,54 @@ + +
+
+
+
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + +

+ {{pageEntry.numbering}}. {{pageEntry.label |uppercase}} +

+
+
+ + +
+ +
+
+
+
+
+
+ +
+
+
+
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.scss b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.scss new file mode 100644 index 000000000..3b8872d71 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.scss @@ -0,0 +1,47 @@ +@media (max-width: 768px) { + .dynamic-form-editor { + .form-container { + padding: 0px; + } + } +} + +.form-container { +} + +.intro { + text-align: left; + font-weight: 400; + letter-spacing: 0px; + color: #212121; + opacity: 1; + margin: 3rem 0rem 3rem 0rem; +} + +.dynamic-form-editor { + mat-vertical-stepper { + background-color: #ffffff; + } +} + +// ::ng-deep .mat-form-field-flex > .mat-form-field-infix {padding: 0.4em 0px !important;} +// ::ng-deep .mat-form-field-label-wrapper { +// top: -1.5em; +// } + +// ::ng-deep +// .mat-form-field-appearance-outline.mat-form-field-can-float.mat-form-field-should-float +// .mat-form-field-label { +// transform: translateY(-1.1em) scale(0.75); +// width: 133.33333%; +// } + +// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { +// background: #fafafa !important; +// } + +// ::ng-deep .mat-step-header .mat-step-icon-selected, +// .mat-step-header .mat-step-icon-state-done, +// .mat-step-header .mat-step-icon-state-edit { +// background-color: var(--primary-color) !important; +// } diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts new file mode 100644 index 000000000..a3cd19334 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts @@ -0,0 +1,371 @@ +import { AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { MatExpansionPanel } from '@angular/material/expansion'; +import { Rule } from '@app/core/model/dataset-profile-definition/rule'; +import { BaseComponent } from '@common/base/base.component'; +import { LinkToScroll } from '../table-of-contents/table-of-contents.component'; +import { VisibilityRulesService } from './visibility-rules/visibility-rules.service'; +import { DescriptionTemplate, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { Guid } from '@common/types/guid'; + +@Component({ + selector: 'app-description-form', + templateUrl: './description-form.component.html', + styleUrls: ['./description-form.component.scss'] +}) +export class DescriptionFormComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges { + + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() descriptionTemplate: DescriptionTemplate; + @Input() visibilityRulesService: VisibilityRulesService; + + // @ViewChild('stepper', { static: false }) stepper: MatStepper; + @Input() path: string; + @Input() visibilityRules: Rule[] = []; + @Input() datasetDescription: String; + @Input() linkToScroll: LinkToScroll; + @Output() formChanged: EventEmitter = new EventEmitter(); + @Output() fieldsetFocusChange: EventEmitter = new EventEmitter(); + + // tocentries: ToCEntry[]; + + + @Input() TOCENTRY_ID_PREFIX = ""; + @Output() visibilityRulesInstance = new EventEmitter(); + + // public hiddenEntriesIds: string[] = []; + + constructor( + ) { + super(); + + } + + ngOnInit() { + this.init(); + } + + ngOnChanges(changes: SimpleChanges) { + this.init(); + // When the form is changed set stepper index to 0. + // if (this.stepper && changes['form'] && !changes['form'].isFirstChange()) { + // this.stepper.selectedIndex = 0; + // } else if (this.stepper && changes['linkToScroll'] && changes['linkToScroll'].currentValue) { + // if (changes['linkToScroll'].currentValue.page >= 0) { + // this.stepper.selectedIndex = changes['linkToScroll'].currentValue.page; + // } + // } + } + + ngAfterViewInit() { + + } + + getSectionsOfPage(pageId: string) : DescriptionTemplateSection[]{ //TODO: change that to something more performant since its used at html page. + return this.descriptionTemplate.definition.sections.filter(x => x.page == pageId); + } + init() { + // this.tocentries = this.getTocEntries(); + // const rules_to_append = this._enrichWithMultiplicityRules(this.tocentries); + + // this.visibilityRulesService.buildVisibilityRules([...this.visibilityRules, ...rules_to_append], this.form); + + // if (this.form) { + // this.form.valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(val => { + // this.formChanged.emit(val); + // }); + // } + // this.visibilityRulesInstance.emit(this.visibilityRulesService); + + + + + // this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries); + + // this.visibilityRulesService.visibilityChange + // .pipe( + // takeUntil(this._destroyed), + // debounceTime(100) + // ) + // .subscribe(_ => { + // this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries); + // }) + } + + onAskedToScroll(panel: MatExpansionPanel, id?: string) { + panel.open(); + this.fieldsetFocusChange.emit(id); + } + + + + // private _enrichWithMultiplicityRules(tocentries: ToCEntry[]): Rule[] { + // if (tocentries) { + // return tocentries.map(entry => { + // if (entry.type === ToCEntryType.Field) return []; // * TODO Me to tora implementation den tha ftasei pote edo + + + // if (entry.type === ToCEntryType.FieldSet) { + // // if(multiplicity: ) + // try { + // // TODO OTAN KANW HIDE MULTIPLE PEDIO TOTE STO ON SHOW HANO TA VALUES (AUTO MPOREI NA EINAI KAI LEGIT) ('NA DOUME AN ONTOS DIAGRAFONTAI I APLA DEN TA DEIXNOUME') + // // * UPDATE KANEI DESTROY TO COMPONENT H NGIF . PITHANOTATA NA XREIASTEI NA TO KANOUME HIDDEN AN THELOUME KATI ALLO + // const multiplicity = entry.form.get('multiplicity').value; + // if ((multiplicity.max > 1) && (multiplicity.min > 0) && (multiplicity.max >= multiplicity.min)) { // has valid multiplicity + // return this._createAndAppendVisibilityRule(entry); + // } + // } catch { + + // } + // return []; + // } + + // if (entry.subEntries) { + // return this._enrichWithMultiplicityRules(entry.subEntries); + // } + // }) + // .reduce((r, c) => { return [...c, ...r] }, []); + // } + // return []; + // } + + // private _createAndAppendVisibilityRule(entry: ToCEntry): Rule[] { + + + // const rules_to_append = []; + + // if (entry && (entry.type === ToCEntryType.FieldSet)) { + + // //childs that are either target or source + // const childIdsWithVisRules = (entry.form.get('fields') as UntypedFormArray).controls.reduce((all, s) => { + // const sval = s.value as Field; + // return this.visibilityRules.find(x => (x.targetField === sval.id) || (x.sourceField === sval.id)) ? [...all, sval] : all; + // }, []) as Field[]; + + + // const innerCompositeFieldOriginalIds = (entry.form.get('fields') as UntypedFormArray).controls.map(x => x.get('id').value) as string[]; + + // //multiplicity items + // const multiplicityItemsValue = entry.form.get('multiplicityItems').value as CompositeField[]; + + + // // ********* FIELDS OF FIELDSET ARE EITHER TARGETS OR SOURCES ***** + + + // if (childIdsWithVisRules.length && multiplicityItemsValue && multiplicityItemsValue.length) { + // //check each multiplicity item composite field + // multiplicityItemsValue.forEach(mi => { + + // const multiplicityCompositeFieldIds = mi.fields.map(x => x.id); + // const idMappings = multiplicityCompositeFieldIds.map(x => { + // return { + // original: innerCompositeFieldOriginalIds.find(l => x.includes(l)), + // multiplicityIdValue: x + // } + // }) as { original: string, multiplicityIdValue: string }[]; + + // //each field of mutliplicity item + // mi.fields.forEach(field => { + + + // //get original visibility rules (original field) + + // //original id + // const original_id = childIdsWithVisRules.find(x => field.id.includes(x.id)).id; + + + // //get vis rules + + // //as source + // const original_as_source = this.visibilityRules.filter(x => x.sourceField === original_id); + // const original_as_target = this.visibilityRules.filter(x => x.targetField === original_id); + + + + // if (original_as_source.length) { + + // //inner dependencies + // const innerDep = original_as_source.filter(x => innerCompositeFieldOriginalIds.includes(x.targetField)); + // innerDep.forEach(x => { + // const newRule = { ...x, sourceField: field.id, targetField: idMappings.find(l => l.original === x.targetField).multiplicityIdValue } as Rule; + // rules_to_append.push(newRule); + // }) + + + // //outer dependencies + // const outerDep = original_as_source.filter(x => !innerCompositeFieldOriginalIds.includes(x.targetField)); + // outerDep.forEach(x => { + // const newRule = { ...x, sourceField: field.id }; + // rules_to_append.push(newRule); + // }) + // } + + + + // if (original_as_target.length) { + + // //inner dependencies + // const innerDep = original_as_target.filter(x => innerCompositeFieldOriginalIds.includes(x.sourceField)); + // innerDep.forEach(x => { + // const newRule = { ...x, targetField: field.id, sourceField: idMappings.find(l => l.original === x.sourceField).multiplicityIdValue } as Rule; + // rules_to_append.push(newRule); + // }) + + // //outer dependencies + // const outerDep = original_as_target.filter(x => !innerCompositeFieldOriginalIds.includes(x.sourceField)); + // outerDep.forEach(x => { + // const newRule = { ...x, targetField: field.id } as Rule; + // rules_to_append.push(newRule); + // }) + // } + + // }) + // }); + // } + + + + + // // ** FIELDSET ITSELF IS TARGET + // // ** source it can never be + + // const compositeFieldAsTargetRules = this.visibilityRules.filter(x => x.targetField === entry.id); + // const idCompositeFieldMappings = multiplicityItemsValue.map(x => { + // return { + // originalValue: entry.id, + // newValue: x.id + // } + // }) as { originalValue: string, newValue: string }[]; + + + // if (compositeFieldAsTargetRules.length) { + + // compositeFieldAsTargetRules.forEach(x => { + // idCompositeFieldMappings.forEach(l => { + // const newRule = { ...x, targetField: l.newValue }; + // rules_to_append.push(newRule); + // }); + // }); + // } + + + // } + + // return rules_to_append; + // } + + // private _buildRecursively(form: UntypedFormGroup, whatAmI: ToCEntryType): ToCEntry { + // if (!form) return null; + + // switch (whatAmI) { + // case ToCEntryType.Section: + // const sections = form.get('sections') as UntypedFormArray; + // const fieldsets = form.get('compositeFields') as UntypedFormArray; + + + // const tempResult: ToCEntry[] = []; + + // if (sections && sections.length) { + // sections.controls.forEach(section => { + // tempResult.push(this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section)); + // }); + + // } else if (fieldsets && fieldsets.length) { + // fieldsets.controls.forEach(fieldset => { + // tempResult.push(this._buildRecursively(fieldset as UntypedFormGroup, ToCEntryType.FieldSet)); + // }); + // } + // return { + // // form: form, + // id: form.get('id').value, + // label: form.get('title').value, + // numbering: '', + // subEntries: tempResult, + // subEntriesType: sections && sections.length ? ToCEntryType.Section : ToCEntryType.FieldSet, + // type: ToCEntryType.Section, + // ordinal: form.get('ordinal').value + // } + // case ToCEntryType.FieldSet: + // return { + // // form: form, + // label: form.get('title').value, + // id: form.get('id').value, + // numbering: 's', + // subEntries: [], + // subEntriesType: ToCEntryType.Field, + // type: ToCEntryType.FieldSet, + // ordinal: form.get('ordinal').value + // } + // } + // } + + // private _sortByOrdinal(tocentries: ToCEntry[]) { + + // if (!tocentries || !tocentries.length) return; + + // tocentries.sort(this._customCompare); + // tocentries.forEach(entry => { + // this._sortByOrdinal(entry.subEntries); + // }); + // } + + // private _customCompare(a, b) { + // return a.ordinal - b.ordinal; + // } + + // private _calculateNumbering(tocentries: ToCEntry[], depth: number[] = []) { + // if (!tocentries || !tocentries.length) { + // return; + // } + + // let prefixNumbering = depth.length ? depth.join('.') : ''; + + // if (depth.length) prefixNumbering = prefixNumbering + "."; + // tocentries.forEach((entry, i) => { + // entry.numbering = prefixNumbering + (i + 1); + // this._calculateNumbering(entry.subEntries, [...depth, i + 1]) + // }); + // } + + // getTocEntries(): ToCEntry[] { + // if (!this.form) { return []; } + // const result: ToCEntry[] = []; + + // //build parent pages + // (this.form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { + // result.push({ + // id: i + 'id', + // label: pageElement.get('title').value, + // type: ToCEntryType.Page, + // // form: pageElement, + // numbering: (i + 1).toString(), + // subEntriesType: ToCEntryType.Section, + // subEntries: [], + // ordinal: pageElement.get('ordinal').value + // } as ToCEntry) + // }); + + + + // result.forEach((entry, i) => { + + // const sections = entry.form.get('sections') as UntypedFormArray; + + // sections.controls.forEach(section => { + // const tempResults = this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section); + // entry.subEntries.push(tempResults); + // }); + + // }); + + // this._sortByOrdinal(result); + // //calculate numbering + // this._calculateNumbering(result); + // return result; + + // } + + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts new file mode 100644 index 000000000..6b3a9994a --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.module.ts @@ -0,0 +1,41 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from "@app/core/formatting.module"; +import { FileService } from "@app/core/services/file/file.service"; +import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; +import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { NgxDropzoneModule } from "ngx-dropzone"; +import { DescriptionFormCompositeTitleComponent } from './components/form-composite-title/form-composite-title.component'; +import { DescriptionFormFieldSetComponent } from './components/form-field-set/form-field-set.component'; +import { DescriptionFormFieldComponent } from './components/form-field/form-field.component'; +import { DescriptionFormSectionComponent } from './components/form-section/form-section.component'; +import { DescriptionFormComponent } from './description-form.component'; +import { VisibilityRulesService } from './visibility-rules/visibility-rules.service'; + + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + AutoCompleteModule, + RichTextEditorModule, + NgxDropzoneModule, + FormattingModule + ], + declarations: [ + DescriptionFormComponent, + DescriptionFormSectionComponent, + DescriptionFormFieldSetComponent, + DescriptionFormFieldComponent, + DescriptionFormCompositeTitleComponent + ], + exports: [ + DescriptionFormComponent + ], + providers: [ + FileService + ] +}) +export class DescriptionFormModule { } + diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule-source.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule-source.ts new file mode 100644 index 000000000..2db9978a3 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule-source.ts @@ -0,0 +1,4 @@ +export class VisibilityRuleSource { + public sourceControlId: string; + public sourceControlValue: string; +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule.ts new file mode 100644 index 000000000..b2fba603b --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rule.ts @@ -0,0 +1,6 @@ +import { VisibilityRuleSource } from "./visibility-rule-source"; + +export class VisibilityRule { + public targetControlId: string; + public sourceVisibilityRules: Array; +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts new file mode 100644 index 000000000..547b088ef --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/models/visibility-rules-context.ts @@ -0,0 +1,47 @@ +import { Rule } from "@app/core/model/dataset-profile-definition/rule"; +import { VisibilityRule } from "./visibility-rule"; + +export class VisibilityRulesContext { + + public rules: Array = new Array(); + + constructor() { } + + public getRulesFromKey(id: string): VisibilityRule { + + for (let i = 0; i < this.rules.length; i++) { + if (id === this.rules[i].targetControlId) { return this.rules[i]; } + } + return null; + } + + public buildVisibilityRuleContext(items: Array) { + items.forEach(item => { + this.addToVisibilityRulesContext(item); + }); + } + + public addToVisibilityRulesContext(item: Rule): void { + for (let i = 0; i < this.rules.length; i++) { + if (this.rules[i].targetControlId === item.targetField) { + + const newRule = { sourceControlId: item.sourceField, sourceControlValue: item.requiredValue }; + const ruleExists = this.rules[i].sourceVisibilityRules.find(x => { + return Object.keys(x).reduce((exact, key) => { + if (!exact) return false; + return x[key] === newRule[key]; + }, true); + }) + + if (!ruleExists) { + this.rules[i].sourceVisibilityRules.push(newRule); + } + + return; + } + } + const newVisibilityRuleArray = [({ sourceControlId: item.sourceField, sourceControlValue: item.requiredValue })]; + this.rules.push({ targetControlId: item.targetField, sourceVisibilityRules: newVisibilityRuleArray }); + return; + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts new file mode 100644 index 000000000..285e2a19d --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/description-form/visibility-rules/visibility-rules.service.ts @@ -0,0 +1,453 @@ +import { ApplicationRef, Injectable, NgZone } from '@angular/core'; +import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; +import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; +import { isNumeric } from '@app/utilities/enhancers/utils'; +import { Observable, Subject } from 'rxjs'; +import { VisibilityRule } from './models/visibility-rule'; +import { VisibilityRuleSource } from './models/visibility-rule-source'; +import { VisibilityRulesContext } from './models/visibility-rules-context'; +import { Rule } from '@app/core/model/dataset-profile-definition/rule'; +import { DescriptionTemplate, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; + +@Injectable() +export class VisibilityRulesService { + + private readonly VISIBILITY_RULE_LOGIC: 'OR' | 'AND' = 'OR'; + private readonly DEFAULTVISIBILITY = false; + + private visibilityRuleContext: VisibilityRulesContext; + private form: AbstractControl; + public elementVisibilityMap = new MapWithDefault(); + private elementVisibilityMapSubject = new Subject>(); + private elementComputationalMap = new Map>(); /// keep saved the values of each form control validity value + private _changeMade$ = new Subject(); + + + get isVisibleMap(): MapWithDefault { + // console.log('isVisibleMap'); + return this.elementVisibilityMap; + + }; /// keep saved the values of each form control validity value + + constructor( + public applicationReference: ApplicationRef, + public ngZone: NgZone + ) { + + } + + getElementVisibilityMapObservable(): Observable> { + this.isVisibleMap + console.log('getElementVisibilityMapObservable: '); + return this.elementVisibilityMapSubject.asObservable(); + } + + public checkElementVisibility(id: string): boolean { + console.log('checkElementVisibility: ' + id); + return true; + // if (this.visibilityRuleContext.rules.filter(item => item.targetControlId === id).length === 0) { return true; } + // console.log(this.elementVisibilityMap.has(id) ? this.elementVisibilityMap.get(id) : false); + // return this.elementVisibilityMap.has(id) ? this.elementVisibilityMap.get(id) : false; + } + + public buildVisibilityRules(item: Array, form: AbstractControl) { + this.visibilityRuleContext = new VisibilityRulesContext(); + this.visibilityRuleContext.buildVisibilityRuleContext(item || []); + this.form = form; + this.resetVisibilityRules(); + } + + public updateValueAndVisibility(id: string, value: any) { + console.log('updateValueAndVisibility: ' + id + ' value: ' + value); + const visibilityRules = this.visibilityRuleContext.rules.filter(item => item.sourceVisibilityRules.filter(source => source.sourceControlId === id).length > 0); + if (visibilityRules.length > 0) { + visibilityRules.forEach(item => this.evaluateVisibility(item, value, id)); + this.elementVisibilityMapSubject.next(this.elementVisibilityMap); + } + } + + private evaluateVisibility(visibilityRule: VisibilityRule, value: any, sourceId: string) {// source controlId is the same + console.log('evaluateVisibility: ' + visibilityRule + ' value: ' + value + ' sourceId: ' + sourceId); + + const targetId = visibilityRule.targetControlId; + const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); + + + if (value instanceof Array) { + + const parsedSourceControlValues = visibilityRule.sourceVisibilityRules.map(e => this.parseValue(e.sourceControlValue)); + const parsedValues = value.map(e => this.parseValue(e)); + + const isVisible = parsedValues.map(v => parsedSourceControlValues.includes(v)).reduce((acc, current) => acc || current, false); + + + // if(isVisible){ + // this._emitChangesIfNeeded(visibilityRule.targetControlId, true); + // this.elementVisibilityMap.set(visibilityRule.targetControlId, true); + // return; + // } + visibilityMap.set(sourceId, isVisible); + + } else { + const visibilityDependencySource = visibilityRule.sourceVisibilityRules.filter(x => x.sourceControlId === sourceId); + + const shouldBeVisible = visibilityDependencySource.reduce((isVisible, x) => { + + const shouldBeHidden = value !== null && (this.parseValue(value) !== this.parseValue(x.sourceControlValue)); + return this.VISIBILITY_RULE_LOGIC === 'OR' ? (isVisible || !shouldBeHidden) : (isVisible && !shouldBeHidden); + // if(value !== null && ) + }, this.VISIBILITY_RULE_LOGIC === 'AND'); + visibilityMap.set(sourceId, shouldBeVisible); + } + + + this.elementComputationalMap.set(targetId, visibilityMap);// unnessecary + + + const isVisible = this._computeVisibility(targetId); + this._emitChangesIfNeeded(targetId, isVisible); + const previousVisibility = this.elementVisibilityMap.get(targetId); + this.elementVisibilityMap.set(targetId, isVisible); + + if (!isVisible && previousVisibility !== isVisible) { + this.resetControlWithId(this.form, targetId); + } + + + // for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) { + // if (value != null && (this.parseValue(value) !== this.parseValue(visibilityRule.sourceVisibilityRules[i].sourceControlValue))) { + // this._emitChangesIfNeeded(visibilityRule.targetControlId, false); + // this.elementVisibilityMap.set(visibilityRule.targetControlId, false); + // this.resetControlWithId(this.form, visibilityRule.targetControlId); + // //this.updateValueAndVisibility(visibilityRule.targetControlId, null); + // // this.clearValues(targetPathKey); + // return; + // } + // } + // this._emitChangesIfNeeded(visibilityRule.targetControlId, true); + // this.elementVisibilityMap.set(visibilityRule.targetControlId, true); + + // this.updateValueAndVisibility(visibilityRule.targetControlId, null); + } + + + private _computeVisibility(targetId: string): boolean { + console.log('_computeVisibility: ' + targetId); + + const visibilityMap = this.elementComputationalMap.get(targetId); + const values = visibilityMap.values(); + let currentVal = values.next(); + let visibilityValues: boolean[] = []; + while (!currentVal.done) { + visibilityValues.push(currentVal.value); + currentVal = values.next(); + } + + + if (visibilityValues.length) { + return visibilityValues.reduce((r, c) => { + if (this.VISIBILITY_RULE_LOGIC === 'OR') { + return r || c; + } else { + return r && c; + } + }, visibilityValues[0]); + } + + return this.DEFAULTVISIBILITY; + } + + private resetVisibilityRules() { + console.log('resetVisibilityRules: '); + + this.elementVisibilityMap.clear(); + this.elementVisibilityMap = new MapWithDefault(); + this.elementComputationalMap.clear(); + this.elementComputationalMap = new Map>(); + this._populateComputationMap(); /// !IMPORTANT FOR THE AND LOGIC + this._changeMade$.next(); + } + + private _populateComputationMap(): void { + console.log('_populateComputationMap: '); + this.visibilityRuleContext.rules.forEach(rule => { + const targetId = rule.targetControlId; + const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); + rule.sourceVisibilityRules.forEach(vr => { + visibilityMap.set(vr.sourceControlId, this.DEFAULTVISIBILITY); + }); + this.elementComputationalMap.set(targetId, visibilityMap); + }); + } + + parseValue(value: any) { + if (typeof value === 'string') { + if (isNumeric(value)) { return value; } + else if (value === 'true') { + return true; + } + else if (value === 'false') { + return false; + } + else { return this.translate(value); } + } else { return value; } + } + + search(path, obj, target) { + for (const k in obj) { + if (obj.hasOwnProperty(k)) { + if (obj[k] === target) { + return path + '.' + k; + } else if (typeof obj[k] === 'object') { + const result = this.search(path + '.' + k, obj[k], target); + if (result) { + return result; + } + } + } + } + return false; + } + + scanIfChildsOfCompositeFieldHasVisibleItems(compositeFieldParent: UntypedFormGroup): boolean { + // console.log('scanIfChildsOfCompositeFieldHasVisibleItems: ' + compositeFieldParent); + + //TODO: implement this + return true; + // let isVisible = false; + // ((compositeFieldParent.get('fields'))).controls.forEach(element => { + // if (this.checkElementVisibility(element.get('id').value)) { + // isVisible = true; + // } + // }); + // return isVisible; + } + + private translate(item: any) { + try { + return JSON.parse(item).value; + } catch (error) { + return item; + } + } + + private resetControlWithId(formControl: AbstractControl, id: string) { + console.log('resetControlWithId: ' + id); + //TODO: implement this + // if (formControl instanceof UntypedFormGroup) { + // if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (formControl as UntypedFormGroup).get('id').value === id) { + // this.resetFieldFormGroup(formControl); + // } if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields') && (formControl as UntypedFormGroup).get('id').value === id) { + // this.resetCompositeFieldFormGroup(formControl); + // } else { + // Object.keys(formControl.controls).forEach(item => { + // const control = formControl.get(item); + // this.resetControlWithId(control, id); + // }); + // } + // } else if (formControl instanceof UntypedFormArray) { + // formControl.controls.forEach(item => { + // this.resetControlWithId(item, id); + // }); + // } + } + + private resetFieldFormGroup(formGroup: UntypedFormGroup) { + console.log('resetFieldFormGroup: ' + formGroup); + //TODO: implement this + // const renderStyle = formGroup.getRawValue().viewStyle.renderStyle; + // if (renderStyle === DatasetProfileFieldViewStyle.Validation || renderStyle === DatasetProfileFieldViewStyle.DatasetIdentifier) { + // formGroup.get('value').setValue({ identifier: '', type: '' }); + // } else { + // formGroup.get('value').setValue(formGroup.get('defaultValue').value ? this.parseValue(formGroup.get('defaultValue').value.value) : undefined); + // } + + } + + private resetCompositeFieldFormGroup(formGroup: UntypedFormGroup) { + console.log('resetCompositeFieldFormGroup: ' + formGroup); + //TODO: implement this + // (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { + // this.resetFieldFormGroup(element); + // }); + // (formGroup.get('multiplicityItems') as UntypedFormArray).controls.splice(0); + } + private _emitChangesIfNeeded(id: string, valueToBeSet: boolean) { + if (this.elementVisibilityMap.has(id)) { + if (this.elementVisibilityMap.get(id) != valueToBeSet) { + this._changeMade$.next(); + } + } else { + this._changeMade$.next(); + } + } + public get visibilityChange() { + return this._changeMade$.asObservable(); + } + public getVisibilityDependency(targetId: string): VisibilityRuleSource[] | null { + console.log('getVisibilityDependency: ' + targetId); + return this.visibilityRuleContext.rules.reduce((hasDependency, rule) => { + if (hasDependency) return hasDependency; + + if (rule.targetControlId === targetId) { + return rule.sourceVisibilityRules; + } + + return null; + }, null) as VisibilityRuleSource[]; + } + + public getVisibilityTargets(sourceId: string): string[] { + console.log('getVisibilityTargets: ' + sourceId); + return this.visibilityRuleContext.rules.filter(x => { + const result = x.sourceVisibilityRules.filter(y => y.sourceControlId === sourceId); + return result.length; + }).map(x => x.targetControlId); + } + + // public appendVisibilityRule(rule: VisibilityRule): void{ + + // const existingTargetRule = this.visibilityRuleContext.rules.find( r => r.targetControlId === rule.targetControlId); + + // if(existingTargetRule){ + // rule.sourceVisibilityRules.forEach(svr =>{ + // existingTargetRule.sourceVisibilityRules.push(svr); + // }); + // }else{ + // this.visibilityRuleContext.rules.push(rule); + // } + + + // } + + + //removes rule that has the specific id either as a source either as a target + public removeAllIdReferences(id: string): void { + console.log('removeAllIdReferences: ' + id); + + // * Remove from visibility rues and visibility rules context + + //remove as a target + const temp = this.visibilityRuleContext.rules.map((x, i) => (x.targetControlId === id) ? i : null); + const indexes = temp.filter(x => x !== null); + indexes.reverse().forEach(index => this.visibilityRuleContext.rules.splice(index, 1)); + this.elementVisibilityMap.delete(id); + + + + //remove as a source + const tbd = this.visibilityRuleContext.rules.reduce((to_be_deleted, rule, ruleIdx) => { + const idxs = rule.sourceVisibilityRules.map((x, i) => (x.sourceControlId === id) ? i : null).filter(x => x !== null); + idxs.reverse().forEach(index => rule.sourceVisibilityRules.splice(index, 1)); + + if (!rule.sourceVisibilityRules.length) { + to_be_deleted.push(ruleIdx); + } + return to_be_deleted + }, []); + + + //clean up empty + tbd.reverse().forEach(index => { + this.visibilityRuleContext.rules.splice(index, 1); + }); + + + + // * Remove from computational map + + // as a target + if (this.elementComputationalMap.get(id)) { + this.elementComputationalMap.delete(id); + } + + + // as a source + const keyIterator = this.elementComputationalMap.keys(); + let currentKey = keyIterator.next(); + + + while (!currentKey.done) { + const currentVals = this.elementComputationalMap.get(currentKey.value); + currentVals.delete(id); + currentKey = keyIterator.next(); + } + } + + + public addNewRule(rule: Rule, currentVisibility = this.DEFAULTVISIBILITY): void { + console.log('addNewRule: ' + rule + ' currentVisibility: ' + currentVisibility); + + const targetId = rule.targetField; + const sourceId = rule.sourceField; + this.visibilityRuleContext.addToVisibilityRulesContext(rule); + + + let visibilityMap = this.elementComputationalMap.get(targetId); + + if (!visibilityMap) { + visibilityMap = new Map(); + this.elementComputationalMap.set(targetId, visibilityMap); + } + + visibilityMap.set(sourceId, currentVisibility); + const isVisible = this._computeVisibility(targetId); + + this._emitChangesIfNeeded(targetId, isVisible); + this.elementVisibilityMap.set(targetId, isVisible); + this.elementVisibilityMapSubject.next(this.elementVisibilityMap); + } + + + /** + * Check what sourceId hides or shows the target field + * return true if no rule found + */ + public checkTargetVisibilityProvidedBySource(sourceId: string, targetId: string): boolean { + console.log('checkTargetVisibilityProvidedBySource: ' + sourceId + ' targetId: ' + targetId); + + const computationalMap = this.elementComputationalMap.get(targetId); + if (computationalMap) { + return !!computationalMap.get(sourceId); + } + + return true; + } + + public getVisibilityRulesFromDescriptionTempalte(descriptionTemplate: DescriptionTemplate): Rule[] { + console.log('getVisibilityRulesFromDescriptionTempalte: ' + descriptionTemplate); + const result: Rule[] = this.getVisibilityRulesFromDescriptionTempalteSections(descriptionTemplate?.definition?.sections); + return result; + } + + public getVisibilityRulesFromDescriptionTempalteSections(sections: DescriptionTemplateSection[]): Rule[] { + console.log('getVisibilityRulesFromDescriptionTempalteSections: ' + sections); + const result: Rule[] = []; + + sections.forEach(section => { + if (section.sections != null) { result.push(...this.getVisibilityRulesFromDescriptionTempalteSections(section.sections)); }; + section?.fieldSets?.forEach(fieldSet => { + fieldSet?.fields?.forEach(field => { + field.visibilityRules?.forEach(visibilityRule => { + result.push({ + sourceField: field.id.toString(), + targetField: visibilityRule.target, + requiredValue: visibilityRule.value + }) + }); + }); + }); + }); + return result; + } +} + +class MapWithDefault extends Map { + get(key) { + console.log('MapWithDefault'); + if (!this.has(key)) { + this.set(key, true); + } + return super.get(key); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.html b/dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.html similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.html rename to dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.html diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/dataset-external-references-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.ts diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html b/dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.html similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.html rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.html diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss b/dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.scss rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component.ts rename to dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.ts diff --git a/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.html b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.html new file mode 100644 index 000000000..56966d9ab --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.html @@ -0,0 +1,5 @@ +
+
{{progressSoFar}} {{'GENERAL.PREPOSITIONS.OF' | translate}} {{total}}
+ +
{{value}}%
+
diff --git a/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.scss b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.scss new file mode 100644 index 000000000..a15510639 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.scss @@ -0,0 +1,16 @@ +.percentage { + color: #212121; + opacity: 0.7; + font-weight: 400; + font-size: 0.875rem; +} + +.progress-bar { + border-radius: 20px; + height: 11px; + +} + +::ng-deep .mat-progress-bar .mat-progress-bar-fill::after { + border-radius: 20px !important; +} diff --git a/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts new file mode 100644 index 000000000..908acd641 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.component.ts @@ -0,0 +1,211 @@ +import {ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; +import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from 'rxjs/operators'; + +@Component({ + selector: 'app-form-progress-indication', + templateUrl: './form-progress-indication.component.html', + styleUrls: ['./form-progress-indication.component.scss'] +}) +export class FormProgressIndicationComponent extends BaseComponent implements OnInit, OnChanges { + @Input() formGroup: UntypedFormGroup; + @Input() isDmpEditor: boolean; + @Input() isDatasetEditor: boolean; + @Input() public progressValueAccuracy = 2; + determinateProgressValue: number; + progressSoFar: number; + total: number; + percent: number; + + constructor(private visibilityRulesService: VisibilityRulesService) { super(); } + + public value = 0; + ngOnInit() { + this.init(); + } + + ngOnChanges(changes: SimpleChanges) { + if(changes.formGroup) { + this.init(); + } + } + + init() { + setTimeout(() => {this.calculateValueForProgressbar();}); + this.formGroup + .valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(control => { + setTimeout(() => {this.calculateValueForProgressbar();}); + }); + } + + calculateValueForProgressbar() { + if (this.isDmpEditor) { + this.progressSoFar = this.countFormControlsValidForProgress(this.formGroup); + this.total = this.countFormControlsRequiredFieldsForTotal(this.formGroup); + } else if (this.isDatasetEditor) { + this.progressSoFar = this.countFormControlsValidForProgress(this.formGroup) + this.countFormControlsWithValueForProgress(this.formGroup); + this.total = this.countFormControlsRequiredFieldsForTotal(this.formGroup, true) + this.CountFormControlDepthLengthFotTotal(this.formGroup); + } else { + this.progressSoFar = this.countFormControlsWithValueForProgress(this.formGroup); + this.total = this.CountFormControlDepthLengthFotTotal(this.formGroup); + } + this.percent = (this.progressSoFar / this.total) * 100; + this.value = Number.parseFloat(this.percent.toPrecision(this.progressValueAccuracy)); + } + + countFormControlsWithValueForProgress(formControl: AbstractControl): number { + let valueCurent = 0; + if (formControl instanceof UntypedFormGroup) { + if (this.checkFormsIfIsFieldsAndVisible(formControl) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { + if (this.hasValue(formControl)) + valueCurent++; + } + if (this.chechFieldIfIsFieldSetAndVisible((formControl as UntypedFormGroup)) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { + valueCurent = valueCurent + this.compositeFieldsGetChildsForProgress(formControl); + } else { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(control); + }); + } + } else if (formControl instanceof UntypedFormArray) { + formControl.controls.forEach(item => { + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(item); + }); + } + return valueCurent; + } + private hasValue(formGroup: UntypedFormGroup): boolean { + return formGroup.get('value').valid && formGroup.get('value').value != null && formGroup.get('value').value !== '' && (this.visibilityRulesService.isVisibleMap[formGroup.get('id').value] ?? true); + } + + private compositeFieldsGetChildsForProgress(formGroup: UntypedFormGroup): number { + let valueCurent = 0; + if (this.visibilityRulesService.isVisibleMap[formGroup.get('id').value] ?? true) { + (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); + }); + + (formGroup.get('multiplicityItems') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { + valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); + }); + } + return valueCurent; + } + + private checkIfIsRequired(formControl: UntypedFormGroup): boolean { + return !!(formControl.get('validationRequired') && formControl.get('validationRequired').value); + + } + + private checkFormsIfIsFieldsAndVisible(formControl: UntypedFormGroup): boolean { + if (formControl.contains('id') && formControl.contains('value')) { + return true; + } + return false; + } + private chechFieldIfIsFieldSetAndVisible(formControl: UntypedFormGroup): boolean { + if (formControl.contains('id') && formControl.contains('fields')) { + return true; + } + return false; + } + + CountFormControlDepthLengthFotTotal(formControl: AbstractControl): number { + let valueCurent = 0; + if (formControl instanceof UntypedFormArray) { + formControl.controls.forEach(item => { + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(item); + }); + } else if (formControl instanceof UntypedFormGroup) { + if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (this.visibilityRulesService.isVisibleMap[(formControl as UntypedFormGroup).get('id').value] ?? true) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { + valueCurent++; + } else if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields')) { + valueCurent = valueCurent + this.compositeFieldsGetChildsForTotal(formControl); + } else { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(control); + }); + } + } + + return valueCurent; + } + + private compositeFieldsGetChildsForTotal(formGroup: UntypedFormGroup): number { + let valueCurent = 0; + if (this.visibilityRulesService.isVisibleMap[formGroup.get('id').value] ?? true) { + (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); + }); + (formGroup.get('multiplicityItems') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { + valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); + }); + } + return valueCurent; + } + + countFormControlsValidForProgress(formControl: AbstractControl): number { + let valueCurrent = 0; + if (formControl instanceof UntypedFormControl) { + if (this.controlRequired(formControl) && this.controlEnabled(formControl) && formControl.valid) { + valueCurrent++; + } + } else if (formControl instanceof UntypedFormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + valueCurrent = valueCurrent + this.countFormControlsValidForProgress(control); + }); + } else if (formControl instanceof UntypedFormArray) { + formControl.controls.forEach(item => { + valueCurrent = valueCurrent + this.countFormControlsValidForProgress(item); + }); + } + return valueCurrent; + } + + countFormControlsRequiredFieldsForTotal(formControl: AbstractControl, checkVisibility = false): number { + let valueCurrent = 0; + if (formControl instanceof UntypedFormControl) { + if (this.controlRequired(formControl) && this.controlEnabled(formControl)) { + valueCurrent++; + } + } else if (formControl instanceof UntypedFormGroup) { + if(!checkVisibility || (!formControl.get('id')?.value || (this.visibilityRulesService.isVisibleMap[formControl.get('id').value] ?? true))) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + valueCurrent = valueCurrent + this.countFormControlsRequiredFieldsForTotal(control, checkVisibility); + }); + } + } else if (formControl instanceof UntypedFormArray) { + formControl.controls.forEach(item => { + valueCurrent = valueCurrent + this.countFormControlsRequiredFieldsForTotal(item, checkVisibility); + }); + } + return valueCurrent; + } + + controlRequired(formControl: AbstractControl) { + if (formControl.validator) { + const validator = formControl.validator({} as AbstractControl); + if (validator && validator.required) { + return true; + } + } else { return false } + } + + controlEnabled(formControl: AbstractControl) { + if (formControl.enabled) { + return true; + } else { return false } + } + + isEditor(): boolean { + return this.isDmpEditor || this.isDatasetEditor; + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts new file mode 100644 index 000000000..5a834c683 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/form-progress-indication/form-progress-indication.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { FormProgressIndicationComponent } from './form-progress-indication.component'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule + ], + declarations: [ + FormProgressIndicationComponent + ], + exports: [ + FormProgressIndicationComponent + ] +}) +export class DescriptionFormProgressIndicationModule { } diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.html b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.html similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.html rename to dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.html diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.scss b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.scss rename to dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.scss diff --git a/dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.ts b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/description/dataset-wizard/prefill-dataset/prefill-dataset.component.ts rename to dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts new file mode 100644 index 000000000..395c8ff33 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry-type.enum.ts @@ -0,0 +1,6 @@ +export enum ToCEntryType { + Page = 0, + Section = 1, + FieldSet = 2, + Field = 3 +} diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts new file mode 100644 index 000000000..353f72d7e --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/models/toc-entry.ts @@ -0,0 +1,14 @@ +import { Guid } from "@common/types/guid"; +import { ToCEntryType } from "./toc-entry-type.enum"; + +export interface ToCEntry { + id: string; + label: string; + subEntriesType: ToCEntryType; + subEntries: ToCEntry[]; + type: ToCEntryType; + // form: AbstractControl; + numbering: string; + ordinal: number; + hidden?: boolean +} \ No newline at end of file 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 new file mode 100644 index 000000000..3ffaf7c2c --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.html @@ -0,0 +1,50 @@ +
+ + + + + + + + + + {{entry.numbering}}. {{entry.label}} + + + + + +
+ + + +
+
+ + + +
+ +
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.scss b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.scss new file mode 100644 index 000000000..91152786d --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.scss @@ -0,0 +1,33 @@ + +.internal-table{ + margin-left: 1em; + padding-left: 0.2rem; + +} +.table-entry{ + + text-overflow: ellipsis; + overflow: hidden; + padding-left: 0.2rem; + color: rgba(0, 0, 0, 0.54); + transition: color 100ms; + + display: block; + span{ + white-space: nowrap; + } +} + +.table-entry:hover{ + background-color: #ececec; + border-radius: 6px; +} +.selected { + color: #212121 !important; + font-weight: 700 !important; + opacity: 1 !important; +} + +.section{ + line-height: 1.7em; +} \ No newline at end of file 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 new file mode 100644 index 000000000..a6c554fb7 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts @@ -0,0 +1,168 @@ +import { Component, EventEmitter, Input, OnInit, Output, QueryList, SimpleChanges, ViewChildren } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { Guid } from '@common/types/guid'; +import { ToCEntry } from '../models/toc-entry'; +import { ToCEntryType } from '../models/toc-entry-type.enum'; + +@Component({ + selector: 'table-of-contents-internal', + styleUrls: ['./table-of-contents-internal.scss'], + templateUrl: './table-of-contents-internal.html' +}) +export class TableOfContentsInternal implements OnInit { + + @Input() tocentries: ToCEntry[] = null; + @Input() selected: ToCEntry = null; + // @Input() visibilityRules:Rule[] = []; + @Output() entrySelected = new EventEmitter(); + @Input() propertiesFormGroup: UntypedFormGroup; + + expandChildren: boolean[]; + tocEntryTypeEnum = ToCEntryType; + @Input() TOCENTRY_ID_PREFIX = ""; + @Input() showErrors: boolean = false; + @Input() hiddenEntries: string[] = []; + @Input() visibilityRulesService: VisibilityRulesService; + @ViewChildren(TableOfContentsInternal) internalTables: QueryList; + + constructor() { + } + ngOnInit(): void { + // console.log('component created'); + if (this.tocentries) { + this.expandChildren = this.tocentries.map(() => false); + if (this.selected) { + for (let i = 0; i < this.tocentries.length; i++) { + if (this._findTocEntryById(this.selected.id, this.tocentries[i].subEntries)) { + if (this.expandChildren) { + this.expandChildren[i] = true; + } + break; + } + } + } + } + } + + ngOnChanges(changes: SimpleChanges) { + if (changes.selected && this.selected) { + for (let i = 0; i < this.tocentries.length; i++) { + if (this._findTocEntryById(this.selected.id, this.tocentries[i].subEntries)) { + if (this.expandChildren) { + this.expandChildren[i] = true; + } + break; + } + } + } + // if (!this.isActive && this.links && this.links.length > 0) { + // this.links.forEach(link => { + // link.selected = false; + // }) + // this.links[0].selected = true; + // } + } + + toggleExpand(index) { + this.expandChildren[index] = !this.expandChildren[index]; + // console.log(this.expandChildren); + } + + navigateToFieldSet(entry: ToCEntry, event) { + if (entry.type === ToCEntryType.FieldSet) { + + const fieldSetId = entry.id; + const element = document.getElementById(this.TOCENTRY_ID_PREFIX + fieldSetId); + if (element) { + element.click();//open mat expansion panel + + //scroll asyn in 200 ms so the expansion panel is expanded and the element coordinates are updated + setTimeout(() => { + const element = document.getElementById(this.TOCENTRY_ID_PREFIX + fieldSetId); + if (element) { + element.scrollIntoView({ behavior: 'smooth' }); + } + }, 300); + } + + } + } + + + onEntrySelected(entry: ToCEntry) { + this.entrySelected.emit(entry); + } + + + calculateStyle(entry: ToCEntry) { + const style = {}; + style['font-size'] = entry.type === this.tocEntryTypeEnum.FieldSet ? '.9em' : '1em'; + return style; + } + + calculateClass(entry: ToCEntry) { + const myClass = {}; + + if (this.selected && entry.id === this.selected.id) { + myClass['selected'] = true; + } + + if (entry.type != this.tocEntryTypeEnum.FieldSet) { + myClass['section'] = true; + } + + return myClass; + } + + private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { + if (!tocentries || !tocentries.length) { + return null; + } + + let tocEntryFound = tocentries.find(entry => entry.id === id); + + if (tocEntryFound) { + return tocEntryFound; + } + + for (let entry of tocentries) { + const result = this._findTocEntryById(id, entry.subEntries); + if (result) { + tocEntryFound = result; + break; + } + } + + return tocEntryFound ? tocEntryFound : null; + } + public invalidChildsVisible(entry: ToCEntry): boolean { + if (!entry || !this.visibilityRulesService) { + return false; + } + + if (entry.type != this.tocEntryTypeEnum.FieldSet) { + return entry.subEntries.some(_ => this.invalidChildsVisible(_)); + } + if (entry.type === this.tocEntryTypeEnum.FieldSet) { + const id = entry.id; + if (!(this.visibilityRulesService.isVisibleMap[id.toString()] ?? true)) { + return false; + } + // const fieldsArray = entry.form.get('fields') as UntypedFormArray; + const hasError = !entry.subEntries.every(field => {//every invalid field should be invisible + //TODO: check this + // if (field.invalid) { + // const id = field.id; + // const isVisible = this.visibilityRulesService.isVisibleMap[id); + // if (isVisible) { + // return false; + // } + // } + return true; + }); + return hasError; + } + return false; + } +} diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.html b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.html new file mode 100644 index 000000000..b94d4efd7 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.html @@ -0,0 +1,24 @@ +
+
+ + {{link.name}} + +
+
+ +
+ +
+ + + +
+
+{{hiddenEntries | json}} diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.scss b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.scss new file mode 100644 index 000000000..7dbc877af --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.scss @@ -0,0 +1,80 @@ +.docs-toc-container { + width: 100%; + padding: 5px 0 10px 0px; + cursor: pointer; + // border-left: solid 4px #0c7489; + + .scroll-container { + overflow-y: auto; + // calc(100vh - 250px) + // height: calc(100vh - 250px); + } + + .docs-link { + color: rgba(0, 0, 0, 0.54); + // color: mat-color($app-blue-theme-foreground, secondary-text); + transition: color 100ms; + + &:hover, + &.docs-active { + .link-name { + background-color: #ececec; + border-radius: 6px; + // color: #0c7489; + } + // color: mat-color($primary, if($is-dark-theme, 200, default)); + } + } +} + +.docs-toc-heading { + margin: 0; + padding: 0; + font-size: 13px; + font-weight: bold; +} + +span { + line-height: 16px; + margin: 6px 0 0; + position: relative; + text-decoration: none; + display: block; + overflow: hidden; + color: #21212194; + font-weight: 400; + max-width: 290px; + min-width: 290px; + padding: 0rem .4rem; + span { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + width: 100%; + } +} + +.selected { + color: #212121 !important; + font-weight: 700 !important; + opacity: 1 !important; +} + +// .docs-level-mat-expansion-panel { +// margin-left: 12px; +// } + +.docs-level-h5 { + margin-left: 24px; +} + +// .internal-table-outer{ +// padding-left: 1.1em; +// width: 100%; +// } + +.internal-table{ + max-width: 320px; + min-width: 320px; +} \ No newline at end of file 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 new file mode 100644 index 000000000..8f107d4b7 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts @@ -0,0 +1,514 @@ +import { DOCUMENT } from '@angular/common'; +import { Component, EventEmitter, Inject, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { DescriptionTemplate, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { BaseComponent } from '@common/base/base.component'; +import { Subject, Subscription, interval } from 'rxjs'; +import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; +import { ToCEntry } from './models/toc-entry'; +import { ToCEntryType } from './models/toc-entry-type.enum'; +import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal'; + +export interface Link { + /* id of the section*/ + id: string; + /* header type h3/h4 */ + type: string; + /* If the anchor is in view of the page */ + active: boolean; + /* name of the anchor */ + name: string; + /* top offset px of the anchor */ + top: number; + page: number; + section: number; + show: boolean; + selected: boolean; +} + +@Component({ + selector: 'app-table-of-contents', + styleUrls: ['./table-of-contents.component.scss'], + templateUrl: './table-of-contents.component.html' +}) +export class TableOfContentsComponent extends BaseComponent implements OnInit, OnChanges { + + @ViewChild('internalTable') internalTable: TableOfContentsInternal; + + + @Input() links: Link[]; + container: string; + headerSelectors = '.toc-page-header, .toc-section-header, .toc-compositeField-header'; + @Output() stepFound = new EventEmitter(); + @Output() currentLinks = new EventEmitter(); + @Output() entrySelected = new EventEmitter(); + subscription: Subscription; + linksSubject: Subject = new Subject(); + + @Input() isActive: boolean; + + tocentries: ToCEntry[] = null; + @Input() TOCENTRY_ID_PREFIX = ''; + @Input() showErrors: boolean = false; + @Input() selectedFieldsetId: string; + + private _tocentrySelected: ToCEntry = null; + private isSelecting: boolean = false; + private _intersectionObserver: IntersectionObserver; + private _actOnObservation: boolean = true; + public hiddenEntries: string[] = []; + get tocentrySelected() { + return this.hasFocus ? this._tocentrySelected : null; + } + set tocentrySelected(value) { + this._tocentrySelected = value; + } + + @Input() propertiesFormGroup: UntypedFormGroup; + @Input() descriptionTemplate: DescriptionTemplate; + @Input() hasFocus: boolean = false; + @Input() visibilityRulesService: VisibilityRulesService; + show: boolean = false; + + constructor( + @Inject(DOCUMENT) private _document: Document, + // public visibilityRulesService: VisibilityRulesService + ) { + super(); + } + + + ngOnInit(): void { + + if (this.descriptionTemplate) { + this.tocentries = this.getTocEntries(this.descriptionTemplate); + if (this.visibilityRulesService) { + this.hiddenEntries = this._findHiddenEntries(this.tocentries); + } + + } else { + + //emit value every 500ms + const source = interval(500); + this.subscription = source.subscribe(val => { + const headers = Array.from(this._document.querySelectorAll(this.headerSelectors)) as HTMLElement[]; + this.linksSubject.next(headers); + }); + + if (!this.links || this.links.length === 0) { + this.linksSubject.asObservable() + .pipe(distinctUntilChanged((p: HTMLElement[], q: HTMLElement[]) => JSON.stringify(p) == JSON.stringify(q))) + .subscribe(headers => { + const links: Array = []; + + if (headers.length) { + let page; + let section; + let show + for (const header of headers) { + let name; + let id; + if (header.classList.contains('toc-page-header')) { // deprecated after removing stepper + name = header.innerText.trim().replace(/^link/, ''); + id = header.id; + page = header.id.split('_')[1]; + section = undefined; + show = true; + } else if (header.classList.contains('toc-section-header')) { + name = header.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue.trim().replace(/^link/, ''); + id = header.id; + page = header.id.split('.')[1]; + section = header.id; + if (header.id.split('.')[4]) { show = false; } + else { show = true; } + } else if (header.classList.contains('toc-compositeField-header')) { + name = (header.childNodes[0]).nodeValue.trim().replace(/^link/, ''); + id = header.id; + // id = header.parentElement.parentElement.parentElement.id; + show = false; + } + const { top } = header.getBoundingClientRect(); + links.push({ + name, + id, + type: header.tagName.toLowerCase(), + top: top, + active: false, + page: page, + section: section, + show: show, + selected: false + }); + } + } + this.links = links; + // Initialize selected for button next on dataset wizard component editor + this.links.length > 0 ? this.links[0].selected = true : null; + }) + } + } + + } + + private _findHiddenEntries(tocentries: ToCEntry[]): string[] { + if (!tocentries) return []; + + const invisibleEntries: string[] = [] + tocentries.forEach(entry => { + if (entry.type === ToCEntryType.FieldSet) { + const isVisible = this.visibilityRulesService.isVisibleMap[entry.id.toString()] ?? true; + if (!isVisible) { + invisibleEntries.push(entry.id.toString()); + } else { + //check field inputs + const oneFieldAtLeastIsVisible = entry.subEntries.some(field => this.visibilityRulesService.isVisibleMap[field.id.toString()] ?? true); + if (!oneFieldAtLeastIsVisible) { + invisibleEntries.push(entry.id.toString()); + } + } + } else { + const hiddenEntries = this._findHiddenEntries(entry.subEntries); + + if (entry.subEntries && (entry.subEntries.every(e => hiddenEntries.includes(e.id.toString())))) { + //all children all hidden then hide parent node; + invisibleEntries.push(entry.id.toString()); + } else { + invisibleEntries.push(...hiddenEntries); + } + } + }) + + return invisibleEntries; + } + + private _visibilityRulesSubscription: Subscription; + ngOnChanges(changes: SimpleChanges) { + + if (this.selectedFieldsetId) { + this.onToCentrySelected(this._findTocEntryById(this.selectedFieldsetId, this.tocentries), false); + this._actOnObservation = false; + setTimeout(() => { + this._actOnObservation = true; + }, 1000); + + } + + + if (changes['hasFocus'] && changes.hasFocus.currentValue) { + this._resetObserver(); + + } + + if ('visibilityRulesService') { + if (this._visibilityRulesSubscription) { + this._visibilityRulesSubscription.unsubscribe(); + this._visibilityRulesSubscription = null; + } + + if (!this.visibilityRulesService) return; + + this._visibilityRulesSubscription = this.visibilityRulesService.visibilityChange + .pipe(takeUntil(this._destroyed)) + .pipe(debounceTime(200)) + .subscribe(_ => { + if (this.hasFocus) { + this._resetObserver(); + this.hiddenEntries = this._findHiddenEntries(this.tocentries); + } + }); + this.hiddenEntries = this._findHiddenEntries(this.tocentries); + } + // if (!this.isActive && this.links && this.links.length > 0) { + // this.links.forEach(link => { + // link.selected = false; + // }) + // this.links[0].selected = true; + // } + } + + + private _resetObserver() { + if (this._intersectionObserver) {//clean up + this._intersectionObserver.disconnect(); + this._intersectionObserver = null; + } + + const options = { + root: null, + rootMargin: '-38% 0px -60% 0px', + threshold: 0 + } + + this._intersectionObserver = new IntersectionObserver((entries, observer) => { + if (!this._actOnObservation) { + return; + } + + entries.forEach(ie => { + if (ie.isIntersecting) { + try { + const target_id = ie.target.id.replace(this.TOCENTRY_ID_PREFIX, ''); + if (this.visibilityRulesService.isVisibleMap[target_id] ?? true) { + this.onToCentrySelected(this._findTocEntryById(target_id, this.tocentries)); + } + } catch { + + } + } + }) + }, options); + + const fieldsetsEtries = this._getAllFieldSets(this.tocentries); + + fieldsetsEtries.forEach(e => { + if (e.type === ToCEntryType.FieldSet) { + try { + const targetElement = document.getElementById(this.TOCENTRY_ID_PREFIX + e.id); + this._intersectionObserver.observe(targetElement); + } catch { + console.log('element not found'); + } + } + }); + } + + goToStep(link: Link) { + this.stepFound.emit({ + page: link.page, + section: link.section + }); + this.currentLinks.emit(this.links); + + setTimeout(() => { + const target = document.getElementById(link.id); + target.scrollIntoView(true); + + var scrolledY = window.scrollY; + if (scrolledY) { + window.scroll(0, scrolledY - 70); + } + }, 500); + } + + toggle(headerLink: Link) { + const headerPage = +headerLink.name.split(" ", 1); + let innerPage; + for (const link of this.links) { + link.selected = false; + if (link.type === 'mat-expansion-panel') { + innerPage = +link.name.split(".", 1)[0]; + if (isNaN(innerPage)) { innerPage = +link.name.split(" ", 1) } + } else if (link.type === 'h5') { + innerPage = +link.name.split(".", 1)[0]; + } + if (headerPage === innerPage && (link.type !== 'mat-expansion-panel' || (link.type === 'mat-expansion-panel' && link.id.split(".")[4]))) { + link.show = !link.show; + } + } + headerLink.selected = true; + } + + // getIndex(link: Link): number { + // return +link.id.split("_", 2)[1]; + // } + + + private _buildRecursivelySection(item: DescriptionTemplateSection): ToCEntry { + if (!item) return null; + + const sections = item.sections; + const fieldsets = item.fieldSets; + + + const tempResult: ToCEntry[] = []; + + if (sections && sections.length) { + sections.forEach(section => { + tempResult.push(this._buildRecursivelySection(section)); + }); + + } else if (fieldsets && fieldsets.length) { + fieldsets.forEach(fieldset => { + tempResult.push(this._buildRecursivelyFieldSet(fieldset)); + }); + } + return { + // form: form, + id: item.id, + label: item.title, + numbering: '', + subEntries: tempResult, + subEntriesType: sections && sections.length ? ToCEntryType.Section : ToCEntryType.FieldSet, + type: ToCEntryType.Section, + ordinal: item.ordinal + } + } + + private _buildRecursivelyFieldSet(item: DescriptionTemplateFieldSet): ToCEntry { + if (!item) return null; + const tempResult: ToCEntry[] = []; + if (item && item.fields.length > 0) { + item.fields.forEach(field => { + tempResult.push(this._buildRecursivelyField(field)); + }); + } + + return { + // form: form, + id: item.id, + label: item.title, + numbering: 's', + subEntries: tempResult, + subEntriesType: ToCEntryType.Field, + type: ToCEntryType.FieldSet, + ordinal: item.ordinal + }; + } + + private _buildRecursivelyField(item: DescriptionTemplateField): ToCEntry { + if (!item) return null; + return { + // form: form, + id: item.id, + label: null, + numbering: 's', + subEntries: null, + subEntriesType: null, + type: ToCEntryType.Field, + ordinal: item.ordinal, + hidden: true + }; + } + + private _sortByOrdinal(tocentries: ToCEntry[]) { + + if (!tocentries || !tocentries.length) return; + + tocentries.sort(this._customCompare); + tocentries.forEach(entry => { + this._sortByOrdinal(entry.subEntries); + }); + } + + private _customCompare(a, b) { + return a.ordinal - b.ordinal; + } + + private _calculateNumbering(tocentries: ToCEntry[], depth: number[] = []) { + if (!tocentries || !tocentries.length) { + return; + } + + let prefixNumbering = depth.length ? depth.join('.') : ''; + + if (depth.length) prefixNumbering = prefixNumbering + "."; + tocentries.forEach((entry, i) => { + entry.numbering = prefixNumbering + (i + 1); + this._calculateNumbering(entry.subEntries, [...depth, i + 1]) + }); + } + + + getTocEntries(descriptionTemplate: DescriptionTemplate): ToCEntry[] { + if (descriptionTemplate == null) { return []; } + const result: ToCEntry[] = []; + + //build parent pages + descriptionTemplate.definition.pages.forEach((pageElement, i) => { + const tocEntry: ToCEntry = { + // id: i + 'id', + id: pageElement.id, + label: pageElement.title, + type: ToCEntryType.Page, + // form: pageElement, + numbering: (i + 1).toString(), + subEntriesType: ToCEntryType.Section, + subEntries: [], + ordinal: pageElement.ordinal + }; + + const sections = descriptionTemplate.definition.sections.filter(x => x.page == pageElement.id); + + sections.forEach(section => { + const tempResults = this._buildRecursivelySection(section); + tocEntry.subEntries.push(tempResults); + }); + result.push(tocEntry) + }); + + this._sortByOrdinal(result); + //calculate numbering + this._calculateNumbering(result); + return result; + + } + + onToCentrySelected(entry: ToCEntry = null, execute: boolean = true) { + if (!this.isSelecting) { + this.isSelecting = true; + this.tocentrySelected = entry; + this.entrySelected.emit({ entry: entry, execute: execute }); + setTimeout(() => { + this.isSelecting = false; + }, 600); + } + } + + private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { + if (!tocentries || !tocentries.length) { + return null; + } + + let tocEntryFound = tocentries.find(entry => entry.id === id); + + if (tocEntryFound) { + return tocEntryFound; + } + + for (let entry of tocentries) { + const result = this._findTocEntryById(id, entry.subEntries); + if (result) { + tocEntryFound = result; + break; + } + } + + return tocEntryFound ? tocEntryFound : null; + } + /** + * Get all filedsets in a tocentry array; + * @param entries Tocentries to search in + * @returns The tocentries that are Fieldsets provided in the entries + */ + private _getAllFieldSets(entries: ToCEntry[]): ToCEntry[] { + + const fieldsets: ToCEntry[] = []; + if (!entries || !entries.length) return fieldsets; + + + entries.forEach(e => { + if (e.type === ToCEntryType.FieldSet) { + fieldsets.push(e); + } else { + fieldsets.push(...this._getAllFieldSets(e.subEntries)); + } + }); + return fieldsets; + } + + + public hasVisibleInvalidFields(): boolean { + if (!this.internalTable || !this.tocentries) { + return false; + } + return this.tocentries.some(e => this.internalTable.invalidChildsVisible(e)); + } + + protected readonly console = console; +} + +export interface LinkToScroll { + page: number; + section: number; +} diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts new file mode 100644 index 000000000..2a7bc3749 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.module.ts @@ -0,0 +1,15 @@ +import {CommonModule} from '@angular/common'; +import {NgModule} from '@angular/core'; +import {RouterModule} from '@angular/router'; +import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal'; +import { MatIconModule } from '@angular/material/icon'; +import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; +import { TableOfContentsComponent } from './table-of-contents.component'; + +@NgModule({ + imports: [CommonModule, RouterModule, MatIconModule], + declarations: [TableOfContentsComponent, TableOfContentsInternal], + exports: [TableOfContentsComponent], + providers: [VisibilityRulesService] +}) +export class TableOfContentsModule { } diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.module.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.module.ts new file mode 100644 index 000000000..0422f9ac3 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.module.ts @@ -0,0 +1,27 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; +import { DescriptionListingComponent } from '@app/ui/description/listing/description-listing.component'; +import { DescriptionListingItemComponent } from '@app/ui/description/listing/listing-item/description-listing-item.component'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DescriptionListingRoutingModule } from './description-listing.routing'; +import { DescriptionCopyDialogModule } from '../description-copy-dialog/description-copy-dialog.module'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + UrlListingModule, + FormattingModule, + DescriptionCopyDialogModule, + DescriptionListingRoutingModule + ], + declarations: [ + DescriptionListingComponent, + DescriptionListingItemComponent, + ], + exports: [ + ] +}) +export class DescriptionListingModule { } diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts new file mode 100644 index 000000000..38230cad5 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.routing.ts @@ -0,0 +1,30 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { AuthGuard } from '@app/core/auth-guard.service'; +import { DescriptionListingComponent } from './description-listing.component'; + +const routes: Routes = [ + { + path: '', + component: DescriptionListingComponent, + // canActivate: [AuthGuard], + data: { + breadcrumb: true + }, + }, + { + path: 'dmp/:dmpId', + component: DescriptionListingComponent, + canActivate: [AuthGuard], + data: { + breadcrumb: true + }, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [] +}) +export class DescriptionListingRoutingModule { } diff --git a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts index b4769f897..ddb8adde0 100644 --- a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts @@ -96,11 +96,11 @@ export class DescriptionListingItemComponent extends BaseComponent implements On getItemLink(): string[] { // return this.isPublic ? [`/descriptions/publicEdit/${this.description.id}`] : [`/descriptions/edit/${this.description.id}`]; - return this.isPublic ? ['/descriptions/publicOverview/' + this.description.id] : ['/descriptions/overview/' + this.description.id]; + return this.isPublic ? ['/descriptions/overview/public/' + this.description.id] : ['/descriptions/overview/' + this.description.id]; } getDmpLink(): string[] { - return this.isPublic ? [`/explore-plans/publicOverview/${this.description.dmp.id}`] : [`/plans/edit/${this.description.dmp.id}`]; + return this.isPublic ? [`/explore-plans/overview/public/${this.description.dmp.id}`] : [`/plans/edit/${this.description.dmp.id}`]; } downloadPDF(description: Description): void { diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts index e2a401b2a..1aa72bb5c 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts @@ -126,7 +126,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni // this.users = this.description.dmp.users; // const breadCrumbs = []; // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" }); - // breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/publicOverview/' + this.description.id }); + // breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/public/' + this.description.id }); // this.breadCrumbs = observableOf(breadCrumbs); }, (error: any) => { if (error.status === 404) { @@ -249,7 +249,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni dmpClicked(dmp: Dmp) { if (this.isPublicView) { - this.router.navigate(['/explore-plans/publicOverview/' + dmp.id]); + this.router.navigate(['/explore-plans/overview/public/' + dmp.id]); } else { this.router.navigate(['/plans/overview/' + dmp.id]); } diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts index 31a9bc4d8..4dbd3315d 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.module.ts @@ -6,7 +6,9 @@ import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DescriptionCopyDialogModule } from '../description-copy-dialog/description-copy-dialog.module'; import { DescriptionOverviewComponent } from './description-overview.component'; +import { DescriptionOverviewRoutingModule } from './description-overview.routing'; @NgModule({ imports: [ @@ -16,7 +18,9 @@ import { DescriptionOverviewComponent } from './description-overview.component'; ConfirmationDialogModule, ExportMethodDialogModule, FormattingModule, - AutoCompleteModule + AutoCompleteModule, + DescriptionCopyDialogModule, + DescriptionOverviewRoutingModule ], declarations: [ DescriptionOverviewComponent diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts new file mode 100644 index 000000000..05cf0c095 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.routing.ts @@ -0,0 +1,29 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { DescriptionOverviewComponent } from './description-overview.component'; + +const routes: Routes = [ + { + path: ':id', + component: DescriptionOverviewComponent, + data: { + breadcrumb: true, + title: 'GENERAL.TITLES.DATASET-OVERVIEW' + }, + }, + { + path: 'public/:publicId', + component: DescriptionOverviewComponent, + data: { + breadcrumb: true, + title: 'GENERAL.TITLES.DATASET-OVERVIEW' + }, + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [] +}) +export class DescriptionOverviewRoutingModule { } diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index 3d8a5bd20..02af5a640 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -1,5 +1,5 @@ - {{'GENERAL.ACTIONS.SHOW-MORE' | translate}} + {{'GENERAL.ACTIONS.SHOW-MORE' | translate}}
open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index e7580d2a2..9ecc87d09 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -84,7 +84,7 @@
{{'DMP-OVERVIEW.DESCRIPTIONS' | translate}}
- +
- {{ 'FAQ.TITLE' | translate }} -
-
- -
-
- - -
- - - -
-
- - - {{'QUICKWIZARD.HINT' | translate}} - -
-
- - -
-
-
- -
-
-
-
- diff --git a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.scss b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.scss deleted file mode 100644 index 3d2ff8cf7..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.scss +++ /dev/null @@ -1,10 +0,0 @@ -.toc-pane-container { - &.is-sticky~.nav-spacer { - height: 500px; // the container size } - // height: calc(100vh - 100px); // the container size } - } -} - -.is-sticky { - margin-top: 70px !important; -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts deleted file mode 100644 index bd212cc49..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { Component, Input, OnInit } from "@angular/core"; -import { UntypedFormArray, UntypedFormGroup } from "@angular/forms"; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { QuickWizardDatasetDescriptionModel } from '@app/ui/quick-wizard/dataset-editor/quick-wizard-dataset-description-model'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from "@ngx-translate/core"; -import { Observable } from "rxjs"; -import { takeUntil } from "rxjs/operators"; -import { LinkToScroll } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; - -@Component({ - selector: 'app-dataset-editor-wizard-component', - templateUrl: 'dataset-editor-wizard.component.html', - styleUrls: ['./dataset-editor-wizard.component.scss'] -}) -export class DatasetEditorWizardComponent extends BaseComponent implements OnInit { - - @Input() formGroup: UntypedFormGroup; - @Input() datasetProfile: UntypedFormGroup; // DatasetProfileModel; - @Input() datasetLabel: string; - editedDataset: boolean = false; - dataset: DatasetDescriptionFormEditorModel; - public datasetProfileDefinition: DatasetDescriptionFormEditorModel; - public lastIndexOfDataset = 0; - public toggleButton = 0; - public _inputValue: string; - - isFirst: boolean; - - constructor( - private datasetWizardService: DatasetWizardService, - public language: TranslateService, - ) { - super(); - } - - ngOnInit(): void { - this.datasetWizardService.getDefinition(this.datasetProfile.value["id"]) - .pipe(takeUntil(this._destroyed)) - .subscribe(item => { - this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); - this.onValChange("list"); - const length = (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).length; - if (length == 0) { - this.lastIndexOfDataset = length; - this.isFirst = true; - this.addDataset(this.isFirst); - this.onValChange("dataset"); - } - }); - } - - onValChange(event: any) { - if (event == "list") { - this.toggleButton = 0; - this.editedDataset = false; - this._inputValue = "list"; - } else if (event == "add") { - this.addDataset(this.isFirst); - this.toggleButton = 2; - this._inputValue = "dataset"; - } else if (event == "dataset") { - this.toggleButton = 2; - this._inputValue = "dataset"; - } - } - - editDataset(index: number) { - // this.lastIndexOfDataset = index; - this.toggleButton = 2; - this.editedDataset = true; - this._inputValue = "dataset" - } - - deleteDataset(index: number) {//TODO: delete Dataset From List - this.lastIndexOfDataset = index; - this.toggleButton = 0; - this.editedDataset = false; - this._inputValue = "list"; - (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).removeAt(index); - if (index == 0) { - this.isFirst = true; - } - } - - addDataset(isFirst: boolean) { - const formArray: UntypedFormArray = (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray); - let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition); - let formGroup = dataset.buildForm(); - - if (isFirst) { - formGroup.get('datasetLabel').setValue( - this.datasetProfile.value["label"] + " " + - this.language.instant('GENERAL.NAMES.DATASET') - ); - this.isFirst = false; - } - else { - formGroup.get('datasetLabel').setValue( - this.datasetProfile.value["label"] + " " + - this.language.instant('GENERAL.NAMES.DATASET') + - " (" + - this.lastIndexOfDataset + ")" - ); - } - formArray.push(formGroup); - this.lastIndexOfDataset = formArray.length - 1; - this.editedDataset = true; - this.scrollToTop(); - } - - listingMode() { - if (this.toggleButton === 0) return true; - } - - scrollToTop() { - var currentScroll = document.documentElement.scrollTop || document.body.scrollTop; - if (currentScroll > 0) { - window.scrollTo(0, 0); - } - } - - linkToScroll: LinkToScroll; - onStepFound(linkToScroll: LinkToScroll) { - this.linkToScroll = linkToScroll; - } -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/quick-wizard-dataset-description-model.ts b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/quick-wizard-dataset-description-model.ts deleted file mode 100644 index 75b30d1f8..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/quick-wizard-dataset-description-model.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { UntypedFormControl, UntypedFormGroup } from "@angular/forms"; -import { DatasetProfileDefinitionModel } from "../../../core/model/dataset-profile-definition/dataset-profile-definition"; -import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model"; - -export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEditorModel { - - public datasetLabel: string; - - fromModel(item: DatasetProfileDefinitionModel): DatasetDescriptionFormEditorModel { - super.fromModel(item); - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup: UntypedFormGroup = super.buildForm(); - formGroup.addControl('datasetLabel', new UntypedFormControl({ value: this.datasetLabel })); - formGroup.addControl('status', new UntypedFormControl({ value: this.status })); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard-model.ts b/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard-model.ts deleted file mode 100644 index 576bf9458..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard-model.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { ValidJsonValidator } from '@app/library/auto-complete/auto-complete-custom-validator'; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - -export class DmpEditorWizardModel { - public id: string; - public label: string; - public status: DmpStatus = DmpStatus.Draft; - public description: String; - public datasetProfile: DatasetProfileModel; - public definition: DmpBlueprintDefinition; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - public language: String; - - fromModel(item: DmpModel): DmpEditorWizardModel { - this.id = item.id; - this.label = item.label; - this.status = item.status; - this.description = item.description; - this.datasetProfile = { id: item.profiles[0].descriptionTemplateId, label: item.profiles[0].label, description: "" }; - this.language = item.language; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - const formGroup = new UntypedFormBuilder().group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], - label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], - status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], - description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], - datasetProfile: [{ value: this.datasetProfile, disabled: disabled }, context.getValidation('datasetProfile').validators], - language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators], - }); - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); - baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] }); - baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); - baseContext.validation.push({ key: 'datasetProfile', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'datasetProfile')] }); - baseContext.validation.push({ key: 'language', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'language')] }); - return baseContext; - } -} - - diff --git a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.html deleted file mode 100644 index a9313f047..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.html +++ /dev/null @@ -1,94 +0,0 @@ -
-
- - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.NEW-TITLE' | translate}} - -

{{formGroup?.get('label')?.value}}

-
-
-
- - -
-

- {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.ABOUT' | translate}}

- - - - {{formGroup.get('label').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.DESCRIPTION-HINT' | translate}} - - - - - - - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.PROFILE-HINT' | translate}} - - - {{formGroup.get('datasetProfile').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{ lang.name }} - - - - {{formGroup.get('language').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
- {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.HELP' | translate}} -
- -
- -
-
-
-
diff --git a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.scss b/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.scss deleted file mode 100644 index 441021760..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.scss +++ /dev/null @@ -1,4 +0,0 @@ -.help { - font-size: 12px; - margin-top: 3em; -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.ts deleted file mode 100644 index 43afaf15a..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component.ts +++ /dev/null @@ -1,141 +0,0 @@ - -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { ActivatedRoute, Router } from '@angular/router'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { DmpEditorWizardModel } from './dmp-editor-wizard-model'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { LanguageInfo } from '@app/core/model/language-info'; -import { LanguageService } from '@app/core/services/language/language.service'; -import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; - - -@Component({ - selector: 'app-quick-wizard-dmp-editor-component', - templateUrl: 'dmp-editor-wizard.component.html', - styleUrls: ['./dmp-editor-wizard.component.scss'] -}) -export class DmpEditorWizardComponent extends BaseComponent implements OnInit { //IBreadCrumbComponent - - // breadCrumbs: Observable = observableOf([]); - - isNew = true; - dmp: DmpEditorWizardModel; - @Input() formGroup: UntypedFormGroup; - @Input() dmpLabel: string; - @Input() datasetFormGroup: UntypedFormGroup; - private uiNotificationService: UiNotificationService - - profilesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - filteredProfiles: DatasetProfileModel[]; - filteredProfilesAsync = false; - - - constructor( - public snackBar: MatSnackBar, - public router: Router, - private route: ActivatedRoute, - private _service: DmpService, - public language: TranslateService, - private formService: FormService, - private languageInfoService: LanguageInfoService - ) { - super(); - } - - ngOnInit(): void { - - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (extraData) => this.filterProfiles(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'] - }; - - if (this.formGroup == null) { - this.dmp = new DmpEditorWizardModel(); - this.formGroup = this.dmp.buildForm(); - } - this.formGroup.get('label').setValue(this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.DMP-NAME') + this.dmpLabel); - this.formGroup.get('label').setValue(this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.DMP-NAME') + this.dmpLabel); - - // this.breadCrumbs = observableOf([{ - // parentComponentName: 'grant', - // label: this.language.instant('NAV-BAR.DMP'), - // url: '/quick-wizard/dmp' - // }]); - } - - formSubmit(): void { - this.formService.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } - this.onSubmit(); - } - - public isFormValid() { - return this.formGroup.valid; - } - - onSubmit(): void { - // this.grantService.createGrant(this.formGroup.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => this.onCallbackSuccess(), - // error => this.onCallbackError(error) - // ); - } - - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/dmp']); - } - - onCallbackError(errorResponse: any) { - this.setErrorModel(errorResponse.error.payload); - this.formService.validateAllFormFields(this.formGroup); - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.dmp.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - filterProfiles(value: string): Observable { - - this.filteredProfiles = undefined; - this.filteredProfilesAsync = true; - - const request = new DataTableRequest(null, null, { fields: ['+label']}); - const criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this._service.searchDmpBlueprints(request); - } - - datasetIsEmpty() { - if (this.datasetFormGroup && this.datasetFormGroup.get('datasetsList') && (this.datasetFormGroup.get('datasetsList') as UntypedFormArray).length != 0) { - return true; - } - return false; - } - - getLanguageInfos(): LanguageInfo[] { - return this.languageInfoService.getLanguageInfoValues(); - } -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html deleted file mode 100644 index 80acc2f60..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html +++ /dev/null @@ -1,48 +0,0 @@ -
-
- - - -
-

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-FUNDER' | translate}}

- - - - {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
-

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-NEW-FUNDER' | translate}}

- - - {{funderFormGroup.get('label').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
-
-
-
-

- {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate}} -

-
-
-
-
-
-
- - - - -
-
- -
-
-
-
diff --git a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.scss b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts deleted file mode 100644 index 569e5f433..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { FunderModel } from '@app/core/model/funder/funder'; -import { TranslateService } from '@ngx-translate/core'; -import { FunderCriteria } from '../../../core/query/funder/funder-criteria'; -import { RequestItem } from '../../../core/query/request-item'; -import { FunderService } from '../../../core/services/funder/funder.service'; -import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration'; -import { FunderFormModel } from '../../dmp/editor/grant-tab/funder-form-model'; - -@Component({ - selector: 'app-quick-wizard-funder-editor-component', - templateUrl: './funder-editor-wizard.component.html', - styleUrls: ['./funder-editor-wizard.component.scss'] -}) -export class FunderEditorWizardComponent implements OnInit { - - isNew = false; - funder: FunderFormModel; - funderLabelCleared = true; - @Input() funderFormGroup: UntypedFormGroup; - funderAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - - constructor( - private funderService: FunderService, - private language: TranslateService - ) { } - - ngOnInit() { - - this.funderAutoCompleteConfiguration = { - filterFn: this.searchFunder.bind(this), - initialItems: (extraData) => this.searchFunder(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) - }; - - if (!this.funderFormGroup) { - this.funder = new FunderFormModel(); - this.funderFormGroup = this.funder.buildForm(); - } - - this.funderFormGroup.get('existFunder').enable(); - this.funderFormGroup.get('label').disable(); - } - - searchFunder(query: string) { - const funderRequestItem: RequestItem = new RequestItem(); - funderRequestItem.criteria = new FunderCriteria(); - funderRequestItem.criteria.like = query; - return this.funderService.getWithExternal(funderRequestItem); - } - - create() { - this.isNew = !this.isNew; - if (this.isNew) { - this.funderFormGroup.get('existFunder').reset(); - this.funderFormGroup.get('existFunder').disable(); - this.funderFormGroup.get('label').enable(); - } else { - this.funderFormGroup.get('label').reset(); - this.funderFormGroup.get('label').disable(); - this.funderFormGroup.get('existFunder').enable(); - } - } -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard-model.ts b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard-model.ts deleted file mode 100644 index 7a243c40e..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard-model.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { Status } from '@app/core/common/enum/status'; -import { GrantListingModel } from '@app/core/model/grant/grant-listing'; -import { ValidJsonValidator } from '@app/library/auto-complete/auto-complete-custom-validator'; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - -export class GrantEditorWizardModel { - public id: string; - public label: string; - public status: Status = Status.Active; - public description: String; - public existGrant: GrantListingModel; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - - - fromModel(item: GrantListingModel): GrantEditorWizardModel { - this.id = item.id; - this.label = item.label; - this.status = item.status; - this.description = item.description; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - - const formGroup = new UntypedFormBuilder().group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], - label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], - status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], - description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], - existGrant: [{ value: this.existGrant, disabled: disabled }, context.getValidation('existGrant').validators], - }); - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'id', validators: [] }); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); - baseContext.validation.push({ key: 'status', validators: [] }); - baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); - baseContext.validation.push({ key: 'existGrant', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] }); - return baseContext; - } - - -} - diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html deleted file mode 100644 index f55f3f3c1..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html +++ /dev/null @@ -1,65 +0,0 @@ -
- -
- - - - -
-

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-GRANT' | translate}}

- - - - {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}} - - {{grantformGroup.get('grant').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
-

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-NEW-GRANT' | translate}}

- - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL-HINT' | translate}} - - {{grantformGroup.get('label').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION-HINT' | translate}} - - {{grantformGroup.get('description').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
-
-
-
-

- {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate}} -

-
-
-
-
-
-
- - - -
-
- -
-
-
-
diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.scss b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts deleted file mode 100644 index 118ceda70..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts +++ /dev/null @@ -1,151 +0,0 @@ - -import { Component, Input, OnInit } from '@angular/core'; -import { AbstractControl, FormArray, FormControl, UntypedFormGroup } from '@angular/forms'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { Router } from '@angular/router'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -import { GrantEditorWizardModel } from '@app/ui/quick-wizard/grant-editor/grant-editor-wizard-model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; -import { strict } from 'assert'; - -@Component({ - selector: 'app-quick-wizard-grant-editor-component', - templateUrl: 'grant-editor-wizard.component.html', - styleUrls: ['./grant-editor-wizard.component.scss'] -}) -export class GrantEditorWizardComponent extends BaseComponent implements OnInit { //IBreadCrumbComponent - // breadCrumbs: Observable = observableOf([]); - - isNew = false; - grant: GrantEditorWizardModel; - @Input() grantformGroup: UntypedFormGroup; - @Input() funderFormGroup: UntypedFormGroup; - private uiNotificationService: UiNotificationService - - grantAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - - constructor( - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - private grantService: GrantService, - private formService: FormService - ) { - super(); - } - - getGrantIdText(item) { - if (item.reference != null && typeof item.reference == 'string') { - const parts = (item.reference as String).split('::'); - return parts.length > 1 ? ' (' + parts[parts.length - 1] + ')' : ''; - } - return ''; - } - - ngOnInit() { - // this.breadCrumbs = observableOf([{ - // parentComponentName: 'QuickCreate', - // label: this.language.instant('NAV-BAR.GRANT'), - // url: '/quick-wizard/grant' - // }]); - - const grantRequestItem: RequestItem = new RequestItem(); - grantRequestItem.criteria = new GrantCriteria(); - - this.grantAutoCompleteConfiguration = { - filterFn: this.searchGrant.bind(this), - initialItems: (extraData) => this.searchGrant(''), - displayFn: (item) => item['label'] + this.getGrantIdText(item), - titleFn: (item) => item['label'] + this.getGrantIdText(item), - subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) - }; - - if (this.funderFormGroup && this.funderFormGroup.valid) { - this.grantformGroup.get('existGrant').enable(); - this.grantformGroup.get('label').disable(); - this.grantformGroup.get('description').disable(); - } else { - this.grantformGroup.get('existGrant').disable(); - } - - this.funderFormGroup.statusChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.grantformGroup.reset(); - if (x == 'INVALID') { - this.grantformGroup.get('existGrant').reset(); - this.grantformGroup.get('label').reset(); - this.grantformGroup.get('description').reset(); - this.grantformGroup.get('existGrant').disable(); - this.grantformGroup.get('label').disable(); - this.grantformGroup.get('description').disable(); - } else if (x == 'VALID') { - if (!this.isNew) { - this.grantformGroup.get('label').reset(); - this.grantformGroup.get('description').reset(); - this.grantformGroup.get('label').disable(); - this.grantformGroup.get('description').disable(); - this.grantformGroup.get('existGrant').enable(); - - } - } - }) - } - - isFunderFormInvalid() { - return !this.funderFormGroup.valid; - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/grant']); - } - - onCallbackError(errorResponse: any) { - this.setErrorModel(errorResponse.error.payload); - this.formService.validateAllFormFields(this.grantformGroup); - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.grant.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - searchGrant(query: string) { - const grantRequestItem: RequestItem = new RequestItem(); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - if (this.funderFormGroup.get('existFunder').value) { - grantRequestItem.criteria.funderReference = this.funderFormGroup.controls['existFunder'].value.reference; - } - return this.grantService.getWithExternal(grantRequestItem); - } - - create() { - this.isNew = !this.isNew; - if (this.isNew) { - this.grantformGroup.get('existGrant').reset(); - this.grantformGroup.get('existGrant').disable(); - this.grantformGroup.get('label').enable(); - this.grantformGroup.get('description').enable(); - } else { - this.grantformGroup.get('label').reset(); - this.grantformGroup.get('label').disable(); - this.grantformGroup.get('description').reset(); - this.grantformGroup.get('description').disable(); - this.grantformGroup.get('existGrant').enable(); - } - } -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html deleted file mode 100644 index 208838c21..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html +++ /dev/null @@ -1,57 +0,0 @@ -
- -
- - - -
-

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-PROJECT' | translate}}

- - - - {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}} - -
- -
-

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-NEW-PROJECT' | translate}}

- - - - {{formGroup.get('label').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{formGroup.get('description').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
-
-
-
-

- {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate}} -

-
-
-
-
-
-
- - - - -
-
- -
-
-
-
diff --git a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.scss b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts deleted file mode 100644 index dcfb6dee4..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration'; -import { UntypedFormGroup } from '@angular/forms'; -import { ProjectService } from '../../../core/services/project/project.service'; -import { RequestItem } from '../../../core/query/request-item'; -import { ProjectCriteria } from '../../../core/query/project/project-criteria'; -import { ProjectFormModel } from '../../dmp/editor/grant-tab/project-form-model'; -import { TranslateService } from '@ngx-translate/core'; - -@Component({ - selector: 'app-quick-wizard-project-editor-component', - templateUrl: './project-editor-wizard.component.html', - styleUrls: ['./project-editor-wizard.component.scss'] -}) -export class ProjectEditorWizardComponent implements OnInit { - - isNew = false; - project: ProjectFormModel; - @Input() formGroup: UntypedFormGroup; - projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - - constructor( - private projectService: ProjectService, - private language: TranslateService - ) { } - - ngOnInit() { - this.projectAutoCompleteConfiguration = { - filterFn: this.searchProject.bind(this), - initialItems: (extraData) => this.searchProject(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) - }; - - if (!this.formGroup) { - this.project = new ProjectFormModel(); - this.formGroup = this.project.buildForm(); - } - - this.formGroup.get('existProject').enable(); - this.formGroup.get('label').disable(); - this.formGroup.get('description').disable(); - } - - searchProject(query: string) { - const projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - projectRequestItem.criteria.like = query; - return this.projectService.getWithExternal(projectRequestItem); - } - - create() { - this.isNew = !this.isNew; - if (this.isNew) { - this.formGroup.get('existProject').disable(); - this.formGroup.get('existProject').reset(); - this.formGroup.get('label').enable(); - this.formGroup.get('description').enable(); - } else { - this.formGroup.get('existProject').enable(); - this.formGroup.get('label').disable(); - this.formGroup.get('label').reset(); - this.formGroup.get('description').disable(); - this.formGroup.get('description').reset(); - } - } - -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html deleted file mode 100644 index 166f4b99b..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html +++ /dev/null @@ -1,68 +0,0 @@ -
-
-
-
-

{{ 'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.TITLE' | translate }}

-

{{ 'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.POST-SELECTION-INFO' | translate }}

-
- - - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}} - -
-
- - -
-
-
- -
- -
- - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}} - - -
- - -
- -
-
- - - {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}} - - - -
- - - - - -
- -
-
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.scss b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.scss deleted file mode 100644 index ea2e9bba1..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.scss +++ /dev/null @@ -1,11 +0,0 @@ -.saveAndFinalizeButton{ - float:right; -} -.finalizeButton{ - float: right; - text-transform: uppercase; -} -.saveButton{ - float:right; - margin-right: 15px; -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts deleted file mode 100644 index 9c1bf928f..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts +++ /dev/null @@ -1,203 +0,0 @@ - -import { Component, OnInit, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, FormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { MatStepper } from '@angular/material/stepper'; -import { Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { QuickWizardService } from '@app/core/services/quick-wizard/quick-wizard.service'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { DmpFinalizeDialogComponent, DmpFinalizeDialogDataset, DmpFinalizeDialogInput } from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component'; -import { FunderFormModel } from '@app/ui/dmp/editor/grant-tab/funder-form-model'; -import { ProjectFormModel } from '@app/ui/dmp/editor/grant-tab/project-form-model'; -import { DatasetEditorWizardComponent } from '@app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component'; -import { GrantEditorWizardModel } from '@app/ui/quick-wizard/grant-editor/grant-editor-wizard-model'; -import { QuickWizardEditorWizardModel } from '@app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model'; -import { FormService } from '@common/forms/form-service'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-quick-wizard-editor-component', - templateUrl: 'quick-wizard-editor.component.html', - styleUrls: ['./quick-wizard-editor.component.scss'] -}) -export class QuickWizardEditorComponent extends CheckDeactivateBaseComponent implements OnInit { - - // breadCrumbs: Observable = observableOf([]); - @ViewChild('stepper', { static: true }) stepper: MatStepper; - @ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent; - isNew = true; - isSubmitted = false; - quickWizard: QuickWizardEditorWizardModel; - allDatasets: DmpFinalizeDialogDataset[] = []; - formGroup: UntypedFormGroup = null; - - constructor( - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - public datasetService: DatasetService, - public quickWizardService: QuickWizardService, - private uiNotificationService: UiNotificationService, - private dialog: MatDialog, - private formService: FormService - ) { - super(); - } - - ngOnInit(): void { - this.quickWizard = new QuickWizardEditorWizardModel(); - this.quickWizard.grant = new GrantEditorWizardModel(); - this.quickWizard.funder = new FunderFormModel(); - this.quickWizard.project = new ProjectFormModel(); - this.formGroup = this.quickWizard.buildForm(); - this.language.get('NAV-BAR.DMP-WIZARD').pipe(takeUntil(this._destroyed)).subscribe(x => { - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: 'Dashboard', - // label: x, - // url: '/quick-wizard' - // }] - // ); - }) - } - - isActive(step: string): boolean { - switch (step) { - case 'step1': - return this.stepper.selectedIndex == 0; - case 'step2': - return this.stepper.selectedIndex == 1; - case 'step3': - return this.stepper.selectedIndex == 2; - } - } - - formSubmit(): void { - this.formService.touchAllFormFields(this.formGroup); - if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).length > 0) { - for (let control of (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).controls) { - control.get('status').setValue(DatasetStatus.Draft); - } - this.onSubmitSave(); - } else { - this.uiNotificationService.popupNotification(this.language.instant('GENERAL.NOTIFICATION-DIALOG.POPUP.TITLE'), this.language.instant('GENERAL.NOTIFICATION-DIALOG.POPUP.MESSAGE')); - return; - } - } - - saveFinalize() { - if (!this.isFormValid()) { return; } - - const dialogInputModel: DmpFinalizeDialogInput = { - dmpLabel: this.formGroup.get('dmp').get('label').value, - dmpDescription: this.formGroup.get('dmp').get('description').value, - datasets: (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).controls.map(x => { - return { label: x.get('datasetLabel').value, status: DatasetStatus.Finalized }; - }), - accessRights: false - } - - const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { - maxWidth: '500px', - restoreFocus: false, - autoFocus: false, - data: { - dialogInputModel: dialogInputModel, - confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result && !result.cancelled) { - if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).length > 0) { - for (let control of (this.formGroup.get('datasets').get('datasetsList') as UntypedFormArray).controls) { - control.get('status').setValue(DatasetStatus.Finalized); - } - this.formGroup.get('dmp').get('status').setValue(DmpStatus.Finalized); - this.onSubmitSaveAndFinalize(); - } else { - this.uiNotificationService.popupNotification(this.language.instant('GENERAL.NOTIFICATION-DIALOG.POPUP.TITLE'), this.language.instant('GENERAL.NOTIFICATION-DIALOG.POPUP.MESSAGE')); - } - } - }); - } - - hasDatasets() { - return this.formGroup.get('datasets').get('datasetsList').valid; - } - - public isFormValid() { - return this.formGroup.get('grant').valid && this.formGroup.get('funder').valid; - } - - onSubmitSaveAndFinalize() { - this.quickWizardService.createQuickWizard(this.formGroup.getRawValue()) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - - onSubmitSave(): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetEditorWizardComponent.addDataset(false); - } else if (result === false) { - this.quickWizardService.createQuickWizard(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess() - ) - } - }); - } - - onCallbackSuccess(): void { - this.isSubmitted = true; - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/home']); - } - - onCallbackError(errorResponse: any) { - this.setErrorModel(errorResponse.error.payload); - this.formService.validateAllFormFields(this.formGroup); - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.quickWizard.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - getGrantLabel(): string { - if (this.formGroup.get('grant').get('existGrant').value) { - return this.formGroup.get('grant').get('existGrant').value['label']; - } else { - return this.formGroup.get('grant').get('label').value; - } - } - - canDeactivate(): boolean { - return this.isSubmitted || !this.formGroup.dirty; - } - -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model.ts b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model.ts deleted file mode 100644 index 069011166..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { FunderModel } from '@app/core/model/funder/funder'; -import { GrantListingModel } from '@app/core/model/grant/grant-listing'; -import { ProjectModel } from '@app/core/model/project/project'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { FunderFormModel } from '@app/ui/dmp/editor/grant-tab/funder-form-model'; -import { ProjectFormModel } from '@app/ui/dmp/editor/grant-tab/project-form-model'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; -import { DatasetEditorWizardModel } from '../dataset-editor/dataset-editor-wizard-model'; -import { DmpEditorWizardModel } from '../dmp-editor/dmp-editor-wizard-model'; -import { GrantEditorWizardModel } from '../grant-editor/grant-editor-wizard-model'; - - -export class QuickWizardEditorWizardModel { - public grant: GrantEditorWizardModel; - public funder: FunderFormModel; - public project: ProjectFormModel; - public dmp: DmpEditorWizardModel; - public datasets: DatasetEditorWizardModel; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - - fromModelGrant(item: GrantListingModel): QuickWizardEditorWizardModel { - this.grant.fromModel(item); - return this; - } - - fromModelFunder(item: FunderModel): QuickWizardEditorWizardModel { - this.funder.fromModel(item); - return this; - } - - fromModelProject(item: ProjectModel): QuickWizardEditorWizardModel { - this.project.fromModel(item); - return this; - } - - fromModelDmp(item: DmpModel): QuickWizardEditorWizardModel { - this.dmp.fromModel(item); - return this; - } - - fromModelDataset(item: DatasetWizardEditorModel[]): QuickWizardEditorWizardModel { - this.datasets.fromModel(item); - return this; - } - - buildForm(context: ValidationContext = null): UntypedFormGroup { - // if (context == null) { context = this.createValidationContext(); } - const formGroup = new UntypedFormBuilder().group({ - grant: new GrantEditorWizardModel().buildForm(), - funder: new FunderFormModel().buildForm(), - project: new ProjectFormModel().buildForm(), - dmp: new DmpEditorWizardModel().buildForm(), - datasets: new DatasetEditorWizardModel().buildForm() - - }); - return formGroup; - } - - // createValidationContext(): ValidationContext { - // const baseContext: ValidationContext = new ValidationContext(); - // baseContext.validation.push({ key: 'grant', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'grant')] }); - // baseContext.validation.push({ key: 'dmp', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmp')] }); - // baseContext.validation.push({ key: 'datasets', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasets')] }); - // return baseContext; - // } - -} diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard.module.ts b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard.module.ts deleted file mode 100644 index 0811a1e48..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard.module.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { NgModule } from '@angular/core'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; -import { DmpModule } from '@app/ui/dmp/dmp.module'; -import { DatasetDescriptionFormModule } from '@app/ui/misc/dataset-description-form/dataset-description-form.module'; -import { DatasetEditorWizardComponent } from '@app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component'; -import { DmpEditorWizardComponent } from '@app/ui/quick-wizard/dmp-editor/dmp-editor-wizard.component'; -import { FunderEditorWizardComponent } from '@app/ui/quick-wizard/funder-editor/funder-editor-wizard.component'; -import { GrantEditorWizardComponent } from '@app/ui/quick-wizard/grant-editor/grant-editor-wizard.component'; -import { ProjectEditorWizardComponent } from '@app/ui/quick-wizard/project-editor/project-editor-wizard.component'; -import { QuickWizardEditorComponent } from '@app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component'; -import { QuickWizardRoutingModule } from '@app/ui/quick-wizard/quick-wizard.routing'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { TableOfContentsModule } from '../misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - UrlListingModule, - AutoCompleteModule, - ConfirmationDialogModule, - QuickWizardRoutingModule, - DatasetDescriptionFormModule, - // DmpModule, - TableOfContentsModule, - AngularStickyThingsModule - ], - declarations: [ - GrantEditorWizardComponent, - DmpEditorWizardComponent, - QuickWizardEditorComponent, - DatasetEditorWizardComponent, - FunderEditorWizardComponent, - ProjectEditorWizardComponent - ], - exports: [ - DatasetEditorWizardComponent, - ], - providers: [ - CanDeactivateGuard - ] -}) -export class OuickWizardModule { } diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard.routing.ts b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard.routing.ts deleted file mode 100644 index 22f849a67..000000000 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard.routing.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { QuickWizardEditorComponent } from './quick-wizard-editor/quick-wizard-editor.component'; -import { CanDeactivateGuard } from '../../library/deactivate/can-deactivate.guard'; -import { AuthGuard } from '@app/core/auth-guard.service'; - -const routes: Routes = [ - { - path: '', - component: QuickWizardEditorComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - canDeactivate: [CanDeactivateGuard] - }, - // { - // path: 'grant', - // component: GrantEditorWizardComponent, - // data: { - // breadcrumb: true - // }, - // }, - // { - // path: 'dmp', - // component: DmpEditorWizardComponent, - // data: { - // breadcrumb: true - // }, - // }, - // { - // path: 'dataset', - // component: DatasetEditorWizardComponent, - // data: { - // breadcrumb: true - // }, - // } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class QuickWizardRoutingModule { } diff --git a/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts b/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts index 011c90d49..25b94beb0 100644 --- a/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts +++ b/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts @@ -31,13 +31,11 @@ export const GENERAL_ROUTES: RouteInfo[] = [ export const DMP_ROUTES: RouteInfo[] = [ { path: '/plans', title: 'SIDE-BAR.MY-DMPS', icon: 'library_books' }, { path: '/descriptions', title: 'SIDE-BAR.MY-DESCRIPTIONS', icon: 'dns' }, - // { path: '/quick-wizard', title: 'SIDE-BAR.QUICK-WIZARD', icon: 'play_circle_outline' }, // { path: '/plans/new', title: 'SIDE-BAR.ADD-EXPERT', icon: 'playlist_add' } ]; export const DATASETS_ROUTES: RouteInfo[] = [ { path: '/explore-plans', title: 'SIDE-BAR.PUBLIC-DMPS', icon: 'library_books' }, { path: '/explore-descriptions', title: 'SIDE-BAR.PUBLIC-DESC', icon: 'dns' }, - // { path: '/datasetcreatewizard', title: 'SIDE-BAR.QUICK-WIZARD-DATASET', icon: "play_circle_outline" }, ]; export const PUBLIC_ROUTES: RouteInfo[] = [ From 2a6b0473276bc00e7a6708bff51aa761e149f5ce Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Fri, 22 Dec 2023 19:00:53 +0200 Subject: [PATCH 2/5] Implementing validators for Description template related persist models (not completed) --- .../model/persist/DescriptionPersist.java | 2 - .../persist/DescriptionStatusPersist.java | 64 ++++- .../persist/DescriptionTemplatePersist.java | 121 +++++++-- .../DefinitionPersist.java | 94 +++++-- .../FieldPersist.java | 250 +++++++++++++----- .../FieldSetPersist.java | 240 ++++++++++------- .../MultiplicityPersist.java | 90 ++++--- .../PagePersist.java | 102 +++++-- .../RulePersist.java | 80 ++++-- .../SectionPersist.java | 242 +++++++++++------ .../AuthAutoCompleteDataPersist.java | 141 ++++++---- .../fielddata/AutoCompleteDataPersist.java | 64 ++++- .../AutoCompleteSingleDataPersist.java | 195 +++++++++----- .../fielddata/BaseFieldDataPersist.java | 134 ++++++---- .../fielddata/BooleanDecisionDataPersist.java | 35 +++ .../fielddata/CheckBoxDataPersist.java | 33 ++- .../fielddata/ComboBoxOptionPersist.java | 126 ++++++--- .../DatasetAutoCompleteDataPersist.java | 58 +++- .../fielddata/DatePickerDataPersist.java | 36 +++ .../fielddata/DmpAutoCompleteDataPersist.java | 57 +++- .../fielddata/ExternalDatasetDataPersist.java | 54 +++- .../fielddata/FreeTextDataPersist.java | 32 +++ .../fielddata/LicenseDataPersist.java | 42 ++- .../fielddata/OrganizationDataPersist.java | 42 ++- .../fielddata/PublicationDataPersist.java | 41 ++- .../fielddata/RadioBoxDataPersist.java | 52 +++- .../fielddata/RadioBoxOptionPersist.java | 84 ++++-- .../DefinitionPersist.java | 73 +++-- .../referencedefinition/FieldPersist.java | 59 ++++- .../controllers/v2/DescriptionController.java | 1 + 30 files changed, 1970 insertions(+), 674 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java index 391d15023..eaab7cb1f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java @@ -8,8 +8,6 @@ import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java index a9d623447..361918915 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionStatusPersist.java @@ -1,28 +1,34 @@ package eu.eudat.model.persist; import eu.eudat.commons.enums.DescriptionStatus; -import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet; -import eu.eudat.commons.validation.old.ValidEnum; -import eu.eudat.commons.validation.old.ValidId; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; +import java.util.List; import java.util.UUID; -@FieldNotNullIfOtherSet(message = "{validation.hashempty}") public class DescriptionStatusPersist { - @NotNull(message = "{validation.empty}") - @ValidId(message = "{validation.invalidid}") private UUID id; - @ValidEnum(message = "{validation.empty}") + public static final String _id = "id"; + private DescriptionStatus status; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _status = "status"; + private String hash; + public static final String _hash = "hash"; + public UUID getId() { return id; } @@ -46,4 +52,40 @@ public class DescriptionStatusPersist { public void setHash(String hash) { this.hash = hash; } + + @Component(DescriptionStatusPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DescriptionStatusPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionStatusPersistValidator"; + + private final MessageSource messageSource; + + protected DescriptionStatusPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return DescriptionStatusPersist.class; + } + + @Override + protected List specifications(DescriptionStatusPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isValidGuid(item.getId())) + .failOn(DescriptionStatusPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> this.isValidGuid(item.getId())) + .must(() -> this.isValidHash(item.getHash())) + .failOn(DescriptionStatusPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._hash}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getStatus())) + .failOn(DescriptionStatusPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._status}, LocaleContextHolder.getLocale())) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java index cde3040b5..2d159f9d1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplatePersist.java @@ -1,55 +1,65 @@ package eu.eudat.model.persist; - import eu.eudat.commons.enums.DescriptionTemplateStatus; -import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet; -import eu.eudat.commons.validation.old.ValidEnum; -import eu.eudat.commons.validation.old.ValidId; -import eu.eudat.data.DescriptionTemplateEntity; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.model.persist.descriptiontemplatedefinition.DefinitionPersist; import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; import java.util.UUID; -@FieldNotNullIfOtherSet(message = "{validation.hashempty}") public class DescriptionTemplatePersist { - @ValidId(message = "{validation.invalidid}") private UUID id; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - @Size(max = DescriptionTemplateEntity._labelLength, message = "{validation.largerthanmax}") private String label = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _label = "label"; + + public static final int _labelLength = 250; + private String description = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _description = "description"; + private String language = null; - @NotNull(message = "{validation.empty}") - @ValidId(message = "{validation.invalidid}") + public static final String _language = "language"; + private UUID type = null; - @ValidEnum(message = "{validation.empty}") + public static final String _type = "type"; + private DescriptionTemplateStatus status; + public static final String _status = "status"; + @NotNull(message = "{validation.empty}") @Valid private DefinitionPersist definition = null; + public static final String _definition = "definition"; + @Valid private List users = null; + public static final String _users = "users"; + private String hash; + public static final String _hash = "hash"; + public UUID getId() { return id; } @@ -121,6 +131,79 @@ public class DescriptionTemplatePersist { public void setUsers(List users) { this.users = users; } + + @Component(DescriptionTemplatePersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DescriptionTemplatePersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplatePersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected DescriptionTemplatePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return DescriptionTemplatePersist.class; + } + + @Override + protected List specifications(DescriptionTemplatePersist item) { + return Arrays.asList( + this.spec() + .iff(() -> this.isValidGuid(item.getId())) + .must(() -> this.isValidHash(item.getHash())) + .failOn(DescriptionTemplatePersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._hash}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isValidGuid(item.getId())) + .must(() -> !this.isValidHash(item.getHash())) + .failOn(DescriptionTemplatePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getLabel())) + .must(() -> this.lessEqual(item.getLabel(), DescriptionTemplatePersist._labelLength)) + .failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getDescription())) + .failOn(DescriptionTemplatePersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._description}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getLanguage())) + .failOn(DescriptionTemplatePersist._language).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._language}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> this.isValidGuid(item.getType())) + .failOn(DescriptionTemplatePersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._type}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getStatus())) + .failOn(DescriptionTemplatePersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._status}, LocaleContextHolder.getLocale())), + + this.spec() + .must(() -> !this.isNull(item.getDefinition())) + .failOn(DescriptionTemplatePersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._definition}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getDefinition())) + .on(DescriptionTemplatePersist._definition) + .over(item.getDefinition()) + .using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)), + this.spec() + .must(() -> !this.isNull(item.getUsers())) + .failOn(DescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getUsers())) + .on(DescriptionTemplatePersist._users) + .over(item.getUsers()) + .using(() -> null) //TODO (thgiannos) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java index b1fb3aa68..d9896f9c7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/DefinitionPersist.java @@ -1,33 +1,87 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class DefinitionPersist { - @NotNull(message = "{validation.empty}") - @Valid - private List sections = null; + private List sections = null; - @NotNull(message = "{validation.empty}") - @Valid - private List pages = null; + public static final String _sections = "sections"; - public List getSections() { - return sections; - } + private List pages = null; - public void setSections(List sections) { - this.sections = sections; - } + public static final String _pages = "pages"; - public List getPages() { - return pages; - } + public List getSections() { + return sections; + } + + public void setSections(List sections) { + this.sections = sections; + } + + public List getPages() { + return pages; + } + + public void setPages(List pages) { + this.pages = pages; + } + + @Component(DefinitionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DefinitionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.DefinitionPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + public DefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return DefinitionPersist.class; + } + + @Override + protected List specifications(DefinitionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getSections())) + .failOn(DefinitionPersist._sections).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._sections}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getSections())) + .on(DefinitionPersist._sections) + .over(item.getSections()) + .using(() -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)), + this.spec() + .must(() -> !this.isNull(item.getPages())) + .failOn(DefinitionPersist._pages).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._pages}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getPages())) + .on(DefinitionPersist._pages) + .over(item.getPages()) + .using(() -> this.validatorFactory.validator(PagePersist.PagePersistValidator.class)) + ); + } + } - public void setPages(List pages) { - this.pages = pages; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java index be84fb58c..bf8fdaef1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldPersist.java @@ -1,99 +1,215 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; +import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.enums.FieldValidationType; -import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.descriptiontemplatedefinition.fielddata.*; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class FieldPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; + private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + public static final String _id = "id"; - private List schematics; + private Integer ordinal = null; - private String defaultValue; + public static final String _ordinal = "ordinal"; - @Valid - private List visibilityRules; + private List schematics; - private List validations; + private String defaultValue; - @NotNull(message = "{validation.empty}") - private Boolean includeInExport = null; + private List visibilityRules; - @NotNull(message = "{validation.empty}") - @Valid - private BaseFieldDataPersist data = null; + public static final String _visibilityRules = "visibilityRules"; - public String getId() { - return id; - } + private List validations; - public void setId(String id) { - this.id = id; - } + private Boolean includeInExport = null; - public Integer getOrdinal() { - return ordinal; - } + public static final String _includeInExport = "includeInExport"; - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } + private BaseFieldDataPersist data = null; - public List getSchematics() { - return schematics; - } + public static final String _data = "data"; - public void setSchematics(List schematics) { - this.schematics = schematics; - } + public String getId() { + return id; + } - public String getDefaultValue() { - return defaultValue; - } + public void setId(String id) { + this.id = id; + } - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } + public Integer getOrdinal() { + return ordinal; + } - public List getVisibilityRules() { - return visibilityRules; - } + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } - public void setVisibilityRules(List visibilityRules) { - this.visibilityRules = visibilityRules; - } + public List getSchematics() { + return schematics; + } - public List getValidations() { - return validations; - } + public void setSchematics(List schematics) { + this.schematics = schematics; + } - public void setValidations(List validations) { - this.validations = validations; - } + public String getDefaultValue() { + return defaultValue; + } - public Boolean getIncludeInExport() { - return includeInExport; - } + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } - public void setIncludeInExport(Boolean includeInExport) { - this.includeInExport = includeInExport; - } + public List getVisibilityRules() { + return visibilityRules; + } - public BaseFieldDataPersist getData() { - return data; - } + public void setVisibilityRules(List visibilityRules) { + this.visibilityRules = visibilityRules; + } + + public List getValidations() { + return validations; + } + + public void setValidations(List validations) { + this.validations = validations; + } + + public Boolean getIncludeInExport() { + return includeInExport; + } + + public void setIncludeInExport(Boolean includeInExport) { + this.includeInExport = includeInExport; + } + + public BaseFieldDataPersist getData() { + return data; + } + + public void setData(BaseFieldDataPersist data) { + this.data = data; + } + + @Component(FieldPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FieldPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.FieldPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected FieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return FieldPersist.class; + } + + @Override + protected List specifications(FieldPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(FieldPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(FieldPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getIncludeInExport())) + .failOn(FieldPersist._includeInExport).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._includeInExport}, LocaleContextHolder.getLocale())), + + this.navSpec() + .iff(() -> !this.isNull(item.getVisibilityRules())) + .on(FieldPersist._visibilityRules) + .over(item.getVisibilityRules()) + .using(() -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.AUTO_COMPLETE) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(AutoCompleteDataPersist.AutoCompleteDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.BOOLEAN_DECISION) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(BooleanDecisionDataPersist.BooleanDecisionPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.INTERNAL_DMP_ENTRIES_DATASETS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(DatasetAutoCompleteDataPersist.DatasetAutoCompleteDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.INTERNAL_DMP_ENTRIES_DMPS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(DmpAutoCompleteDataPersist.DmpAutoCompleteDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.CHECK_BOX) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(CheckBoxDataPersist.CheckBoxDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.DATE_PICKER) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(DatePickerDataPersist.DatePickerDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.EXTERNAL_DATASETS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(ExternalDatasetDataPersist.ExternalDatasetDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.FREE_TEXT) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(FreeTextDataPersist.FreeTextDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.LICENSES) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(LicenseDataPersist.LicenseDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.ORGANIZATIONS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(OrganizationDataPersist.OrganizationDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.PUBLICATIONS) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(PublicationDataPersist.PublicationDataPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.RADIO_BOX) + .on(FieldPersist._data) + .over(item.getData()) + .using(() -> this.validatorFactory.validator(RadioBoxDataPersist.RadioBoxDataPersistValidator.class)) + ); + } + } - public void setData(BaseFieldDataPersist data) { - this.data = data; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java index 1cf21610d..fedd67717 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java @@ -1,127 +1,187 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class FieldSetPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; + private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + public static final String _id = "id"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String numbering = null; + private Integer ordinal = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String title = null; + public static final String _ordinal = "ordinal"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String description = null; + private String numbering = null; -// @NotNull(message = "{validation.empty}") -// @NotEmpty(message = "{validation.empty}") - private String extendedDescription = null; - -// @NotNull(message = "{validation.empty}") -// @NotEmpty(message = "{validation.empty}") - private String additionalInformation = null; + public static final String _numbering = "numbering"; - @Valid - private MultiplicityPersist multiplicity= null; + private String title = null; + public static final String _title = "title"; - private Boolean hasCommentField = null; + private String description = null; - @NotNull(message = "{validation.empty}") - @Valid - private List fields = null; + public static final String _description = "description"; - public String getId() { - return id; - } + private String extendedDescription = null; - public void setId(String id) { - this.id = id; - } + private String additionalInformation = null; - public Integer getOrdinal() { - return ordinal; - } + private MultiplicityPersist multiplicity = null; - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } + public static final String _multiplicity = "multiplicity"; - public String getNumbering() { - return numbering; - } + private Boolean hasCommentField = null; - public void setNumbering(String numbering) { - this.numbering = numbering; - } + private List fields = null; - public String getTitle() { - return title; - } + public static final String _fields = "fields"; - public void setTitle(String title) { - this.title = title; - } + public String getId() { + return id; + } - public String getDescription() { - return description; - } + public void setId(String id) { + this.id = id; + } - public void setDescription(String description) { - this.description = description; - } + public Integer getOrdinal() { + return ordinal; + } - public String getExtendedDescription() { - return extendedDescription; - } + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; + } - public void setExtendedDescription(String extendedDescription) { - this.extendedDescription = extendedDescription; - } + public String getNumbering() { + return numbering; + } - public String getAdditionalInformation() { - return additionalInformation; - } + public void setNumbering(String numbering) { + this.numbering = numbering; + } - public void setAdditionalInformation(String additionalInformation) { - this.additionalInformation = additionalInformation; - } + public String getTitle() { + return title; + } - public MultiplicityPersist getMultiplicity() { - return multiplicity; - } + public void setTitle(String title) { + this.title = title; + } - public void setMultiplicity(MultiplicityPersist multiplicity) { - this.multiplicity = multiplicity; - } + public String getDescription() { + return description; + } - public Boolean getHasCommentField() { - return hasCommentField; - } + public void setDescription(String description) { + this.description = description; + } - public void setHasCommentField(Boolean hasCommentField) { - this.hasCommentField = hasCommentField; - } + public String getExtendedDescription() { + return extendedDescription; + } - public List getFields() { - return fields; - } + public void setExtendedDescription(String extendedDescription) { + this.extendedDescription = extendedDescription; + } + + public String getAdditionalInformation() { + return additionalInformation; + } + + public void setAdditionalInformation(String additionalInformation) { + this.additionalInformation = additionalInformation; + } + + public MultiplicityPersist getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(MultiplicityPersist multiplicity) { + this.multiplicity = multiplicity; + } + + public Boolean getHasCommentField() { + return hasCommentField; + } + + public void setHasCommentField(Boolean hasCommentField) { + this.hasCommentField = hasCommentField; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + @Component(FieldSetPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FieldSetPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.FieldSetPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected FieldSetPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return FieldSetPersist.class; + } + + @Override + protected List specifications(FieldSetPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(FieldSetPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(FieldSetPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getNumbering())) + .failOn(FieldSetPersist._numbering).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._numbering}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTitle())) + .failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getDescription())) + .failOn(FieldSetPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._description}, LocaleContextHolder.getLocale())), + + this.refSpec() + .iff(() -> !this.isNull(item.getMultiplicity())) + .on(FieldSetPersist._multiplicity) + .over(item.getMultiplicity()) + .using(() -> this.validatorFactory.validator(MultiplicityPersist.MultiplicityValidator.class)), + this.navSpec() + .iff(() -> !this.isNull(item.getFields())) + .on(FieldSetPersist._fields) + .over(item.getFields()) + .using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) + ); + } + } - public void setFields(List fields) { - this.fields = fields; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java index d68fe2170..ac6b63ca3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/MultiplicityPersist.java @@ -1,47 +1,77 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.apache.commons.compress.utils.Lists; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; public class MultiplicityPersist { - private Integer min = null; + private Integer min = null; - private Integer max = null; + private Integer max = null; - private String placeholder = null; + private String placeholder = null; - private Boolean tableView = null; + private Boolean tableView = null; - public Integer getMin() { - return min; - } + public Integer getMin() { + return min; + } - public void setMin(Integer min) { - this.min = min; - } + public void setMin(Integer min) { + this.min = min; + } - public Integer getMax() { - return max; - } + public Integer getMax() { + return max; + } - public void setMax(Integer max) { - this.max = max; - } + public void setMax(Integer max) { + this.max = max; + } - public String getPlaceholder() { - return placeholder; - } + public String getPlaceholder() { + return placeholder; + } - public void setPlaceholder(String placeholder) { - this.placeholder = placeholder; - } + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } - public Boolean getTableView() { - return tableView; - } + public Boolean getTableView() { + return tableView; + } + + public void setTableView(Boolean tableView) { + this.tableView = tableView; + } + + @Component(MultiplicityValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class MultiplicityValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.MultiplicityValidator"; + + protected MultiplicityValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { + super(conventionService, errors); + } + + @Override + protected Class modelClass() { + return MultiplicityPersist.class; + } + + @Override + protected List specifications(MultiplicityPersist item) { + return Lists.newArrayList(); + } + } - public void setTableView(Boolean tableView) { - this.tableView = tableView; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java index a7e14e565..802395039 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/PagePersist.java @@ -1,44 +1,90 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import java.util.Arrays; +import java.util.List; public class PagePersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + private String id = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String title = null; + public static final String _id = "id"; - public String getId() { - return id; - } + private Integer ordinal = null; - public void setId(String id) { - this.id = id; - } + public static final String _ordinal = "ordinal"; - public int getOrdinal() { - return ordinal; - } + private String title = null; - public void setOrdinal(int ordinal) { - this.ordinal = ordinal; - } + public static final String _title = "title"; - public String getTitle() { - return title; - } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Component(PagePersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PagePersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.PagePersistValidator"; + + private final MessageSource messageSource; + + protected PagePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return PagePersist.class; + } + + @Override + protected List specifications(PagePersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(PagePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{PagePersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(PagePersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{PagePersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTitle())) + .failOn(PagePersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{PagePersist._title}, LocaleContextHolder.getLocale())) + ); + } + } - public void setTitle(String title) { - this.title = title; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java index 127786f65..a9738f83c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/RulePersist.java @@ -1,33 +1,73 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class RulePersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String target = null; + private String target = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String value= null; + public static final String _target = "target"; + private String value = null; - public String getTarget() { - return target; - } + public static final String _value = "value"; - public void setTarget(String target) { - this.target = target; - } + public String getTarget() { + return target; + } - public String getValue() { - return value; - } + public void setTarget(String target) { + this.target = target; + } - public void setValue(String value) { - this.value = value; - } + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Component(RulePersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class RulePersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.RulePersistValidator"; + + private final MessageSource messageSource; + + protected RulePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return RulePersist.class; + } + + @Override + protected List specifications(RulePersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getTarget())) + .failOn(RulePersist._target).failWith(messageSource.getMessage("Validation_Required", new Object[]{RulePersist._target}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(RulePersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{RulePersist._value}, LocaleContextHolder.getLocale())) + ); + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java index 688a8b653..9fae38779 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java @@ -1,118 +1,194 @@ package eu.eudat.model.persist.descriptiontemplatedefinition; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.ActionConfirmationPersist; +import eu.eudat.model.persist.actionconfirmation.DmpInvitationPersist; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; - +import java.util.Arrays; import java.util.List; public class SectionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String id = null; + private String id = null; - @NotNull(message = "{validation.empty}") - private Integer ordinal = null; + public static final String _id = "id"; - @NotNull(message = "{validation.empty}") - private Boolean defaultVisibility = null; + private Integer ordinal = null; - @NotNull(message = "{validation.empty}") - private Boolean multiplicity = null; + public static final String _ordinal = "ordinal"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String page = null; + private Boolean defaultVisibility = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String title = null; + public static final String _defaultVisibility = "defaultVisibility"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String description = null; + private Boolean multiplicity = null; - @NotNull(message = "{validation.empty}") - @Valid - private List sections = null; - - @NotNull(message = "{validation.empty}") - @Valid - private List fieldSets = null; + public static final String _multiplicity = "multiplicity"; - public String getId() { - return id; - } + private String page = null; - public void setId(String id) { - this.id = id; - } + public static final String _page = "page"; - public int getOrdinal() { - return ordinal; - } + private String title = null; - public void setOrdinal(int ordinal) { - this.ordinal = ordinal; - } + public static final String _title = "title"; - public Boolean getDefaultVisibility() { - return defaultVisibility; - } + private String description = null; - public void setDefaultVisibility(Boolean defaultVisibility) { - this.defaultVisibility = defaultVisibility; - } + public static final String _description = "description"; - public Boolean getMultiplicity() { - return multiplicity; - } + private List sections = null; - public void setMultiplicity(Boolean multiplicity) { - this.multiplicity = multiplicity; - } + public static final String _sections = "sections"; - public String getPage() { - return page; - } + private List fieldSets = null; - public void setPage(String page) { - this.page = page; - } + public static final String _fieldSets = "fieldSets"; - public String getTitle() { - return title; - } + public String getId() { + return id; + } - public void setTitle(String title) { - this.title = title; - } + public void setId(String id) { + this.id = id; + } - public String getDescription() { - return description; - } + public int getOrdinal() { + return ordinal; + } - public void setDescription(String description) { - this.description = description; - } + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } - public List getSections() { - return sections; - } + public Boolean getDefaultVisibility() { + return defaultVisibility; + } - public void setSections(List sections) { - this.sections = sections; - } + public void setDefaultVisibility(Boolean defaultVisibility) { + this.defaultVisibility = defaultVisibility; + } - public List getFieldSets() { - return fieldSets; - } + public Boolean getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(Boolean multiplicity) { + this.multiplicity = multiplicity; + } + + public String getPage() { + return page; + } + + public void setPage(String page) { + this.page = page; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getSections() { + return sections; + } + + public void setSections(List sections) { + this.sections = sections; + } + + public List getFieldSets() { + return fieldSets; + } + + public void setFieldSets(List fieldSets) { + this.fieldSets = fieldSets; + } + + @Component(SectionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class SectionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.SectionPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected SectionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return SectionPersist.class; + } + + @Override + protected List specifications(SectionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getId())) + .failOn(SectionPersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._id}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getOrdinal())) + .failOn(SectionPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._ordinal}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getDefaultVisibility())) + .failOn(SectionPersist._defaultVisibility).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._defaultVisibility}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getMultiplicity())) + .failOn(SectionPersist._multiplicity).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._multiplicity}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getPage())) + .failOn(SectionPersist._page).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._page}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTitle())) + .failOn(SectionPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._title}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getDescription())) + .failOn(SectionPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._description}, LocaleContextHolder.getLocale())), + + this.navSpec() + .iff(() -> !this.isNull(item.getSections())) + .on(SectionPersist._sections) + .over(item.getSections()) + .using(() -> this.validatorFactory.validator(SectionPersistValidator.class)), + this.spec() + .must(() -> !this.isNull(item.getFieldSets())) + .failOn(SectionPersist._fieldSets).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._fieldSets}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getFieldSets())) + .on(SectionPersist._fieldSets) + .over(item.getFieldSets()) + .using(() -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class)) + ); + } + } - public void setFieldSets(List fieldSets) { - this.fieldSets = fieldSets; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java index f075bc094..3185f4d68 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AuthAutoCompleteDataPersist.java @@ -1,66 +1,113 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +import java.util.Arrays; +import java.util.List; public class AuthAutoCompleteDataPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String url = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String method = null; + private String url = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String body = null; + public static final String _uri = "uri"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String path = null; + private String method = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String type = null; + public static final String _method = "method"; - public String getUrl() { - return url; - } + private String body = null; - public void setUrl(String url) { - this.url = url; - } + public static final String _body = "body"; - public String getMethod() { - return method; - } + private String path = null; - public void setMethod(String method) { - this.method = method; - } + public static final String _path = "path"; - public String getBody() { - return body; - } + private String type = null; - public void setBody(String body) { - this.body = body; - } + public static final String _type = "type"; - public String getPath() { - return path; - } + public String getUrl() { + return url; + } - public void setPath(String path) { - this.path = path; - } + public void setUrl(String url) { + this.url = url; + } - public String getType() { - return type; - } + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static class AuthAutoCompleteDataPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.AuthAutoCompleteDataPersistValidator"; + + private final MessageSource messageSource; + + protected AuthAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return AuthAutoCompleteDataPersist.class; + } + + @Override + protected List specifications(AuthAutoCompleteDataPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getUrl())) + .failOn(AuthAutoCompleteDataPersist._uri).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._uri}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getMethod())) + .failOn(AuthAutoCompleteDataPersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._method}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getBody())) + .failOn(AuthAutoCompleteDataPersist._body).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._body}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getPath())) + .failOn(AuthAutoCompleteDataPersist._path).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._path}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getType())) + .failOn(AuthAutoCompleteDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._type}, LocaleContextHolder.getLocale())) + ); + } + } - public void setType(String type) { - this.type = type; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java index 1ccdc7c1c..4c5e1a065 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteDataPersist.java @@ -1,20 +1,35 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class AutoCompleteDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; - @NotNull(message = "{validation.empty}") - @Valid + public static final String _multiAutoComplete = "multiAutoComplete"; + private List autoCompleteSingleDataList = null; - public Boolean getMultiAutoComplete() { return multiAutoComplete; } - public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; } + public static final String _autoCompleteSingleDataList = "autoCompleteSingleDataList"; + + public Boolean getMultiAutoComplete() { + return multiAutoComplete; + } + + public void setMultiAutoComplete(Boolean multiAutoComplete) { + this.multiAutoComplete = multiAutoComplete; + } public List getAutoCompleteSingleDataList() { return autoCompleteSingleDataList; @@ -23,5 +38,40 @@ public class AutoCompleteDataPersist extends BaseFieldDataPersist { public void setAutoCompleteSingleDataList(List autoCompleteSingleDataList) { this.autoCompleteSingleDataList = autoCompleteSingleDataList; } + + @Component(AutoCompleteDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class AutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.AutoCompleteDataPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected AutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return AutoCompleteDataPersist.class; + } + + @Override + protected List specifications(AutoCompleteDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.addAll(Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(AutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getAutoCompleteSingleDataList())) + .on(AutoCompleteDataPersist._autoCompleteSingleDataList) + .over(item.getAutoCompleteSingleDataList()) + .using(() -> this.validatorFactory.validator(AutoCompleteSingleDataPersist.AutoCompleteSingleDataPersistValidator.class)) + )); + return specifications; + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java index c300150cc..3671b83c5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/AutoCompleteSingleDataPersist.java @@ -1,88 +1,157 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class AutoCompleteSingleDataPersist { - @ValidEnum(message = "{validation.empty}") - private AutoCompleteDataEntity.AutocompleteType autocompleteType; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String url = null; - - @Valid - private ComboBoxOptionPersist autoCompleteOptions; - - private String optionsRoot; + private AutoCompleteDataEntity.AutocompleteType autocompleteType; + public static final String _autocompleteType = "autocompleteType"; - @NotNull(message = "{validation.empty}") - private Boolean hasAuth = null; + private String url = null; - @Valid - private AuthAutoCompleteDataPersist auth; + public static final String _url = "url"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String method = null; + private ComboBoxOptionPersist autoCompleteOptions; - public AutoCompleteDataEntity.AutocompleteType getAutocompleteType() { - return autocompleteType; - } + public static final String _autoCompleteOptions = "autoCompleteOptions"; - public void setAutocompleteType(AutoCompleteDataEntity.AutocompleteType autocompleteType) { - this.autocompleteType = autocompleteType; - } + private String optionsRoot; - public String getOptionsRoot() { - return optionsRoot; - } + private Boolean hasAuth = null; - public void setOptionsRoot(String optionsRoot) { - this.optionsRoot = optionsRoot; - } + public static final String _hasAuth = "hasAuth"; - public String getUrl() { - return url; - } + private AuthAutoCompleteDataPersist auth; - public void setUrl(String url) { - this.url = url; - } + public static final String _auth = "auth"; - public Boolean getHasAuth() { - return hasAuth; - } + private String method = null; - public void setHasAuth(Boolean hasAuth) { - this.hasAuth = hasAuth; - } + public static final String _method = "method"; - public AuthAutoCompleteDataPersist getAuth() { - return auth; - } + public AutoCompleteDataEntity.AutocompleteType getAutocompleteType() { + return autocompleteType; + } - public void setAuth(AuthAutoCompleteDataPersist auth) { - this.auth = auth; - } + public void setAutocompleteType(AutoCompleteDataEntity.AutocompleteType autocompleteType) { + this.autocompleteType = autocompleteType; + } - public ComboBoxOptionPersist getAutoCompleteOptions() { - return autoCompleteOptions; - } + public String getOptionsRoot() { + return optionsRoot; + } - public void setAutoCompleteOptions(ComboBoxOptionPersist autoCompleteOptions) { - this.autoCompleteOptions = autoCompleteOptions; - } + public void setOptionsRoot(String optionsRoot) { + this.optionsRoot = optionsRoot; + } - public String getMethod() { - return method; - } + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Boolean getHasAuth() { + return hasAuth; + } + + public void setHasAuth(Boolean hasAuth) { + this.hasAuth = hasAuth; + } + + public AuthAutoCompleteDataPersist getAuth() { + return auth; + } + + public void setAuth(AuthAutoCompleteDataPersist auth) { + this.auth = auth; + } + + public ComboBoxOptionPersist getAutoCompleteOptions() { + return autoCompleteOptions; + } + + public void setAutoCompleteOptions(ComboBoxOptionPersist autoCompleteOptions) { + this.autoCompleteOptions = autoCompleteOptions; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + @Component(AutoCompleteSingleDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class AutoCompleteSingleDataPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.AutoCompleteSingleDataPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected AutoCompleteSingleDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return AutoCompleteSingleDataPersist.class; + } + + @Override + protected List specifications(AutoCompleteSingleDataPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getAutocompleteType())) + .failOn(AutoCompleteSingleDataPersist._autocompleteType).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._autocompleteType}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getUrl())) + .failOn(AutoCompleteSingleDataPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._url}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getHasAuth())) + .failOn(AutoCompleteSingleDataPersist._hasAuth).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._hasAuth}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getMethod())) + .failOn(AutoCompleteSingleDataPersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._method}, LocaleContextHolder.getLocale())), + + this.refSpec() + .iff(() -> !this.isNull(item.getAutoCompleteOptions())) + .on(AutoCompleteSingleDataPersist._autoCompleteOptions) + .over(item.getAutoCompleteOptions()) + .using(() -> this.validatorFactory.validator(ComboBoxOptionPersist.ComboBoxOptionPersistValidator.class)), + this.spec() + .iff(() -> !this.isNull(item.getHasAuth()) && item.getHasAuth()) + .must(() -> !this.isNull(item.getAuth())) + .failOn(AutoCompleteSingleDataPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{AutoCompleteSingleDataPersist._auth}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getAuth())) + .on(AutoCompleteSingleDataPersist._auth) + .over(item.getAuth()) + .using(() -> this.validatorFactory.validator(AuthAutoCompleteDataPersist.AuthAutoCompleteDataPersistValidator.class)) + ); + } + } - public void setMethod(String method) { - this.method = method; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java index f64f5eaee..6fe490360 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java @@ -3,67 +3,97 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import eu.eudat.commons.enums.FieldType; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +import java.util.Arrays; +import java.util.List; @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - property = "fieldType", - visible = true) + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "fieldType", + visible = true) @JsonSubTypes({ - @JsonSubTypes.Type(value = AutoCompleteDataPersist.class, name = FieldType.Names.Autocomplete), - @JsonSubTypes.Type(value = BooleanDecisionDataPersist.class, name = FieldType.Names.BooleanDecision), - @JsonSubTypes.Type(value = DatasetAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDatasets), - @JsonSubTypes.Type(value = DmpAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDmps), - @JsonSubTypes.Type(value = CheckBoxDataPersist.class, name = FieldType.Names.CheckBox), - @JsonSubTypes.Type(value = DatePickerDataPersist.class, name = FieldType.Names.DatePicker), - @JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets), - @JsonSubTypes.Type(value = FreeTextDataPersist.class, name = FieldType.Names.FreeText), - @JsonSubTypes.Type(value = LicenseDataPersist.class, name = FieldType.Names.Licenses), - @JsonSubTypes.Type(value = OrganizationDataPersist.class, name = FieldType.Names.Organizations), - @JsonSubTypes.Type(value = PublicationDataPersist.class, name = FieldType.Names.Publications), - @JsonSubTypes.Type(value = RadioBoxDataPersist.class, name = FieldType.Names.RadioBox), - @JsonSubTypes.Type(value = RegistryDataPersist.class, name = FieldType.Names.Registries), - @JsonSubTypes.Type(value = ResearcherAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpResearchers), - @JsonSubTypes.Type(value = ResearcherDataPersist.class, name = FieldType.Names.Researchers), - @JsonSubTypes.Type(value = RichTextAreaDataPersist.class, name = FieldType.Names.RichTextarea), - @JsonSubTypes.Type(value = ServiceDataPersist.class, name = FieldType.Names.Services), - @JsonSubTypes.Type(value = TagDataPersist.class, name = FieldType.Names.Tags), - @JsonSubTypes.Type(value = TaxonomyDataPersist.class, name = FieldType.Names.Taxonomies), - @JsonSubTypes.Type(value = TextAreaDataPersist.class, name = FieldType.Names.TextArea), - @JsonSubTypes.Type(value = UploadDataPersist.class, name = FieldType.Names.Upload), - @JsonSubTypes.Type(value = ValidationDataPersist.class, name = FieldType.Names.Validation), - @JsonSubTypes.Type(value = DatasetIdentifierDataPersist.class, name = FieldType.Names.DatasetIdentifier), - @JsonSubTypes.Type(value = CurrencyDataPersist.class, name = FieldType.Names.Currency), - @JsonSubTypes.Type(value = WordListDataPersist.class, name = FieldType.Names.Wordlist), - @JsonSubTypes.Type(value = DataRepositoryDataPersist.class, name = FieldType.Names.DataRepositories), - @JsonSubTypes.Type(value = JournalRepositoryDataPersist.class, name = FieldType.Names.JournalRepositories), - @JsonSubTypes.Type(value = PublicationRepositoryDataPersist.class, name = FieldType.Names.Publications), + @JsonSubTypes.Type(value = AutoCompleteDataPersist.class, name = FieldType.Names.Autocomplete), + @JsonSubTypes.Type(value = BooleanDecisionDataPersist.class, name = FieldType.Names.BooleanDecision), + @JsonSubTypes.Type(value = DatasetAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDatasets), + @JsonSubTypes.Type(value = DmpAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpDmps), + @JsonSubTypes.Type(value = CheckBoxDataPersist.class, name = FieldType.Names.CheckBox), + @JsonSubTypes.Type(value = DatePickerDataPersist.class, name = FieldType.Names.DatePicker), + @JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets), + @JsonSubTypes.Type(value = FreeTextDataPersist.class, name = FieldType.Names.FreeText), + @JsonSubTypes.Type(value = LicenseDataPersist.class, name = FieldType.Names.Licenses), + @JsonSubTypes.Type(value = OrganizationDataPersist.class, name = FieldType.Names.Organizations), + @JsonSubTypes.Type(value = PublicationDataPersist.class, name = FieldType.Names.Publications), + @JsonSubTypes.Type(value = RadioBoxDataPersist.class, name = FieldType.Names.RadioBox), + @JsonSubTypes.Type(value = RegistryDataPersist.class, name = FieldType.Names.Registries), + @JsonSubTypes.Type(value = ResearcherAutoCompleteDataPersist.class, name = FieldType.Names.InternalDmpResearchers), + @JsonSubTypes.Type(value = ResearcherDataPersist.class, name = FieldType.Names.Researchers), + @JsonSubTypes.Type(value = RichTextAreaDataPersist.class, name = FieldType.Names.RichTextarea), + @JsonSubTypes.Type(value = ServiceDataPersist.class, name = FieldType.Names.Services), + @JsonSubTypes.Type(value = TagDataPersist.class, name = FieldType.Names.Tags), + @JsonSubTypes.Type(value = TaxonomyDataPersist.class, name = FieldType.Names.Taxonomies), + @JsonSubTypes.Type(value = TextAreaDataPersist.class, name = FieldType.Names.TextArea), + @JsonSubTypes.Type(value = UploadDataPersist.class, name = FieldType.Names.Upload), + @JsonSubTypes.Type(value = ValidationDataPersist.class, name = FieldType.Names.Validation), + @JsonSubTypes.Type(value = DatasetIdentifierDataPersist.class, name = FieldType.Names.DatasetIdentifier), + @JsonSubTypes.Type(value = CurrencyDataPersist.class, name = FieldType.Names.Currency), + @JsonSubTypes.Type(value = WordListDataPersist.class, name = FieldType.Names.Wordlist), + @JsonSubTypes.Type(value = DataRepositoryDataPersist.class, name = FieldType.Names.DataRepositories), + @JsonSubTypes.Type(value = JournalRepositoryDataPersist.class, name = FieldType.Names.JournalRepositories), + @JsonSubTypes.Type(value = PublicationRepositoryDataPersist.class, name = FieldType.Names.Publications), }) public abstract class BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String label = null; + private String label = null; - @ValidEnum(message = "{validation.empty}") - private FieldType fieldType; + public static final String _label = "label"; - public String getLabel() { - return label; - } + private FieldType fieldType; - public void setLabel(String label) { - this.label = label; - } + public static final String _fieldType = "fieldType"; - public FieldType getFieldType() { - return fieldType; - } + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public FieldType getFieldType() { + return fieldType; + } + + public void setFieldType(FieldType fieldType) { + this.fieldType = fieldType; + } + + public abstract static class BaseFieldDataPersistValidator extends BaseValidator { + + protected final MessageSource messageSource; + + protected BaseFieldDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + protected List getBaseSpecifications(T item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(BaseFieldDataPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getFieldType())) + .failOn(BaseFieldDataPersist._fieldType).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._fieldType}, LocaleContextHolder.getLocale())) + ); + } + + } - public void setFieldType(FieldType fieldType) { - this.fieldType = fieldType; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java index 2815510f5..13f8d515d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BooleanDecisionDataPersist.java @@ -1,5 +1,40 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class BooleanDecisionDataPersist extends BaseFieldDataPersist { + @Component(BooleanDecisionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class BooleanDecisionPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.BooleanDecisionPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected BooleanDecisionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return BooleanDecisionDataPersist.class; + } + + @Override + protected List specifications(BooleanDecisionDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java index 81885a3c3..7fe287582 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/CheckBoxDataPersist.java @@ -1,6 +1,37 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class CheckBoxDataPersist extends BaseFieldDataPersist { - + @Component(CheckBoxDataPersist.CheckBoxDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class CheckBoxDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.CheckBoxDataPersistValidator"; + + protected CheckBoxDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return CheckBoxDataPersist.class; + } + + @Override + protected List specifications(CheckBoxDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java index c4b358a2e..113e4b04b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ComboBoxOptionPersist.java @@ -1,53 +1,103 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class ComboBoxOptionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String label = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String value = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String source = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String uri = null; - public String getLabel() { - return label; - } + private String label = null; - public void setLabel(String label) { - this.label = label; - } + public static final String _label = "label"; - public String getValue() { - return value; - } + private String value = null; - public void setValue(String value) { - this.value = value; - } + public static final String _value = "value"; - public String getSource() { - return source; - } + private String source = null; - public void setSource(String source) { - this.source = source; - } + public static final String _source = "source"; - public String getUri() { - return uri; - } + private String uri = null; - public void setUri(String uri) { - this.uri = uri; - } + public static final String _uri = "uri"; + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + @Component(ComboBoxOptionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ComboBoxOptionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.ComboBoxOptionPersistValidator"; + + private final MessageSource messageSource; + + protected ComboBoxOptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return ComboBoxOptionPersist.class; + } + + @Override + protected List specifications(ComboBoxOptionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(ComboBoxOptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(ComboBoxOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._value}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getSource())) + .failOn(ComboBoxOptionPersist._source).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._source}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getUri())) + .failOn(ComboBoxOptionPersist._uri).failWith(messageSource.getMessage("Validation_Required", new Object[]{ComboBoxOptionPersist._uri}, LocaleContextHolder.getLocale())) + ); + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java index 13003c3c9..e47c47812 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatasetAutoCompleteDataPersist.java @@ -1,15 +1,55 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class DatasetAutoCompleteDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - private Boolean multiAutoComplete = null; - public Boolean getMultiAutoComplete() { - return multiAutoComplete; - } - public void setMultiAutoComplete(Boolean multiAutoComplete) { - this.multiAutoComplete = multiAutoComplete; - } + private Boolean multiAutoComplete = null; + + public static final String _multiAutoComplete = "multiAutoComplete"; + + public Boolean getMultiAutoComplete() { + return multiAutoComplete; + } + + public void setMultiAutoComplete(Boolean multiAutoComplete) { + this.multiAutoComplete = multiAutoComplete; + } + + @Component(DatasetAutoCompleteDataPersist.DatasetAutoCompleteDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DatasetAutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.DatasetAutoCompleteDataPersistValidator"; + + protected DatasetAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return DatasetAutoCompleteDataPersist.class; + } + + @Override + protected List specifications(DatasetAutoCompleteDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(DatasetAutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{DatasetAutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java index 1e3b4ddfb..4e38e4d54 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DatePickerDataPersist.java @@ -1,4 +1,40 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class DatePickerDataPersist extends BaseFieldDataPersist { + + @Component(DatePickerDataPersist.DatePickerDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DatePickerDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.DatePickerDataPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected DatePickerDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return DatePickerDataPersist.class; + } + + @Override + protected List specifications(DatePickerDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java index c7cec3ea4..ca19f633a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/DmpAutoCompleteDataPersist.java @@ -1,16 +1,55 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class DmpAutoCompleteDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - private Boolean multiAutoComplete = null; + private Boolean multiAutoComplete = null; + + public static final String _multiAutoComplete = "multiAutoComplete"; + + public Boolean getMultiAutoComplete() { + return multiAutoComplete; + } + + public void setMultiAutoComplete(Boolean multiAutoComplete) { + this.multiAutoComplete = multiAutoComplete; + } + + @Component(DmpAutoCompleteDataPersist.DmpAutoCompleteDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DmpAutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.DmpAutoCompleteDataPersistValidator"; + + protected DmpAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return DmpAutoCompleteDataPersist.class; + } + + @Override + protected List specifications(DmpAutoCompleteDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(DmpAutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpAutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } - public Boolean getMultiAutoComplete() { - return multiAutoComplete; - } - public void setMultiAutoComplete(Boolean multiAutoComplete) { - this.multiAutoComplete = multiAutoComplete; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java index 6ade782c9..001686c1d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java @@ -1,16 +1,28 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; - import eu.eudat.commons.enums.FieldDataExternalDatasetType; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class ExternalDatasetDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; - @ValidEnum(message = "{validation.empty}") + + public static final String _multiAutoComplete = "multiAutoComplete"; + private FieldDataExternalDatasetType type; + public static final String _type = "type"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -26,4 +38,36 @@ public class ExternalDatasetDataPersist extends BaseFieldDataPersist { public void setType(FieldDataExternalDatasetType type) { this.type = type; } + + @Component(ExternalDatasetDataPersist.ExternalDatasetDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ExternalDatasetDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.ExternalDatasetDataPersistValidator"; + + protected ExternalDatasetDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return ExternalDatasetDataPersist.class; + } + + @Override + protected List specifications(ExternalDatasetDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.addAll(Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(ExternalDatasetDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getType())) + .failOn(ExternalDatasetDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._type}, LocaleContextHolder.getLocale())) + + )); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java index caf84f8af..31896b639 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/FreeTextDataPersist.java @@ -1,4 +1,36 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + public class FreeTextDataPersist extends BaseFieldDataPersist { + + @Component(FreeTextDataPersist.FreeTextDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FreeTextDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.FreeTextDataPersistValidator"; + + protected FreeTextDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return FreeTextDataPersist.class; + } + + @Override + protected List specifications(FreeTextDataPersist item) { + return getBaseSpecifications(item); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java index 2d33a5f18..954d45e15 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/LicenseDataPersist.java @@ -1,11 +1,22 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class LicenseDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; + public static final String _multiAutoComplete = "multiAutoComplete"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -14,4 +25,31 @@ public class LicenseDataPersist extends BaseFieldDataPersist { this.multiAutoComplete = multiAutoComplete; } + @Component(LicenseDataPersist.LicenseDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class LicenseDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.LicenseDataPersistValidator"; + + protected LicenseDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return LicenseDataPersist.class; + } + + @Override + protected List specifications(LicenseDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(LicenseDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{LicenseDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java index fc5cde675..6055bff29 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/OrganizationDataPersist.java @@ -1,11 +1,22 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.List; public class OrganizationDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete = null; + public static final String _multiAutoComplete = "multiAutoComplete"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -14,4 +25,31 @@ public class OrganizationDataPersist extends BaseFieldDataPersist { this.multiAutoComplete = multiAutoComplete; } + @Component(OrganizationDataPersist.OrganizationDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class OrganizationDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.OrganizationDataPersistValidator"; + + protected OrganizationDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return OrganizationDataPersist.class; + } + + @Override + protected List specifications(OrganizationDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(OrganizationDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{OrganizationDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java index db1854960..9ea264215 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/PublicationDataPersist.java @@ -1,12 +1,22 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.constraints.NotNull; +import java.util.List; public class PublicationDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") + private Boolean multiAutoComplete; + public static final String _multiAutoComplete = "multiAutoComplete"; + public Boolean getMultiAutoComplete() { return multiAutoComplete; } @@ -15,4 +25,31 @@ public class PublicationDataPersist extends BaseFieldDataPersist { this.multiAutoComplete = multiAutoComplete; } + @Component(PublicationDataPersist.PublicationDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PublicationDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.PublicationDataPersistValidator"; + + protected PublicationDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors, messageSource); + } + + @Override + protected Class modelClass() { + return PublicationDataPersist.class; + } + + @Override + protected List specifications(PublicationDataPersist item) { + List specifications = getBaseSpecifications(item); + specifications.add( + this.spec() + .must(() -> !this.isNull(item.getMultiAutoComplete())) + .failOn(PublicationDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{PublicationDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale())) + ); + return specifications; + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java index c50714189..63e48a63e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java @@ -1,16 +1,24 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; +import eu.eudat.commons.validation.ValidatorFactory; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; - +import java.util.Arrays; import java.util.List; public class RadioBoxDataPersist extends BaseFieldDataPersist { - @NotNull(message = "{validation.empty}") - @Valid + private List options = null; + public static final String _options = "options"; + public List getOptions() { return options; } @@ -18,4 +26,38 @@ public class RadioBoxDataPersist extends BaseFieldDataPersist { public void setOptions(List options) { this.options = options; } + + @Component(RadioBoxDataPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class RadioBoxDataPersistValidator extends BaseFieldDataPersistValidator { + + public static final String ValidatorName = "DescriptionTemplate.RadioBoxDataPersistValidator"; + + private final ValidatorFactory validatorFactory; + + protected RadioBoxDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors, messageSource); + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return RadioBoxDataPersist.class; + } + + @Override + protected List specifications(RadioBoxDataPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getOptions())) + .failOn(RadioBoxDataPersist._options).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxDataPersist._options}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getOptions())) + .on(RadioBoxDataPersist._options) + .over(item.getOptions()) + .using(() -> this.validatorFactory.validator(RadioBoxOptionPersist.RadioBoxOptionPersistValidator.class)) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java index 5fcd6fd47..fc70ea54d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxOptionPersist.java @@ -1,29 +1,73 @@ package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class RadioBoxOptionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String label = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String value = null; - public String getLabel() { - return label; - } + private String label = null; - public void setLabel(String label) { - this.label = label; - } + public static final String _label = "label"; - public String getValue() { - return value; - } + private String value = null; + + public static final String _value = "value"; + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Component(RadioBoxOptionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class RadioBoxOptionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DescriptionTemplate.RadioBoxOptionPersistValidator"; + + private final MessageSource messageSource; + + protected RadioBoxOptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return RadioBoxOptionPersist.class; + } + + @Override + protected List specifications(RadioBoxOptionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(RadioBoxOptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxOptionPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(RadioBoxOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxOptionPersist._value}, LocaleContextHolder.getLocale())) + ); + } + } - public void setValue(String value) { - this.value = value; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java index 8d9b9ff51..e5a48e32a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/DefinitionPersist.java @@ -5,7 +5,6 @@ import eu.eudat.commons.validation.ValidatorFactory; import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; -import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -19,54 +18,54 @@ import java.util.List; public class DefinitionPersist { - @NotNull(message = "{validation.empty}") - @Valid - private List fields = null; + @NotNull(message = "{validation.empty}") + @Valid + private List fields = null; - public static final String _fields = "fields"; + public static final String _fields = "fields"; - public List getFields() { - return fields; - } + public List getFields() { + return fields; + } - public void setFields(List fields) { - this.fields = fields; - } + public void setFields(List fields) { + this.fields = fields; + } - @Component(DefinitionPersistValidator.ValidatorName) - @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class DefinitionPersistValidator extends BaseValidator { + @Component(DefinitionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DefinitionPersistValidator extends BaseValidator { - public static final String ValidatorName = "Reference.DefinitionPersistValidator"; + public static final String ValidatorName = "Reference.DefinitionPersistValidator"; - private final MessageSource messageSource; + private final MessageSource messageSource; - private final ValidatorFactory validatorFactory; + private final ValidatorFactory validatorFactory; - protected DefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { - super(conventionService, errors); + protected DefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); this.messageSource = messageSource; this.validatorFactory = validatorFactory; } - @Override - protected Class modelClass() { - return DefinitionPersist.class; - } + @Override + protected Class modelClass() { + return DefinitionPersist.class; + } - @Override - protected List specifications(DefinitionPersist item) { - return Arrays.asList( - this.spec() - .must(() -> !this.isNull(item.getFields())) - .failOn(DefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._fields}, LocaleContextHolder.getLocale())), - this.navSpec() - .iff(() -> !this.isNull(item.getFields())) - .on(DefinitionPersist._fields) - .over(item.getFields()) - .using(() -> null) //TODO - ); - } - } + @Override + protected List specifications(DefinitionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getFields())) + .failOn(DefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._fields}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getFields())) + .on(DefinitionPersist._fields) + .over(item.getFields()) + .using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) + ); + } + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java index 5acd9eb51..655bf5a79 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencedefinition/FieldPersist.java @@ -1,24 +1,38 @@ package eu.eudat.model.persist.referencedefinition; import eu.eudat.commons.enums.ReferenceFieldDataType; +import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.old.ValidEnum; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.DescriptionTemplateTypePersist; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class FieldPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String code = null; - @ValidEnum(message = "{validation.empty}") + public static final String _code = "code"; + private ReferenceFieldDataType dataType; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _dataType = "dataType"; + private String value = null; + public static final String _value = "value"; + public String getCode() { return code; } @@ -42,6 +56,41 @@ public class FieldPersist { public void setValue(String value) { this.value = value; } + + @Component(FieldPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class FieldPersistValidator extends BaseValidator { + + public static final String ValidatorName = "Reference.FieldPersistValidator"; + + private final MessageSource messageSource; + + protected FieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return FieldPersist.class; + } + + @Override + protected List specifications(FieldPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getCode())) + .failOn(FieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._code}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getDataType())) + .failOn(FieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dataType}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(FieldPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._value}, LocaleContextHolder.getLocale())) + ); + } + } + } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java index 9946d880e..434374a42 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java @@ -169,6 +169,7 @@ public class DescriptionController { @PostMapping("persist-status") @Transactional + @ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model") public Description persistStatus(@MyValidate @RequestBody DescriptionStatusPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException { logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); Description persisted = this.descriptionService.persistStatus(model, fieldSet); From 244e0e83a2bbc9dca1a7db49d6b5cfb43b649209 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Thu, 28 Dec 2023 17:18:49 +0200 Subject: [PATCH 3/5] more frontend changes --- .../java/eu/eudat/audit/AuditableAction.java | 5 + .../main/java/eu/eudat/event/EventBroker.java | 4 + .../java/eu/eudat/event/TagTouchedEvent.java | 24 + .../src/main/java/eu/eudat/model/Dmp.java | 34 +- .../eu/eudat/model/builder/DmpBuilder.java | 29 +- .../eu/eudat/model/persist/TagPersist.java | 97 + .../java/eu/eudat/service/tag/TagService.java | 20 + .../eu/eudat/service/tag/TagServiceImpl.java | 127 + .../core/target/maven-archiver/pom.properties | 3 + .../eudat/controllers/v2/TagController.java | 133 + .../00.01.042_Change_Entity_Type_To_Enum.sql | 17 + dmp-frontend/src/app/app-routing.module.ts | 8 - .../app/core/common/enum/permission.enum.ts | 7 +- .../src/app/core/core-service.module.ts | 14 +- .../src/app/core/formatting.module.ts | 4 - .../app/core/model/description/description.ts | 4 +- .../src/app/core/model/dmp/dmp-reference.ts | 2 +- dmp-frontend/src/app/core/model/dmp/dmp.ts | 17 +- .../app/core/model/file/file-format.model.ts | 5 + .../src/app/core/model/grant/grant-listing.ts | 2 - .../src/app/core/model/project/project.ts | 2 - .../src/app/core/model/reference/reference.ts | 13 +- dmp-frontend/src/app/core/model/tag/tag.ts | 6 +- .../app/core/pipes/dataset-in-section.pipe.ts | 18 - dmp-frontend/src/app/core/query/tag.lookup.ts | 23 + .../dataset-profile.service.ts | 84 - .../dataset-wizard/dataset-wizard.service.ts | 95 - .../dataset-external-autocomplete.service.ts | 35 - .../core/services/dataset/dataset.service.ts | 101 - .../description-template.service.ts | 2 +- .../description/description.service.ts | 2 +- .../services/dmp/dmp-blueprint.service.ts | 12 +- .../services/reference/reference.service.ts | 10 +- .../src/app/core/services/tag/tag.service.ts | 98 + .../services/utilities/enum-utils.service.ts | 63 +- .../rich-text-editor.component.ts | 28 +- .../library/url-listing/url-listing-item.ts | 6 - .../url-listing/url-listing.component.html | 4 - .../url-listing/url-listing.component.scss | 8 - .../url-listing/url-listing.component.ts | 27 - .../library/url-listing/url-listing.module.ts | 20 - .../admin/default-value-editor-model.ts | 22 - .../auto-complete-auth-field-data.model.ts | 33 - .../auto-complete-field-data-editor-model.ts | 42 - .../field-data/auto-complete-single-data.ts | 46 - ...oolean-decision-field-data-editor-model.ts | 18 - .../check-box-field-data-editor-model.ts | 18 - .../field-data/currency-data-editor-models.ts | 19 - .../data-repositories-data-editor-models.ts | 22 - .../dataset-identifier-data-editor-models.ts | 19 - ...ets-autocomplete-field-data-editor-mode.ts | 26 - .../date-picker-data-editor-models.ts | 19 - ...ps-autocomplete-field-data-editor-model.ts | 27 - .../external-datasets-data-editor-models.ts | 26 - .../field-data/field-data-editor-model.ts | 15 - .../field-data-option-editor-model.ts | 23 - .../free-text-field-data-editor-model.ts | 18 - .../field-data/licenses-data-editor-models.ts | 21 - .../organizations-data-editor-models.ts | 22 - .../publications-data-editor-models.ts | 21 - .../radio-box-field-data-editor-model.ts | 30 - .../registries-data-editor-models.ts | 22 - ...s-auto-complete-field-data-editor-model.ts | 31 - .../researchers-data-editor-models.ts | 22 - .../rich-text-area-field-data-editor-model.ts | 18 - .../field-data/services-data-editor-models.ts | 22 - .../field-data/tags-data-editor-models.ts | 19 - .../taxonomies-data-editor-models.ts | 22 - .../text-area-field-data-editor-model.ts | 18 - .../upload-field-data-editor-model.ts | 39 - .../validation-data-editor-models.ts | 19 - .../word-list-field-data-editor-model.ts | 37 - .../admin/field-editor-model.ts | 175 -- .../admin/field-set-editor-model.ts | 54 - .../admin/multiplicity-editor-model.ts | 30 - .../admin/page-editor-model.ts | 32 - .../admin/rule-editor-model.ts | 32 - .../admin/section-editor-model.ts | 61 - .../admin/view-style-editor-model.ts | 22 - .../admin/visibility-editor-model.ts | 36 - .../dataset-profile/dataset-profile.module.ts | 137 -- .../dataset-profile.routing.ts | 85 - .../editor/animations/animations.ts | 90 - ...file-editor-composite-field.component.html | 463 ---- ...file-editor-composite-field.component.scss | 146 -- ...rofile-editor-composite-field.component.ts | 1088 --------- ...rofile-editor-default-value.component.html | 97 - ...rofile-editor-default-value.component.scss | 3 - ...-profile-editor-default-value.component.ts | 31 - ...-editor-auto-complete-field.component.html | 112 - ...-editor-auto-complete-field.component.scss | 3 - ...le-editor-auto-complete-field.component.ts | 35 - ...itor-boolean-decision-field.component.html | 9 - ...itor-boolean-decision-field.component.scss | 3 - ...editor-boolean-decision-field.component.ts | 19 - ...ofile-editor-checkbox-field.component.html | 9 - ...ofile-editor-checkbox-field.component.scss | 3 - ...profile-editor-checkbox-field.component.ts | 18 - ...file-editor-combo-box-field.component.html | 10 - ...file-editor-combo-box-field.component.scss | 3 - ...rofile-editor-combo-box-field.component.ts | 41 - ...ofile-editor-currency-field.component.html | 9 - ...ofile-editor-currency-field.component.scss | 3 - ...profile-editor-currency-field.component.ts | 18 - ...tor-data-repositories-field.component.html | 12 - ...tor-data-repositories-field.component.scss | 3 - ...ditor-data-repositories-field.component.ts | 20 - ...or-dataset-identifier-field.component.html | 9 - ...or-dataset-identifier-field.component.scss | 3 - ...itor-dataset-identifier-field.component.ts | 24 - ...datasets-autocomplete-field.component.html | 13 - ...datasets-autocomplete-field.component.scss | 0 ...r-datasets-autocomplete-field.component.ts | 19 - ...le-editor-date-picker-field.component.html | 9 - ...le-editor-date-picker-field.component.scss | 3 - ...file-editor-date-picker-field.component.ts | 18 - ...tor-dmps-autocomplete-field.component.html | 13 - ...tor-dmps-autocomplete-field.component.scss | 0 ...ditor-dmps-autocomplete-field.component.ts | 20 - ...tor-external-datasets-field.component.html | 22 - ...tor-external-datasets-field.component.scss | 3 - ...ditor-external-datasets-field.component.ts | 41 - ...file-editor-free-text-field.component.html | 11 - ...file-editor-free-text-field.component.scss | 3 - ...rofile-editor-free-text-field.component.ts | 18 - ...internal-dmp-entities-field.component.html | 12 - ...internal-dmp-entities-field.component.scss | 0 ...r-internal-dmp-entities-field.component.ts | 44 - ...-journal-repositories-field.component.html | 12 - ...-journal-repositories-field.component.scss | 3 - ...or-journal-repositories-field.component.ts | 19 - ...ofile-editor-licenses-field.component.html | 12 - ...ofile-editor-licenses-field.component.scss | 3 - ...profile-editor-licenses-field.component.ts | 18 - ...-editor-organizations-field.component.html | 13 - ...-editor-organizations-field.component.scss | 3 - ...le-editor-organizations-field.component.ts | 25 - ...itor-pub-repositories-field.component.html | 12 - ...itor-pub-repositories-field.component.scss | 3 - ...editor-pub-repositories-field.component.ts | 20 - ...e-editor-publications-field.component.html | 12 - ...e-editor-publications-field.component.scss | 3 - ...ile-editor-publications-field.component.ts | 18 - ...file-editor-radio-box-field.component.html | 41 - ...file-editor-radio-box-field.component.scss | 4 - ...rofile-editor-radio-box-field.component.ts | 29 - ...ile-editor-registries-field.component.html | 12 - ...ile-editor-registries-field.component.scss | 3 - ...ofile-editor-registries-field.component.ts | 21 - ...archers-auto-complete-field.component.html | 13 - ...archers-auto-complete-field.component.scss | 0 ...searchers-auto-complete-field.component.ts | 19 - ...le-editor-researchers-field.component.html | 12 - ...le-editor-researchers-field.component.scss | 3 - ...file-editor-researchers-field.component.ts | 30 - ...editor-rich-text-area-field.component.html | 13 - ...editor-rich-text-area-field.component.scss | 3 - ...e-editor-rich-text-area-field.component.ts | 18 - ...ofile-editor-services-field.component.html | 12 - ...ofile-editor-services-field.component.scss | 3 - ...profile-editor-services-field.component.ts | 22 - ...t-profile-editor-tags-field.component.html | 9 - ...t-profile-editor-tags-field.component.scss | 3 - ...set-profile-editor-tags-field.component.ts | 29 - ...ile-editor-taxonomies-field.component.html | 12 - ...ile-editor-taxonomies-field.component.scss | 3 - ...ofile-editor-taxonomies-field.component.ts | 18 - ...file-editor-text-area-field.component.html | 13 - ...file-editor-text-area-field.component.scss | 3 - ...rofile-editor-text-area-field.component.ts | 18 - ...profile-editor-upload-field.component.html | 62 - ...profile-editor-upload-field.component.scss | 3 - ...t-profile-editor-upload-field.component.ts | 102 - ...file-editor-validator-field.component.html | 9 - ...file-editor-validator-field.component.scss | 3 - ...rofile-editor-validator-field.component.ts | 18 - ...file-editor-word-list-field.component.html | 41 - ...file-editor-word-list-field.component.scss | 3 - ...rofile-editor-word-list-field.component.ts | 29 - ...ataset-profile-editor-field.component.html | 333 --- ...ataset-profile-editor-field.component.scss | 66 - .../dataset-profile-editor-field.component.ts | 988 -------- .../components/field/view-style-enum.ts | 29 - .../final-preview.component.html | 3 - .../final-preview.component.scss | 0 .../final-preview/final-preview.component.ts | 28 - ...dataset-profile-editor-page.component.html | 13 - ...dataset-profile-editor-page.component.scss | 7 - .../dataset-profile-editor-page.component.ts | 17 - ...dataset-profile-editor-rule.component.html | 99 - ...dataset-profile-editor-rule.component.scss | 3 - .../dataset-profile-editor-rule.component.ts | 223 -- ...ile-editor-section-fieldset.component.html | 173 -- ...ile-editor-section-fieldset.component.scss | 80 - ...ofile-editor-section-fieldset.component.ts | 269 --- ...aset-profile-editor-section.component.html | 95 - ...aset-profile-editor-section.component.scss | 31 - ...ataset-profile-editor-section.component.ts | 87 - .../editor-custom-validators.ts | 67 - .../editor/dataset-profile-editor-model.ts | 65 - .../dataset-profile-editor.component.html | 522 ---- .../dataset-profile-editor.component.scss | 386 --- .../dataset-profile-editor.component.ts | 2142 ----------------- .../criteria/dataset-profile.component.html | 23 - .../criteria/dataset-profile.component.scss | 17 - .../criteria/dataset-profile.component.ts | 50 - ...onfirmation-upload-profiles.component.html | 44 - ...onfirmation-upload-profiles.component.scss | 102 - ...-confirmation-upload-profiles.component.ts | 63 - .../dataset-profile-listing.component.html | 100 - .../dataset-profile-listing.component.scss | 119 - .../dataset-profile-listing.component.ts | 319 --- .../listing/pipe/parse-status.pipe.ts | 27 - .../dataset-profile-preview.component.html | 2 - .../dataset-profile-preview.component.scss | 0 .../dataset-profile-preview.component.ts | 35 - .../table-of-contents-entry.ts | 29 - .../table-of-contents-internal-section.html | 252 -- .../table-of-contents-internal-section.scss | 116 - .../table-of-contents-internal-section.ts | 281 --- .../table-of-contents/table-of-contents.html | 32 - .../table-of-contents/table-of-contents.scss | 92 - .../table-of-contents/table-of-contents.ts | 605 ----- .../description-template.module.ts | 2 - .../dmp-blueprint/dmp-blueprint.module.ts | 2 - .../index-managment.component.ts | 2 - .../app/ui/admin/language/language.module.ts | 2 - .../notification-template.module.ts | 2 - .../reference-type/reference-type.module.ts | 2 - .../ui/admin/reference/reference.module.ts | 2 - .../src/app/ui/admin/tenant/tenant.module.ts | 2 - .../app/ui/dashboard/dashboard.component.ts | 2 +- .../src/app/ui/dashboard/dashboard.module.ts | 7 +- .../ui/dashboard/drafts/drafts.component.ts | 7 +- .../recent-edited-activity.component.ts | 3 +- ...t-edited-description-activity.component.ts | 3 +- .../recent-edited-dmp-activity.component.ts | 2 - .../dataset-copy-dialogue.component.html | 17 - .../dataset-copy-dialogue.component.scss | 50 - .../dataset-copy-dialogue.component.ts | 95 - .../dataset-copy-dialogue.module.ts | 18 - .../dataset-editor.component.html | 107 - .../dataset-editor.component.scss | 117 - .../dataset-editor.component.ts | 145 -- .../dataset-wizard-editor.model.ts | 382 --- .../dataset-wizard.component.html | 288 --- .../dataset-wizard.component.scss | 524 ---- .../dataset-wizard.component.ts | 1507 ------------ ...-external-references-editor.component.html | 489 ---- ...et-external-references-editor.component.ts | 341 --- .../prefill-dataset.component.html | 57 - .../prefill-dataset.component.scss | 57 - .../prefill-dataset.component.ts | 200 -- .../src/app/ui/dataset/dataset.module.ts | 78 - .../src/app/ui/dataset/dataset.routing.ts | 121 - .../dataset-criteria-dialog.component.html | 2 - .../dataset-criteria-dialog.component.scss | 20 - .../dataset-criteria-dialog.component.ts | 44 - .../criteria/dataset-criteria.component.html | 200 -- .../criteria/dataset-criteria.component.scss | 56 - .../criteria/dataset-criteria.component.ts | 339 --- .../dataset-upload-dialogue.component.html | 42 - .../dataset-upload-dialogue.component.scss | 21 - .../dataset-upload-dialogue.component.ts | 157 -- .../listing/dataset-listing.component.html | 120 - .../listing/dataset-listing.component.scss | 265 -- .../listing/dataset-listing.component.ts | 446 ---- .../dataset-listing-item.component.html | 150 -- .../dataset-listing-item.component.scss | 261 -- .../dataset-listing-item.component.ts | 294 --- .../overview/dataset-overview.component.html | 186 -- .../overview/dataset-overview.component.scss | 301 --- .../overview/dataset-overview.component.ts | 550 ----- .../dataset-preview-dialog.component.html | 0 .../dataset-preview-dialog.component.scss | 0 .../dataset-preview-dialog.component.ts | 0 .../dataset-preview-dialog.module.ts | 20 + ...cription-base-fields-editor.component.html | 65 +- ...escription-base-fields-editor.component.ts | 86 +- .../editor/description-editor.component.html | 31 +- .../editor/description-editor.component.ts | 1 - .../editor/description-editor.module.ts | 8 +- .../editor/description-editor.resolver.ts | 14 + .../form-composite-title.component.html | 3 +- .../form-composite-title.component.ts | 1 + .../form-field-set.component.html | 7 +- .../form-field-set.component.ts | 8 +- .../form-field/form-field.component.html | 4 +- .../form-field/form-field.component.ts | 48 +- .../form-section/form-section.component.html | 153 +- .../form-section/form-section.component.ts | 11 +- .../description-form.component.html | 67 +- .../description-form.component.ts | 7 +- .../visibility-rules.service.ts | 55 +- ...-external-references-editor.component.scss | 35 - ...et-external-references-editor.component.ts | 341 --- ...ta-repository-dialog-editor.component.html | 28 - ...ta-repository-dialog-editor.component.scss | 3 - ...data-repository-dialog-editor.component.ts | 42 - ...ernal-dataset-dialog-editor.component.html | 24 - ...ernal-dataset-dialog-editor.component.scss | 3 - ...xternal-dataset-dialog-editor.component.ts | 42 - ...rnal-registry-dialog-editor.component.html | 28 - ...rnal-registry-dialog-editor.component.scss | 3 - ...ternal-registry-dialog-editor.component.ts | 42 - ...ernal-service-dialog-editor.component.html | 28 - ...ernal-service-dialog-editor.component.scss | 3 - ...xternal-service-dialog-editor.component.ts | 42 - .../listing/description-listing.component.ts | 14 +- .../listing/description-listing.module.ts | 2 - .../description-overview.component.ts | 14 +- .../overview/description-overview.module.ts | 2 - ...art-new-description-dialog.component.html} | 0 ...art-new-description-dialog.component.scss} | 0 ...start-new-description-dialog.component.ts} | 28 +- .../start-new-description-dialog.module.ts | 20 + .../clone-dialog/clone-dialog.component.ts | 49 +- .../dmp-editor-blueprint.component.ts | 1236 ---------- ...mponent.html => dmp-editor.component.html} | 157 +- ...mponent.scss => dmp-editor.component.scss} | 0 .../dmp-editor.component.ts | 1518 ++++++++++++ .../dmp-editor-blueprint/dmp-editor.model.ts | 228 ++ .../dmp-editor.module.ts} | 24 +- .../dmp-editor.resolver.ts | 105 + .../dmp-editor.routing.ts | 62 + .../dmp-editor.service.ts | 15 + dmp-frontend/src/app/ui/dmp/dmp.module.ts | 176 +- dmp-frontend/src/app/ui/dmp/dmp.routing.ts | 69 +- .../dataset-editor-details.module.ts | 2 - .../ui/dmp/editor/dmp-editor.component.html | 258 -- .../ui/dmp/editor/dmp-editor.component.scss | 467 ---- .../app/ui/dmp/editor/dmp-editor.component.ts | 1177 --------- .../src/app/ui/dmp/editor/dmp-editor.model.ts | 214 -- .../app/ui/dmp/listing/dmp-listing.module.ts | 23 + .../app/ui/dmp/listing/dmp-listing.routing.ts | 28 + .../start-new-dmp-dialog.component.html | 0 .../start-new-dmp-dialog.component.scss | 0 .../start-new-dmp-dialog.component.ts | 4 +- .../start-new-dmp-dialog.module.ts | 22 + .../dmp-upload-dialog.component.html} | 0 .../dmp-upload-dialog.component.scss} | 0 .../dmp-upload-dialog.component.ts} | 65 +- .../dmp-upload-dialog.module.ts | 22 + .../dmp/overview/dmp-overview.component.html | 5 +- .../dmp/overview/dmp-overview.component.scss | 2 + .../ui/dmp/overview/dmp-overview.component.ts | 9 +- .../ui/dmp/overview/dmp-overview.module.ts | 31 +- .../ui/dmp/overview/dmp-overview.routing.ts | 29 + .../ui/dmp/wizard/dmp-wizard-editor.model.ts | 173 -- .../ui/dmp/wizard/dmp-wizard.component.html | 23 - .../ui/dmp/wizard/dmp-wizard.component.scss | 46 - .../app/ui/dmp/wizard/dmp-wizard.component.ts | 176 -- .../editor/dmp-wizard-editor.component.html | 86 - .../editor/dmp-wizard-editor.component.scss | 47 - .../editor/dmp-wizard-editor.component.ts | 179 -- .../dmp-wizard-dataset-listing.component.html | 15 - .../dmp-wizard-dataset-listing.component.scss | 37 - .../dmp-wizard-dataset-listing.component.ts | 83 - .../src/app/ui/navbar/navbar.component.ts | 2 +- ...ta-repository-dialog-editor.component.html | 0 ...ta-repository-dialog-editor.component.scss | 0 ...data-repository-dialog-editor.component.ts | 0 ...ernal-dataset-dialog-editor.component.html | 0 ...ernal-dataset-dialog-editor.component.scss | 0 ...xternal-dataset-dialog-editor.component.ts | 0 ...rnal-registry-dialog-editor.component.html | 0 ...rnal-registry-dialog-editor.component.scss | 0 ...ternal-registry-dialog-editor.component.ts | 0 ...ernal-service-dialog-editor.component.html | 0 ...ernal-service-dialog-editor.component.scss | 0 ...xternal-service-dialog-editor.component.ts | 0 .../reference-field.component.html} | 34 +- .../reference-field.component.scss} | 0 .../reference-field.component.ts | 345 +++ .../reference-field/reference-field.module.ts | 19 + .../tag/tags-field/tags-field.component.html | 17 + .../tag/tags-field/tags-field.component.scss | 3 + .../ui/tag/tags-field/tags-field.component.ts | 70 + .../ui/tag/tags-field/tags-field.module.ts | 21 + dmp-frontend/src/assets/i18n/en.json | 194 +- .../src/common/base/base-entity.model.ts | 14 +- 381 files changed, 3895 insertions(+), 27118 deletions(-) create mode 100644 dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java create mode 100644 dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java create mode 100644 dmp-backend/core/target/maven-archiver/pom.properties create mode 100644 dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java create mode 100644 dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql create mode 100644 dmp-frontend/src/app/core/model/file/file-format.model.ts delete mode 100644 dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts create mode 100644 dmp-frontend/src/app/core/query/tag.lookup.ts delete mode 100644 dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts delete mode 100644 dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts delete mode 100644 dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts delete mode 100644 dmp-frontend/src/app/core/services/dataset/dataset.service.ts create mode 100644 dmp-frontend/src/app/core/services/tag/tag.service.ts delete mode 100644 dmp-frontend/src/app/library/url-listing/url-listing-item.ts delete mode 100644 dmp-frontend/src/app/library/url-listing/url-listing.component.html delete mode 100644 dmp-frontend/src/app/library/url-listing/url-listing.component.scss delete mode 100644 dmp-frontend/src/app/library/url-listing/url-listing.component.ts delete mode 100644 dmp-frontend/src/app/library/url-listing/url-listing.module.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss delete mode 100644 dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset.module.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/dataset.routing.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts delete mode 100644 dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html delete mode 100644 dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss delete mode 100644 dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts rename dmp-frontend/src/app/ui/{dmp/dataset-preview => description/description-preview}/dataset-preview-dialog.component.html (100%) rename dmp-frontend/src/app/ui/{dmp/dataset-preview => description/description-preview}/dataset-preview-dialog.component.scss (100%) rename dmp-frontend/src/app/ui/{dmp/dataset-preview => description/description-preview}/dataset-preview-dialog.component.ts (100%) create mode 100644 dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/dataset-external-references-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/registry/dataset-external-registry-dialog-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/description/editor/external-references/editors/service/dataset-external-service-dialog-editor.component.ts rename dmp-frontend/src/app/ui/{dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.html => description/start-new-description-dialog/start-new-description-dialog.component.html} (100%) rename dmp-frontend/src/app/ui/{dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.scss => description/start-new-description-dialog/start-new-description-dialog.component.scss} (100%) rename dmp-frontend/src/app/ui/{dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component.ts => description/start-new-description-dialog/start-new-description-dialog.component.ts} (81%) create mode 100644 dmp-frontend/src/app/ui/description/start-new-description-dialog/start-new-description-dialog.module.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts rename dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/{dmp-editor-blueprint.component.html => dmp-editor.component.html} (65%) rename dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/{dmp-editor-blueprint.component.scss => dmp-editor.component.scss} (100%) create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts rename dmp-frontend/src/app/ui/{dataset/overview/dataset-overview.module.ts => dmp/dmp-editor-blueprint/dmp-editor.module.ts} (61%) create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.routing.ts create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.service.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts create mode 100644 dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts create mode 100644 dmp-frontend/src/app/ui/dmp/listing/dmp-listing.routing.ts rename dmp-frontend/src/app/ui/dmp/{ => new}/start-new-dmp-dialogue/start-new-dmp-dialog.component.html (100%) rename dmp-frontend/src/app/ui/dmp/{ => new}/start-new-dmp-dialogue/start-new-dmp-dialog.component.scss (100%) rename dmp-frontend/src/app/ui/dmp/{ => new}/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts (94%) create mode 100644 dmp-frontend/src/app/ui/dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.module.ts rename dmp-frontend/src/app/ui/dmp/{listing/upload-dialogue/dmp-upload-dialogue.component.html => new/upload-dialogue/dmp-upload-dialog.component.html} (100%) rename dmp-frontend/src/app/ui/dmp/{listing/upload-dialogue/dmp-upload-dialogue.component.scss => new/upload-dialogue/dmp-upload-dialog.component.scss} (100%) rename dmp-frontend/src/app/ui/dmp/{listing/upload-dialogue/dmp-upload-dialogue.component.ts => new/upload-dialogue/dmp-upload-dialog.component.ts} (66%) create mode 100644 dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.module.ts create mode 100644 dmp-frontend/src/app/ui/dmp/overview/dmp-overview.routing.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard-editor.model.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.html delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.scss delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/dmp-wizard.component.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.html delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.scss delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/editor/dmp-wizard-editor.component.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.html delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.scss delete mode 100644 dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.ts rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/registry/dataset-external-registry-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/registry/dataset-external-registry-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/registry/dataset-external-registry-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/service/dataset-external-service-dialog-editor.component.html (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/service/dataset-external-service-dialog-editor.component.scss (100%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references => reference/reference-field}/editors/service/dataset-external-service-dialog-editor.component.ts (100%) rename dmp-frontend/src/app/ui/{description/editor/external-references/dataset-external-references-editor.component.html => reference/reference-field/reference-field.component.html} (96%) rename dmp-frontend/src/app/ui/{dataset/dataset-wizard/external-references/dataset-external-references-editor.component.scss => reference/reference-field/reference-field.component.scss} (100%) create mode 100644 dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts create mode 100644 dmp-frontend/src/app/ui/reference/reference-field/reference-field.module.ts create mode 100644 dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.html create mode 100644 dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.scss create mode 100644 dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.ts create mode 100644 dmp-frontend/src/app/ui/tag/tags-field/tags-field.module.ts diff --git a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java index 25fe23812..74bb495ae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java +++ b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java @@ -114,4 +114,9 @@ public class AuditableAction { public static final EventId Deposit_GetAccessToken = new EventId(18001, "Deposit_GetAccessToken"); public static final EventId Deposit_Deposit = new EventId(18002, "Deposit_Deposit"); public static final EventId Deposit_GetLogo = new EventId(18003, "Deposit_GetLogo"); + + public static final EventId Tag_Query = new EventId(19000, "Tag_Query"); + public static final EventId Tag_Lookup = new EventId(19001, "Tag_Lookup"); + public static final EventId Tag_Persist = new EventId(19002, "Tag_Persist"); + public static final EventId Tag_Delete = new EventId(19003, "Tag_Delete"); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java b/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java index 75ffc150d..62cc50830 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java +++ b/dmp-backend/core/src/main/java/eu/eudat/event/EventBroker.java @@ -50,4 +50,8 @@ public class EventBroker { this.applicationEventPublisher.publishEvent(event); } + public void emit(TagTouchedEvent event) { + this.applicationEventPublisher.publishEvent(event); + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java b/dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java new file mode 100644 index 000000000..5d6047f80 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/event/TagTouchedEvent.java @@ -0,0 +1,24 @@ +package eu.eudat.event; + +import java.util.UUID; + +public class TagTouchedEvent { + + public TagTouchedEvent() { + } + + public TagTouchedEvent(UUID id) { + this.id = id; + } + + private UUID id; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + +} 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 f815edd2e..0874d3a99 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 @@ -12,95 +12,75 @@ 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 Short version; - public static final String _version = "version"; private DmpStatus status; - public static final String _status = "status"; private DmpVersionStatus versionStatus; - public static final String _versionStatus = "versionStatus"; private String properties; - public static final String _properties = "properties"; private UUID groupId; - public static final String _groupId = "groupId"; private String description; - public static final String _description = "description"; 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 User creator; - public static final String _creator = "creator"; private DmpAccessType accessType; - public static final String _accessType = "accessType"; private DmpBlueprint blueprint; - public static final String _blueprint = "blueprint"; private String language; - public static final String _language = "language"; private Instant publicAfter; - public static final String _publicAfter = "publicAfter"; private String hash; - public static final String _hash = "hash"; private List dmpReferences; - public static final String _dmpReferences = "dmpReferences"; private List dmpUsers; - public static final String _dmpUsers = "dmpUsers"; private List descriptions; - public static final String _descriptions = "descriptions"; - private List entityDois; + private List dmpDescriptionTemplates; + public static final String _dmpDescriptionTemplates = "dmpDescriptionTemplates"; + private List entityDois; public static final String _entityDois = "entityDois"; public UUID getId() { @@ -279,6 +259,14 @@ public class Dmp { this.descriptions = descriptions; } + public List getDmpDescriptionTemplates() { + return dmpDescriptionTemplates; + } + + public void setDmpDescriptionTemplates(List dmpDescriptionTemplates) { + this.dmpDescriptionTemplates = dmpDescriptionTemplates; + } + public List getEntityDois() { return entityDois; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java index 061843e29..8db8c2596 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java @@ -3,6 +3,7 @@ package eu.eudat.model.builder; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.enums.EntityType; import eu.eudat.convention.ConventionService; +import eu.eudat.data.DmpDescriptionTemplateEntity; import eu.eudat.data.DmpEntity; import eu.eudat.model.*; import eu.eudat.query.*; @@ -73,6 +74,9 @@ public class DmpBuilder extends BaseBuilder { FieldSet descriptionsFields = fields.extractPrefixed(this.asPrefix(Dmp._descriptions)); Map> descriptionsMap = this.collectDmpDescriptions(descriptionsFields, data); + FieldSet dmpDescriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpDescriptionTemplates)); + Map> dmpDescriptionTemplatesMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplatesFields, data); + for (DmpEntity d : data) { Dmp m = new Dmp(); if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId()); @@ -97,6 +101,7 @@ public class DmpBuilder extends BaseBuilder { if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId())); if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId())); if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); + if (dmpDescriptionTemplatesMap != null && !dmpDescriptionTemplatesMap.isEmpty() && dmpDescriptionTemplatesMap.containsKey(d.getId())) m.setDmpDescriptionTemplates(dmpDescriptionTemplatesMap.get(d.getId())); models.add(m); } @@ -110,7 +115,7 @@ public class DmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, Dmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, DmpReference._id)); DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); @@ -207,7 +212,7 @@ public class DmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", DmpUser.class.getSimpleName()); Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, Dmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, DmpUser._id)); DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); @@ -225,7 +230,7 @@ public class DmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", Description.class.getSimpleName()); Map> itemMap; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Dmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Description._id)); DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); @@ -238,4 +243,22 @@ public class DmpBuilder extends BaseBuilder { return itemMap; } + private Map> collectDmpDescriptionTemplates(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) return null; + this.logger.debug("checking related - {}", Description.class.getSimpleName()); + + Map> itemMap; + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpDescriptionTemplate._dmp, DmpDescriptionTemplate._id)); + DmpDescriptionTemplateQuery query = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); + + if (!fields.hasField(this.asIndexer(DmpDescriptionTemplate._dmp, Dmp._id))) { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> { + x.getDmp().setId(null); + }); + } + + return itemMap; + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java new file mode 100644 index 000000000..b085a074b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/TagPersist.java @@ -0,0 +1,97 @@ +package eu.eudat.model.persist; + + +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.data.TagEntity; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +public class TagPersist { + + private UUID id; + + public final static String _id = "id"; + + private String label = null; + + public final static String _label = "label"; + + private String hash; + + public final static String _hash = "hash"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + @Component(TagPersistValidator.ValidatorName) + @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class TagPersistValidator extends BaseValidator { + public static final String ValidatorName = "TagPersistValidator"; + + private final MessageSource messageSource; + + public TagPersistValidator(MessageSource messageSource, ConventionService conventionService, ErrorThesaurusProperties errors) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return TagPersist.class; + } + + @Override + protected List specifications(TagPersist item) { + return Arrays.asList( + this.spec() + .iff(() -> this.isValidGuid(item.getId())) + .must(() -> this.isValidHash(item.getHash())) + .failOn(TagPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{TagPersist._hash}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isValidGuid(item.getId())) + .must(() -> !this.isValidHash(item.getHash())) + .failOn(TagPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getLabel())) + .failOn(TagPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{TagPersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getLabel())) + .must(() -> this.lessEqual(item.getLabel(), TagEntity._labelLength)) + .failOn(TagPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{TagPersist._label}, LocaleContextHolder.getLocale())) + ); + } + } + +} + diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java new file mode 100644 index 000000000..649e24e92 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagService.java @@ -0,0 +1,20 @@ +package eu.eudat.service.tag; + +import eu.eudat.model.Tag; +import eu.eudat.model.persist.TagPersist; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.FieldSet; + +import javax.management.InvalidApplicationException; +import java.util.UUID; + +public interface TagService { + + Tag persist(TagPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException; + + void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java new file mode 100644 index 000000000..d88ecc8a4 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/tag/TagServiceImpl.java @@ -0,0 +1,127 @@ +package eu.eudat.service.tag; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.authorization.Permission; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.scope.user.UserScope; +import eu.eudat.convention.ConventionService; +import eu.eudat.data.TagEntity; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.event.EventBroker; +import eu.eudat.event.TagTouchedEvent; +import eu.eudat.model.Tag; +import eu.eudat.model.builder.TagBuilder; +import eu.eudat.model.deleter.TagDeleter; +import eu.eudat.model.persist.TagPersist; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.exception.MyValidationException; +import gr.cite.tools.fieldset.BaseFieldSet; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import jakarta.persistence.EntityManager; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Service; + +import javax.management.InvalidApplicationException; +import java.time.Instant; +import java.util.List; +import java.util.UUID; + +@Service +public class TagServiceImpl implements TagService { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagServiceImpl.class)); + + private final EntityManager entityManager; + + private final AuthorizationService authorizationService; + + private final DeleterFactory deleterFactory; + + private final BuilderFactory builderFactory; + + private final ConventionService conventionService; + + private final ErrorThesaurusProperties errors; + + private final MessageSource messageSource; + + private final EventBroker eventBroker; + + private final UserScope userScope; + + + @Autowired + public TagServiceImpl( + EntityManager entityManager, + AuthorizationService authorizationService, + DeleterFactory deleterFactory, + BuilderFactory builderFactory, + ConventionService conventionService, + ErrorThesaurusProperties errors, + MessageSource messageSource, + UserScope userScope, + EventBroker eventBroker) { + this.entityManager = entityManager; + this.authorizationService = authorizationService; + this.deleterFactory = deleterFactory; + this.builderFactory = builderFactory; + this.conventionService = conventionService; + this.errors = errors; + this.messageSource = messageSource; + this.eventBroker = eventBroker; + this.userScope = userScope; + } + + public Tag persist(TagPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException { + logger.debug(new MapLogEntry("persisting data tag").And("model", model).And("fields", fields)); + + this.authorizationService.authorizeForce(Permission.EditTag); + + Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); + + TagEntity data; + if (isUpdate) { + data = this.entityManager.find(TagEntity.class, model.getId()); + if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); + } else { + data = new TagEntity(); + data.setId(UUID.randomUUID()); + data.setIsActive(IsActive.Active); + data.setCreatedAt(Instant.now()); + data.setCreatedById(userScope.getUserId()); + } + + data.setLabel(model.getLabel()); + data.setUpdatedAt(Instant.now()); + if (isUpdate) + this.entityManager.merge(data); + else + this.entityManager.persist(data); + + this.entityManager.flush(); + + this.eventBroker.emit(new TagTouchedEvent(data.getId())); + return this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Tag._id), data); + } + + public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { + logger.debug("deleting tag: {}", id); + + this.authorizationService.authorizeForce(Permission.DeleteTag); + + this.deleterFactory.deleter(TagDeleter.class).deleteAndSaveByIds(List.of(id)); + } + +} + diff --git a/dmp-backend/core/target/maven-archiver/pom.properties b/dmp-backend/core/target/maven-archiver/pom.properties new file mode 100644 index 000000000..bc6d378ce --- /dev/null +++ b/dmp-backend/core/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=core +groupId=eu.eudat +version=1.0.0-SNAPSHOT diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java new file mode 100644 index 000000000..dd5a2ba96 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/TagController.java @@ -0,0 +1,133 @@ +package eu.eudat.controllers.v2; + +import eu.eudat.audit.AuditableAction; +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.validation.ValidationFilterAnnotation; +import eu.eudat.data.TagEntity; +import eu.eudat.logic.services.ApiContext; +import eu.eudat.model.Tag; +import eu.eudat.model.builder.TagBuilder; +import eu.eudat.model.censorship.TagCensor; +import eu.eudat.model.persist.TagPersist; +import eu.eudat.model.result.QueryResult; +import eu.eudat.query.TagQuery; +import eu.eudat.query.lookup.TagLookup; +import eu.eudat.service.tag.TagService; +import gr.cite.tools.auditing.AuditService; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.censor.CensorFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.exception.MyForbiddenException; +import gr.cite.tools.exception.MyNotFoundException; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import javax.management.InvalidApplicationException; +import java.util.*; + +@RestController +@RequestMapping(path = "api/tag") +public class TagController { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TagController.class)); + @Autowired + private ApiContext apiContext; + + private final BuilderFactory builderFactory; + private final AuditService auditService; + + private final TagService tagService; + + private final CensorFactory censorFactory; + + private final QueryFactory queryFactory; + + private final MessageSource messageSource; + + public TagController( + BuilderFactory builderFactory, + AuditService auditService, + TagService tagService, + CensorFactory censorFactory, + QueryFactory queryFactory, + MessageSource messageSource) { + this.builderFactory = builderFactory; + this.auditService = auditService; + this.tagService = tagService; + this.censorFactory = censorFactory; + this.queryFactory = queryFactory; + this.messageSource = messageSource; + } + + @PostMapping("query") + public QueryResult Query(@RequestBody TagLookup lookup) throws MyApplicationException, MyForbiddenException { + logger.debug("querying {}", Tag.class.getSimpleName()); + + this.censorFactory.censor(TagCensor.class).censor(lookup.getProject(), null); + + TagQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic); + + List data = query.collectAs(lookup.getProject()); + List models = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data); + long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size(); + + this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + + return new QueryResult<>(models, count); + } + + @GetMapping("{id}") + public Tag Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + logger.debug(new MapLogEntry("retrieving" + Tag.class.getSimpleName()).And("id", id).And("fields", fieldSet)); + + this.censorFactory.censor(TagCensor.class).censor(fieldSet, null); + + TagQuery query = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id); + Tag model = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet)); + if (model == null) + throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tag.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + this.auditService.track(AuditableAction.Tag_Lookup, Map.ofEntries( + new AbstractMap.SimpleEntry("id", id), + new AbstractMap.SimpleEntry("fields", fieldSet) + )); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + + return model; + } + + @PostMapping("persist") + @Transactional + @ValidationFilterAnnotation(validator = TagPersist.TagPersistValidator.ValidatorName, argumentName ="model") + public Tag Persist(@RequestBody TagPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { + logger.debug(new MapLogEntry("persisting" + Tag.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); + Tag persisted = this.tagService.persist(model, fieldSet); + + this.auditService.track(AuditableAction.Tag_Persist, Map.ofEntries( + new AbstractMap.SimpleEntry("model", model), + new AbstractMap.SimpleEntry("fields", fieldSet) + )); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + return persisted; + } + + @DeleteMapping("{id}") + @Transactional + public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException { + logger.debug(new MapLogEntry("retrieving" + Tag.class.getSimpleName()).And("id", id)); + + this.tagService.deleteAndSave(id); + + this.auditService.track(AuditableAction.Tag_Delete, "id", id); + //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); + } +} diff --git a/dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql b/dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql new file mode 100644 index 000000000..d9587bc09 --- /dev/null +++ b/dmp-db-scema/updates/00.01.042_Change_Entity_Type_To_Enum.sql @@ -0,0 +1,17 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.042'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + ALTER TABLE IF EXISTS public."EntityDoi" DROP COLUMN IF EXISTS entity_type; + +ALTER TABLE IF EXISTS public."EntityDoi" + ADD COLUMN entity_type smallint NOT NULL DEFAULT 0; + +ALTER TABLE IF EXISTS public."EntityDoi" + ALTER COLUMN entity_type DROP DEFAULT; + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.042', '2023-12-27 12:00:00.000000+02', now(), 'Change Entity Type To Enum at Entity DOI table'); + +END$$; \ No newline at end of file diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index ce28a3f8a..99e963b29 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -91,14 +91,6 @@ const appRoutes: Routes = [ // }, - { - path: 'dataset-profiles', - loadChildren: () => import('./ui/admin/dataset-profile/dataset-profile.module').then(m => m.DatasetProfileModule), - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-PROFILES' - } - }, { path: 'description-templates', loadChildren: () => import('./ui/admin/description-template/description-template.module').then(m => m.DescriptionTemplateModule), diff --git a/dmp-frontend/src/app/core/common/enum/permission.enum.ts b/dmp-frontend/src/app/core/common/enum/permission.enum.ts index cd71ed394..205ec77ca 100644 --- a/dmp-frontend/src/app/core/common/enum/permission.enum.ts +++ b/dmp-frontend/src/app/core/common/enum/permission.enum.ts @@ -9,11 +9,16 @@ export enum AppPermission { EditDmpBlueprint = "EditDmpBlueprint", DeleteDmpBlueprint = "DeleteDmpBlueprint", - //DmpBlueprint + //Description BrowseDescription = "BrowseDescription", EditDescription = "EditDescription", DeleteDescription= "DeleteDescription", + //Dmp + BrowseDmp = "BrowseDmp", + EditDmp = "EditDmp", + DeleteDmp= "DeleteDmp", + //DescriptionTemplateType BrowseDescriptionTemplate = "BrowseDescriptionTemplate", EditDescriptionTemplate = "EditDescriptionTemplate", diff --git a/dmp-frontend/src/app/core/core-service.module.ts b/dmp-frontend/src/app/core/core-service.module.ts index 9ac0062fd..f769c318e 100644 --- a/dmp-frontend/src/app/core/core-service.module.ts +++ b/dmp-frontend/src/app/core/core-service.module.ts @@ -9,10 +9,6 @@ import { CultureService } from './services/culture/culture-service'; import { LanguageInfoService } from './services/culture/language-info-service'; import { CurrencyService } from './services/currency/currency.service'; import { DashboardService } from './services/dashboard/dashboard.service'; -import { DatasetProfileService } from './services/dataset-profile/dataset-profile.service'; -import { DatasetWizardService } from './services/dataset-wizard/dataset-wizard.service'; -import { DatasetExternalAutocompleteService } from './services/dataset/dataset-external-autocomplete.service'; -import { DatasetService } from './services/dataset/dataset.service'; import { DepositRepositoriesService } from './services/deposit-repositories/deposit-repositories.service'; import { DescriptionTemplateTypeService } from './services/description-template-type/description-template-type.service'; import { DmpBlueprintService } from './services/dmp/dmp-blueprint.service'; @@ -64,6 +60,8 @@ import { LanguageHttpService } from './services/language/language.http.service'; import { DescriptionService } from './services/description/description.service'; import { MaintenanceService } from './services/maintenance/maintenance.service'; import { NotificationTemplateService } from './services/notification-template/notification-template.service'; +import { TagService } from './services/tag/tag.service'; +import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; // // // This is shared module that provides all the services. Its imported only once on the AppModule. @@ -108,17 +106,13 @@ export class CoreServiceModule { DmpBlueprintService, ExternalSourcesService, ExternalSourcesConfigurationService, - DatasetService, - DatasetWizardService, ExternalDatasetService, ExternalDataRepositoryService, ExternalRegistryService, ExternalResearcherService, ExternalServiceService, - DatasetProfileService, UserServiceOld, DmpInvitationService, - DatasetExternalAutocompleteService, OrganisationService, EmailConfirmationService, ContactSupportService, @@ -147,7 +141,9 @@ export class CoreServiceModule { DmpServiceNew, DescriptionService, MaintenanceService, - NotificationTemplateService + NotificationTemplateService, + TagService, + CanDeactivateGuard ], }; } diff --git a/dmp-frontend/src/app/core/formatting.module.ts b/dmp-frontend/src/app/core/formatting.module.ts index efa153368..b5ca3f3c0 100644 --- a/dmp-frontend/src/app/core/formatting.module.ts +++ b/dmp-frontend/src/app/core/formatting.module.ts @@ -9,7 +9,6 @@ import { JsonParserPipe } from './pipes/json-parser.pipe'; import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe'; import {FieldValuePipe} from "@app/core/pipes/field-value.pipe"; import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe"; -import { DatasetInSectioPipe } from './pipes/dataset-in-section.pipe'; import { PipeService } from '@common/formatting/pipe.service'; // @@ -28,7 +27,6 @@ import { PipeService } from '@common/formatting/pipe.service'; JsonParserPipe, FieldValuePipe, ColumnClassPipe, - DatasetInSectioPipe, ], exports: [ NgForLimitPipe, @@ -39,7 +37,6 @@ import { PipeService } from '@common/formatting/pipe.service'; JsonParserPipe, FieldValuePipe, ColumnClassPipe, - DatasetInSectioPipe ], providers: [ EnumUtils, @@ -53,7 +50,6 @@ import { PipeService } from '@common/formatting/pipe.service'; JsonParserPipe, FieldValuePipe, ColumnClassPipe, - DatasetInSectioPipe ] }) export class FormattingModule { } diff --git a/dmp-frontend/src/app/core/model/description/description.ts b/dmp-frontend/src/app/core/model/description/description.ts index 84723774c..3c10d2226 100644 --- a/dmp-frontend/src/app/core/model/description/description.ts +++ b/dmp-frontend/src/app/core/model/description/description.ts @@ -2,7 +2,7 @@ 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 { DescriptionTemplate } from "../description-template/description-template"; -import { Dmp, DmpDescriptionTemplatePersist } from "../dmp/dmp"; +import { Dmp, DmpDescriptionTemplate, DmpDescriptionTemplatePersist } from "../dmp/dmp"; import { Reference, ReferencePersist } from "../reference/reference"; import { Tag } from "../tag/tag"; import { User } from "../user/user"; @@ -19,7 +19,7 @@ export interface Description extends BaseEntity { descriptionReferences: DescriptionReference[]; descriptionTags: DescriptionTag[]; descriptionTemplate: DescriptionTemplate; - dmpDescriptionTemplate: DmpDescriptionTemplatePersist; + dmpDescriptionTemplate: DmpDescriptionTemplate; dmp: Dmp; } diff --git a/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts b/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts index 8c009455a..bbe9edd8f 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp-reference.ts @@ -8,5 +8,5 @@ import { Dmp } from "./dmp"; export interface DmpReference extends BaseEntity { dmp?: Dmp; reference?: Reference; - data: String; + 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 29966f13d..a90ca5e45 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -12,13 +12,15 @@ import { FunderModel } from "../funder/funder"; import { GrantListingModel } from "../grant/grant-listing"; import { OrganizationModel } from "../organisation/organization"; import { ProjectModel } from "../project/project"; -import { DmpReference, ReferencePersist } from '../reference/reference'; +import { ReferencePersist } from '../reference/reference'; import { ResearcherModel } from "../researcher/researcher"; import { User, UserModel } from "../user/user"; 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 { DmpBlueprint } from '../dmp-blueprint/dmp-blueprint'; +import { DmpReference } from './dmp-reference'; export interface DmpModel { //TODO: Delete id: string; @@ -47,12 +49,6 @@ export interface DmpModel { //TODO: Delete language: String; } - -export interface DmpBlueprint { - id: string; - label: string; -} - export interface Dmp extends BaseEntity { label: string; version: number; @@ -71,6 +67,7 @@ export interface Dmp extends BaseEntity { dmpReferences: DmpReference[]; dmpUsers: DmpUser[]; descriptions: Description[]; + dmpDescriptionTemplates: DmpDescriptionTemplate[]; entityDois: EntityDoi[]; @@ -119,15 +116,15 @@ export interface DmpPersist extends BaseEntityPersist { properties: string; description: String; language: String; - blueprint: DmpBlueprint; + blueprint: Guid; accessType: DmpAccessType; references: DmpReferencePersist[]; descriptionTemplates: DmpDescriptionTemplatePersist[]; } export interface DmpReferencePersist extends BaseEntityPersist { - reference: ReferencePersist; - data: string; + reference?: ReferencePersist; + data?: string; } export interface DmpDescriptionTemplatePersist extends BaseEntityPersist { diff --git a/dmp-frontend/src/app/core/model/file/file-format.model.ts b/dmp-frontend/src/app/core/model/file/file-format.model.ts new file mode 100644 index 000000000..df5b80c0d --- /dev/null +++ b/dmp-frontend/src/app/core/model/file/file-format.model.ts @@ -0,0 +1,5 @@ +export interface FileFormat { + format: string; + formatName: string; + icon: string; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/grant/grant-listing.ts b/dmp-frontend/src/app/core/model/grant/grant-listing.ts index d6d2fba85..6c5e0ef86 100644 --- a/dmp-frontend/src/app/core/model/grant/grant-listing.ts +++ b/dmp-frontend/src/app/core/model/grant/grant-listing.ts @@ -1,4 +1,3 @@ -import { UrlListingItem } from "../../../library/url-listing/url-listing-item"; import { GrantType } from '../../common/enum/grant-type'; import { Status } from '../../common/enum/status'; @@ -16,7 +15,6 @@ export interface GrantListingModel { contentUrl?: string; funderId?: string; files?: ContentFile[]; - dmps?: UrlListingItem[]; source?: string; } diff --git a/dmp-frontend/src/app/core/model/project/project.ts b/dmp-frontend/src/app/core/model/project/project.ts index bd467a575..fb30e3490 100644 --- a/dmp-frontend/src/app/core/model/project/project.ts +++ b/dmp-frontend/src/app/core/model/project/project.ts @@ -1,5 +1,4 @@ import { Status } from "../../common/enum/status"; -import { UrlListingItem } from "../../../library/url-listing/url-listing-item"; import { ProjectType } from "../../common/enum/project-type"; export class ProjectModel { @@ -15,7 +14,6 @@ export class ProjectModel { description?: String; contentUrl?: string; files?: ContentFile[]; - dmps?: UrlListingItem[]; } export interface ContentFile { diff --git a/dmp-frontend/src/app/core/model/reference/reference.ts b/dmp-frontend/src/app/core/model/reference/reference.ts index f243d3cd5..9f7ab1730 100644 --- a/dmp-frontend/src/app/core/model/reference/reference.ts +++ b/dmp-frontend/src/app/core/model/reference/reference.ts @@ -14,7 +14,7 @@ export interface Reference extends BaseEntity{ abbreviation: string; source: string; sourceType: ReferenceSourceType; - dmpReferences: DmpReference[]; + // dmpReferences: DmpReference[]; } export interface Definition { @@ -27,15 +27,6 @@ export interface Field { value: string; } -export interface DmpReference { - id: UUID; - dmp: DmpModel; - reference: Reference; - data: string; - createdAt: Date; - updatedAt: Date; -} - // old fetcher export interface FetcherReference { id: string; @@ -61,7 +52,7 @@ export interface ReferencePersist extends BaseEntityPersist { label: string; type: ReferenceType; description: string; - definition?: DefinitionPersist; + definition: DefinitionPersist; reference: string; abbreviation: string; source: string; diff --git a/dmp-frontend/src/app/core/model/tag/tag.ts b/dmp-frontend/src/app/core/model/tag/tag.ts index 68204c2c9..577dbb76f 100644 --- a/dmp-frontend/src/app/core/model/tag/tag.ts +++ b/dmp-frontend/src/app/core/model/tag/tag.ts @@ -1,4 +1,4 @@ -import { BaseEntity } from "@common/base/base-entity.model"; +import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; import { User } from "../user/user"; export interface TagModel { //TODO: old entity, delete @@ -10,3 +10,7 @@ export interface Tag extends BaseEntity { label?: string; createdBy?: User; } + +export interface TagPersist extends BaseEntityPersist { + label?: string; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts b/dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts deleted file mode 100644 index fd9e2e4f2..000000000 --- a/dmp-frontend/src/app/core/pipes/dataset-in-section.pipe.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { UntypedFormGroup } from "@angular/forms"; - -@Pipe({ - name: 'datasetInSection' -}) -export class DatasetInSectioPipe implements PipeTransform{ - - transform(datasets: UntypedFormGroup[], args: string): UntypedFormGroup[] { - let values = []; - for(var dataset of datasets){ - if(dataset.get('dmpSectionIndex').value == args){ - values.push(dataset); - } - } - return values; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/tag.lookup.ts b/dmp-frontend/src/app/core/query/tag.lookup.ts new file mode 100644 index 000000000..28627e99d --- /dev/null +++ b/dmp-frontend/src/app/core/query/tag.lookup.ts @@ -0,0 +1,23 @@ +import { Lookup } from "@common/model/lookup"; +import { Guid } from "@common/types/guid"; +import { IsActive } from "../common/enum/is-active.enum"; + +export class TagLookup extends Lookup implements TagFilter { + ids: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + createdByIds: Guid[]; + + constructor() { + super(); + } +} + +export interface TagFilter { + ids: Guid[]; + excludedIds: Guid[]; + like: string; + isActive: IsActive[]; + createdByIds: Guid[]; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts deleted file mode 100644 index 521b71da7..000000000 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { DatasetProfile } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileDefinitionModel } from '@app/core/model/dataset-profile-definition/dataset-profile-definition'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { BaseHttpService } from '@app/core/services/http/base-http.service'; -import { DatasetProfileEditorModel } from '@app/ui/admin/dataset-profile/editor/dataset-profile-editor-model'; -import { BaseService } from '@common/base/base.service'; -import { BaseHttpParams } from '@common/http/base-http-params'; -import { InterceptorType } from '@common/http/interceptors/interceptor-type'; -import { environment } from 'environments/environment'; -import { Observable } from 'rxjs'; -import { takeUntil } from "rxjs/operators"; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class DatasetProfileService extends BaseService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - super(); - this.actionUrl = configurationService.server + 'admin/'; - } - - createForm(data) { - return this.httpClient.post(this.actionUrl + 'addDmp', data); - } - - updateForm(id, data): Observable { - return this.http.post(this.actionUrl + 'addDmp/' + id, data); - } - - getDatasetProfileById(datasetProfileID): Observable { - return this.http.get(this.actionUrl + 'get/' + datasetProfileID); - } - - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest); - } - - preview(data: DatasetProfile): Observable { - return this.http.post(this.actionUrl + 'preview', data); - } - - clone(id: string): Observable { - return this.http.post(this.actionUrl + 'datasetprofile/clone/' + id, {}); - } - - newVersion(id, data) { - return this.httpClient.post(this.actionUrl + 'newVersion/' + id, data); - } - - delete(id: string, data): Observable { - //return this.http.post(this.actionUrl + 'addDmp/' + id, data); - return this.http.delete(this.actionUrl + id, {}); - } - - downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml }); - } - - uploadFile(file: FileList, labelSent: string, datasetProfileId?: string): Observable> { - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - const formData = new FormData(); - formData.append('file', file[0], labelSent); - return (datasetProfileId === undefined || datasetProfileId == null) - ? this.http.post(this.actionUrl + "upload", formData, { params: params }) - : this.http.post(this.actionUrl + "upload/" + datasetProfileId, formData, { params: params }); - - } - - searchSemantics(like: string): Observable { - return this.http.get(this.actionUrl + "getSemantics?query=" + like); - } -} diff --git a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts deleted file mode 100644 index 437a413ea..000000000 --- a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { BaseHttpParams } from '../../../../common/http/base-http-params'; -import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; -import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition'; -import { DatasetProfileModel } from '../../model/dataset/dataset-profile'; -import { DatasetWizardModel } from '../../model/dataset/dataset-wizard'; -import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; -import { RequestItem } from '../../query/request-item'; -import { BaseHttpService } from '../http/base-http.service'; -import { ConfigurationService } from '../configuration/configuration.service'; - -@Injectable() -export class DatasetWizardService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'datasets/'; - } - - // public userDmps(criteria: RequestItem): Observable { - // return this.http.post(this.actionUrl + 'userDmps', criteria, { headers: this.headers }); - // } - - public getAvailableProfiles(criteria: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers }); - } - - public getSingle(id: String): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); // + 'getSingle/' - } - - public getSinglePublic(id: String): Observable { - return this.http.get(this.actionUrl + 'public/' + id, { headers: this.headers }); // + 'getSingle/' - } - - public delete(id: string): Observable { - return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); - } - - createDataset(datasetModel: DatasetWizardModel): Observable { - return this.http.post(this.actionUrl, datasetModel, { headers: this.headers }); - } - - public downloadPDF(id: string): Observable> { - return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: this.headers }); - } - - public downloadDOCX(id: string): Observable> { - let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDocx }); - } - - public downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); // + 'getXml/' - } - - public getDefinition(id: String): Observable { - return this.http.get(this.actionUrl + 'get/' + id, { headers: this.headers }); - } - - unlock(id: String): Observable { - return this.http.get(this.actionUrl + id + '/unlock', { headers: this.headers }); - } - - public uploadXml(fileList: FileList, datasetTitle: string, dmpId: string, datasetProfileId: string): Observable { - const formData: FormData = new FormData(); - if (fileList instanceof FileList) { - for (let i = 0; i < fileList.length; i++) { - formData.append('file', fileList[i], datasetTitle); - } - } else if (Array.isArray(fileList)) { - formData.append('files', fileList); - } else { - formData.append('file', fileList); - } - formData.append('dmpId', dmpId); - formData.append('datasetProfileId', datasetProfileId); - - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.JSONContentType] - }; - return this.http.post(this.actionUrl + 'upload', formData, { params: params }); - } - - public updateDatasetProfile(id: String): Observable { - return this.http.get(this.actionUrl + "profile/" + id, { headers: this.headers }); - } -} diff --git a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts deleted file mode 100644 index 48e7348cf..000000000 --- a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria'; -import { RequestItem } from '../../query/request-item'; -import { DatasetProfileService } from '../dataset-profile/dataset-profile.service'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { map } from 'rxjs/operators'; - -@Injectable() -export class DatasetExternalAutocompleteService { - - private actionUrl: string; - - constructor( - private httpClient: HttpClient, - private datasetProfileService: DatasetProfileService, - private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + '/'; - } - - getDatasetProfileById(datasetProfileID) { - return this.datasetProfileService.getDatasetProfileById(datasetProfileID); - } - - queryAutocomplete(lookUpItem: RequestItem): Observable { - return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem); - } - - queryApi(lookUpItem: RequestItem): Observable{ - return this.httpClient.post(this.configurationService.server + 'search/autocompleteOptions', lookUpItem); - } - -} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts deleted file mode 100644 index 418196418..000000000 --- a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DataTableData } from '../../model/data-table/data-table-data'; -import { DataTableRequest } from '../../model/data-table/data-table-request'; -import { DatasetListingModel } from '../../model/dataset/dataset-listing'; -import { DatasetProfileModel } from '../../model/dataset/dataset-profile'; -import { DatasetCriteria } from '../../query/dataset/dataset-criteria'; -import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria'; -import { BaseHttpService } from '../http/base-http.service'; -import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; -import { ConfigurationService } from '../configuration/configuration.service'; -import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview'; -import { HttpHeaders, HttpResponse, HttpClient } from '@angular/common/http'; -import { DatasetModel } from '@app/core/model/dataset/dataset'; - -@Injectable() -export class DatasetService { - - private actionUrl: string; - private headers = new HttpHeaders(); - - constructor( - private http: BaseHttpService, - private configurationSevice: ConfigurationService, - private httpClient: HttpClient) { - this.actionUrl = configurationSevice.server + 'datasets/'; - } - - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'paged', dataTableRequest); - } - - getPublicPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'public/paged', dataTableRequest); - } - - makeDatasetPublic(id: String) { - return this.http.get(this.actionUrl + 'makepublic/' + id); - } - - getDatasetProfiles(dataTableRequest: DataTableRequest): Observable { - return this.http.post(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest); - } - - getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest) { - return this.http.post>(this.actionUrl + 'datasetProfilesUsedByDatasets/paged', dataTableRequest); - } - - generateIndex() { - return this.http.post(this.actionUrl + 'index', {}); - } - - clearIndex() { - return this.http.delete(this.actionUrl + 'index'); - } - - getOverviewSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'overview/' + id, { headers: this.headers }); - } - - getOverviewSinglePublic(id: string): Observable { - return this.http.get(this.actionUrl + 'publicOverview/' + id, { headers: this.headers }) - } - - clone(datasetModel: DatasetModel, id: String): Observable { - return this.http.post(this.actionUrl + 'clone/' + id, datasetModel, { headers: this.headers }); - } - - delete(id: String): Observable { - return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); // + 'delete/' - } - - publish(id: String): Observable { - return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }); - } - - public downloadXML(id: string): Observable> { - let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); //+ "/getXml/" - } - - public downloadDocx(id: string): Observable> { - let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword') - return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDoc }); - } - - public downloadPDF(id: string): Observable> { - let headerPdf: HttpHeaders = this.headers.set('Content-Type', 'application/pdf') - return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf }); - } - - public validateDataset(id: string) : Observable{ - return this.http.get(this.actionUrl+id+"/validate"); - } - - //GK: NO - // public downloadJson(id: string): Observable> { - // return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); - // } -} diff --git a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts index cf3ad57f4..a2c01c23a 100644 --- a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts +++ b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts @@ -111,7 +111,7 @@ export class DescriptionTemplateService { valueAssign: (item: DescriptionTemplate) => item.id, }; - private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateLookup { + public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateLookup { const lookup: DescriptionTemplateLookup = new DescriptionTemplateLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } diff --git a/dmp-frontend/src/app/core/services/description/description.service.ts b/dmp-frontend/src/app/core/services/description/description.service.ts index 8e7309812..a9289d9a4 100644 --- a/dmp-frontend/src/app/core/services/description/description.service.ts +++ b/dmp-frontend/src/app/core/services/description/description.service.ts @@ -113,7 +113,7 @@ export class DescriptionService { valueAssign: (item: Description) => item.id, }; - private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionLookup { + public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionLookup { const lookup: DescriptionLookup = new DescriptionLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } 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 222c958d1..06f47ab0e 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 @@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DmpBlueprint, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DmpBlueprint, DmpBlueprintDefinitionSection, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.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'; @@ -126,4 +126,14 @@ export class DmpBlueprintService { if (like) { lookup.like = this.filterService.transformLike(like); } return lookup; } + + // + // + // UI Helpers + // + // + + getSection(dmpBlueprint: DmpBlueprint, sectionId: Guid): DmpBlueprintDefinitionSection { + return dmpBlueprint?.definition?.sections?.find(x => x.id === sectionId); + } } diff --git a/dmp-frontend/src/app/core/services/reference/reference.service.ts b/dmp-frontend/src/app/core/services/reference/reference.service.ts index 36f0b04ca..16ba3f344 100644 --- a/dmp-frontend/src/app/core/services/reference/reference.service.ts +++ b/dmp-frontend/src/app/core/services/reference/reference.service.ts @@ -1,7 +1,10 @@ import { Injectable } from '@angular/core'; import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { DmpReference, Reference, ReferencePersist } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { Reference, ReferencePersist } from '@app/core/model/reference/reference'; +import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; 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'; @@ -13,9 +16,6 @@ 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'; -import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type'; -import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; -import { Dmp } from '@app/core/model/dmp/dmp'; @Injectable() export class ReferenceService { @@ -130,5 +130,5 @@ export class ReferenceService { getReferencesForTypesFirstSafe(dmpReferences: DmpReference[], referenceTypes: ReferenceType[]): DmpReference { return this.getReferencesForTypes(dmpReferences, referenceTypes)?.find(Boolean); } - + } diff --git a/dmp-frontend/src/app/core/services/tag/tag.service.ts b/dmp-frontend/src/app/core/services/tag/tag.service.ts new file mode 100644 index 000000000..3dc92c9aa --- /dev/null +++ b/dmp-frontend/src/app/core/services/tag/tag.service.ts @@ -0,0 +1,98 @@ +import { Injectable } from '@angular/core'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { Tag, TagPersist } from '@app/core/model/tag/tag'; +import { TagLookup } from '@app/core/query/tag.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 TagService { + + constructor( + private http: BaseHttpV2Service, + private installationConfiguration: ConfigurationService, + private filterService: FilterService + ) { } + + private get apiBase(): string { return `${this.installationConfiguration.server}tag`; } + + query(q: TagLookup): 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: TagPersist): 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 + // + // tslint:disable-next-line: member-ordering + singleAutocompleteConfiguration: SingleAutoCompleteConfiguration = { + initialItems: (data?: any) => this.query(this.buildAutocompleteLookup()).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), + displayFn: (item: Tag) => item.label, + titleFn: (item: Tag) => item.label, + valueAssign: (item: Tag) => item.id, + }; + + // tslint:disable-next-line: member-ordering + multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = { + initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(searchQuery, excludedItems)).pipe(map(x => x.items)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)), + displayFn: (item: Tag) => item.label, + titleFn: (item: Tag) => item.label, + valueAssign: (item: Tag) => item.id, + }; + + public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): TagLookup { + const lookup: TagLookup = new TagLookup(); + 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) + ] + }; + lookup.order = { items: [nameof(x => x.label)] }; + if (like) { lookup.like = this.filterService.transformLike(like); } + return lookup; + } +} diff --git a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts index 5b3c35f56..8b80025b3 100644 --- a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts +++ b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts @@ -15,7 +15,6 @@ import { Role } from '@app/core/common/enum/role'; import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; import { SupportiveMaterialFieldType } from '@app/core/common/enum/supportive-material-field-type'; import { UserDescriptionTemplateRole } from '@app/core/common/enum/user-description-template-role'; -import { ViewStyleType } from '@app/ui/admin/dataset-profile/editor/components/field/view-style-enum'; import { TranslateService } from '@ngx-translate/core'; import { AppRole } from '../../common/enum/app-role'; import { DatasetProfileComboBoxType } from '../../common/enum/dataset-profile-combo-box-type'; @@ -132,38 +131,38 @@ export class EnumUtils { case DatasetProfileFieldViewStyle.Validation: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.VALIDATION'); } } - toDatasetProfileViewTypeString(status: ViewStyleType): string { - switch (status) { - case ViewStyleType.BooleanDecision: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.BOOLEAN-DECISION'); - case ViewStyleType.CheckBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CHECKBOX'); - case ViewStyleType.Select: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SELECT'); - case ViewStyleType.InternalDmpEntities: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.INTERNAL-DMP-ENTITIES'); - case ViewStyleType.FreeText: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.FREE-TEXT'); - case ViewStyleType.RadioBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RADIO-BOX'); - case ViewStyleType.TextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TEXT-AREA'); - case ViewStyleType.RichTextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA'); - case ViewStyleType.Table: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TABLE'); - case ViewStyleType.Upload: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.UPLOAD'); - case ViewStyleType.DatePicker: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATE-PICKER'); - case ViewStyleType.ExternalDatasets: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.EXTERNAL-DATASETS'); - case ViewStyleType.DataRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATA-REPOSITORIES'); - case ViewStyleType.PubRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUB-REPOSITORIES'); - case ViewStyleType.JournalRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.JOURNALS-REPOSITORIES'); - case ViewStyleType.Taxonomies: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAXONOMIES'); - case ViewStyleType.Licenses: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.LICENSES'); - case ViewStyleType.Publications: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUBLICATIONS'); - case ViewStyleType.Registries: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.REGISTRIES'); - case ViewStyleType.Services: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SERVICES'); - case ViewStyleType.Tags: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAGS'); - case ViewStyleType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RESEARCHERS'); - case ViewStyleType.Organizations: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.ORGANIZATIONS'); - case ViewStyleType.DatasetIdentifier: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATASET-IDENTIFIER'); - case ViewStyleType.Currency: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CURRENCY'); - case ViewStyleType.Validation: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.VALIDATION'); - case ViewStyleType.Other: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.OTHER'); - } + // toDatasetProfileViewTypeString(status: ViewStyleType): string { + // switch (status) { + // case ViewStyleType.BooleanDecision: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.BOOLEAN-DECISION'); + // case ViewStyleType.CheckBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CHECKBOX'); + // case ViewStyleType.Select: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SELECT'); + // case ViewStyleType.InternalDmpEntities: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.INTERNAL-DMP-ENTITIES'); + // case ViewStyleType.FreeText: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.FREE-TEXT'); + // case ViewStyleType.RadioBox: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RADIO-BOX'); + // case ViewStyleType.TextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TEXT-AREA'); + // case ViewStyleType.RichTextArea: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RICH-TEXT-AREA'); + // case ViewStyleType.Table: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TABLE'); + // case ViewStyleType.Upload: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.UPLOAD'); + // case ViewStyleType.DatePicker: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATE-PICKER'); + // case ViewStyleType.ExternalDatasets: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.EXTERNAL-DATASETS'); + // case ViewStyleType.DataRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATA-REPOSITORIES'); + // case ViewStyleType.PubRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUB-REPOSITORIES'); + // case ViewStyleType.JournalRepositories: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.JOURNALS-REPOSITORIES'); + // case ViewStyleType.Taxonomies: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAXONOMIES'); + // case ViewStyleType.Licenses: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.LICENSES'); + // case ViewStyleType.Publications: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.PUBLICATIONS'); + // case ViewStyleType.Registries: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.REGISTRIES'); + // case ViewStyleType.Services: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.SERVICES'); + // case ViewStyleType.Tags: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.TAGS'); + // case ViewStyleType.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RESEARCHERS'); + // case ViewStyleType.Organizations: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.ORGANIZATIONS'); + // case ViewStyleType.DatasetIdentifier: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATASET-IDENTIFIER'); + // case ViewStyleType.Currency: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CURRENCY'); + // case ViewStyleType.Validation: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.VALIDATION'); + // case ViewStyleType.Other: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.OTHER'); + // } - } + // } toDatasetProfileComboBoxTypeString(status: DatasetProfileComboBoxType): string { switch (status) { diff --git a/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts b/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts index 4168ab651..097038de2 100644 --- a/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts +++ b/dmp-frontend/src/app/library/rich-text-editor/rich-text-editor.component.ts @@ -1,6 +1,5 @@ -import {Component, Input} from "@angular/core"; -import {AngularEditorConfig} from "@kolkov/angular-editor"; -import {UntypedFormControl} from "@angular/forms"; +import { ChangeDetectionStrategy, Component, Input } from "@angular/core"; +import { AngularEditorConfig } from "@kolkov/angular-editor"; @Component({ selector: 'rich-text-editor-component', @@ -10,10 +9,12 @@ import {UntypedFormControl} from "@angular/forms"; [config]="editorConfig" [formControlName]="controlName" placeholder="{{(placeholder? (placeholder | translate) : '') + (required ? ' *': '')}}" (paste)="pasteWithoutFormatting($event)"> - close + close `, - styleUrls: ['./rich-text-editor.component.scss'] + styleUrls: ['./rich-text-editor.component.scss'], + // TODO: performance issue with this control. changed the change detection strategy in case it improves + changeDetection: ChangeDetectionStrategy.OnPush }) export class RichTextEditorComponent { @Input() parentFormGroup; @@ -42,12 +43,12 @@ export class RichTextEditorComponent { sanitize: true, toolbarPosition: 'top', customClasses: [ - { name: 'H1 header', class: '', tag: 'h1' }, - { name: 'H2 header', class: '', tag: 'h2' }, - { name: 'H3 header', class: '', tag: 'h3' }, - { name: 'H4 header', class: '', tag: 'h4' }, - { name: 'H5 header', class: '', tag: 'h5'}, - { name: 'H6 header', class: '', tag: 'h6'} + { name: 'H1 header', class: '', tag: 'h1' }, + { name: 'H2 header', class: '', tag: 'h2' }, + { name: 'H3 header', class: '', tag: 'h3' }, + { name: 'H4 header', class: '', tag: 'h4' }, + { name: 'H5 header', class: '', tag: 'h5' }, + { name: 'H6 header', class: '', tag: 'h6' } ], toolbarHiddenButtons: [ [ @@ -66,8 +67,9 @@ export class RichTextEditorComponent { ] }; - get formInput(): UntypedFormControl { - return this.parentFormGroup.get(this.controlName); + + ngOnInit() { + console.log('ngOnInit: '); } ngAfterContentInit() { diff --git a/dmp-frontend/src/app/library/url-listing/url-listing-item.ts b/dmp-frontend/src/app/library/url-listing/url-listing-item.ts deleted file mode 100644 index 6fd4c5639..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing-item.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export class UrlListingItem { - public label: string; - public url: string; - public all: string; -} diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.component.html b/dmp-frontend/src/app/library/url-listing/url-listing.component.html deleted file mode 100644 index baa37bc6c..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.component.html +++ /dev/null @@ -1,4 +0,0 @@ - -{{'URL-LISTING-COMPONENT.SHOW-MORE'|translate}} diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.component.scss b/dmp-frontend/src/app/library/url-listing/url-listing.component.scss deleted file mode 100644 index 757307de7..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -.url-listing-item:hover { - color: #0056b3 !important; - text-decoration: underline !important; -} - -.url-listing-item { - color: #007bff !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.component.ts b/dmp-frontend/src/app/library/url-listing/url-listing.component.ts deleted file mode 100644 index 95bc53b5a..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Component, Input } from "@angular/core"; -import { Router } from "@angular/router"; -import { UrlListingItem } from "./url-listing-item"; - -@Component({ - selector: 'app-url-listing', - templateUrl: './url-listing.component.html', - styleUrls: ['./url-listing.component.scss'] -}) -export class UrlListingComponent { - - @Input() items: UrlListingItem[]; - @Input() parameters: any - @Input() urlLimit: number = 3; - - constructor( - private router: Router - ) { } - - ngOnInit() { - - } - - navigate(link: string) { - this.router.navigate([link], { queryParams: this.parameters }); - } -} diff --git a/dmp-frontend/src/app/library/url-listing/url-listing.module.ts b/dmp-frontend/src/app/library/url-listing/url-listing.module.ts deleted file mode 100644 index 3ee5b0996..000000000 --- a/dmp-frontend/src/app/library/url-listing/url-listing.module.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormattingModule } from '@app/core/formatting.module'; -import { UrlListingComponent } from '@app/library/url-listing/url-listing.component'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [ - CommonUiModule, - FormattingModule - ], - declarations: [ - UrlListingComponent - ], - exports: [ - UrlListingComponent - ] -}) -export class UrlListingModule { - constructor() { } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts deleted file mode 100644 index 58e01114a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/default-value-editor-model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { DefaultValue } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; - -export class DefaultValueEditorModel extends BaseFormModel { - public type: string; - public value: string; - - fromModel(item: DefaultValue): DefaultValueEditorModel { - this.type = item.type; - this.value = item.value; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DefaultValueEditorModel.type')) }], - value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('DefaultValueEditorModel.value')) }] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts deleted file mode 100644 index 9eec7c2a7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-auth-field-data.model.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { UntypedFormGroup, Validators } from "@angular/forms"; -import { FieldDataEditorModel } from "./field-data-editor-model"; -import { AuthAutoCompleteData, AutoCompleteSingleData } from "@app/core/model/dataset-profile-definition/field-data/field-data"; - -export class AuthFieldEditorModel extends FieldDataEditorModel { - url: string; - method: string; - body: string; - path: string; - type: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - method: [{ value: this.method, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.method')) }], - url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.url')) },[Validators.required]], - body: [{ value: this.body, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.body')) }], - path: [{ value: this.path, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.path')) }, [Validators.required]], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('AuthFieldEditorModel.type')) }, [Validators.required]] - }); - - return formGroup; - } - - fromModel(item: AuthAutoCompleteData): AuthFieldEditorModel { - this.url = item.url; - this.method = item.method; - this.body = item.body; - this.path = item.path; - this.type = item.type; - return this; - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts deleted file mode 100644 index ecf09ebce..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { AutoCompleteFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; -import { AutoCompleteSingleDataEditorModel } from './auto-complete-single-data'; - -export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - - public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.Autocomplete; - public multiAutoComplete: boolean; - public autoCompleteSingleDataList: Array = new Array(); - //public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('AutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }); - - const autocompleteFormArray = new Array(); - if (this.autoCompleteSingleDataList) { - this.autoCompleteSingleDataList.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - autocompleteFormArray.push(form); - }); - } - - formGroup.addControl('autoCompleteSingleDataList', this.formBuilder.array(autocompleteFormArray)); - - return formGroup; - } - - fromModel(item: AutoCompleteFieldData): AutoCompleteFieldDataEditorModel { - this.type = item.type; - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - if (item.autoCompleteSingleDataList) { this.autoCompleteSingleDataList = item.autoCompleteSingleDataList.map(x => new AutoCompleteSingleDataEditorModel().fromModel(x)); } - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts deleted file mode 100644 index e84fd4e1d..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; -import { UntypedFormGroup, Validators } from '@angular/forms'; -import { AutoCompleteFieldData, AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data'; -//import { AuthFieldEditorModel } from './auto-complete-auth-field-data.model'; - -export class AutoCompleteSingleDataEditorModel extends FieldDataEditorModel { - - public url: string; - public optionsRoot: string; - - public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - public autoCompleteType: number; - public method: string; - public hasAuth: boolean; - //public auth: AuthFieldEditorModel = new AuthFieldEditorModel(); - //public multiAutoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.label')) }], - url: [{ value: this.url, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.url')) },[Validators.required]], - optionsRoot: [{ value: this.optionsRoot, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.optionsRoot')) }, [Validators.required]], - autoCompleteType: [{ value: this.autoCompleteType, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.autoCompleteType')) }], - hasAuth: [{ value: this.hasAuth, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.hasAuth')) }], - method: [{ value: this.method, disabled: (disabled && !skipDisable.includes('AutoCompleteSingleDataEditorModel.method')) }] - }); - formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable)); - //formGroup.addControl('auth', this.auth.buildForm(disabled, skipDisable)); - - return formGroup; - } - - fromModel(item: AutoCompleteSingleData): AutoCompleteSingleDataEditorModel { - this.url = item.url; - this.label = item.label; - this.optionsRoot = item.optionsRoot; - this.autoCompleteType = item.autocompleteType; - this.hasAuth = item.hasAuth; - this.method = item.method ? item.method : 'GET'; - this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions); - //this.auth = new AuthFieldEditorModel().fromModel(item.auth); - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts deleted file mode 100644 index ca0332c32..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/boolean-decision-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { BooleanDecisionFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class BooleanDecisionFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('BooleanDecisionFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: BooleanDecisionFieldData): BooleanDecisionFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts deleted file mode 100644 index 996ad10b3..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/check-box-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { CheckBoxFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class CheckBoxFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('CheckBoxFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: CheckBoxFieldData): CheckBoxFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts deleted file mode 100644 index c4f2d35e0..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/currency-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { CurrencyFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class CurrencyDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('CurrencyDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: CurrencyFieldData): CurrencyDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts deleted file mode 100644 index 45b23fcb2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DataRepositoriesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class DataRepositoriesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: DataRepositoriesFieldData): DataRepositoriesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts deleted file mode 100644 index 414526181..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DatasetIdentifierFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class DatasetIdentifierDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetIdentifierDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: DatasetIdentifierFieldData): DatasetIdentifierDataEditorModel { - this.label = item.label; - return this; - } -} 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 deleted file mode 100644 index 32f65bfea..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode.ts +++ /dev/null @@ -1,26 +0,0 @@ -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(); - - 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')) }], - }) - return formGroup; - } - - fromModel(item: DatasetsAutoCompleteFieldData): DatasetsAutoCompleteFieldDataEditorModel { - this.label = item.label; - this.type = item.type; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts deleted file mode 100644 index 7101a775a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/date-picker-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { DatePickerFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class DatePickerDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatePickerDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: DatePickerFieldData): DatePickerDataEditorModel { - this.label = item.label; - 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 deleted file mode 100644 index 24bf7d582..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model.ts +++ /dev/null @@ -1,27 +0,0 @@ -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 { DmpsAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; -import { UntypedFormGroup } from "@angular/forms"; - -export class DmpsAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Dmps; - public multiAutoComplete: boolean = false; - //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('DmpsAutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DmpsAutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('DmpsAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }) - return formGroup; - } - - fromModel(item: DmpsAutoCompleteFieldData): DmpsAutoCompleteFieldDataEditorModel { - this.label = item.label; - this.type = item.type; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts deleted file mode 100644 index 447c8bb90..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ExternalDatasetsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { ExternalDatasetTypeEnum } from '@app/core/common/enum/external-dataset-type-enum'; - -export class ExternalDatasetsDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - public type: ExternalDatasetTypeEnum; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.multiAutoComplete')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('ExternalDatasetsDataEditorModel.type')) }] - }); - return formGroup; - } - - fromModel(item: ExternalDatasetsFieldData): ExternalDatasetsDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - this.type = item.type; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts deleted file mode 100644 index 78f15c0d8..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-editor-model.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { BaseFormModel } from '../../../../../core/model/base-form-model'; - -export abstract class FieldDataEditorModel extends BaseFormModel { - - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - throw new Error('Build Form Is not not correctly overriden'); - } - - fromJSONObject(item: any): T { - throw new Error('From Json Object is not correctly overriden'); - } -} 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 deleted file mode 100644 index 991f4fc72..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { FieldDataOption } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class FieldDataOptionEditorModel extends FieldDataEditorModel { - public label: string; - public value: 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]], - }); - } - - fromModel(item: FieldDataOption): FieldDataOptionEditorModel { - if (item) { - this.label = item.label; - this.value = item.value; - } - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts deleted file mode 100644 index bf5c11038..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/free-text-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FreeTextFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class FreeTextFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('FreeTextFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: FreeTextFieldData): FreeTextFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts deleted file mode 100644 index 56427d988..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { LicensesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -export class LicensesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: LicensesFieldData): LicensesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts deleted file mode 100644 index 2efa6c160..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { OrganizationsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class OrganizationsDataEditorModel 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('OrganizationsDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('OrganizationsDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: OrganizationsFieldData): OrganizationsDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts deleted file mode 100644 index 233d18e1d..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { PublicationsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -export class PublicationsDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: PublicationsFieldData): PublicationsDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts deleted file mode 100644 index a7f8ba191..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/radio-box-field-data-editor-model.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { RadioBoxFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; - -export class RadioBoxFieldDataEditorModel extends FieldDataEditorModel { - - public options: Array = []; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RadioBoxFieldDataEditorModel.label')) }] - }); - const optionsFormArray = new Array(); - if (this.options) { - this.options.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - optionsFormArray.push(form); - }); - } - formGroup.addControl('options', this.formBuilder.array(optionsFormArray)); - return formGroup; - } - - fromModel(item: RadioBoxFieldData): RadioBoxFieldDataEditorModel { - if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); } - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts deleted file mode 100644 index 6f996564e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { RegistriesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class RegistriesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RegistriesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('RegistriesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: RegistriesFieldData): RegistriesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts deleted file mode 100644 index c4101bdbd..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model.ts +++ /dev/null @@ -1,31 +0,0 @@ -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 { UntypedFormGroup } from "@angular/forms"; -import { ResearchersAutoCompleteFieldData } from "../../../../../core/model/dataset-profile-definition/field-data/field-data"; - -export class ResearchersAutoCompleteFieldDataEditorModel extends FieldDataEditorModel { - - public type: DatasetProfileInternalDmpEntitiesType = DatasetProfileInternalDmpEntitiesType.Researchers; - public multiAutoComplete: boolean = false; - //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('ResearchersAutoCompleteFieldDataEditorModel.label')) }], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.type')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ResearchersAutoCompleteFieldDataEditorModel.multiAutoComplete')) }] - }) - //formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm(disabled, skipDisable)); - - return formGroup; - } - - fromModel(item: ResearchersAutoCompleteFieldData): ResearchersAutoCompleteFieldDataEditorModel { - this.label = item.label; - this.type = item.type; - this.multiAutoComplete = item.multiAutoComplete; - // this.autoCompleteOptions = new FieldDataOptionEditorModel().fromModel(item.autoCompleteOptions); - return this; - } -} 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 deleted file mode 100644 index 27f9abc12..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ResearchersFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -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')) }], - 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/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts deleted file mode 100644 index cbc8e5ffc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/rich-text-area-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { RichTextAreaFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class RichTextAreaFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('RichTextAreaFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: RichTextAreaFieldData): RichTextAreaFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts deleted file mode 100644 index 4c738bbbc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ServicesFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class ServicesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: ServicesFieldData): ServicesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts deleted file mode 100644 index b5c20ff22..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { TagsFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class TagsDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('TagsDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: TagsFieldData): TagsDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts deleted file mode 100644 index 0f7f0c4d3..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import {TaxonomiesFieldData} from "@app/core/model/dataset-profile-definition/field-data/field-data"; - -export class TaxonomiesDataEditorModel extends FieldDataEditorModel { - public label: string; - public multiAutoComplete: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.label')) }], - multiAutoComplete: [{ value: this.multiAutoComplete, disabled: (disabled && !skipDisable.includes('ServicesDataEditorModel.multiAutoComplete')) }] - }); - return formGroup; - } - - fromModel(item: TaxonomiesFieldData): TaxonomiesDataEditorModel { - this.label = item.label; - this.multiAutoComplete = item.multiAutoComplete; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts deleted file mode 100644 index 7c9d9f34b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/text-area-field-data-editor-model.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { TextAreaFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; - -export class TextAreaFieldDataEditorModel extends FieldDataEditorModel { - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('TextAreaFieldDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: TextAreaFieldData): TextAreaFieldDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts deleted file mode 100644 index 950f7e364..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/upload-field-data-editor-model.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { - FieldDataOption, - UploadFieldData -} from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import {FieldDataOptionEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model"; - -export class UploadFieldDataEditorModel extends FieldDataEditorModel { - public types: Array = []; - public maxFileSizeInMB: number; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('UploadFieldDataEditorModel.label')) }], - maxFileSizeInMB: [{ value: this.maxFileSizeInMB, disabled: (disabled && !skipDisable.includes('UploadFieldDataEditorModel.maxFileSizeInMB')) }], - // types: [{ value: this.types, disabled: (disabled && !skipDisable.includes('UploadFieldDataEditorModel.types')) }] - }); - const optionsFormArray = new Array(); - if (this.types) { - this.types.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - optionsFormArray.push(form); - }); - } - formGroup.addControl('types', this.formBuilder.array(optionsFormArray)); - if(disabled && !skipDisable.includes('UploadFieldDataEditorModel.types')) { - formGroup.disable(); - } - return formGroup; } - - fromModel(item: UploadFieldData): UploadFieldDataEditorModel { - if (item.types) { this.types = item.types.map(x => new FieldDataOptionEditorModel().fromModel(x)); } - this.label = item.label; - this.maxFileSizeInMB = item.maxFileSizeInMB; - // this.types = item.types; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts deleted file mode 100644 index e67cd93dc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/validation-data-editor-models.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { ValidationFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; - -export class ValidationDataEditorModel extends FieldDataEditorModel { - public label: string; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('ValidationDataEditorModel.label')) }] - }); - return formGroup; - } - - fromModel(item: ValidationFieldData): ValidationDataEditorModel { - this.label = item.label; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts deleted file mode 100644 index 82e2497ba..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { WordListFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data'; -import { FieldDataEditorModel } from './field-data-editor-model'; -import { FieldDataOptionEditorModel } from './field-data-option-editor-model'; - -export class WordListFieldDataEditorModel extends FieldDataEditorModel { - public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.WordList; - public options: Array; - public multipleList: boolean; - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.type')) }], - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.label')) }], - multiList: [{ value: this.multipleList, disabled: (disabled && !skipDisable.includes('WordListFieldDataEditorModel.multipleList'))}] - }); - const optionsFormArray = new Array(); - if (this.options) { - this.options.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - optionsFormArray.push(form); - }); - } - formGroup.addControl('options', this.formBuilder.array(optionsFormArray)); - - return formGroup; - } - - fromModel(item: WordListFieldData): WordListFieldDataEditorModel { - this.type = item.type; - if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); } - this.label = item.label; - this.multipleList = item.multiList; - return this; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts deleted file mode 100644 index b4a09b98f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-editor-model.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { FormArray, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { ValidationType } from '../../../../core/common/enum/validation-type'; -import { Field } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { DefaultValueEditorModel } from './default-value-editor-model'; -import { AutoCompleteFieldDataEditorModel } from './field-data/auto-complete-field-data-editor-model'; -import { BooleanDecisionFieldDataEditorModel } from './field-data/boolean-decision-field-data-editor-model'; -import { CheckBoxFieldDataEditorModel } from './field-data/check-box-field-data-editor-model'; -import { FieldDataEditorModel } from './field-data/field-data-editor-model'; -import { FreeTextFieldDataEditorModel } from './field-data/free-text-field-data-editor-model'; -import { RadioBoxFieldDataEditorModel } from './field-data/radio-box-field-data-editor-model'; -import { TextAreaFieldDataEditorModel } from './field-data/text-area-field-data-editor-model'; -import { RichTextAreaFieldDataEditorModel } from './field-data/rich-text-area-field-data-editor-model'; -import {UploadFieldDataEditorModel} from "./field-data/upload-field-data-editor-model"; -import { WordListFieldDataEditorModel } from './field-data/word-list-field-data-editor-model'; -import { ViewStyleEditorModel } from './view-style-editor-model'; -import { VisibilityEditorModel } from './visibility-editor-model'; -import { DatasetProfileEditorDatePickerFieldComponent } from '../editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component'; -import { DatePickerDataEditorModel } from './field-data/date-picker-data-editor-models'; -import { ResearchersAutoCompleteFieldDataEditorModel } from './field-data/researchers-auto-complete-field-data-editor-model'; -import { DatasetsAutoCompleteFieldDataEditorModel } from './field-data/datasets-autocomplete-field-data-editor-mode'; -import { DmpsAutoCompleteFieldDataEditorModel } from './field-data/dmps-autocomplete-field-data-editor-model'; -import { ExternalDatasetsDataEditorModel } from './field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from './field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from './field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from './field-data/services-data-editor-models'; -import { TagsDataEditorModel } from './field-data/tags-data-editor-models'; -import { ResearchersDataEditorModel } from './field-data/researchers-data-editor-models'; -import { OrganizationsDataEditorModel } from './field-data/organizations-data-editor-models'; -import { DatasetIdentifierDataEditorModel } from './field-data/dataset-identifier-data-editor-models'; -import { CurrencyDataEditorModel } from './field-data/currency-data-editor-models'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { EditorCustomValidators } from '../editor/custom-validators/editor-custom-validators'; -import { ValidationDataEditorModel } from './field-data/validation-data-editor-models'; -import {PublicationsDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models"; -import {LicensesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models"; -import {TaxonomiesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models"; - -export class FieldEditorModel extends BaseFormModel { - - public id: string; - // public title: string; - public defaultValue: DefaultValueEditorModel = new DefaultValueEditorModel(); - public viewStyle: ViewStyleEditorModel = new ViewStyleEditorModel(); - public page: number = null; - public ordinal: number = null; - public visible: VisibilityEditorModel = new VisibilityEditorModel(); - public data: FieldDataEditorModel; - public validations: ValidationType[] = []; - public schematics: string[]; - public export: boolean = true; - - fromModel(item: Field): FieldEditorModel { - this.id = item.id; - if (item.defaultValue) { this.defaultValue = new DefaultValueEditorModel().fromModel(item.defaultValue); } - this.page = item.page; - this.ordinal = item.ordinal; - this.validations = item.validations; - this.viewStyle = new ViewStyleEditorModel().fromModel(item.viewStyle); - this.visible = new VisibilityEditorModel().fromModel(item.visible); - this.schematics = item.schematics; - this.export = item.export; - - if (item.data) { - if (this.viewStyle.renderStyle === 'combobox') { - if (item.data.type === 'autocomplete') { this.data = new AutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (item.data.type === 'wordlist') { this.data = new WordListFieldDataEditorModel().fromModel(item.data); } - } else if (this.viewStyle.renderStyle === 'internalDmpEntities') { - if (item.data.type === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (item.data.type === 'datasets') { this.data = new DatasetsAutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (item.data.type === 'dmps') { this.data = new DmpsAutoCompleteFieldDataEditorModel().fromModel(item.data); } - } else { - if (this.viewStyle.renderStyle === 'radiobox') { this.data = new RadioBoxFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'checkBox') { this.data = new CheckBoxFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'textarea') { this.data = new TextAreaFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'richTextarea') { this.data = new RichTextAreaFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'upload') { this.data = new UploadFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'freetext') { this.data = new FreeTextFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'booleanDecision') { this.data = new BooleanDecisionFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'datePicker') { this.data = new DatePickerDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'externalDatasets') { this.data = new ExternalDatasetsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'dataRepositories') { this.data = new DataRepositoriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'pubRepositories') { this.data = new DataRepositoriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'journalRepositories') { this.data = new DataRepositoriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'taxonomies') { this.data = new TaxonomiesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'licenses') { this.data = new LicensesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'publications') { this.data = new PublicationsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'registries') { this.data = new RegistriesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'services') { this.data = new ServicesDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'tags') { this.data = new TagsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'researchers') { this.data = new ResearchersAutoCompleteFieldDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'organizations') { this.data = new OrganizationsDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'datasetIdentifier') { this.data = new DatasetIdentifierDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'currency') { this.data = new CurrencyDataEditorModel().fromModel(item.data); } - if (this.viewStyle.renderStyle === 'validation') { this.data = new ValidationDataEditorModel().fromModel(item.data); } - } - } - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], - // title: [this.title], - page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('FieldEditorModel.page')) }], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldEditorModel.ordinal')) }], - validations: [{ value: this.validations, disabled: (disabled && !skipDisable.includes('FieldEditorModel.validations')) }], - schematics: [{ value: this.schematics, disabled: (disabled && !skipDisable.includes('FieldEditorModel.schematics')) }], - export: [{value: this.export, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.export'))}] - }); - - formGroup.addControl('defaultValue', this.defaultValue.buildForm(disabled, skipDisable)); - formGroup.addControl('viewStyle', this.viewStyle.buildForm(disabled, skipDisable)); - formGroup.addControl('visible', this.visible.buildForm(disabled, skipDisable)); - if (this.data) { formGroup.addControl('data', this.data.buildForm(disabled, skipDisable)); } - else { formGroup.addControl('data', new WordListFieldDataEditorModel().buildForm(disabled, skipDisable)); } - - - // //append validators - - this._appendCustomValidators(formGroup); - - - // //setting up listeners - // formGroup.get('viewStyle').valueChanges.subscribe(changes=>{ - // // const viewStyleChanges:{cssClass:string, renderStyle: string} = changes; - - // this._removeCustomValidators(formGroup); - // this._appendCustomValidators(formGroup); - - // }) - - return formGroup; - } - - - private _appendCustomValidators(formGroup: UntypedFormGroup){ - const renderStyleValue = formGroup.get('viewStyle').get('renderStyle').value; - if(renderStyleValue === 'checkBox'){ - formGroup.get('defaultValue').get('value').setValidators(Validators.required); - formGroup.get('defaultValue').get('value').updateValueAndValidity(); - }else if(renderStyleValue === 'combobox'){ - try{ - const comboType = formGroup.get('data').get('type').value; - if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - }else if(comboType === DatasetProfileComboBoxType.WordList){ - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - } - }catch(e){ - console.error('Error setting validators.'); - console.error(e); - } - }else if(renderStyleValue === 'radiobox'){ - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - }else if(renderStyleValue === 'upload'){ - formGroup.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('types')); - formGroup.get('data').get('maxFileSizeInMB').setValidators(Validators.required); - } - - formGroup.get('data').updateValueAndValidity(); - } - - // private _removeCustomValidators(formGroup:FormGroup){ - // const renderStyleValue = formGroup.get('viewStyle').get('renderStyle').value; - // if(renderStyleValue != 'checkBox'){ - // formGroup.get('defaultValue').get('value').clearValidators(); - // }else if(renderStyleValue === 'combobox'){ - // formGroup.get('data').clearValidators(); - // } - // } - // private _buildData(formGroup: FormGroup){ - - // } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts deleted file mode 100644 index 56884bc71..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts +++ /dev/null @@ -1,54 +0,0 @@ - -import { UntypedFormGroup, Validators } from '@angular/forms'; -import { FieldSet } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { FieldEditorModel } from './field-editor-model'; -import { MultiplicityEditorModel } from './multiplicity-editor-model'; - -export class FieldSetEditorModel extends BaseFormModel { - - public fields: Array = new Array(); - public id: string; - public ordinal: number; - public multiplicity: MultiplicityEditorModel = new MultiplicityEditorModel(); - public title: string; - public description: string; - public extendedDescription: string; - public additionalInformation: string; - public hasCommentField: boolean; - - fromModel(item: FieldSet): FieldSetEditorModel { - - if (item.fields) { this.fields = item.fields.map(x => new FieldEditorModel().fromModel(x)); } - if (item.multiplicity) this.multiplicity = new MultiplicityEditorModel().fromModel(item.multiplicity); - this.id = item.id; - this.ordinal = item.ordinal; - this.title = item.title; - this.description = item.description; - this.extendedDescription = item.extendedDescription; - this.additionalInformation = item.additionalInformation; - this.hasCommentField = item.hasCommentField; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.ordinal')) }], - title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.title')) }, [Validators.required]], - description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.description')) }], - extendedDescription: [{ value: this.extendedDescription, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.extendedDescription')) }], - additionalInformation: [{ value: this.additionalInformation, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.additionalInformation')) }], - hasCommentField: [{ value: this.hasCommentField, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.hasCommentField')) }] - }); - const fieldsFormArray = new Array(); - this.fields.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - fieldsFormArray.push(form); - }); - formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); - formGroup.addControl('multiplicity', this.multiplicity.buildForm(disabled, skipDisable)); - - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts deleted file mode 100644 index 6efbd8bf1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/multiplicity-editor-model.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {UntypedFormGroup} from '@angular/forms'; -import {Multiplicity} from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import {BaseFormModel} from '../../../../core/model/base-form-model'; - -export class MultiplicityEditorModel extends BaseFormModel { - public min: number; - public max: number; - public placeholder: string; - public tableView: boolean; - - fromModel(item: Multiplicity): MultiplicityEditorModel { - this.min = item.min; - this.max = item.max; - this.placeholder = item.placeholder; - this.tableView = item.tableView; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - return this.formBuilder.group({ - min: [{value: this.min, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.min'))}], - max: [{value: this.max, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.max'))}], - placeholder: [{ - value: this.placeholder, - disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.placeholder')) - }], - tableView: [{value: this.tableView, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.tableView'))}] - }); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts deleted file mode 100644 index 1fc8fc536..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/page-editor-model.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { UntypedFormGroup, Validators } from '@angular/forms'; -import { Page } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '@app/core/model/base-form-model'; -import { Guid } from '@common/types/guid'; - -export class PageEditorModel extends BaseFormModel { - public title: string; - public id: string; - public ordinal: number; - - constructor(ordinal?: number) { - super(); - if (isNaN(ordinal)) { this.ordinal = 0; } else { this.ordinal = ordinal; } - this.id = Guid.create().toString(); - } - - fromModel(item: Page): PageEditorModel { - this.title = item.title; - this.id = item.id; - this.ordinal = item.ordinal; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('PageEditorModel.title')) }, [Validators.required]], - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('PageEditorModel.id')) }, [Validators.required]], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('PageEditorModel.ordinal')) }] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts deleted file mode 100644 index 9f3cdc5a6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { UntypedFormGroup, Validators } from "@angular/forms"; -import { Rule } from "../../../../core/model/admin/dataset-profile/dataset-profile"; -import { BaseFormModel } from "../../../../core/model/base-form-model"; - -export class RuleEditorModel extends BaseFormModel { - public target: string; - public value: string; - public ruleType: string; - public ruleStyle: string; - public valueType: string; - - fromModel(item: Rule): RuleEditorModel { - this.target = item.target; - this.value = item.value; - this.ruleType = item.ruleType; - this.ruleStyle = item.ruleStyle; - this.valueType = item.valueType; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - // sourceField: [this.sourceField], - target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }, [Validators.required]], - ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }], - value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }, [Validators.required]], - ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }], - valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts deleted file mode 100644 index 42e5b286f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/section-editor-model.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { UntypedFormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { Section } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { EditorCustomValidators } from '../editor/custom-validators/editor-custom-validators'; -import { FieldSetEditorModel } from './field-set-editor-model'; - -export class SectionEditorModel extends BaseFormModel { - public sections: Array = new Array(); - public defaultVisibility: boolean; - public page: string; - public id: string; - public title: string; - public description: string; - public ordinal: number; - public fieldSets: Array = new Array(); - - fromModel(item: Section): SectionEditorModel { - if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } - this.page = item.page; - this.defaultVisibility = item.defaultVisibility; - this.id = item.id; - this.title = item.title; - this.description = item.description; - this.ordinal = item.ordinal; - if (item.fieldSets) { this.fieldSets = item.fieldSets.map(x => new FieldSetEditorModel().fromModel(x)); } - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({ - id: [{ value: this.id, disabled: (disabled && !skipDisable.includes('SectionEditorModel.id')) }, [Validators.required, Validators.pattern('^[^<_>]+$')]], - page: [{ value: this.page, disabled: (disabled && !skipDisable.includes('SectionEditorModel.page')) }, [Validators.required]], - title: [{ value: this.title, disabled: (disabled && !skipDisable.includes('SectionEditorModel.title')) } , [Validators.required]], - description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('SectionEditorModel.description')) }], - ordinal: [{ value: this.ordinal, disabled: (disabled && !skipDisable.includes('SectionEditorModel.ordinal')) }, [Validators.required]], - defaultVisibility: [{ value: this.defaultVisibility, disabled: (disabled && !skipDisable.includes('SectionEditorModel.defaultVisibility')) }] - }); - const sectionsFormArray = new Array(); - if (this.sections) { - this.sections.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - sectionsFormArray.push(form); - }); - } - const compositeFieldsFormArray = new Array(); - if (this.fieldSets) { - this.fieldSets.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - compositeFieldsFormArray.push(form); - }); - } - formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - formGroup.addControl('fieldSets', this.formBuilder.array(compositeFieldsFormArray)); - - if (!formGroup.controls['defaultVisibility'].value) { formGroup.controls['defaultVisibility'].setValue(true); } - - formGroup.setValidators(EditorCustomValidators.sectionHasAtLeastOneChildOf('fieldSets','sections')); - formGroup.updateValueAndValidity(); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts deleted file mode 100644 index 19c8853b3..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/view-style-editor-model.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UntypedFormGroup, Validators } from "@angular/forms"; -import { ViewStyle } from "../../../../core/model/admin/dataset-profile/dataset-profile"; -import { BaseFormModel } from "../../../../core/model/base-form-model"; - -export class ViewStyleEditorModel extends BaseFormModel { - public cssClass: string; - public renderStyle: string; - - fromModel(item: ViewStyle): ViewStyleEditorModel { - this.cssClass = item.cssClass; - this.renderStyle = item.renderStyle; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - cssClass: [{ value: this.cssClass, disabled: (disabled && !skipDisable.includes('ViewStyleEditorModel.cssClass')) }], - renderStyle: [{ value: this.renderStyle, disabled: (disabled && !skipDisable.includes('ViewStyleEditorModel.renderStyle')) }, Validators.required] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts deleted file mode 100644 index d3b77e405..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/visibility-editor-model.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { UntypedFormGroup } from '@angular/forms'; -import { Visibility } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { RuleEditorModel } from './rule-editor-model'; - -export class VisibilityEditorModel extends BaseFormModel { - - public rules: Array = new Array(); - public style: string; - - fromModel(item: Visibility): VisibilityEditorModel { - if (item.rules) { this.rules = item.rules.map(x => new RuleEditorModel().fromModel(x)); } - this.style = item.style; - - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - style: [{ value: this.style, disabled: (disabled && !skipDisable.includes('VisibilityEditorModel.style')) }] - }); - - const rulesFormArray = new Array(); - if (this.rules) { - this.rules.forEach(rule => { - const form: UntypedFormGroup = rule.buildForm(disabled, skipDisable); - rulesFormArray.push(form); - }); - } - - formGroup.addControl('rules', this.formBuilder.array(rulesFormArray)); - - return formGroup; - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts deleted file mode 100644 index 66dcb4cc6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.module.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { DragDropModule } from '@angular/cdk/drag-drop'; -import { NgModule } from '@angular/core'; -//matrial -import { MatBadgeModule } from '@angular/material/badge'; -import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { DatasetProfileRoutingModule } from '@app/ui/admin/dataset-profile/dataset-profile.routing'; -import { DatasetProfileEditorCompositeFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component'; -import { DatasetProfileEditorDefaultValueComponent } from '@app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component'; -import { DatasetProfileEditorAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component'; -import { DatasetProfileEditorBooleanDecisionFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component'; -import { DatasetProfileEditorCheckboxFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component'; -import { DatasetProfileEditorComboBoxFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component'; -import { DatasetProfileEditorDatasetsAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component'; -import { DatasetProfileEditorDatePickerFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component'; -import { DatasetProfileEditorDmpsAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component'; -import { DatasetProfileEditorFreeTextFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component'; -import { DatasetProfileEditorInternalDmpEntitiesFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component'; -import { DatasetProfileEditorRadioBoxFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component'; -import { DatasetProfileEditorResearchersAutoCompleteFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component'; -import { DatasetProfileEditorTextAreaFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component'; -import { DatasetProfileEditorWordListFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component'; -import { DatasetProfileEditorFieldComponent } from '@app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component'; -import { DatasetProfileEditorPageComponent } from '@app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component'; -import { DatasetProfileEditorRuleComponent } from '@app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component'; -import { DatasetProfileEditorSectionComponent } from '@app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component'; -import { DatasetProfileEditorComponent } from '@app/ui/admin/dataset-profile/editor/dataset-profile-editor.component'; -import { DatasetProfileCriteriaComponent } from '@app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component'; -import { DialogConfirmationUploadDatasetProfiles } from '@app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; -import { DatasetProfileListingComponent } from '@app/ui/admin/dataset-profile/listing/dataset-profile-listing.component'; -import { DatasetModule } from '@app/ui/dataset/dataset.module'; -import { FormProgressIndicationModule } from '@app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; -import { DragulaModule } from 'ng2-dragula'; -import { NgxDropzoneModule } from 'ngx-dropzone'; -import { DatasetProfileEditorCurrencyFieldComponent } from './editor/components/field-type/currency/dataset-profile-editor-currency-field.component'; -import { DatasetProfileEditorDataRepositoriesFieldComponent } from './editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component'; -import { DatasetProfileEditorDatasetIdentifierFieldComponent } from './editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component'; -import { DatasetProfileEditorExternalDatasetsFieldComponent } from './editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component'; -import { DatasetProfileEditorOrganizationsFieldComponent } from './editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component'; -import { DatasetProfileEditorRegistriesFieldComponent } from './editor/components/field-type/registries/dataset-profile-editor-registries-field.component'; -import { DatasetProfileEditorResearchersFieldComponent } from './editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component'; -import { DatasetProfileEditorServicesFieldComponent } from './editor/components/field-type/services/dataset-profile-editor-services-field.component'; -import { DatasetProfileEditorTagsFieldComponent } from './editor/components/field-type/tags/dataset-profile-editor-tags-field.component'; -import { DatasetProfileEditorValidatorFieldComponent } from './editor/components/field-type/validator/dataset-profile-editor-validator-field.component'; -import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component'; -import { DatasetProfileEditorSectionFieldSetComponent } from './editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component'; -import { ParseStatus } from './listing/pipe/parse-status.pipe'; -import { DatasetProfileTableOfContents } from './table-of-contents/table-of-contents'; -import { DatasetProfileTableOfContentsInternalSection } from './table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section'; -import {TransitionGroupModule} from "@app/ui/transition-group/transition-group.module"; -import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; -import {DatasetProfileEditorRichTextAreaFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component"; -import {DatasetProfileEditorTaxonomiesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component"; -import {DatasetProfileEditorLicensesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component"; -import {DatasetProfileEditorPublicationsFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component"; -import {DatasetProfileEditorJournalRepositoriesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component"; -import {DatasetProfileEditorPubRepositoriesFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component"; -import {DatasetProfileEditorUploadFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component"; -// import { TableEditorModule } from "@app/library/table-editor/table-editor.module"; -// import {DatasetProfileEditorTableFieldComponent} from "@app/ui/admin/dataset-profile/editor/components/field-type/table/dataset-profile-editor-table-field.component"; - - - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - FormattingModule, - DatasetProfileRoutingModule, - ConfirmationDialogModule, - NgxDropzoneModule, - FormProgressIndicationModule, - DatasetModule, - AngularStickyThingsModule, - DragDropModule, - MatBadgeModule, - DragulaModule, - AutoCompleteModule, - TransitionGroupModule, - RichTextEditorModule, - // TableEditorModule - ], - declarations: [ - DatasetProfileListingComponent, - DatasetProfileCriteriaComponent, - DatasetProfileEditorComponent, - DatasetProfileEditorSectionComponent, - DatasetProfileEditorCompositeFieldComponent, - DatasetProfileEditorFieldComponent, - DatasetProfileEditorPageComponent, - DatasetProfileEditorRuleComponent, - DatasetProfileEditorAutoCompleteFieldComponent, - DatasetProfileEditorBooleanDecisionFieldComponent, - DatasetProfileEditorCheckboxFieldComponent, - DatasetProfileEditorComboBoxFieldComponent, - DatasetProfileEditorFreeTextFieldComponent, - DatasetProfileEditorRadioBoxFieldComponent, - DatasetProfileEditorTextAreaFieldComponent, - DatasetProfileEditorRichTextAreaFieldComponent, - DatasetProfileEditorUploadFieldComponent, - // DatasetProfileEditorTableFieldComponent, - DatasetProfileEditorDatePickerFieldComponent, - DatasetProfileEditorWordListFieldComponent, - DatasetProfileEditorDefaultValueComponent, - DialogConfirmationUploadDatasetProfiles, - DatasetProfileEditorInternalDmpEntitiesFieldComponent, - DatasetProfileEditorResearchersAutoCompleteFieldComponent, - DatasetProfileEditorDatasetsAutoCompleteFieldComponent, - DatasetProfileEditorDmpsAutoCompleteFieldComponent, - ParseStatus, - DatasetProfileEditorExternalDatasetsFieldComponent, - DatasetProfileEditorDataRepositoriesFieldComponent, - DatasetProfileEditorPubRepositoriesFieldComponent, - DatasetProfileEditorJournalRepositoriesFieldComponent, - DatasetProfileEditorTaxonomiesFieldComponent, - DatasetProfileEditorLicensesFieldComponent, - DatasetProfileEditorPublicationsFieldComponent, - DatasetProfileEditorRegistriesFieldComponent, - DatasetProfileEditorServicesFieldComponent, - DatasetProfileEditorTagsFieldComponent, - DatasetProfileEditorResearchersFieldComponent, - DatasetProfileEditorOrganizationsFieldComponent, - DatasetProfileEditorDatasetIdentifierFieldComponent, - DatasetProfileEditorCurrencyFieldComponent, - DatasetProfileEditorValidatorFieldComponent, - DatasetProfileTableOfContents, - DatasetProfileTableOfContentsInternalSection, - DatasetProfileEditorSectionFieldSetComponent, - FinalPreviewComponent - ] -}) -export class DatasetProfileModule { } - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts deleted file mode 100644 index 9d8f971a7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { DatasetProfileEditorComponent } from './editor/dataset-profile-editor.component'; -import { DatasetProfileListingComponent } from './listing/dataset-profile-listing.component'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; -import { AppRole } from '@app/core/common/enum/app-role'; -import { SpecialAuthGuard } from '@app/core/special-auth-guard.service'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; - -const routes: Routes = [ - { - path: 'new', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-NEW', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: ':id', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-EDIT', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'clone/:cloneid', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-CLONE', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'newversion/:newversionid', - component: DatasetProfileEditorComponent, - data: { - title: 'GENERAL.TITLES.DATASET-PROFILES-NEW-VERSION', - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard], - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'versions/:groupId', - component: DatasetProfileListingComponent, - data: { - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard] - }, - { - path: '', - component: DatasetProfileListingComponent, - data: { - authContext: { - permissions: [AppRole.Admin, AppRole.DescriptionTemplateEditor] - } - }, - canActivate: [SpecialAuthGuard] - }, -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class DatasetProfileRoutingModule { } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts deleted file mode 100644 index 5b4cd484a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { animate, keyframes, state, style, transition, trigger } from "@angular/animations"; - -export const STEPPER_ANIMATIONS = [ - trigger('previous_btn',[ - transition(':enter',[ - style({'transform': 'translateX(100%)', 'z-index':'9999', 'opacity':0.4}), - animate('600ms ease-out', style({ - 'transform': 'translateX(0)', - 'opacity':1 - })) - ]), - transition(':leave',[ - style({ - 'transform': 'translateX(0)', - 'opacity':'1', - 'z-index':'9999' - }), - animate('800ms ease-out', keyframes([ - style({'transform': 'translateX(120%)', offset:0.8}), - style({'opacity': '0.2', offset:0.96}) - ])) - ]) - ]), - trigger('next_btn', [ - transition(':leave',[ - style({opacity:1, position:'absolute', 'z-index':'9999'}), - animate('700ms ease-out', keyframes( [ - style({ transform:'translateX(-100%)', offset:0.6}), - style({ opacity:'0.2', offset:0.87}) - ])) - ]), - transition(':enter',[ - style({opacity:0.3, 'z-index':'9999', transform:'translateX(-100%)'}), - animate('600ms ease-out', style({ opacity:'1', transform:'translateX(0)' })) - ]) - ]), - trigger('finalize_btn',[ - transition(':enter',[ - style({opacity:0.3}), - animate('400ms ease-in', style({opacity:1})) - ]), - transition(':leave',[ - style({opacity:1, position:'absolute'}), - animate('600ms ease-in', style({opacity:0.3})) - ]) - ]) -]; -export const GENERAL_ANIMATIONS = [ - trigger('enterIn',[ - transition(':enter',[ - style({ - transform:'scale(0)', - 'transform-origin':'50% 0', - opacity:0 - }), - animate('800ms ease', style({transform:'scale(1)', opacity:1})) - ]) - ]), - trigger('fadeElement',[ - state('updated',style({opacity:0})), - transition("*=>updated", - animate('2s 1s ease-out')) - ]), - trigger('add-new-user-field', [ - state('untriggered', style({ - transform:'translateX(120%)' - })), - state('triggered', style({ - transform:'translateX(0)' - })), - transition('untriggered => triggered', animate('400ms ease')), - transition('triggered => untriggered', animate('400ms 100ms ease')) - ]), - trigger('scroll-on-top-btn',[ - transition(":enter", [style({opacity:0, transform:'scale(0)'}), animate('400ms ease', style({'opacity':1, transform:'scale(1)'}))]), - transition(":leave", [style({opacity:1,transform:'scale(1)'}), animate('400ms ease', style({'opacity':0, transform:'scale(0)'}))]) - ]), - trigger('action-btn',[ - transition(":enter", [style({opacity:0, transform:'scale(0)'}), animate('400ms ease', style({'opacity':1, transform:'scale(1)'}))]), - transition(":leave", [style({opacity:1,transform:'scale(1)'}), animate('400ms ease', style({'opacity':0, transform:'scale(0)'}))]) - ]), - trigger('fade-in',[ - transition(":enter", [style({opacity:0}), animate('1000ms 800ms ease', style({'opacity':1}))]), - ]), - trigger('fade-in-fast',[ - transition(":enter", [style({opacity:0}), animate('800ms 100ms ease', style({'opacity':1}))]), - ]), - - -] \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html deleted file mode 100644 index ec0d23910..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html +++ /dev/null @@ -1,463 +0,0 @@ - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - -
-
-
-
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}}
- - -
-
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXTENDED-DESCRIPTION' | translate}}
- - -
-
- - - -
- -
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
- - - -
-
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}} - -
-
- - - -
- - -
-
- - - - - - - -
-
    -
  • - keyboard_arrow_up -
  • -
  • - keyboard_arrow_down -
  • -
-
-
-
-
- -
- - - -
-
- {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.PREVIEW' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.STATUS.PREVIEW-UPDATED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.STATUS.CALCULATING-PREVIEW' | translate}} - - -
-
-
- - -
-
- -
- - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.NOT-INITIALIZED' | translate}} - -
- -
-
-
-
-
- - - -
-
-
    - - - - -
  • - - - 'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.ADD-INPUT' | translate - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.ADD-INPUT' | translate}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • - - - -
  • - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.COMMENT-FIELD' | translate}} -
  • -
  • - - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELDSET.MULTIPLICITY' | translate}} - -
  • -
  • - - more_vert - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXTENDED-DESCRIPTION' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.ADDITIONAL-INFORMATION' | translate}} - -
  • -
-
-
-
- - -
- - - - - - - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss deleted file mode 100644 index 121ec9530..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.scss +++ /dev/null @@ -1,146 +0,0 @@ -.full-width{ - width: 100%; -} - -.deleteBtn{ - margin-right:0.7em; -} - -.titleStile{ - font-weight: bold; -} - -//REFACTOR SECTION - - -//Palete - -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; - -.actions-list{ - border-radius: 7px; - box-shadow: 0 1px 0.8em $blue-color; - padding: 1em 0em; - font-size: small; -} - -.field-container{ - box-shadow: 0px 1px 2px rgb(173, 173, 173) ; - padding: 3em; - border-radius: .3em; - // border-left: 0.3em solid yellow; - padding-bottom: 2em; - margin-bottom: 2em; - -} -.field-container-active{ - box-shadow: 0px 1px 2px rgb(173, 173, 173) ; - padding: 3em; - border-radius: .3em; - border-left: 0.3em solid $blue-color; - padding-bottom: 2em; - margin-bottom: 2em; - -} -.field-id-container{ - background-color: $blue-color-light; - position: absolute; - right: 0; - top: 0; - padding: .6em 1.2em; - overflow: visible; - .field-id-container-icon{ - position: absolute; - top: -50%; - - } -} - -.main-content-page{ - padding: 0em 1.5em; -} - -.fielset-header{ - font-size: 1.5em; - font-weight: bold; - - // .numbering{ - // padding: 0.5em 0em; - // } -} - -.fieldset-actions-list{ - margin: 0; - cursor: pointer; -} - -// ::ng-deep .main-content-page .fieldset-header .field-title .mat-form-field-infix{ -// border-top: 0px; -// } - - -.numbering-label .mat-input-element:disabled{ - color: #212121; -} - -:host ::ng-deep .fieldset-checkbox-action-dataset-profile-editor -{ - .mat-checkbox-label{ - font-size: 0.8em; - color: #212121; - transform: translateY(3px); - } - .mat-checkbox-frame{ - border: 1px solid $blue-color ; - } -} - -.fieldset-new-input-action { - font-size: 0.8em; - font-weight: 400; - color: #212121; - display: inline-block; - transform: translateY(1px); -} -.inputMenuTrigger { - margin-bottom: 0.3rem; - display: inline-block; -} - -.previewer{ - background-color: #129d9811; - padding: 2em; - border: 1px solid #70707015; - border-radius: 4px; -} - -.input_icon{ - width: 14px; - margin-right: 0.5em; - // display: flex; - // align-items: center; -} - -::ng-deep .mat-menu-panel{ - max-height: 32em; -} -:host ::ng-deep .fielset-header .mat-form-field-wrapper{ - padding-bottom: 0px; -} - -.previewer-text{ - font-weight: bold; - font-style: italic; -} - -.field-input { - position: relative; -} - -.field-input .arrows { - position: absolute; - top: 0; - left: 50%; - transform: translateX(-50%); -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts deleted file mode 100644 index 7e84e85dc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts +++ /dev/null @@ -1,1088 +0,0 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatCheckboxChange } from '@angular/material/checkbox'; -import { MatDialog } from '@angular/material/dialog'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { ValidationType } from '@app/core/common/enum/validation-type'; -import { Field, FieldSet } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { CompositeField } from '@app/core/model/dataset-profile-definition/composite-field'; -import { Field as FieldDefinition } from '@app/core/model/dataset-profile-definition/field'; -import { - AutoCompleteFieldData, - BooleanDecisionFieldData, - CheckBoxFieldData, - CurrencyFieldData, - DataRepositoriesFieldData, - DatasetIdentifierFieldData, - DatePickerFieldData, - DmpsAutoCompleteFieldData, - ExternalDatasetsFieldData, - FieldDataOption, - FreeTextFieldData, - LicensesFieldData, - OrganizationsFieldData, - PublicationsFieldData, - RadioBoxFieldData, - RegistriesFieldData, - ResearchersAutoCompleteFieldData, - RichTextAreaFieldData, - ServicesFieldData, - TagsFieldData, - TaxonomiesFieldData, - TextAreaFieldData, - UploadFieldData, - ValidationFieldData, - WordListFieldData -} from '@app/core/model/dataset-profile-definition/field-data/field-data'; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { - DatasetDescriptionCompositeFieldEditorModel, - DatasetDescriptionFieldEditorModel, - DatasetDescriptionSectionEditorModel -} from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { TransitionGroupComponent } from "@app/ui/transition-group/transition-group.component"; -import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import { Subject } from 'rxjs'; -import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators'; -import { FieldEditorModel } from '../../../admin/field-editor-model'; -import { RuleEditorModel } from '../../../admin/rule-editor-model'; -import { GENERAL_ANIMATIONS } from '../../animations/animations'; -import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators'; -import { ViewStyleType } from '../field/view-style-enum'; - -@Component({ - selector: 'app-dataset-profile-editor-composite-field-component', - templateUrl: './dataset-profile-editor-composite-field.component.html', - styleUrls: ['./dataset-profile-editor-composite-field.component.scss'], - animations: [GENERAL_ANIMATIONS] -}) -export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent implements OnInit, OnChanges { - - @Input() form: UntypedFormGroup; - @Input() indexPath: string; - @Input() viewOnly: boolean; - - @Input() datasetProfileId?: string; - - @Input() numbering: string; - @Input() hasFocus: boolean = false; - @ViewChild("inputs") inputs: TransitionGroupComponent; - - showPreview: boolean = true; - previewDirty: boolean = false; - - - showDescription: boolean = true; - showAdditionalInfo: boolean = false; - showExtendedDescription: boolean = false; - - previewForm: UntypedFormGroup = null; - // isComposite = false; - // isMultiplicityEnabled = false; - viewStyleEnum = DatasetProfileFieldViewStyle; - - viewTypeEnum = ViewStyleType; - - private myCustomValidators: EditorCustomValidators = new EditorCustomValidators(); - - isMultiplicityEnabled = false; - constructor( - private dialog: MatDialog, - private language: TranslateService, - public enumUtils: EnumUtils, - public datasetProfileService: DatasetProfileService, - private configurationService: ConfigurationService - ) { - super(); - } - - ngOnChanges(changes: SimpleChanges) { - // this.setTargetField(null); - // this.showExtendedDescription = !!this.form.get('extendedDescription').value; - // this.showAdditionalInfo = !!this.form.get('additionalInformation').value; - // console.log(this.form.get('fields')['controls']) - if (changes['form']) { - - try { - const multiplicity = this.form.get('multiplicity').value; - this.isMultiplicityEnabled = multiplicity.min > 0 || multiplicity.max > 0; - } catch { - this.isMultiplicityEnabled = false; - } - } - - } - - get firstField() { - try { - return (this.form.get('fields') as UntypedFormArray).at(0); - } catch { - return null; - } - } - - - - - ngOnInit() { - //this.addNewField(); - // if (this.form.get('multiplicity')) { - // if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) { - // this.isMultiplicityEnabled = true; - // } - // } - // this.isComposite = (this.form.get('fields') as FormArray).length > 1; - - if (this.viewOnly) { - this.form.get('hasCommentField').disable(); - } - - //SET UP TARGET FIELD - // if((this.form.get('fields') as FormArray).length>0){ - // //get the first field in list - // this.targetField = (this.form.get('fields') as FormArray).at(0) as FormGroup; - // } - - this.showExtendedDescription = !!this.form.get('extendedDescription').value; - this.showAdditionalInfo = !!this.form.get('additionalInformation').value; - - this.form.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(changes => { - // this.previewForm = null; - this.previewDirty = true; - this.generatePreviewForm(); - - }); - this.previewSubject$ - .pipe(debounceTime(600)) - .pipe( - takeUntil(this._destroyed), - map(model => model.buildForm()), - map(updatedForm => { - const previewContainer = document.getElementById('preview_container' + this.form.get('id').value); - // let clientHeight = -1; - if (previewContainer) { - // console.log(previewContainer); - const clientHeight = previewContainer.clientHeight; - // console.log(clientHeight); - - if (clientHeight) { - previewContainer.style.height = clientHeight.toString() + 'px'; - - // console.log('height:' ,previewContainer.style.height); - } - } - this.showPreview = false; - this.previewDirty = true; - this.previewForm = updatedForm; - return previewContainer; - }), - delay(100), - tap(previewContainer => { - this.showPreview = true; - this.previewDirty = false; - }), - delay(100) - ) - .subscribe(previewContainer => { - - if (previewContainer) { - previewContainer.style.height = 'auto'; - } - - // const updatedForm = model.buildForm(); - // this.reloadPreview(updatedForm) - }); - - - this.generatePreviewForm(); - } - - - get updatedClass() { - if (this.previewDirty) return ''; - else return 'updated'; - } - private reloadPreview(updatedForm: UntypedFormGroup) { - setTimeout(() => { - - const previewContainer = document.getElementById('preview_container' + this.form.get('id').value); - // let clientHeight = -1; - if (previewContainer) { - // console.log(previewContainer); - const clientHeight = previewContainer.clientHeight; - // console.log(clientHeight); - - if (clientHeight) { - previewContainer.style.height = clientHeight.toString() + 'px'; - - // console.log('height:' ,previewContainer.style.height); - } - } - this.showPreview = false; - this.previewDirty = true; - this.previewForm = updatedForm; - - setTimeout(() => { - - - this.showPreview = true; - this.previewDirty = false; - - if (previewContainer) { - setTimeout(() => { - if (previewContainer) { - previewContainer.style.height = 'auto'; - } - }); - } - }); - }); - } - - previewSubject$: Subject = new Subject(); - - private generatePreviewForm() { - const formValue: FieldSet = this.form.getRawValue(); - const fields: FieldDefinition[] = formValue.fields.map(editorField => this._fieldToFieldDefinition(editorField)); - - - const compositeField: CompositeField = { - id: formValue.id, - additionalInformation: formValue.additionalInformation, - extendedDescription: formValue.extendedDescription, - numbering: '', - title: formValue.title, - ordinal: formValue.ordinal, - description: formValue.description, - hasCommentField: formValue.hasCommentField, - commentFieldValue: '', - multiplicity: { - max: formValue.multiplicity.max, min: formValue.multiplicity.min, - placeholder: formValue.multiplicity.placeholder, tableView: formValue.multiplicity.tableView - }, - multiplicityItems: null, - fields: fields.map(editorField => { - const model = new DatasetDescriptionFieldEditorModel().fromModel(editorField); - if (model.viewStyle.renderStyle === this.viewStyleEnum.CheckBox) { - model.value = model.value ? "true" : "false";//patch - } - return model; - }) - } - - - const section = new DatasetDescriptionSectionEditorModel(); - section.title = ''; - section.numbering = ''; - - const compositeForm = new DatasetDescriptionCompositeFieldEditorModel().fromModel(compositeField) - section.compositeFields = [compositeForm]; - - this.previewSubject$.next(section); - } - - - private _fieldToFieldDefinition(editorField: Field): FieldDefinition { - const field = { - id: editorField.id, - title: '', - page: editorField.page, - numbering: '', - multiplicity: null, - multiplicityItems: null, - viewStyle: editorField.viewStyle, - defaultValue: editorField.defaultValue, - value: null, - validations: editorField.validations, - } as FieldDefinition; - - field.data = editorField.data; - - // return new DatasetDescriptionFieldEditorModel().fromModel(field); - return field; - } - - - // generatePreview(){ - // const editorModel = new DatasetDescriptionCompositeFieldEditorModel(); - // editorModel.title = this.form.get('title').value; - // editorModel.description = this.form.get('description').value; - // editorModel.extendedDescription = this.form.get('extendedDescription').value; - // editorModel.additionalInformation = this.form.get('additionalInformation').value; - // editorModel.hasCommentField = this.form.get('hasCommentField').value; - // editorModel.fields = []; - - // (this.form.get('fields') as FormArray).controls.forEach(field=>{ - // const fieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // fieldEditorModel.viewStyle= { - // renderStyle: field.get('viewStyle').get('renderStyle').value, - // cssClass: null - // }; - // fieldEditorModel.defaultValue = field.get('defaultValue').value; - // switch (field.get('viewStyle').get('renderStyle').value) { - // case DatasetProfileFieldViewStyle.TextArea: - // fieldEditorModel.data = { - // label: field.get('data').get('label').value - // }; - // break; - - // default: - // break; - // } - - - // editorModel.fields.push(fieldEditorModel); - // }); - - - // this.previewForm = editorModel.buildForm(); - // } - - onIsCompositeChange(isComposite: boolean) { - if (!isComposite && (this.form.get('fields')).length > 1) { - for (let i = 0; i < (this.form.get('fields')).length - 1; i++) { - (this.form.get('fields')).removeAt(1); - } - (this.form.get('fields') as UntypedFormArray).controls.splice(1); - } - if ((this.form.get('fields')).length === 0) { - const field: FieldEditorModel = new FieldEditorModel(); - (this.form.get('fields')).push(field.buildForm()); - } - } - - onIsMultiplicityEnabledChange(isMultiplicityEnabled: MatCheckboxChange) { - const multiplicity = this.form.get('multiplicity') as UntypedFormGroup; - - const minControl = multiplicity.get('min'); - const maxControl = multiplicity.get('max'); - const placeholder = multiplicity.get('placeholder'); - const tableView = multiplicity.get('tableView'); - - if (isMultiplicityEnabled.checked) { - minControl.setValue(0); - maxControl.setValue(1); - placeholder.setValue(''); - tableView.setValue(false); - } else { - minControl.setValue(0); - maxControl.setValue(0); - placeholder.setValue(null); - tableView.setValue(null); - } - - this.isMultiplicityEnabled = isMultiplicityEnabled.checked; - minControl.updateValueAndValidity(); - maxControl.updateValueAndValidity(); - - } - - addNewField() { - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - - field.ordinal = (this.form.get('fields') as UntypedFormArray).length; - - const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); - - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - - (this.form.get('fields')).push(fieldForm); - - this.setTargetField(fieldForm); - fieldForm.updateValueAndValidity(); - } - - DeleteField(index) { - - const fieldsForm = this.form.get('fields'); - fieldsForm.removeAt(index); - this.inputs.init(); - // calculate ordinals - fieldsForm.controls.forEach((field, idx) => { - field.get('ordinal').setValue(idx); - field.updateValueAndValidity(); - }); - this.form.markAsDirty();//deactivate guard - } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } - - - targetField: UntypedFormGroup; - validationTypeEnum = ValidationType; - - - addVisibilityRule(targetField: UntypedFormGroup) { - const rule: RuleEditorModel = new RuleEditorModel(); - (targetField.get('visible').get('rules')).push(rule.buildForm()); - } - toggleRequired(targetField: UntypedFormGroup, event: MatCheckboxChange) { - - let validationsControl = targetField.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - - if (event.checked) { - if (!validations.includes(ValidationType.Required)) {//IS ALREADY REQUIRED - // validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required)); - // validationsControl.updateValueAndValidity(); - validations.push(ValidationType.Required); - // validationsControl.setValue(validations); - validationsControl.updateValueAndValidity(); - } - } else { - validationsControl.setValue(validations.filter(validator => validator != ValidationType.Required)); - validationsControl.updateValueAndValidity(); - } - - - // if(validations.includes(ValidationType.Required)){//IS ALREADY REQUIRED - // validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required)); - // validationsControl.updateValueAndValidity(); - // }else{ - // //SET REQUIRED VALIDATOR - // console.log('setting required validator'); - // validations.push(ValidationType.Required); - // validationsControl.setValue(validations); - // validationsControl.updateValueAndValidity(); - // } - } - setTargetField(field: AbstractControl) { - this.targetField = field; - } - - - deleteTargetField() { - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - this._deleteTargetField(); - } - }); - - } - - - private _deleteTargetField() { - if (!this.targetField) return; - - let index = -1; - - const fields = this.form.get('fields') as UntypedFormArray; - - for (let i = 0; i < fields.length; i++) { - let field = fields.at(i); - if (field.get('id').value === this.targetField.get('id').value) {//index found - index = i; - break; - } - } - - if (index >= 0) {//target found in fields - this.DeleteField(index); - this.targetField = null; - } - - } - - deleteField(index: number) { - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - this.DeleteField(index); - } - }); - - } - - - - - addNewInput(type: ViewStyleType) { - - const fieldsArray = this.form.get('fields') as UntypedFormArray; - - let targetOrdinal = fieldsArray.length; - try { - targetOrdinal = fieldsArray.controls.map(control => control.get('ordinal').value).reduce((a, b) => Math.max(a, b)) + 1; - } catch { - - } - - - - const field = { - id: Guid.create().toString(), - ordinal: targetOrdinal, - visible: { rules: [], style: null }, - validations: [], - viewStyle: {}, - export: true - - } as Field; - - - // const field: FieldEditorModel = new FieldEditorModel(); - // field.id=Guid.create().toString(); - - // field.ordinal = (this.form.get('fields') as FormArray).length; - - // const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - - - - // if (fieldForm.get('data')) { - // fieldForm.removeControl('data'); - // } - - switch (type) { - case this.viewTypeEnum.BooleanDecision: { - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.BooleanDecision) - // fieldForm.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm()); - - const data: BooleanDecisionFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.BooleanDecision; - field.data = data; - - break; - } - case this.viewTypeEnum.CheckBox: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.CheckBox) - // fieldForm.addControl('data', new CheckBoxFieldDataEditorModel().buildForm()); - const data: CheckBoxFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.CheckBox; - field.data = data; - - break; - } - case this.viewTypeEnum.Select: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // fieldForm.addControl('data', new WordListFieldDataEditorModel().buildForm()); - - // fieldForm.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // fieldForm.get('data').updateValueAndValidity(); - - const firstOption = { label: '', value: '' } as FieldDataOption; - - const data: WordListFieldData = { - label: '', - multiList: false, - options: [firstOption], - type: DatasetProfileComboBoxType.WordList - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } - case this.viewTypeEnum.Other: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // fieldForm.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE - - // fieldForm.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - // fieldForm.get('data').updateValueAndValidity(); - - const data: AutoCompleteFieldData = { - autoCompleteSingleDataList: [], - multiAutoComplete: false, - label: '', - type: DatasetProfileComboBoxType.Autocomplete - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } case this.viewTypeEnum.InternalDmpEntities: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.InternalDmpEntities) - // fieldForm.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());//TODO TO SEE - - const data: DmpsAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Dmps - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities; - field.data = data; - - break; - } - case this.viewTypeEnum.FreeText: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.FreeText) - // fieldForm.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); - - const data: FreeTextFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.FreeText; - field.data = data; - break; - } - case this.viewTypeEnum.RadioBox: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox) - // fieldForm.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - // fieldForm.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // fieldForm.get('data').updateValueAndValidity(); - const data: RadioBoxFieldData = { - label: '', - options: [] - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RadioBox; - field.data = data; - - break; - } - case this.viewTypeEnum.TextArea: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // fieldForm.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: TextAreaFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.TextArea; - field.data = data; - - break; - } - case this.viewTypeEnum.RichTextArea: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // fieldForm.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: RichTextAreaFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RichTextArea; - field.data = data; - - break; - } - case this.viewTypeEnum.Upload: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // fieldForm.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: UploadFieldData = { - label: '', - types: [], - maxFileSizeInMB: this.configurationService.maxFileSizeInMB - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Upload; - field.data = data; - - break; - } - case this.viewTypeEnum.DatePicker: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatePicker) - // fieldForm.addControl('data', new DatePickerDataEditorModel().buildForm()); - const data: DatePickerFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatePicker; - - break; - } - case this.viewTypeEnum.ExternalDatasets: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ExternalDatasets) - // fieldForm.addControl('data', new ExternalDatasetsDataEditorModel().buildForm()); - const data: ExternalDatasetsFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ExternalDatasets; - field.data = data; - break; - } - case this.viewTypeEnum.DataRepositories: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DataRepositories) - // fieldForm.addControl('data', new DataRepositoriesDataEditorModel().buildForm()); - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.PubRepositories: { - - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.JournalRepositories: { - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.Taxonomies: { - - const data: TaxonomiesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Taxonomies; - field.data = data; - - break; - } - case this.viewTypeEnum.Licenses: { - - const data: LicensesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Licenses; - field.data = data; - - break; - } - case this.viewTypeEnum.Publications: { - - const data: PublicationsFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Publications; - field.data = data; - - break; - } - case this.viewTypeEnum.Registries: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Registries) - // fieldForm.addControl('data', new RegistriesDataEditorModel().buildForm()); - - const data: RegistriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Registries; - field.data = data; - - break; - } - case this.viewTypeEnum.Services: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Services) - // fieldForm.addControl('data', new ServicesDataEditorModel().buildForm()); - - const data: ServicesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Services; - field.data = data; - - break; - } - case this.viewTypeEnum.Tags: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Tags) - // fieldForm.addControl('data', new TagsDataEditorModel().buildForm()); - - const data: TagsFieldData = { - label: '' - } - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Tags; - field.data = data; - - break; - } - case this.viewTypeEnum.Researchers: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Researchers) - // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); //TODO TO ASK - // fieldForm.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - - const data: ResearchersAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Researchers - } - - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities; - // field.data = {label:''} - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - field.data = data; - - - - - break; - } - case this.viewTypeEnum.Organizations: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Organizations) - // fieldForm.addControl('data', new OrganizationsDataEditorModel().buildForm()); - // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()) - // fieldForm.addControl('data', new DatasetsAutoCompleteFieldDataEditorModel().buildForm()); //TODO - - const data = { - autoCompleteSingleDataList: [], - label: '', - multiAutoComplete: false, - - } as OrganizationsFieldData; //TODO - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Organizations; - field.data = data; - - break; - } - case this.viewTypeEnum.DatasetIdentifier: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatasetIdentifier) - // fieldForm.addControl('data', new DatasetIdentifierDataEditorModel().buildForm()); - - const data: DatasetIdentifierFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatasetIdentifier; - field.data = data; - - break; - } - case this.viewTypeEnum.Currency: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Currency) - // fieldForm.addControl('data', new CurrencyDataEditorModel().buildForm()); - - const data: CurrencyFieldData = { - label: '' - } - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Currency; - field.data = data; - - break; - } - case this.viewTypeEnum.Validation: { - - - // fieldForm.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Validation) - // fieldForm.addControl('data', new ValidationDataEditorModel().buildForm()); - - const data: ValidationFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Validation; - field.data = data; - - break; - } - } - - (this.form.get('fields')).push(new FieldEditorModel().fromModel(field).buildForm()); - this.inputs.init(); - // fieldForm.get('viewStyle').get('renderStyle').updateValueAndValidity(); - // fieldForm.get('data').updateValueAndValidity(); - - - } - - // private customFieldValidator(): ValidatorFn{ - // return (control):ValidationErrors | null=>{ - // DatasetProfileFieldViewStyle - // switch(control.get('viewStyle').get('renderStyle').value){ - - // case DatasetProfileFieldViewStyle.TextArea: - // return null; - // case DatasetProfileFieldViewStyle.BooleanDecision: - // return null; - // case DatasetProfileFieldViewStyle.ComboBox: - // return null; - // case DatasetProfileFieldViewStyle.CheckBox: - // return null; - // case DatasetProfileFieldViewStyle.FreeText: - // return null; - // case DatasetProfileFieldViewStyle.RadioBox: - // return null; - // case DatasetProfileFieldViewStyle.DatePicker: - // return null; - // case DatasetProfileFieldViewStyle.InternalDmpEntities: - // return null; - // case DatasetProfileFieldViewStyle.ExternalDatasets: - // return null; - // case DatasetProfileFieldViewStyle.DataRepositories: - // return null; - // case DatasetProfileFieldViewStyle.Registries: - // return null; - // case DatasetProfileFieldViewStyle.Services: - // return null; - // case DatasetProfileFieldViewStyle.Tags: - // return null; - // case DatasetProfileFieldViewStyle.Researchers: - // return null; - // case DatasetProfileFieldViewStyle.Organizations: - // return null; - // case DatasetProfileFieldViewStyle.DatasetIdentifier: - // return null; - // case DatasetProfileFieldViewStyle.Currency: - // return null; - // case DatasetProfileFieldViewStyle.Validation: - // return null; - // default: - // return {inputTypeNotValid: true} - // } - // } - // } - - - // private _atLeastOneElementListValidator(arrayToCheck): ValidatorFn{ - // return (control: AbstractControl): ValidationErrors | null=>{ - - // const fa = control.get(arrayToCheck) as FormArray; - - // if(fa.length === 0){ - // return {emptyArray: true}; - // } - // return null; - // } - // } - - - calculateLabelWidth(numbering: string) { - - const width = numbering.split('.').reduce((acc, item) => item + acc, '').length; - - - return { 'width': width + 'em' } - } - - get fieldsArray(): UntypedFormArray { - if (this.form && this.form.get('fields')) { - return this.form.get('fields') as UntypedFormArray; - } - return null; - } - - move(index, direction: "up" | "down" = "up") { - this.inputs.init(); - if (direction === "up" && this.canGoUp(index)) { - let temp = this.fieldsArray.at(index); - this.fieldsArray.removeAt(index); - this.fieldsArray.insert(index - 1, temp); - } else if (direction === "down" && this.canGoDown(index)) { - let temp = this.fieldsArray.at(index + 1); - this.fieldsArray.removeAt(index + 1); - this.fieldsArray.insert(index, temp); - } - this.fieldsArray.controls.forEach((field, index) => { - field.get('ordinal').setValue(index); - }); - } - - canGoUp(index: number): boolean { - return index > 0 && !this.viewOnly; - } - - canGoDown(index: number): boolean { - return index < (this.fieldsArray.length - 1) && !this.viewOnly; - } -} - - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html deleted file mode 100644 index 4a6fa65ec..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.html +++ /dev/null @@ -1,97 +0,0 @@ -
- - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | - translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' - | - translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO' - | - translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }} - {{opt.get('label').value}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - - - {{placeHolder}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}} - {{opt.get('label').value}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - {{placeHolder}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{placeHolder}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss deleted file mode 100644 index 946679a44..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width{ - width: 100%; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts deleted file mode 100644 index e1b13e149..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-profile-editor-default-value/component-profile-editor-default-value.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormControl } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type'; - -@Component({ - selector: 'app-component-profile-editor-default-value-component', - templateUrl: './component-profile-editor-default-value.component.html', - styleUrls: ['./component-profile-editor-default-value.component.scss'] -}) -export class DatasetProfileEditorDefaultValueComponent implements OnInit { - - @Input() viewStyle: DatasetProfileFieldViewStyle; - @Input() form: UntypedFormControl; - @Input() formArrayOptions: UntypedFormArray; - @Input() comboBoxType: DatasetProfileComboBoxType; - @Input() internalDmpEntitiesType: DatasetProfileInternalDmpEntitiesType; - @Input() placeHolder: String; - // @Input() required: Boolean; - - comboBoxTypeEnum = DatasetProfileComboBoxType; - internalDmpEntitiesTypeEnum = DatasetProfileInternalDmpEntitiesType; - viewStyleEnum = DatasetProfileFieldViewStyle; - - constructor() { } - - ngOnInit() { - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html deleted file mode 100644 index e00d41f20..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.html +++ /dev/null @@ -1,112 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-PLACEHOLDER' | translate}} - - - - -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-SOURCE-TITLE' | translate}}
-
- - - -
- warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-OTHER-SOURCES-REQUIRED'| translate}} -
- -
-
- -
- - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-METHOD' | translate}} - - {{method.value}} - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-LABEL' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-VALUE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-SOURCE' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-HAS-AUTH' | translate}} -
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-METHOD' | translate}} - - {{method.value}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-TYPE' | translate}} - - {{type.value}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-BODY' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- - -
- diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts deleted file mode 100644 index 378fb9aad..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/auto-complete/dataset-profile-editor-auto-complete-field.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup, UntypedFormArray, AbstractControl } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { AutoCompleteFieldDataEditorModel } from '../../../../admin/field-data/auto-complete-field-data-editor-model'; -import { AutoCompleteSingleDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-single-data'; -// import { HtmlMethod } from '@app/core/model/dataset-profile-definition/html-method.enum'; -// import { AuthType } from '@app/core/model/dataset-profile-definition/auth-type.enum'; - -@Component({ - selector: 'app-dataset-profile-editor-auto-complete-field-component', - styleUrls: ['./dataset-profile-editor-auto-complete-field.component.scss'], - templateUrl: './dataset-profile-editor-auto-complete-field.component.html' -}) -export class DatasetProfileEditorAutoCompleteFieldComponent implements OnInit { - - // public htmlMethods = HtmlMethod; - // public authTypes = AuthType; - - @Input() form: UntypedFormGroup; - private data: AutoCompleteFieldDataEditorModel = new AutoCompleteFieldDataEditorModel(); - multiForm: UntypedFormArray; - - ngOnInit() { - this.multiForm = (this.form.get('data').get('autoCompleteSingleDataList')); - this.data.type = DatasetProfileComboBoxType.Autocomplete; - } - - addSource() { - (this.multiForm).push(new AutoCompleteSingleDataEditorModel().buildForm()); - } - - removeSource(index: number) { - (this.multiForm).removeAt(index); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html deleted file mode 100644 index e1f96a2e1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts deleted file mode 100644 index cb7f31d47..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/boolean-decision/dataset-profile-editor-boolean-decision-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ - -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { BooleanDecisionFieldDataEditorModel } from '../../../../admin/field-data/boolean-decision-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-boolean-decision-field-component', - styleUrls: ['./dataset-profile-editor-boolean-decision-field.component.scss'], - templateUrl: './dataset-profile-editor-boolean-decision-field.component.html' -}) -export class DatasetProfileEditorBooleanDecisionFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: BooleanDecisionFieldDataEditorModel = new BooleanDecisionFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html deleted file mode 100644 index 56ae77ff2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-TITLE' | translate}}
- - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts deleted file mode 100644 index 8d0e6c756..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/checkbox/dataset-profile-editor-checkbox-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { CheckBoxFieldDataEditorModel } from '../../../../admin/field-data/check-box-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-checkbox-field-component', - styleUrls: ['./dataset-profile-editor-checkbox-field.component.scss'], - templateUrl: './dataset-profile-editor-checkbox-field.component.html' -}) -export class DatasetProfileEditorCheckboxFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: CheckBoxFieldDataEditorModel = new CheckBoxFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html deleted file mode 100644 index 9f4e545ab..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts deleted file mode 100644 index 9fc577234..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/combo-box/dataset-profile-editor-combo-box-field.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { AutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/auto-complete-field-data-editor-model'; -import { WordListFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/word-list-field-data-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-editor-combo-box-field-component', - styleUrls: ['./dataset-profile-editor-combo-box-field.component.scss'], - templateUrl: './dataset-profile-editor-combo-box-field.component.html' -}) -export class DatasetProfileEditorComboBoxFieldComponent extends BaseComponent implements OnInit { - - @Input() form: UntypedFormGroup; - options = DatasetProfileComboBoxType; - - constructor( - public enumUtils: EnumUtils - ) { super(); } - - ngOnInit() { - // this.setupListeners(); - } - - setupListeners() { - this.form.get('data').get('type').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (this.form.get('data')) { this.form.removeControl('data'); } - if (x === DatasetProfileComboBoxType.Autocomplete) { - this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); - } else if (x === DatasetProfileComboBoxType.WordList) { - this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - } - this.setupListeners(); - }); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html deleted file mode 100644 index da6e65ae7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CURRENCY-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CURRENCY-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts deleted file mode 100644 index 474ffa93f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/currency/dataset-profile-editor-currency-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-currency-field-component', - styleUrls: ['./dataset-profile-editor-currency-field.component.scss'], - templateUrl: './dataset-profile-editor-currency-field.component.html' -}) -export class DatasetProfileEditorCurrencyFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html deleted file mode 100644 index 641c26ce1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATA-REPOSITORIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATA-REPOSITORIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts deleted file mode 100644 index 5bf8fd251..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/data-repositories/dataset-profile-editor-data-repositories-field.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-data-repositories-field-component', - styleUrls: ['./dataset-profile-editor-data-repositories-field.component.scss'], - templateUrl: './dataset-profile-editor-data-repositories-field.component.html' -}) -export class DatasetProfileEditorDataRepositoriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html deleted file mode 100644 index 263601838..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASET-IDENTIFIER-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASET-IDENTIFIER-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts deleted file mode 100644 index d9ecf05e1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { Router } from '@angular/router'; -import { DatasetIdentifierDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/dataset-identifier-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-dataset-identifier-field-component', - styleUrls: ['./dataset-profile-editor-dataset-identifier-field.component.scss'], - templateUrl: './dataset-profile-editor-dataset-identifier-field.component.html' -}) -export class DatasetProfileEditorDatasetIdentifierFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DatasetIdentifierDataEditorModel = new DatasetIdentifierDataEditorModel(); - - constructor(private router: Router) {} - - ngOnInit() { - if(this.router.url.includes('new')){ - this.form.patchValue({'rdaCommonStandard': 'dataset.dataset_id'}); - } - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html deleted file mode 100644 index e7c6d01dc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASETS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts deleted file mode 100644 index ec9c22260..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { OnInit, Input, Component } from "@angular/core"; -import { UntypedFormGroup } from "@angular/forms"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { DatasetsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/datasets-autocomplete-field-data-editor-mode"; - -@Component({ - selector: 'app-dataset-profile-editor-datasets-autocomplete-field-component', - styleUrls: ['./dataset-profile-editor-datasets-autocomplete-field.component.scss'], - templateUrl: './dataset-profile-editor-datasets-autocomplete-field.component.html' -}) -export class DatasetProfileEditorDatasetsAutoCompleteFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DatasetsAutoCompleteFieldDataEditorModel = new DatasetsAutoCompleteFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileInternalDmpEntitiesType.Datasets; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html deleted file mode 100644 index bf505dbea..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATE-PICKER-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts deleted file mode 100644 index a0d6bbb3b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-date-picker-field-component', - styleUrls: ['./dataset-profile-editor-date-picker-field.component.scss'], - templateUrl: './dataset-profile-editor-date-picker-field.component.html' -}) -export class DatasetProfileEditorDatePickerFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DatePickerDataEditorModel = new DatePickerDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html deleted file mode 100644 index 2109b436b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DMPS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts deleted file mode 100644 index a7ec9d4fb..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { OnInit, Input, Component } from "@angular/core"; -import { UntypedFormGroup } from "@angular/forms"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; -import { DatasetsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/datasets-autocomplete-field-data-editor-mode"; -import { DmpsAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/dmps-autocomplete-field-data-editor-model"; - -@Component({ - selector: 'app-dataset-profile-editor-dmps-autocomplete-field-component', - styleUrls: ['./dataset-profile-editor-dmps-autocomplete-field.component.scss'], - templateUrl: './dataset-profile-editor-dmps-autocomplete-field.component.html' -}) -export class DatasetProfileEditorDmpsAutoCompleteFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DmpsAutoCompleteFieldDataEditorModel = new DatasetsAutoCompleteFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileInternalDmpEntitiesType.Dmps; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html deleted file mode 100644 index d8e932f46..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html +++ /dev/null @@ -1,22 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-EXTERNAL-DATASETS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-EXTERNAL-DATASETS-PLACEHOLDER' | translate}} - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPE-NAME' | translate}} - - - {{type.label | translate}} - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts deleted file mode 100644 index dbd2e951e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { ExternalDatasetTypeEnum } from '@app/core/common/enum/external-dataset-type-enum'; - -@Component({ - selector: 'app-dataset-profile-editor-external-datasets-field-component', - styleUrls: ['./dataset-profile-editor-external-datasets-field.component.scss'], - templateUrl: './dataset-profile-editor-external-datasets-field.component.html' -}) -export class DatasetProfileEditorExternalDatasetsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ExternalDatasetsDataEditorModel = new ExternalDatasetsDataEditorModel(); - - externalDatasetTypes = [ - ... Object.keys(ExternalDatasetTypeEnum).map(key=>{ - return { - label: this.parseExtrernalDatasetTypeKey(key), - value: ExternalDatasetTypeEnum[key] - }; - }) - ]; - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } - - parseExtrernalDatasetTypeKey(key: string): string{ - if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ProducedDataset){ - return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.PRODUCED'; - } - if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ReusedDataset){ - return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.REUSED'; - } - if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.Other){ - return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.OTHER'; - } - return key; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html deleted file mode 100644 index cc1248c46..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
- -
- {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-FREE-TEXT-TITLE' | translate}}
- - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-FREE-TEXT-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts deleted file mode 100644 index b0471954e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/free-text/dataset-profile-editor-free-text-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { FreeTextFieldDataEditorModel } from '../../../../admin/field-data/free-text-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-free-text-field-component', - styleUrls: ['./dataset-profile-editor-free-text-field.component.scss'], - templateUrl: './dataset-profile-editor-free-text-field.component.html' -}) -export class DatasetProfileEditorFreeTextFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: FreeTextFieldDataEditorModel = new FreeTextFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html deleted file mode 100644 index 26d4cff98..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
- - - {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Researchers)}} - {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Datasets)}} - {{enumUtils.toDatasetProfileInternalDmpEntitiesTypeString(options.Dmps)}} - - - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts deleted file mode 100644 index 63c74dd1e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/internal-dmp-entities/dataset-profile-editor-internal-dmp-entities-field.component.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { DatasetsAutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/datasets-autocomplete-field-data-editor-mode'; -import { DmpsAutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/dmps-autocomplete-field-data-editor-model'; -import { ResearchersAutoCompleteFieldDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/researchers-auto-complete-field-data-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-internal-dmp-entities-field-component', - styleUrls: ['./dataset-profile-editor-internal-dmp-entities-field.component.scss'], - templateUrl: './dataset-profile-editor-internal-dmp-entities-field.component.html' -}) -export class DatasetProfileEditorInternalDmpEntitiesFieldComponent extends BaseComponent implements OnInit { - @Input() form: UntypedFormGroup; - options = DatasetProfileInternalDmpEntitiesType; - - constructor( - public enumUtils: EnumUtils - ) { super() } - - ngOnInit() { - this.setupListeners(); - } - - setupListeners() { - this.form.get('data').get('type').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (this.form.get('data')) { this.form.removeControl('data'); } - if (x === DatasetProfileInternalDmpEntitiesType.Researchers) { - this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - } else if (x === DatasetProfileInternalDmpEntitiesType.Datasets) { - this.form.addControl('data', new DatasetsAutoCompleteFieldDataEditorModel().buildForm()); - } - else if (x === DatasetProfileInternalDmpEntitiesType.Dmps) { - this.form.addControl('data', new DmpsAutoCompleteFieldDataEditorModel().buildForm()); - } - this.setupListeners(); - }) - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html deleted file mode 100644 index c7be19408..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-JOURNALS-REPOSITORIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-JOURNALS-REPOSITORIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts deleted file mode 100644 index 272b4f55b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/journal-repositories/dataset-profile-editor-journal-repositories-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { FormControl } from '@angular/forms'; - -@Component({ - selector: 'app-dataset-profile-editor-journal-repositories-field-component', - styleUrls: ['./dataset-profile-editor-journal-repositories-field.component.scss'], - templateUrl: './dataset-profile-editor-journal-repositories-field.component.html' -}) -export class DatasetProfileEditorJournalRepositoriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html deleted file mode 100644 index a133a33da..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-LICENSES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-LICENSES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts deleted file mode 100644 index aac88601b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/licenses/dataset-profile-editor-licenses-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormGroup} from '@angular/forms'; -import {LicensesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/licenses-data-editor-models"; - -@Component({ - selector: 'app-dataset-profile-editor-licenses-field-component', - styleUrls: ['./dataset-profile-editor-licenses-field.component.scss'], - templateUrl: './dataset-profile-editor-licenses-field.component.html' -}) -export class DatasetProfileEditorLicensesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: LicensesDataEditorModel = new LicensesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html deleted file mode 100644 index 303388518..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-ORGANIZATIONS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-ORGANIZATIONS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts deleted file mode 100644 index 8dfb885ae..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; -import { TagsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models'; -import { ResearchersDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models'; -import { OrganizationsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/organizations-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-organizations-field-component', - styleUrls: ['./dataset-profile-editor-organizations-field.component.scss'], - templateUrl: './dataset-profile-editor-organizations-field.component.html' -}) -export class DatasetProfileEditorOrganizationsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: OrganizationsDataEditorModel = new OrganizationsDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html deleted file mode 100644 index d0e981adc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUB-REPOSITORIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUB-REPOSITORIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts deleted file mode 100644 index f4940251e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/pub-repositories/dataset-profile-editor-pub-repositories-field.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-pub-repositories-field-component', - styleUrls: ['./dataset-profile-editor-pub-repositories-field.component.scss'], - templateUrl: './dataset-profile-editor-pub-repositories-field.component.html' -}) -export class DatasetProfileEditorPubRepositoriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html deleted file mode 100644 index 3421efdb5..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUBLICATIONS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-PUBLICATIONS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts deleted file mode 100644 index 56dc16378..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/publications/dataset-profile-editor-publications-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormGroup} from '@angular/forms'; -import {PublicationsDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/publications-data-editor-models"; - -@Component({ - selector: 'app-dataset-profile-editor-publications-field-component', - styleUrls: ['./dataset-profile-editor-publications-field.component.scss'], - templateUrl: './dataset-profile-editor-publications-field.component.html' -}) -export class DatasetProfileEditorPublicationsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: PublicationsDataEditorModel = new PublicationsDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html deleted file mode 100644 index 944b3e3a9..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html +++ /dev/null @@ -1,41 +0,0 @@ -
-
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE' - | translate}}
- - warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}} - -
- - - -
-
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}} - - - -
-
-
- - -
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss deleted file mode 100644 index 8bec9923c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.scss +++ /dev/null @@ -1,4 +0,0 @@ -.full-width { - width: 100%; -} - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts deleted file mode 100644 index 6c2d2ce36..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { FieldDataOptionEditorModel } from '../../../../admin/field-data/field-data-option-editor-model'; -import { RadioBoxFieldDataEditorModel } from '../../../../admin/field-data/radio-box-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-radio-box-field-component', - styleUrls: ['./dataset-profile-editor-radio-box-field.component.scss'], - templateUrl: './dataset-profile-editor-radio-box-field.component.html' -}) -export class DatasetProfileEditorRadioBoxFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: RadioBoxFieldDataEditorModel = new RadioBoxFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } - - addNewRow() { - const radioListOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - if (!this.form.get('data').get('options')) { (this.form.get('data')).addControl('options', new UntypedFormBuilder().array([])); } - (this.form.get('data').get('options')).push(radioListOptions.buildForm()); - } - - deleteRow(intex: number) { - if (this.form.get('data').get('options')) { (this.form.get('data').get('options')).removeAt(intex); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html deleted file mode 100644 index 7aad9fc38..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-REGISTRIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-REGISTRIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts deleted file mode 100644 index c6f4a3955..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/registries/dataset-profile-editor-registries-field.component.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-registries-field-component', - styleUrls: ['./dataset-profile-editor-registries-field.component.scss'], - templateUrl: './dataset-profile-editor-registries-field.component.html' -}) -export class DatasetProfileEditorRegistriesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: RegistriesDataEditorModel = new RegistriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html deleted file mode 100644 index 94260ad5a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts deleted file mode 100644 index 723f776d4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers-auto-complete/dataset-profile-editor-researchers-auto-complete-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ResearchersAutoCompleteFieldDataEditorModel } from "../../../../admin/field-data/researchers-auto-complete-field-data-editor-model"; -import { UntypedFormGroup } from "@angular/forms"; -import { Input, Component, OnInit } from "@angular/core"; -import { DatasetProfileInternalDmpEntitiesType } from "../../../../../../../core/common/enum/dataset-profile-internal-dmp-entities-type"; - -@Component({ - selector: 'app-dataset-profile-editor-researchers-auto-complete-field-component', - styleUrls: ['./dataset-profile-editor-researchers-auto-complete-field.component.scss'], - templateUrl: './dataset-profile-editor-researchers-auto-complete-field.component.html' -}) -export class DatasetProfileEditorResearchersAutoCompleteFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ResearchersAutoCompleteFieldDataEditorModel = new ResearchersAutoCompleteFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileInternalDmpEntitiesType.Researchers; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html deleted file mode 100644 index bc1c84e39..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts deleted file mode 100644 index b7ecb9364..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; -import { TagsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models'; -import { ResearchersDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/researchers-data-editor-models'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'app-dataset-profile-editor-researchers-field-component', - styleUrls: ['./dataset-profile-editor-researchers-field.component.scss'], - templateUrl: './dataset-profile-editor-researchers-field.component.html' -}) -export class DatasetProfileEditorResearchersFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ResearchersDataEditorModel = new ResearchersDataEditorModel(); - - constructor(private router: Router) {} - - ngOnInit() { - if(this.router.url.includes('new')){ - this.form.patchValue({'rdaCommonStandard': 'dmp.contributor'}); - } - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html deleted file mode 100644 index 05e06a486..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RICH-TEXT-AREA-TITLE' - | translate}}
- - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RICH-TEXT-AREA-PLACEHOLDER' | translate}} - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss deleted file mode 100644 index 8da39919b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts deleted file mode 100644 index a1d74a86c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/rich-textarea/dataset-profile-editor-rich-text-area-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { RichTextAreaFieldDataEditorModel } from '../../../../admin/field-data/rich-text-area-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-rich-text-area-field-component', - styleUrls: ['./dataset-profile-editor-rich-text-area-field.component.scss'], - templateUrl: './dataset-profile-editor-rich-text-area-field.component.html' -}) -export class DatasetProfileEditorRichTextAreaFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: RichTextAreaFieldDataEditorModel = new RichTextAreaFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html deleted file mode 100644 index 9f0991328..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-SERVICES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-SERVICES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts deleted file mode 100644 index bf87cfd08..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/services/dataset-profile-editor-services-field.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-services-field-component', - styleUrls: ['./dataset-profile-editor-services-field.component.scss'], - templateUrl: './dataset-profile-editor-services-field.component.html' -}) -export class DatasetProfileEditorServicesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: ServicesDataEditorModel = new ServicesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html deleted file mode 100644 index bab2b500f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAGS-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAGS-PLACEHOLDER' | translate}} - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts deleted file mode 100644 index 350809a8b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models'; -import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; -import { RegistriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/registries-data-editor-models'; -import { ServicesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/services-data-editor-models'; -import { TagsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/tags-data-editor-models'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'app-dataset-profile-editor-tags-field-component', - styleUrls: ['./dataset-profile-editor-tags-field.component.scss'], - templateUrl: './dataset-profile-editor-tags-field.component.html' -}) -export class DatasetProfileEditorTagsFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: TagsDataEditorModel = new TagsDataEditorModel(); - - constructor(private router: Router) {} - - ngOnInit() { - if(this.router.url.includes('new')){ - this.form.patchValue({'rdaCommonStandard': 'dataset.keyword'}); - } - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html deleted file mode 100644 index 8249d5df7..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAXONOMIES-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAXONOMIES-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts deleted file mode 100644 index 3a1033397..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/taxonomies/dataset-profile-editor-taxonomies-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormGroup} from '@angular/forms'; -import {TaxonomiesDataEditorModel} from "@app/ui/admin/dataset-profile/admin/field-data/taxonomies-data-editor-models"; - -@Component({ - selector: 'app-dataset-profile-editor-taxonomies-field-component', - styleUrls: ['./dataset-profile-editor-taxonomies-field.component.scss'], - templateUrl: './dataset-profile-editor-taxonomies-field.component.html' -}) -export class DatasetProfileEditorTaxonomiesFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: TaxonomiesDataEditorModel = new TaxonomiesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html deleted file mode 100644 index f3fe6ee4a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TEXT-AREA-TITLE' - | translate}}
- - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TEXT-AREA-PLACEHOLDER' | translate}} - - - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts deleted file mode 100644 index 8daf1e271..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/textarea/dataset-profile-editor-text-area-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { TextAreaFieldDataEditorModel } from '../../../../admin/field-data/text-area-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-text-area-field-component', - styleUrls: ['./dataset-profile-editor-text-area-field.component.scss'], - templateUrl: './dataset-profile-editor-text-area-field.component.html' -}) -export class DatasetProfileEditorTextAreaFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: TextAreaFieldDataEditorModel = new TextAreaFieldDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html deleted file mode 100644 index 73e64e186..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.html +++ /dev/null @@ -1,62 +0,0 @@ - -
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-TITLE' - | translate}}
- - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-PLACEHOLDER' | translate}} - - - - - - - {{ "DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-MAX-FILE-SIZE" | - translate: { maxfilesize: getConfiguration().maxFileSizeInMB.toString() } }} - - - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-SELECT-FILETYPE' | translate}} - - - - {{type.label}} - - - - -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-CUSTOM-FILETYPE' | translate}}
- -
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-LABEL' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-VALUE' | translate}} - - - -
-
-
-
- -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss deleted file mode 100644 index 8da39919b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts deleted file mode 100644 index 76fb38032..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/upload/dataset-profile-editor-upload-field.component.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { FieldDataOption } from "@app/core/model/dataset-profile-definition/field-data/field-data"; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { FieldDataOptionEditorModel } from "@app/ui/admin/dataset-profile/admin/field-data/field-data-option-editor-model"; -import { UploadFieldDataEditorModel } from '../../../../admin/field-data/upload-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-upload-field-component', - styleUrls: ['./dataset-profile-editor-upload-field.component.scss'], - templateUrl: './dataset-profile-editor-upload-field.component.html' -}) -export class DatasetProfileEditorUploadFieldComponent implements OnInit { - types: Array = [ - // images - { label: "Animated Portable Network Graphics (APNG)", value: "image/apng", source: "" }, - { label: "AV1 Image File Format (AVIF)", value: "image/avif", source: "" }, - { label: "Graphics Interchange Format (GIF)", value: "image/gif", source: "" }, - { label: "Joint Photographic Expert Group image (JPEG)", value: "image/jpeg", source: "" }, - { label: "Portable Network Graphics (PNG)", value: "image/png", source: "" }, - { label: "Scalable Vector Graphics (SVG)", value: "image/svg+xml", source: "" }, - { label: "Web Picture format (WEBP)", value: "image/webp", source: "" }, - { label: "Tagged Image File Format (TIFF)", value: "image/tiff", source: "" }, - - // office word - { label: "Microsoft Word 97-2003", value: "application/msword", source: "" }, // .doc, .dot - { label: "Microsoft Word 2007-2013", value: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", source: "" }, // .docx - { label: "OpenDocument Text", value: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", source: "" }, // .odt - - // office excel - { label: "Microsoft Excel 97-2003", value: "application/vnd.ms-excel", source: "" }, // .xls, .xlt, .xla - { label: "Microsoft Excel 2007-2013", value: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", source: "" }, // .xlsx - { label: "OpenDocument Spreadsheet", value: "application/vnd.oasis.opendocument.spreadsheet", source: "" }, // .ods - - // office powerpoint - { label: "Microsoft PowerPoint 97-2003", value: "application/vnd.ms-powerpoint", source: "" }, // .ppt, .pot, .pps, .ppa - { label: "Microsoft PowerPoint 2007-2013", value: "application/vnd.openxmlformats-officedocument.presentationml.presentation", source: "" }, // .pptx - { label: "OpenDocument Presentation", value: "application/vnd.oasis.opendocument.presentation", source: "" }, // .odp - - - { label: "Comma-Seperated Values (CSV)", value: "text/csv", source: "" }, - { label: "Adobe Portable Document Format (PDF)", value: "application/pdf", source: "" } - ]; - - selected: string[] = []; - public typesFormControl = new UntypedFormControl(); - - @Input() form: UntypedFormGroup; - private data: UploadFieldDataEditorModel = new UploadFieldDataEditorModel(); - - constructor(private configurationService: ConfigurationService) { } - - ngOnInit() { - let typeValues: string[] = this.types.map(type => type.value); - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - if (this.form.get('data') && this.form.get('data').get('types')) { - for (let type of this.form.get('data').get('types').value) { - if (typeValues.indexOf(type.value) != -1) { - this.selected.push(type.value); - } - } - this.typesFormControl.setValue(this.selected); - // if (this.form.get('data').get('types').disabled) { - // this.typesFormControl.disable(); - // } - } - } - - selectedType(type: FieldDataOption) { - if (!this.form.get('data').get('types').disabled) { - let index = this.selected.indexOf(type.value); - if (index == -1) { - this.selected.push(type.value); - this.addNewRow(type); - } else { - this.selected.splice(index, 1); - this.deleteRow(index); - } - } - } - - isCustomType(value: string) { - return this.selected.indexOf(value) == -1; - } - - addNewRow(type: FieldDataOption = null) { - const typeListOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - if (type != null) { - typeListOptions.fromModel(type); - } - (this.form.get('data')).addControl('types', new UntypedFormBuilder().array([])); - (this.form.get('data').get('types')).push(typeListOptions.buildForm()); - } - - deleteRow(index: number) { - if (this.form.get('data').get('types')) { (this.form.get('data').get('types')).removeAt(index); } - } - - public getConfiguration() { - return this.configurationService; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html deleted file mode 100644 index 8b28d4c4e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-VALIDATOR-TITLE' - | translate}}
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-VALIDATOR-PLACEHOLDER' | translate}} - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts deleted file mode 100644 index b3ec7f309..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/validator/dataset-profile-editor-validator-field.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models'; - -@Component({ - selector: 'app-dataset-profile-editor-validator-field-component', - styleUrls: ['./dataset-profile-editor-validator-field.component.scss'], - templateUrl: './dataset-profile-editor-validator-field.component.html' -}) -export class DatasetProfileEditorValidatorFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel(); - - ngOnInit() { - if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html deleted file mode 100644 index 12d82cae4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.html +++ /dev/null @@ -1,41 +0,0 @@ -
-
- -
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-TITLE' - | translate}}
- - - warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-SELECT-AT-LEAST-ONE-REQUIRED' |translate}} - -
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-WORDLIST' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-PLACEHOLDER' | translate}} - - - -
-
- - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-LABEL' | translate}} - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-WORD-LIST-VALUE' | translate}} - - - -
-
-
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts deleted file mode 100644 index b7f78262c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field-type/word-list/dataset-profile-editor-word-list-field.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { FieldDataOptionEditorModel } from '../../../../admin/field-data/field-data-option-editor-model'; -import { WordListFieldDataEditorModel } from '../../../../admin/field-data/word-list-field-data-editor-model'; - -@Component({ - selector: 'app-dataset-profile-editor-word-list-field-component', - styleUrls: ['./dataset-profile-editor-word-list-field.component.scss'], - templateUrl: './dataset-profile-editor-word-list-field.component.html' -}) -export class DatasetProfileEditorWordListFieldComponent implements OnInit { - - @Input() form: UntypedFormGroup; - private data: WordListFieldDataEditorModel = new WordListFieldDataEditorModel(); - - ngOnInit() { - this.data.type = DatasetProfileComboBoxType.WordList; - } - - addNewRow() { - const wordListOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel(); - (this.form.get('data').get('options')).push(wordListOptions.buildForm()); - } - - deleteRow(intex: number) { - if (this.form.get('data').get('options')) { (this.form.get('data').get('options')).removeAt(intex); } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html deleted file mode 100644 index f924390b4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html +++ /dev/null @@ -1,333 +0,0 @@ - - - -
- -
-
    -
  • - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
  • -
  • - - {{'GENERAL.VALIDATION.URL.LABEL' | translate}} - -
  • - -
  • - delete -
  • -
-
-
- -
- - - - - - - - - {{enumUtils.toDatasetProfileViewTypeString(select.value)}} - - - TextArea icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.TextArea)}} - - - RichTextArea icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.RichTextArea)}} - - - FreeText icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.FreeText)}} - - - - - upload - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Upload)}} - - - - - - - - Boolean icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.BooleanDecision)}} - - - RadioBox icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.RadioBox)}} - - - - Select icon - - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Select)}} - - - CheckBox icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.CheckBox)}} - - - - - - DatePicker icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DatePicker)}} - - - Current icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Currency)}} - - - - - - - - Registries icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Registries)}} - - - Services icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Services)}} - - - Researchers icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Researchers)}} - - - Organizations icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Organizations)}} - - - ExternalDatasets icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.ExternalDatasets)}} - - - DataRepositories icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DataRepositories)}} - - - PubRepositories icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.PubRepositories)}} - - - Journal Repositories icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.JournalRepositories)}} - - - Taxonomies icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Taxonomies)}} - - - licenses icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Licenses)}} - - - Publications icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Publications)}} - - - Other icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Other)}} - - - - - - - InternalDmpEntities icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.InternalDmpEntities)}} - - - Tags icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Tags)}} - - - DatasetIdentifier icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DatasetIdentifier)}} - - - Validation icon - {{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.Validation)}} - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - - - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.SEMANTICS' | translate}} - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXPORT' | translate}} - - - - -
-
-
- 'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.ADD-VISIBILITY-RULE' | translate - {{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.ADD-VISIBILITY-RULE' | translate}} -
-
- -
-
- -

{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | translate}} -

- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss deleted file mode 100644 index 7dfc9b224..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.scss +++ /dev/null @@ -1,66 +0,0 @@ -.full-width { - width: 100%; -} - - -.preview-box{ - padding: 1em; - border: 1px solid #e8dcdc; - border-radius: 0.3em; -} - -mat-radio-button{ - padding-right: 1em; -} - -li.list-inline-item{ - color: var(--primary-color); - .mat-icon{ - vertical-align: bottom; - } -} - -:host ::ng-deep .field-toggler -{ - .mat-slide-toggle-content{ - font-size: 0.8em; - color: #212121; - } - .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb { - background-color:var(--primary-color) ; - } - .mat-slide-toggle.mat-checked .mat-slide-toggle-bar { - background-color:rgba(0,178,159,0.34); - } - .mat-slide-toggle-bar{ - height: 11.93px; - width: 26.42px; - } - .mat-slide-toggle-thumb-container{ - top: -3px; - } - .mat-slide-toggle-thumb{ - width: 16px; - height: 16px; - } -} - - -.input_icon{ - width: 14px; - margin-right: 0.5em; -} -.visibility-icon{ - width: 20px; - margin-right: 0.5em; -} -.add-visibility-button{ - // display: flex; - // align-items: center; - width: auto; - cursor: pointer; - span{ - font-weight: 400; - font-size: 0.8em; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts deleted file mode 100644 index cf2a828f6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts +++ /dev/null @@ -1,988 +0,0 @@ -import { COMMA, ENTER } from '@angular/cdk/keycodes'; -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { FormGroupDirective, NgForm, UntypedFormArray, UntypedFormControl, UntypedFormGroup, } from '@angular/forms'; -import { ErrorStateMatcher } from '@angular/material/core'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSlideToggleChange } from '@angular/material/slide-toggle'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { ValidationType } from '@app/core/common/enum/validation-type'; -import { DefaultValue, Field } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { - AutoCompleteFieldData, - BooleanDecisionFieldData, - CheckBoxFieldData, - CurrencyFieldData, - DataRepositoriesFieldData, - DatasetIdentifierFieldData, - DatePickerFieldData, - DmpsAutoCompleteFieldData, - ExternalDatasetsFieldData, - FieldDataOption, - FreeTextFieldData, - LicensesFieldData, - OrganizationsFieldData, - PublicationsFieldData, - RadioBoxFieldData, - RegistriesFieldData, - ResearchersAutoCompleteFieldData, - RichTextAreaFieldData, - ServicesFieldData, - // TableFieldData, - TagsFieldData, - TaxonomiesFieldData, - TextAreaFieldData, - UploadFieldData, - ValidationFieldData, - WordListFieldData -} from '@app/core/model/dataset-profile-definition/field-data/field-data'; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { RuleEditorModel } from '@app/ui/admin/dataset-profile/admin/rule-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable, Subscription } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { FieldEditorModel } from '../../../admin/field-editor-model'; -import { ViewStyleType } from './view-style-enum'; - -@Component({ - selector: 'app-dataset-profile-editor-field-component', - templateUrl: './dataset-profile-editor-field.component.html', - styleUrls: ['./dataset-profile-editor-field.component.scss'] -}) -export class DatasetProfileEditorFieldComponent extends BaseComponent implements OnInit, ErrorStateMatcher { - @Input() viewOnly: boolean; - @Input() form: UntypedFormGroup; - @Input() showOrdinal = true; - @Input() indexPath: string; - validationTypeEnum = ValidationType; - viewStyleEnum = DatasetProfileFieldViewStyle; - // isFieldMultiplicityEnabled = false; - - viewType: ViewStyleType; - viewTypeEnum = ViewStyleType; - // private subject$:Subject = new Subject(); - - - - @Input() expandView: boolean = true; - @Input() canBeDeleted: boolean = true; - - @Output() delete = new EventEmitter(); - - readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - semanticsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterSemantics.bind(this), - initialItems: (excludedItems: any[]) => this.filterSemantics('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x !== resultItem)))), - displayFn: (item) => item, - titleFn: (item) => item - } - - filterSemantics(value: string): Observable { - return this.datasetProfileService.searchSemantics(value); - } - - constructor( - public enumUtils: EnumUtils, - public datasetProfileService: DatasetProfileService, - private dialog: MatDialog, - private configurationService: ConfigurationService - ) { - super(); - - } - - - isErrorState(control: UntypedFormControl, form: FormGroupDirective | NgForm): boolean { - - if (this.form.get('viewStyle').untouched) return false; - - return this.form.get('viewStyle').invalid; - } - - ngOnInit() { - - // this.subject$.pipe(takeUntil(this._destroyed)).pipe(debounceTime(600)).subscribe(model=>{ - // this.previewForm = model.buildForm(); - // }); - - - - // if (this.form.get('multiplicity')) { - // if (this.form.get('multiplicity').value.min > 1 && this.form.get('multiplicity').value.max > 1) { - // this.isFieldMultiplicityEnabled = true; - // } - // } - - const renderStyle = this.form.get('viewStyle').get('renderStyle').value; - if (renderStyle) { - - // this.matcher.setReference(this.form); - const type = this.form.get('viewStyle').get('renderStyle').value; - - switch (type) { - case DatasetProfileFieldViewStyle.BooleanDecision: - this.viewType = this.viewTypeEnum.BooleanDecision; - break; - case DatasetProfileFieldViewStyle.CheckBox: - this.viewType = this.viewTypeEnum.CheckBox; - break; - case DatasetProfileFieldViewStyle.ComboBox: - - const comboType = this.form.get('data').get('type').value; - if (comboType === DatasetProfileComboBoxType.Autocomplete) { - this.viewType = this.viewTypeEnum.Other; - } else if (comboType === DatasetProfileComboBoxType.WordList) { - this.viewType = this.viewTypeEnum.Select; - } - break; - case DatasetProfileFieldViewStyle.InternalDmpEntities: - this.viewType = this.viewTypeEnum.InternalDmpEntities; - break; - case DatasetProfileFieldViewStyle.FreeText: - this.viewType = this.viewTypeEnum.FreeText; - break; - case DatasetProfileFieldViewStyle.RadioBox: - this.viewType = this.viewTypeEnum.RadioBox; - break; - case DatasetProfileFieldViewStyle.TextArea: - this.viewType = this.viewTypeEnum.TextArea; - break; - case DatasetProfileFieldViewStyle.RichTextArea: - this.viewType = this.viewTypeEnum.RichTextArea; - break; - case DatasetProfileFieldViewStyle.Upload: - this.viewType = this.viewTypeEnum.Upload; - break; - case DatasetProfileFieldViewStyle.Table: - this.viewType = this.viewTypeEnum.Table; - break; - case DatasetProfileFieldViewStyle.DatePicker: - this.viewType = this.viewTypeEnum.DatePicker; - break; - case DatasetProfileFieldViewStyle.ExternalDatasets: - this.viewType = this.viewTypeEnum.ExternalDatasets; - break; - case DatasetProfileFieldViewStyle.DataRepositories: - this.viewType = this.viewTypeEnum.DataRepositories; - break; - case DatasetProfileFieldViewStyle.PubRepositories: - this.viewType = this.viewTypeEnum.PubRepositories; - break; - case DatasetProfileFieldViewStyle.JournalRepositories: - this.viewType = this.viewTypeEnum.JournalRepositories; - break; - case DatasetProfileFieldViewStyle.Taxonomies: - this.viewType = this.viewTypeEnum.Taxonomies; - break; - case DatasetProfileFieldViewStyle.Licenses: - this.viewType = this.viewTypeEnum.Licenses; - break; - case DatasetProfileFieldViewStyle.Publications: - this.viewType = this.viewTypeEnum.Publications; - break; - case DatasetProfileFieldViewStyle.Registries: - this.viewType = this.viewTypeEnum.Registries; - break; - case DatasetProfileFieldViewStyle.Services: - this.viewType = this.viewTypeEnum.Services; - break; - case DatasetProfileFieldViewStyle.Tags: - this.viewType = this.viewTypeEnum.Tags; - break; - case DatasetProfileFieldViewStyle.Researchers: - this.viewType = this.viewTypeEnum.Researchers; //TODO RESEARCHERS - break; - case DatasetProfileFieldViewStyle.Organizations: - this.viewType = this.viewTypeEnum.Organizations; - break; - case DatasetProfileFieldViewStyle.DatasetIdentifier: - this.viewType = this.viewTypeEnum.DatasetIdentifier; - break; - case DatasetProfileFieldViewStyle.Currency: - this.viewType = this.viewTypeEnum.Currency; - break; - case DatasetProfileFieldViewStyle.Validation: - this.viewType = this.viewTypeEnum.Validation; - break; - } - if (this.viewType !== this.viewTypeEnum.FreeText) { - this.setValidator(ValidationType.URL, false); - } - } - - // this.showPreview = true; - - - - - // this.addNewRule(); - - // this.form.get('viewStyle').get('renderStyle').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => { - - - // // const previewStatus = this.showPreview; - // //!! Important to be before the if statement - // this.showPreview = false; - - // if (this.form.get('data')) { - // this.form.removeControl('data'); - - // switch (x) { - // case DatasetProfileFieldViewStyle.BooleanDecision: - // this.form.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.CheckBox: - // this.form.addControl('data', new CheckBoxFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.ComboBox: - // this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.InternalDmpEntities: - // this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.FreeText: - // this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.RadioBox: - // this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.TextArea: - // this.form.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.DatePicker: - // this.form.addControl('data', new DatePickerDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.ExternalDatasets: - // this.form.addControl('data', new ExternalDatasetsDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.DataRepositories: - // this.form.addControl('data', new DataRepositoriesDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Registries: - // this.form.addControl('data', new RegistriesDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Services: - // this.form.addControl('data', new ServicesDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Tags: - // this.form.addControl('data', new TagsDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Researchers: - // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Organizations: - // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.DatasetIdentifier: - // this.form.addControl('data', new DatasetIdentifierDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Currency: - // this.form.addControl('data', new CurrencyDataEditorModel().buildForm()); - // break; - // case DatasetProfileFieldViewStyle.Validation: - // this.form.addControl('data', new ValidationDataEditorModel().buildForm()); - // break; - // } - // } - - - // //reset the preview status - // // this.showPreview = previewStatus; - // this.showPreview = true; - // }); - } - - // defaulValueRequired(viewStile: DatasetProfileFieldViewStyle): boolean { - // switch (viewStile) { - // case DatasetProfileFieldViewStyle.CheckBox: - // return true; - // case DatasetProfileFieldViewStyle.RadioBox: - // case DatasetProfileFieldViewStyle.TextArea: - // case DatasetProfileFieldViewStyle.FreeText: - // case DatasetProfileFieldViewStyle.ComboBox: - // case DatasetProfileFieldViewStyle.InternalDmpEntities: - // case DatasetProfileFieldViewStyle.BooleanDecision: - // case DatasetProfileFieldViewStyle.DatePicker: - // case DatasetProfileFieldViewStyle.ExternalDatasets: - // case DatasetProfileFieldViewStyle.DataRepositories: - // case DatasetProfileFieldViewStyle.Registries: - // case DatasetProfileFieldViewStyle.Services: - // case DatasetProfileFieldViewStyle.Tags: - // case DatasetProfileFieldViewStyle.Registries: - // case DatasetProfileFieldViewStyle.Organizations: - // case DatasetProfileFieldViewStyle.DatasetIdentifier: - // case DatasetProfileFieldViewStyle.Currency: - // case DatasetProfileFieldViewStyle.Validation: - // return false; - // default: - // return false; - // } - // } - - - - // onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) { - // if (!isFieldMultiplicityEnabled) { - // (this.form.get('multiplicity').get('min')).setValue(0); - // (this.form.get('multiplicity').get('max')).setValue(0); - // } - // } - - addNewRule() { - const rule: RuleEditorModel = new RuleEditorModel(); - (this.form.get('visible').get('rules')).push(rule.buildForm()); - } - - - private _formChangesSubscription: Subscription; - private _showPreview: boolean = false; - - // get showPreview(): boolean{ - - // return this._showPreview; - // } - - // set showPreview(value:boolean){ - // if(value == false){//hide preview - // //close subsciption - // if(this._formChangesSubscription){ - // this._formChangesSubscription.unsubscribe(); - // this._formChangesSubscription = null; - // } - // } - - // if(value == true){ - // //value is already true - // if(this._showPreview){ - // if(this._formChangesSubscription){ - // this._formChangesSubscription.unsubscribe(); - // this._formChangesSubscription = null; - // } - // } - - // //initialize - // if(this.form.get('viewStyle').get('renderStyle').value){ - // this._generatePreviewForm(); - // } - // this._formChangesSubscription = this.form.valueChanges.subscribe(()=>{ - // this._generatePreviewForm(); - // }); - // } - // this._showPreview = value; - - // } - - // previewForm: FormGroup; - - // private _generatePreviewForm(){ - - // if(!this.form.get('data')){ - // return; - // } - // this.previewForm = null; - // const fieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // fieldEditorModel.viewStyle= { - // renderStyle: this.form.get('viewStyle').get('renderStyle').value, - // cssClass: null - // }; - - // fieldEditorModel.data = (this.form.get('data') as FormGroup).getRawValue(); - // fieldEditorModel.value = this.form.get('defaultValue').get('value').value; - // fieldEditorModel.validationRequired = (this.form.get('validations').value as Array).includes(ValidationType.Required); - - // if(this.form.get('viewStyle').get('renderStyle').value == DatasetProfileFieldViewStyle.CheckBox){ - // fieldEditorModel.value = this.form.get('defaultValue').get('value').value === 'true'; - // } - // // if(this.form.get('viewStyle').get('renderStyle').value == DatasetProfileFieldViewStyle.Researchers){ - // // fieldEditorModel.data = new ResearchersAutoCompleteFieldDataEditorModel().buildForm().getRawValue(); - // // } - // if(fieldEditorModel.viewStyle.renderStyle === DatasetProfileFieldViewStyle.Validation || (fieldEditorModel.viewStyle.renderStyle === DatasetProfileFieldViewStyle.DatasetIdentifier) - // || (fieldEditorModel.viewStyle.renderStyle === DatasetProfileFieldViewStyle.Tags) - // ){ - // fieldEditorModel.value = null; - // } - - // // const myTicket = Guid.create().toString(); - // // this.validTicket = myTicket; - // // setTimeout(() => { //TODO - // // //user hasnt make any new change to inputs /show preview - // // if(myTicket === this.validTicket){ - // // this.previewForm = fieldEditorModel.buildForm(); - // // } - // // }, 600); - - // this.subject$.next(fieldEditorModel); - - - // // setTimeout(() => { - // // this.previewForm = fieldEditorModel.buildForm(); - // // }); - // }; - - get canApplyVisibility(): boolean { - - - switch (this.viewType) { - case this.viewTypeEnum.TextArea: - case this.viewTypeEnum.RichTextArea: - case this.viewTypeEnum.Upload: - case this.viewTypeEnum.FreeText: - case this.viewTypeEnum.BooleanDecision: - case this.viewTypeEnum.RadioBox: - case this.viewTypeEnum.Select: - case this.viewTypeEnum.CheckBox: - case this.viewTypeEnum.DatePicker: - return true; - - } - - - return false; - - } - - // validTicket:string; - // generatePreview(){ - // const fieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // fieldEditorModel.viewStyle= { - // renderStyle: this.form.get('viewStyle').get('renderStyle').value, - // cssClass: null - // }; - // fieldEditorModel.defaultValue = this.form.get('defaultValue').value; - // switch (this.form.get('viewStyle').get('renderStyle').value) { - // case DatasetProfileFieldViewStyle.TextArea: - // fieldEditorModel.data = { - // label: this.form.get('data').get('label').value - // }; - // break; - - // default: - // break; - // } - - // // this.previewForm = fieldEditorModel.buildForm(); - - - // } - onInputTypeChange() { - - - const x = this.viewType; - - // this.showPreview = false; - - - - const field: Field = this.form.getRawValue(); - // field.defaultValue = {type:null, value: null}; - field.defaultValue = undefined; - if (!this.canApplyVisibility) { - field.visible.rules = []; - } - - - - // if (this.form.get('data')) { - // this.form.removeControl('data'); - // } - - // this.form.removeControl('defaultValue'); - // const defaultValueModel = new DefaultValueEditorModel(); - // this.form.addControl('defaultValue',defaultValueModel.buildForm()); - - switch (x) { - case this.viewTypeEnum.BooleanDecision: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.BooleanDecision) - // this.form.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm()); - - const data: BooleanDecisionFieldData = { - label: "" - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.BooleanDecision; - field.data = data; - - break; - } - case this.viewTypeEnum.CheckBox: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.CheckBox) - // this.form.addControl('data', new CheckBoxFieldDataEditorModel().buildForm()); - - const data: CheckBoxFieldData = { - label: '' - } - const defaultValue: DefaultValue = { - type: '', - value: 'false' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.CheckBox; - field.data = data; - field.defaultValue = defaultValue; - - break; - } - case this.viewTypeEnum.Select: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // this.form.addControl('data', new WordListFieldDataEditorModel().buildForm()); - - // this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // this.form.get('data').updateValueAndValidity(); - const option1 = { label: '', value: '' } as FieldDataOption; - - const data: WordListFieldData = { - label: '', - multiList: false, - options: [option1], - type: DatasetProfileComboBoxType.WordList - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } - case this.viewTypeEnum.Other: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox) - // this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE - - // this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - // this.form.get('data').updateValueAndValidity(); - - const data: AutoCompleteFieldData = { - autoCompleteSingleDataList: [], - multiAutoComplete: false, - label: '', - type: DatasetProfileComboBoxType.Autocomplete - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox; - field.data = data; - - break; - } - case this.viewTypeEnum.InternalDmpEntities: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.InternalDmpEntities) - // this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());//TODO TO SEE - - const data: DmpsAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Dmps - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities; - field.data = data; - - break; - } - case this.viewTypeEnum.FreeText: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.FreeText) - // this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm()); - - const data: FreeTextFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.FreeText; - field.data = data; - - break; - } - case this.viewTypeEnum.RadioBox: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox) - // this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm()); - - // this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - // this.form.get('data').updateValueAndValidity(); - - const data: RadioBoxFieldData = { - label: '', - options: [] - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RadioBox; - field.data = data; - - break; - } - case this.viewTypeEnum.TextArea: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea) - // this.form.addControl('data', new TextAreaFieldDataEditorModel().buildForm()); - - const data: TextAreaFieldData = { - label: '' - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.TextArea; - field.data = data; - break; - } - case this.viewTypeEnum.RichTextArea: { - const data: RichTextAreaFieldData = { - label: '' - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RichTextArea; - field.data = data; - break; - } - case this.viewTypeEnum.Upload: { - const data: UploadFieldData = { - label: '', - types: [], - maxFileSizeInMB: this.configurationService.maxFileSizeInMB - } - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Upload; - field.data = data; - break; - } - // case this.viewTypeEnum.Table:{ - // const data: TableFieldData = { - // label:'', - // headers: [], - // rows: [] - // } - // - // - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Table; - // field.data = data; - // break; - // } - case this.viewTypeEnum.DatePicker: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatePicker) - // this.form.addControl('data', new DatePickerDataEditorModel().buildForm()); - - const data: DatePickerFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatePicker; - field.data = data; - - break; - } - case this.viewTypeEnum.ExternalDatasets: { - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ExternalDatasets) - // this.form.addControl('data', new ExternalDatasetsDataEditorModel().buildForm()); - - const data: ExternalDatasetsFieldData = { - label: '', - multiAutoComplete: false - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ExternalDatasets; - field.data = data; - - break; - } - case this.viewTypeEnum.DataRepositories: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DataRepositories) - // this.form.addControl('data', new DataRepositoriesDataEditorModel().buildForm()); - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.PubRepositories: { - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.PubRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.JournalRepositories: { - - const data: DataRepositoriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.JournalRepositories; - field.data = data; - - break; - } - case this.viewTypeEnum.Taxonomies: { - - const data: TaxonomiesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Taxonomies; - field.data = data; - - break; - } - case this.viewTypeEnum.Licenses: { - - const data: LicensesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Licenses; - field.data = data; - - break; - } - case this.viewTypeEnum.Publications: { - - const data: PublicationsFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Publications; - field.data = data; - - break; - } - case this.viewTypeEnum.Registries: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Registries) - // this.form.addControl('data', new RegistriesDataEditorModel().buildForm()); - - const data: RegistriesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Registries; - field.data = data; - - break; - } - case this.viewTypeEnum.Services: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Services) - // this.form.addControl('data', new ServicesDataEditorModel().buildForm()); - - const data: ServicesFieldData = { - label: '', - multiAutoComplete: false - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Services; - field.data = data; - - break; - } - case this.viewTypeEnum.Tags: { - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Tags) - // this.form.addControl('data', new TagsDataEditorModel().buildForm()); - - const data: TagsFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Tags; - field.data = data; - - - break; - } - case this.viewTypeEnum.Researchers: { - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Researchers) - // // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); //TODO TO ASK - // this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm()); - - // field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - - const data: ResearchersAutoCompleteFieldData = { - label: '', - multiAutoComplete: false, - type: DatasetProfileInternalDmpEntitiesType.Researchers - } - - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers; - field.data = data; - - - break; - } - case this.viewTypeEnum.Organizations: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Organizations) - // this.form.addControl('data', new OrganizationsDataEditorModel().buildForm()); - - const data = { - autoCompleteSingleDataList: [], - label: '', - multiAutoComplete: false, - - } as OrganizationsFieldData; //TODO - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Organizations; - field.data = data; - - break; - } - case this.viewTypeEnum.DatasetIdentifier: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatasetIdentifier) - // this.form.addControl('data', new DatasetIdentifierDataEditorModel().buildForm()); - - const data: DatasetIdentifierFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatasetIdentifier; - field.data = data; - - break; - } - case this.viewTypeEnum.Currency: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Currency) - // this.form.addControl('data', new CurrencyDataEditorModel().buildForm()); - - const data: CurrencyFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Currency; - field.data = data; - break; - } - case this.viewTypeEnum.Validation: { - - - // this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Validation) - // this.form.addControl('data', new ValidationDataEditorModel().buildForm()); - - const data: ValidationFieldData = { - label: '' - } - - field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Validation; - field.data = data; - - break; - } - } - - // this.form.get('data').updateValueAndValidity(); - // this.form.get('viewStyle').get('renderStyle').updateValueAndValidity(); - // this.form.updateValueAndValidity(); - - - const form = (new FieldEditorModel).fromModel(field).buildForm(); - - - const fields = this.form.parent as UntypedFormArray; - let index = -1; - - fields.controls.forEach((control, i) => { - if (this.form.get('id').value === control.get('id').value) { - index = i - } - }); - if (index >= 0) { - fields.removeAt(index); - fields.insert(index, form); - this.form = form; - - - } - - // setTimeout(() => { //TODO - // this.showPreview = true; - // }); - } - - - toggleRequired(event: MatSlideToggleChange) { - this.setValidator(ValidationType.Required, event.checked); - } - - toggleURL(event: MatSlideToggleChange) { - this.setValidator(ValidationType.URL, event.checked); - } - - private setValidator(validationType: ValidationType, add: boolean) { - let validationsControl = this.form.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - - if (add) { - if (!validations.includes(validationType)) { - validations.push(validationType); - validationsControl.updateValueAndValidity(); - } - } else { - validationsControl.setValue(validations.filter(validator => validator != validationType)); - validationsControl.updateValueAndValidity(); - } - this.form.markAsDirty();//deactivate guard - } - - get isRequired() { - let validationsControl = this.form.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - return validations.includes(ValidationType.Required); - } - - get isURL() { - let validationsControl = this.form.get('validations') as UntypedFormControl; - let validations: Array = validationsControl.value; - return validations.includes(ValidationType.URL); - } - - - onDelete() { - this.delete.emit(); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts deleted file mode 100644 index 6bec2f1d2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/view-style-enum.ts +++ /dev/null @@ -1,29 +0,0 @@ -export enum ViewStyleType{ - TextArea = "textarea", - RichTextArea = "richTextarea", - Upload = "upload", - Table = "table", - BooleanDecision = "booleanDecision", - CheckBox = "checkBox", - FreeText = "freetext", - RadioBox = "radiobox", - DatePicker = "datePicker", - InternalDmpEntities = "internalDmpEntities", - ExternalDatasets = "externalDatasets", - DataRepositories = "dataRepositories", - PubRepositories = "pubRepositories", - JournalRepositories = "journalRepositories", - Taxonomies = "taxonomies", - Licenses = "licenses", - Publications = "publications", - Registries = "registries", - Services = "services", - Tags = "tags", - Researchers = "researchers", - Organizations = "organizations", - DatasetIdentifier = "datasetIdentifier", - Currency = "currency", - Validation = 'validation', - Select ="selection", - Other ="other" -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html deleted file mode 100644 index 39882e08c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts deleted file mode 100644 index d2ba708e6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/final-preview/final-preview.component.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Component, Input, OnInit} from '@angular/core'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - - -@Component({ - selector: 'app-final-preview-component', - templateUrl: './final-preview.component.html', - styleUrls: ['./final-preview.component.scss'], - providers:[VisibilityRulesService] -}) - -export class FinalPreviewComponent implements OnInit { - - - @Input() formGroup = null; - @Input() visibilityRules:Rule[] = []; - constructor(private visibilityRulesService: VisibilityRulesService){ - - } - - - - ngOnInit(): void { - this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.formGroup); - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html deleted file mode 100644 index 9017f02f1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.html +++ /dev/null @@ -1,13 +0,0 @@ - - {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.PAGE-PREFIX' | translate}} {{i + 1}} -
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss deleted file mode 100644 index 135c7a3f6..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.page-card { - margin-bottom: 1em; - - .page-card-title { - text-align: center; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts deleted file mode 100644 index 8ef8a40f2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/page/dataset-profile-editor-page.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormArray } from '@angular/forms'; - -@Component({ - selector: 'app-dataset-profile-editor-page-component', - templateUrl: './dataset-profile-editor-page.component.html', - styleUrls: ['./dataset-profile-editor-page.component.scss'] -}) -export class DatasetProfileEditorPageComponent { - - @Input() form: UntypedFormArray; - @Input() viewOnly: boolean; - - removePage(index) { - (this.form).removeAt(index); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html deleted file mode 100644 index dd2a26762..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html +++ /dev/null @@ -1,99 +0,0 @@ -
- {{i + 1}} - - - - - - - - - - - - - - - - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-THEN'| translate}} - - - - - - - - {{option.label? option.label:'<'+ ('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) + '>'}} -
- - {{option.id}} - -
-
- - - - - {{option.label? option.label:'<'+ ('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) + '>'}} -
- - {{option.id}} - -
-
- - -
- {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
- -
-
-
- - - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss deleted file mode 100644 index 3db0dee74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.full-width { - width: 100%; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts deleted file mode 100644 index 645853d74..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; -import { UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileComboBoxType } from '../../../../../../core/common/enum/dataset-profile-combo-box-type'; -import { ToCEntryType } from '../../../table-of-contents/table-of-contents-entry'; -import { Rule } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { TranslateService } from '@ngx-translate/core'; - -@Component({ - selector: 'app-dataset-profile-editor-rule-component', - templateUrl: './dataset-profile-editor-rule.component.html', - styleUrls: ['./dataset-profile-editor-rule.component.scss'] -}) - -export class DatasetProfileEditorRuleComponent implements OnInit { - - - @Input() form: UntypedFormArray; - - @Input() viewStyleForCheck: DatasetProfileFieldViewStyle; - @Input() formControlForCheck: UntypedFormControl; - @Input() formArrayOptionsForCheck: UntypedFormArray; - @Input() comboBoxTypeForCheck: DatasetProfileComboBoxType; - @Input() viewOnly: boolean; - - - options: OptionItem[]; - sectionOptions: OptionItem[]; - fieldSetOptions: OptionItem[]; - fieldOptions: OptionItem[]; - - parentIds: string[] = []; - hiddenBy: string[] = []; - - constructor(private language: TranslateService){ - - } - - targetValidation() { - //TODO - } - - deleteRule(index) { - this.form.removeAt(index); - this.form.markAsDirty();//deactivate guard - } - - ngOnInit(): void { - this._computeOptions(); - } - - private _computeOptions(){ - this.options = this.getOptions(); - - this.sectionOptions = []; - this.fieldOptions = []; - this.fieldSetOptions = []; - this.options.forEach(option=>{ - switch (option.type) { - case ToCEntryType.Field: - this.fieldOptions.push(option); - break; - case ToCEntryType.FieldSet: - this.fieldSetOptions.push(option); - break; - case ToCEntryType.Section: - this.sectionOptions.push(option); - break; - default: - break; - } - }); - //remove options to hide if given fieldset is already hidden by option - - this.fieldOptions.forEach(e=>this._buildHiddenBy(e)); - this.fieldSetOptions.forEach(e=>this._buildHiddenBy(e)); - this.parentIds = this.computeParentIds(); - this.hiddenBy = this.computeHiddenBy(); - } - - - - computeOptions(isOpened: boolean){ - if(isOpened){ - this._computeOptions(); - } - } - - private _buildHiddenBy(fo:OptionItem){ - try{ - this.fieldOptions.forEach(foption=>{ - const rules = (foption.form.get('visible').get('rules') as UntypedFormArray).controls.map(c=>(c as UntypedFormGroup).getRawValue()) as Rule[] - const targets = rules.map(rule=>rule.target); - targets.forEach(target=>{ - if(fo.parentsIds.includes(target) && !fo.hiddenBy.includes(foption.id)){ - fo.hiddenBy.push(...foption.parentsIds); - } - }) - - }); - }catch{ - console.log('error'); - } - } - - - - - - getOptions():OptionItem[]{ - const rootForm = this.form.root; - if(rootForm){ - // const parentSections = rootForm.get('sections') as FormArray; - - const result:OptionItem[] =[]; - - const sections = rootForm.get('sections') as UntypedFormArray; - - if(sections){ - sections.controls.forEach(section=>{ - const subResult = this.buildOptions(section as UntypedFormGroup, ToCEntryType.Section,[]); - result.push(...subResult); - }); - } - - //return options - return result; - - } - //nothing found - return []; - } - - private buildOptions(form: UntypedFormGroup, type: ToCEntryType, parentIds:string[]):OptionItem[]{ - - const sections = form.get('sections') as UntypedFormArray; - const fieldSets = form.get('fieldSets') as UntypedFormArray; - const fields = form.get('fields') as UntypedFormArray; - - const result:OptionItem[] = []; - - // parentIds.push(form.get('id').value); - const currentOptionItem:OptionItem = { - id: form.get('id').value, - type: type, - label: type ===ToCEntryType.Field? form.get('data').get('label').value :form.get('title').value, - // parentsIds: [form.get('id').value] - parentsIds: [...parentIds, form.get('id').value], - form: form, - hiddenBy:[] - } - result.push(currentOptionItem); - - if(sections){ - sections.controls.forEach(section=>{ - result.push( ...this.buildOptions(section as UntypedFormGroup, ToCEntryType.Section, currentOptionItem.parentsIds) ); - }); - } - if(fieldSets){ - fieldSets.controls.forEach(fieldset=>{ - result.push( ...this.buildOptions(fieldset as UntypedFormGroup, ToCEntryType.FieldSet, currentOptionItem.parentsIds) ); - }); - } - if(fields){ - fields.controls.forEach(field=>{ - result.push( ...this.buildOptions(field as UntypedFormGroup, ToCEntryType.Field, currentOptionItem.parentsIds) ); //TODO NA TO DOUME - }); - } - - return result; - } - - // get parentIds(): string[]{ - - - // } - // get hiddenBy(): string[]{ - - // } - - computeParentIds(): string[]{ - if(!this.formControlForCheck.get('id')) return []; - - const current = this.options.find(opt=> opt.id === this.formControlForCheck.get('id').value); - - if(current){ - return current.parentsIds; - } - return []; - } - - computeHiddenBy(): string[]{ - if(!this.formControlForCheck.get('id')) return []; - - const current = this.options.find(opt=> opt.id === this.formControlForCheck.get('id').value); - - if(current){ - return current.hiddenBy; - } - return []; - } - - getToolTipMessage(id: string){ - if(this.parentIds.includes(id)){ - // return 'Cannot hide element that contain the field'; - return this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.HINTS.ELEMENT-CHILD-OF-TARGET'); - }else if(this.hiddenBy.includes(id)){ - return this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.HINTS.ELEMENT-HIDDEN-FROM-ELEMENT'); - } - return ''; - } - -} - - -interface OptionItem{ - id: string, - label: string, - type: ToCEntryType, - parentsIds: string[], - form:UntypedFormGroup, - hiddenBy:string[] -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html deleted file mode 100644 index d57310531..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html +++ /dev/null @@ -1,173 +0,0 @@ -
-
- - -
-
- -
- - - - - - -
-
- Add Question icon - {{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.NEW-INPUT-SET' | translate}} -
-
-
-
- -
- -
-
-
- -
- - -
- -
- - - - - -
-
-
- - - - - drag_indicator - - - - - -
- -
-
- -
-
-
-
-
- Add Question icon - {{'DATASET-PROFILE-EDITOR.STEPS.TOOLKIT.NEW-INPUT-SET' | translate}} -
-
-
- - - - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss deleted file mode 100644 index 4870b869e..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.scss +++ /dev/null @@ -1,80 +0,0 @@ -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; - - -.field-container-active{ - border-radius: .3em; - border-left: 0.3em solid $blue-color; -} -.fieldset-actions-list li{ - cursor: pointer; -} -.fieldset{ - .add-question{ - cursor: pointer; - visibility: hidden; - transition-property: visibility; - transition-delay: 20ms; - transition-timing-function: ease; - transition-duration: 200ms; - } -} -.fieldset:hover{ - .add-question{ - visibility: visible; - } -} -.question-icon{ - width: 20px; -} -.stick-list{ - position: sticky; - top: 7em; -} -.actions-list{ - // border: 1px solid $blue-color; - // box-shadow: 0px 3px 12px var(--primary-color)99; - border-radius: 4px; - // padding-top: 1rem; - padding: 1em 0.9em; - padding-bottom: 3em; - min-width: 166px; - box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%); - - .mat-list-item-content{ - padding: 0px; - } - - - .action-list-item{ - display: flex; - align-items: center; - cursor: pointer; - - - .action-list-icon{ - font-size: 1.2em; - // padding-right: 1em; - width: 14px; - margin-right: 0.5em; - margin-left: -.09em; - height: auto; - color: var(--primary-color);; - } - .input_icon{ - width: 14px; - margin-right: .5em; - } - .action-list-text{ - font-size: 0.9em; - } - } - .action-list-label{ - color: #212121; - font-size: small; - opacity: 0.6; - } - .list-unstyled{ - margin-bottom: 0.2rem; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts deleted file mode 100644 index 3e45e2c28..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts +++ /dev/null @@ -1,269 +0,0 @@ -import { OnDestroy } from '@angular/core'; -import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { Guid } from '@common/types/guid'; -import { isNullOrUndefined } from '@swimlane/ngx-datatable'; -import { DragulaService } from 'ng2-dragula'; -import { pipe, Subject, Subscription } from 'rxjs'; -import { debounceTime, delay, tap } from 'rxjs/operators'; -import { FieldEditorModel } from '../../../admin/field-editor-model'; -import { FieldSetEditorModel } from '../../../admin/field-set-editor-model'; -import { ToCEntry, ToCEntryType } from '../../../table-of-contents/table-of-contents-entry'; -import { GENERAL_ANIMATIONS } from '../../animations/animations'; - -@Component({ - selector: 'app-dataset-profile-editor-section-fieldset-component', - templateUrl: './dataset-profile-editor-section-fieldset.component.html', - styleUrls: ['./dataset-profile-editor-section-fieldset.component.scss'], - animations:[GENERAL_ANIMATIONS] -}) - -export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnChanges, OnDestroy { - // @Input() form: FormGroup; - //@Input() dataModel: SectionEditorModel; - // @Input() indexPath: string; - @Input() viewOnly: boolean; - // @Input() numbering: string; - @Input() tocentry: ToCEntry; - - @Input() datasetProfileId?: string; - - @Output() selectedEntryId = new EventEmitter(); - @Output() dataNeedsRefresh = new EventEmitter (); - @Output() removeFieldSet = new EventEmitter(); - @Output() addNewFieldSet = new EventEmitter(); - @Output() cloneFieldSet = new EventEmitter(); - - - // FIELDSET_PREFIX_ID="FIELDSET_PREFIX_ID"; - - // @Output() fieldsetAdded = new EventEmitter(); //returns the id of the fieldset added - idprefix = "id"; - readonly dragula_prefix = "dragulaid"; - private subs = new Subscription(); - private FIELDSETS = 'FIELDSETS'; - - private initializer = new Subject(); - private scroller = new Subject(); - // private $selectedFieldsetId = new Subject(); - constructor( - private dragulaService: DragulaService, - private myElement: ElementRef - ) - { - if(this.dragulaService.find(this.FIELDSETS)){ - this.dragulaService.destroy(this.FIELDSETS); - } - - - this.dragulaService.createGroup(this.FIELDSETS,{ - moves:(el, container, handle)=>{ - // if(this.viewOnly) return false; //uncomment if want to unable drag n drop in viewonly mode - if(el.id != (this.dragula_prefix+this.tocentry.id)) return false; - if(handle.className && handle.classList.contains('handle')) return true; - return false; - } - }); - this.subs.add(this.dragulaService.drop(this.FIELDSETS).subscribe(obs=>{ - - - (this.form.get('fieldSets') as UntypedFormArray).controls.forEach((e,i)=>{ - e.get('ordinal').setValue(i); - }); - - - // obs. - this.dataNeedsRefresh.emit(); - return ; - })); - const initializerSub = this.initializer - .pipe( - debounceTime(100) - ) - .subscribe(() =>{ - this.initialize(); - }); - this.subs.add(initializerSub); - this.subs.add( - this.scroller - .pipe(debounceTime(700)) - .subscribe(id => { - if(isNullOrUndefined(id)){ - this._scrollOnTop(); - return ; - } - this._scrollToElement(id); - }) - ); - - // this.subs.add( - // this.$selectedFieldsetId - // .pipe( - // debounceTime(100) - // ) - // .subscribe(id => this.selectedEntryId.emit(id)) - // ); - - } - ngOnDestroy(){ - // console.log('elemement destroyed -->'); - - this.subs.unsubscribe(); - } - ngOnChanges(changes: SimpleChanges): void { - this.initializer.next(); - } - - - form; - numbering; - - - - private _selectedFieldSetId: string = null; - get selectedFieldSetId(){ - return this._selectedFieldSetId; - } - set selectedFieldSetId(id: string){ - - if(id === this._selectedFieldSetId) return; - this._selectedFieldSetId = id; - this.selectedEntryId.emit(id); - } - - - - - - // private _findParentSection():FormGroup{ - // const parent = this.form.parent; - - // return parent; - // } - - - private initialize(){ - if(this.tocentry.type === ToCEntryType.Section){ - this.form = this.tocentry.form; - this.numbering = this.tocentry.numbering; - this._selectedFieldSetId = null; - - // this.scroller.next(null); - this._scrollOnTop(true); - }else if(this.tocentry.type === ToCEntryType.FieldSet){ - this.form = this.tocentry.form.parent.parent; - const numberingArray = this.tocentry.numbering.split('.'); - if(numberingArray.length){ - numberingArray.splice(numberingArray.length-1); - this.numbering = numberingArray.join('.'); - }else{ - // console.warn('!not found numbering'); - } - this._selectedFieldSetId = this.tocentry.id; - - // this._scrollToElement(this.selectedFieldSetId); - this.scroller.next(this.tocentry.id); - }else{//scroll on top - // this._scrollOnTop(); - this.scroller.next(null); - } - } - - private _scrollToElement(id: string){ - let el = this.myElement.nativeElement.querySelector("#"+this.idprefix+id); - if(el){ - el.scrollIntoView({behavior: "smooth", block:'start'}); - } - } - private _scrollOnTop(instant?: boolean){ - const el = this.myElement.nativeElement.querySelector('#topofcontainer'); - if(el){ - if(instant){ - el.scrollIntoView({ block:'end'}); - }else{ - el.scrollIntoView({behavior:'smooth', block:'end'}); - } - } - } - ngOnInit() { - - } - - onRemoveFieldSet(fieldsetId: string){ - this.removeFieldSet.emit(fieldsetId); - } - - onCloneFieldSet(fieldset: UntypedFormGroup){ - this.cloneFieldSet.emit(fieldset); - } - onAddFieldSet(){ - // this.addNewFieldSet.emit(this.form); - try{ - const length = (this.form.get('fieldSets') as UntypedFormArray).length; - if(length === 0){ - this.addFieldSetAfter(-9999, 0); - return; - } - else{ - const lastElement = (this.form.get('fieldSets') as UntypedFormArray).at(length -1); - this.addFieldSetAfter(lastElement.get('ordinal').value, length-1); - } - } catch {} - } - - addFieldSetAfter(afterOrdinal: number, afterIndex: number):void{ - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first filed in the fields list - const fieldForm = field.buildForm(); - - //give fieldset id and ordinal - const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); - const fieldSetId = Guid.create().toString(); - fieldSet.id = fieldSetId; - fieldSet.ordinal = afterOrdinal < 0? 0 :afterOrdinal; - - const parentArray = this.form.get('fieldSets') as UntypedFormArray; - - parentArray.controls.forEach(fieldset=>{ - const ordinalControl = fieldset.get('ordinal'); - const ordinalValue = ordinalControl.value; - if(ordinalValue > afterOrdinal){ - ordinalControl.setValue(ordinalValue +1); - } - }); - const fieldsetForm = fieldSet.buildForm(); - (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); - - const index = afterOrdinal < 0 ? 0: afterIndex +1; - parentArray.insert(index, fieldsetForm); - this.dataNeedsRefresh.emit(); - - // this.selectedFieldSetId = fieldSetId; - setTimeout(() => { - this.selectedFieldSetId = fieldSetId; - }, 200); - } - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html deleted file mode 100644 index 391dd4238..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html +++ /dev/null @@ -1,95 +0,0 @@ -
- - - - - -
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-NAME' | translate}} *
-
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-NAME-HINT' | translate}}
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - -
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION' | translate}}
-
{{'DATASET-PROFILE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION-HINT' | translate}}
-
- - -
- - - - - - - - - - - - - - - - -
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss deleted file mode 100644 index 7645fb831..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.scss +++ /dev/null @@ -1,31 +0,0 @@ -.dataset-profile-editor { - - - .field-card { - margin-bottom: 1em; - } -} -.deleteBtn{ - margin-right:2em; -} - -.heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - // margin-top: 1.625rem; - margin-bottom: 0.625rem; -} - -.hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 0.125rem; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts deleted file mode 100644 index c608c731b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { FieldEditorModel } from '@app/ui/admin/dataset-profile/admin/field-editor-model'; -import { FieldSetEditorModel } from '@app/ui/admin/dataset-profile/admin/field-set-editor-model'; -import { SectionEditorModel } from '@app/ui/admin/dataset-profile/admin/section-editor-model'; -import { BaseComponent } from '@common/base/base.component'; -import { Guid } from '@common/types/guid'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-editor-section-component', - templateUrl: './dataset-profile-editor-section.component.html', - styleUrls: ['./dataset-profile-editor-section.component.scss'] -}) - -export class DatasetProfileEditorSectionComponent extends BaseComponent implements OnInit { - - @Input() form: UntypedFormGroup; - //@Input() dataModel: SectionEditorModel; - @Input() indexPath: string; - @Input() viewOnly: boolean; - @Output() fieldsetAdded = new EventEmitter(); //returns the id of the fieldset added - - constructor() { super(); } - - ngOnInit() { - - //TODO - // this.form.root.get('pages').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => - // this.keepPageSelectionValid(x) - // ); - } - - addField() { - const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); - fieldSet.ordinal = (this.form.get('fieldSets') as UntypedFormArray).length; - - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first field in fields - fieldSet.fields.push(field); - // if (this.dataModel.fieldSets) { - fieldSet.id = Guid.create().toString(); - //this.dataModel.fieldSets.push(fieldSet); - //} - const fieldsetsArray = this.form.get('fieldSets') as UntypedFormArray; - fieldsetsArray.push(fieldSet.buildForm()); - - const fieldSetForm = fieldsetsArray.at(fieldsetsArray.length-1); - //emit id inserted - if(fieldSetForm){ - const id: string = fieldSetForm.get('id').value; - this.fieldsetAdded.emit(id); - } - } - - addSectioninSection() { - const section: SectionEditorModel = new SectionEditorModel(); - //this.dataModel.sections.push(section); - (this.form.get('sections')).push(section.buildForm()); - } - - DeleteSectionInSection(index) { - //this.dataModel.sections.splice(index, 1); - (this.form.get('sections')).removeAt(index); - } - - deleteFieldSet(index) { - //this.dataModel.fieldSets.splice(index, 1); - (this.form.get('fieldSets')).removeAt(index); - } - - keepPageSelectionValid(pagesJson: Array) { - const selectedPage = this.form.get('page').value as String; - // const pages: Array = JsonSerializer.fromJSONArray(pagesJson, Page); - if (pagesJson.find(elem => elem.id === selectedPage) === undefined) { - this.form.get('page').reset(); - } - } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts deleted file mode 100644 index 94649b0bc..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/custom-validators/editor-custom-validators.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Inject, Injectable } from "@angular/core"; -import { AbstractControl, UntypedFormArray, ValidationErrors, ValidatorFn } from "@angular/forms"; - - -export class EditorCustomValidators{ - - static atLeastOneElementListValidator(arrayToCheck): ValidatorFn{ - return (control: AbstractControl): ValidationErrors | null=>{ - - const fa = control.get(arrayToCheck) as UntypedFormArray; - - if(!fa || fa.length === 0){ - return {[EditorCustomValidatorsEnum.emptyArray]: true}; - } - return null; - } - } - static pagesHaveAtLeastOneSection(pagesArrayName:string,sectionsArrayName:string ): ValidatorFn{ - - return (control: AbstractControl): ValidationErrors | null=>{ - - const pages = control.get(pagesArrayName) as UntypedFormArray; - const sections = control.get(sectionsArrayName) as UntypedFormArray; - - - const pageIdsArray = pages.controls.map(page=>page.get('id').value); - const sectionsPageIds = sections.controls.map(section=> section.get('page').value); - - let invalidMessage = null; - - pageIdsArray.forEach(pageId=>{ - if(!sectionsPageIds.includes(pageId)){ - invalidMessage = {[EditorCustomValidatorsEnum.atLeastOneSectionInPage]:true}; - } - }) - - return invalidMessage; - } - } - - static sectionHasAtLeastOneChildOf(fieldsetsArrayName, sectionsArrayName): ValidatorFn{ - - return (control: AbstractControl): ValidationErrors | null=>{ - - const fieldsets = control.get(fieldsetsArrayName) as UntypedFormArray; - const sections = control.get(sectionsArrayName) as UntypedFormArray; - - - if((fieldsets && fieldsets.length) || (sections && sections.length)){ - return null; - } - - return {[EditorCustomValidatorsEnum.sectionMustHaveOneChild] : true}; - } - } - - - -} - - - -export enum EditorCustomValidatorsEnum{ - sectionMustHaveOneChild = "sectionMustHaveOneChild", - atLeastOneSectionInPage = 'atLeastOneSectionInPage', - emptyArray="emptyArray" -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts deleted file mode 100644 index 4cd0066cf..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { UntypedFormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DatasetProfile } from '../../../../core/model/admin/dataset-profile/dataset-profile'; -import { BaseFormModel } from '../../../../core/model/base-form-model'; -import { PageEditorModel } from '../admin/page-editor-model'; -import { SectionEditorModel } from '../admin/section-editor-model'; -import { EditorCustomValidators } from './custom-validators/editor-custom-validators'; - - -export class DatasetProfileEditorModel extends BaseFormModel { - - public sections: Array = new Array(); - public pages: Array = new Array(); - public label: string; - public status: number; - public version: number; - private description: string; - private type: string; - private language: string; - private users: UserInfoListingModel[] = []; - - fromModel(item: DatasetProfile): DatasetProfileEditorModel { - if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } - if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); } - this.label = item.label; - this.type = item.type; - this.status = item.status; - this.version = item.version; - this.description = item.description; - this.language = item.language; - this.users = item.users; - return this; - } - - buildForm(disabled: boolean = false, skipDisable: Array = []): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({ - label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.label')) }, [Validators.required]], - description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]], - type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.type')) }, [Validators.required]], - language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]], - status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }], - version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }], - users: [{ value: this.users, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.users')) }] - }); - - const sectionsFormArray = new Array(); - this.sections.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - sectionsFormArray.push(form); - }); - formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - - const pagesFormArray = new Array(); - this.pages.forEach(item => { - const form: UntypedFormGroup = item.buildForm(disabled, skipDisable); - pagesFormArray.push(form); - }); - formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); - - formGroup.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages','sections')]); - formGroup.updateValueAndValidity(); - - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html deleted file mode 100644 index b943a4bb1..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ /dev/null @@ -1,522 +0,0 @@ - - -
-
- - - - - -
-
-
- -
-

{{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE' | translate}}

-

- {{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE-CLONE' | translate}} - {{form.get('label').value}} -

-

- {{'DATASET-PROFILE-EDITOR.TITLE.NEW-PROFILE-VERSION' | translate}} - {{form.get('label').value}} -

- -

{{form.get('label').value}}

-
- - - - -
-
- -
- - - -
-
- - - - - - -
-
-
-
- - - done - - - {{idx+1}} - - {{step.label}} - -
-
-
- - - - - - - - -
-
-
-
- - - - - - - - - -
-
-
-
1.1 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NAME'| translate}} *
-
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NAME-HINT'| translate}}
- - - {{'GENERAL.VALIDATION.REQUIRED' | - translate}} - - -
-
-
1.2 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-DESCRIPTION'| translate}} *
- -
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-DESCRIPTION-HINT'| translate}}
-
- - -
- - {{'GENERAL.VALIDATION.REQUIRED'| translate}} - -
-
-
- -
-
1.3 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-TYPE'| translate}} *
- - - - {{ type.name }} - - - {{'GENERAL.VALIDATION.REQUIRED' | - translate}} - - -
-
- -
1.4 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-LANGUAGE'| translate}} *
- - - - - {{ lang.name }} - - - {{'GENERAL.VALIDATION.REQUIRED' | - translate}} - - -
-
-
1.5 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}
-
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS-HINT'| translate}}
-
- - - - - - - - - - - - - - - - - - -
{{'USERS.LISTING.NAME' | translate}}{{'USERS.LISTING.EMAIL' | translate}}
{{user.name}}{{user.email}} - -
- {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-NO-USERS-YET' | translate}} -
-
-
- -
-
-
-
- - - -
-
- -
- -
-
-
- -
- - - -
-
- - -
- - -
- - -
- - -
-
- - - -
- -
- -
-
- - -
-
-
- -
-
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME' | translate}} *
-
{{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME-HINT' | translate}}
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
- -
- -
- - -
- -
-
- -
- - - -
- - -
- -
-
-
-
- {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.NOTHING-HERE-HINT'| translate}} -
-
-
-
- {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-START'| translate}} - - add - - {{'DATASET-PROFILE-EDITOR.STEPS.PAGE-INFO.ACTIONS.START-CREATING-PAGE-END'| translate}} - -
-
-
-
- -
-
-
- - -
-
- - - - -
-
-
- - - -
-
-
- - - -
-
- -
- - - - - - - - - - - - - - - arrow_upward - -
SCROLL
-
- - -
- - -
-
- - - - - - - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss deleted file mode 100644 index cd066b05f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.scss +++ /dev/null @@ -1,386 +0,0 @@ -.dataset-profile-editor { - //margin-top: 1.3rem; - - .full-width { - width: 100%; - } -} - -.deleteBtn{ - margin-right:2em; -} - - - -// REFACTORED CSS - -.stepper{ - background-color: transparent; - min-height: 500px; -} -.content-displayer{ - background-color: #fff; - border-radius: 7px; - box-shadow: 0px 1px 2px #bfbfbf; - padding: 0em; - // padding-top: 0em; - overflow: visible; - // min-height: 30em; -} - -.heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - // margin-top: 1.625rem; - margin-bottom: 0.625rem; -} - -.hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 0.125rem; -} - -//TO CHECK -:host ::ng-deep .mat-horizontal-content-container { - overflow: visible; - // padding: 0px; -} -:host ::ng-deep .mat-form-field-outline{ - background-color: #ffffff4f; -} - -:host ::ng-deep .mat-horizontal-stepper-header-container { - display: none !important; -} - -#progress{ - position: absolute; - height: 100%; - width: 100%; - clip-path: polygon(0 0, 0 0, 0 0, 0 0); - transition-property: clip-path; - transition-duration: 600ms; - transition-timing-function: ease-out; - transition-delay: 50ms; - box-shadow: 0px 1px 2px #bfbfbf; - background-color: var(--secondary-color); -} -#progress-container{ - box-shadow: 1px 1px 6px #00000029;; - // border-radius: .3em; -} -// .import-btn { -// background: #ffffff 0% 0% no-repeat padding-box; -// border-radius: 30px; -// // color: var(--primary-color); -// // border: 1px solid var(--primary-color); -// padding-left: 2em; -// padding-right: 2em; -// color: #000; -// border: 1px solid #000; -// } -.navigate-btn { - border-radius: 30px; - background-color: var(--secondary-color); - border: 1px solid transparent; - padding-left: 2em; - padding-right: 2em; - box-shadow: 0px 3px 6px #1E202029; - - transition-property: background-color, color; - transition-duration: 200ms; - transition-delay: 50ms; - transition-timing-function: ease-in-out; -} -.navigate-btn-disabled{ -background-color: #CBCBCB; -color: #FFF; -} - -.create-section-btn { - border-radius: 30px; - background-color: var(--secondary-color); - border: 1px solid transparent; - padding-left: 1em; - padding-right: 1em; - box-shadow: 0px 3px 6px #1E202029; - line-height: 1.7em; -} - - -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; - -.finalize-btn { - border-radius: 30px; - border: 1px solid var(--primary-color); - background: transparent; - padding-left: 2em; - padding-right: 2em; - box-shadow: 0px 3px 6px #1E202029; - color: var(--primary-color); -} -.template_action_btn{ - border-radius: 30px; - border: 1px solid var(--primary-color); - background: transparent; - //padding-left: 2em; - //padding-right: 2em; - height: 2.5em; - min-width: 110px; - width: auto; - box-shadow: 0px 3px 6px #1E202029; - color: var(--primary-color); - flex: 0 0 auto; - &.save-btn{ - background-color: var(--secondary-color); - border: 1px solid transparent; - //padding-left: 2em; - //padding-right: 2em; - box-shadow: 0px 3px 6px #1E202029; - color: #212121; - - transition-property: background-color, color; - transition-duration: 200ms; - transition-delay: 50ms; - transition-timing-function: ease-in-out; - } - &:disabled{ - background-color: #CBCBCB; - color: #FFF; - border: 0px; - } -} - - - - -.stepper-title-label{ - cursor: pointer; - transition-property: color, opacity; - transition-duration: 200ms; - transition-delay: 50ms; - transition-timing-function: ease-in-out; - color: #212121; - font-size: 0.9em; -} - -.stepper-title-label-locked{ - color: #DEDEDE; -} - -.stepper-title-label-completed{ - opacity: 0.5; -} -.page-infos{ - padding: 2em; -} -.mat-subheader{ - padding: 0px; -} - -//for the acitons list toolbar -// .mat-list-item.mat-list-item-with-avatar{ -// padding-left: 0em; -// } - - -.actions-list{ - // border: 1px solid $blue-color; - box-shadow: 0px 3px 12px var(--primary-color)99; - border-radius: 4px; - // padding-top: 1rem; - padding: 1em 0.9em; - min-width: 166px; - - .mat-list-item-content{ - padding: 0px; - } - - - .action-list-item{ - display: flex; - align-items: center; - cursor: pointer; - - - .action-list-icon{ - font-size: 1.2em; - // padding-right: 1em; - width: 14px; - margin-right: 0.5em; - margin-left: -.09em; - height: auto; - color: var(--primary-color);; - } - .input_icon{ - width: 14px; - margin-right: .5em; - } - .action-list-text{ - font-size: 0.9em; - } - } - .action-list-label{ - color: #212121; - font-size: small; - opacity: 0.6; - } - .list-unstyled{ - margin-bottom: 0.2rem; - } -} - - -// .mli{ -// height: auto; -// } - - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -.basic-info-input{ - margin-top: 2em; - margin-bottom: 2em; -} - -.delete-btn { - // background-color: rgba(255, 0, 0, 0.76); - // color: white; -} - -.email-input { - border-color: black; - border-style: solid; - border-width: thin; - border-radius: 4px; - margin-right: 5px; - background-color: white; - padding-top: 10px; - padding-bottom: 10px; -} - - -.user-table { - // border: thin solid rgb(179, 173, 173); - // border: 1px solid rgba(0, 0, 0, 0.12); - background-color: white; - border-radius: 4px; - padding-bottom: 1em; - box-shadow: -1px 1px 11px -3px #00000017; -} - -.user-table-header { - text-align: center; - display: revert; - background-color: rgb(243 245 248); - // background-color: #129d9811; -} - -.user-table-header th { - padding-top: 10px; - padding-bottom: 10px; - // border: thin solid darkgray; -} - -.user-table-row { - // display: revert; - background-color: #fafafa; - td{ - padding-top: .5em; - padding-bottom: .5em; - } - &:hover{ - background-color: #eef5f6; - } - border-top:1px solid rgba(0, 0, 0, 0.12); -} - -.user-table-row:nth-child(even) { - // background-color: silver; -} -.user-table-body{ - text-align: center; -} -.scroll-on-top{ - position: fixed; - bottom: 20em; - right: 2em; - color: var(--primary-color) !important; - cursor: pointer; - font-size: 1rem; - font-weight: 400; -} - -.floating-btn { - position: fixed; - bottom: 2em; - right: 2em; -} - -.progress-min-height { - min-height: 35px; -} - - -#stepper-navigation-wrapper{ - z-index: 99; - width: 100%; - #stepper-navigation{ - background-color: #f4f4f4; - z-index: 99; - } -} - -.actions-template{ - align-self:flex-end; - display: flex; - justify-content: space-between; - width: 100%; - padding-left: 15px; - padding-right: 15px; -} -.stepper-navigation-outer-wrapper{ - padding: 2em; - margin-bottom: 1em; - //background: #f4f4f4; - //position: sticky; - //top: 0.01em; - //z-index: 9999; -} - -#header-outer-wrapper { - padding-top: 1.3rem; - background: #f4f4f4; - position: sticky; - top: 0.01em; - z-index: 9999; -} - -#title-column{ - justify-content: space-between; - align-items: baseline; - padding-right: 15px; -} -.side-actions{ - display: flex; - height: 40vh; - position: sticky; - top: 2em; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts deleted file mode 100644 index 3ba2002a4..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ /dev/null @@ -1,2142 +0,0 @@ - -import { of as observableOf, Observable, combineLatest, BehaviorSubject,of } from 'rxjs'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { Component, OnInit, QueryList, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatStepper} from '@angular/material/stepper'; -import { ActivatedRoute, ParamMap, Router } from '@angular/router'; -import { TranslateService } from '@ngx-translate/core'; -import { debounceTime, filter, map, mergeMap, takeUntil, tap } from 'rxjs/operators'; -import * as FileSaver from 'file-saver'; -import { BaseComponent } from '@common/base/base.component'; -import { DatasetProfileEditorModel } from '@app/ui/admin/dataset-profile/editor/dataset-profile-editor-model'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { LoggingService } from '@app/core/services/logging/logging-service'; -import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; -import { DatasetProfile } from '@app/core/model/admin/dataset-profile/dataset-profile'; -import { DatasetProfileEnum } from '@app/core/common/enum/dataset-profile'; -import { SectionEditorModel } from '@app/ui/admin/dataset-profile/admin/section-editor-model'; -import { PageEditorModel } from '@app/ui/admin/dataset-profile/admin/page-editor-model'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { LanguageInfo } from '@app/core/model/language-info'; -import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; -import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { NewEntryType, ToCEntry, ToCEntryType } from '../table-of-contents/table-of-contents-entry'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FieldSetEditorModel } from '../admin/field-set-editor-model'; -import { Guid } from '@common/types/guid'; -import { FieldEditorModel } from '../admin/field-editor-model'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { CdkStep, StepperSelectionEvent } from '@angular/cdk/stepper'; -import { DatasetDescriptionCompositeFieldEditorModel, DatasetDescriptionFieldEditorModel, DatasetDescriptionSectionEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { SideNavService } from '@app/core/services/sidenav/side-nav.sevice'; -import { EditorCustomValidators, EditorCustomValidatorsEnum } from './custom-validators/editor-custom-validators'; -import { GENERAL_ANIMATIONS, STEPPER_ANIMATIONS } from './animations/animations'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { MatInput } from '@angular/material/input'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service'; -import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type'; -import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status'; -import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template-type.lookup'; -import { nameof } from 'ts-simple-nameof'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; - -const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json'); - -@Component({ - selector: 'app-dataset-profile-editor-component', - templateUrl: './dataset-profile-editor.component.html', - styleUrls: ['./dataset-profile-editor.component.scss'], - animations:[...STEPPER_ANIMATIONS, ...GENERAL_ANIMATIONS], - providers:[VisibilityRulesService] -}) -export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent implements OnInit { - - canDeactivate(): boolean { - return !this.form.dirty; - } - - isNew = true; - isNewVersion = false; - isClone = false; - isDeleted = false; - dataModel: DatasetProfileEditorModel; - form: UntypedFormGroup; - previewerFormGroup: UntypedFormGroup; - private datasetProfileId: string; - newVersionId: string; - dataWizardModel: DatasetWizardModel; - // breadCrumbs: Observable; - @ViewChild('stepper') stepper: MatStepper; - viewOnly = false; - nestedCount: number[] = []; - nestedIndex: number = 0; - errorMessages: string[] = []; - tocEntryEnumValues = ToCEntryType; - public userChipList:any[] = []; - displayedColumns: String[] = ['name', 'email', 'button']; - descriptionTemplateTypes: DescriptionTemplateType[] = []; - - colorizeInvalid:boolean = false; - inputUserState: 'untriggered'| 'triggered' = 'untriggered'; - private _inputUserField$:BehaviorSubject = new BehaviorSubject(false); - private _inputUserButton$:BehaviorSubject = new BehaviorSubject(false); - showScrollOnTopButton:boolean = true; - - private stepperNavigationObserver: IntersectionObserver; - - // customEditorValidators = new EditorCustomValidators(); - - // sectionIdPreviewed:string = null; - // currentSubForm:FormGroup = null; - // currentSectionIndex: number = null; - // currentSectionEditorModel: SectionEditorModel = null; - - constructor( - private datasetProfileService: DatasetProfileService, - private route: ActivatedRoute, - private router: Router, - private logger: LoggingService, - private uiNotificationService: UiNotificationService, - private language: TranslateService, - private dialog: MatDialog, - private languageInfoService: LanguageInfoService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private enumUtils: EnumUtils, - private datasetWizardService: DatasetWizardService, - private visibilityRulesService: VisibilityRulesService, - private fb: UntypedFormBuilder, - private sidenavService: SideNavService, - private userService: UserServiceOld, - private descriptionTemplateTypeService: DescriptionTemplateTypeService, - private fileUtils: FileUtils - ) { - super(); - // this.profileID = route.snapshot.params['id']; - // this.cloneId = route.snapshot.params['cloneid']; - } - - ngOnDestroy(){ - this.sidenavService.setStatus(true); - if(this.stepperNavigationObserver){ - this.stepperNavigationObserver.disconnect(); - this.stepperNavigationObserver = null; - } - } - - ngOnInit() { - this.sidenavService.setStatus(false); - this.matomoService.trackPageView('Admin: Dataset Profile Edit'); - this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((paramMap: ParamMap) => { - this.datasetProfileId = paramMap.get('id'); - const cloneId = paramMap.get('cloneid'); - this.newVersionId = paramMap.get('newversionid'); - - if (this.datasetProfileId != null) { - this.isNew = false; - this.datasetProfileService.getDatasetProfileById(this.datasetProfileId) - .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) - .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - this.form = this.dataModel.buildForm(true, skipDisable); - this.viewOnly = true; - } else { - this.form = this.dataModel.buildForm(); - } - this.prepareForm(); - } catch (error) { - this.logger.error('Could not parse MasterItem: ' + data); - console.log(error) - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) - ); - // this.breadCrumbs = observableOf([{ - // parentComponentName: 'DatasetProfileListingComponent', - // label: this.language.instant('NAV-BAR.TEMPLATE'), - // url: '/dataset-profiles/' + this.datasetProfileId - // }]); - } else if (cloneId != null) { - this.isClone = true; - this.datasetProfileService.clone(cloneId) - .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) - .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.dataModel.status = DatasetProfileEnum.SAVED; - this.form = this.dataModel.buildForm(); - this.prepareForm(); - } catch (error){ - this.logger.error('Could not parse MasterItem: ' + data); - this.logger.error(error); - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) - ); - } else if (this.newVersionId != null) { - this.isNewVersion = true; - this.datasetProfileService.getDatasetProfileById(this.newVersionId) - .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) - .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.form = this.dataModel.buildForm(); - this.form.get('version').setValue(this.form.get('version').value + 1); - // this.form.controls['label'].disable(); - // this.form.controls['description'].disable(); - // this.form.controls['language'].disable(); - this.prepareForm(); - } catch (error){ - this.logger.error('Could not parse MasterItem: ' + data); - this.logger.error(error); - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) - ); - } else { - this.dataModel = new DatasetProfileEditorModel(); - this.form = this.dataModel.buildForm(); - // this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]); - - if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - this.form.disable(); - this.viewOnly = true; - } - // this.addSection(); - // this.addPage(); - this.visibilityRulesService.buildVisibilityRules([],this.form); - setTimeout(() => { - this.steps = this.stepper.steps; - }); - this._initializeToCEntries(); - - } - }); - - this.getDescriptionTemplateTypes(); - - combineLatest(this._inputUserButton$.asObservable(),this._inputUserField$.asObservable()) - .pipe(takeUntil(this._destroyed)) - .pipe(debounceTime(400)) - .pipe(filter(_=> !_[0] && !_[1])) - .subscribe(_=>{ - // if(!this.userFormDisabled) - this.inputUserState = 'untriggered'; - }); - } - - private _initializeToCEntries(){ - const tocentries = this.refreshToCEntries();//tocentries are sorted based on their ordinal value - - this._updateOrdinals(tocentries); - - if(tocentries && tocentries.length){ - this.selectedTocEntry = tocentries[0]; - } - // setTimeout(() => { - // // const stepperNavigation = document.getElementById('stepper-navigation'); - // // const titleColumn = document.getElementById('title-column'); - // // const stepperNavigationWrapper = document.getElementById('stepper-navigation-wrapper'); - // - // if(titleColumn){ - // if(this.stepperNavigationObserver){ - // this.stepperNavigationObserver.disconnect(); - // this.stepperNavigationObserver = null; - // } - // this.stepperNavigationObserver = new IntersectionObserver((e)=>{ - // e.forEach(_=>{ - // if(_.isIntersecting){ - // this.showScrollOnTopButton = false; - // // stepperNavigation.classList.remove('fixed-navigation'); - // // stepperNavigationWrapper.classList.remove('fixed-navigation'); - // }else{ - // this.showScrollOnTopButton = true; - // // stepperNavigation.classList.add('fixed-navigation'); - // // stepperNavigationWrapper.classList.add('fixed-navigation'); - // } - // }) - // }, {root:null, rootMargin:'0px', threshold:0}); - // this.stepperNavigationObserver.observe(titleColumn); - // }else{ - // console.log('Could not load scroll On Top Observer') - // } - // }, 400); - // this._initializeFormValidity(tocentries); - - //Checking invalid visibilty RULES - const fieldsetEntries = this._getAllFieldSets(this.toCEntries); - const fieldSetHavingInvalidVisibilityRules:ToCEntry[] = fieldsetEntries - .filter(entry=>{ - const fieldsFormGroup = entry.form.get('fields'); - const invalid = (fieldsFormGroup as UntypedFormArray).controls.filter(field=>{ - return this.hasInvalidVisibilityRule(field as UntypedFormGroup); - - }); - if(invalid && invalid.length){ - return true; - } - return false; - }); - - - if(fieldSetHavingInvalidVisibilityRules.length){ - const occurences = fieldSetHavingInvalidVisibilityRules.map(record=>record.numbering).join(' , '); - this.dialog.open(ConfirmationDialogComponent, { - data:{ - message: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.MESSAGE-START')+occurences+ this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.MESSAGE-END'), - confirmButton: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.CONFIRM-YES'), - cancelButton: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.CONFIRM-NO') - }, - maxWidth:'30em' - }) - .afterClosed() - .subscribe(confirm=>{ - if(confirm){ - this.removeFieldSetVisibilityRules(fieldSetHavingInvalidVisibilityRules); - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.REMOVE-SUCCESS'), SnackBarNotificationLevel.Success); - - }else{ - console.log('User not confirmed'); - } - }) - } - - - } - - private removeFieldSetVisibilityRules(fieldsets:ToCEntry[]){ - - if(!fieldsets || !fieldsets.length) return; - - fieldsets.forEach(fieldset=>{ - if(fieldset.type != ToCEntryType.FieldSet){ - return; - } - const fields = fieldset.form.get('fields') as UntypedFormArray; - - fields.controls.forEach(fieldControl=>{ - if(this.hasInvalidVisibilityRule(fieldControl as UntypedFormGroup)){ - try{ - (fieldControl.get('visible').get('rules') as UntypedFormArray).clear(); - }catch{} - } - }) - - }) - - } - - private hasInvalidVisibilityRule(field: UntypedFormGroup):boolean{ - const renderStyle = field.get('viewStyle').get('renderStyle').value; - if(renderStyle && ![ - DatasetProfileFieldViewStyle.TextArea, - DatasetProfileFieldViewStyle.RichTextArea, - DatasetProfileFieldViewStyle.Upload, - DatasetProfileFieldViewStyle.FreeText, - DatasetProfileFieldViewStyle.BooleanDecision, - DatasetProfileFieldViewStyle.RadioBox, - DatasetProfileFieldViewStyle.CheckBox, - DatasetProfileFieldViewStyle.DatePicker, - DatasetProfileFieldViewStyle.ComboBox, - ].includes(renderStyle)){ - if(((renderStyle === DatasetProfileFieldViewStyle) && (field.get('data').get('type').value === DatasetProfileComboBoxType.WordList))){ - return false; - } - try{ - if(field.get('visible').get('rules').value.length){ - return true; - } - return false; - - }catch{ - return false; - } - }else{ - return false; - } - } - - - prepareForm() { - this.visibilityRulesService.buildVisibilityRules([],this.form); - // this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'),EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]); - // this.form.updateValueAndValidity(); - this.form.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(change => { - - // this.datasetProfileService.preview(this.form.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(dataset => { - // const datasetModel = new DatasetWizardModel(); - // datasetModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(dataset, DatasetProfileDefinitionModel); - // this.dataWizardModel = datasetModel; - // this.previewerFormGroup = this.dataWizardModel.buildForm().get('datasetProfileDefinition'); - // }); - }); - setTimeout(() => { - this.steps = this.stepper.steps; - }); - this._initializeToCEntries(); - // console.log(this.form.get('users').value); - if (this.form.get('users').value !== null && this.form.get('users').value !== undefined) { - this.userChipList = [...this.form.get('users').value]; - } else { - this.userChipList = []; - } - - } - - onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { - if (!isMultiplicityEnabled) { - (this.form.get('multiplicity').get('min')).setValue(0); - (this.form.get('multiplicity').get('max')).setValue(0); - } - } - - // addSection() { - // const section: SectionEditorModel = new SectionEditorModel(); - // this.dataModel.sections.push(section); - // (this.form.get('sections')).push(section.buildForm()); - // } - - // addPage() { - // const page: PageEditorModel = new PageEditorModel(this.dataModel.pages.length); - // this.dataModel.pages.push(page); - // (this.form.get('pages')).push(page.buildForm()); - // } - - // DeleteSection(index) { - // this.dataModel.sections.splice(index, 1); - // (this.form.get('sections')).removeAt(index); - // } - - onSubmit(close: boolean = false) { - let data = this.form.value; - - if (this.datasetProfileId) { - this.datasetProfileService.updateForm(this.datasetProfileId, data) - .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - this.afterSave(); - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); - },error=> this.onCallbackError(error)); - } else if (this.newVersionId) { - data.label = this.form.get('label').value; - data.description = this.form.get('description').value; - this.datasetProfileService.newVersion(this.newVersionId, data) - .pipe(takeUntil(this._destroyed)) - .subscribe((newVersionTemplateId: string) => { - this.afterSave(newVersionTemplateId); - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); - }, - error => this.onCallbackErrorNewVersion(error) - ); - } else { - if(this.form.get('status').value != DatasetStatus.Finalized){// forn created and finalized instantly - this.form.get('status').setValue(DatasetStatus.Draft); - } - data = this.form.value; - this.datasetProfileService.createForm(data) - .pipe(takeUntil(this._destroyed)) - .subscribe(newTemplateId => { - this.afterSave(newTemplateId); - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); - }, error=> this.onCallbackError(error)); - } - } - - afterSave(newId: string = null) { - if(newId) { - this.datasetProfileId = newId; - this.form.value.id = newId; - } - this.isNew = false; - this.newVersionId = null; - - // this.dataModel.fromModel(this.form.value); - // if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - // this.form = this.dataModel.buildForm(true, skipDisable); - // this.viewOnly = true; - // } else { - // this.form = this.dataModel.buildForm(); - // } - // this.prepareForm(); - } - - finalize() { - //const data = this.form.value; - this.form.get('status').setValue(DatasetProfileEnum.FINALIZED); - - this.onSubmit(true); - } - - updateFinalized(close: boolean = false) { - this.datasetProfileService.updateForm(this.datasetProfileId, this.form.getRawValue()) - .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - this.form.markAsPristine();//deactivate guard - if(close) { - this.router.navigate(['/dataset-profiles']); - } - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success) - },error=>this.onCallbackError(error)); - } - - showUpdateButton() { - return !this.isNew && this.dataModel.status === DatasetProfileEnum.FINALIZED; - } - - // isStepActive(step: number) { - // return this.stepper && this.stepper.selectedIndex === step; - // } - - // onCallbackSuccess(): void { - // this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - // this.router.navigate(['/master-items']); - // } - - onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) { - this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error); - } - - onCallbackError(errorResponse: HttpErrorResponse) { - // const error: HttpError = this.httpErrorHandlingService.getError(errorResponse); - // if (error.statusCode === 400) { - // this.masterItem.validationErrorModel.fromJSONObject(errorResponse.error); - // this.formService.validateAllFormFields(this.formGroup); - // } else { - this.uiNotificationService.snackBarNotification(errorResponse.message, SnackBarNotificationLevel.Warning); - // } - } - - // DELETE Function - public delete(): void { - if (this.datasetProfileId && !this.isNew) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - //this.form.get('status').setValue(DatasetProfileEnum.DELETED); - this.datasetProfileService.delete(this.datasetProfileId, this.form.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/dataset-profiles']); - }, - error => { - this.onCallbackError(error); - if (error.error.statusCode == 674) { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - } - } - ); - } - }); - } - } - - downloadXML(): void { - this.datasetProfileService.downloadXML(this.datasetProfileId) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - }); - } - - getDescriptionTemplateTypes(): DescriptionTemplateType[] { - let lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup(); - lookup.project = { - fields: [ - nameof(x => x.id), - nameof(x => x.name), - nameof(x => x.status) - ] - }; - this.descriptionTemplateTypeService.query(lookup).pipe(takeUntil(this._destroyed)) - .subscribe(types => { - this.descriptionTemplateTypes = types.items.filter(type => type.status === DescriptionTemplateTypeStatus.Finalized); - }); - return this.descriptionTemplateTypes; - } - - getLanguageInfos(): LanguageInfo[] { - return this.languageInfoService.getLanguageInfoValues(); - } - - checkFormValidation() { - this.colorizeInvalid = true; - this.printMyErrors(this.form); - - - // if (!this.form.valid) { - // this.nestedIndex = -1; - // this.form.markAllAsTouched(); - // this.printErrors(this.form); - // this.showValidationErrorsDialog(); - // this.nestedCount = []; - // this.nestedIndex = 0; - // this.errorMessages = []; - // } - } - - - //BEFORE REDESIGN - // printErrors(rootform: FormGroup) { - // if (!rootform.valid) { - // Object.keys(rootform.controls).forEach(key => { - // const errors = rootform.get(key).errors; - // if (errors !== null) { - // let numbering: string = ''; - // for (let j = 0; j < this.nestedCount.length; j++) { - // numbering += this.nestedCount[j]; - // if (j < this.nestedIndex) { - // numbering += '.'; - // } else { - // break; - // } - // } - // Object.keys(errors).forEach(keyError => { - // if (typeof errors[keyError] === 'boolean') { - // this.errorMessages.push(numbering + ' ' + key + ' is ' + keyError); - // } else { - // this.errorMessages.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); - // } - // }); - // } else { - // if (rootform.get(key) instanceof FormGroup) { - // this.printErrors(rootform.get(key)); - // } else if (rootform.get(key) instanceof FormArray) { - // this.nestedIndex++; - // this.nestedCount[this.nestedIndex] = 0; - // for (let childForm of (rootform.get(key)).controls) { - // this.nestedCount[this.nestedIndex]++; - // this.printErrors(childForm); - // } - // this.nestedCount[this.nestedIndex] = 0; - // this.nestedIndex--; - - // } - // } - // }); - // } - // } - - // private showValidationErrorsDialog(projectOnly?: boolean) { - // const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - // disableClose: true, - // autoFocus: false, - // restoreFocus: false, - // data: { - // errorMessages: this.errorMessages, - // projectOnly: projectOnly - // }, - // }); - // } - - - - - - - // links: Link[] = []; - - // getLinks(currentLinks: Link[]) { - // this.links = currentLinks; - // } - - - datasetWizardModel: DatasetWizardEditorModel; - formGroup: UntypedFormGroup; - getPreview() { - let data = this.form.getRawValue(); - this.datasetProfileService.preview(data).subscribe(x => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel({ - datasetProfileDefinition: x - }); - this.updateVisibilityRules(); - this.formGroup = this.datasetWizardModel.buildForm().get('datasetProfileDefinition'); - }); - //this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - //this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - // this.formGroup.disable(); - // this.viewOnly = true; - // } - //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - // this.registerFormListeners(); - // this.dmpValueChanged(null); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('DATASET-LISTING.ACTIONS.CREATE-NEW').toUpperCase(), - // url: '/datasets/new/' - // }]); - - - - // this.datasetWizardService.updateDatasetProfile(this.profileUpdateId) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(data => { - // this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - // this.needsUpdate(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // }, - // ] - // }]); - // this.formGroup = this.datasetWizardModel.buildForm(); - // this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - // this.formGroup.disable(); - // this.viewOnly = true; - // } - // // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - // this.loadDatasetProfiles(); - // }); - } - - private refreshToCEntries(): ToCEntry[]{ - this.toCEntries = this.getTocEntries(); - //update selected tocentry - if(this.selectedTocEntry){ - this.selectedTocEntry = this._findTocEntryById(this.selectedTocEntry.id, this.toCEntries); - } - // this.updateOrdinals(this.toCEntries); - // this._updateNumbering(this.toCEntries); - return this.toCEntries; - } - - /** - * Updates entries ordinal form value - * based on the index they have on the tocentry array. - * Tocentries that are on the same level have distinct ordinal value - * - * @param tocentries - * - */ - private _updateOrdinals(tocentries: ToCEntry[]){ - - if(!tocentries || !tocentries.length) return; - tocentries.forEach((e,idx)=>{ - const ordinalControl = e.form.get('ordinal'); - if(ordinalControl){ - ordinalControl.setValue(idx); - ordinalControl.updateValueAndValidity(); - } - this._updateOrdinals(e.subEntries); - }); - } - - //sort tocentries based on their ordinality - private _sortToCentries(entries: ToCEntry[]){ - if(!entries || !entries.length) return; - entries.sort(this._compareOrdinals); - entries.forEach(e=>{ - this._sortToCentries(e.subEntries) - }); - } - private _compareOrdinals(a, b){ - - const aValue = a.form.get('ordinal').value as number; - const bValue = b.form.get('ordinal').value as number; - - // if(!aValue || !bValue) return 0; - return aValue - bValue; - } - private _updateNumbering(entries:ToCEntry[], parentNumbering:string){ - if(!entries || !entries.length) return; - let prefix =''; - if(parentNumbering.length){ - prefix = parentNumbering + '.'; - } - entries.forEach((entry,index)=>{ - const numbering = prefix + (index+1); - entry.numbering = numbering; - this._updateNumbering(entry.subEntries, numbering); - }) - } - - toCEntries:ToCEntry[]; - - getTocEntries(): ToCEntry[] { - if (this.form == null) { return []; } - const result: ToCEntry[] = []; - - //build parent pages - (this.form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { - result.push({ - id: pageElement.get('id').value, - label: pageElement.get('title').value, - type: ToCEntryType.Page, - form: pageElement, - numbering: (i + 1).toString(), - subEntriesType: ToCEntryType.Section - } as ToCEntry) - }); - - // build first level sections - (this.form.get('sections') as UntypedFormArray).controls.forEach((sectionElement, i) => { - const currentSectionPageId = sectionElement.get('page').value; - const pageToAdd = result.filter(x => x.id == currentSectionPageId)[0]; - if (pageToAdd.subEntries == null) pageToAdd.subEntries = []; - - const item = { - id: sectionElement.get('id').value, - label: sectionElement.get('title').value, - type: ToCEntryType.Section, - form: sectionElement, - numbering: pageToAdd.numbering + '.' + (pageToAdd.subEntries.length +1) - } as ToCEntry; - const sectionItems = this.populateSections(sectionElement.get('sections') as UntypedFormArray, item.numbering); - const fieldSetItems = this.populateFieldSets(sectionElement.get('fieldSets') as UntypedFormArray, item.numbering); - if (sectionItems != null) { - item.subEntries = sectionItems; - item.subEntriesType = ToCEntryType.Section; - } - if (fieldSetItems != null) { - if (item.subEntries == null) { - item.subEntries = fieldSetItems; - } else { - item.subEntries.push(...fieldSetItems); - } - item.subEntriesType = ToCEntryType.FieldSet; - - } - pageToAdd.subEntries.push(item); - - }); - this._sortToCentries(result);//ordeby ordinal - this._updateNumbering(result, '');//update nubering if needed - return result; - } - - private populateSections(sections: UntypedFormArray, existingNumbering: string): ToCEntry[] { - if (sections == null || sections.controls == null || sections.controls.length == 0) { return null; } - - const result: ToCEntry[] = []; - sections.controls.forEach((sectionElement, i) => { - - const item = { - id: sectionElement.get('id').value, - label: sectionElement.get('title').value, - type: ToCEntryType.Section, - form: sectionElement, - numbering: existingNumbering + '.' + (i + 1) - } as ToCEntry; - const sectionItems = this.populateSections(sectionElement.get('sections') as UntypedFormArray, item.numbering); - const fieldSetItems = this.populateFieldSets(sectionElement.get('fieldSets') as UntypedFormArray, item.numbering); - if (sectionItems != null) { - item.subEntries = sectionItems; - item.subEntriesType = ToCEntryType.Section; - } - if (fieldSetItems != null) { - if (item.subEntries == null) { - item.subEntries = fieldSetItems; - } else { - item.subEntries.push(...fieldSetItems); - } - item.subEntriesType = ToCEntryType.FieldSet; - } - result.push(item); - }); - - return result; - } - - private populateFieldSets(fieldSets: UntypedFormArray, existingNumbering: string): ToCEntry[] { - if (fieldSets == null || fieldSets.controls == null || fieldSets.controls.length == 0) { return null; } - - const result: ToCEntry[] = []; - fieldSets.controls.forEach((fieldSetElement, i) => { - - result.push({ - id: fieldSetElement.get('id').value, - label: fieldSetElement.get('title').value, - type: ToCEntryType.FieldSet, - //subEntries: this.populateSections((fieldSetElement.get('fieldSets') as FormArray), existingNumbering + '.' + i), - form: fieldSetElement, - numbering: existingNumbering + '.' + (i + 1) - } as ToCEntry) - - }); - - return result; - } - - - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries || !tocentries.length){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } - addNewEntry(tce: NewEntryType) { - - const parent = tce.parent; - - //define entry type - switch (tce.childType) { - case ToCEntryType.Page: - const pagesArray = (this.form.get('pages') as UntypedFormArray); - - const page: PageEditorModel = new PageEditorModel(pagesArray.length); - const pageForm = page.buildForm(); - // this.dataModel.pages.push(page); - - pagesArray.push(pageForm); - // this.form.updateValueAndValidity(); - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(pageForm.get('id').value, this.toCEntries); - - break; - case ToCEntryType.Section: - - const section: SectionEditorModel = new SectionEditorModel(); - section.id = Guid.create().toString(); - let sectionsArray:UntypedFormArray; - - if (parent.type === ToCEntryType.Page) {//FIRST LEVEL SECTION - sectionsArray = this.form.get('sections') as UntypedFormArray; - - section.page = parent.id; - - try{ - const max = sectionsArray.controls.filter(control=>control.get('page').value === parent.id) - .map(control=>control.get('ordinal').value) - .reduce((a,b)=>Math.max(a,b)); - - section.ordinal = max + 1; - }catch{ - section.ordinal = sectionsArray.length; - - } - sectionsArray.push(section.buildForm()); - // this.form.updateValueAndValidity(); - - } else if( parent.type == ToCEntryType.Section) { //SUBSECTION OF SECTION - sectionsArray = parent.form.get('sections') as UntypedFormArray; - - //adding page parent MAYBE NOT NEEDED - section.page = parent.form.get('page').value; - try{ - const maxOrdinal = sectionsArray.controls.map(control=>control.get('ordinal').value).reduce((a,b)=>Math.max(a, b)); - section.ordinal = maxOrdinal+1; - }catch{ - section.ordinal = sectionsArray.length; - } - - sectionsArray.push(section.buildForm()); - // (child.form.parent as FormArray).push(section.buildForm()); - - }else{ - console.error('Section can only be child of a page or another section'); - } - - - const sectionAdded = sectionsArray.at(sectionsArray.length -1) as UntypedFormGroup; - // sectionAdded.setValidators(this.customEditorValidators.sectionHasAtLeastOneChildOf('fieldSets','sections')); - // sectionAdded.updateValueAndValidity(); - - - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(sectionAdded.get('id').value, this.toCEntries); - - break; - case ToCEntryType.FieldSet: - - //create one field form fieldset - const field: FieldEditorModel = new FieldEditorModel(); - field.id = Guid.create().toString(); - field.ordinal = 0;//first filed in the fields list - const fieldForm = field.buildForm(); - // fieldForm.setValidators(this.customFieldValidator()); - // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - - // fieldSet.fields.push(field); - // field.ordinal = fieldSet.fields.length-1; - - const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray - - //give fieldset id and ordinal - const fieldSet: FieldSetEditorModel = new FieldSetEditorModel(); - const fieldSetId = Guid.create().toString(); - fieldSet.id = fieldSetId; - - try{ - const maxOrdinal = fieldSetsArray.controls.map(control=>control.get('ordinal').value).reduce((a,b)=>Math.max(a, b)); - fieldSet.ordinal = maxOrdinal+1; - }catch{ - fieldSet.ordinal = fieldSetsArray.length; - } - const fieldsetForm = fieldSet.buildForm(); - - - - (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); - fieldSetsArray.push(fieldsetForm); - - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(fieldSetId, this.toCEntries); - // fieldForm.updateValueAndValidity(); - - break; - - default: - break; - } - - this.form.updateValueAndValidity(); - } - - - onRemoveEntry(tce: ToCEntry){ - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this._deleteEntry(tce); - } - }); - - } - - - private _deleteEntry(tce: ToCEntry) { - //define entry type - switch (tce.type) { - case ToCEntryType.Page: - const pages = this.form.get('pages') as UntypedFormArray; - - let pageIndex = -1; - //get the index - for (let i = 0; i < pages.length; i++) { - let page = pages.at(i) as UntypedFormGroup; - - if (page.controls.id.value === tce.id) { - pageIndex = i; - break; - } - } - - if (pageIndex >= 0) { - //remove page - this._updateSelectedItem(tce); - pages.removeAt(pageIndex); - //clean up sections of removed page - - const sections = (this.form.get('sections') as UntypedFormArray); - - const sectionsIndexToBeRemoved = []; - - sections.controls.forEach((section,idx)=>{ - if(section.get('page').value === tce.id){ - sectionsIndexToBeRemoved.push(idx); - } - }); - - if(sectionsIndexToBeRemoved.length){ - sectionsIndexToBeRemoved.reverse().forEach(index=>{ - sections.removeAt(index); - }); - } - - //update page ordinals - for(let i=0; i= 0) { //section found - - const sections = (this.form.get('sections') as UntypedFormArray); - - //remove section - this._updateSelectedItem(tce); - sections.removeAt(index); - - //update ordinal - for(let i=0; i< sections.length; i++){ - sections.at(i).get('ordinal').patchValue(i); - } - } else {//NOT FOUND IN FIRST LEVEL CASE - - //LOOK FOR SUBSECTION CASE - let parentFormArray = tce.form.parent as UntypedFormArray; - - for (let i = 0; i < parentFormArray.length; i++) { - let section = parentFormArray.at(i); - - if (section.get('id').value == tce.id) { - index = i; - break; - } - } - if (index >= 0) { - this._updateSelectedItem(tce); - parentFormArray.removeAt(index); - - //update odrinal - - for(let i=0; i=0){//fieldset found - this._updateSelectedItem(tce); - parentFormArray.removeAt(idx); - - //patching order - for(let i=0; i{ - if(section.get('id').value === tce.id){ - isFirstLevel = true; - } - }); - - let parentId = null; - if(isFirstLevel){ - parentId = tce.form.get('page').value; - }else{ - parentId = tce.form.parent.parent.get('id').value - } - - // const parentId = tce.form.parent.parent.get('id').value; - if(parentId){ - const tocentries = this.getTocEntries(); - const parent = this._findTocEntryById(parentId, tocentries); - - if(parent){ - this.selectedTocEntry = parent; - }else{ - this.selectedTocEntry = null; - } - }else{ - this.selectedTocEntry = null; - } - } - } - } - } - - tocEntryIsChildOf(testingChild: ToCEntry,parent: ToCEntry): boolean{ - - if(!testingChild || !parent) return false; - - if(testingChild.id == parent.id){return true;} - - if(parent.subEntries){ - let childFound:boolean = false; - - parent.subEntries.forEach(subEntry=>{ - if(this.tocEntryIsChildOf(testingChild, subEntry)){ - childFound = true; - return true; - } - }) - - return childFound; - } - return false; - } - - selectedTocEntry: ToCEntry - displayItem(entry: ToCEntry): void { - this.selectedTocEntry = entry; - } - - get numOfPages(){ - return (this.form.get('pages')).length; - } - - // getSectionIndex(): number{ - // // if(this.sectionIdPreviewed == null) return; - // const valuesArray = this.form.get('sections').value; - // let currentVal = this.sectionIdPreviewed; - // let indexArray:string[] = valuesArray.map(element=> element.page); - // let index = indexArray.indexOf(currentVal); - // console.log(index); - // return index ? index :-1; - // } - - // getCurrentEditorModel(): SectionEditorModel{ - // let currentEditor = this.dataModel.sections.filter(section=> section.page == this.sectionIdPreviewed)[0]; - // return currentEditor; - - // } - - - // subForm(){ - // const valuesArray = this.form.get('sections').value; - // let currentVal = this.sectionIdPreviewed; - // let indexArray:string[] = valuesArray.map(element=> element.page); - // let index = indexArray.indexOf(currentVal); - // let subForm = (this.form.get('sections') as FormArray).controls[index]; - // console.log(subForm); - // return subForm; - // } - - getFieldTile(formGroup: UntypedFormGroup, index: number) { - if (formGroup.get('title') && formGroup.get('title').value && formGroup.get('title').value.length > 0) { return formGroup.get('title').value; } - return "Field " + (index + 1); - } - - deleteFieldSet(formArray: UntypedFormArray, index: number) { - formArray.removeAt(index); - } - - - - printForm(){ - // console.log(this.form.value); - console.log(this.form); - } - - get barPercentage(){ - if(!this.stepper || !this.steps){ - return 0; - } - const selectedIndex = this.stepper.selectedIndex + 1; - return (selectedIndex / this.stepper.steps.length) * 100; - } - - - get progressStyle(){ - // return {'transform': 'translateX('+this.barPercentage+'%) skewX(-25deg)'} - const diff = 3; - - return { - 'clip-path': `polygon(0 0, ${Math.round(this.barPercentage + diff)}% 0, ${Math.round(this.barPercentage)}% 100%, 0 100%)` - } - } - - steps:QueryList; - // get steps(){ - // if(!this.stepper){ - // return []; - // } - - // return this.stepper.steps; - // } - - - // generatePreviewForm(){ - - - // const model = new DatasetDescriptionFormEditorModel(); - - // const toCentries = this.getTocEntries(); - - - // //first level is always pages - // model.pages = toCentries.map((entry,idx)=>{ - // if( !(entry.type == ToCEntryType.Page)){ - // return null; - // } - // const pageModel = new DatasetDescriptionPageEditorModel(); - - // pageModel.ordinal = entry.form.get('ordinal').value; - // pageModel.title = entry.label; - - // if(entry.subEntries){ - // pageModel.sections = entry.subEntries.map(section=>{ - // const sectionModel = new DatasetDescriptionSectionEditorModel(); - - // sectionModel.id = section.id; - // sectionModel.ordinal = section.form.get('ordinal').value; - // sectionModel.description = section.form.get('description').value; - // sectionModel.page = entry.form.get('ordinal').value; - // sectionModel.title = section.label; - // sectionModel.numbering = (idx+1).toString(); - - - // if(section.subEntriesType == ToCEntryType.Section){ - // sectionModel.sections = this._buildSectionsRecursively(section.subEntries, sectionModel.numbering); - // }else{ - // sectionModel.compositeFields = this._buildFormFields(section.subEntries, sectionModel.numbering) - // } - - // return sectionModel; - // }); - // }; - // return pageModel; - - // }); - - - // //populate rules - // const rules:Rule[] =[]; - // const fieldSets = this._getFieldSets(toCentries); - - // fieldSets.forEach(fs=>{ - // const fields = fs.form.get('fields') as FormArray; - // if(fields){ - // fields.controls.forEach(field=>{ - // const rulesArray = field.get('visible').get('rules').value; - // if(rulesArray){ - // rulesArray.forEach(ruleElement => { - // const rule: Rule = new Rule(); - // rule.targetField = ruleElement.target; - // rule.sourceField = field.get('id').value; - // rule.requiredValue = ruleElement.value; - // rules.push(rule); - // }); - // } - // }); - // } - // }); - - // model.rules = rules; - // this.visibilityRules = rules; - - // this.previewForm = model.buildForm(); - // } - - - updateVisibilityRules(){ - const rules:Rule[] =[]; - const fieldSets = this._getFieldSets(this.getTocEntries()); - - fieldSets.forEach(fs=>{ - const fields = fs.form.get('fields') as UntypedFormArray; - if(fields){ - fields.controls.forEach(field=>{ - const rulesArray = field.get('visible').get('rules').value; - if(rulesArray){ - rulesArray.forEach(ruleElement => { - const rule: Rule = new Rule(); - rule.targetField = ruleElement.target; - rule.sourceField = field.get('id').value; - rule.requiredValue = ruleElement.value; - rules.push(rule); - }); - } - }); - } - }); - - this.visibilityRules = rules; - - } - - visibilityRules:Rule[]; - private _buildSectionsRecursively( tocentries: ToCEntry[], parentNumbering:string): DatasetDescriptionSectionEditorModel[]{ - - - if(!tocentries) return null; - - - const result: Array = []; - - tocentries.forEach((tocentry, idx)=>{ - - const sectionModel = new DatasetDescriptionSectionEditorModel(); - sectionModel.id = tocentry.id; - sectionModel.ordinal = tocentry.form.get('ordinal').value; - sectionModel.description = tocentry.form.get('description').value; - // sectionModel.page = entry.form.get('ordinal').value; - sectionModel.title = tocentry.label; - // sectionModel.numbering = tocentry.numbering; - sectionModel.numbering = parentNumbering+"."+(idx+1);; - - if(tocentry.subEntriesType == ToCEntryType.Section){ - sectionModel.sections = this._buildSectionsRecursively(tocentry.subEntries, sectionModel.numbering); - - }else{ - sectionModel.compositeFields = this._buildFormFields(tocentry.subEntries, sectionModel.numbering); - } - - result.push(sectionModel); - }) - - return result; - } - - private _buildFormFields(tocentries: ToCEntry[], parentNumbering: string):DatasetDescriptionCompositeFieldEditorModel[]{ - if(!tocentries) return null; - - const fieldsets:DatasetDescriptionCompositeFieldEditorModel[] = []; - - tocentries.forEach((fs, idx)=>{ - - const fieldset = new DatasetDescriptionCompositeFieldEditorModel(); - - fieldset.description = fs.form.get('description').value; - fieldset.extendedDescription = fs.form.get('extendedDescription').value; - fieldset.id = fs.form.get('id').value; - fieldset.multiplicity = fs.form.get('multiplicity').value; - fieldset.additionalInformation = fs.form.get('additionalInformation').value; - fieldset.ordinal = fs.form.get('ordinal').value; - // fieldset.numbering = fs.numbering; - fieldset.numbering = parentNumbering+"."+(idx+1); - fieldset.hasCommentField = fs.form.get('hasCommentField').value; - fieldset.title = fs.label; - // fieldset.fields = (fs.form.get('fields') as FormArray).getRawValue(); - fieldset.fields = (fs.form.get('fields') as UntypedFormArray).controls.map(field=>{ - - const fieldModel = new DatasetDescriptionFieldEditorModel(); - - fieldModel.data = (field.get('data') as UntypedFormGroup).getRawValue(); - fieldModel.id = field.get('id').value; - fieldModel.viewStyle = (field.get('viewStyle') as UntypedFormGroup).getRawValue(); - // fieldModel.defaultValue = (field.get('defaultValue') as FormGroup).getRawValue(); - fieldModel.value = (field.get('defaultValue') as UntypedFormGroup).get('value').value; - fieldModel.defaultValue = fieldModel.value; - fieldModel.page = field.get('page').value; - fieldModel.validations = field.get('validations').value; - - return fieldModel; - }); - - - - fieldsets.push(fieldset); - }); - - return fieldsets; - } - - private _getFieldSets(tocentries: ToCEntry[]):ToCEntry[]{ - - const fieldsets:ToCEntry[] = []; - - if(!tocentries) return fieldsets; - - tocentries.forEach(entry=>{ - if(entry.type == ToCEntryType.FieldSet){ - fieldsets.push(entry); - }else{ - fieldsets.push(...this._getFieldSets(entry.subEntries)); - } - }); - - return fieldsets; - } - - - - // get basicInfo(){ - - // const label = this.form.get('label'); - // const description = this.form.get('description'); - // const language = this.form.get('language'); - - - - // const fg = new FormGroup({ - // label: label, - // description: description, - // language: language - // }) - - // return fg; - // } - - - - - - onMatStepperSelectionChange(event: StepperSelectionEvent){ - - if(event.selectedIndex === (this.steps.length -1)){//preview selected - // this.generatePreviewForm();//TODO LAZY LOADING IN THE TEMPLATE - this.getPreview(); - }else{ - // this.previewForm = null; - this.formGroup = null; - } - this.form.markAsUntouched(); - - } - - // previewForm:FormGroup; - onDataNeedsRefresh(params?){ - - const tocentries = this.refreshToCEntries(); - - if(params && params.draggedItemId){ - if(params.draggedItemId){ - this.displayItem(this._findTocEntryById(params.draggedItemId, tocentries)); - } - } - this.form.markAsDirty(); - } - - cloneFieldSet(fieldset: UntypedFormGroup){ - const values = fieldset.getRawValue(); - const parentArray = fieldset.parent as UntypedFormArray; - - values.id = Guid.create().toString(); - values.ordinal = parentArray.length; - - values.fields.forEach(element => { - element.id = Guid.create().toString() - }); - - - const clonedModel = new FieldSetEditorModel().fromModel(values); - const clonedForm = clonedModel.buildForm(); - parentArray.push(clonedForm); - - //update tocentries and make selected tocentry the cloedn - let entries = this.refreshToCEntries(); - - const entryfound = this._findTocEntryById(clonedForm.get('id').value, entries); - if(entryfound){ - this.selectedTocEntry = entryfound; - } - - // //create one field form fieldset - // const field: FieldEditorModel = new FieldEditorModel(); //to ask - // field.id = Guid.create().toString(); - // field.ordinal = 0;//first filed in the fields list - // fieldSet.fields.push(field); - // // field.ordinal = fieldSet.fields.length-1; - - // //give fieldset id and ordinal - // fieldSet.id = Guid.create().toString(); - // fieldSet.ordinal = (parent.form.get('fieldSets') as FormArray).length; - - // (parent.form.get('fieldSets')).push(fieldSet.buildForm()); - - // // const parentArray = parent.form.get('fieldSets') as FormArray; - // const addedFieldSet = parentArray.at(parentArray.length - 1); - - - - - } - - isStepCompleted(stepIndex: number){ - - let stepCompleted = false; - this.steps.forEach((step,index)=>{ - if(stepIndex === index){ - stepCompleted = step.completed; - } - }); - - return stepCompleted; - } - - isStepUnlocked(stepIndex: number): boolean{ - if(stepIndex === 0) return true; - if(stepIndex <0 ) return false; - //if previous step is valid then unlock - let stepUnlocked: boolean = false; - - if(!this.isStepUnlocked(stepIndex -1)) return false; - - this.steps.forEach((step,index)=>{ - - if(index+1 == stepIndex){//previous step - - if(step.completed){ - stepUnlocked = true; - } - } - }); - - return stepUnlocked; - } - - validateStep(selectedIndex){ - - if(selectedIndex === 1){//form description - if(this.form.invalid){ - this.checkFormValidation(); - } - } - - - // if(step.hasError){ - // this.printMyErrors(this.form); - // } - } - - // getFormValidationErrors() { - // Object.keys(this.form.controls).forEach(key => { - - // const controlErrors: ValidationErrors = this.form.get(key).errors; - // if (controlErrors != null) { - // Object.keys(controlErrors).forEach(keyError => { - // console.log('Key control: ' + key + ', keyError: ' + keyError + ', err value: ', controlErrors[keyError]); - // }); - // } - // }); - - // if(this.form.invalid){ - // console.log('this form is invalid!'); - // console.log(this.form.errors); - // } - // } - - - - private _buildErrorMessage(errors, numbering, key):string[]{ - const errmess: string[] = []; - - Object.keys(errors).forEach(keyError => { - - switch(keyError){ - case EditorCustomValidatorsEnum.atLeastOneSectionInPage: - errmess.push( this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.PAGE-MUST-HAVE-SECTION')); - break; - case EditorCustomValidatorsEnum.emptyArray: - errmess.push(numbering+this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.NEEDS-MORE-INFORMATION')) - break; - case EditorCustomValidatorsEnum.sectionMustHaveOneChild: - errmess.push(numbering+this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.MUST-HAVE-SECTION-OR-FIELDSET')) - break; - default: - if (typeof errors[keyError] === 'boolean') { - errmess.push(numbering + ' ' + key + ' is ' + keyError); - } else { - errmess.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); - } - - } - - }); - - return errmess; - } - - - printMyErrors(form: AbstractControl){ - // this._printToCentriesErrrors(this.toCEntries); - const result = this._getErrors(form); - - // console.log('got errors '); - // console.log(result); - - if(result && form.invalid){ - const errmess:string[] = []; - if(result.length){ - form.markAllAsTouched(); - - let indexes:number[] = []; - ///search in pages,sections and fieldsets for the id - result.forEach((err,i)=>{ - const entry = this._findTocEntryById(err.id, this.toCEntries); - if(entry){ - - // errmess.push(`Error on ${entry.numbering} ${entry.label} . ${err.key}`); - errmess.push(...this._buildErrorMessage(err.errors, entry.numbering, err.key)); - indexes.push(i); - } - }); - indexes.reverse().forEach(index=>{ - result.splice(index,1); - }); - - indexes = []; - //searching in fields - const fieldsets = this._getAllFieldSets(this.toCEntries); - result.forEach((err,i)=>{ - fieldsets.filter(fs=>{ - let fieldFound = false; - (fs.form.get('fields') as UntypedFormArray).controls.forEach(field=>{ - if(field.get('id').value === err.id){ - fieldFound = true; - indexes.push(i); - } - }); - return fieldFound; - }) - //printing fieldsets that the field missing - .forEach(fs=>{ - // errmess.push(`Missing input in ${fs.numbering} ${fs.label} . ${err.key}`); - errmess.push(...this._buildErrorMessage(err.errors, fs.numbering, err.key)); - }); - }); - - indexes.reverse().forEach(index=>{ - result.splice(index,1); - }); - - result.forEach(err=>{ - // console.log(err); - if(err.key){ - errmess.push(`${this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.MISSING')} ${err.key}` ); - }else{ - - errmess.push(this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.PROVIDE-PAGE-AND-SECTION')); - } - // errmess.push(...this._buildErrorMessage(err.errors,"", err.key) ); - - }) - } - - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - errorMessages: errmess, - projectOnly: false - }, - }); - } - } - - /** - * Get all filedsets in a tocentry array; - * @param entries Tocentries to search in - * @returns The tocentries that are Fieldsets provided in the entries - */ - private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{ - - const fieldsets:ToCEntry[] = []; - if(!entries || !entries.length) return fieldsets; - - - entries.forEach(e=>{ - if(e.type === ToCEntryType.FieldSet){ - fieldsets.push(e); - }else{ - fieldsets.push(...this._getAllFieldSets(e.subEntries)); - } - }); - return fieldsets; - } - - - private _getErrors(aControl: AbstractControl):InvalidControl[]{ - - - if(aControl.valid) return; - - let controlType = 'control'; - - if(aControl instanceof UntypedFormGroup) controlType="fg" - if(aControl instanceof UntypedFormControl) controlType="fc"; - if(aControl instanceof UntypedFormArray) controlType="fa"; - - - const invalidControls:InvalidControl[] = []; - //invalid - switch (controlType){ - case 'fg': - - const controls = (aControl as UntypedFormGroup).controls; - const keys = Object.keys(controls); - keys.forEach(key=>{ - const control = controls[key]; - if(!control.invalid) return; //// !!!!! Important to be !invalid. (In case the template is finalized) - - if(control instanceof UntypedFormControl){ - const ctrl = control as UntypedFormControl; - - invalidControls.push({ - errors:ctrl.errors, - id: ctrl.get('id')? ctrl.get('id').value: null, - invalidSubControls: [], - key: key - }); - - }else{ - // if(aControl.errors){ - // invalidControls.push({ - // id: aControl.get('id')? aControl.get('id').value: null, - // errors:aControl.errors, - // key: aControl.get('title')? aControl.get('title').value: 'unspecified', - // invalidSubControls:[]//TODO TO CHECK - // }); - // } - - - //THE ONE WE REMOVED - // if(control.errors){ - // // invalidControls.push({ - // // id: aControl.get('id')? aControl.get('id').value: null, - // // errors:aControl.errors, - // // key: aControl.get('title')? aControl.get('title').value: 'unspecified', - // // invalidSubControls:[]//TODO TO CHECK - // // }); - - // invalidControls.push({ - // errors:control.errors, - // id: control.get('id')? control.get('id').value: null, - // invalidSubControls: [], - // key: key - // }); - // } - invalidControls.push(...this._getErrors(control)) ; - - } - }); - - /**In case there is an error in a formgroup then the validator probably is custom */ - if(aControl.errors){ - invalidControls.push({ - errors:aControl.errors, - id: aControl.get('id')? aControl.get('id').value: null, - invalidSubControls: [], - key: aControl.get('title')?aControl.get('title').value: null - }); - } - - break; - case 'fa': - // const fa = (aControl as FormArray); - const ctrls = (aControl as UntypedFormArray).controls; - const keys_ = Object.keys(ctrls); - keys_.forEach(key=>{ - const control = ctrls[key]; - if(control.valid) return; - - - if(control instanceof UntypedFormControl){ //for completion purposes. should never run this case - const ctrl = control as UntypedFormControl; - invalidControls.push({ - errors:ctrl.errors, - id: ctrl.get('id')? ctrl.get('id').value: null, - invalidSubControls: [], - key: key - }); - - }else{ - invalidControls.push(... this._getErrors(control)); - } - }); - - break; - } - - invalidControls.forEach(e=>{ - if(!e.id){ - e.id = aControl.get('id')? aControl.get('id').value : null; - } - }) - return invalidControls; - - } - userFormDisabled:boolean = false; - addUser(email:MatInput){ - - // email.focus(); - if(this.userFormDisabled) return; - - // console.log('user add'); - if(this.inputUserState === 'triggered'){ - // this.checkAndAdd(email); - - of(email.value) - .pipe(tap(_=> {this.userFormDisabled = true; email.focus()})) - .pipe(mergeMap(email=>this.userService.getFromEmail(email))) - .pipe(takeUntil(this._destroyed)) - .subscribe((result) => { - this.userChipList.push(result); - this.form.patchValue({'users': this.userChipList}); - - email.value = ''; - this.userFormDisabled = false; - this.form.markAsDirty(); - // email.focus(); - // this.inputUserState = 'triggered'; - - - }, - error=>{ - // console.log(error.message); - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.ERRORS.USER-NOT-FOUND'), SnackBarNotificationLevel.Error); - this.userFormDisabled = false; - // this.inputUserState = 'triggered';//when it loses focus(when disabled) it becomes untriggered - // email.focus(); - }); - // this.inputUserState = 'untriggered'; - }else{ - this.inputUserState = 'triggered'; - email.focus(); - - } - } - onUserButtonFocus(){ - this._inputUserButton$.next(true); - } - onUserButtonBlur(){ - this._inputUserButton$.next(false); - } - onUserFieldFocus(){ - this._inputUserField$.next(true); - } - onUserFieldBlur(){ - this._inputUserField$.next(false); - } - - - - //Temporary patch - /** - * Append custom validators to fields. Some validators are applied on template. In case they are never rendereed, - * he form might be valid when it shouldnt. - * @param - */ - private _initializeFormValidity(tocentries: ToCEntry[]) { - const fieldsets = this._getAllFieldSets(tocentries); - - try{ - fieldsets.forEach(fs=>{ - fs.form.get('title').setValidators(Validators.required); - const fieldsF = fs.form.get('fields') as UntypedFormArray; - if(fieldsF){ - fieldsF.controls.forEach(field=>{ - const renderStyleValue = field.get('viewStyle').get('renderStyle').value; - - if(renderStyleValue === DatasetProfileFieldViewStyle.CheckBox){ - field.get('defaultValue').get('value').setValidators(Validators.required); - }else if(renderStyleValue === 'combobox'){ - - const comboType = field.get('data').get('type').value; - if(comboType === DatasetProfileComboBoxType.Autocomplete){//As 'Other' in UI - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('autoCompleteSingleDataList')); - }else if(comboType === DatasetProfileComboBoxType.WordList){ - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - } - - }else if(renderStyleValue === DatasetProfileFieldViewStyle.RadioBox){ - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options')); - } else if(renderStyleValue === DatasetProfileFieldViewStyle.Upload) { - field.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('types')); - field.get('data').get('maxFileSizeInMB').setValidators(Validators.required); - } - }); - } - }); - }catch(e){ - console.error('Error initializing validators.'); - console.error(e); - } - - } - - checkAndAdd(ev: any) { - this.userService.getFromEmail(ev).pipe(takeUntil(this._destroyed)).subscribe((result) => { - this.userChipList.push(result); - this.form.patchValue({'users': this.userChipList}); - }); - } - - removeUser(user: any) { - this.userChipList.splice(this.userChipList.indexOf(user), 1); - this.form.patchValue({'users': this.userChipList}); - this.form.markAsDirty();//deactivate guard - } - - - verifyAndRemoveUser(user:any){ - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(approve => { - if (approve) { - this.removeUser(user); - } - }); - } - - scrollOnTop(){ - try{ - const topPage = document.getElementById('main-content'); - topPage.scrollIntoView({behavior:'smooth'}); - }catch{ - console.log('coulnd not scroll'); - } - } - - updateAndFinalize(close: boolean = false){ - if(this.form.get('status').value == DatasetProfileEnum.FINALIZED ){ - //UPDATE FORM - if(this.newVersionId){ - this.onSubmit(close); - }else{ - this.updateFinalized(close); - } - }else{ - //finalize - this.finalize(); - } - - } - discardChanges(){ - this.router.navigate([ - 'dataset-profiles' - ]); - } - -} - -interface InvalidControl{ - key: string, - errors: any, - id: string, - invalidSubControls: InvalidControl[] -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html deleted file mode 100644 index 45a016601..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
-
- {{'CRITERIA.USERS.SHOW' | translate}}: -
- - - - {{'DATASET-PROFILE-STATUS.NONE' | translate}} - {{'DATASET-PROFILE-STATUS.DRAFT' | translate}} - {{'DATASET-PROFILE-STATUS.FINALIZED' | translate}} - - - -
-
- - - search - -
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss deleted file mode 100644 index 9b64c055a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.scss +++ /dev/null @@ -1,17 +0,0 @@ -.mat-form-field{ - display: inline-block !important; -} - -:host ::ng-deep .status-form-field .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .search-form-field .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts deleted file mode 100644 index 7cf625f1f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { DialogConfirmationUploadDatasetProfiles } from '@app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-profile-criteria-component', - templateUrl: './dataset-profile.component.html', - styleUrls: ['./dataset-profile.component.scss'] -}) -export class DatasetProfileCriteriaComponent extends BaseCriteriaComponent implements OnInit { - - public criteria: DatasetProfileCriteria = new DatasetProfileCriteria(); - - constructor( - private datasetService: DatasetProfileService, - private dialog: MatDialog, - private language: TranslateService, - ) { - super(new ValidationErrorModel()); - } - - ngOnInit() { - super.ngOnInit(); - if (this.criteria == null) { this.criteria = new DatasetProfileCriteria(); } - } - - setCriteria(criteria: DatasetProfileCriteria): void { - this.criteria = criteria; - } - - onCallbackError(error: any) { - this.setErrorModel(error.error); - } - - controlModified(): void { - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2) - ) { - this.refreshCallback(); - } - } - -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html deleted file mode 100644 index d071e4cb2..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.html +++ /dev/null @@ -1,44 +0,0 @@ -
-
-
-

{{ data.message }}

-
-
- close -
-
- -
-
- - - {{ selectedFileName }} - - -
-
- -
-
- - -
-
- -
- - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss deleted file mode 100644 index c79fa2851..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.scss +++ /dev/null @@ -1,102 +0,0 @@ -.hidden { - display: none; -} - - -.cancel-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid #b5b5b5; - border-radius: 30px; -min-width: 101px; - height: 43px; - color: #212121; - font-weight: 500; -} - -.next-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid var(--primary-color); - border-radius: 30px; - opacity: 1; -min-width: 101px; - height: 43px; - color: var(--primary-color); - font-weight: 500; -} - -.next-btn[disabled] { - width: 100px; - height: 43px; - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid #b5b5b5; - border-radius: 30px; - opacity: 1; -} - -.next-btn:not([disabled]):hover { - background-color: var(--primary-color); - color: #ffffff; -} - -//ngx dropzone -.drop-file { - background-color: #fafafa; - border: 1px dashed #d1d1d1; - border-radius: 4px; - max-width: 480px; - height: 98px; - margin-top: 0.5rem; -} - -.file-preview { - height: auto !important; - width: auto !important; - max-width: 500px !important; - min-height: 1rem !important; - - background-color: #e0e0e0 !important; - background-image: none !important; - color: rgba(0, 0, 0, 0.87) !important; - font-weight: 500 !important; - border-radius: 24px !important; - line-height: 1.25 !important; -} - -.file-label { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - font-size: 14px !important; -} - -::ng-deep ngx-dropzone-remove-badge { - opacity: 1 !important; - margin-left: .5rem !important; - position: initial !important; -} - - -//attach file - -.attach-btn { - top: -20px; -} - -.attach-file { - width: 156px; - height: 44px; - color: #ffffff; - background: var(--primary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border-radius: 30px; -} - -.attach-file:hover { - background-color: #ffffff; - border: 1px solid var(--primary-color); - color: var(--primary-color); -} - -.close-btn:hover{ - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts deleted file mode 100644 index 144bde02f..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { Inject, Component } from '@angular/core'; - - -@Component({ - selector: 'app-dialog-confirmation-upload', - templateUrl: './dialog-confirmation-upload-profiles.component.html', - styleUrls: ['./dialog-confirmation-upload-profiles.component.scss'] -}) -export class DialogConfirmationUploadDatasetProfiles { - - sizeError = false; - selectedFileName= ""; - selectFile =false; - maxFileSize: number = 1048576; - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } - - - selectXML(event) { - let file: FileList = null; - - if(event.target && event.target.files){ - file = event.target.files; - }else if(event.addedFiles && event.addedFiles.length){ - file = event.addedFiles; - } - if(!file) return;//no select closed with cancel . no file selected - const size: number = file[0].size; // Get file size. - this.sizeError = size > this.maxFileSize; // Checks if file size is valid. - const formdata: FormData = new FormData(); - if (!this.sizeError) { - this.data.file = file; - this.selectFile=true; - this.selectedFileName = file[0].name; - } - this.data.name = file[0].name; - } - - cancel() { - this.data.sucsess = false; - this.dialogRef.close(this.data); - } - - confirm() { - this.data.sucsess = true; - this.dialogRef.close(this.data); - } - - hasProfile():boolean{ - return (this.selectFile && !this.sizeError); - } - - //remove selected file - onRemove(){ - this.data.name=""; - this.selectFile = false; - this.selectedFileName = ""; - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html deleted file mode 100644 index b1c49f61c..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html +++ /dev/null @@ -1,100 +0,0 @@ -
-
- -
-
-

{{titlePrefix}} {{'DATASET-PROFILE-LISTING.TITLE' | translate}}

-
-
-
- - -
-
-
-
-
- -
-
- -
- - - - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.NAME' | translate}} - {{row.label}} - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.DESCRIPTION' | translate}} - - - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.CREATED' | - translate}} - {{row.created | date:'short'}} - - - - - {{'DATASET-PROFILE-LISTING.COLUMNS.STATUS' | - translate}} -
{{ (row.status | parseStatus) | translate}}
-
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
-
-
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss deleted file mode 100644 index d6013801d..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss +++ /dev/null @@ -1,119 +0,0 @@ -.dataset-profile-listing { - margin-top: 1rem; - margin-left: 1rem; - margin-right: 2rem; -} - -.mat-table { - margin-top: 47px; - // margin-bottom: 20px; - border-radius: 4px; - -} - -.mat-fab-bottom-right { - // top: auto !important; - // right: 20px !important; - // bottom: 10px !important; - // left: auto !important; - // position: fixed !important; - float: right; - z-index: 5; -} - -.mat-header-row{ - background: #f3f5f8; -} - -.full-width { - width: 100%; -} - -.mat-card { - margin: 16px 0; -} - -.mat-row { - cursor: pointer; - min-height: 4.5em; -} - -mat-row:hover { - background-color: #eef5f6; -} - -.status-chip{ - - border-radius: 20px; - padding-left: 1em; - padding-right: 1em; - padding-top: 0.2em; - font-size: .8em; -} - -.status-chip-finalized{ - color: #568b5a; - background: #9dd1a1 0% 0% no-repeat padding-box; -} - -.status-chip-draft{ - color: #00c4ff; - background: #d3f5ff 0% 0% no-repeat padding-box; -} -// mat-row:nth-child(even){ -// background-color:red; -// } - -// mat-row:nth-child(odd) { -// background-color: #0c748914; -// // background-color: #eef0fb; -// } - -:host ::ng-deep .mat-paginator-container { - flex-direction: row-reverse !important; - justify-content: space-between !important; - background-color: #f6f6f6; - align-items: center; - // height: 30px; - // min-height: 30px !important; -} - -// ::ng-deep .mat-paginator-page-size { -// height: 43px; -// } - -// ::ng-deep .mat-paginator-range-label { -// margin: 15px 32px 0 24px !important; -// } - -// ::ng-deep .mat-paginator-range-actions { -// width: 55% !important; -// min-height: 43px !important; -// justify-content: space-between; -// } - -// ::ng-deep .mat-paginator-navigation-previous { -// margin-left: auto !important; -// } - -// ::ng-deep .mat-icon-button { -// height: 30px !important; -// font-size: 12px !important; -// } - -.import-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - // color: var(--primary-color); - // border: 1px solid var(--primary-color); - padding-left: 2em; - padding-right: 2em; - color: #000; - border: 1px solid #000; -} -.create-btn { - border-radius: 30px; - background-color: var(--secondary-color); - padding-left: 2em; - padding-right: 2em; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts deleted file mode 100644 index f9181daab..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts +++ /dev/null @@ -1,319 +0,0 @@ -import { DataSource } from '@angular/cdk/table'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { MatPaginator, PageEvent } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { DatasetProfileCriteriaComponent } from '@app/ui/admin/dataset-profile/listing/criteria/dataset-profile.component'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { Observable, merge as observableMerge } from 'rxjs'; -import { map, startWith, switchMap, takeUntil } from 'rxjs/operators'; -import { DialogConfirmationUploadDatasetProfiles } from './criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component'; - -@Component({ - selector: 'app-dataset-profile-listing-component', - templateUrl: 'dataset-profile-listing.component.html', - styleUrls: ['./dataset-profile-listing.component.scss'] -}) -export class DatasetProfileListingComponent extends BaseComponent implements OnInit { - - @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; - @ViewChild(MatSort, { static: true }) sort: MatSort; - @ViewChild(DatasetProfileCriteriaComponent, { static: true }) criteria: DatasetProfileCriteriaComponent; - - // breadCrumbs: Observable; - dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'description', 'created', 'status', 'actions']; - pageEvent: PageEvent; - titlePrefix: String; - dmpId: String; - itemId: string; - datasetStatusEnum = DatasetStatus; - - constructor( - private datasetService: DatasetProfileService, - private router: Router, - private route: ActivatedRoute, - private dmpService: DmpService, - private language: TranslateService, - private uiNotificationService: UiNotificationService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private dialog: MatDialog, - private datasetProfileService: DatasetProfileService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Admin: Dataset Templates'); - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - if (params['dmpId']) { - this.dmpId = params['dmpId']; - if (this.dmpId != null) { this.setDmpTitle(this.dmpId); } - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - // this.breadCrumbs = Observable.of([{ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.DATASET-TEMPLATES'), - // url: 'plans/edit/' + this.dmpId - // }]); - } else { - this.itemId = params['groupId']; - if (this.itemId) { - const datasetProfileLabel = this.route.snapshot.queryParams.groupLabel; - } - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - // this.breadCrumbs = observableOf([{ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.DATASET-TEMPLATES'), - // url: '/dataset-profiles' - // }]); - } - }); - } - - setDmpTitle(dmpId: String) { - this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.titlePrefix = data.label; - } - ); - } - - refresh() { - this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.criteria, this.itemId); - this._paginator.pageIndex = 0; - } - - rowClick(rowId: String) { - this.router.navigate(['dataset-profiles/' + rowId]); - } - - getDefaultCriteria(): DatasetProfileCriteria { - const defaultCriteria = new DatasetProfileCriteria(); - return defaultCriteria; - } - - clone(id: string) { - this.router.navigate(['dataset-profiles/clone/' + id]); - } - - newVersion(id: string, label: string) { - this.router.navigate(['dataset-profiles/newversion/' + id]); - } - - newVersionFromFile(id: string, label: string): void { - const dialogRef = this.dialog.open(DialogConfirmationUploadDatasetProfiles, { - width: '500px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-FILE-TITLE', { datasetName: label }), - confirmButton: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML'), - cancelButton: this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-FILE-CANCEL'), - name: "", - file: FileList, - sucsess: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { - if (data && data.sucsess && data.name != null && data.file != null) { - this.datasetService.uploadFile(data.file, data.name, id) - .pipe(takeUntil(this._destroyed)) - .subscribe(_ => { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.NEW-VERSION-FROM-FILE.NEW-VERSION-XML-SUCCESSFUL'), SnackBarNotificationLevel.Success); - this.refresh(); - }, - error => { - this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); - } - ); - } - }); - } - - viewVersions(rowId, rowLabel) { - this.router.navigate(['/dataset-profiles/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } - downloadXML(datasetProfileId: string): void { - this.datasetProfileService.downloadXML(datasetProfileId) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - }); - } - - deleteTemplate(id: string) { - if (id) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - //this.form.get('status').setValue(DatasetProfileEnum.DELETED); - this.datasetProfileService.delete(id, null) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); - this.refresh(); - }, - error => { - this.onCallbackError(error); - if (error.error.statusCode == 674) { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - } - } - ); - } - }); - - - } - } - - onCallbackError(errorResponse: HttpErrorResponse) { - this.uiNotificationService.snackBarNotification(errorResponse.message, SnackBarNotificationLevel.Warning); - } - // makeItPublic(id: String) { - // debugger; - // this.datasetService.makeDatasetPublic(id).pipe(takeUntil(this._destroyed)).subscribe(); - // } - - openDialog(): void { - const dialogRef = this.dialog.open(DialogConfirmationUploadDatasetProfiles, { - width: '500px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-TITLE'), - confirmButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML'), - cancelButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-CANCEL'), - name: "", - file: FileList, - sucsess: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { - if (data && data.sucsess && data.name != null && data.file != null) { - this.datasetService.uploadFile(data.file, data.name) - .pipe(takeUntil(this._destroyed)) - .subscribe(_ => { - this.uiNotificationService.snackBarNotification('Template successfully uploaded', SnackBarNotificationLevel.Success); - this.refresh(); - }, - error => { - this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); - } - ); - } - }); - } - - /** - * gets as a a pameter a number representing the status and returns the class that is applied - * to status-chip */ - getStatusClass(status: DatasetStatus): string { - - if (status == DatasetStatus.Finalized) { - return 'status-chip-finalized' - } - - return 'status-chip-draft'; - } - -} - -export class DatasetDataSource extends DataSource { - - totalCount = 0; - - constructor( - private _service: DatasetProfileService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _criteria: DatasetProfileCriteriaComponent, - private itemId - ) { - super(); - - } - - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; - - return observableMerge(...displayDataChanges).pipe( - startWith(null), - switchMap(() => { - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array(); - if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.criteria; - request.criteria.finalized = false; - if (this.itemId) { - request.criteria.groupIds = [this.itemId]; - request.criteria.allVersions = true; - } - return this._service.getPaged(request); - }), - /*.catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }); - //this._criteria.criteria.onCallbackError(error); - return Observable.of(null); - })*/ - map(result => { - return result; - }), - map(result => { - if (!result) { return []; } - // if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.totalCount = result.totalCount; - return result.data; - })); - } - - disconnect() { - // No-op - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts deleted file mode 100644 index 82b75d2ab..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/pipe/parse-status.pipe.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; - -@Pipe({ - name: 'parseStatus', - pure: true -}) -export class ParseStatus implements PipeTransform { - transform(value: any, ...args: any[]) { - return this.parseStatus(value); - } - - - parseStatus(status: DatasetStatus): string { - - switch (status) { - case DatasetStatus.Finalized: - return 'DATASET-PROFILE-STATUS.FINALIZED'; - case DatasetStatus.Draft: - return 'DATASET-PROFILE-STATUS.DRAFT'; - case DatasetStatus.Deleted: - return 'DATASET-PROFILE-STATUS.DRAFT.DELETED'; - default: - return 'DATASET-PROFILE-STATUS.DRAFT.NONE'; - } - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html deleted file mode 100644 index eb2d6a4ba..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.html +++ /dev/null @@ -1,2 +0,0 @@ - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts deleted file mode 100644 index 092d41f6a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/preview/dataset-profile-preview.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Inject, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -// @Component({ -// selector: 'app-dataset-profile-preview-component', -// templateUrl: './dataset-profile-preview.component.html', -// styleUrls: ['./dataset-profile-preview.component.scss'] -// }) -export class DatasetProfilePreviewerComponent extends BaseComponent implements OnInit { - formGroup: FormGroup; - datasetWizardModel: DatasetWizardEditorModel; - constructor( - private datasetProfileService: DatasetProfileService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { super(); } - - ngOnInit(): void { - - this.datasetProfileService.preview(this.data['model']) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel({ - datasetProfileDefinition: x - }); - this.formGroup = this.datasetWizardModel.buildForm().get('datasetProfileDefinition'); - }); - - } -} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts deleted file mode 100644 index b1ddf7e9a..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AbstractControl } from "@angular/forms"; - -export interface ToCEntry { - id: string; - label: string; - subEntriesType: ToCEntryType; - subEntries: ToCEntry[]; - type: ToCEntryType; - form: AbstractControl; - numbering: string; -} - - -export enum ToCEntryType { - Page = 0, - Section = 1, - FieldSet = 2, - Field = 3 -} - -export interface NewEntryType { - childType: ToCEntryType, - parent: ToCEntry -} - -export interface TableUpdateInfo{ - draggedItemId?: string; - data?:any; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html deleted file mode 100644 index f31a10a89..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html +++ /dev/null @@ -1,252 +0,0 @@ - - -
- -
- - - - - {{parentLink.subEntries?.length}} - - - - - - delete - -
-
- - - - -
- - -
- - -
- -
- -
- - - - - - - - - - - - - - - -
- - -
- -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss deleted file mode 100644 index 3e4c13517..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss +++ /dev/null @@ -1,116 +0,0 @@ -// .docs-toc-container { -// width: 100%; -// padding: 5px 0 10px 0px; -// // cursor: pointer; -// // border-left: solid 4px #0c7489; - -// .scroll-container { -// overflow-y: auto; -// // calc(100vh - 250px) -// // height: calc(100vh - 250px); -// } - -// .docs-link { -// color: rgba(0, 0, 0, 0.54); -// // color: mat-color($app-blue-theme-foreground, secondary-text); -// transition: color 100ms; - -// &:hover, -// &.docs-active { -// .link-name { -// background-color: #ececec; -// border-radius: 6px; -// cursor: pointer;; -// // color: #0c7489; -// } -// // color: mat-color($primary, if($is-dark-theme, 200, default)); -// } -// } -// } - -// .docs-toc-heading { -// margin: 0; -// padding: 0; -// font-size: 13px; -// font-weight: bold; -// } - -// .table-item-actions{ -// // display: none; -// display: inline-block; -// visibility: hidden; -// } - -// .table-item:hover { -// .table-item-actions{ -// // display: inline-block; -// visibility: visible; -// } -// } - -// .table-item col{ -// text-overflow: ellipsis; -// overflow: hidden; -// white-space: nowrap; -// } - -.link-info{ - // display: inline-block; cursor: pointer; - // padding-top: .6em; - // padding-left: .6em; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - - -.border-left-active{ - border-left: 1px solid #000; -} - - -.side-bolder{ - border-left: 1px solid red; -} - - -.cdk-link-list { - - display: block; - // background: white; - overflow: hidden; -} - - - -$blue-color : var(--primary-color); -$blue-color-light: #5cf7f2; -$yellow: var(--secondary-color); -.badge-ball{ - display: inline-block; - border-radius: 50%; - background-color: #FFF; - font-size: small; - font-weight: bold; - min-width: 2em; - text-align: center; -} - -.table-label-element{ - cursor: pointer; - // font-weight: normal; - - // transition-property: font-weight; - // transition-duration: 160ms; - // transition-delay: 50ms; - // transition-timing-function: ease-in-out; -} - - -.table-label-element-active{ - font-weight: bold; - // color: red; -} -.add-input-icon{ - width: 20px; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts deleted file mode 100644 index a7098cd0b..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts +++ /dev/null @@ -1,281 +0,0 @@ -import { CdkDrag, CdkDragDrop, CdkDropList, moveItemInArray } from '@angular/cdk/drag-drop'; -import { DOCUMENT } from '@angular/common'; -import { Component, EventEmitter, Inject, Input, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { BaseComponent } from '@common/base/base.component'; -import { NewEntryType, ToCEntry, ToCEntryType } from '../table-of-contents-entry'; - -@Component({ - selector: 'app-dataset-profile-table-of-contents-internal-section', - styleUrls: ['./table-of-contents-internal-section.scss'], - templateUrl: './table-of-contents-internal-section.html' -}) -export class DatasetProfileTableOfContentsInternalSection extends BaseComponent implements OnInit { - - @Input() links: ToCEntry[]; - @Output() itemClick = new EventEmitter(); - @Output() removeEntry = new EventEmitter(); - - @Output() createFooEntry = new EventEmitter(); - - @Output() dataNeedsRefresh = new EventEmitter(); - - - - @Input() parentLink: ToCEntry; - @Input() itemSelected: ToCEntry; - @Input() DRAGULA_ITEM_ID_PREFIX; - @Input() overContainerId: string; - @Input() isDragging; - @Input() draggingItemId: string; - @Input() parentRootId: string; - - @Input() colorizeInvalid:boolean = false; - - @Input() viewOnly: boolean; - // @Input() dropListGroup: Set = new Set(); - // @Input() dropListGroup: string[]; - - // @Input() dragHoveringOver: boolean = false; - // @Input() depth: number = 0; - - // @Input() dropListStruct: { id: string, depth: number}[] = []; - - constructor( - @Inject(DOCUMENT) private _document: Document) { - super(); - } - - tocEntryType = ToCEntryType; - - - // compareFn(a, b){ - // if(a.depth> b.depth) return -1; - // if(a.depth< b.depth) return 1; - - // return 0; - // } - - ngOnInit(): void { - } - - // hoveroverEnter(){ - // // console.log('user hovering drag over', this.parentLink.id, this.parentLink.label); - // this.dragHoveringOver = true; - // } - // hoveroverLeft(){ - // this.dragHoveringOver = false; - // } - - ngOnChanges(changes: SimpleChanges) { - - } - - // get grouListIds(){ - // return Array.from(this.dropListGroup); - // } - itemClicked(item: ToCEntry) { - //leaf node - this.itemClick.emit(item); - } - - deleteEntry(currentLink: ToCEntry){ - this.removeEntry.emit(currentLink); - } - - createNewEntry(foo: NewEntryType){ - this.createFooEntry.emit(foo); - } - - // tocEntryIsChildOf(testingChild: ToCEntry,parent: ToCEntry): boolean{ - - // if(!testingChild || !parent) return false; - - // if(testingChild.id == parent.id){return true;} - - // if(parent.subEntries){ - // let childFound:boolean = false; - - // parent.subEntries.forEach(subEntry=>{ - // if(this.tocEntryIsChildOf(testingChild, subEntry)){ - // childFound = true; - // return true; - // } - // }) - - // return childFound; - // } - // return false; - // } - - get selectedItemInLinks(){ - if(!this.links || !this.itemSelected) return false; - - const link = this.links.find(l=>l.id === this.itemSelected.id); - - if(link) return true; - return false; - } - - // appendAndGetDroplists(dropList: CdkDropList){ - // this.dropListGroup.push(dropList); - // return this.dropListGroup; - // } - - // drop(event: CdkDragDrop) { - // // if(!this.links || !this.links.length) return; - - // if(event.container === event.previousContainer){ - // moveItemInArray(this.links, event.previousIndex, event.currentIndex); - - // let arrayToUpdate: FormArray = this.links[0].form.parent as FormArray; - // // if(this.parentLink && this.parentLink.form){ - // // switch(this.parentLink.subEntriesType){ - // // case this.tocEntryType.Field: - // // arrayToUpdate = (this.parentLink.form.get('fields') as FormArray); - // // break; - // // case this.tocEntryType.FieldSet: - // // arrayToUpdate = (this.parentLink.form.get('fieldSets') as FormArray); - // // break; - // // case this.tocEntryType.Section: - // // arrayToUpdate = (this.parentLink.form.get('sections') as FormArray); - // // break - // // } - - // // } - // if(arrayToUpdate.controls){ - // moveItemInArray(arrayToUpdate.controls, event.previousIndex, event.currentIndex); - // //update ordinality - // arrayToUpdate.controls.forEach((element,idx ) => { - // element.get('ordinal').setValue(idx); - // element.updateValueAndValidity(); - // }); - // } - - // this.dataNeedsRefresh.emit(); - // }else{ - // console.log('not same container'); - // } - - // console.log(event.container.id); - - // } - - onDataNeedsRefresh(){ - this.dataNeedsRefresh.emit(); - } - - - // get hoveringOverParent(){ - // if(!this.overContainerId) return false; - // const child = this._findTocEntryById(this.overContainerId, this.parentLink.subEntries); - // if(!child) return false; - // return true; - // } - - - public _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } - - - - colorError():boolean{ - - if(!this.colorizeInvalid) return false; - - const form = this.parentLink.form; - if((!form || form.valid || !form.touched) && this.parentLink.type !== this.tocEntryType.Page) return false; - - const allFieldsAreTouched = this.allFieldsAreTouched(form); - - //fieldset may have errros that are inside its controls and not in the fieldsetFormGroup - if(this.parentLink.type === this.tocEntryType.FieldSet && allFieldsAreTouched) return true; - - if(form.errors && allFieldsAreTouched) return true; - - //check if page has sections - if(this.parentLink.type === this.tocEntryType.Page && allFieldsAreTouched){ - const rootForm = form.root; - if(rootForm){ - const sections = rootForm.get('sections') as UntypedFormArray; - if(!sections.controls.find(section=>section.get('page').value === this.parentLink.id)){ - return true; - } - } - } - - - //checking first child form controls if have errors - let hasErrors = false; - if(allFieldsAreTouched){ - if(form instanceof UntypedFormGroup){ - const formGroup = form as UntypedFormGroup; - - const controls = Object.keys(formGroup.controls); - - controls.forEach(control=>{ - if(formGroup.get(control).errors){ - hasErrors = true; - } - }) - - } - } - - return hasErrors; - } - - - allFieldsAreTouched(aControl:AbstractControl){//auto na testaroume - - if(!aControl|| aControl.untouched) return false; - - if(aControl instanceof UntypedFormControl){ - return aControl.touched; - }else if(aControl instanceof UntypedFormGroup){ - const controlKeys = Object.keys((aControl as UntypedFormGroup).controls); - let areAllTouched = true; - controlKeys.forEach(key=>{ - if(!this.allFieldsAreTouched(aControl.get(key))){ - areAllTouched = false; - } - }) - // const areAllTouched = controlKeys.reduce((acc, key)=>acc && this._allFieldsAreTouched(aControl.get(key)), true); - return areAllTouched; - - }else if(aControl instanceof UntypedFormArray){ - const controls = (aControl as UntypedFormArray).controls; - // const areAllTouched = controls.reduce((acc, control)=>acc && this._allFieldsAreTouched(control), true); - let areAllTouched = true; - // controls.reduce((acc, control)=>acc && this._allFieldsAreTouched(control), true); - controls.forEach(control=>{ - if(!this.allFieldsAreTouched(control)){ - areAllTouched = false; - } - }); - return areAllTouched; - } - - - return false; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html deleted file mode 100644 index 69b4f0247..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html +++ /dev/null @@ -1,32 +0,0 @@ -
-

{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.TEMPLATE-OUTLINE' | translate}}

-
- - - -
-
- keyboard_arrow_up -
-
-
-
- keyboard_arrow_down -
-
-
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss deleted file mode 100644 index dc1e64f35..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.scss +++ /dev/null @@ -1,92 +0,0 @@ -$scroller-height: 3em; -.scroll-container { - // overflow-y: auto; - max-height: 60vh; - overflow-y: scroll; - padding-left: .2em; - padding-right: 1em; - // padding-top: $scroller-height; - // padding-bottom: $scroller-height; -} - -// #style-6::-webkit-scrollbar-track -// { -// -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); -// background-color: #F5F5F5; -// } - -// #style-6::-webkit-scrollbar -// { -// width: 6px; -// background-color: #F5F5F5; -// } - -// #style-6::-webkit-scrollbar-thumb -// { -// background-color: rgb(162, 163, 163); -// background-image: -webkit-linear-gradient(45deg, -// rgba(255, 255, 255, .2) 25%, -// transparent 25%, -// transparent 50%, -// rgba(255, 255, 255, .2) 50%, -// rgba(255, 255, 255, .2) 75%, -// transparent 75%, -// transparent) -// } - - -#tocentrytable::-webkit-scrollbar-track -{ - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); - border-radius: 10px; - background-color: #F5F5F5; -} - -#tocentrytable::-webkit-scrollbar -{ - width: 4px; - background-color: #F5F5F5; -} - -#tocentrytable::-webkit-scrollbar-thumb -{ - border-radius: 2px; - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); - background-color: rgb(158, 158, 158);// #FFF;//$blue-color-light;// rgb(162, 163, 163);// #D62929; -} - - -#guide-steps{ - color: #212121; - opacity: 0.6; - font-size: 1.6em; - margin-top: 0px; -} - -.table-container{ - position: relative; -} -.table-scroller{ - // background-color: #5cf7f221; - position: absolute; - width: 95%; - height: $scroller-height; - display: flex; - align-items: center; - justify-content: center; - // z-index: -9999; -} -.top-scroller{ - top: 1px; - background: rgb(255,255,255); - background: linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(92,247,242,0.4542191876750701) 100%); -} -.bottom-scroller{ - bottom: 1px; - background: rgb(255,255,255); - background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(92,247,242,0.4542191876750701) 100%); -} - -.opacity-0{ - opacity: 0 !important; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts deleted file mode 100644 index 9fe19a5b9..000000000 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts +++ /dev/null @@ -1,605 +0,0 @@ -import { DOCUMENT } from '@angular/common'; -import { AfterViewInit, Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormArray } from '@angular/forms'; -import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { DragulaService } from 'ng2-dragula'; -import { interval } from 'rxjs'; -import { filter, takeUntil } from 'rxjs/operators'; -import { NewEntryType, TableUpdateInfo, ToCEntry, ToCEntryType } from './table-of-contents-entry'; - - -@Component({ - selector: 'dataset-profile-table-of-contents', - styleUrls: ['./table-of-contents.scss'], - templateUrl: './table-of-contents.html' -}) -export class DatasetProfileTableOfContents extends BaseComponent implements OnInit, AfterViewInit { - - @Input() links: ToCEntry[]; - @Input() itemSelected: ToCEntry; - @Input() colorizeInvalid: boolean = false; - @Input() viewOnly: boolean; - - - @Output() itemClick = new EventEmitter(); - // @Output() newEntry = new EventEmitter(); - @Output() removeEntry = new EventEmitter(); - @Output() createEntry = new EventEmitter(); - @Output() dataNeedsRefresh = new EventEmitter(); - - isDragging: boolean = false; - draggingItemId: string = null; - tocEntryType = ToCEntryType; - - DRAGULA_ITEM_ID_PREFIX = "table_item_id_"; - ROOT_ID: string = "ROOT_ID";//no special meaning - private _dragStartedAt; - private VALID_DROP_TIME = 500;//ms - overcontainer: string = null; - - $clock = interval(10); - scrollTableTop = false; - scrollTableBottom = false; - pxToScroll = 15; - - constructor( - @Inject(DOCUMENT) private _document: Document, - private dragulaService: DragulaService, - private snackbar: MatSnackBar, - private language: TranslateService - ) { - super(); - - if (this.dragulaService.find('TABLEDRAG')) { - this.dragulaService.destroy('TABLEDRAG'); - } - - const dragula = this.dragulaService.createGroup('TABLEDRAG', {}); - - const drake = dragula.drake; - - drake.on('drop', (el, target, source, sibling) => { - - if (this._dragStartedAt) { - const timeNow = new Date().getTime(); - - if (timeNow - this._dragStartedAt > this.VALID_DROP_TIME) { - // console.log('timenow: ', timeNow); - // console.log('timestarted', this._dragStartedAt); - this._dragStartedAt = null; - - } else { - this.dataNeedsRefresh.emit();// even though the data is not changed the TABLE DRAG may has changed - return; - } - } else { - this.dataNeedsRefresh.emit();// even though the data is not changed the TABLE DRAG may has changed - return; - - } - - const elementId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - const targetId = target.id as string; - const sourceId = source.id as string; - - - if (!(elementId && targetId && sourceId)) { - console.info('Elements do not have an id'); - this.dataNeedsRefresh.emit(); - return; - } - - - const element: ToCEntry = this._findTocEntryById(elementId, this.links); - const targetContainer: ToCEntry = this._findTocEntryById(targetId, this.links); - const sourceContainer: ToCEntry = this._findTocEntryById(sourceId, this.links); - - if (!(element && (targetContainer || ((element.type === ToCEntryType.Page) && (targetId === this.ROOT_ID))) && (sourceContainer || ((element.type === ToCEntryType.Page) && (sourceId === this.ROOT_ID))))) { - // console.info('Could not find elements'); - this.dataNeedsRefresh.emit(); - //TODO: angular update //drake.cancel(true); - return; - } - - - switch (element.type) { - case ToCEntryType.FieldSet: { - if (targetContainer.type != this.tocEntryType.Section) { - // const message = 'Fieldset can only be child of Subsections'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.FIELDSET-MUST-HAVE-PARENT-SECTION'); - // console.error(message); - this.notifyUser(message) - this.dataNeedsRefresh.emit(); - return; - } - - //check if target container has no sections - if ((targetContainer.form.get('sections') as UntypedFormArray).length) { - // const message = 'Cannot have inputs and sections on the same level'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL'); - this.notifyUser(message); - // console.error(message); - this.dataNeedsRefresh.emit(); - return; - } - - const fieldsetForm = element.form; - const targetFieldsets = targetContainer.form.get('fieldSets') as UntypedFormArray; - const sourceFieldsets = sourceContainer.form.get('fieldSets') as UntypedFormArray; - - if (!targetFieldsets) { - console.info('Not target fieldsets container found'); - this.dataNeedsRefresh.emit(); - return; - } - - let sourceOrdinal = -1; - let idx = -1; - sourceFieldsets.controls.forEach((elem, index) => { - if (elem.get('id').value === elementId) { - sourceOrdinal = elem.get('ordinal').value; - idx = index - } - }); - - if (sourceOrdinal >= 0 && idx >= 0) { - sourceFieldsets.removeAt(idx); - - sourceFieldsets.controls.forEach(control => { - const ordinal = control.get('ordinal'); - if ((ordinal.value >= sourceOrdinal) && sourceOrdinal > 0) { - const updatedOrdinalVal = ordinal.value - 1; - ordinal.setValue(updatedOrdinalVal); - } - }); - sourceFieldsets.controls.sort(this._compareOrdinals); - } - - let position: number = targetFieldsets.length; - - if (!sibling || !sibling.id) { - console.info('No sibling Id found'); - } else { - const siblingId = (sibling.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - let siblingIndex = -1; - targetFieldsets.controls.forEach((e, idx) => { - if (e.get('id').value === siblingId) { - siblingIndex = idx; - position = e.get('ordinal').value; - } - - }); - - if (siblingIndex >= 0) { //sibling found - - targetFieldsets.controls.filter(control => control.get('ordinal').value >= position).forEach(control => { - const ordinal = control.get('ordinal'); - const updatedOrdinalVal = ordinal.value + 1; - ordinal.setValue(updatedOrdinalVal); - }) - } - - } - - - fieldsetForm.get('ordinal').setValue(position); - targetFieldsets.insert(position, fieldsetForm); - targetFieldsets.controls.sort(this._compareOrdinals); - this.dataNeedsRefresh.emit({ draggedItemId: elementId }); - - break; - } - case ToCEntryType.Section: { - - if (targetContainer.type == ToCEntryType.Section) { - if ((targetContainer.form.get('fieldSets') as UntypedFormArray).length) { - // const message = 'Cannot have inputs and sections on the same level'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL');; - this.notifyUser(message); - // console.info(message); - this.dataNeedsRefresh.emit(); - return; - } - - const targetSections = targetContainer.form.get('sections') as UntypedFormArray; - const elementSectionForm = element.form; - const sourceSections = elementSectionForm.parent as UntypedFormArray; - - if (!(targetSections && sourceSections && elementSectionForm)) { - console.info('Could not load sections'); - this.dataNeedsRefresh.emit(); - return; - } - - let idx = -1; - sourceSections.controls.forEach((section, i) => { - if (section.get('id').value === elementId) { - idx = i; - } - }); - - if (!(idx >= 0)) { - console.info('Could not find element in Parent container'); - this.dataNeedsRefresh.emit(); - return; - } - - sourceSections.controls.filter(control => control.get('ordinal').value >= elementSectionForm.get('ordinal').value).forEach(control => { - const ordinal = control.get('ordinal'); - const updatedOrdinalVal = ordinal.value ? ordinal.value - 1 : 0; - ordinal.setValue(updatedOrdinalVal); - }); - - - sourceSections.removeAt(idx); - - let targetOrdinal = targetSections.length; - - if (sibling && sibling.id) { - const siblingId = sibling.id.replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - - targetSections.controls.forEach((section, i) => { - if (section.get('id').value === siblingId) { - targetOrdinal = section.get('ordinal').value; - } - }) - - // if(targetOrdinal!=targetSections.length){//mporei na einai idio - // section.get('ordinal').setValue(i+1); - targetSections.controls.filter(control => control.get('ordinal').value >= targetOrdinal).forEach(control => { - const ordinal = control.get('ordinal'); - const updatedOrdinalVal = ordinal.value + 1; - ordinal.setValue(updatedOrdinalVal); - }); - // } - - } else { - console.info('no siblings found'); - } - elementSectionForm.get('ordinal').setValue(targetOrdinal); - targetSections.insert(targetOrdinal, elementSectionForm); - - } else if (targetContainer.type === ToCEntryType.Page) { - // const pageId = targetContainer.form.get('id').value; - - const rootform = targetContainer.form.root; - const sectionForm = element.form; - const parentSections = sectionForm.parent as UntypedFormArray; - - let parentIndex = -1; - parentSections.controls.forEach((section, i) => { - if (section.get('id').value === elementId) { - parentIndex = i - } - }) - - - if (parentIndex < 0) { - console.info('could not locate section in parents array'); - this.dataNeedsRefresh.emit(); - return; - } - - //update parent sections ordinal - parentSections.controls.filter(section => section.get('ordinal').value >= sectionForm.get('ordinal').value).forEach(section => { - const ordinal = section.get('ordinal'); - const updatedOrdinalVal = ordinal.value ? ordinal.value - 1 : 0; - ordinal.setValue(updatedOrdinalVal); - }) - - parentSections.removeAt(parentIndex); - - - - let position = 0; - if (targetContainer.subEntries) { - position = targetContainer.subEntries.length; - } - //populate sections - const targetSectionsArray = rootform.get('sections') as UntypedFormArray; - - - if (sibling && sibling.id) { - const siblingId = sibling.id.replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - let indx = -1; - - targetContainer.subEntries.forEach((e, i) => { - if (e.form.get('id').value === siblingId) { - indx = i; - position = e.form.get('ordinal').value; - } - }); - if (indx >= 0) { - - // e.form.get('ordinal').setValue(i+1); - targetContainer.subEntries.filter(e => e.form.get('ordinal').value >= position).forEach(e => { - const ordinal = e.form.get('ordinal'); - const updatedOrdinalVal = ordinal.value + 1; - ordinal.setValue(updatedOrdinalVal); - }); - } - - } else { - console.info('No sibling found'); - } - - sectionForm.get('ordinal').setValue(position); - sectionForm.get('page').setValue(targetContainer.id); - targetSectionsArray.push(sectionForm); - - } else { - // const message = 'Drag not support to specific container'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.DRAG-NOT-SUPPORTED'); - this.notifyUser(message); - // console.info(message); - this.dataNeedsRefresh.emit(); - return; - } - - - - this.dataNeedsRefresh.emit({ draggedItemId: elementId }); - break; - } - case ToCEntryType.Page: { - if (targetId != this.ROOT_ID) { - // const message = 'A page element can only be at top level'; - const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.PAGE-ELEMENT-ONLY-TOP-LEVEL'); - this.notifyUser(message); - // console.info(message); - this.dataNeedsRefresh.emit(); - return; - } - - const rootForm = element.form.root; - if (!rootForm) { - console.info('Could not find root!') - this.dataNeedsRefresh.emit(); - return; - } - - - const pages = rootForm.get('pages') as UntypedFormArray; - const pageForm = element.form; - - let index = -1; - - pages.controls.forEach((page, i) => { - if (page.get('id').value === elementId) { - index = i; - } - }); - - if (index < 0) { - console.info('Could not locate page on pages'); - this.dataNeedsRefresh.emit(); - return; - } - - - //ordinality - pages.controls.filter(page => page.get('ordinal').value >= pageForm.get('ordinal').value).forEach(page => { - const ordinal = page.get('ordinal'); - const ordinalVal = ordinal.value ? ordinal.value - 1 : 0; - ordinal.setValue(ordinalVal); - }); - - pages.removeAt(index); - - let targetPosition = pages.length; - - if (sibling) { - const siblingId = sibling.id.replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - - pages.controls.forEach((page, i) => { - if (page.get('id').value === siblingId) { - targetPosition = page.get('ordinal').value; - } - }); - } - pageForm.get('ordinal').setValue(targetPosition); - - //update ordinality - pages.controls.filter(page => page.get('ordinal').value >= targetPosition).forEach(page => { - const ordinal = page.get('ordinal'); - const ordinalVal = ordinal.value + 1; - ordinal.setValue(ordinalVal); - }); - - - pages.insert(targetPosition, pageForm); - this.dataNeedsRefresh.emit({ draggedItemId: elementId }); - break; - } - default: - - console.info('Could not support moving objects for specific type of element'); - this.dataNeedsRefresh.emit(); - return; - - } - }); - - - drake.on('drag', (el, source) => { - this._dragStartedAt = new Date().getTime(); - // console.log('drag fired'); - this.isDragging = true; - this.draggingItemId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); - - // setTimeout(() => { - // if(this.isDragging){ - // this._scrollIntoDragginItem(this.draggingItemId); - // } - // }, this.VALID_DROP_TIME); - }); - drake.on('over', (el, container, source) => { - try { - this.overcontainer = container.id; - } catch (error) { - this.overcontainer = null; - } - }); - drake.on('dragend', (el) => { - this.isDragging = false; - this.draggingItemId = null; - this.overcontainer = null; - }); - - - - - } - ngAfterViewInit(): void { - - const top = document.querySelector('.top-scroller'); - const bottom = document.querySelector('.bottom-scroller'); - const tableDiv = document.querySelector('#tocentrytable'); - - try { - top.addEventListener('mouseover', (e) => { this.scrollTableTop = true; }, { - passive: true - }); - bottom.addEventListener('mouseover', (e) => { this.scrollTableBottom = true; }, { - passive: true - }); - - top.addEventListener('mouseout', (e) => { this.scrollTableTop = false }, { - passive: true - }); - bottom.addEventListener('mouseout', (e) => { this.scrollTableBottom = false; }, { - passive: true - }); - - - this.$clock - .pipe( - takeUntil(this._destroyed), - filter(() => this.scrollTableTop) - ) - .subscribe(() => { - try { - tableDiv.scrollBy(0, -this.pxToScroll); - } catch { } - }); - this.$clock - .pipe( - takeUntil(this._destroyed), - filter(() => this.scrollTableBottom) - ) - .subscribe(() => { - try { - tableDiv.scrollBy(0, this.pxToScroll); - } catch { } - }); - } catch { - console.log('could not find scrolling elements'); - } - - - } - - private _scrollIntoDragginItem(id: string) { - - // const table = document.getElementById('tocentrytable'); - // if(table){ - // // const element = document.getElementById('TABLE_ENTRY'+id); - // console.log('Table found!'); - // const element = document.getElementById('TABLE_ENTRY' + id); - // const elementFromTable = table.closest('#TABLE_ENTRY'+ id); - - - // if(elementFromTable){ - // console.log('found from table:', elementFromTable); - // } - // if(element){ - // console.log('Element found!'); - // // element.classList.add('text-danger'); - // // console.log(element); - - // const tableRect = table.getBoundingClientRect(); - // const elementRect = element.getBoundingClientRect(); - - - // console.log('tablerect :',tableRect); - // console.log('elementRect :',elementRect); - - // const dY = elementRect.top - tableRect.top; - // console.log('Distance from table is ', dY); - // // table.scroll({top:dY,behavior:'smooth'}); - // console.log('found from document ', element); - - // // element.scrollIntoView(); - // } - // // element.scrollIntoView(); - // } - } - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { - if (!tocentries) { - return null; - } - - let tocEntryFound = tocentries.find(entry => entry.id === id); - - if (tocEntryFound) { - return tocEntryFound; - } - - for (let entry of tocentries) { - const result = this._findTocEntryById(id, entry.subEntries); - if (result) { - tocEntryFound = result; - break; - } - } - - return tocEntryFound ? tocEntryFound : null; - } - - ngOnInit(): void { - - - } - - - itemClicked(item: ToCEntry) { - //leaf node - this.itemClick.emit(item); - } - - // addNewEntry(tce: ToCEntry){ - // this.newEntry.emit(tce); - // } - deleteEntry(currentLink: ToCEntry) { - this.removeEntry.emit(currentLink); - } - - createNewEntry(newEntry: NewEntryType) { - this.createEntry.emit(newEntry); - } - onDataNeedsRefresh() { - this.dataNeedsRefresh.emit(); - } - - notifyUser(message: string) { - this.snackbar.open(message, null, this._snackBarConfig); - } - - private _snackBarConfig: MatSnackBarConfig = { - duration: 2000 - } - - private _compareOrdinals(a, b) { - - const aValue = a.get('ordinal').value as number; - const bValue = b.get('ordinal').value as number; - - // if(!aValue || !bValue) return 0; - return aValue - bValue; - } - - -} diff --git a/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts b/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts index ecb2df333..08cc416ad 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/description-template.module.ts @@ -2,7 +2,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -33,7 +32,6 @@ import { ImportDescriptionTemplateDialogComponent } from './listing/import-descr imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, DescriptionTemplateRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts index c0cce8cea..fa3871907 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { ImportDmpBlueprintDialogComponent } from './listing/import-dmp-blueprin imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, DmpBlueprintRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts b/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts index 4abe57908..d3ae0db1f 100644 --- a/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts +++ b/dmp-frontend/src/app/ui/admin/index-managment/index-managment.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit } from '@angular/core'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; import { BaseComponent } from '@common/base/base.component'; import { takeUntil } from 'rxjs/operators'; import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; @@ -16,7 +15,6 @@ import { MaintenanceService } from '@app/core/services/maintenance/maintenance.s export class IndexManagmentComponent extends BaseComponent implements OnInit { constructor( - private datasetService: DatasetService, private uiNotificationService: UiNotificationService, private translate: TranslateService, private router: Router, diff --git a/dmp-frontend/src/app/ui/admin/language/language.module.ts b/dmp-frontend/src/app/ui/admin/language/language.module.ts index f188ebe86..b3c3fd6da 100644 --- a/dmp-frontend/src/app/ui/admin/language/language.module.ts +++ b/dmp-frontend/src/app/ui/admin/language/language.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-ed imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, LanguageRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts b/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts index c324591a2..0e494b5fe 100644 --- a/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts +++ b/dmp-frontend/src/app/ui/admin/notification-template/notification-template.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -22,7 +21,6 @@ import { EditorModule } from '@tinymce/tinymce-angular'; imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, NotificationTemplateRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts b/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts index 8a4e8ab4d..57eca9e06 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/reference-type.module.ts @@ -9,7 +9,6 @@ import { HybridListingModule } from '@common/modules/hybrid-listing/hybrid-listi import { TextFilterModule } from '@common/modules/text-filter/text-filter.module'; import { UserSettingsModule } from '@common/modules/user-settings/user-settings.module'; import { ReferenceTypeListingFiltersComponent } from './listing/filters/reference-type-listing-filters.component'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { NgxDropzoneModule } from 'ngx-dropzone'; import { DragDropModule } from '@angular/cdk/drag-drop'; @@ -28,7 +27,6 @@ import { ReferenceTypeListingComponent } from './listing/reference-type-listing. CommonModule, CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, ReferenceTypeRoutingModule, EditorModule, diff --git a/dmp-frontend/src/app/ui/admin/reference/reference.module.ts b/dmp-frontend/src/app/ui/admin/reference/reference.module.ts index 8bcc715e9..e7a9a6940 100644 --- a/dmp-frontend/src/app/ui/admin/reference/reference.module.ts +++ b/dmp-frontend/src/app/ui/admin/reference/reference.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-ed imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, ReferenceRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts b/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts index bd58b40e6..79e6dceb0 100644 --- a/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts +++ b/dmp-frontend/src/app/ui/admin/tenant/tenant.module.ts @@ -1,7 +1,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { NgModule } from "@angular/core"; import { AutoCompleteModule } from "@app/library/auto-complete/auto-complete.module"; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormattingModule } from '@common/formatting/common-formatting.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; @@ -20,7 +19,6 @@ import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-ed imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, ConfirmationDialogModule, TenantRoutingModule, NgxDropzoneModule, diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts index e96011ff1..e9bdb74cf 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts @@ -11,7 +11,7 @@ import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service' import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; import { takeUntil } from 'rxjs/operators'; -import { StartNewDmpDialogComponent } from '../dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; +import { StartNewDmpDialogComponent } from '../dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component'; @Component({ diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts index 915656f2c..6d05911fb 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts @@ -6,13 +6,13 @@ import { DashboardComponent } from '@app/ui/dashboard/dashboard.component'; import { DashboardRoutingModule } from '@app/ui/dashboard/dashboard.routing'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; -import { DatasetCopyDialogModule } from '../dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module'; import { DescriptionModule } from '../description/description.module'; import { DmpModule } from '../dmp/dmp.module'; import { DraftsComponent } from './drafts/drafts.component'; import { RecentEditedActivityComponent } from './recent-edited-activity/recent-edited-activity.component'; import { RecentEditedDescriptionActivityComponent } from './recent-edited-description-activity/recent-edited-description-activity.component'; import { RecentEditedDmpActivityComponent } from './recent-edited-dmp-activity/recent-edited-dmp-activity.component'; +import { StartNewDmpDialogModule } from '../dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.module'; @NgModule({ imports: [ @@ -21,12 +21,13 @@ import { RecentEditedDmpActivityComponent } from './recent-edited-dmp-activity/r DashboardRoutingModule, ExportMethodDialogModule, ConfirmationDialogModule, - DatasetCopyDialogModule, + // DatasetCopyDialogModule, FormsModule, ReactiveFormsModule, DmpModule, //TODO: add only listing component to a seperate module - DescriptionModule //TODO: add only listing component to a seperate module + DescriptionModule, //TODO: add only listing component to a seperate module + StartNewDmpDialogModule ], declarations: [ DashboardComponent, diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts index d71b40a1c..e5dd00d2c 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts @@ -7,17 +7,18 @@ import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-it import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from "@app/core/model/dmp/dmp"; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { FileFormat } from '@app/core/model/file/file-format.model'; +import { Reference } from '@app/core/model/reference/reference'; import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { DashboardService } from "@app/core/services/dashboard/dashboard.service"; +import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { BaseComponent } from '@common/base/base.component'; import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { AuthService } from '../../../core/services/auth/auth.service'; -import { FileFormat } from '@app/core/model/file/file-format.model'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; @Component({ selector: 'app-drafts', diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index a94a3e005..2e8673967 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -7,8 +7,9 @@ import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-it import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; import { FileFormat } from '@app/core/model/file/file-format.model'; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { Reference } from '@app/core/model/reference/reference'; import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DashboardService } from '@app/core/services/dashboard/dashboard.service'; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts index 8ae9d67ca..72d53051f 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts @@ -6,7 +6,8 @@ import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; -import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { Reference } from '@app/core/model/reference/reference'; import { DescriptionLookup } from '@app/core/query/description.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DescriptionService } from '@app/core/services/description/description.service'; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts index 3ca4237db..16377d759 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts @@ -14,7 +14,6 @@ import { DashboardService } from '@app/core/services/dashboard/dashboard.service import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { DmpEditorModel } from '@app/ui/dmp/editor/dmp-editor.model'; import { BaseComponent } from '@common/base/base.component'; import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; @@ -37,7 +36,6 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O listingItems: RecentActivityItem[]; datasetActivities: DatasetListingModel[]; - dmpModel: DmpEditorModel; isDraft: boolean; totalCount: number; diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.html deleted file mode 100644 index 2421c0c98..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.html +++ /dev/null @@ -1,17 +0,0 @@ -
-
-
{{'DATASET-WIZARD.DIALOGUE.TITLE' | translate}}
-
close
-
-
- - - - - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss deleted file mode 100644 index 69f3e2062..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.scss +++ /dev/null @@ -1,50 +0,0 @@ -.confirmation-message { - padding-bottom: 20px; -} - -.close-btn { - cursor: pointer; -} - -.dataset-copy-dialog { - margin-bottom: 1.125rem; -} - -.cancel-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid #b5b5b5; - border-radius: 30px; -min-width: 101px; - height: 43px; - color: #212121; - font-weight: 500; -} - -.confirm-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid var(--primary-color); - border-radius: 30px; - opacity: 1; -min-width: 101px; - height: 43px; - color: var(--primary-color); - font-weight: 500; -} - -.confirm-btn:hover { - background-color: var(--primary-color); - color: #ffffff; -} - -.close-icon { - cursor: pointer; - // margin-right: 20px; - padding: .4rem; - width: auto !important; - height: auto !important; -} - -.close-icon:hover { - background-color: #ECECED !important; - border-radius: 50%; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts deleted file mode 100644 index dc98a3e37..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component.ts +++ /dev/null @@ -1,95 +0,0 @@ - -import { map, filter } from 'rxjs/operators'; -import { Component } from "@angular/core"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; -import { SingleAutoCompleteConfiguration } from "../../../../library/auto-complete/single/single-auto-complete-configuration"; -import { Observable } from "rxjs"; -import { DataTableRequest } from "../../../../core/model/data-table/data-table-request"; -import { DmpCriteria } from "../../../../core/query/dmp/dmp-criteria"; -import { DmpListingModel } from "../../../../core/model/dmp/dmp-listing"; -import { DmpService } from "../../../../core/services/dmp/dmp.service"; -import { Inject } from "@angular/core"; -import { DmpModel } from "../../../../core/model/dmp/dmp"; -import { TranslateService } from "@ngx-translate/core"; - -@Component({ - selector: 'dataset-copy-dialogue-component', - templateUrl: 'dataset-copy-dialogue.component.html', - styleUrls: ['./dataset-copy-dialogue.component.scss'], -}) -export class DatasetCopyDialogueComponent { - - dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - dmpModel: DmpModel; - datasetDescriptionTemplateLabel: String; - - constructor( - public dialogRef: MatDialogRef, - public dmpService: DmpService, - public language: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } - - ngOnInit() { - this.dmpAutoCompleteConfiguration = { - filterFn: this.searchDmp.bind(this), - initialItems: (extraData) => this.searchDmp(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - }; - } - - cancel() { - this.dialogRef.close(this.data); - } - - confirm() { - this.datasetProfileValidate().subscribe(x => { - if (this.data.datasetProfileExist) { - this.dialogRef.close(this.data); - } - else if (!this.data.datasetProfileExist) { - this.data.formControl.setErrors({ 'incorrect': true }); - } - }); - } - - searchDmp(query: string): Observable { - const fields: Array = new Array(); - fields.push('asc'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = query; - dmpDataTableRequest.criteria.datasetTemplates = [this.data.datasetProfileId]; - return this.dmpService.getPaged(dmpDataTableRequest, "profiles").pipe(map(x => x.data)); - } - - datasetProfileValidate() { - return this.dmpService.getSingle(this.data.formControl.value.id).pipe(map(result => result as DmpModel), - map(result => { - this.dmpModel = result - this.dmpModel.profiles.forEach((element) => { - if (element.id == this.data.datasetProfileId) { - this.data.datasetProfileExist = true; - } - }) - })); - } - - getErrorMessage() { - return this.language.instant('DATASET-WIZARD.DIALOGUE.ERROR-MESSAGE'); - } - - hasValidDatasetProfile() { - if (this.data.datasetProfileExist) { - return true; - } - else { - return false; - } - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts deleted file mode 100644 index d1c8a4602..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { DatasetCopyDialogueComponent } from './dataset-copy-dialogue.component'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - AutoCompleteModule - ], - declarations: [ - DatasetCopyDialogueComponent - ] -}) -export class DatasetCopyDialogModule { } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html deleted file mode 100644 index c56c214e4..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html +++ /dev/null @@ -1,107 +0,0 @@ -
-
-

{{'DATASET-EDITOR.TITLE.INTRO' | translate}}

- {{'DATASET-EDITOR.TITLE.INTRO-TIP' | translate}} -
-
- -
-
-
1.1 {{'DATASET-EDITOR.FIELDS.TITLE' | translate}}*
- - -
- - - {{formGroup.get('label').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
- -
-
-
1.2 {{'DATASET-EDITOR.FIELDS.DESCRIPTION' | translate}}
- {{'DATASET-EDITOR.HINT.DESCRIPTION' | translate}} - -
- - -
- {{formGroup.get('description').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - - -
1.4 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
-
- - - -
- {{profile.label}} -
-
-
- {{formGroup.get('profile').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
-
- - - - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss deleted file mode 100644 index b006bc845..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.scss +++ /dev/null @@ -1,117 +0,0 @@ -.dataset-editor { - .intro { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - opacity: 1; - margin: 3rem 0rem 3rem 0rem; - } - - .heading { - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-top: 1.625rem; - margin-bottom: 0.625rem; - } - - .hint { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-bottom: 2.125rem; - } - - .title-form, - .description-form, - .profile-form { - text-align: left; - font-weight: 400; - font-size: 16px; - letter-spacing: 0.15px; - color: #7d7d7d; - opacity: 1; - margin-bottom: 1rem; - } - - // textarea::placeholder { - // font-style: oblique; - // } - - .input-btn { - border: none; - color: #aaaaaa; - background-color: #ffffff00; - cursor: pointer; - } - - .input-btn :hover { - color: var(--primary-color-3) !important; - } - - .dmp-link { - color: #3fafac; - font-weight: 400; - font-size: 16px; - cursor: pointer; - } - - .dmp-link:hover { - text-decoration: underline; - } -} - -::ng-deep .title-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .description-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .uri-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .tags-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .profile-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - - - - -::ng-deep .title-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .description-form .mat-form-field-appearance-outline .mat-form-field-infix { - // font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .uri-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .tags-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - -::ng-deep .profile-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts deleted file mode 100644 index e9b339ad4..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { Router } from '@angular/router'; -import { BaseComponent } from '@common/base/base.component'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; -import { TranslateService } from '@ngx-translate/core'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { takeUntil } from 'rxjs/operators'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { MatDialog } from '@angular/material/dialog'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { Guid } from '@common/types/guid'; -import { nameof } from 'ts-simple-nameof'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; - -@Component({ - selector: 'app-dataset-editor-component', - templateUrl: 'dataset-editor.component.html', - styleUrls: ['./dataset-editor.component.scss'] -}) -export class DatasetEditorComponent extends BaseComponent { - - @Input() formGroup: UntypedFormGroup; - // @Input() formGroup: FormGroup = null; - @Input() availableProfiles: DatasetProfileModel[]; - @Input() dmpId: string; - showUri: boolean = false; - dmpText: string = null; - viewOnly = false; - - constructor( - private router: Router, - private dmpBlueprintService: DmpBlueprintService, - private dialog: MatDialog, - private guidedTourService: GuidedTourService, - private language: TranslateService - ) { super(); } - - public dashboardTourDmp: GuidedTour = { - tourId: 'only-dmp-tour', - useOrb: true, - steps: [ - { - title: this.dmpText, - content: 'Step 1', - orientation: Orientation.Bottom, - highlightPadding: 3, - isStepUnique: true, - customTopOffset: 8 - } - ] - }; - - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); - const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; - const blueprintId = this.formGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, - [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if(section.hasTemplates){ - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if(this.formGroup.get('dmp').value.datasets != null){ - for(let dataset of this.formGroup.get('dmp').value.datasets){ - if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ - count++; - } - } - if(count === foundTemplate.maxMultiplicity){ - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - } - else{ - this.formGroup.get('profile').setValue(profile); - } - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - } - else { - this.formGroup.get('profile').setValue(profile); - } - }); - } - - getDmpText(): string { - return this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' + - this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' + - this.language.instant('DMP-LISTING.LINK-ZENODO') + ' ' + - this.language.instant('DMP-LISTING.GET-IDEA'); - } - - setDashboardTourDmp(label: string): void { - this.dashboardTourDmp.steps[0].title = this.getDmpText(); - this.dashboardTourDmp.steps[0].selector = '.dmp-tour-' + label; - } - - public restartTour(label: string): void { - this.setDashboardTourDmp(label); - this.guidedTourService.startTour(this.dashboardTourDmp); - - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - public compareWith(object1: any, object2: any) { - return object1 && object2 && object1.id === object2.id; - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts deleted file mode 100644 index 47ec72a17..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard-editor.model.ts +++ /dev/null @@ -1,382 +0,0 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { ExternalDatasetType } from '@app/core/common/enum/external-dataset-type'; -import { DataRepositoryModel } from '@app/core/model/data-repository/data-repository'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { ExternalDatasetModel } from '@app/core/model/external-dataset/external-dataset'; -import { RegistryModel } from '@app/core/model/registry/registry'; -import { ServiceModel } from '@app/core/model/service/service'; -import { TagModel } from '@app/core/model/tag/tag'; -import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ValidationContext } from '@common/forms/validation/validation-context'; - -export class DatasetWizardEditorModel { - public id: string; - public label: string; - public profile: DatasetProfileModel; - public uri: String; - public status: number; - public description: String; - public services: ExternalServiceEditorModel[] = []; - public registries: ExternalRegistryEditorModel[] = []; - public dataRepositories: ExternalDataRepositoryEditorModel[] = []; - public tags: ExternalTagEditorModel[] = []; - public externalDatasets: ExternalDatasetEditorModel[] = []; - public dmp: DmpModel; - public dmpSectionIndex: number; - public datasetProfileDefinition: DatasetDescriptionFormEditorModel; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - public isProfileLatestVersion: Boolean; - public modified: Date; - - fromModel(item: DatasetWizardModel): DatasetWizardEditorModel { - this.id = item.id; - this.label = item.label; - this.profile = item.profile; - this.uri = item.uri; - this.status = item.status; - this.description = item.description; - if (item.services) { this.services = item.services.map(x => new ExternalServiceEditorModel().fromModel(x)); } - if (item.registries) { this.registries = item.registries.map(x => new ExternalRegistryEditorModel().fromModel(x)); } - if (item.dataRepositories) { this.dataRepositories = item.dataRepositories.map(x => new ExternalDataRepositoryEditorModel().fromModel(x)); } - if (item.externalDatasets) { this.externalDatasets = item.externalDatasets.map(x => new ExternalDatasetEditorModel().fromModel(x)); } - this.dmp = item.dmp; - this.dmpSectionIndex = item.dmpSectionIndex; - if (item.datasetProfileDefinition) { this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item.datasetProfileDefinition); } - if (item.tags) { this.tags = item.tags.map(x => new ExternalTagEditorModel().fromModel(x)); } - this.isProfileLatestVersion = item.isProfileLatestVersion; - this.modified = new Date(item.modified); - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - if (context == null) { context = this.createValidationContext(); } - const formBuilder = new UntypedFormBuilder(); - const formGroup = formBuilder.group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], - label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], - uri: [{ value: this.uri, disabled: disabled }, context.getValidation('uri').validators], - status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], - description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], - dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators], - dmpSectionIndex: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators], - //externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators], - tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators], - //registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators], - //dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators], - //services: [{ value: this.services, disabled: disabled }, context.getValidation('services').validators], - profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators], - modified: [{value: this.modified, disabled: disabled}, context.getValidation('modified').validators] - }); - - const externalDatasetsFormArray = new Array(); - //if (this.externalDatasets && this.externalDatasets.length > 0) { - this.externalDatasets.forEach(item => { - externalDatasetsFormArray.push(item.buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('externalDatasets', formBuilder.array(externalDatasetsFormArray)); - - // const tagsFormArray = new Array(); - // if (this.tags && this.tags.length > 0) { - // this.tags.forEach(item => { - // tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled)); - // }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - // formGroup.addControl('tags', formBuilder.array(tagsFormArray)); - - const registriesFormArray = new Array(); - //if (this.registries && this.registries.length > 0) { - this.registries.forEach(item => { - registriesFormArray.push(item.buildForm(context.getValidation('registries').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('registries', formBuilder.array(registriesFormArray)); - - const dataRepositoriesFormArray = new Array(); - //if (this.dataRepositories && this.dataRepositories.length > 0) { - this.dataRepositories.forEach(item => { - dataRepositoriesFormArray.push(item.buildForm(context.getValidation('dataRepositories').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('dataRepositories', formBuilder.array(dataRepositoriesFormArray)); - - const servicesFormArray = new Array(); - // if (this.services && this.services.length > 0) { - this.services.forEach(item => { - servicesFormArray.push(item.buildForm(context.getValidation('services').descendantValidations, disabled)); - }); - // } else { - // //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled)); - // } - formGroup.addControl('services', formBuilder.array(servicesFormArray)); - - // const tagsFormArray = new Array(); - // this.tags.forEach(item => { - // tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled)); - // }); - // formGroup.addControl('tags', formBuilder.array(tagsFormArray)); - - if (this.datasetProfileDefinition) { formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinition.buildForm()); } - // formGroup.addControl('profile', this.profile.buildForm()); - return formGroup; - } - - createValidationContext(): ValidationContext { - const baseContext: ValidationContext = new ValidationContext(); - baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); - baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'profile')] }); - baseContext.validation.push({ key: 'uri', validators: [BackendErrorValidator(this.validationErrorModel, 'uri')] }); - baseContext.validation.push({ key: 'status', validators: [BackendErrorValidator(this.validationErrorModel, 'status')] }); - baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); - baseContext.validation.push({ key: 'services', validators: [BackendErrorValidator(this.validationErrorModel, 'services')] }); - baseContext.validation.push({ key: 'registries', validators: [BackendErrorValidator(this.validationErrorModel, 'registries')] }); - baseContext.validation.push({ key: 'dataRepositories', validators: [BackendErrorValidator(this.validationErrorModel, 'dataRepositories')] }); - baseContext.validation.push({ key: 'externalDatasets', validators: [BackendErrorValidator(this.validationErrorModel, 'externalDatasets')] }); - baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.validationErrorModel, 'dmp')] }); - baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] }); - baseContext.validation.push({ key: 'datasetProfileDefinition', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetProfileDefinition')] }); - baseContext.validation.push({ key: 'tags', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetProfileDefinition')] }); - baseContext.validation.push({ key: 'modified', validators: []}); - return baseContext; - } -} - -export class ExternalTagEditorModel { - public abbreviation: String; - public definition: String; - public id: String; - public name: String; - public reference: String; - public uri: String; - - constructor(id?: String, name?: String) { - this.id = id; - this.name = name; - } - - fromModel(item: TagModel): ExternalTagEditorModel { - this.id = item.id; - this.name = item.name; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - name: [this.name] - }); - } -} - -export class ExternalServiceEditorModel { - public id: String; - public abbreviation: String; - public definition: String; - public uri: String; - public label: String; - public reference: String; - public source: String; - - constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) { - this.id = id; - this.abbreviation = abbreviation; - this.definition = definition; - this.uri = uri; - this.label = label; - this.reference = reference; - this.source = source; - } - - fromModel(item: ServiceModel): ExternalServiceEditorModel { - this.id = item.id; - this.abbreviation = item.abbreviation; - this.definition = item.definition; - this.uri = item.uri; - this.label = item.label; - this.reference = item.reference; - this.source = item.source; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - abbreviation: [this.abbreviation], - label: [this.label, Validators.required], - reference: [this.reference], - uri: [this.uri, Validators.required], - definition: [this.definition], - source: [this.source] - }); - } -} - -export class ExternalRegistryEditorModel { - public abbreviation: String; - public definition: String; - public id: String; - public label: String; - public reference: String; - public uri: String; - public source: String - - constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) { - this.abbreviation = abbreviation; - this.definition = definition; - this.id = id; - this.label = label; - this.reference = reference; - this.uri = uri; - this.source = source; - } - - fromModel(item: RegistryModel): ExternalRegistryEditorModel { - this.abbreviation = item.abbreviation; - this.definition = item.definition; - this.id = item.id; - this.label = item.label; - this.reference = item.pid ? item.pid : item.reference; - this.uri = item.uri; - this.source = item.source - - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - abbreviation: [this.abbreviation], - label: [this.label, Validators.required], - reference: [this.reference], - uri: [this.uri, Validators.required], - definition: [this.definition], - source: [this.source] - }); - } -} - -export class ExternalDatasetEditorModel { - - public abbreviation: String; - public id: String; - public name: String; - public reference: String; - public type: ExternalDatasetType; - public info: String; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - public source: String; - - constructor(id?: string, abbreviation?: string, name?: string, reference?: string, source?: String, info?: string, type?: ExternalDatasetType) { - this.id = id; - this.name = name; - this.abbreviation = abbreviation; - this.reference = reference; - this.info = info; - this.type = type; - this.source = source; - } - - fromModel(item: ExternalDatasetModel): ExternalDatasetEditorModel { - this.abbreviation = item.abbreviation; - this.id = item.id; - this.name = item.name; - this.reference = item.reference; - this.type = item.type; - this.info = item.info; - this.source = item.source; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - abbreviation: [this.abbreviation], - name: [this.name, Validators.required], - reference: [this.reference], - type: [this.type], - info: [this.info], - source: [this.source] - }); - } -} - -export class ExternalDataRepositoryEditorModel { - public id: string; - public name: string; - public abbreviation: string; - public uri: string; - public reference: string; - public info: string; - public created: Date; - public modified: Date; - public source: string; - - constructor(id?: string, name?: string, abbreviation?: string, uri?: string, reference?: string, source?: string) { - this.id = id; - this.name = name; - this.abbreviation = abbreviation; - this.uri = uri; - this.reference = reference; - this.source = source; - } - - fromModel(item: DataRepositoryModel): ExternalDataRepositoryEditorModel { - this.id = item.id; - this.name = item.name; - this.abbreviation = item.abbreviation; - this.uri = item.uri; - this.info = item.info; - this.reference = item.pid; - this.source = item.source; - return this; - } - - buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { - return new UntypedFormBuilder().group({ - id: [this.id], - name: [this.name, [Validators.required]], - abbreviation: [this.abbreviation], - uri: [this.uri, [Validators.required]], - info: [this.info], - reference: [this.reference], - source: [this.source] - }); - } -} - -// export class TagModel implements Serializable { - -// public id: string; -// public name: string; - -// constructor(id?: string, name?: string) { -// this.id = id; -// this.name = name; -// } - -// fromJSONObject(item: any): TagModel { -// this.id = item.id; -// this.name = item.name; -// return this; -// } - -// buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { -// return new FormBuilder().group({ -// id: [this.id], -// name: [this.name] -// }); -// } -// } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html deleted file mode 100644 index 6f65a8697..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ /dev/null @@ -1,288 +0,0 @@ -
-
-
- - -
-
-
-
-
- -
{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}}
-
{{'DMP-EDITOR.TITLE.EDIT-DESCRIPTION' | translate}}
-
{{ formGroup.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
- -
{{'DMP-EDITOR.TITLE.PREVIEW-DATASET' | translate}}
-
-
-
{{'DATASET-LISTING.TOOLTIP.TO-DMP' | translate}}
-
: {{ formGroup.get('dmp').value.label }}
- -
-
-
-
- - - - - - -
- - - -
- -
-
- - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
- chevron_left - {{'DATASET-WIZARD.ACTIONS.BACK-TO' | translate}} -
-
{{'DATASET-LISTING.TOOLTIP.DMP' | translate}}
-
-
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
-
-
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
-
-
- -
-
-
-
- - -
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
-
-
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
- chevron_right -
- -
-
- -
-
-
- - -
-
-
-
-
- - - - - - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss deleted file mode 100644 index 246e7ad8b..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.scss +++ /dev/null @@ -1,524 +0,0 @@ -.main-content { - height: 100vh !important; - margin-top: -80px; -} - -.dataset-wizard { - .toc-pane-container { - &.is-sticky ~ .nav-spacer { - height: 500px; // the container size } - // height: calc(100vh - 100px); // the container size } - } - } - - .step-container { - margin-top: 1em; - } - - .external-item-card { - margin-top: 1em; - } - - .external-item-action-row, - .description-action-row { - margin-top: 1em; - } - - .deleteButton, - .reverseButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .cancelButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .saveButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .saveAndFinalizeButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .finalizeButton { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - text-transform: uppercase; - } - - .export-btn { - padding-right: 6px; - } - - .downloadPDF { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .downloadXML { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .downloadDOCX { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .updateDatasetProfile { - margin-top: 15px; - margin-bottom: 15px; - margin-right: 15px; - } - - .actions { - display: flex; - justify-content: flex-end; - } - - // .actions > button { - // background-color: #0070c0; - // color: #ffffff; - // text-transform: uppercase; - // } - - .more-horiz { - font-size: 28px; - color: #aaaaaa; - } - - .more-icon :hover { - color: var(--primary-color-3); - } - - .new-dataset { - height: 3.5em; - } - - .fixed-editor-header { - // position: fixed; - // width: calc(100% - 310px); - z-index: 3; - background-color: whitesmoke; - } - - .dataset-editor-header { - height: 113px; - background: var(--unnamed-color-var(--primary-color)) 0% 0% no-repeat padding-box; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #00000029; - padding: 0.6rem; - margin: 30px 0px 0px 0px; - border-radius: 4px; - opacity: 1; - - .info { - flex: 2; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - } - - .dataset-title { - text-align: left; - letter-spacing: 0px; - color: #212121; - opacity: 0.9; - font-size: 14px; - font-weight: 400; - } - - .subtitle { - text-align: left; - color: #ffffff; - font-weight: 700; - font-size: 16px; - opacity: 1; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - - .dataset-subtitle { - text-align: left; - letter-spacing: 0px; - color: #212121; - font-weight: 700; - font-size: 16px; - opacity: 0.9; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - - .discard-btn { - background: transparent; - border: 1px solid #ffffff; - color: white; - border-radius: 30px; - opacity: 1; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - } - - .save-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - width: auto; - min-width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - font-weight: 700; - color: var(--primary-color); - } - - .dataset-discard-btn { - border: 1px solid #212121; - border-radius: 30px; - opacity: 1; - background-color: transparent; - font-weight: 700; - width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - } - - .dataset-save-btn, .dataset-export-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - width: auto; - min-width: 110px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - } - - .dataset-to-dmp { - display: flex; - align-items: center; - padding: 0; - text-align: left; - font-size: 1rem; - font-weight: 700; - color: var(--primary-color); - line-height: 25px; - } - - .dmp-info { - padding-top: 0.75rem; - } - - .dmp-label { - min-width: 67px; - height: 37px; - background: var(--primary-color) 0% 0% no-repeat padding-box; - color: white; - border-radius: 4px; - opacity: 1; - display: flex; - align-items: center; - justify-content: center; - } - - .dmp-title { - text-align: left; - font-weight: 700; - font-family: "Roboto", sans-serif; - font-size: 1rem; - color: #212121; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - line-height: 25px; - } - - .open-in-new-icon { - color: #434343; - opacity: 0.75; - } - .open-in-new-icon:hover { - color: var(--primary-color); - } - - .dataset-stepper { - position: fixed; - // height: 100%; - display: flex; - flex-direction: column; - height: calc(100vh - 246px); - // max-width: 366px; - } - - .stepper-options { - height: calc(100vh - 600px); - overflow-y: auto; - .main-info { - padding-left: .2rem; - color: #21212194; - font-weight: 400; - cursor: pointer; - } - .main-info:hover { - background-color: #ececec; - border-radius: 6px; - } - } - - .stepper-back { - margin-top: 3.125rem; - padding-left: 0.5rem; - font-size: 0.875rem; - letter-spacing: 0px; - color: #848484; - opacity: 1; - } - - .stepper-title { - text-align: left; - font-weight: 300; - font-size: 20px; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; - margin: 2.875rem 0rem 2.25rem 0rem; - padding-left: 1rem; - } - - .stepper-list { - .toc-pane-container { - // padding-left: 0.2rem; - // overflow-x: hidden; - span { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - padding: 0.3rem 0.1rem; - opacity: 0.6; - cursor: pointer; - max-width: 290px; - } - } - } - - .stepper-list span:hover { - background-color: #ececec; - border-radius: 6px; - } - - .stepper-list .active { - color: #212121; - font-weight: 700; - opacity: 1; - } - - .stepper-list .active-dataset { - color: #212121; - font-weight: 700; - opacity: 1; - .label { - width: 100%; - height: 27px; - line-height: 27px; - background-color: var(--secondary-color); - color: #5d5d5d; - border-radius: 4px; - font-weight: 400; - font-size: 14px; - justify-content: left; - display: flex; - align-items: center; - padding-left: 0.625rem; - padding-right: 0.625rem; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - display: inline-block; - } - } - - .back-to-dmp:hover { - background: #ececec; - border-radius: 6px; - } - - .back-icon { - display: inline-flex; - vertical-align: middle; - } - - .editor-content { - .form { - // position: relative; - // left: 362px; - // width: calc(100% - 366px); - - position: relative; - left: 362px; - width: calc(100% - 366px); - overflow-y: auto; - height: calc(100vh - 218px); - } - } - - form { - height: calc(100vh - 124px); - margin-top: 6rem; - } - - .stepper-actions { - display: flex; - padding-left: 1rem; - margin-top: auto; - margin-bottom: 0.5rem; - // margin-top: 5rem; - // flex-grow: 8; - } - - .stepper-btn { - border-radius: 30px; - opacity: 1; - width: 154px; - height: 40px; - display: flex; - justify-content: center; - align-items: center; - font-size: 14px; - } - - .previous { - color: #212121; - background: #f5f5f5 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border: 2px solid #212121; - font-weight: 500; - cursor: pointer; - } - - .add-dataset-btn { - background: var(--secondary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 500; - word-wrap: break-word; - white-space: normal; - line-height: normal; - } - - .next { - background: var(--primary-color) 0% 0% no-repeat padding-box; - color: white; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 400; - cursor: pointer; - } - - .dataset-next { - background: var(--secondary-color) 0% 0% no-repeat padding-box; - color: #212121; - box-shadow: 0px 3px 6px #1e202029; - font-weight: 700; - cursor: pointer; - } - - .previous-disabled { - border: 1px solid #b5b5b5; - color: #b5b5b5 !important; - cursor: auto !important; - } - - .next-disabled { - background: #cbcbcb 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - color: white; - cursor: auto !important; - } -} - -mat-icon.size-18 { - width: 18px; - height: 18px; - line-height: 18px; - font-size: 18px; -} - -.menu-item { - width: 248px; -} - -.toc-pane-container { - &.is-sticky ~ .nav-spacer { - height: 500px; // the container size } - // height: calc(100vh - 100px); // the container size } - } -} - -.is-sticky { - margin-top: 70px !important; -} - -.done-icon { - display: inline-flex; - vertical-align: middle; - font-size: 16px !important; - height: auto; - width: auto; -} - -// ::ng-deep .mat-tab-labels { -// justify-content: space-between; -// } - -// ::ng-deep .mat-tab-label-content { -// text-transform: uppercase; -// } - -// ::ng-deep .mat-ink-bar { -// background-color: var(--primary-color-3) !important; -// // background-color: #0070c0 !important; -// } - -// @media (max-width: 768px) { -// .main-content { -// padding: 30px 0px; -// } - -// ::ng-deep .mat-expansion-panel-header { -// min-height: 48px; -// height: auto !important; -// } - -// ::ng-deep .mat-expansion-panel-body { -// padding: 0 0px 16px !important; -// } - -// ::ng-deep .mat-vertical-content { -// padding: 0 14px 24px 14px !important; -// } -// } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts deleted file mode 100644 index 370100898..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ /dev/null @@ -1,1507 +0,0 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { ActivatedRoute, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { SaveType } from '@app/core/common/enum/save-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { LockModel } from '@app/core/model/lock/lock.model'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { - ExternalSourcesConfigurationService -} from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { LockService } from '@app/core/services/lock/lock.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { - SnackBarNotificationLevel, - UiNotificationService -} from '@app/core/services/notification/ui-notification-service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { - DatasetCopyDialogueComponent -} from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { PrefillDatasetComponent } from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component"; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { ToCEntry, ToCEntryType } from "@app/ui/misc/dataset-description-form/dataset-description.component"; -import { - Link, - LinkToScroll, - TableOfContents -} from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { FormService } from '@common/forms/form-service'; -import { - FormValidationErrorsDialogComponent -} from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { Observable, interval, of as observableOf } from 'rxjs'; -import { catchError, debounceTime, filter, map, takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-dataset-wizard-component', - templateUrl: 'dataset-wizard.component.html', - styleUrls: ['./dataset-wizard.component.scss'] -}) -export class DatasetWizardComponent extends CheckDeactivateBaseComponent implements OnInit {//IBreadCrumbComponent - canDeactivate(): boolean { - return !this.isDirty(); - } - - // breadCrumbs: Observable; - viewOnly = false; - editMode = false; - publicMode = false; - hasChanges = false; - isDiscarded = false; - formGroupRawValue: any; - saving = false; - - DatasetStatus = DatasetStatus; - dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - - datasetWizardModel: DatasetWizardEditorModel; - isNew = true; - isCopy = false; - formGroup: UntypedFormGroup = null; - datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel; - - availableProfiles: DatasetProfileModel[] = []; - finalize: boolean = false; - itemId: string; - dmpId: string; - dmpSectionIndex: number; - availableDescriptionTemplates: DatasetProfileModel[] = []; - newDmpId: string; - publicId: string; - profileUpdateId: string; - downloadDocumentId: string; - isLinear = false; - lock: LockModel; - lockStatus: Boolean; - - step: number = 0; - stepOffset: number = 1; - - saveAnd = SaveType; - datasetSavedLinks: any = null; - - scrollTop: number; - tocScrollTop: number; - links: Link[] = []; - //the table seraches for elements to scroll on page with id (TOCENTRY_ID_PREFIX+fieldsetId) - TOCENTRY_ID_PREFIX = "TocEntRy"; - showtocentriesErrors = false; - @ViewChild('table0fContents') table0fContents: TableOfContents; - hintErrors: boolean = false; - datasetIsOnceSaved = false; - - fieldsetIdWithFocus: string; - visRulesService: VisibilityRulesService; - - constructor( - private datasetWizardService: DatasetWizardService, - private route: ActivatedRoute, - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - public externalSourcesService: ExternalSourcesService, - public dmpService: DmpService, - public dialog: MatDialog, - public externalSourcesConfigurationService: ExternalSourcesConfigurationService, - private uiNotificationService: UiNotificationService, - private formService: FormService, - private lockService: LockService, - private location: Location, - private authService: AuthService, - private configurationService: ConfigurationService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Editor'); - this.route - .data - .pipe(takeUntil(this._destroyed)) - .subscribe(v => { - this.viewOnly = v['public']; - }); - - const dmpRequestItem: RequestItem = new RequestItem(); - dmpRequestItem.criteria = new DmpCriteria(); - - this.dmpAutoCompleteConfiguration = { - filterFn: this.searchDmp.bind(this), - initialItems: (extraData) => this.searchDmp(''), - displayFn: (item) => this.getDatasetDisplay(item), - titleFn: (item) => item['label'], - subtitleFn: (item) => this.language.instant('DATASET-WIZARD.FIRST-STEP.SUB-TITLE') + new Date(item['creationTime']).toISOString() - // iconFn: (item) => this.publicMode ? '' : (item['status'] ? 'lock' : 'lock_open'), - // linkFn: (item) => this.publicMode ? '/explore-plans/overview/' + item['id'] : '/plans/overview/' + item['id'] - }; - - const params = this.route.snapshot.params; - const queryParams = this.route.snapshot.queryParams; - const data: any = this.route.snapshot.data; - this.itemId = params['id']; - this.dmpId = params['dmpId']; - this.dmpSectionIndex = parseInt(params['dmpSectionIndex']); - this.newDmpId = queryParams['newDmpId']; - this.publicId = params['publicId']; - this.profileUpdateId = params['updateId']; - this.finalize = data.finalize; - this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId - - this.init(); - // this.route.params - // .pipe(takeUntil(this._destroyed)) - // .subscribe((params: Params) => { - // const itemId = params['id']; - // if (itemId != null) { setTimeout(() => this.stepper.selectedIndex = 2); } - // }); - } - - init() { - if (this.itemId != null && this.newDmpId == null) { - this.isNew = false; - this.datasetWizardService.getSingle(this.itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { - this.lockStatus = lockStatus; - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex; - this.needsUpdate(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.datasetWizardModel.label, - // url: '/datasets/edit/' + this.datasetWizardModel.id, - // notFoundResolver: [ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS').toUpperCase(), - // url: '/datasets' - // }, - // ] - // }]); - this.formGroup = this.datasetWizardModel.buildForm(); - let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.datasetWizardModel.dmpSectionIndex)); - for (var profile of profiles) { - this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) - } - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) { - this.formGroup.disable(); - this.viewOnly = true; - } - if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { - const lockedBy: UserInfoListingModel = { - email: this.authService.getUserProfileEmail(), - id: this.authService.userId()?.toString(), - name: this.authService.getPrincipalName(), - role: 0 //TODO - //role: this.authService.getRoles()?.at(0) - } - this.lock = new LockModel(data.id, lockedBy); - - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - this.lock.id = Guid.parse(result); - interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); - }); - } - // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.loadDatasetProfiles(); - this.registerFormListeners(); - - if (lockStatus) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-WIZARD.LOCKED.TITLE'), - message: this.language.instant('DATASET-WIZARD.LOCKED.MESSAGE') - }, maxWidth: '30em' - }); - } - if (this.finalize && !this.lockStatus && !this.viewOnly) { - setTimeout(() => { - this.saveFinalize(); - }, 0); - } - // this.availableProfiles = this.datasetWizardModel.dmp.profiles; - }); - }, - error => { - switch (error.status) { - case 403: - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-ALLOWED'), SnackBarNotificationLevel.Error); - break; - case 404: - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-FOUND'), SnackBarNotificationLevel.Error); - break; - default: - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), SnackBarNotificationLevel.Error); - } - this.router.navigate(['/datasets/']); - return observableOf(null); - }); - } else if (this.dmpId != null) { - this.isNew = true; - this.dmpService.getSingle(this.dmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.datasetWizardModel = new DatasetWizardEditorModel(); - setTimeout(() => { - this.datasetWizardModel.dmp = data; - this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; - this.formGroup = this.datasetWizardModel.buildForm(); - let profiles = this.datasetWizardModel.dmp.profiles.filter(profile => profile.data.dmpSectionIndex.includes(this.dmpSectionIndex)); - for (var profile of profiles) { - this.availableDescriptionTemplates.push({ id: profile.descriptionTemplateId, label: profile.label, description: "" }) - } - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - this.formGroup.get('dmp').disable(); - const dialogRef = this.dialog.open(PrefillDatasetComponent, { - width: '590px', - minHeight: '200px', - restoreFocus: false, - data: { - availableProfiles: this.availableDescriptionTemplates, - datasetFormGroup: this.formGroup - }, - panelClass: 'custom-modalbox' - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - this.datasetWizardModel = this.datasetWizardModel.fromModel(result); - this.datasetWizardModel.dmp = data; - this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.formGroup.get('dmp').disable(); - this.loadDatasetProfiles(); - this.registerFormListeners(); - } - }) - this.loadDatasetProfiles(); - this.registerFormListeners(); - // this.availableProfiles = data.profiles; - - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // }] - // }]); - }); - }); - } else if (this.newDmpId != null) { - this.isNew = false; - this.isCopy = true; - this.datasetWizardService.getSingle(this.itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.lockService.checkLockStatus(Guid.parse(data.id)).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { - this.lockStatus = lockStatus; - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex; - this.datasetWizardModel.status = 0; - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroup.get('id').setValue(null); - this.dmpService.getSingleNoDatasets(this.newDmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - setTimeout(() => { - this.datasetWizardModel.dmp = data; - this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - this.loadDatasetProfiles(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // } - // ] - // }]); - }); - }); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) { - this.formGroup.disable(); - this.viewOnly = true; - } - if (!lockStatus && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { - const lockedBy: UserInfoListingModel = { - email: this.authService.getUserProfileEmail(), - id: this.authService.userId()?.toString(), - name: this.authService.getPrincipalName(), - role: 0 //TODO - //role: this.authService.getRoles()?.at(0) - } - this.lock = new LockModel(data.id, lockedBy); - - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - this.lock.id = Guid.parse(result); - interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); - }); - } - // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.loadDatasetProfiles(); - // this.availableProfiles = data.dmp.profiles; - }) - }); - } else if (this.publicId != null) { // For Finalized -> Public Datasets - this.isNew = false; - this.datasetWizardService.getSinglePublic(this.publicId) - .pipe(takeUntil(this._destroyed)).pipe( - catchError((error: any) => { - this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); - this.router.navigate(['/datasets/publicEdit/' + this.publicId]); - return observableOf(null); - })) - .subscribe(data => { - if (data) { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.formGroup.disable(); - this.viewOnly = true; - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp); - const breadcrumbs = []; - breadcrumbs.push({ - parentComponentName: null, - label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), - url: '/explore-descriptions' - }); - breadcrumbs.push({ - parentComponentName: null, - label: this.datasetWizardModel.label, - url: '/datasets/publicEdit/' + this.datasetWizardModel.id - }); - // this.breadCrumbs = observableOf(breadcrumbs); - } - }); - this.publicMode = true; - } else if (this.profileUpdateId != null) { - this.datasetWizardService.updateDatasetProfile(this.profileUpdateId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - this.needsUpdate(); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: '/datasets', - // notFoundResolver: [ - // // { - // // parentComponentName: null, - // // label: this.datasetWizardModel.dmp.grant.label, - // // url: '/grants/edit/' + this.datasetWizardModel.dmp.grant.id - // // }, - // { - // parentComponentName: null, - // label: this.datasetWizardModel.dmp.label, - // url: '/plans/edit/' + this.datasetWizardModel.dmp.id, - // }, - // ] - // }]); - this.formGroup = this.datasetWizardModel.buildForm(); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - this.formGroup.disable(); - this.viewOnly = true; - } - // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.loadDatasetProfiles(); - }); - - } else { - this.datasetWizardModel = new DatasetWizardEditorModel(); - this.formGroup = this.datasetWizardModel.buildForm(); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - if (this.datasetWizardModel.status === DatasetStatus.Finalized) { - this.formGroup.disable(); - this.viewOnly = true; - } - //if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. - this.registerFormListeners(); - this.dmpValueChanged(null); - // this.breadCrumbs = observableOf([ - // { - // parentComponentName: null, - // label: this.language.instant('DATASET-LISTING.ACTIONS.CREATE-NEW').toUpperCase(), - // url: '/datasets/new/' - // }]); - } - } - - // private _listenersSubscription:Subscription = new Subscription(); - registerFormListeners() { - // const dmpSubscription = - this.formGroup.get('dmp').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.dmpValueChanged(x); - }); - // const profileSubscription = - this.formGroup.get('profile').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (x) { - this.showtocentriesErrors = false; - this.datasetProfileValueChanged(x.id); - this.formChanged(); - } - }); - // const labelSubscription = - this.formGroup.get('label').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // const descriptionSubscription = - this.formGroup.get('description').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // const uriSubscription = - this.formGroup.get('uri').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // const tagsSubscription = - this.formGroup.get('tags').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - if (this.formGroup.get('datasetProfileDefinition')) { - // const datasetProfileDefinitionSubscription = - this.formGroup.get('datasetProfileDefinition').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - // this._listenersSubscription.add(datasetProfileDefinitionSubscription); - } - - // this._listenersSubscription.add(dmpSubscription); - // this._listenersSubscription.add(profileSubscription); - // this._listenersSubscription.add(labelSubscription); - // this._listenersSubscription.add(descriptionSubscription); - // this._listenersSubscription.add(uriSubscription); - // this._listenersSubscription.add(tagsSubscription); - } - - // private _unregisterFormListeners(){ - // this._listenersSubscription.unsubscribe(); - // this._listenersSubscription = new Subscription(); - // } - - dmpValueChanged(dmp: DmpListingModel) { - if (dmp) { - this.formGroup.get('profile').enable(); - this.loadDatasetProfiles(); - } else { - this.availableProfiles = []; - this.formGroup.get('profile').reset(); - this.formGroup.get('profile').disable(); - this.formGroup.removeControl('datasetProfileDefinition'); - } - } - - datasetProfileValueChanged(profiledId: string) { - if (profiledId && profiledId.length > 0) { - this.formGroup.removeControl('datasetProfileDefinition'); - this.getDefinition(profiledId); - } - } - - searchDmp(query: string): Observable { - const fields: Array = new Array(); - fields.push('-created'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = query; - dmpDataTableRequest.criteria.status = DmpStatus.Draft; - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete").pipe(map(x => x.data)); - } - - loadDatasetProfiles() { - const datasetProfileRequestItem: RequestItem = new RequestItem(); - datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - datasetProfileRequestItem.criteria.id = this.formGroup.get('dmp').value.id; - if (datasetProfileRequestItem.criteria.id) { - this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.availableProfiles = items; - }); - } - } - - public formChanged() { - if (!this.isDiscarded) { - this.hasChanges = true; - } - } - - public cancel(): void { - if (!isNullOrUndefined(this.lock)) { - this.lockService.unlockTarget(Guid.parse(this.datasetWizardModel.id)).pipe(takeUntil(this._destroyed)).subscribe( - complete => { - this.publicMode ? this.router.navigate(['/explore-descriptions']) : this.router.navigate(['/datasets']); - }, - error => { - this.formGroup.get('status').setValue(DmpStatus.Draft); - this.onCallbackError(error); - } - ) - } else { - this.publicMode ? this.router.navigate(['/explore-descriptions']) : this.router.navigate(['/datasets']); - } - - } - - getDatasetDisplay(item: any): string { - if (!this.publicMode) { - return (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label']; - } else { - return item['label']; - } - } - - getDefinition(profileId: string) { - // if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; } - this.datasetWizardService.getDefinition(profileId) - .pipe(takeUntil(this._destroyed)) - .subscribe(item => { - this.datasetWizardModel.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); - this.datasetProfileDefinitionModel = this.datasetWizardModel.datasetProfileDefinition; - this.formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinitionModel.buildForm()); - - // const datasetProfileDefinitionForm = this.datasetProfileDefinitionModel.buildForm(); - - // let profId = null; - // try{ - // profId = this.formGroup.get('profile').value.id; - // }catch{ - - // } - // if(this.formGroupRawValue && this.formGroupRawValue.datasetProfileDefinition && (this.formGroupRawValue.profile.id === profId)){ - // // this.formGroup.get('datasetProfileDefinition').patchValue( this.formGroupRawValue.datasetProfileDefinition); - // datasetProfileDefinitionForm.patchValue(this.formGroupRawValue.datasetProfileDefinition); - // } - - // this.formGroup.addControl('datasetProfileDefinition', datasetProfileDefinitionForm); - this.formGroup.get('datasetProfileDefinition').valueChanges - .pipe(debounceTime(600)) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - }); - } - - // formSubmit(): void { - // if (!this.isFormValid()) { return; } - // this.onSubmit(); - // } - - public isFormValid() { - return this.formGroup.valid; - } - - public isSemiFormValid(formGroup: UntypedFormGroup): boolean { - var isValid: boolean = true; - Object.keys(formGroup.controls).forEach(controlName => { - if (controlName != 'datasetProfileDefinition' && !formGroup.get(controlName).disabled && !(formGroup.get(controlName).valid)) { - isValid = false; - } - }); - return isValid; - } - - // onSubmit(): void { - // this.datasetWizardService.createDataset(this.formGroup.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => { - // this.datasetWizardService.getSingle(complete.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // result => { - // this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result); - // } - // ); - // this.onCallbackSuccess(); - // }, - // error => this.onCallbackError(error) - // ); - // } - - - submit(saveType?: SaveType, onSuccess: Function = null, onError: Function = null) { - this.scrollTop = document.getElementById('dataset-editor-form').scrollTop; - this.tocScrollTop = document.getElementById('stepper-options').scrollTop; - this.datasetWizardService.createDataset(this.formGroup.getRawValue()) - .pipe(takeUntil(this._destroyed)) - .subscribe( - data => { - this.hasChanges = false; - this.datasetIsOnceSaved = true; - this.onCallbackSuccess(data, saveType); - if (onSuccess) { - onSuccess(); - } - }, - error => { - if (onError) { - onError(); - } - this.onCallbackError(error) - }); - } - - - private _getErrorMessage(formControl: AbstractControl, name: string): string[] { - const errors: string[] = []; - Object.keys(formControl.errors).forEach(key => { - if (key === 'required') { - errors.push(this.language.instant(name + ": " + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED'))); - } - // if (key === 'required') { errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + this.getPlaceHolder(formControl) + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.REQUIRED')); } - else if (key === 'email') { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.EMAIL')); - } else if (key === 'min') { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MIN-VALUE', { 'min': formControl.getError('min').min })); - } else if (key === 'max') { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.MAX-VALUE', { 'max': formControl.getError('max').max })); - } else { - errors.push(this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.THIS-FIELD') + ' "' + name + '" ' + this.language.instant('GENERAL.FORM-VALIDATION-DISPLAY-DIALOG.HAS-ERROR') + ', ' + formControl.errors[key].message); - } - }); - return errors; - } - - private _getPlaceHolder(formControl: any): string { - if (formControl.nativeElement.localName === 'input' || formControl.nativeElement.localName === 'textarea' - || formControl.nativeElement.localName === 'richTextarea') { - return formControl.nativeElement.getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'mat-select') { - return formControl.nativeElement.getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'app-single-auto-complete') { - return (Array.from(formControl.nativeElement.firstChild.children).filter((x: any) => x.localName === 'input')[0] as any).getAttribute('placeholder'); - } else if (formControl.nativeElement.localName === 'app-multiple-auto-complete') { - return (Array.from(formControl.nativeElement.firstChild.firstChild.firstChild.children).filter((x: any) => x.localName === 'input')[0] as any).getAttribute('placeholder'); - } - } - - - private _buildSemiFormErrorMessages(): string[] {//not including datasetProfileDefinition - const errmess: string[] = []; - Object.keys(this.formGroup.controls).forEach(controlName => { - if (controlName != 'datasetProfileDefinition' && this.formGroup.get(controlName).invalid) { - errmess.push(...this._buildErrorMessagesForAbstractControl(this.formGroup.get(controlName), controlName)); - } - }) - - return errmess; - } - - // takes as an input an abstract control and gets its error messages[] - private _buildErrorMessagesForAbstractControl(aControl: AbstractControl, controlName: string): string[] { - const errmess: string[] = []; - - if (aControl.invalid) { - - if (aControl.errors) { - //check if has placeholder - if ((aControl).nativeElement !== undefined && (aControl).nativeElement !== null) { - const placeholder = this._getPlaceHolder(aControl); - if (placeholder) { - controlName = placeholder; - } - } - const errorMessage = this._getErrorMessage(aControl, controlName); - - errmess.push(...errorMessage); - } - - /*in case the aControl is FormControl then the it should have provided its error messages above. - No need to check case of FormControl below*/ - - if (aControl instanceof UntypedFormGroup) { - - const fg = aControl as UntypedFormGroup; - //check children - Object.keys(fg.controls).forEach(controlName => { - errmess.push(...this._buildErrorMessagesForAbstractControl(fg.get(controlName), controlName)); - }); - } else if (aControl instanceof UntypedFormArray) { - - const fa = aControl as UntypedFormArray; - - fa.controls.forEach((control, index) => { - errmess.push(...this._buildErrorMessagesForAbstractControl(control, `${controlName} --> ${index + 1}`)); - }); - - } - } - - return errmess; - } - - save(saveType?: SaveType) { - this.saving = true; - Object.keys(this.formGroup.controls).forEach(controlName => { - if (controlName == 'datasetProfileDefinition') { - return; - } - this.formService.touchAllFormFields(this.formGroup.get(controlName)); - }) - - - // this.formService.touchAllFormFields(this.formGroup); - if (!this.isSemiFormValid(this.formGroup)) { - //build messages - const errorMessages = this._buildSemiFormErrorMessages(); - this.showValidationErrorsDialog(undefined, errorMessages); - this.hintErrors = true; - this.saving = false; - return; - } - this.submit(saveType); - } - - private showValidationErrorsDialog(projectOnly?: boolean, errmess?: string[]) { - if (errmess) { - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - errorMessages: errmess, - projectOnly: projectOnly - }, - }); - } else { - - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - formGroup: this.formGroup, - projectOnly: projectOnly - }, - }); - } - - } - - hasReversableStatus(): boolean { - if (this.formGroup.get('dmp').value) { - return (this.formGroup.get('dmp').value.status == DmpStatus.Draft && this.formGroup.get('status').value == DatasetStatus.Finalized); - } else { - return false; - } - } - - hasNotReversableStatus(): boolean { - if (this.formGroup.get('dmp').value && !this.publicMode) { - return (this.formGroup.get('dmp').value.status == DmpStatus.Finalized && this.formGroup.get('status').value == DatasetStatus.Finalized); - } else { - return false; - } - } - - reverse() { - - this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.UNDO-FINALIZATION-QUESTION'), - confirmButton: this.language.instant('DATASET-WIZARD.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('DATASET-WIZARD.ACTIONS.REJECT'), - }, - maxWidth: '30em' - }) - .afterClosed() - .pipe( - filter(x => x), - takeUntil(this._destroyed) - ).subscribe(result => { - if (result) { - // if (!this.isFormValid()) { return; } - this.formGroup.get('status').setValue(DatasetStatus.Draft); - this.submit(SaveType.finalize, () => { - this.viewOnly = false; - this.datasetWizardModel.status = DatasetStatus.Draft; - setTimeout(x => { - this.formGroup = null; - }); - setTimeout(x => { - this.formGroup = this.datasetWizardModel.buildForm(); - this.registerFormListeners(); - }); - }, () => { - this.formGroup.get('status').setValue(DatasetStatus.Finalized); - this.viewOnly = true; - }); - } else { - this.saving = false; - } - }); - - - } - - saveFinalize() { - // this.formService.touchAllFormFields(this.formGroup); - this.saving = true; - if (!this.isSemiFormValid(this.formGroup) || (this.table0fContents && this.table0fContents.hasVisibleInvalidFields())) { - // this.showValidationErrorsDialog(); - this.dialog.open(FormValidationErrorsDialogComponent, { - data: { - errorMessages: [this.language.instant('DATASET-WIZARD.MESSAGES.MISSING-FIELDS')] - } - }) - - - this.touchForm(); - this.hintErrors = true; - this.saving = false; - return; - } - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - // if (!this.isFormValid()) { return; } - this.formGroup.get('status').setValue(DatasetStatus.Finalized); - this.submit(SaveType.finalize, null, () => { - this.formGroup.get('status').setValue(DatasetStatus.Draft); - }); - } else { - this.saving = false; - } - }); - } - - onCallbackSuccess(data?: DatasetWizardModel, saveType?: SaveType): void { - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - if (data) { - if (saveType === this.saveAnd.addNew) { - this.router.navigate(['/reload']).then(() => { - this.router.navigate(['/datasets', 'new', this.formGroup.get('dmp').value.id, this.dmpSectionIndex]); - }) - } else if (saveType === this.saveAnd.close) { - this.router.navigate(['/reload']).then(() => { - this.router.navigate(['/plans', 'edit', this.formGroup.get('dmp').value.id]); - }); - } else if (saveType === SaveType.finalize) { - this.router.navigate(['/reload']).then(() => { - this.router.navigate(['/datasets', 'edit', data.id]); - }); - } else { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); - this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; - // setTimeout(() => { this.formGroup = null; }); - setTimeout(() => { - this.formGroup.get('id').patchValue(data.id); - this.formGroup.get('modified').patchValue(data.modified); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.hasChanges = false; - - // this.formGroup = this.datasetWizardModel.buildForm(); - // if (this.formGroup.get('datasetProfileDefinition')) { - // this.formGroup.removeControl('datasetProfileDefinition'); - // this.getDefinition(data.profile.id); - // this.maxStep = 1; - // } else { - // this.getDefinition(data.profile.id); - // this.maxStep = 1; - // } - }); - - setTimeout(() => { - document.getElementById('dataset-editor-form').scrollTop = this.scrollTop; - document.getElementById('stepper-options').scrollTop = this.tocScrollTop; - }, 500); - this.saving = false; - if (this.isNew) { - this.reloadDateset(this.datasetWizardModel.id); - } - // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', data.id]); }); - } - } else { - this.router.navigate(['/datasets']); - } - } - - onCallbackError(error: any) { - const errmes = error && error.message ? error.message as string : null; - let feedbackMessage = this.language.instant('DATASET-EDITOR.ERRORS.ERROR-OCCURED'); - if (errmes) { - feedbackMessage += errmes; - } - this.uiNotificationService.snackBarNotification(feedbackMessage, SnackBarNotificationLevel.Warning); - this.setErrorModel(error.error); - this.saving = false; - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - Object.keys(validationErrorModel).forEach(item => { - (this.datasetWizardModel.validationErrorModel)[item] = (validationErrorModel)[item]; - }); - } - - downloadPDF(id: string): void { - this.datasetWizardService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", id); - }); - } - - downloadDOCX(id: string): void { - this.datasetWizardService.downloadDOCX(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", id); - }); - - } - - downloadXML(id: string): void { - this.datasetWizardService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", id); - }); - } - - // advancedClicked() { - // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { - // maxWidth: '500px', - // data: { - // message: "Download as:", - // XMLButton: "XML", - // documentButton: "Document", - // pdfButton: "PDF" - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result == "pdf") { - // this.downloadPDF(); - // } else if (result == "xml") { - // this.downloadXML(); - // } else if (result == "doc") { - // this.downloadDOCX(); - // } - // }); - // } - - public redirectToGrant() { - this.router.navigate(['grants/edit/' + this.datasetWizardModel.dmp.grant.id]); - } - - public redirectToDmp() { - this.router.navigate(['plans/edit/' + this.datasetWizardModel.dmp.id]); - } - - public enableForm() { - if (this.formGroup.get('status').value !== DatasetStatus.Finalized) { - this.editMode = true; - this.viewOnly = false; - this.formGroup.enable(); - } else { - this.datasetWizardService.unlock(this.formGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.editMode = true; - this.viewOnly = false; - this.datasetWizardModel.status = DatasetStatus.Draft; - this.formGroup.get('status').patchValue(DatasetStatus.Draft); - this.formGroup.enable(); - }); - } - } - - public disableForm() { - this.editMode = false; - //this.viewOnly = true; - this.formGroup.disable(); - } - - openConfirm(dmpLabel, id): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - }); - } - - openDmpSearchDialogue() { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: this.formGroup.value.id, - datasetProfileId: this.formGroup.value.profile, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - } - }); - } - - needsUpdate() { - if (this.datasetWizardModel.isProfileLatestVersion || (this.datasetWizardModel.status === DatasetStatus.Finalized) - || (this.datasetWizardModel.isProfileLatestVersion == undefined && this.datasetWizardModel.status == undefined)) { - return false; - } else { - return true; - } - } - - linkToScroll: LinkToScroll; - - onStepFound(linkToScroll: LinkToScroll) { - this.linkToScroll = linkToScroll; - } - - private pumpLock() { - this.lock.touchedAt = new Date(); - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - if (!isNullOrUndefined(result)) { - this.lock.id = Guid.parse(result); - } else { - this.location.back(); - } - }); - } - - getEntryVisibleFieldSets(entry: ToCEntry): ToCEntry[] { - let fieldSets = []; - if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id)) { - fieldSets.push(entry); - } else if (entry.type !== ToCEntryType.FieldSet) { - entry.subEntries.forEach(subEntry => { - fieldSets = fieldSets.concat(this.getEntryVisibleFieldSets(subEntry)); - }); - } - return fieldSets; - } - - get visibleFieldSets(): ToCEntry[] { - let fieldSets = []; - let arrays = this.table0fContents ? this.table0fContents.tocentries. - filter(entry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id)).map(entry => { - return this.getEntryVisibleFieldSets(entry); - }) - : []; - arrays.forEach(array => { - fieldSets = fieldSets.concat(array); - }); - return fieldSets; - } - - getFirstFieldSet(entry: ToCEntry): ToCEntry { - if (entry.type === ToCEntryType.FieldSet && !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === entry.id)) { - return entry; - } else { - let subEntries = entry.subEntries.filter(subEntry => !this.table0fContents.internalTable.hiddenEntries.find(hiddenEntry => hiddenEntry === subEntry.id)); - if (subEntries.length > 0) { - return this.getFirstFieldSet(subEntries[0]); - } else { - return null; - } - } - } - - public changeStep(selected: ToCEntry = null, execute: boolean = true) { - if (execute) { - if (selected) { - let fieldSet = this.getFirstFieldSet(selected); - let index = this.visibleFieldSets.findIndex(entry => entry.id === fieldSet.id); - this.step = index + (selected.type === ToCEntryType.FieldSet ? 1 : 0.5); - } else { - this.step = 0; - this.resetScroll(); - } - } - } - - get maxStep() { - return this.visibleFieldSets.length; - } - - public nextStep() { - if (this.step < this.maxStep) {//view is changing - this.step = Math.floor(this.step + 1); - let entry = this.visibleFieldSets[this.step - 1]; - this.table0fContents.onToCentrySelected(entry, false); - this.scroll(entry); - } - } - - public previousStep() { - if (this.step > 0) { - this.step = Math.ceil(this.step - 1); - if (this.step >= 1) { - let entry = this.visibleFieldSets[this.step - 1]; - this.table0fContents.onToCentrySelected(entry, false); - this.scroll(entry); - } else { - this.table0fContents.onToCentrySelected(null, false); - this.resetScroll(); - } - } - } - - private resetScroll() { - document.getElementById('dataset-editor-form').scrollTop = 0; - } - - private scroll(entry: ToCEntry) { - document.getElementById(entry.id).scrollIntoView(); - } - - isDirty() { - return this.formGroup.dirty && this.hasChanges; // do we need this.formGroup.dirty - } - - discardChanges() { - // this.isDiscarded = true; - // this.hasChanges = false; - // this.hintErrors = false; - let messageText = ""; - let confirmButtonText = ""; - let cancelButtonText = ""; - let isDeleteConfirmation = false; - - if (this.isNew && !this.datasetIsOnceSaved) { - - messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-MESSAGE'); - confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-CONFIRM'); - cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-NEW-DENY'); - isDeleteConfirmation = true; - - // Object.keys(this.formGroup['controls']).forEach((key: string) => { - // if (key !== 'dmp' && (key!== 'profile')) { - // if(key === 'datasetProfileDefinition'){ - // this.formGroup.get(key).patchValue(this.datasetProfileDefinitionModel.buildForm().getRawValue); - // }else{ - // this.formGroup.get(key).reset(); - // } - - // } - // }); - } else { - - messageText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-MESSAGE'); - confirmButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-CONFIRM'); - cancelButtonText = this.language.instant('DATASET-EDITOR.ACTIONS.DISCARD.DISCARD-EDITED-DENY'); - isDeleteConfirmation = false; - - // this.isDiscarded = true; - // this.hasChanges = false; - // this.hintErrors = false; - // // this._unregisterFormListeners(); - // this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue))); - // // this.registerFormListeners(); - // this.isDiscarded = false; - - - } - - - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: messageText, - confirmButton: confirmButtonText, - cancelButton: cancelButtonText, - isDeleteConfirmation: true - }, - maxWidth: '40em' - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - // this.backToDmp(this.formGroup.get('dmp').value.id) - setTimeout(x => { - this.init(); - }); - } - }); - - - // this.isDiscarded = false; - } - - addDataset(dmpId: string) { - this.router.navigate(['/datasets', 'new', dmpId]); - } - - reloadDateset(datasetId: string) { - let url = this.router.createUrlTree(['/datasets', 'edit', datasetId]).toString(); - this.location.go(url); - } - - backToDmp(id: string) { - this.router.navigate(['/plans', 'edit', id]); - } - - datasetInfoValid(): boolean { - return this.formGroup.get('label') && this.formGroup.get('label').valid && this.formGroup.get('profile') && this.formGroup.get('profile').valid; - } - - getLinks(currentLinks: Link[]) { - this.links = currentLinks; - } - - printForm() { - console.log(this.formGroup); - } - - printFormValue() { - console.log(this.formGroup.value); - } - - touchForm() { - this.formGroup.markAllAsTouched(); - this.showtocentriesErrors = true; - } - - // tocentries; - // this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); //TODO - - - // get tocentries(){ - // const form = this.formGroup.get('datasetProfileDefinition') - // if(!form) return null; - - // return this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); - // } - - - // private _buildRecursively(form: FormGroup,whatAmI:ToCEntryType):ToCEntry{ - // if(!form) return null; - - // switch(whatAmI){ - // case ToCEntryType.Section: - // const sections = form.get('sections') as FormArray; - // const fieldsets = form.get('compositeFields') as FormArray; - - - // const tempResult:ToCEntry[] = []; - - // if(sections &§ions.length){ - // sections.controls.forEach(section=>{ - // tempResult.push(this._buildRecursively(section as FormGroup, ToCEntryType.Section)); - // }); - - // }else if(fieldsets && fieldsets.length){ - // fieldsets.controls.forEach(fieldset=>{ - // tempResult.push(this._buildRecursively(fieldset as FormGroup, ToCEntryType.FieldSet)); - // }); - // } - // return { - // form: form, - // id: form.get('id').value, - // label: form.get('title').value, - // numbering: '', - // subEntries:tempResult, - // subEntriesType: sections &§ions.length? ToCEntryType.Section: ToCEntryType.FieldSet, - // type: ToCEntryType.Section, - // ordinal: form.get('ordinal').value - // } - // case ToCEntryType.FieldSet: - // return { - // form: form, - // label:form.get('title').value, - // id: form.get('id').value, - // numbering:'s', - // subEntries:[], - // subEntriesType: ToCEntryType.Field, - // type: ToCEntryType.FieldSet, - // ordinal: form.get('ordinal').value - // } - // } - // } - - // private _sortByOrdinal(tocentries: ToCEntry[]){ - - // if(!tocentries || !tocentries.length) return; - - // tocentries.sort(this._customCompare); - // tocentries.forEach(entry=>{ - // this._sortByOrdinal(entry.subEntries); - // }); - // } - - // private _customCompare(a,b){ - // return a.ordinal - b.ordinal; - // } - - // private _calculateNumbering(tocentries: ToCEntry[], depth:number[] = []){ - // if(!tocentries || !tocentries.length){ - // return; - // } - - // let prefixNumbering = depth.length? depth.join('.'): ''; - - // if(depth.length) prefixNumbering = prefixNumbering+"."; - // tocentries.forEach((entry,i)=>{ - // entry.numbering = prefixNumbering + (i+1); - // this._calculateNumbering(entry.subEntries, [...depth, i+1]) - // }); - // } - - - // getTocEntries(form): ToCEntry[] { - // if (form == null) { return []; } - // const result: ToCEntry[] = []; - - // //build parent pages - // (form.get('pages') as FormArray).controls.forEach((pageElement, i) => { - // result.push({ - // id: i+'id', - // label: pageElement.get('title').value, - // type: ToCEntryType.Page, - // form: pageElement, - // numbering: (i + 1).toString(), - // subEntriesType: ToCEntryType.Section, - // subEntries:[], - // ordinal: pageElement.get('ordinal').value - // } as ToCEntry) - // }); - - - // result.forEach((entry,i)=>{ - - // const sections = entry.form.get('sections') as FormArray; - - // sections.controls.forEach(section=>{ - // const tempResults = this._buildRecursively(section as FormGroup,ToCEntryType.Section); - // entry.subEntries.push(tempResults); - // }); - - // }); - - // this._sortByOrdinal(result); - // //calculate numbering - // this._calculateNumbering(result); - // return result; - - // } - - -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html deleted file mode 100644 index 4cf8f26cc..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html +++ /dev/null @@ -1,489 +0,0 @@ -
- -
-
-
-

1.3 {{'DATASET-EDITOR.FIELDS.TAGS' | translate}}

-
-
-
- - - -
-
- - - - - - - - -
- - - - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts deleted file mode 100644 index cac88b15d..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalSourcesConfiguration } from '@app/core/model/external-sources/external-sources-configuration'; -import { DataRepositoryCriteria } from '@app/core/query/data-repository/data-repository-criteria'; -import { ExternalDatasetCriteria } from '@app/core/query/external-dataset/external-dataset-criteria'; -import { RegistryCriteria } from '@app/core/query/registry/registry-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { ServiceCriteria } from '@app/core/query/service/service-criteria'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { ExternalSourcesConfigurationService } from '@app/core/services/external-sources/external-sources-configuration.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { ExternalDataRepositoryEditorModel, ExternalDatasetEditorModel, ExternalRegistryEditorModel, ExternalServiceEditorModel, ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { DatasetExternalDataRepositoryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component'; -import { DatasetExternalDatasetDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component'; -import { DatasetExternalRegistryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component'; -import { DatasetExternalServiceDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable } from 'rxjs'; -import { takeUntil, map } from 'rxjs/operators'; -import { ENTER, COMMA } from '@angular/cdk/keycodes'; -import { MatChipInputEvent } from '@angular/material/chips'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service'; -import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service'; -import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; - -@Component({ - selector: 'app-dataset-external-references-editor-component', - templateUrl: 'dataset-external-references-editor.component.html', - styleUrls: ['./dataset-external-references-editor.component.scss'] -}) -export class DatasetExternalReferencesEditorComponent extends BaseComponent implements OnInit { - - @Input() formGroup: UntypedFormGroup = null; - @Input() viewOnly = false; - @Output() formChanged: EventEmitter = new EventEmitter(); - - public filteringTagsAsync = false; - public filteredTags: ExternalSourceItemModel[]; - - readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDatasets.bind(this), - initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - }; - - registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalRegistries.bind(this), - initialItems: (type) => this.searchDatasetExternalRegistries('', type), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - }; - - dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDataRepositories.bind(this), - initialItems: (type) => this.searchDatasetExternalDataRepositories('', type), - displayFn: (item) => item ? item.name : null, - titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - }; - - servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalServices.bind(this), - initialItems: (type) => this.searchDatasetExternalServices('', type), - displayFn: (item) => item ? item.label : null, - titleFn: (item) => item ? item.label : null, - subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - }; - - tagsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => this.showTag(item), - titleFn: (item) => item['name'], - valueAssign: (item) => this.addTag(item) - }; - - externalSourcesConfiguration: ExternalSourcesConfiguration; - - // new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), - - constructor( - private dialog: MatDialog, - private router: Router, - private language: TranslateService, - private externalSourcesService: ExternalSourcesService, - private externalSourcesConfigurationService: ExternalSourcesConfigurationService, - private externalDataRepositoryService: ExternalDataRepositoryService, - private externalDatasetService: ExternalDatasetService, - private externalRegistryService: ExternalRegistryService, - private externalServiceService: ExternalServiceService, - ) { super(); } - - ngOnInit() { - - this.externalSourcesConfigurationService.getExternalSourcesConfiguration() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.externalSourcesConfiguration = result; - this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' }); - this.externalSourcesConfiguration.services.push({ key: '', label: 'All' }); - if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) { - this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' }); - } else { - this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }]; - } - }); - - this.formGroup.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(val => { - this.formChanged.emit(val); - }); - } - - public cancel(): void { - this.router.navigate(['/datasets']); - } - - externalDatasetsOnItemChange(event) { - const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.name, event.pid ? event.pid : event.reference, event.source); - (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - } - - registriesOnItemChange(event) { - const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.name, event.pid ? event.pid : event.reference, event.uri, event.source); - (this.formGroup.get('registries')).push(registryModel.buildForm()); - } - - servicesOnItemChange(event) { - const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri); - (this.formGroup.get('services')).push(serviceModel.buildForm()); - } - - tagsOnItemChange(event) { - const tagModel = new ExternalTagEditorModel(event.id, event.name); - (this.formGroup.get('tags')).push(tagModel.buildForm()); - } - - - dataRepositoriesOnItemChange(event) { - const dataRepositoryModel = new ExternalDataRepositoryEditorModel(event.id, event.name, event.abbreviation, event.uri, event.pid, event.source); - (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - } - - addDataRepository() { - const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source); - (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - }); - } - - addRegistry() { - const dialogRef = this.dialog.open(DatasetExternalRegistryDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - (this.formGroup.get('registries')).push(registryModel.buildForm()); - }); - } - - addExternalDataset() { - const dialogRef = this.dialog.open(DatasetExternalDatasetDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const externalDatasetModel = new ExternalDatasetEditorModel(result.id, result.abbreviation, result.name, result.reference, result.source); - (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - }); - } - - addService() { - const dialogRef = this.dialog.open(DatasetExternalServiceDialogEditorComponent, { - width: '500px', - restoreFocus: false, - data: {} - }); - dialogRef.afterClosed() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (!result) { return; } - const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - (this.formGroup.get('services')).push(serviceModel.buildForm()); - }); - } - - searchDatasetExternalDatasets(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ExternalDatasetCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); - } - - searchDatasetExternalDataRepositories(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new DataRepositoryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetRepository(requestItem); - } - - searchDatasetExternalRegistries(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new RegistryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetRegistry(requestItem); - } - - searchDatasetExternalServices(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ServiceCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetService(requestItem); - } - - searchDatasetTags(query: string, type: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new TagCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = type; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - removeTag(tag: any) { - (this.formGroup.get('tags')).removeAt(((this.formGroup.get('tags')).value as any[]).indexOf(tag)); - } - - addTag(ev: any) { - let item: ExternalTagEditorModel; - //this.filteredTags = this.formGroup.get('tags').value; - if (typeof ev === 'string') { - item = new ExternalTagEditorModel('', ev); - } else { - item = ev; - } - if (item.name !== '' ) { - return item; - } - } - - isInternal(element: any): boolean { - if (element.get('source') == null) { - // console.log(element); - } - return element.get('source').value === 'Internal'; - } - - updateDataRepository(dataRepository: UntypedFormGroup) { - this.externalDataRepositoryService.create(dataRepository.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - dataRepository.setValue(result); - } - ); - } - - updateExternalDataset(externalDataset: UntypedFormGroup) { - this.externalDatasetService.create(externalDataset.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - externalDataset.setValue(result); - } - ); - } - - updateRegistry(registry: UntypedFormGroup) { - this.externalRegistryService.create(registry.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - registry.setValue(result); - } - ); - } - - updateService(service: UntypedFormGroup) { - this.externalServiceService.create(service.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (result) => { - service.setValue(result); - } - ); - } - - filterTags(value: string): Observable { - this.filteringTagsAsync = true; - - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - showTag(ev: any) { - if (typeof ev === 'string') { - return ev; - } else { - return ev.name; - } - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html deleted file mode 100644 index b6d159d7b..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html +++ /dev/null @@ -1,57 +0,0 @@ -
-
- {{'DATASET-CREATE-WIZARD.PREFILL-STEP.TITLE' | translate}} - close -
-
- -
-
-
-
- {{'DATASET-CREATE-WIZARD.PREFILL-STEP.HINT' | translate}} -
-
-
- -
{{'DATASET-CREATE-WIZARD.PREFILL-STEP.OR' | translate}}
- -
-
-
-

{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE' | translate}}

-
- - - -
- {{profile.label}} -
-
-
- {{prefillForm.get('profile').getError('backendError').message}} -
-
-
-
-

{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILLED-DATASET' | translate}}

-
- - - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.scss b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.scss deleted file mode 100644 index 7a892e68b..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.scss +++ /dev/null @@ -1,57 +0,0 @@ -.template-container { - .header { - display: flex; - width: 100%; - height: 60px; - background-color: var(--secondary-color); - color: #212121; - font-size: 1.25rem; - } - - .template-title { - margin-left: 37px; - white-space: nowrap; - width: 480px; - overflow: hidden; - text-overflow: ellipsis; - } - - .close-icon { - cursor: pointer; - margin-right: 20px; - } - - .close-icon:hover { - background-color: #fefefe6e !important; - border-radius: 50%; - } - - .definition-content { - display: block; - margin: 0; - padding: 25px; - } - - .empty-btn, .prefill-btn { - background: var(--secondary-color) 0 0 no-repeat padding-box; - border: 1px solid var(--secondary-color); - border-radius: 30px; - opacity: 1; - min-width: 101px; - height: 43px; - color: #212121; - font-weight: 500; - } - - .prefill-btn:disabled { - background: #a1a1a1 0 0 no-repeat padding-box; - border: 1px solid #a1a1a1; - opacity: 0.5; - } - - .empty-btn { - background: #ffffff 0 0 no-repeat padding-box; - border: 1px solid #a1a1a1; - } -} - diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts deleted file mode 100644 index 08bdc21d1..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts +++ /dev/null @@ -1,200 +0,0 @@ -import { Component, Inject, OnInit } from "@angular/core"; -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog"; -import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile"; -import { Prefilling } from "@app/core/model/dataset/prefilling"; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint"; -import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service"; -import { PrefillingService } from "@app/core/services/prefilling.service"; -import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service"; -import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration"; -import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component"; -import { BaseComponent } from "@common/base/base.component"; -import { Guid } from "@common/types/guid"; -import { TranslateService } from "@ngx-translate/core"; -import { Observable } from "rxjs"; -import { map, takeUntil } from "rxjs/operators"; -import { nameof } from "ts-simple-nameof"; - -@Component({ - selector: 'prefill-dataset-component', - templateUrl: 'prefill-dataset.component.html', - styleUrls: ['prefill-dataset.component.scss'] -}) -export class PrefillDatasetComponent extends BaseComponent implements OnInit { - - progressIndication = false; - prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - isPrefilled: boolean = false; - prefillForm: UntypedFormGroup; - - constructor(public dialogRef: MatDialogRef, - private prefillingService: PrefillingService, - private dmpBlueprintService: DmpBlueprintService, - private dialog: MatDialog, - private language: TranslateService, - private progressIndicationService: ProgressIndicationService, - private fb: UntypedFormBuilder, - @Inject(MAT_DIALOG_DATA) public data: any) { - super(); - } - - ngOnInit() { - this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - setTimeout(() => { this.progressIndication = x; }); - }); - this.prefillForm = this.fb.group({ - type: this.fb.control(false), - profile: this.fb.control('', Validators.required), - prefill: this.fb.control(null, Validators.required) - }) - if (this.data.availableProfiles && this.data.availableProfiles.length === 1) { - this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]); - } - this.prefillAutoCompleteConfiguration = { - filterFn: this.searchDatasets.bind(this), - loadDataOnStart: false, - displayFn: (item) => (item['name'].length > 60) ? (item['name'].substr(0, 60) + "...") : item['name'], - titleFn: (item) => item['name'], - subtitleFn: (item) => item['pid'] - }; - } - - addProfileIfUsedLessThanMax(profile: DatasetProfileModel) { - const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value; - const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields()) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if (section.hasTemplates) { - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if (this.data.datasetFormGroup.get('dmp').value.datasets != null) { - for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) { - if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) { - count++; - } - } - if (count < foundTemplate.maxMultiplicity) { - this.prefillForm.get('profile').patchValue(profile); - } - } - } - else { - this.prefillForm.get('profile').patchValue(profile); - } - } - else { - this.prefillForm.get('profile').patchValue(profile); - } - }); - } - - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); - const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value; - const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id; - this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields()) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - const section = result.definition.sections[dmpSectionIndex]; - if (section.hasTemplates) { - const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - if (foundTemplate !== undefined) { - let count = 0; - if (this.data.datasetFormGroup.get('dmp').value.datasets != null) { - for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) { - if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) { - count++; - } - } - if (count === foundTemplate.maxMultiplicity) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - } - else { - this.prefillForm.get('profile').setValue(profile); - } - } - } - else { - this.prefillForm.get('profile').setValue(profile); - } - } - else { - this.prefillForm.get('profile').setValue(profile); - } - }); - } - - private getBlueprintDefinitionFields() { - return [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - } - - public compareWith(object1: any, object2: any) { - return object1 && object2 && object1.id === object2.id; - } - - searchDatasets(query: string): Observable { - return this.prefillingService.getPrefillingList(query).pipe(map(prefilling => prefilling.sort((a, b) => { - if (a.name > b.name) { - return 1; - } else if (a.name < b.name) { - return -1; - } else { - return 0; - } - }))); - } - - next() { - if (this.isPrefilled) { - if (this.prefillForm.get('prefill').value.data == null) { - this.prefillingService.getPrefillingDataset(this.prefillForm.get('prefill').value.pid, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => { - wizard.profile = this.prefillForm.get('profile').value; - this.closeDialog(wizard); - }); - } - else { - this.prefillingService.getPrefillingDatasetUsingData(this.prefillForm.get('prefill').value.data, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => { - wizard.profile = this.prefillForm.get('profile').value; - this.closeDialog(wizard); - }); - } - } else { - this.closeDialog(); - } - } - - closeDialog(result = null): void { - this.dialogRef.close(result); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/dataset.module.ts b/dmp-frontend/src/app/ui/dataset/dataset.module.ts deleted file mode 100644 index c31346c9b..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset.module.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; -import { DatasetEditorComponent } from '@app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component'; -import { DatasetWizardComponent } from '@app/ui/dataset/dataset-wizard/dataset-wizard.component'; -import { DatasetExternalReferencesEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component'; -import { DatasetExternalDataRepositoryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/data-repository/dataset-external-data-repository-dialog-editor.component'; -import { DatasetExternalDatasetDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/external-dataset/dataset-external-dataset-dialog-editor.component'; -import { DatasetExternalRegistryDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/registry/dataset-external-registry-dialog-editor.component'; -import { DatasetExternalServiceDialogEditorComponent } from '@app/ui/dataset/dataset-wizard/external-references/editors/service/dataset-external-service-dialog-editor.component'; -import { DatasetRoutingModule } from '@app/ui/dataset/dataset.routing'; -import { DatasetCriteriaComponent } from '@app/ui/dataset/listing/criteria/dataset-criteria.component'; -import { DatasetUploadDialogue } from '@app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component'; -import { DatasetListingComponent } from '@app/ui/dataset/listing/dataset-listing.component'; -import { DatasetListingItemComponent } from '@app/ui/dataset/listing/listing-item/dataset-listing-item.component'; -import { DatasetDescriptionFormModule } from '@app/ui/misc/dataset-description-form/dataset-description-form.module'; -import { TableOfContentsModule } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module'; -import { ExternalSourcesModule } from '@app/ui/misc/external-sources/external-sources.module'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { AngularStickyThingsModule } from '@w11k/angular-sticky-things'; -import { FormProgressIndicationModule } from '../misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module'; -import { DatasetCopyDialogModule } from './dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module'; -import { DatasetCriteriaDialogComponent } from './listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component'; -import { DatasetOverviewModule } from './overview/dataset-overview.module'; -import {RichTextEditorModule} from "@app/library/rich-text-editor/rich-text-editor.module"; -import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component"; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - UrlListingModule, - FormattingModule, - ConfirmationDialogModule, - AutoCompleteModule, - ExternalSourcesModule, - ExportMethodDialogModule, - DatasetDescriptionFormModule, - TableOfContentsModule, - AngularStickyThingsModule, - DatasetRoutingModule, - FormValidationErrorsDialogModule, - DatasetCopyDialogModule, - DatasetOverviewModule, - FormProgressIndicationModule, - RichTextEditorModule - ], - declarations: [ - DatasetListingComponent, - DatasetCriteriaComponent, - DatasetWizardComponent, - DatasetEditorComponent, - DatasetExternalReferencesEditorComponent, - DatasetExternalDataRepositoryDialogEditorComponent, - DatasetExternalDatasetDialogEditorComponent, - DatasetExternalRegistryDialogEditorComponent, - DatasetExternalServiceDialogEditorComponent, - DatasetUploadDialogue, - DatasetListingItemComponent, - DatasetCriteriaDialogComponent, - PrefillDatasetComponent - ], - exports: [ - DatasetExternalReferencesEditorComponent, - DatasetExternalDataRepositoryDialogEditorComponent, - DatasetExternalDatasetDialogEditorComponent, - DatasetExternalRegistryDialogEditorComponent, - DatasetExternalServiceDialogEditorComponent, - DatasetEditorComponent, - DatasetDescriptionFormModule - ] -}) -export class DatasetModule { } diff --git a/dmp-frontend/src/app/ui/dataset/dataset.routing.ts b/dmp-frontend/src/app/ui/dataset/dataset.routing.ts deleted file mode 100644 index ab3bb27ed..000000000 --- a/dmp-frontend/src/app/ui/dataset/dataset.routing.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; -import { AuthGuard } from '../../core/auth-guard.service'; -import { DatasetWizardComponent } from './dataset-wizard/dataset-wizard.component'; -import { DatasetListingComponent } from './listing/dataset-listing.component'; -import { DatasetOverviewComponent } from './overview/dataset-overview.component'; - -const routes: Routes = [ - { - path: 'new/:dmpId/:dmpSectionIndex', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-NEW' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'edit/:id', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - public: false, - title: 'GENERAL.TITLES.DATASET-EDIT' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'edit/:id/finalize', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - public: false, - title: 'GENERAL.TITLES.DATASET-EDIT', - finalize: true - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'publicEdit/:publicId', - component: DatasetWizardComponent, - //canActivate: [AuthGuard], - data: { - public: true, - title: 'GENERAL.TITLES.DATASET-PUBLIC-EDIT' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'new', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-NEW' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: '', - component: DatasetListingComponent, - // canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, - { - path: 'dmp/:dmpId', - component: DatasetListingComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true - }, - }, - { - path: 'copy/:id', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-COPY' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'profileupdate/:updateId', - component: DatasetWizardComponent, - canActivate: [AuthGuard], - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-UPDATE' - }, - canDeactivate:[CanDeactivateGuard] - }, - { - path: 'overview/:id', - component: DatasetOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - }, - { - path: 'publicOverview/:publicId', - component: DatasetOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASET-OVERVIEW' - }, - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class DatasetRoutingModule { } diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html deleted file mode 100644 index db2bddfee..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.html +++ /dev/null @@ -1,2 +0,0 @@ -clear - diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss deleted file mode 100644 index 6ad258085..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.scss +++ /dev/null @@ -1,20 +0,0 @@ -.clear-icon { - cursor: pointer; - color: #212121; - padding: 0.4rem; -} - -.clear-icon:hover { - background-color: #ececec !important; - border-radius: 50%; - padding: 0.4rem; -} - -:host ::ng-deep .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts deleted file mode 100644 index d640a6d1f..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, Inject, OnInit, ViewChild } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { DatasetCriteriaComponent } from '../dataset-criteria.component'; - -@Component({ - selector: 'dataset-criteria-dialog-component', - templateUrl: './dataset-criteria-dialog.component.html', - styleUrls: ['./dataset-criteria-dialog.component.scss'] -}) - -export class DatasetCriteriaDialogComponent implements OnInit { - - @ViewChild(DatasetCriteriaComponent, { static: true }) criteria: DatasetCriteriaComponent; - - constructor( - public dialogRef: MatDialogRef, - private httpClient: HttpClient, - private matomoService: MatomoService, - @Inject(MAT_DIALOG_DATA) public data: { isPublic: boolean, status: Number, criteria: DatasetCriteria, formGroup: UntypedFormGroup, updateDataFn: Function } - ) { - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Criteria'); - this.criteria.setCriteria(this.data.criteria); - } - - onNoClick(): void { - this.dialogRef.close(); - } - - onClose(): void { - this.dialogRef.close(); - } - - onFiltersChanged(event) { - this.data.updateDataFn(this.criteria); - } - -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html deleted file mode 100644 index 6498dc3f5..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html +++ /dev/null @@ -1,200 +0,0 @@ -
-
-
-
-
{{'CRITERIA.FILTERS'| translate}}
-
-
-
- - - - - -
-
{{'CRITERIA.DATA-SETS.STATUS'| translate}}
- - - {{ 'TYPES.DATASET-STATUS.ANY' | translate }} - - - {{ 'TYPES.DATASET-STATUS.DRAFT' | translate }} - - - {{ 'TYPES.DATASET-STATUS.FINALISED' | translate }} - - -
-
- - - -
-
{{ 'FACET-SEARCH.GRANT-STATUS.TITLE' | translate }}
- - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ANY' | translate }} - - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE' | translate }} - - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE' | translate }} - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-DATASET-TEMPLATES' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-DATASET-TEMPLATES' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-DMP' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-DMP' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.ALL-VERSIONS'| translate}}
- -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-GRANT' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-GRANTS' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.RELATED-COLLABORATORS' | translate}}
- - {{'CRITERIA.DATA-SETS.SELECT-COLLABORATORS' | translate }} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.ROLE' | translate }}
- - - {{ 'TYPES.DATASET-ROLE.ANY' | translate }} - - - {{ 'TYPES.DATASET-ROLE.OWNER' | translate }} - - - {{ 'TYPES.DATASET-ROLE.MEMBER' | translate }} - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.ORGANIZATION' | translate }}
- - {{'CRITERIA.DATA-SETS.SELECT-ORGANIZATIONS' | translate}} - - - -
-
- - - -
-
{{'CRITERIA.DATA-SETS.TAGS' | translate }}
- - {{'CRITERIA.DATA-SETS.SELECT-TAGS' | translate}} - - - -
- - - - - -
-
-
- - diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss deleted file mode 100644 index a8e92de7c..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.scss +++ /dev/null @@ -1,56 +0,0 @@ -.search ::ng-deep.mat-form-field-infix { - margin-left: 1em; -} - -.category-title { - color: black; - // color: #089dbb; - margin-top: 8px; - margin-bottom: 12px; - text-transform: none; - font-size: 1rem; - font-weight: 400; -} - -.import { - margin: 10px; - padding: 0px; -} - -.filters { - // border: 1px solid #e4e4e4; - // border-radius: 5px; -} - -.criteria-title { - color: black; - font-weight: 500; - text-transform: none; - font-size: 1.25rem; - margin-bottom: 1.5em; - opacity: 0.8; -} - -.filters-title { - width: 93px; - // color: #089dbb; - color: var(--primary-color-2); - background-color: white; - padding: 0px 20px; - margin-top: -10px; - margin-left: 20px; - text-transform: uppercase; -} - -.style-icon { - color: #adadad; -} - -::ng-deep .search-form .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts deleted file mode 100644 index a05881fc8..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts +++ /dev/null @@ -1,339 +0,0 @@ - -import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { OrganisationCriteria } from '@app/core/query/organisation/organisation-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { UserCriteria } from '@app/core/query/user/user-criteria'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { OrganisationService } from '@app/core/services/organisation/organisation.service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { DatasetUploadDialogue } from '@app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; - -@Component({ - selector: 'app-dataset-criteria-component', - templateUrl: './dataset-criteria.component.html', - styleUrls: ['./dataset-criteria.component.scss'] -}) -export class DatasetCriteriaComponent extends BaseCriteriaComponent implements OnInit { - - @Input() dmpSearchEnabled; - @Input() status; - @Input() isPublic: boolean; - @Input() criteriaFormGroup: UntypedFormGroup; - @Output() filtersChanged: EventEmitter = new EventEmitter(); - public criteria: any; - public filteringTagsAsync = false; - public filteredTags: ExternalSourceItemModel[]; - statuses = DatasetStatus; - - options: UntypedFormGroup; - - public formGroup = new UntypedFormBuilder().group({ - like: new UntypedFormControl(), - groupIds: new UntypedFormControl(), - grants: new UntypedFormControl(), - status: new UntypedFormControl(), - role: new UntypedFormControl(), - organisations: new UntypedFormControl(), - collaborators: new UntypedFormControl(), - datasetTemplates: new UntypedFormControl(), - tags: new UntypedFormControl(), - allVersions: new UntypedFormControl(), - grantStatus: new UntypedFormControl() - }); - - tagsAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - }; - - datasetTemplateAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterDatasetTemplate.bind(this), - initialItems: (excludedItems: any[]) => this.filterDatasetTemplate('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'] - }; - - dmpAutoCompleteConfiguration = { - filterFn: (x, excluded) => this.filterDmps(x).pipe(map(x => x.data)), - initialItems: (extraData) => this.filterDmps('').pipe(map(x => x.data)), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - collaboratorsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterCollaborators.bind(this), - initialItems: (excludedItems: any[]) => this.filterCollaborators('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - }; - - grantAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterGrant.bind(this), - initialItems: (excludedItems: any[]) => this.filterGrant('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - organisationAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterOrganisations.bind(this), - initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - } - - constructor( - private externalSourcesService: ExternalSourcesService, - public enumUtils: EnumUtils, - public dmpService: DmpService, - public datasetWizardService: DatasetWizardService, - private dialog: MatDialog, - private snackBar: MatSnackBar, - private uiNotificationService: UiNotificationService, - private router: Router, - private language: TranslateService, - public grantService: GrantService, - private organisationService: OrganisationService, - private userService: UserServiceOld, - private datasetService: DatasetService, - fb: UntypedFormBuilder, - private authService: AuthService - - ) { - super(new ValidationErrorModel()); - // this.options = fb.group({ - // status: new FormControl(), - // floatLabel: 'auto', - // }); - } - - ngOnInit() { - super.ngOnInit(); - - // This if is just for passing label on chips of dialog - if (this.formGroup && this.criteriaFormGroup) { - this.formGroup.get('datasetTemplates').setValue(this.criteriaFormGroup.get('datasetTemplates').value); - this.formGroup.get('groupIds').setValue(this.criteriaFormGroup.get('groupIds').value); - this.formGroup.get('grants').setValue(this.criteriaFormGroup.get('grants').value); - this.formGroup.get('collaborators').setValue(this.criteriaFormGroup.get('collaborators').value); - this.formGroup.get('organisations').setValue(this.criteriaFormGroup.get('organisations').value); - this.formGroup.get('tags').setValue(this.criteriaFormGroup.get('tags').value); - - } - - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('groupIds').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('grants').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('status').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('role').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('organisations').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('collaborators').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('datasetTemplates').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('allVersions').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('tags').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - this.formGroup.get('grantStatus').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - // if (this.criteria == null) { this.criteria = {}; } - // this.formGroup.patchValue({'status': this.status !== undefined ? this.status : 'null'}); - } - - setCriteria(criteria: DatasetCriteria): void { - this.formGroup.get('like').patchValue(criteria.like); - this.formGroup.get('groupIds').patchValue(criteria.groupIds); - this.formGroup.get('grants').patchValue(criteria.grants); - this.formGroup.get('status').patchValue(criteria.status); - this.formGroup.get('role').patchValue(criteria.role); - this.formGroup.get('collaborators').patchValue(criteria.collaborators); - this.formGroup.get('datasetTemplates').patchValue(criteria.datasetTemplates); - this.formGroup.get('allVersions').patchValue(criteria.allVersions); - this.formGroup.get('tags').patchValue(criteria.tags); - this.formGroup.get('grantStatus').patchValue(criteria.grantStatus); - // this.criteria = criteria; - } - - controlModified(): void { - this.clearErrorModel(); - this.filtersChanged.emit(); - if (this.refreshCallback != null && - (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) - ) { - setTimeout(() => this.refreshCallback(true)); - } - // if (this.refreshCallback != null && - // (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2) - // ) { - // this.refreshCallback(); - // } - } - - filterTags(value: string): Observable { - this.filteredTags = undefined; - this.filteringTagsAsync = true; - - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - filterDatasetTemplate(query: string): Observable { - const fields: Array = new Array(); - fields.push('asc'); - const datasetTemplateRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - datasetTemplateRequestItem.criteria = new DatasetProfileCriteria(); - datasetTemplateRequestItem.criteria.like = query; - if (this.isPublic) { - return this.datasetService.getDatasetProfiles(datasetTemplateRequestItem); - } else { - return this.datasetService.getDatasetProfilesUsedPaged(datasetTemplateRequestItem).pipe(map(x => x.data)); - } - } - - filterDmps(value: string): Observable> { - const fields: Array = new Array(); - fields.push('asc'); - - // if (this.isPublic) { - // const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - // dmpDataTableRequest.criteria = new ExploreDmpCriteriaModel(); - // dmpDataTableRequest.criteria.like = value; - // return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete"); - // } else { - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = value; - if (this.isPublic) { - dmpDataTableRequest.criteria.isPublic = true; - dmpDataTableRequest.criteria.onlyPublic = true; - } - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); - // } - } - - filterGrant(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const grantRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - if (this.isPublic) { - return this.grantService.getPublicPaged(grantRequestItem).pipe(map(x => x.data)); - } else { - return this.grantService.getPaged(grantRequestItem, "autocomplete").pipe(map(x => x.data)); - } - } - - filterOrganisations(value: string) { - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = value; - if (this.isPublic) { - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } else { - return this.organisationService.searchInternalOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - } - - filterCollaborators(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const collaboratorsRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - collaboratorsRequestItem.criteria = new UserCriteria(); - collaboratorsRequestItem.criteria.collaboratorLike = query; - return this.userService.getCollaboratorsPaged(collaboratorsRequestItem).pipe(map(x => x.data)); - } - - fileImport(event) { - const dialogRef = this.dialog.open(DatasetUploadDialogue, { - data: { - fileList: FileList, - success: Boolean, - datasetTitle: String, - dmpId: String, - datasetProfileId: String, - dmpSearchEnabled: this.dmpSearchEnabled, - criteria: this.criteria - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result && result.success) { - this.datasetWizardService.uploadXml(result.fileList, result.datasetTitle, result.dmpId, result.datasetProfileId) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - }) - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-UPLOAD.SNACK-BAR.SUCCESSFUL-CREATION'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - onCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Success); - } - - isAuthenticated(): boolean { - return this.authService.currentAccountIsAuthenticated(); - } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html deleted file mode 100644 index f631c3a39..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.html +++ /dev/null @@ -1,42 +0,0 @@ -
-
-
-

{{'DATASET-UPLOAD.TITLE' | translate}}

-
-
- - -
-
-
- - - - - - - - - - - - - {{datasetProfile.label}} - - - - -
- -
-
-
- -
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss deleted file mode 100644 index c066ed1b5..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.scss +++ /dev/null @@ -1,21 +0,0 @@ -.confirmation-dialog { - .confirmation-message { - padding-bottom: 20px; - } - - .hidden { - display: none; - } - - .uploadButton { - float: right; - } - - .col-md-6 { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - margin: -4px; - } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts deleted file mode 100644 index 307907fcd..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-upload-dialogue/dataset-upload-dialogue.component.ts +++ /dev/null @@ -1,157 +0,0 @@ - -import { Component, Inject, OnInit } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { Observable } from 'rxjs'; -import { map, takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'dataset-upload-dialogue', - templateUrl: './dataset-upload-dialogue.component.html', - styleUrls: ['./dataset-upload-dialogue.component.scss'] -}) -export class DatasetUploadDialogue extends BaseCriteriaComponent implements OnInit { - - public dialogueCriteria: any; - datasetTitle: string; - dmp: DmpModel; - datasetProfile: DatasetProfileModel; - availableProfiles: DatasetProfileModel[] = []; - - dmpAutoCompleteConfiguration = { - filterFn: (x, excluded) => this.filterDmps(x).pipe(map(x => x.data)), - initialItems: (extraData) => this.filterDmps('').pipe(map(x => x.data)), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - constructor( - public dialogRef: MatDialogRef, - public dmpService: DmpService, - private datasetWizardService: DatasetWizardService, - @Inject(MAT_DIALOG_DATA) public data: any, - ) { super(new ValidationErrorModel()); } - - ngOnInit() { - super.ngOnInit(); - if (this.dialogueCriteria == null) { this.dialogueCriteria = {}; } - if (!this.data.dmpSearchEnabled) { - this.dialogueCriteria = this.data.criteria; - this.dmp = this.dialogueCriteria.dmpIds[0]; - this.loadDatasetProfiles(); - } - } - - cancel() { - this.data.success = false; - this.dialogRef.close(this.data) - } - - confirm() { - this.data.success = true; - this.data.datasetTitle = this.datasetTitle; - this.data.dmpId = this.dmp.id; - this.data.datasetProfileId = this.datasetProfile.id; - this.dialogRef.close(this.data); - } - - uploadFile(event) { - const fileList: FileList = event.target.files - this.data.fileList = fileList; - if (this.data.fileList.length > 0) { - this.datasetTitle = fileList.item(0).name; - } - } - - filterDmps(value: string): Observable> { - const fields: Array = new Array(); - fields.push('asc'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = value; - return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); - } - - controlModified(): void { - this.loadDatasetProfiles(); - if (!this.dmp) { - this.availableProfiles = []; - } - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.dialogueCriteria.like == null || this.dialogueCriteria.like.length === 0 || this.dialogueCriteria.like.length > 2) - ) { - this.refreshCallback(); - } - } - - loadDatasetProfiles() { - const datasetProfileRequestItem: RequestItem = new RequestItem(); - datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - if (this.dmp) { - datasetProfileRequestItem.criteria.id = this.dmp.id; - } - if (datasetProfileRequestItem.criteria.id) { - this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.availableProfiles = items; - if (this.availableProfiles.length === 1) { - this.datasetProfile = this.availableProfiles[0]; - } - }); - } - } - - setCriteriaDialogue(criteria: DatasetCriteria): void { - this.dialogueCriteria = criteria; - } - - disableButton() { - if (!(this.data.fileList.length > 0) || !this.dmp) { - return true; - } - else { - return false; - } - } - - disableDatasetName() { - if (!(this.data.fileList.length > 0)) { - return true; - } - else { - return false; - } - } - - disableDmpSearch() { - if (!(this.data.fileList.length > 0) || !this.data.dmpSearchEnabled) { - return true; - } - else { - return false; - } - } - - disableDatasetProfile() { - if (!this.dmp || (!this.data.dmpSearchEnabled && !(this.data.fileList.length > 0)) || (!this.data.dmpSearchEnabled && this.availableProfiles.length === 1)) { - return true; - } - else { - return false; - } - } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html deleted file mode 100644 index 632807de0..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.html +++ /dev/null @@ -1,120 +0,0 @@ -
-
-
-
- - -
-

{{'DATASET-LISTING.TEXT-INFO' | translate}} {{'DATASET-LISTING.LINK-PUBLIC-DATASETS' | translate}} {{'DATASET-LISTING.TEXT-INFO-REST' | translate}}

-

{{'DATASET-LISTING.TEXT-INFO-PAR' | translate}} -

- - -
-
-
-

{{(isPublic ? 'GENERAL.TITLES.EXPLORE' : 'GENERAL.TITLES.DESCRIPTIONS') | translate}}

-
-
- -
-
-
- -
-
-
-
-
-
- - {{'DMP-LISTING.SORT-BY' | translate}}: - - - {{enumUtils.toRecentActivityOrderString(order.MODIFIED)}} - {{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}} - {{enumUtils.toRecentActivityOrderString(order.LABEL)}} - {{enumUtils.toRecentActivityOrderString(order.STATUS)}} - - - - -
- -
- {{ 'GENERAL.ACTIONS.TAKE-A-TOUR'| translate }} -
- - - - search - - {{formGroup.get('like').getError('backendError').message}} - - -
-
-
-
-
- -
-
- -
-
-
- {{'DATASET-LISTING.EMPTY-LIST' | translate}} -
-
-
-
-
- - - diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss deleted file mode 100644 index 5042fe772..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss +++ /dev/null @@ -1,265 +0,0 @@ -@import "node_modules/bootstrap/scss/functions"; -@import "node_modules/bootstrap/scss/variables"; -@import "node_modules/bootstrap/scss/mixins/_breakpoints"; - -@include media-breakpoint-down(sm) { - .lightblue-btn { - font-size: 12px; - } - ::ng-deep .mat-paginator-container { - height: auto !important; - } -} - -.header-image { - background: url("/assets/images/new-dashboard-bg.png") no-repeat; - background-size: cover; - margin-top: 70px; - min-height: 15em; - position: relative; -} - -.header-title { - text-align: left; - font-size: 1.25rem; - font-weight: 300; - color: #212121; - padding: 0px; -} - -.header-text-container { - background: rgba(255, 255, 255, 0.7); - position: absolute; - bottom: 0px; - padding-left: 5em; - padding-right: 10em; - padding-top: 2em; - padding-bottom: 2em; -} - -.explore-dmp-content { - padding: 30px 15px; -} - -.main-content { - background-color: #f5f5f5; - padding-top: 4.68rem; - padding-bottom: 3rem; - padding-left: 3rem; - padding-right: 3rem; - margin: 0; - display: flex; - flex-grow: 1; -} - -.card { - background: #ffffff 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #00000029; - border-radius: 4px; - // width: 987px; - margin-bottom: 3.75rem; - /* height: 407px; */ - opacity: 1; -} - -.card-title { - text-align: left; - font: Bold 20px/30px Roboto; - letter-spacing: 0px; - color: #212121; - padding-left: 40px; - /* padding-top: 40px; */ - padding-right: 55px; - opacity: 1; -} - -.card-content { - text-align: left; - font-weight: 300; - letter-spacing: 0px; - color: #212121; - padding-left: 40px; - padding-top: 36px; -// padding-bottom: 36px; - padding-right: 55px; - opacity: 1; -} - -.clear-icon { - cursor: pointer; - color: #212121; - padding: 0.4rem; -} - -.clear-icon:hover { - background-color: #ececec !important; - border-radius: 50%; - padding: 0.4rem; -} - -.normal-btn { - min-width: 162px; - max-width: 256px; - height: 40px; - cursor: pointer; - background: var(--primary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border-radius: 30px; - border: none; - color: #ffffff; - opacity: 1; - line-height: 1; - font-size: 0.87rem; - padding: 0.62rem 1.87rem; - margin-left: 40px; -} - -.yellow-btn { - min-width: 162px; - max-width: 256px; - height: 40px; - cursor: pointer; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - border-radius: 30px; - opacity: 1; - border: none; - color: #000000; - opacity: 1; - line-height: 1; - font-size: 0.87rem; - padding: 0.62rem 1.87rem; - font-weight: 700; -} - -.info-text { - text-align: left; - font-weight: 300; - font-size: 1rem; - letter-spacing: 0px; - color: #212121; -} - -.filter-btn { - position: fixed; - right: 0px; - z-index: 100; - width: 37px; -} - -.filter-btn button { - color: white; - background-color: var(--primary-color-2); - width: 37px; - height: 45px; -} - -.center-content { - width: 100%; - min-width: 10rem; - margin: auto; - padding: 0 15px; - text-align: right; - font-size: 0.875rem; - font-weight: 600; - letter-spacing: 0.02rem; - color: #2d72d6; - cursor: pointer; -} - -.search-form { - // font-size: 12px; - text-align: left; - width: 20rem; -} - -.search-form mat-icon { - color: var(--primary-color); -} - -.empty-list { - text-align: center; - font-weight: 300; - font-size: 1.25rem; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; -} - -.pointer:hover { - color: var(--primary-color-3); -} - -::ng-deep .search-form .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -::ng-deep .sort-form .mat-form-field-wrapper { - background-color: white !important; - padding-bottom: 0 !important; -} - -:host ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - padding: 0.3rem 0rem 0.6rem 0rem !important; -} - -:host ::ng-deep .mat-paginator-container { - flex-direction: row-reverse !important; - justify-content: space-between !important; - background-color: #f6f6f6; - height: 30px; - min-height: 30px !important; -} - -:host ::ng-deep .mat-paginator-page-size { - height: 43px; -} - -:host ::ng-deep .mat-icon-button { - height: 30px !important; - font-size: 12px !important; -} - -:host ::ng-deep .mat-paginator-range-label { - margin: 15px 32px 0 24px !important; -} - -:host ::ng-deep .mat-paginator-range-actions { - width: auto !important; - min-width: 55% !important; - min-height: 43px !important; - justify-content: space-between; -} - -:host ::ng-deep .mat-paginator-navigation-previous { - margin-left: auto !important; -} - -::ng-deep .mat-ripple-element { - background-color: #2e74b649 !important; -} - -::ng-deep .mat-radio-container { - border-radius: 1em; - background: white; -} - -::ng-deep .mat-radio-button .mat-radio-outer-circle { - border: 1px solid #aaaaaa; -} - -::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle { - border-color: #777777; - // border-color: var(--primary-color-3); -} - -::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle { - // color: var(--primary-color-3); - // background-color: var(--primary-color-3); - color: #777777; - background-color: #777777; -} - -.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { - background-color: #2e74b649; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts deleted file mode 100644 index cea9fb961..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts +++ /dev/null @@ -1,446 +0,0 @@ - -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { MatPaginator } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { DatasetCriteriaComponent } from '@app/ui/dataset/listing/criteria/dataset-criteria.component'; -import { StartNewDatasetDialogComponent } from '@app/ui/dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component'; -import { StartNewDmpDialogComponent } from '@app/ui/dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { debounceTime, takeUntil } from 'rxjs/operators'; -import { DatasetWizardEditorModel, ExternalTagEditorModel } from '../dataset-wizard/dataset-wizard-editor.model'; -import { DatasetCriteriaDialogComponent } from './criteria/dataset-criteria-dialogue/dataset-criteria-dialog.component'; - -@Component({ - selector: 'app-dataset-listing-component', - templateUrl: 'dataset-listing.component.html', - styleUrls: ['./dataset-listing.component.scss'] -}) -export class DatasetListingComponent extends BaseComponent implements OnInit {//IBreadCrumbComponent - - @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - // @ViewChild(DatasetCriteriaComponent, { static: true }) criteria: DatasetCriteriaComponent; - - // breadCrumbs: Observable; - - titlePrefix: String; - dmpId: string; - status: Number; - totalCount: number; - dmpSearchEnabled = true; - listingItems: DatasetListingModel[] = []; - hasListingItems = null; - - isPublic: boolean = false; - public isVisible = true - - startIndex: number = 0; - pageSize: number = 5; - criteria: DatasetCriteria; - criteriaFormGroup: UntypedFormGroup; - public formGroup = new UntypedFormBuilder().group({ - like: new UntypedFormControl(), - order: new UntypedFormControl() - }); - - scrollbar: boolean; - order = RecentActivityOrder; - dmpText: string; - datasetText: string; - - constructor( - private datasetService: DatasetService, - private router: Router, - private route: ActivatedRoute, - public dialog: MatDialog, - private dmpService: DmpService, - private language: TranslateService, - private authService: AuthService, - public enumUtils: EnumUtils, - private authentication: AuthService, - private guidedTourService: GuidedTourService, - private httpClient: HttpClient, - private matomoService: MatomoService - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Datasets'); - this.isPublic = this.router.url === '/explore-descriptions'; - if (this.isPublic) { - this.formGroup.get('order').setValue(this.order.DATASETPUBLISHED); - } else { - this.formGroup.get('order').setValue(this.order.MODIFIED); - } - if (!this.isPublic && !this.authService.currentAccountIsAuthenticated()) { - this.router.navigateByUrl("/explore"); - } - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe(async (params: Params) => { - const queryParams = this.route.snapshot.queryParams; - this.dmpId = queryParams['dmpId']; - this.status = queryParams['status']; - // Makes multiple post requests - // this.criteria.setRefreshCallback(() => this.refresh()); - if (this.dmpId != null) { - this.dmpSearchEnabled = false; - const dmp = await this.dmpService.getSingle(this.dmpId).toPromise(); - this.criteria = this.getDefaultCriteria(dmp); - // this.criteria.setCriteria(this.getDefaultCriteria(dmp)); - this.refresh(); - // this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); - // this.breadCrumbs = observableOf([{ - // parentComponentName: 'DmpEditorComponent', - // label: dmp.label, - // url: '/plans/edit/' + this.dmpId - // }]); - if (params['dmpLabel'] !== undefined) { - this.titlePrefix = 'for ' + params['dmpLabel']; - } - } else { - this.criteria = this.getDefaultCriteria(); - // this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - // this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); - // this.breadCrumbs = observableOf([{ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - // url: this.isPublic ? "/explore" : "/datasets" - // }]); - } - - if (this.status != null && this.status == DatasetStatus.Draft) { - this.criteria = this.getDraftCriteria(); - // this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); - this.refresh(); - } - }); - - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.controlModified()); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); - } - - ngAfterContentChecked(): void { - this.scrollbar = this.hasScrollbar(); - } - - public dashboardTour: GuidedTour = { - tourId: 'dmp-dataset-tour', - useOrb: true, - steps: [ - { - selector: '.dmp-tour', - content: 'Step 1', - orientation: Orientation.Right, - isStepUnique: false - }, - { - selector: '.dataset-tour', - content: 'Step 2', - orientation: Orientation.Right, - isStepUnique: false - } - ] - }; - - public isAuthenticated(): boolean { - return this.authService.currentAccountIsAuthenticated(); - } - - controlModified(): void { - // this.clearErrorModel(); - // if (this.refreshCallback != null && - // (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) - // ) { - // setTimeout(() => this.refreshCallback(true)); - // } - this.criteria.like = this.formGroup.get("like").value; - this.startIndex = 0; - this.refresh(); - } - - refresh(resetPages = false) { - // if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10; - // if (resetPages) this._paginator.pageIndex = 0; - // const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - // let fields: Array = new Array(); - // fields.push('-modified'); - //if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const request = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }); - this.criteria.isPublic = this.isPublic; - request.criteria = this.criteria; - - this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - // if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.totalCount = result.totalCount; - this.listingItems = result.data; - this.hasListingItems = true; - }); - } - - public loadMore() { - this.startIndex = this.startIndex + this.pageSize; - // const fields: Array = ["-modified"]; - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const request = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }); - this.criteria.isPublic = this.isPublic; - request.criteria = this.criteria; - - this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - // if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - // this.listingItems = this.listingItems.concat(result.data); - this.listingItems = this.listingItems.length > 0 ? this.mergeTwoSortedLists(this.listingItems, result.data, this.formGroup.get('order').value) : result.data; - this.hasListingItems = true; - }); - } - - pageThisEvent(event) { - this.refresh(); - } - - getDefaultCriteria(dmp: any = null): DatasetCriteria { - const defaultCriteria = new DatasetCriteria(); - if (dmp != null) { - defaultCriteria.dmpIds.push(dmp); - } - return defaultCriteria; - } - - getDraftCriteria(): DatasetCriteria { - const draftCriteria = new DatasetCriteria(); - draftCriteria.status = DatasetStatus.Draft; - return draftCriteria; - } - - makeItPublic(id: String) { - this.datasetService.makeDatasetPublic(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(); - } - - openFiltersDialog(): void { - const dialogRef = this.dialog.open(DatasetCriteriaDialogComponent, { - width: '456px', - height: '100%', - id: 'filters', - restoreFocus: false, - data: { - isPublic: this.isPublic, - status: this.status, - criteria: this.criteria, - formGroup: this.criteriaFormGroup, - // criteria: this.grantId ? this.criteria : this.getDefaultCriteria(), - updateDataFn: this.updateDataFn.bind(this) - }, - position: { right: '0px;' }, - panelClass: 'dialog-side-panel' - }); - - dialogRef.afterClosed().subscribe(result => { - }); - } - - updateDataFn(criteria: DatasetCriteriaComponent): void { - this.criteriaFormGroup = criteria.formGroup; - this.toDatasetCriteria(criteria); - this.refresh(); - } - - toDatasetCriteria(criteria: DatasetCriteriaComponent) { - let formGroup = criteria.formGroup; - this.criteria = { - like: formGroup.get("like").value, - status: formGroup.get("status").value, - allVersions: formGroup.get("allVersions").value, - role: formGroup.get("role").value - } - if (formGroup.get("tags") && formGroup.get("tags").value) { - this.criteria.tags = formGroup.get("tags").value.map(x => (x)); - } - if (formGroup.get("collaborators") && formGroup.get("collaborators").value) { - this.criteria.collaborators = formGroup.get("collaborators").value.map(x => x.id); - } - if (formGroup.get("dmpIds") && formGroup.get("dmpIds").value) { - this.criteria.dmpIds = formGroup.get("dmpIds").value.map(x => x.id); - } - if (formGroup.get("groupIds") && formGroup.get("groupIds").value) { - this.criteria.groupIds = formGroup.get("groupIds").value.map(x => x.groupId); - } - if (formGroup.get("grants") && formGroup.get("grants").value) { - this.criteria.grants = formGroup.get("grants").value.map(x => x.id); - } - if (formGroup.get("organisations") && formGroup.get("organisations").value) { - this.criteria.organisations = formGroup.get("organisations").value.map(x => x.id); - } - if (formGroup.get("datasetTemplates") && formGroup.get("datasetTemplates").value) { - this.criteria.datasetTemplates = formGroup.get("datasetTemplates").value.map(x => x.id) - } - if (formGroup.get("grantStatus") && formGroup.get("grantStatus").value) { - this.criteria.grantStatus = formGroup.get("grantStatus").value; - } - this.criteria.isPublic = this.isPublic; - // if (this.itemId) { - // // this.criteria.groupIds = [this.itemId]; - // this.criteria.allVersions = true; - // } - } - - public closeCard(): void { - this.isVisible = false; - } - - hasScrollbar(): boolean { - return document.getElementById("main-page").scrollHeight > document.documentElement.clientHeight - } - - private mergeTwoSortedLists(arr1: DatasetListingModel[], arr2: DatasetListingModel[], order: string): DatasetListingModel[] { - let merged = []; - let index1 = 0; - let index2 = 0; - let current = 0; - - while (current < (arr1.length + arr2.length)) { - - let isArr1Depleted = index1 >= arr1.length; - let isArr2Depleted = index2 >= arr2.length; - - if (order === 'modified') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].modified) > new Date(arr2[index2].modified)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'created') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].created) > new Date(arr2[index2].created)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'label') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].label.localeCompare(arr2[index2].label)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'status') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].status < arr2[index2].status))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'dmp:publishedAt|join|') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].dmpPublishedAt) > new Date(arr2[index2].dmpPublishedAt)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } - current++; - } - return merged; - } - - public setDashboardTourDmpText(): void { - this.dmpText = this.language.instant('DMP-LISTING.TEXT-INFO') + '\n\n' + - this.language.instant('DMP-LISTING.TEXT-INFO-QUESTION') + ' ' + - this.language.instant('DMP-LISTING.LINK-ZENODO') + ' ' + - this.language.instant('DMP-LISTING.GET-IDEA'); - this.dashboardTour.steps[0].title = this.dmpText; - } - - public setDashboardTourDatasetText(): void { - this.datasetText = this.language.instant('DATASET-LISTING.TEXT-INFO') + - this.language.instant('DATASET-LISTING.LINK-PUBLIC-DATASETS') + ' ' + - this.language.instant('DATASET-LISTING.TEXT-INFO-REST') + '\n\n' + - this.language.instant('DATASET-LISTING.TEXT-INFO-PAR'); - this.dashboardTour.steps[1].title = this.datasetText; - } - - public restartTour(): void { - this.setDashboardTourDmpText(); - this.setDashboardTourDatasetText(); - this.guidedTourService.startTour(this.dashboardTour); - } - - openNewDmpDialog() { - if (this.dialog.openDialogs.length > 0) { - this.dialog.closeAll(); - } - else { - const dialogRef = this.dialog.open(StartNewDmpDialogComponent, { - disableClose: false, - data: { - isDialog: true - } - }); - } - } - - addNewDataset() { - const dialogRef = this.dialog.open(StartNewDatasetDialogComponent, { - disableClose: false, - restoreFocus: false, - data: { - startNewDmp: false, - formGroup: new DatasetWizardEditorModel().buildForm() - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (result.startNewDmp) { - this.openNewDmpDialog(); - } else { - this.router.navigate(['/plans', 'edit', result.formGroup.get('dmp').value.id]); - } - } - }); - } - - hasLikeCriteria(): boolean { - return this.criteria.like !== undefined && this.criteria.like !== null; - } - - // rowClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/datasets/edit/' + dataset.id]); - // } -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html deleted file mode 100644 index fe2eebae2..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss deleted file mode 100644 index 20b421820..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.scss +++ /dev/null @@ -1,261 +0,0 @@ -.gray-container { - letter-spacing: 5px; - color: #aaaaaa; -} - -.container-header { - display: flex; - align-items: baseline; - margin-top: 0px; - text-transform: uppercase; -} - -.container-header p { - letter-spacing: 5px; - color: #aaaaaa; - padding-top: 10px; - margin-bottom: 0px; -} - -.container-header :hover { - color: var(--primary-color-3); -} - -h4 { - display: inline; - padding-left: 1em; - color: #333333; -} - -h4 > span { - text-transform: uppercase; -} - -.title h4 { - padding-left: 30px; - line-height: 2em; -} - -.about-item { - display: flex; - flex-wrap: wrap; -} - -.links :hover { - color: var(--primary-color-3); -} - -.about-item .length { - color: var(--primary-color-3); -} - -.about-item .title { - margin: 2px 10px; - // text-transform: uppercase; -} - -.about-item p { - margin-left: auto; - margin-bottom: 0px; - padding-top: 7px; - color: #aaaaaa; -} - -p { - color: #333333; -} - -.storage :hover { - color: var(--primary-color-3); -} - -.draft-bookmark { - color: #e7e6e6; -} - -.finalized-bookmark { - color: #08bd63; -} - -.dmp-card, -.dataset-card { - min-width: 712px; - /* min-height: 308px; */ - background: #ffffff 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #0000001a; - border-radius: 4px; - opacity: 1; - margin-top: 2.43rem; - margin-bottom: 1rem; -} - -.remove-border-bottom ::ng-deep .mat-tab-header { - border-bottom: none; -} - -input[type="text"] { - background: #fafafa 0% 0% no-repeat padding-box; - border: 1px solid #d1d1d1; - border-radius: 4px; - opacity: 1; - width: 347px; - height: 56px; - font-family: Arial, FontAwesome; - padding-left: 15px; -} - -.edited-date { - text-align: left; - font-weight: 300; - font-family: "Roboto", sans-serif; - line-height: 2.4; - letter-spacing: 0px; - color: #212121; - opacity: 0.6; -} - -.dmp-label { - background: var(--primary-color) 0% 0% no-repeat padding-box; - border-radius: 4px 0px; - opacity: 1; - min-width: 67px; - height: 37px; - color: #ffffff; - line-height: 2.4; -} - -.dataset-label { - width: auto; - height: 37px; - background: var(--secondary-color) 0% 0% no-repeat padding-box; - border-radius: 4px 0px; - text-align: left; - line-height: 2.8; - font-size: 0.875rem; - font-weight: 400; - letter-spacing: 0px; - color: #212121; -} - -.dmp-title, -.dataset-title { - text-align: left; - font-weight: 600; - font-family: "Roboto", sans-serif; - font-size: 1rem; - // opacity: 0.81; - padding-top: 0.75rem; - padding-bottom: 0.55rem; - color: #212121; -} - -.dataset-subtitle, -.dmp-subtitle { - display: flex; - flex-direction: row; - text-align: left; - font-weight: 400; - font-family: "Roboto", sans-serif; - font-size: 0.875rem; - opacity: 1; - align-items: center; - color: #848484; -} - -.dmp-title-draft, -.dataset-title-draft { - text-align: left; - font-weight: 600; - font-family: "Roboto", sans-serif; - font-size: 1rem; - // opacity: 0.81; - padding-top: 0.75rem; - padding-bottom: 0.55rem; - color: #f16868; -} - -.icon-align { - display: inline-flex; - vertical-align: middle; - // line-height: .9em; - // padding-bottom: 0.4rem; -} - -.dmp-subtitle, -.dataset-subtitle { - - .icon-align { - display: inline-flex; - vertical-align: top; - margin-right: .2rem; - line-height: .95em; - } -} - -.dataset-card-actions, -.dmp-card-actions { - display: flex; - flex-direction: row; - border-top: 1px solid #dbdbdb; - line-height: 4; - color: #848484; -} - -.dataset-card-actions a, -.dmp-card-actions a { - color: #848484 !important; - text-decoration: none !important; -} - -.dataset-card-actions a:hover, -.dmp-card-actions a:hover { - color: var(--primary-color) !important; -} - -.dmp-dataset-descriptions-title { - color: #000000; - opacity: 0.6; - padding-top: 1.5rem; - padding-bottom: 0.8rem; -} - -.dmp-dataset-descriptions-name { - color: #000000; - opacity: 0.6; - font-weight: 700; -} - -.show-more { - color: black !important; -} - -.show-more:hover { - color: var(--primary-color) !important; -} - -.btn-load-more { - border: 2px solid #212121; - border-radius: 30px; - opacity: 1; - min-width: 132px; - width: auto; - height: 40px; - margin-top: 4.125rem; -} - -.btn-load-more:hover { - background-color: black; - color: white; -} - -.draft { - color: #f16868; -} - -.pointer { - cursor: pointer; -} - -::ng-deep .mat-menu-panel { - max-width: 282px !important; -} diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts deleted file mode 100644 index fa61a8994..000000000 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts +++ /dev/null @@ -1,294 +0,0 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { Role } from '@app/core/common/enum/role'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { LockService } from '@app/core/services/lock/lock.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { takeUntil } from 'rxjs/operators'; -import { DatasetStatus } from '../../../../core/common/enum/dataset-status'; -import { DatasetListingModel } from '../../../../core/model/dataset/dataset-listing'; -import { DatasetCopyDialogueComponent } from '../../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { Guid } from '@common/types/guid'; - -@Component({ - selector: 'app-dataset-listing-item-component', - templateUrl: './dataset-listing-item.component.html', - styleUrls: ['./dataset-listing-item.component.scss'] -}) -export class DatasetListingItemComponent extends BaseComponent implements OnInit { - - @Input() dataset: DatasetListingModel; - @Input() showDivider: boolean = true; - @Input() isPublic: boolean = false; - @Output() onClick: EventEmitter = new EventEmitter(); - - isDraft: boolean; - isDeleted: boolean; - isUserOwner: boolean; - - constructor( - private router: Router, - public enumUtils: EnumUtils, - private datasetWizardService: DatasetWizardService, - public dialog: MatDialog, - private language: TranslateService, - private authentication: AuthService, - private uiNotificationService: UiNotificationService, - private lockService: LockService, - private location: Location, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Listing Item'); - if (this.dataset.status === DatasetStatus.Draft) { - this.isDraft = true; - this.isDeleted = false; - this.setIsUserOwner(); - } else if (this.dataset.status === DatasetStatus.Deleted) { - this.isDeleted = true; - } - else { - this.isDraft = false; - this.isDeleted = false; - this.setIsUserOwner(); - } - } - - setIsUserOwner() { - if (this.dataset) { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) this.isUserOwner = !!this.dataset.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - getItemLink(): string[] { - // return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`]; - return this.isPublic ? ['/datasets/overview/public/' + this.dataset.id] : ['/datasets/overview/' + this.dataset.id]; - } - - getDmpLink(): string[] { - return this.isPublic ? [`/explore-plans/overview/public/${this.dataset.dmpId}`] : [`/plans/edit/${this.dataset.dmpId}`]; - } - - downloadPDF(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadPDF(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", dataset.id); - }); - } - - downloadDOCX(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadDOCX(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", dataset.id); - }); - - } - - downloadXML(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadXML(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", dataset.id); - }); - } - - openShareDialog(dmpRowId: any, dmpRowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: dmpRowId, - dmpName: dmpRowName - } - }); - } - - openDmpSearchDialogue(dataset: DatasetListingModel) { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: dataset.id, - datasetProfileId: dataset.profile.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]); - // window.open(url.toString(), '_blank'); - } - }); - } - - deleteClicked(id: string) { - this.lockService.checkLockStatus(Guid.parse(id)).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDialog(id); - } else { - this.openLockedByUserDialog(); - } - }); - } - - openDeleteDialog(id: string): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK') - } - }); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { - this.router.navigate([path]); - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onCallbackSuccess(id?: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']); - } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.language.instant('DMP-LISTING.OWNER'); - } - else if (role === 1) { - return this.language.instant('DMP-LISTING.MEMBER'); - } - else { - return this.language.instant('DMP-LISTING.OWNER'); - } - } - - isUserDatasetRelated() { - const principalId: string = this.authentication.userId()?.toString(); - let isRelated: boolean = false; - if (this.dataset && principalId) { - this.dataset.users.forEach(element => { - if (element.id === principalId) { - isRelated = true; - } - }) - } - return isRelated; - } - - - - // onCallbackError(error: any) { - // this.setErrorModel(error.error); - // } - - // public setErrorModel(validationErrorModel: ValidationErrorModel) { - // Object.keys(validationErrorModel).forEach(item => { - // (this.dataset.validationErrorModel)[item] = (validationErrorModel)[item]; - // }); - // } - - // grantClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/grants/edit/' + dataset.grantId]); - // } - - // itemClicked() { - // this.onClick.emit(this.dataset); - // } - - // datasetClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/plans/edit/' + dataset.dmpId]) - // } - -} diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html deleted file mode 100644 index 92c068c65..000000000 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html +++ /dev/null @@ -1,186 +0,0 @@ -
-
-
- - chevron_left -

{{'DMP-WIZARD.ACTIONS.BACK' | translate}}

-
-
-
-
- -

{{ dataset.label }}

-
-
-
-

- {{ roleDisplayFromList(dataset.users) }} -

-
- . - - -
- public - {{'DMP-OVERVIEW.PUBLIC' | translate}} -
- . - - -
- lock_outline - {{'DMP-OVERVIEW.LOCKED' | translate}} -
- . -
{{'GENERAL.STATUSES.EDIT' | translate}} : - - {{dataset.modified | dateTimeCultureFormatter: "d MMMM y"}} -
-
-
- check - {{'TYPES.DATASET-STATUS.FINALISED' | translate}} -
-
-
-
- - - -
-
{{'DATASET-LISTING.TOOLTIP.PART-OF' | translate}}
-
- -
- -
-
{{'DMP-OVERVIEW.GRANT' | translate}}
-
{{ dataset.grant.label }}
-
- -
{{'DMP-OVERVIEW.RESEARCHERS' | translate}}
-
-
- - -
 
-
{{ researcher.name }},
-
{{ researcher.name }}
-
-
- -
{{ researcher.name }},
-
{{ researcher.name }}
-
-
- horizontal_rule -
- -
{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}
-
-

-
-
- horizontal_rule -
-
-
-
-
-
- -

{{ 'DMP-LISTING.ACTIONS.FINALIZE' | translate }}

-
-
-
-
-
-
- -

{{ 'DATASET-WIZARD.ACTIONS.REVERSE' | translate }}

-
-
- -

- {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}

-
- - - - - - - - -
-
-
-

{{ 'DATASET-OVERVIEW.DESCRIPTION-AUTHORS' | translate }}

-
-
-
-
- -
-

{{ user.name }} - - ({{ 'DMP-OVERVIEW.YOU' | translate }}) -

-

{{ roleDisplay(user) }}

-
-
- -
-
-
- -
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss deleted file mode 100644 index 4d5c9c4c6..000000000 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss +++ /dev/null @@ -1,301 +0,0 @@ -.container-fluid { - margin: 2em 4em; - padding: 2em; -} - -.dataset-overview { - // margin-top: 5rem; -} - -// ********ICONS******** - -.back-icon { - opacity: 0.4; -} - -.mat-mini-fab { - width: 2.5em; - height: 2.5em; - color: #212121; - background-color: var(--secondary-color); -} - -.mat-mini-fab-icon, -.status-icon { - font-size: 1.2em; -} - -.actions-btn:hover, -.finalize-btn:hover { - background-color: var(--primary-color); - color: #ffffff; -} - -.status-icon { - color: #a7a7a7; -} - -.check-icon { - font-weight: bold; -} - -.account-icon { - font-size: 2.5em; -} - -// ********BUTTONS******** - -.version-btn { - // width: 6.7em; - height: 1.8em; - border: 1px solid #707070; - border-radius: 4px; - background-color: transparent; -} - -.id-btn { - background: url("../../../../assets/images/NoPath.png") no-repeat center; - width: 1em; - margin-right: 0.3em; - align-self: center; -} - -.dmp-btn { - width: 35em; - min-height: 2.3em; - background-color: var(--primary-color); - border-radius: 4px; - flex-direction: row; - justify-content: space-between; - border: none; -} - -.dmp-btn, -.dmp-btn > mat-icon { - color: #ffffff; - // opacity: 0.8; -} - -.show-more-btn { - width: 31.6em; - padding: 0 1em; - background-color: #ffffff00; - color: var(--primary-color); - font-weight: 700; -} - -.frame-btn { - border: 1px solid #212121; - color: black; - background: #ffffff; -} - -.finalize-btn { - // border: 1px solid var(--secondary-color); - background: #f5db71; -} - -.frame-btn, -.finalize-btn { - box-shadow: 0px 2px 6px #00000029; -} - -.remove-btn { - border: none; - background-color: transparent; - font-size: 0.875em; - font-weight: bold; - margin-left: auto; -} - -.invite-btn { - width: 9.4em; - height: 2.9em; - background: #ffffff; - box-shadow: 0px 3px 6px #1e202029; - border: 2px solid #212121; - border-radius: 30px; -} - -.account_btn { - background: white; - color: #d5d5d5; - border: none; - height: 2.9em; -} - -// ********TEXT******** - -.dataset-logo { - width: 6em; - height: 2.6em; - background: var(--secondary-color); - border-radius: 4px; - font-size: 0.875em; - // color: #212121; - // color: black; - // opacity: 0.75; -} - -.label-txt { - font-size: 0.875em; -} - -.label2-txt { - font-size: 1em; -} - -.label-txt, -.label2-txt { - color: #848484; - font-weight: 400; -} - -.dataset-label { - font-weight: bold; - width: auto; -} - -.uppercase { - text-transform: uppercase; -} - -.researcher { - font-size: 0.875em; - color: var(--primary-color); - padding-right: 0.5em; - align-self: center; -} - -.header { - opacity: 0.6; - margin-top: 1em; - margin-bottom: 0.5em; -} - -.dataset-label, -.header { - font-size: 1.25em; - color: #212121; -} - -.desc-txt { - width: 48.25em; - font-size: 1em; - color: #212121; - margin-bottom: 1.875em; -} - -.dmp-btn-label { - margin-right: 1em; - overflow: hidden; - color: #ffffff; - opacity: 0.8; - text-align: left; -} - -.doi-label { - font-size: 1em; - color: #212121; - opacity: 0.6; - margin-bottom: 0.3em; -} - -.doi-txt { - font-size: 0.8em; - letter-spacing: 0.009em; - color: #7d7d7d; - width: 12em; - height: 1em; - overflow: hidden; - border: none; - padding: 0px; -} - -.doi-panel { - height: 3.5em; - background: #fafafa; - border: 1px solid #d1d1d1; - border-radius: 4px; - flex-direction: row; - justify-content: space-between; -} - -.doi-link { - color: white; -} - -.frame { - background: #ffffff; - box-shadow: 0px 1px 5px #00000026; - border-radius: 4px; - overflow: hidden; -} - -.frame-txt { - color: #000000; -} - -.frame-txt, -.finalize-txt { - font-size: 0.75em; - font-weight: bold; - letter-spacing: 0px; - text-transform: uppercase; - cursor: pointer; -} - -.hr-line { - border: 1px solid #dbdbdb; - // width: 274px; - // width: 17em; - width: 100%; -} - -.authors { - display: flex; - flex-direction: row; - justify-content: space-between; - width: 100%; -} - -.authors-label { - font-size: 0.875em; - color: #212121; - height: 1.4em; - margin-bottom: 0px; -} - -.authors-role { - font-size: 0.875em; - color: #a8a8a8; - height: 1.4em; - margin-bottom: 0px; -} - -// ********CENTER ELEMENTS******** - -.mat-mini-fab, -.mat-mini-fab-icon, -.actions-btn, -.status-icon, -.dataset-logo, -.frame-btn, -.finalize-btn { - display: flex; - justify-content: center; - align-items: center; -} - -.dataset-label, -.dmp-btn, -.doi-panel, -.researcher { - display: flex; - align-items: center; -} - -.show-more-btn { - display: flex; - justify-content: center; -} diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts deleted file mode 100644 index c2d7f854a..000000000 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ /dev/null @@ -1,550 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview'; -import { BaseComponent } from '@common/base/base.component'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { UntypedFormControl } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; -import { Role } from '@app/core/common/enum/role'; -import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; -import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview'; -import { ResearcherModel } from '@app/core/model/researcher/researcher'; -import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { LockService } from '@app/core/services/lock/lock.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { filter, takeUntil } from 'rxjs/operators'; -import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { Guid } from '@common/types/guid'; - - -@Component({ - selector: 'app-dataset-overview', - templateUrl: './dataset-overview.component.html', - styleUrls: ['./dataset-overview.component.scss'] -}) -export class DatasetOverviewComponent extends BaseComponent implements OnInit { - - dataset: DatasetOverviewModel; - // datasetWizardEditorModel: DatasetWizardEditorModel; - datasetWizardModel: DatasetWizardModel; - isNew = true; - isFinalized = false; - isPublicView = true; - hasPublishButton: boolean = true; - // breadCrumbs: Observable = observableOf(); - isUserOwner: boolean; - expand = false; - researchers: ResearcherModel[]; - users: UserInfoListingModel[]; - lockStatus: Boolean; - - constructor( - private route: ActivatedRoute, - private router: Router, - private datasetService: DatasetService, - private translate: TranslateService, - private authentication: AuthService, - private dialog: MatDialog, - private language: TranslateService, - private uiNotificationService: UiNotificationService, - private configurationService: ConfigurationService, - private oauth2DialogService: Oauth2DialogService, - private userService: UserServiceOld, - private dmpService: DmpService, - private location: Location, - private datasetWizardService: DatasetWizardService, - private lockService: LockService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Dataset Overview'); - // Gets dataset data using parameter id - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe((params: Params) => { - const itemId = params['id']; - const publicId = params['publicId']; - if (itemId != null) { - this.isNew = false; - this.isPublicView = false; - this.datasetService.getOverviewSingle(itemId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dataset = data; - this.researchers = this.dataset.dmp.researchers; - this.users = this.dataset.dmp.users; - this.checkLockStatus(this.dataset.id); - this.setIsUserOwner(); - // const breadCrumbs = []; - // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" }); - // breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/overview/' + this.dataset.id }); - // this.breadCrumbs = observableOf(breadCrumbs); - }, (error: any) => { - if (error.status === 404) { - return this.onFetchingDeletedCallbackError('/datasets/'); - } - if (error.status === 403) { - return this.onFetchingForbiddenCallbackError('/datasets/'); - } - }); - } - else if (publicId != null) { - this.isNew = false; - this.isFinalized = true; - this.isPublicView = true; - this.datasetService.getOverviewSinglePublic(publicId) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dataset = data; - this.researchers = this.dataset.dmp.researchers; - this.users = this.dataset.dmp.users; - // const breadCrumbs = []; - // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); - // breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/overview/public/' + this.dataset.id }); - // this.breadCrumbs = observableOf(breadCrumbs); - }, (error: any) => { - if (error.status === 404) { - return this.onFetchingDeletedCallbackError('/explore'); - } - if (error.status === 403) { - return this.onFetchingForbiddenCallbackError('/explore'); - } - }); - } - }); - } - - checkLockStatus(id: string) { - this.lockService.checkLockStatus(Guid.parse(id)).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - this.lockStatus = lockStatus - if (lockStatus) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DATASET-OVERVIEW.LOCKED.TITLE'), - message: this.language.instant('DATASET-OVERVIEW.LOCKED.MESSAGE') - }, maxWidth: '30em' - }); - } - }); - } - - onFetchingDeletedCallbackError(redirectRoot: string) { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.DELETED-DATASET'), SnackBarNotificationLevel.Error); - this.router.navigate([redirectRoot]); - } - - onFetchingForbiddenCallbackError(redirectRoot: string) { - this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.FORBIDEN-DATASET'), SnackBarNotificationLevel.Error); - this.router.navigate([redirectRoot]); - } - - goBack(): void { - this.location.back(); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path])); - } - - setIsUserOwner() { - if (this.dataset) { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) this.isUserOwner = !!this.dataset.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - } - - isUserAuthor(userId: string): boolean { - if (this.isAuthenticated()) { - const principalId: string = this.authentication.userId()?.toString(); - return userId === principalId; - } else return false; - } - - isUserDatasetRelated() { - const principalId: string = this.authentication.userId()?.toString(); - let isRelated: boolean = false; - if (this.dataset && principalId) { - this.dataset.users.forEach(element => { - if (element.id === principalId) { - isRelated = true; - } - }) - } - return isRelated; - } - - roleDisplay(value: UserInfoListingModel) { - if (value.role === Role.Owner) { - return this.translate.instant('DMP-LISTING.OWNER'); - } else if (value.role === Role.Member) { - return this.translate.instant('DMP-LISTING.MEMBER'); - } else { - return this.translate.instant('DMP-LISTING.OWNER'); - } - } - - - roleDisplayFromList(value: UserInfoListingModel[]) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === Role.Owner) { - return this.translate.instant('DMP-LISTING.OWNER'); - } else if (role === Role.Member) { - return this.translate.instant('DMP-LISTING.MEMBER'); - } else { - return this.translate.instant('DMP-LISTING.OWNER'); - } - } - - openShareDialog(rowId: any, rowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - autoFocus: false, - restoreFocus: false, - data: { - dmpId: rowId, - dmpName: rowName - } - }); - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - isDraftDataset(dataset: DatasetOverviewModel) { - return dataset.status == DatasetStatus.Draft; - } - - isFinalizedDataset(dataset: DatasetOverviewModel) { - return dataset.status == DatasetStatus.Finalized; - } - - editClicked(dataset: DatasetOverviewModel) { - if (dataset.public) { - this.router.navigate(['/datasets/publicEdit/', dataset.id]); - // let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id]); - // window.open(url.toString(), '_blank'); - } else { - this.router.navigate(['/datasets/edit/', dataset.id]); - // let url = this.router.createUrlTree(['/datasets/edit/', dataset.id]); - // let url = this.router.createUrlTree(['/plans/edit/', dataset.dmp.id], { queryParams: { dataset: dataset.id } }); - // window.open(url.toString(), '_blank'); - } - } - - deleteClicked() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetService.delete(this.dataset.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onDeleteCallbackSuccess(); - }, - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - dmpClicked(dmp: DmpOverviewModel) { - if (this.isPublicView) { - this.router.navigate(['/explore-plans/overview/public/' + dmp.id]); - } else { - this.router.navigate(['/plans/overview/' + dmp.id]); - } - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/datasets']); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onUpdateCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onUpdateCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.tryTranslate(error.error.message) : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); - } - tryTranslate(errorMessage: string): string { - return errorMessage.replace('Field value of', this.language.instant('Field value of')) - .replace('must be filled', this.language.instant('must be filled')); - } - - public getOrcidPath(): string { - return this.configurationService.orcidPath; - } - - isOrcid(reference: string) { - const head = reference.split(':')[0]; - return head === 'orcid'; - } - - getOrcidPathForResearcher(reference: string): string { - const path = this.getOrcidPath(); - const userId = reference.split(':')[1]; - return path + userId; - } - - downloadPDF(id: string) { - this.datasetService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", id); - }); - } - - downloadDocx(id: string) { - this.datasetService.downloadDocx(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", id); - }); - } - - downloadXml(id: string) { - this.datasetService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", id); - }); - } - - //GK: NO - // downloadJson(id: string) { - // this.datasetService.downloadJson(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(response => { - // const blob = new Blob([response.body], { type: 'application/json' }); - // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - // FileSaver.saveAs(blob, filename); - // }) - // } - - openDmpSearchDialogue() { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: this.dataset.id, - datasetProfileId: this.dataset.datasetTemplate.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]) - // window.open(url.toString(), '_blank') - } - }); - } - - updateUsers() { - return this.dmpService.updateUsers(this.dataset.dmp.id, this.users).pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onUpdateCallbackSuccess(); - }, - error => this.onUpdateCallbackError(error) - ); - } - - removeUserFromDmp(user: UserInfoListingModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-USER'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().subscribe(result => { - if (result) { - const index = this.users.findIndex(x => x.id === user.id); - if (index > -1) { - this.users.splice(index, 1); - } - this.updateUsers(); - } - }); - } - - showPublishButton(dataset: DatasetOverviewModel) { - return this.isFinalizedDataset(dataset) && !dataset.public && this.hasPublishButton; - } - - // publish(id: String) { - // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - // maxWidth: '500px', - // restoreFocus: false, - // data: { - // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'), - // privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'), - // confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - // cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - // isDeleteConfirmation: false - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // this.datasetService.publish(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(() => { - // this.hasPublishButton = false; - // this.reloadPage(); - // }); - // } - // }); - // } - - finalize(dataset: DatasetOverviewModel) { - - - this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('DATASET-OVERVIEW.FINALISE-POPUP.MESSAGE'), - confirmButton: this.language.instant('DATASET-OVERVIEW.FINALISE-POPUP.CONFIRM'), - cancelButton: this.language.instant('DATASET-OVERVIEW.FINALISE-POPUP.CANCEL'), - }, - maxWidth: '30em' - }) - .afterClosed() - .pipe( - filter(x => x), - takeUntil(this._destroyed) - ) - .subscribe(_ => { - this.router.navigate(['datasets', 'edit', dataset.id, 'finalize']); - }) - - - - - - // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - // restoreFocus: false, - // data: { - // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), - // confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - // cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - // isDeleteConfirmation: false - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // this.datasetWizardService.getSingle(dataset.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(data => { - // this.datasetWizardModel = data; - // this.datasetWizardModel.status = DatasetStatus.Finalized; - // this.datasetWizardService.createDataset(this.datasetWizardModel) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // data => this.onUpdateCallbackSuccess(), - // error => this.onUpdateCallbackError(error) - // ); - // }); - // } - // }); - } - - hasReversableStatus(dataset: DatasetOverviewModel): boolean { - return dataset.dmp.status == DmpStatus.Draft && dataset.status == DatasetStatus.Finalized - } - - reverse(dataset: DatasetOverviewModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.getSingle(dataset.id) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.datasetWizardModel = data; - this.datasetWizardModel.status = DatasetStatus.Draft; - this.datasetWizardService.createDataset(this.datasetWizardModel) - .pipe(takeUntil(this._destroyed)) - .subscribe( - data => this.onUpdateCallbackSuccess(), - error => this.onUpdateCallbackError(error) - ); - }); - } - }); - } - -} diff --git a/dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.html b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.html similarity index 100% rename from dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.html rename to dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.html diff --git a/dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.scss b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.scss rename to dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.scss diff --git a/dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.ts b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.ts similarity index 100% rename from dmp-frontend/src/app/ui/dmp/dataset-preview/dataset-preview-dialog.component.ts rename to dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.component.ts diff --git a/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts new file mode 100644 index 000000000..30c165387 --- /dev/null +++ b/dmp-frontend/src/app/ui/description/description-preview/dataset-preview-dialog.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { FormattingModule } from '@app/core/formatting.module'; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DatasetPreviewDialogComponent } from './dataset-preview-dialog.component'; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + FormattingModule, + ], + declarations: [ + DatasetPreviewDialogComponent, + ], + exports: [ + DatasetPreviewDialogComponent, + ] +}) +export class DatasetPreviewDialogModule { } diff --git a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html index db8d56585..f5a0a48fc 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.html @@ -1,16 +1,16 @@
-

{{'DATASET-EDITOR.TITLE.INTRO' | translate}}

- {{'DATASET-EDITOR.TITLE.INTRO-TIP' | translate}} +

{{'DESCRIPTION-EDITOR.BASE-INFO.INTRO' | translate}}

+ {{'DESCRIPTION-EDITOR.BASE-INFO.INTRO-TIP' | translate}}
-
1.1 {{'DATASET-EDITOR.FIELDS.TITLE' | translate}}*
+
1.1 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.TITLE' | translate}}*
- - + + {{formGroup.get('label').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -20,14 +20,11 @@
-
1.2 {{'DATASET-EDITOR.FIELDS.DESCRIPTION' | translate}}
- {{'DATASET-EDITOR.HINT.DESCRIPTION' | translate}} +
1.2 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.DESCRIPTION' | translate}}
+ {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.DESCRIPTION-HINT' | translate}}
- +
{{formGroup.get('description').getError('backendError').message}} @@ -36,23 +33,33 @@
- - - + +
+
+
1.3 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.TAGS' | translate}}*
+
+ +
+
+
-
1.4 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
- +
+
+
1.4 {{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.DESCRIPTION-TEMPLATE' | translate}}*
+
+ + + +
+ {{descriptionTemplate.label}} +
+
+
+ {{formGroup.get('descriptionTemplateId').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts index 478f45437..af3fab1f2 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-base-fields-editor/description-base-fields-editor.component.ts @@ -1,7 +1,14 @@ import { Component, Input } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { Description } from '@app/core/model/description/description'; +import { DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { Dmp } from '@app/core/model/dmp/dmp'; +import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; +import { DescriptionService } from '@app/core/services/description/description.service'; +import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from 'rxjs/operators'; @Component({ selector: 'app-description-base-fields-editor-component', @@ -11,77 +18,24 @@ import { BaseComponent } from '@common/base/base.component'; export class DescriptionBaseFieldsEditorComponent extends BaseComponent { @Input() formGroup: UntypedFormGroup; - @Input() availableDescriptionTemplates: DescriptionTemplate[]; - @Input() dmpId: string; + @Input() availableDescriptionTemplates: DescriptionTemplate[] = []; + @Input() description: Description; viewOnly = false; //TODO: not used. constructor( + private dmpBlueprintService: DmpBlueprintService, + private descriptionTemplateService: DescriptionTemplateService, ) { super(); } - checkMinMax(event, profile: DescriptionTemplate) { - //TODO: Add logic for validating description templates. - // event.stopPropagation(); - // const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; - // const blueprintId = this.formGroup.get('dmp').value.profile.id; - // this.dmpBlueprintService.getSingle(blueprintId, - // [ - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - // ] - // ) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // const section = result.definition.sections[dmpSectionIndex]; - // if(section.hasTemplates){ - // const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); - // if (foundTemplate !== undefined) { - // let count = 0; - // if(this.formGroup.get('dmp').value.datasets != null){ - // for(let dataset of this.formGroup.get('dmp').value.datasets){ - // if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ - // count++; - // } - // } - // if(count === foundTemplate.maxMultiplicity){ - // this.dialog.open(PopupNotificationDialogComponent, { - // data: { - // title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), - // message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') - // }, maxWidth: '30em' - // }); - // } - // else{ - // this.formGroup.get('profile').setValue(profile); - // } - // } - // } - // else { - // this.formGroup.get('profile').setValue(profile); - // } - // } - // else { - // this.formGroup.get('profile').setValue(profile); - // } - // }); + ngOnInit() { + const section: DmpBlueprintDefinitionSection = this.dmpBlueprintService.getSection(this.description.dmp.blueprint, this.description.dmpDescriptionTemplate.sectionId); + const descriptionTemplateIds = section ? section.descriptionTemplates.map(x => x.descriptionTemplateId) : []; + if (descriptionTemplateIds && descriptionTemplateIds.length > 0) { + this.descriptionTemplateService.query(this.descriptionTemplateService.buildAutocompleteLookup(null, null, descriptionTemplateIds)) + .pipe(takeUntil(this._destroyed)).subscribe(queryResult => { + this.availableDescriptionTemplates = queryResult.items; + }); + } } public compareWith(object1: any, object2: any) { diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html index 209e71324..e1bc4b90d 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html @@ -1,7 +1,6 @@
-
@@ -9,15 +8,15 @@
-
{{'DESCRIPTION-EDITOR.TITLE.ADD-DATASET' | translate}}
-
{{'DESCRIPTION-EDITOR.TITLE.EDIT-DESCRIPTION' | translate}}
+
{{'DESCRIPTION-EDITOR.TITLE-ADD-DESCRIPTION' | translate}}
+
{{'DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION' | translate}}
{{ formGroup.get('label').value }} ({{'DESCRIPTION-EDITOR.CHANGES' | translate}})
-
{{'DESCRIPTION-EDITOR.TITLE.PREVIEW-DATASET' | translate}}
+
{{'DESCRIPTION-EDITOR.TITLE-PREVIEW-DESCRIPTION' | translate}}
-
{{'DESCRIPTION-EDITOR.TOOLTIP.TO-DMP' | translate}}
+
{{'DESCRIPTION-EDITOR.TO-DMP' | translate}}
: {{ item.dmp.label }}
@@ -29,7 +28,7 @@
@@ -70,7 +69,7 @@ - + @@ -90,13 +89,13 @@ chevron_left {{'DESCRIPTION-EDITOR.ACTIONS.BACK-TO' | translate}}
-
{{'DESCRIPTION-EDITOR.TOOLTIP.DMP' | translate}}
+
{{'DESCRIPTION-EDITOR.DMP' | translate}}
-
{{'DESCRIPTION-EDITOR.STEPPER.USER-GUIDE' | translate}}
+
{{'DESCRIPTION-EDITOR.TOC.TITLE' | translate}}
-
0. {{'DESCRIPTION-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
-
0. {{'DESCRIPTION-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
+
0. {{'DESCRIPTION-EDITOR.TOC.MAIN-INFO' | translate}} (2)
+
0. {{'DESCRIPTION-EDITOR.TOC.MAIN-INFO' | translate}} (done)
@@ -106,19 +105,19 @@
-
{{'DESCRIPTION-EDITOR.STEPPER.NEXT' | translate}}
+
{{'DESCRIPTION-EDITOR.TOC.NEXT' | translate}}
chevron_right
-
{{'DESCRIPTION-EDITOR.STEPPER.NEXT' | translate}}
+
{{'DESCRIPTION-EDITOR.TOC.NEXT' | translate}}
chevron_right
@@ -126,7 +125,7 @@
- + = []; diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts index 17d972825..350589979 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.module.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { FormattingModule } from '@app/core/formatting.module'; -import { UrlListingModule } from '@app/library/url-listing/url-listing.module'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; @@ -11,18 +10,21 @@ import { DescriptionFormModule } from './description-form/description-form.modul import { VisibilityRulesService } from './description-form/visibility-rules/visibility-rules.service'; import { DescriptionFormProgressIndicationModule } from './form-progress-indication/form-progress-indication.module'; import { TableOfContentsModule } from './table-of-contents/table-of-contents.module'; +import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module'; +import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module'; @NgModule({ imports: [ CommonUiModule, CommonFormsModule, - UrlListingModule, FormattingModule, ConfirmationDialogModule, TableOfContentsModule, DescriptionFormProgressIndicationModule, DescriptionFormModule, - DescriptionEditorRoutingModule + DescriptionEditorRoutingModule, + RichTextEditorModule, + TagsFieldModule ], declarations: [ DescriptionEditorComponent, diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts index 62e5478c2..87c1c6fda 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; import { Description, DescriptionField, DescriptionReference, DescriptionTag, PropertyDefinition } from '@app/core/model/description/description'; +import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; import { Reference } from '@app/core/model/reference/reference'; import { Tag } from '@app/core/model/tag/tag'; @@ -30,7 +31,20 @@ export class DescriptionEditorResolver extends BaseEditorResolver { [nameof(x => x.dmp), nameof(x => x.id)].join('.'), [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), + [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.sectionId)].join('.'), [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), [nameof(x => x.descriptionTemplate), nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.id)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html index c6bebfe74..5c7661260 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.html @@ -1,8 +1,7 @@
- - + {{path}} {{fieldSet.title}}
info diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts index ef6c0d57f..ce931d8c0 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-composite-title/form-composite-title.component.ts @@ -10,6 +10,7 @@ export class DescriptionFormCompositeTitleComponent implements OnInit { @Input() fieldSet: DescriptionTemplateFieldSet; @Input() isChild: Boolean = false; + @Input() path: string; public showExtendedDescription: boolean = false; diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html index 36d519d48..0670dcec6 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -2,7 +2,7 @@
- +
@@ -19,7 +19,7 @@
- +
@@ -41,7 +41,8 @@
- {{propertiesFormGroup.get(field.id).get('value').getRawValue() | fieldValue | translate}} + + {{propertiesFormGroup.get(field.id).get('value').getRawValue() | fieldValue | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index baaca9e64..9e4e464c2 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -8,8 +8,7 @@ import { MatSort } from '@angular/material/sort'; import { ActivatedRoute, Router } from '@angular/router'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { DmpService, DmpServiceNew } from '@app/core/services/dmp/dmp.service'; -import { GrantService } from "@app/core/services/grant/grant.service"; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; @@ -19,6 +18,7 @@ import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service' // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { Description } from '@app/core/model/description/description'; +import { DmpBlueprint } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; import { DmpLookup } from '@app/core/query/dmp.lookup'; import { BaseComponent } from '@common/base/base.component'; @@ -27,7 +27,6 @@ import { TranslateService } from '@ngx-translate/core'; import { NgDialogAnimationService } from "ng-dialog-animation"; import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; -import { FileFormat } from '@app/core/model/file/file-format.model'; @Component({ selector: 'app-dmp-listing-component', @@ -45,7 +44,6 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr isPublic: boolean = false; hasListingItems = null; pageSize: number = 5; - fileFormats: FileFormat[] = []; public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), order: new UntypedFormControl() @@ -56,14 +54,12 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr constructor( private dmpService: DmpService, - private dmpServiceNew: DmpServiceNew, private router: Router, private route: ActivatedRoute, public dialogAnimation: NgDialogAnimationService, public dialog: MatDialog, public enumUtils: EnumUtils, private language: TranslateService, - private grantService: GrantService, private uiNotificationService: UiNotificationService, private authService: AuthService, private guidedTourService: GuidedTourService, @@ -77,9 +73,11 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr this.matomoService.trackPageView('DMPs'); this.isPublic = this.router.url.startsWith('/explore-plans'); if (this.isPublic) { - this.formGroup.get('order').setValue(this.order.PUBLISHED); + //TODO refactor + // this.formGroup.get('order').setValue(this.order.PUBLISHED); } else { - this.formGroup.get('order').setValue(this.order.MODIFIED); + //TODO refactor + // this.formGroup.get('order').setValue(this.order.MODIFIED); } if (!this.isPublic && !this.authService.currentAccountIsAuthenticated()) { this.router.navigateByUrl("/explore-plans"); @@ -108,8 +106,6 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr this.formGroup.get('order').valueChanges .pipe(takeUntil(this._destroyed)) .subscribe(x => this.refresh(this.lookup)); - - this.dmpServiceNew.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result); } public dashboardTour: GuidedTour = { @@ -165,6 +161,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr fields: [ nameof(x => x.id), nameof(x => x.label), + nameof(x => x.description), nameof(x => x.status), nameof(x => x.accessType), nameof(x => x.version), @@ -172,6 +169,10 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr nameof(x => x.updatedAt), [nameof(x => x.descriptions), nameof(x => x.id)].join('.'), [nameof(x => x.descriptions), nameof(x => x.label)].join('.'), + + [nameof(x => x.blueprint), nameof(x => x.id)].join('.'), + [nameof(x => x.blueprint), nameof(x => x.label)].join('.'), + // [nameof(x => x.descriptionTemplate), nameof(x => x.label)].join('.'), // [nameof(x => x.dmp), nameof(x => x.id)].join('.'), // [nameof(x => x.dmp), nameof(x => x.label)].join('.'), @@ -186,7 +187,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr // [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), ] }; - this.dmpServiceNew.query(lookup).pipe(takeUntil(this._destroyed)) + this.dmpService.query(lookup).pipe(takeUntil(this._destroyed)) .subscribe(result => { if (!result) { return []; } this.totalCount = result.count; diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts index a34ec76af..148a6688e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts @@ -4,6 +4,8 @@ import { DmpListingComponent } from '@app/ui/dmp/listing/dmp-listing.component'; import { DmpListingItemComponent } from '@app/ui/dmp/listing/listing-item/dmp-listing-item.component'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; +import { CloneDmpDialogModule } from '../clone-dialog/dmp-clone-dialog.module'; +import { NewVersionDmpDialogModule } from '../new-version-dialog/dmp-new-version-dialog.module'; import { DmpListingRoutingModule } from './dmp-listing.routing'; @NgModule({ @@ -11,6 +13,8 @@ import { DmpListingRoutingModule } from './dmp-listing.routing'; CommonUiModule, CommonFormsModule, FormattingModule, + CloneDmpDialogModule, + NewVersionDmpDialogModule, DmpListingRoutingModule ], declarations: [ diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index f067d197f..876abaf1a 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -31,43 +31,20 @@ open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} add{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}} group_add{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}} - filter_none{{'DMP-LISTING.ACTIONS.CLONE' | translate}} + filter_none{{'DMP-LISTING.ACTIONS.CLONE' | translate}} library_books{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}} delete{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }} more_horiz
- - -
- -
+
- - -
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index 5ccccc0bd..d5f2a7556 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -6,9 +6,9 @@ import { Router } from '@angular/router'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { Dmp } from '@app/core/model/dmp/dmp'; +import { CloneDmpPersist, Dmp } from '@app/core/model/dmp/dmp'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; @@ -24,6 +24,9 @@ import { DmpStatus } from '../../../../core/common/enum/dmp-status'; import { AuthService } from '../../../../core/services/auth/auth.service'; import * as FileSaver from 'file-saver'; import { FileFormat } from '@app/core/model/file/file-format.model'; +import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; +import { CloneDmpDialogComponent } from '../../clone-dialog/dmp-clone-dialog.component'; +import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-version-dialog.component'; @Component({ selector: 'app-dmp-listing-item-component', @@ -35,7 +38,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { @Input() dmp: Dmp; @Input() showDivider: boolean = true; @Input() isPublic: boolean; - @Input() fileFormats: FileFormat[] = []; @Output() onClick: EventEmitter = new EventEmitter(); isDraft: boolean; @@ -49,7 +51,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { private dialog: MatDialog, private authentication: AuthService, public enumUtils: EnumUtils, - private dmpService: DmpServiceNew, + private dmpService: DmpService, private dmpBlueprintService: DmpBlueprintService, private language: TranslateService, private uiNotificationService: UiNotificationService, @@ -58,6 +60,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { private httpClient: HttpClient, private matomoService: MatomoService, public referenceService: ReferenceService, + public fileTransformerService: FileTransformerService, private fileUtils: FileUtils) { super(); } @@ -118,126 +121,38 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { return this.dmp.dmpUsers?.some(x => (x.user.id === principalId)); } - cloneOrNewVersionClicked(dmp: Dmp, isNewVersion: boolean) { - // this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel)) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(data => { - // this.dmpModel = new DmpEditorModel(); - // this.dmpModel.grant = new GrantTabModel(); - // this.dmpModel.project = new ProjectFormModel(); - // this.dmpModel.funder = new FunderFormModel(); - // this.dmpModel.extraProperties = new ExtraPropertiesFormModel(); - // this.dmpModel.fromModel(data); - // this.dmpModel.status = DmpStatus.Draft; - // this.dmpFormGroup = this.dmpModel.buildForm(); - - // if (!isNullOrUndefined(this.dmpFormGroup.get('profile').value)) { - // this.getBlueprintDefinition(Guid.parse(this.dmpFormGroup.get('profile').value), result => { - // this.checkForGrant(result.definition); - // this.checkForFunder(result.definition); - // this.checkForProject(result.definition); - // }); - // } - - // if (!isNewVersion) { - // this.dmpFormGroup.get('label').setValue(dmp.label + " New"); - // } - // this.openCloneDialog(isNewVersion); - // }); + cloneClicked() { + const dialogRef = this.dialog.open(CloneDmpDialogComponent, { + maxWidth: '700px', + maxHeight: '80vh', + data: { + dmp: this.dmp + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: Dmp) => { + if (result) { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + this.router.navigate(['/plans/edit/', result.id]); + } + }); } - openCloneDialog(isNewVersion: boolean) { - // TODO: fix this - // const dialogRef = this.dialog.open(CloneDialogComponent, { - // maxWidth: '700px', - // maxHeight: '80vh', - // data: { - // formGroup: this.dmpFormGroup, - // datasets: this.dmpFormGroup.get('datasets').value, - // isNewVersion: isNewVersion, - // confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), - // cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result) { - // if (!isNewVersion) { - // this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmp.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => this.onCloneOrNewVersionCallbackSuccess(complete), - // error => this.onCloneOrNewVersionCallbackError(error) - // ); - // } else if (isNewVersion) { - // this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmp.id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => this.onCloneOrNewVersionCallbackSuccess(complete), - // error => this.onCloneOrNewVersionCallbackError(error) - // ); - // } - // } - // }); + newVersionClicked() { + const dialogRef = this.dialog.open(NewVersionDmpDialogComponent, { + maxWidth: '700px', + maxHeight: '80vh', + data: { + dmp: this.dmp + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: Dmp) => { + if (result) { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + this.router.navigate(['/plans/edit/', result.id]); + } + }); } - downloadXml(id: Guid) { - // TODO: Add this - // this.dmpService.downloadXML(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(response => { - // const blob = new Blob([response.body], { type: 'application/xml' }); - // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - // FileSaver.saveAs(blob, filename); - // this.matomoService.trackDownload('dmps', "xml", id); - // }); - } - - download(id: Guid, format: string) { - // TODO: Add this - this.dmpService.download(id.toString(), format) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/octet-stream' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', format, id.toString()); - }); - } - - // downloadPDF(id: Guid) { - // this.dmpService.downloadPDF(id.toString()) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(response => { - // const blob = new Blob([response.body], { type: 'application/pdf' }); - // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - // FileSaver.saveAs(blob, filename); - // this.matomoService.trackDownload('dmps', "pdf", id.toString()); - // }); - // } - - downloadJson(id: Guid) { - // TODO: Add this - // this.dmpService.downloadJson(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(response => { - // const blob = new Blob([response.body], { type: 'application/json' }); - // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - // FileSaver.saveAs(blob, filename); - // this.matomoService.trackDownload('dmps', "json", id); - // }, async error => { - // this.onExportCallbackError(error); - // }); - } - - // async onExportCallbackError(error: any) { - // const errorJsonText = await error.error.text(); - // const errorObj = JSON.parse(errorJsonText); - // this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); - // } - deleteClicked(id: Guid) { this.lockService.checkLockStatus(Guid.parse(id.toString())).pipe(takeUntil(this._destroyed)) .subscribe(lockStatus => { @@ -302,20 +217,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); } - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - onCloneOrNewVersionCallbackSuccess(cloneId: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans/edit/', cloneId]); - } - - onCloneOrNewVersionCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); - } - isUserOwner(dmp: Dmp): boolean { const principalId: Guid = this.authentication.userId(); if (principalId) return !!dmp.dmpUsers?.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.id)); diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html new file mode 100644 index 000000000..5a16f71b9 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html @@ -0,0 +1,67 @@ +
+
+
{{'DMP-NEW-VERSION-DIALOG.TITLE' | translate}}
+ close +
+ +
+
+
{{'DMP-NEW-VERSION-DIALOG.FIELDS.LABEL' | translate}}*
+
+
+ + + {{formGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+ +
+
+
{{'DMP-NEW-VERSION-DIALOG.FIELDS.DESCRIPTION' | translate}}
+
+
{{'DMP-NEW-VERSION-DIALOG.FIELDS.DESCRIPTION-HINT' | translate}}
+
+ + +
+
+ +
+
+
{{'DMP-NEW-VERSION-DIALOG.FIELDS.BLUEPRINT' | translate}}*
+
+
+ + + + +
+
+
+
+
{{'DMP-NEW-VERSION-DIALOG.FIELDS.DESCRIPTIONS' | translate}}
+
+
+
{{'DMP-NEW-VERSION-DIALOG.FIELDS.DESCRIPTIONS-HINT' | translate}}
+
+
+ + + + {{description.label}} + + + +
+
+
{{'DMP-NEW-VERSION-DIALOG.NO-DESCRIPTIONS' | translate}}
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.scss b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.scss new file mode 100644 index 000000000..1aa4894b8 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.scss @@ -0,0 +1,60 @@ +.new-version-dialog { + padding: 1.5rem; + + .heading { + text-align: left; + font-weight: 700; + font-size: 18px; + letter-spacing: 0px; + color: #212121; + opacity: 0.81; + margin-bottom: 0.625rem; + } + + .heading-1 { + text-align: left; + font-weight: 700; + font-size: 20px; + letter-spacing: 0px; + color: #212121; + opacity: 0.81; + margin-bottom: 0.625rem; + } + + .close-icon { + cursor: pointer; + margin-right: 20px; + padding: .4rem; + width: auto !important; + height: auto !important; + } + + .close-icon:hover { + background-color: #ECECED !important; + border-radius: 50%; + } + + .cancel-btn { + min-width: 101px; + height: 43px; + background: #ffffff; + border: 1px solid #b5b5b5; + border-radius: 30px; + opacity: 1; + } + + .confirm-btn { + min-width: 84px; + height: 43px; + background: #ffffff; + color: var(--primary-color); + border: 1px solid var(--primary-color); + border-radius: 30px; + opacity: 1; + } + + .confirm-btn:hover { + background-color: var(--primary-color); + color: #ffffff; + } +} diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts new file mode 100644 index 000000000..a554437cb --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts @@ -0,0 +1,66 @@ +import { Component, Inject } from '@angular/core'; +import { UntypedFormGroup } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Dmp, NewVersionDmpPersist } from '@app/core/model/dmp/dmp'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { BaseComponent } from '@common/base/base.component'; +import { TranslateService } from '@ngx-translate/core'; +import { takeUntil } from 'rxjs/operators'; +import { DmpNewVersionDialogEditorModel } from './dmp-new-version-dialog.editor.model'; +import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; + +@Component({ + selector: 'app-dmp-new-version-dialog', + templateUrl: './dmp-new-version-dialog.component.html', + styleUrls: ['./dmp-new-version-dialog.component.scss'] +}) +export class NewVersionDmpDialogComponent extends BaseComponent { + + dmp: Dmp; + editorModel: DmpNewVersionDialogEditorModel; + formGroup: UntypedFormGroup; + + constructor( + public dialogRef: MatDialogRef, + private dmpService: DmpService, + public dmpBlueprintService: DmpBlueprintService, + private uiNotificationService: UiNotificationService, + private language: TranslateService, + @Inject(MAT_DIALOG_DATA) public data: any + ) { + super(); + this.dmp = data.dmp; + } + + ngOnInit() { + this.editorModel = new DmpNewVersionDialogEditorModel().fromModel(this.data.dmp); + this.formGroup = this.editorModel.buildForm(); + } + + hasDescriptions() { + return this.dmp.descriptions.length > 0; + } + + close() { + this.dialogRef.close(null); + } + + cancel() { + this.dialogRef.close(null); + } + + confirm() { + if (!this.formGroup.valid) { return; } + const value: NewVersionDmpPersist = this.formGroup.value; + this.dmpService.newVersion(value).pipe(takeUntil(this._destroyed)).subscribe( + dmp => this.dialogRef.close(dmp), + error => this.onCallbackError(error) + ); + + } + + onCallbackError(error: any) { + this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); + } +} diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts new file mode 100644 index 000000000..6ca660cd1 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts @@ -0,0 +1,54 @@ +import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; +import { Dmp, NewVersionDmpPersist } from "@app/core/model/dmp/dmp"; +import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; +import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; +import { Validation, ValidationContext } from '@common/forms/validation/validation-context'; +import { Guid } from "@common/types/guid"; + +export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist { + id: Guid; + label: string; + description: String; + blueprintId: Guid; + descriptions: Guid[] = []; + + public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); + protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); + + constructor() { } + + public fromModel(item: Dmp): DmpNewVersionDialogEditorModel { + if (item) { + this.id = item.id; + this.label = item.label; + this.description = item.description; + this.blueprintId = item.blueprint.id; + if (item.descriptions) { this.descriptions = item.descriptions.map(x => x.id); } + } + return this; + } + + buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { + if (context == null) { context = this.createValidationContext(); } + + return this.formBuilder.group({ + id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], + label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], + description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], + blueprintId: [{ value: this.blueprintId, disabled: disabled }, context.getValidation('blueprintId').validators], + descriptions: [{ value: this.descriptions, disabled: disabled }, context.getValidation('descriptions').validators], + }); + } + + createValidationContext(): ValidationContext { + const baseContext: ValidationContext = new ValidationContext(); + const baseValidationArray: Validation[] = new Array(); + baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] }); + baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); + baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); + baseValidationArray.push({ key: 'blueprintId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'blueprintId')] }); + baseValidationArray.push({ key: 'descriptions', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptions')] }); + baseContext.validation = baseValidationArray; + return baseContext; + } +} diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.module.ts b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.module.ts new file mode 100644 index 000000000..71ff8cdd4 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; +import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { NewVersionDmpDialogComponent } from './dmp-new-version-dialog.component'; + +@NgModule({ + imports: [CommonUiModule, FormsModule, ReactiveFormsModule, AutoCompleteModule, RichTextEditorModule], + declarations: [NewVersionDmpDialogComponent], + exports: [NewVersionDmpDialogComponent] +}) +export class NewVersionDmpDialogModule { + constructor() { } +} diff --git a/dmp-frontend/src/app/ui/dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts index 962de5f91..43fc15a15 100644 --- a/dmp-frontend/src/app/ui/dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component.ts @@ -1,13 +1,13 @@ -import { Component, Inject } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; -import { TranslateService } from '@ngx-translate/core'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { takeUntil } from 'rxjs/operators'; -import { BaseComponent } from '@common/base/base.component'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { HttpClient } from '@angular/common/http'; +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { Router } from '@angular/router'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { MatomoService } from '@app/core/services/matomo/matomo-service'; +import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { BaseComponent } from '@common/base/base.component'; +import { TranslateService } from '@ngx-translate/core'; +import { takeUntil } from 'rxjs/operators'; import { DmpUploadDialogComponent } from '../upload-dialogue/dmp-upload-dialog.component'; @Component({ @@ -66,15 +66,16 @@ export class StartNewDmpDialogComponent extends BaseComponent { }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result && result.success) { - this.dmpService.uploadXml(result.fileList[0], result.dmpTitle, result.dmpBlueprints) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (complete) => { - this.onCallbackImportComplete(); - this.dialog.closeAll(); - }, - (error) => this.onCallbackImportFail(error.error) - ); + //TODO refactor + // this.dmpService.uploadXml(result.fileList[0], result.dmpTitle, result.dmpBlueprints) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // (complete) => { + // this.onCallbackImportComplete(); + // this.dialog.closeAll(); + // }, + // (error) => this.onCallbackImportFail(error.error) + // ); } }); } diff --git a/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts index 766fe87c1..284419940 100644 --- a/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/new/upload-dialogue/dmp-upload-dialog.component.ts @@ -1,15 +1,13 @@ import { HttpClient } from '@angular/common/http'; import { Component, Inject } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { DmpService } from '../../../../core/services/dmp/dmp.service'; @Component({ selector: 'dmp-upload-dialog', @@ -91,12 +89,14 @@ export class DmpUploadDialogComponent extends BaseComponent { this.dmpTitle = null; } - filterProfiles(value: string): Observable { - const request = new DataTableRequest(null, null, { fields: ['+label'] }); - const criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this._service.searchDmpBlueprints(request); + filterProfiles(value: string): Observable { + // TODO refactor + // const request = new DataTableRequest(null, null, { fields: ['+label'] }); + // const criteria = new DatasetProfileCriteria(); + // criteria.like = value; + // request.criteria = criteria; + // return this._service.searchDmpBlueprints(request); + return null; } hasFile(): boolean { diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index 7c7cb8584..febec2652 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -166,32 +166,11 @@

-
- -
+
-
@@ -225,4 +204,4 @@
-
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 3e91a2050..0d4a216e1 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -3,7 +3,7 @@ import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService @@ -15,17 +15,16 @@ import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration'; +import { DepositConfiguration } from '@app/core/model/deposit/deposit-configuration'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser, DmpUserRemovePersist } from '@app/core/model/dmp/dmp'; import { DmpReference } from '@app/core/model/dmp/dmp-reference'; -import { DoiModel } from '@app/core/model/doi/doi'; import { EntityDoi } from '@app/core/model/entity-doi/entity-doi'; -import { FileFormat } from '@app/core/model/file/file-format.model'; import { Reference } from '@app/core/model/reference/reference'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { DepositRepositoriesService } from '@app/core/services/deposit-repositories/deposit-repositories.service'; +import { DepositService } from '@app/core/services/deposit/deposit.service'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; +import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { ReferenceService } from '@app/core/services/reference/reference.service'; @@ -58,12 +57,11 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { textMessage: any; pastVersions: Dmp[]; //TODO: get these from the backend selectedModel: EntityDoi; - fileFormats: FileFormat[] = []; @ViewChild('doi') doi: ElementRef; - depositRepos: DepositConfigurationModel[] = []; + depositRepos: DepositConfiguration[] = []; descriptionStatusEnum = DescriptionStatus; dmpAccessTypeEnum = DmpAccessType; @@ -74,9 +72,9 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { constructor( private route: ActivatedRoute, private router: Router, - private dmpService: DmpServiceNew, + private dmpService: DmpService, private dmpBlueprintService: DmpBlueprintService, - private depositRepositoriesService: DepositRepositoriesService, + private depositRepositoriesService: DepositService, private translate: TranslateService, private authentication: AuthService, private dialog: MatDialog, @@ -88,7 +86,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { private matomoService: MatomoService, private fileUtils: FileUtils, public referenceService: ReferenceService, - public enumUtils: EnumUtils + public enumUtils: EnumUtils, + public fileTransformerService: FileTransformerService ) { super(); } @@ -156,7 +155,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { }); } }); - this.dmpService.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result); this.depositRepositoriesService.getAvailableRepos() .pipe(takeUntil(this._destroyed)) .subscribe( @@ -580,7 +578,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { this.dmp.entityDois.unshift(entityDoi); } - createDoiLink(doiModel: DoiModel): string { + // createDoiLink(doiModel: DoiModel): string { + createDoiLink(doiModel: any): string { //TODO: needs rewriting const repository = this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId); if (typeof repository !== "undefined") { @@ -716,6 +715,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { return [ nameof(x => x.id), nameof(x => x.label), + nameof(x => x.description), nameof(x => x.status), nameof(x => x.accessType), nameof(x => x.version), diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts index be48b699b..f94e89ffd 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts @@ -1,14 +1,12 @@ import { NgModule } from '@angular/core'; import { FormattingModule } from '@app/core/formatting.module'; import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; import { DmpDepositDropdown } from "@app/ui/dmp/editor/dmp-deposit-dropdown/dmp-deposit-dropdown.component"; import { DmpOverviewComponent } from '@app/ui/dmp/overview/dmp-overview.component'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; import { NgDialogAnimationService } from 'ng-dialog-animation'; -import { CloneDialogModule } from '../clone/clone-dialog/clone-dialog.module'; import { DmpOverviewRoutingModule } from './dmp-overview.routing'; @NgModule({ @@ -16,8 +14,6 @@ import { DmpOverviewRoutingModule } from './dmp-overview.routing'; CommonUiModule, CommonFormsModule, ConfirmationDialogModule, - CloneDialogModule, - ExportMethodDialogModule, FormattingModule, AutoCompleteModule, DmpOverviewRoutingModule diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.html b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.html deleted file mode 100644 index a7cd49185..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.html +++ /dev/null @@ -1,82 +0,0 @@ -
-
-

Welcome to ARGOS

-

Create, Link, Share Data Management Plans

-
-
-
-
-
-
-
-

{{'DASHBOARD.DATASETS' | translate}}

- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
-
- diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.scss b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.scss deleted file mode 100644 index c5763d039..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.scss +++ /dev/null @@ -1,78 +0,0 @@ -@import "node_modules/bootstrap/scss/functions"; -@import "node_modules/bootstrap/scss/variables"; -@import "node_modules/bootstrap/scss/mixins/_breakpoints"; - -@include media-breakpoint-down(sm) { - .lightblue-btn { - font-size: 12px; - } - ::ng-deep .mat-paginator-container { - height: auto !important; - } -} - -text-center { - text-align: center; -} - -.header-image { - background: url("/assets/images/new-dashboard-bg.png") no-repeat; - background-size: cover; - margin-top: 70px; - min-height: 15em; - position: relative; -} - -.header-text-container { - background: rgba(255, 255, 255, 0.7); - position: absolute; - bottom: 0px; - padding-left: 5em; - padding-right: 10em; - padding-top: 2em; - padding-bottom: 2em; -} - -.explore-dmp-content { - padding: 30px 15px; -} - -.card-desc { - min-height: 5vh; -} - -::ng-deep .mat-paginator { - margin-top: 1em; -} - -::ng-deep .mat-paginator-container { - flex-direction: row-reverse !important; - justify-content: space-between !important; - background-color: #f6f6f6; - height: 30px; - min-height: 30px !important; -} - -::ng-deep .mat-paginator-page-size { - height: 43px; -} - -::ng-deep .mat-icon-button { - height: 30px !important; - font-size: 12px !important; -} - -::ng-deep .mat-paginator-range-label { - margin: 15px 32px 0 24px !important; -} - -::ng-deep .mat-paginator-range-actions { - width: auto !important; - min-width: 55% !important; - min-height: 43px !important; - justify-content: space-between; -} - -::ng-deep .mat-paginator-navigation-previous { - margin-left: auto !important; -} diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts deleted file mode 100644 index 1a480f821..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatPaginator } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; -import { ActivatedRoute, Params, Router } from '@angular/router'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { ExploreDatasetCriteriaModel } from '@app/core/query/explore-dataset/explore-dataset-criteria'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; -// import { BreadcrumbItem } from '../misc/breadcrumb/definition/breadcrumb-item'; -// import { IBreadCrumbComponent } from '../misc/breadcrumb/definition/IBreadCrumbComponent'; - - -@Component({ - selector: 'app-explore-dataset-listing-component', - templateUrl: 'explore-dataset-listing.component.html', - styleUrls: ['./explore-dataset-listing.component.scss'], -}) -export class ExploreDatasetListingComponent extends BaseComponent implements OnInit { //IBreadCrumbComponent - - @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; - @ViewChild(MatSort, { static: false }) sort: MatSort; - - totalCount: number; - listingItems: DatasetListingModel[] = []; - exploreDatasetCriteriaModel: ExploreDatasetCriteriaModel; - // breadCrumbs: Observable; - dmpId: string; - dmpSearchEnabled = true; - titlePrefix: String; - - constructor( - private datasetService: DatasetService, - private dmpService: DmpService, - private router: Router, - private route: ActivatedRoute, - private language: TranslateService, - ) { - super(); - } - - ngOnInit() { - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe(async (params: Params) => { - const queryParams = this.route.snapshot.queryParams; - this.dmpId = queryParams['dmpId']; - if (this.dmpId != null) { - this.dmpSearchEnabled = false; - const dmp = await this.dmpService.getSinglePublic(this.dmpId).toPromise(); - - const fields: Array = []; - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, this._paginator.pageSize, { fields: fields }); - dmpDataTableRequest.criteria = new ExploreDatasetCriteriaModel(); - dmpDataTableRequest.criteria.dmpIds.push(this.dmpId); - - this.datasetService.getPublicPaged(dmpDataTableRequest).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.listingItems = result.data; - }); - - - } else { - this.refresh(); - } - }); - - // const breadCrumbs = []; - // breadCrumbs.push({ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), - // url: "/explore" - // }) - // this.breadCrumbs = observableOf(breadCrumbs); - } - - refresh(resetPages = false) { - if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10; - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array(); - if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this.exploreDatasetCriteriaModel || this.getDefaultCriteria(); - this.datasetService.getPublicPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.listingItems = result.data; - }); - } - - // rowClicked(dataset: DatasetListingModel) { - // this.router.navigate(['/datasets/publicEdit/' + dataset.id]); - // } - - onCriteriaChange(event: ExploreDatasetCriteriaModel) { - this.exploreDatasetCriteriaModel = event; - this._paginator.pageIndex = 0; - this.refresh(); - } - - getDefaultCriteria(): ExploreDatasetCriteriaModel { - const defaultCriteria = new ExploreDatasetCriteriaModel(); - // if (dmp != null) { - // defaultCriteria.dmpIds.push(dmp.id); - // } - return defaultCriteria; - } - - pageThisEvent(event) { - this.refresh(); - } -} diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset.module.ts b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset.module.ts deleted file mode 100644 index 86dfe4e41..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset.module.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { NgModule } from '@angular/core'; -import { FormattingModule } from '@app/core/formatting.module'; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { ExploreDatasetListingComponent } from '@app/ui/explore-dataset/explore-dataset-listing.component'; -import { ExploreDatasetRoutingModule } from '@app/ui/explore-dataset/explore-dataset.routing'; -import { ExploreDatasetFilterItemComponent } from '@app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component'; -import { ExploreDatasetFiltersComponent } from '@app/ui/explore-dataset/filters/explore-dataset-filters.component'; -import { ExploreDatasetListingItemComponent } from '@app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { DatasetOverviewModule } from '../dataset/overview/dataset-overview.module'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - AutoCompleteModule, - ExploreDatasetRoutingModule, - FormattingModule, - DatasetOverviewModule - ], - declarations: [ - ExploreDatasetListingComponent, - ExploreDatasetFiltersComponent, - ExploreDatasetFilterItemComponent, - ExploreDatasetListingItemComponent - ] -}) -export class ExploreDatasetModule { } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset.routing.ts b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset.routing.ts deleted file mode 100644 index f1d28185b..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset.routing.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { ExploreDatasetListingComponent } from './explore-dataset-listing.component'; -import { DatasetOverviewComponent } from '../dataset/overview/dataset-overview.component'; - -const routes: Routes = [ - { - path: '', - component: ExploreDatasetListingComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'overview/:publicId', - component: DatasetOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.EXPLORE-PLANS-OVERVIEW' - }, - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class ExploreDatasetRoutingModule { } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.html b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.html deleted file mode 100644 index 16495cc71..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
- - - -
- - - {{ - displayLabel(option) }} - cancel - - - -
- - -

{{ displayLabel(option) }}

-
-
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.scss b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.scss deleted file mode 100644 index dfc39d9c0..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.scss +++ /dev/null @@ -1,14 +0,0 @@ -.facet-option-item { - height: auto !important; - min-height: 48px; - padding: 0.5em; - .mat-list-item-content { - min-height: inherit; - } -} - -.data-expand-panel{ - max-height: 20em; - overflow-x: hidden; - overflow-y: auto; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.ts b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.ts deleted file mode 100644 index fddaa4b57..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filter-item/explore-dataset-filter-item.component.ts +++ /dev/null @@ -1,94 +0,0 @@ - -import { SelectionModel } from '@angular/cdk/collections'; -import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { FormControl } from '@angular/forms'; -import { MatListOption, MatSelectionList } from '@angular/material/list'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable, of as observableOf } from 'rxjs'; -import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; - - -@Component({ - selector: 'app-explore-dataset-filter-item-component', - templateUrl: './explore-dataset-filter-item.component.html', - styleUrls: ['./explore-dataset-filter-item.component.scss'] -}) -export class ExploreDatasetFilterItemComponent extends BaseComponent implements OnInit { - - @Input() - searchEnabled = false; - - @Input() - requestDelay = 200; - - @Input() - multipleSelect = true; - - @Input() - filterOptions: (value) => Observable; - - @Input() - options: Observable = observableOf([]); - - @Input() - displayTitleFunc: (value) => string; - - @Input() - displayValueFunc: (value) => string; - - @Output() - selectedChanged = new EventEmitter(); - - @Output() - optionRemoved = new EventEmitter(); - - optionSearchControl = new FormControl(''); - - private selectedOptions: any[] = []; - - @ViewChild('optionsList', { static: true }) selectionList: MatSelectionList; - - constructor() { super(); } - - ngOnInit(): void { - if (!this.multipleSelect) { this.selectionList.selectedOptions = new SelectionModel(this.multipleSelect); } - this.optionSearchControl.valueChanges.pipe(debounceTime(this.requestDelay), - distinctUntilChanged()) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { if (this.filterOptions) { this.options = this.filterOptions(x); } }); - } - - public selectionChanged(event: any) { - const eventValue = event.option.value; - if (event.option.selected) { this.selectedOptions.push(eventValue); } - if (!event.option.selected) { - const index = this.selectedOptions.map(x => this.displayValue(x)).indexOf(this.displayValue(eventValue)); - this.selectedOptions.splice(index, 1); - } - this.selectedChanged.emit(event); - } - - public removeOption(grant) { - const list = this.selectionList.selectedOptions.selected.map(x => x.value); - const indexOfGrant = list.indexOf(grant); - if (this.selectionList.selectedOptions.selected[indexOfGrant]) { - this.selectionList.selectedOptions.selected[indexOfGrant].selected = false; - this.selectionList.selectedOptions.selected.splice(indexOfGrant, 1); - } - this.selectedOptions.splice(this.selectedOptions.map(x => this.displayValue(x)).indexOf(this.displayValue(grant)), 1); - this.optionRemoved.emit(grant); - } - - public isOptionSelected(value) { - return this.selectedOptions.map(x => this.displayValue(x)).indexOf(this.displayValue(value)) !== -1; - } - - displayLabel(value) { - return this.displayTitleFunc ? this.displayTitleFunc(value) : value; - } - - displayValue(value) { - return this.displayValueFunc ? this.displayValueFunc(value) : value; - } - -} diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.html b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.html deleted file mode 100644 index 01769decb..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.html +++ /dev/null @@ -1,129 +0,0 @@ -
-
{{'CRITERIA.FILTERS'| translate}}
-
- - - - search - - - - -
-
{{ 'FACET-SEARCH.GRANT-STATUS.TITLE' | translate }}
- - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ANY' | translate }} - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE' | translate }} - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE' | translate }} - -
- -
-
{{'CRITERIA.DATA-SETS.RELATED-DMP' | translate}}
- - - - -
- -
-
{{ 'FACET-SEARCH.GRANT.TITLE' | translate }}
- - - - -
- -
-
{{ 'FACET-SEARCH.PROFILES.TITLE' | translate }}
- - - - -
- -
-
{{ 'FACET-SEARCH.ROLE.TITLE' | translate }}
- - {{ 'FACET-SEARCH.ROLE.ANY' | translate }} - {{ 'FACET-SEARCH.ROLE.OWNER' | translate }} - {{ 'FACET-SEARCH.ROLE.MEMBER' | translate }} - -
- -
-
{{ 'FACET-SEARCH.DMP-ORGANISATIONS.TITLE' | translate }}
- - - - -
-
-
- - - diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.scss b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.scss deleted file mode 100644 index e4fb0d02b..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.scss +++ /dev/null @@ -1,107 +0,0 @@ -.facet-search-component { - .mat-form-field { - width: 100%; - } - - .tags-chips { - padding: 0px; - } -} - -.search ::ng-deep.mat-form-field-infix { - margin-left: 1em; -} - -.category-title { - color: black; - // color: #089dbb; - margin-top: 8px; - margin-bottom: 12px; -} - -.import { - margin: 10px; - padding: 0px; -} - -.filters { - border: 1px solid #e4e4e4; - border-radius: 5px; -} - -.filters-title { - width: 90px; - // color: #089dbb; - color: var(--primary-color-2); - background-color: white; - padding: 0px 20px; - margin-top: -10px; - margin-left: 20px; - text-transform: uppercase; -} - -.style-icon { - color: #adadad; -} - -// ::ng-deep .mat-checkbox-inner-container { -// background: white; -// } - -// ::ng-deep .mat-focused .mat-form-field-label { -// color: var(--primary-color-3) !important; -// } - -// ::ng-deep.mat-form-field-underline { -// background-color: #adadad; -// } - -// ::ng-deep.mat-form-field-ripple { -// background-color: var(--primary-color-3) !important; -// } - -// ::ng-deep .mat-checkbox { -// background-color: #f6f6f6 !important; -// } - -::ng-deep .mat-checkbox .mat-checkbox-frame { - border: 1px solid #aaaaaa; -} - -::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, -.mat-checkbox-indeterminate.mat-accent .mat-checkbox-background, -.mat-accent .mat-pseudo-checkbox-checked, -.mat-accent .mat-pseudo-checkbox-indeterminate, -.mat-pseudo-checkbox-checked, -.mat-pseudo-checkbox-indeterminate { - background-color: var(--primary-color-3); -} - -::ng-deep .mat-ripple-element { - background-color: #2e74b649 !important; -} - -::ng-deep .mat-radio-container { - border-radius: 1em; - background: white; -} - -::ng-deep .mat-radio-button .mat-radio-outer-circle { - border: 1px solid #aaaaaa; -} - -::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle { - border-color: #777777; - // border-color: var(--primary-color-3); -} - -::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle { - color: #777777; - background-color: #777777; - // color: var(--primary-color-3); - // background-color: var(--primary-color-3); -} - -.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { - background-color: #2e74b649; -} diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts deleted file mode 100644 index a256286d0..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts +++ /dev/null @@ -1,366 +0,0 @@ - -import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { MatAccordion } from '@angular/material/expansion'; -import { ActivatedRoute } from '@angular/router'; -import { GrantStateType } from '@app/core/common/enum/grant-state-type'; -import { DataTableData } from '@app/core/model/data-table/data-table-data'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { GrantListingModel } from '@app/core/model/grant/grant-listing'; -import { OrganizationModel } from '@app/core/model/organisation/organization'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { ExploreDatasetCriteriaModel } from '@app/core/query/explore-dataset/explore-dataset-criteria'; -import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { OrganisationCriteria } from '@app/core/query/organisation/organisation-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { OrganisationService } from '@app/core/services/organisation/organisation.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { map } from 'rxjs/operators'; - - -@Component({ - selector: 'app-explore-dataset-filters-component', - templateUrl: './explore-dataset-filters.component.html', - styleUrls: ['./explore-dataset-filters.component.scss'] -}) -export class ExploreDatasetFiltersComponent extends BaseComponent implements OnInit, AfterViewInit { - - @Input() facetCriteria = new ExploreDatasetCriteriaModel(); - @Output() facetCriteriaChange = new EventEmitter(); - public filteringTagsAsync = false; - public filteredTags: ExternalSourceItemModel[]; - GrantStateType = GrantStateType; - grants: Observable; - profiles: Observable; - dmpOrganisations: Observable; - dmpIds: Observable>; - grantOptions: Observable; - grantStateOptions: Observable; - filteringOrganisationsAsync = false; - @ViewChild('facetAccordion', { static: false }) accordion: MatAccordion; - - displayGrantStateValue = (option) => option['value']; - displayGrantStateLabel = (option) => option['label']; - - displayGrantValue = (option) => option['id']; - displayGrantLabel = (option) => option['label']; - - displayProfileValue = (option) => option['id']; - displayProfileLabel = (option) => option['label']; - - displayDmpOrganisationsValue = (option) => option['id']; - displayDmpOrganisationsLabel = (option) => option['name']; - - tagsAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - }; - - dmpAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: (x, excluded) => this.filterDmps(x).pipe(map(x => x.data)), - initialItems: (extraData) => this.filterDmps('').pipe(map(x => x.data)), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - grantAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterGrant.bind(this), - initialItems: (excludedItems: any[]) => - this.filterGrant('').pipe( - map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - } - - profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterProfile.bind(this), - initialItems: (excludedItems: any[]) => - this.filterProfile('').pipe( - map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - organizationAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterOrganisation.bind(this), - initialItems: (excludedItems: any[]) => - this.getOrganisations().pipe( - map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - } - - constructor( - public activatedRoute: ActivatedRoute, - private authentication: AuthService, - public grantService: GrantService, - public dmpService: DmpService, - public organisationService: OrganisationService, - public languageService: TranslateService, - public datasetProfileService: DatasetService, - public externalSourcesService: ExternalSourcesService, - ) { super(); } - - ngOnInit() { - setTimeout(() => { - this.grantStateOptions = observableOf( - [ - { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE'), value: GrantStateType.Finished }, - { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE'), value: GrantStateType.OnGoing }, - ]); - }); - // this.profiles = this.datasetProfileService.getDatasetProfiles(); - this.dmpOrganisations = this.externalSourcesService.searchDMPOrganizations(''); - } - - ngAfterViewInit(): void { - // this.accordion.openAll(); - } - - public grantStatusChanged(event) { - this.facetCriteria.grantStatus = event.value; - if (event.value === 'null') { - this.facetCriteria.grantStatus = null; - this.grants = observableOf([]); - this.facetCriteria.grants = []; - } - // if (event.option.selected) { - // if (event.source.checked) { - else { - // const grantCriteria = new GrantCriteria(); - // grantCriteria.grantStateType = this.facetCriteria.grantStatus; - //grantCriteria['length'] = 10; - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new GrantCriteria(); - dataTableRequest.criteria.grantStateType = this.facetCriteria.grantStatus; - dataTableRequest.criteria['length'] = 10; - - this.grants = this.grantService.getPublicPaged(dataTableRequest).pipe(map(x => x.data)); - this.facetCriteria.grants = []; - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - public grantChanged(event: any) { - const eventValue = event.option.value.id; - if (event.option.selected) { this.facetCriteria.grants.push(eventValue); } - if (!event.option.selected) { - const index = this.facetCriteria.grants.indexOf(eventValue); - this.facetCriteria.grants.splice(index, 1); - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - removeGrant(grant) { - this.facetCriteria.grants.splice(this.facetCriteria.grants.indexOf(grant), 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - public profileChanged(event: any) { - const eventValue = event.option.value.id; - if (event.option.selected) { - this.facetCriteria.datasetProfile.push(eventValue); - } - if (!event.option.selected) { - const index = this.facetCriteria.datasetProfile.indexOf(eventValue); - this.facetCriteria.datasetProfile.splice(index, 1); - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - // getProfiles() { - // return this.datasetProfileService.getDatasetProfiles(); - // } - - removeProfile(profile) { - this.facetCriteria.datasetProfile.splice(this.facetCriteria.datasetProfile.indexOf(profile), 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - getOrganisations() { - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = ''; - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - public roleChanged(event: any) { - this.facetCriteria.role = event.value; - if (event.value === 'null') { - this.facetCriteria.role = null; - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - public dmpOrganisationChanged(event: any) { - const eventValue = event.option.value.id; - if (event.option.selected) { this.facetCriteria.dmpOrganisations.push(eventValue); } - if (!event.option.selected) { - const index = this.facetCriteria.dmpOrganisations.indexOf(eventValue); - this.facetCriteria.dmpOrganisations.splice(index, 1); - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - public grantSearch(value: string): Observable { - - const grantCriteria = new GrantCriteria(); - grantCriteria.grantStateType = this.facetCriteria.grantStatus; - grantCriteria['length'] = 10; - grantCriteria.like = value; - - const fields: Array = new Array(); - fields.push('asc'); - - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = grantCriteria; - //const dataTableRequest: RequestItem = { criteria: grantCriteria }; - //return this.grantService.getPaged(dataTableRequest, "autocomplete").map(x => x.data); - return this.grantService.getPublicPaged(dataTableRequest).pipe(map(x => x.data)); - } - - public dmpOrganisationSearch(value: string): Observable { - return this.externalSourcesService.searchDMPOrganizations(value); - } - - removeOrganisation(organisation) { - this.facetCriteria.dmpOrganisations.splice(this.facetCriteria.dmpOrganisations.indexOf(organisation), 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - // public profileSearch(value: string) { - // return this.datasetProfileService.getDatasetProfiles(); - // } - - public controlModified() { - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onGrantOptionSelected(item: GrantListingModel) { - this.facetCriteria.grants.push(item.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onGrantOptionRemoved(item: GrantListingModel) { - const index = this.facetCriteria.grants.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.grants.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - onDmpOptionSelected(item: DmpListingModel) { - this.facetCriteria.dmpIds.push(item.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onDmpOptionRemoved(item: DmpListingModel) { - const index = this.facetCriteria.dmpIds.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.dmpIds.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - onProfileOptionSelected(item: DatasetProfileModel) { - this.facetCriteria.datasetProfile.push(item.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onProfileOptionRemoved(item: DatasetProfileModel) { - const index = this.facetCriteria.datasetProfile.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.datasetProfile.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - onOrganizationOptionSelected(item: OrganizationModel) { - this.facetCriteria.dmpOrganisations.push(item.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onOrganizationOptionRemoved(item: OrganizationModel) { - const index = this.facetCriteria.dmpOrganisations.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.dmpOrganisations.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - filterDmps(value: string): Observable> { - const fields: Array = new Array(); - fields.push('-finalizedAt'); - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new ExploreDmpCriteriaModel(); - dmpDataTableRequest.criteria.like = value; - return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete") - } - - filterTags(value: string): Observable { - this.filteredTags = undefined; - this.filteringTagsAsync = true; - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - // .subscribe(items => { - // this.filteredTags = items; - // this.filteringTagsAsync = false; - // }); - } - - filterGrant(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const grantRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - return this.grantService.getPublicPaged(grantRequestItem).pipe(map(x => x.data)); - } - - filterProfile(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const profileRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - profileRequestItem.criteria = new DatasetProfileCriteria(); - profileRequestItem.criteria.like = query; - - return this.datasetProfileService.getDatasetProfiles(profileRequestItem); - // this.dmpService.getPublicPaged(profileRequestItem, "listing").pipe(map(x => x.data)); - } - - filterOrganisation(value: string) { - this.filteringOrganisationsAsync = true; - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = value; - - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } -} diff --git a/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.html b/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.html deleted file mode 100644 index b3c332065..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.html +++ /dev/null @@ -1,72 +0,0 @@ - - diff --git a/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.scss b/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.scss deleted file mode 100644 index 99897de43..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.scss +++ /dev/null @@ -1,99 +0,0 @@ -.gray-container { - letter-spacing: 5px; - color: #aaaaaa; -} - -.container-header { - display: flex; - align-items: baseline; - margin-top: 0px; - text-transform: uppercase; -} - -.container-header p { - letter-spacing: 5px; - color: #aaaaaa; - padding-top: 10px; - margin-bottom: 0px; -} - -h4 { - display: inline; - padding-left: 1em; - color: #333333; -} - -.title h4 { - padding-left: 30px; - line-height: 2em; -} - -.about-item { - display: flex; - flex-wrap: wrap; -} - -.about-item .length { - color: var(--primary-color-3); - // color: #089dbb; -} - -.about-item .title { - margin: 2px 10px; -} - -.about-item p { - margin-left: auto; - margin-bottom: 0px; - padding-top: 7px; - color: #aaaaaa; -} - -p { - color: #333333; -} - -.finalized-bookmark { - color: #08bd63; -} - -// .explore-dataset-info { -// background-color: #f6f6f6; -// padding: 8px 15px; -// } - -// .explore-dataset-info p { -// margin-bottom: 0px; -// color: rgb(37, 35, 140); -// font-weight: 600; -// } - -// .template-name { -// padding-left: 0px; -// border: 1px solid rgb(218, 227, 243); -// color: rgb(43, 104, 209); -// background-color: rgb(236, 241, 249); -// border-radius: 10em; -// justify-content: center; -// text-transform: uppercase; -// display: flex; -// width: 25em; -// height: 1.8em; -// margin-top: 15px; -// font-size: 13px; -// font-weight: 500; -// } - -// .draft-bookmark { -// color: #e7e6e6; -// display: inline; -// } - -// .finalized-bookmark { -// color: #92d050; -// display: inline; -// } - -// h4 { -// display: inline; -// } diff --git a/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.ts b/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.ts deleted file mode 100644 index 83ac3f9ad..000000000 --- a/dmp-frontend/src/app/ui/explore-dataset/listing-item/explore-dataset-listing-item.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing'; -import { DatasetStatus } from '../../../core/common/enum/dataset-status'; - -@Component({ - selector: 'app-explore-dataset-listing-item-component', - templateUrl: './explore-dataset-listing-item.component.html', - styleUrls: ['./explore-dataset-listing-item.component.scss'] -}) -export class ExploreDatasetListingItemComponent implements OnInit { - - @Input() dataset: DatasetListingModel; - @Input() showDivider: boolean = true; - @Output() onClick: EventEmitter = new EventEmitter(); - - isDraft: boolean; - - constructor() { } - - ngOnInit() { - if (this.dataset.status == DatasetStatus.Draft) { this.isDraft = true } - else { this.isDraft = false } - } - - // itemClicked() { - // this.onClick.emit(this.dataset); - // } - -} diff --git a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.html b/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.html deleted file mode 100644 index b0406d2ce..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
- - - -
- - - {{ - displayLabel(option) }} - cancel - - - -
- - -

{{ displayLabel(option) }}

-
-
-
diff --git a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.scss b/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.scss deleted file mode 100644 index b4d929724..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.scss +++ /dev/null @@ -1,14 +0,0 @@ -.facet-option-item { - height: auto !important; - min-height: 48px; - padding: 0.5em; - .mat-list-item-content { - min-height: inherit; - } -} - -.data-expand-panel{ - max-height: 20em; - overflow-x: hidden; - overflow-y: auto; -} diff --git a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.ts b/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.ts deleted file mode 100644 index f18a44f34..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component.ts +++ /dev/null @@ -1,84 +0,0 @@ - -import { SelectionModel } from '@angular/cdk/collections'; -import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { FormControl } from '@angular/forms'; -import { MatListOption, MatSelectionList } from '@angular/material/list'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable, of as observableOf } from 'rxjs'; -import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; - - -@Component({ - selector: 'app-explore-dmp-filter-item-component', - templateUrl: './explore-dmp-filter-item.component.html', - styleUrls: ['./explore-dmp-filter-item.component.scss'] -}) -export class ExploreDmpFilterItemComponent extends BaseComponent implements OnInit { - @Input() - searchEnabled = false; - @Input() - requestDelay = 200; - @Input() - multipleSelect = true; - @Input() - filterOptions: (value) => Observable; - @Input() - options: Observable = observableOf([]); - @Input() - displayTitleFunc: (value) => string; - @Input() - displayValueFunc: (value) => string; - @Output() - selectedChanged = new EventEmitter(); - @Output() - optionRemoved = new EventEmitter(); - - - optionSearchControl = new FormControl(''); - public selectedOptions: any[] = []; - - @ViewChild('optionsList', { static: true }) selectionList: MatSelectionList; - - constructor() { super(); } - - ngOnInit(): void { - if (!this.multipleSelect) { this.selectionList.selectedOptions = new SelectionModel(this.multipleSelect); } - this.optionSearchControl.valueChanges.pipe(debounceTime(this.requestDelay), - distinctUntilChanged()) - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { if (this.filterOptions) { this.options = this.filterOptions(x); } }); - } - - public selectionChanged(event: any) { - const eventValue = event.option.value; - if (event.option.selected) { this.selectedOptions.push(eventValue); } - if (!event.option.selected) { - const index = this.selectedOptions.map(x => this.displayValue(x)).indexOf(this.displayValue(eventValue)); - this.selectedOptions.splice(index, 1); - } - this.selectedChanged.emit(event); - } - - public removeOption(grant) { - const list = this.selectionList.selectedOptions.selected.map(x => x.value); - const indexOfGrant = list.indexOf(grant); - if (this.selectionList.selectedOptions.selected[indexOfGrant]) { - this.selectionList.selectedOptions.selected[indexOfGrant].selected = false; - this.selectionList.selectedOptions.selected.splice(indexOfGrant, 1); - } - this.selectedOptions.splice(this.selectedOptions.map(x => this.displayValue(x)).indexOf(this.displayValue(grant)), 1); - this.optionRemoved.emit(grant); - } - - public isOptionSelected(value) { - return this.selectedOptions.map(x => this.displayValue(x)).indexOf(this.displayValue(value)) !== -1; - } - - displayLabel(value) { - return this.displayTitleFunc ? this.displayTitleFunc(value) : value; - } - - displayValue(value) { - return this.displayValueFunc ? this.displayValueFunc(value) : value; - } -} diff --git a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.html b/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.html deleted file mode 100644 index d7a2e6ce6..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.html +++ /dev/null @@ -1,122 +0,0 @@ -
-
{{'CRITERIA.FILTERS'| translate}}
-
- - - - search - - -
-
{{ 'FACET-SEARCH.GRANT-STATUS.TITLE' | translate }}
- - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ANY' | translate }} - - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE' | translate }} - - - {{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE' | translate }} - - -
- -
-
{{ 'FACET-SEARCH.GRANT.TITLE' | translate }}
- - - - -
- -
-
{{ 'FACET-SEARCH.PROFILES.TITLE' | translate }}
- - - - -
- -
-
{{ 'FACET-SEARCH.ROLE.TITLE' | translate }}
- - - {{ 'FACET-SEARCH.ROLE.ANY' | translate }} - - - {{ 'FACET-SEARCH.ROLE.OWNER' | translate }} - - - {{ 'FACET-SEARCH.ROLE.MEMBER' | translate }} - - -
- -
-
{{ 'FACET-SEARCH.DMP-ORGANISATIONS.TITLE' | translate }}
- - - - -
-
-
- - - diff --git a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.scss b/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.scss deleted file mode 100644 index f42ffd3fb..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.scss +++ /dev/null @@ -1,107 +0,0 @@ -.facet-search-component { - .mat-form-field { - width: 100%; - } - - .tags-chips { - padding: 0px; - } -} - -.search ::ng-deep.mat-form-field-infix { - margin-left: 1em; -} - -.category-title { - color: black; - // color: #089dbb; - margin-top: 8px; - margin-bottom: 12px; -} - -.import { - margin: 10px; - padding: 0px; -} - -.filters { - border: 1px solid #e4e4e4; - border-radius: 5px; -} - -.filters-title { - width: 93px; - // color: #089dbb; - color: var(--primary-color-2); - background-color: white; - padding: 0px 20px; - margin-top: -10px; - margin-left: 20px; - text-transform: uppercase; -} - -.style-icon { - color: #adadad; -} - -// ::ng-deep .mat-checkbox-inner-container { -// background: white; -// } - -// ::ng-deep .mat-focused .mat-form-field-label { -// color: var(--primary-color-3) !important; -// } - -// ::ng-deep.mat-form-field-underline { -// background-color: #adadad; -// } - -// ::ng-deep.mat-form-field-ripple { -// background-color: var(--primary-color-3) !important; -// } - -// ::ng-deep .mat-checkbox { -// background-color: #f6f6f6 !important; -// } - -::ng-deep .mat-checkbox .mat-checkbox-frame { - border: 1px solid #aaaaaa; -} - -::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, -.mat-checkbox-indeterminate.mat-accent .mat-checkbox-background, -.mat-accent .mat-pseudo-checkbox-checked, -.mat-accent .mat-pseudo-checkbox-indeterminate, -.mat-pseudo-checkbox-checked, -.mat-pseudo-checkbox-indeterminate { - background-color: var(--primary-color-3); -} - -::ng-deep .mat-ripple-element { - background-color: #2e74b649 !important; -} - -::ng-deep .mat-radio-container { - border-radius: 1em; - background: white; -} - -::ng-deep .mat-radio-button .mat-radio-outer-circle { - border: 1px solid #aaaaaa; -} - -::ng-deep .mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle { - border-color: #777777; - // border-color: var(--primary-color-3); -} - -::ng-deep .mat-radio-button.mat-accent .mat-radio-inner-circle { - color: #777777; - background-color: #777777; - // color: var(--primary-color-3); - // background-color: var(--primary-color-3); -} - -.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element { - background-color: #2e74b649; -} diff --git a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.ts b/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.ts deleted file mode 100644 index 8ee9d6d85..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component.ts +++ /dev/null @@ -1,347 +0,0 @@ - -import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from "@angular/core"; -import { MatAccordion } from "@angular/material/expansion"; -import { ActivatedRoute } from "@angular/router"; -import { GrantStateType } from '@app/core/common/enum/grant-state-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; -import { GrantListingModel } from '@app/core/model/grant/grant-listing'; -import { OrganizationModel } from '@app/core/model/organisation/organization'; -import { DatasetProfileCriteria } from '@app/core/query/dataset-profile/dataset-profile-criteria'; -import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { OrganisationCriteria } from '@app/core/query/organisation/organisation-criteria'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { OrganisationService } from '@app/core/services/organisation/organisation.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { BaseCriteriaComponent } from '@app/ui/misc/criteria/base-criteria.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { TranslateService } from "@ngx-translate/core"; -import { Observable, of as observableOf } from 'rxjs'; -import { map } from 'rxjs/operators'; - - -@Component({ - selector: 'app-explore-dmp-filters-component', - templateUrl: './explore-dmp-filters.component.html', - styleUrls: ['./explore-dmp-filters.component.scss'] -}) -export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements OnInit, AfterViewInit { - - @Input() facetCriteria = new ExploreDmpCriteriaModel(); - @Output() facetCriteriaChange = new EventEmitter(); - @Input() displayTitleFunc: (value) => string; - GrantStateType = GrantStateType; - grants: Observable; - profiles: Observable; - dmpOrganisations: Observable; - grantOptions: Observable; - grantStateOptions: Observable; - filteringOrganisationsAsync = false; - filteredOrganisations: OrganizationModel[]; - status: GrantStateType; - IsChecked: boolean; - IsIndeterminate: boolean; - LabelAlign: string; - IsDisabled: boolean; - Active: string; - Inactive: string; - - @ViewChild('facetAccordion', { static: false }) accordion: MatAccordion; - - displayGrantStateValue = (option) => option['value']; - displayGrantStateLabel = (option) => option['label']; - - displayGrantValue = (option) => option['id']; - displayGrantLabel = (option) => option['label']; - - displayProfileValue = (option) => option['id']; - displayProfileLabel = (option) => option['label']; - - displayDmpOrganisationsValue = (option) => option['id']; - displayDmpOrganisationsLabel = (option) => option['name']; - - profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterProfile.bind(this), - initialItems: (excludedItems: any[]) => - this.filterProfile('').pipe( - map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - organizationAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterOrganisation.bind(this), - initialItems: (excludedItems: any[]) => - this.getOrganisations().pipe( - map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['name'], - titleFn: (item) => item['name'] - } - - grantAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - filterFn: this.filterGrant.bind(this), - initialItems: (excludedItems: any[]) => - this.filterGrant('').pipe( - map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - } - - constructor( - public activatedRoute: ActivatedRoute, - public languageService: TranslateService, - public grantService: GrantService, - private authentication: AuthService, - public datasetProfileService: DatasetService, - public organisationService: OrganisationService, - public externalSourcesService: ExternalSourcesService, - private dmpService: DmpService - ) { - super(new ValidationErrorModel()); - this.IsChecked = false; - this.IsIndeterminate = false; - this.LabelAlign = 'after'; - this.IsDisabled = false; - this.Active = "0"; - this.Inactive = "1"; - } - - ngOnInit() { - setTimeout(x => { - this.grantStateOptions = observableOf( - [ - { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE'), value: GrantStateType.Finished }, - { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE'), value: GrantStateType.OnGoing }, - ]); - }); - //this.profiles = this.datasetProfileService.getDatasetProfiles(); - const fields: Array = new Array(); - fields.push('asc'); - this.dmpOrganisations = this.organisationService.searchPublicOrganisations(new DataTableRequest(0, null, { fields: fields })).pipe(map(x => x.data)); - } - - ngAfterViewInit(): void { - // this.accordion.openAll(); - } - - OnChange($event) { - // console.log($event); - } - - OnIndeterminateChange($event) { - // console.log($event); - } - - controlModified() { - this.facetCriteriaChange.emit(this.facetCriteria); - } - - grantSearch(value: string): Observable { - const grantCriteria = new GrantCriteria(); - grantCriteria.grantStateType = this.facetCriteria.grantStatus; - grantCriteria['length'] = 10; - grantCriteria.like = value; - - const fields: Array = new Array(); - fields.push('asc'); - - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = grantCriteria; - return this.grantService.getPublicPaged(dataTableRequest).pipe(map(x => x.data)); - } - - grantStatusChanged(event) { - this.facetCriteria.grantStatus = event.value; - // this.facetCriteria.grantStatus = +event.source.ariaLabel; // For checkboxes - // this.facetCriteria.grantStatus = event.option.value.value; // For - // if (!event.source.checked) { - if (event.value === 'null') { - this.facetCriteria.grantStatus = null; - this.grants = observableOf([]); - this.facetCriteria.grants = []; - } - // if (event.checked) { - // if (event.option.selected) { - // if (event.source.checked) { - else { - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new GrantCriteria(); - dataTableRequest.criteria.grantStateType = this.facetCriteria.grantStatus; - dataTableRequest.criteria['length'] = 10; - - this.grants = this.grantService.getPublicPaged(dataTableRequest).pipe(map(x => x.data)); - this.facetCriteria.grants = []; - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - grantChanged(event: any) { - const eventValue = event.option.value.id; - if (event.option.selected) { this.facetCriteria.grants.push(eventValue); } - if (!event.option.selected) { - const index = this.facetCriteria.grants.indexOf(eventValue); - this.facetCriteria.grants.splice(index, 1); - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - removeGrant(grant) { - this.facetCriteria.grants.splice(this.facetCriteria.grants.indexOf(grant), 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onProfileOptionSelected(items: DatasetProfileModel) { - //this.facetCriteria.datasetProfile.splice(0); - this.facetCriteria.datasetProfile.push(items.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onProfileOptionRemoved(item: DatasetProfileModel) { - const index = this.facetCriteria.datasetProfile.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.datasetProfile.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - profileChanged(event: any) { - const eventValue = event.option.value.id; - if (event.option.selected) { - this.facetCriteria.datasetProfile.push(eventValue); - } - if (!event.option.selected) { - const index = this.facetCriteria.datasetProfile.indexOf(eventValue); - this.facetCriteria.datasetProfile.splice(index, 1); - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - removeProfile(profile) { - this.facetCriteria.datasetProfile.splice(this.facetCriteria.datasetProfile.indexOf(profile), 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onOrganizationOptionSelected(item: OrganizationModel) { - this.facetCriteria.dmpOrganisations.push(item.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onOrganizationOptionRemoved(item: OrganizationModel) { - const index = this.facetCriteria.dmpOrganisations.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.dmpOrganisations.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - onGrantOptionSelected(item: GrantListingModel) { - this.facetCriteria.grants.push(item.id); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - onGrantOptionRemoved(item: GrantListingModel) { - const index = this.facetCriteria.grants.indexOf(item.id); - if (index >= 0) { - this.facetCriteria.grants.splice(index, 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - } - - public roleChanged(event: any) { - this.facetCriteria.role = event.value; - if (event.value === 'null') { - this.facetCriteria.role = null; - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - dmpOrganisationChanged(event: any) { - const eventValue = event.option.value.id; - if (event.option.selected) { this.facetCriteria.dmpOrganisations.push(eventValue); } - if (!event.option.selected) { - const index = this.facetCriteria.dmpOrganisations.indexOf(eventValue); - this.facetCriteria.dmpOrganisations.splice(index, 1); - } - this.facetCriteriaChange.emit(this.facetCriteria); - } - - // profileSearch(value: string) { - // return this.datasetProfileService.getDatasetProfiles(); - // } - - dmpOrganisationSearch(value: string): Observable { - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = value; - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - removeOrganisation(organisation) { - this.facetCriteria.dmpOrganisations.splice(this.facetCriteria.dmpOrganisations.indexOf(organisation), 1); - this.facetCriteriaChange.emit(this.facetCriteria); - } - - // getProfiles() { - // return this.datasetProfileService.getDatasetProfiles(); - // } - - getOrganisations() { - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = ''; - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - filterGrant(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const grantRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - return this.grantService.getPublicPaged(grantRequestItem).pipe(map(x => x.data)); - } - - filterProfile(query: string) { - const fields: Array = new Array(); - fields.push('asc'); - const profileRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - profileRequestItem.criteria = new DatasetProfileCriteria(); - profileRequestItem.criteria.like = query; - - return this.datasetProfileService.getDatasetProfiles(profileRequestItem); - } - - filterOrganisation(value: string) { - this.filteringOrganisationsAsync = true; - const fields: Array = new Array(); - fields.push('asc'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dataTableRequest.criteria = new OrganisationCriteria(); - dataTableRequest.criteria.labelLike = value; - - return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data)); - } - - displayLabel(value) { - return this.displayTitleFunc ? this.displayTitleFunc(value) : value; - } - - isOptionSelected(profile: any) { - return this.formGroup.value.map(x => x.id).indexOf(profile.id) !== -1; - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } -} diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html deleted file mode 100644 index 1652e34fe..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
-

{{ 'ABOUT.WELCOME' | translate }}

-

{{ 'ABOUT.WELCOME-MESSAGE' | translate }}

-
-
-
-
-
-
-
-

{{'DMP-LISTING.TITLE' | translate}}

-
- - {{'DMP-LISTING.VIEW-ALL-VERSIONS' | translate}} - - - {{this.groupLabel}} - -
-
-
-
-
-
- - -
-
-
- -
- -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss deleted file mode 100644 index 79bfb137b..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss +++ /dev/null @@ -1,86 +0,0 @@ -@import "node_modules/bootstrap/scss/functions"; -@import "node_modules/bootstrap/scss/variables"; -@import "node_modules/bootstrap/scss/mixins/_breakpoints"; - -@include media-breakpoint-down(sm) { - .lightblue-btn { - font-size: 12px; - } - ::ng-deep .mat-paginator-container { - height: auto !important; - } -} - -text-center { - text-align: center; -} - -.card-desc { - min-height: 5vh; -} - -.header-image { - background: url("/assets/images/new-dashboard-bg.png") no-repeat; - background-size: cover; - margin-top: 70px; - min-height: 15em; - position: relative; -} - -.header-text-container { - background: rgba(255, 255, 255, 0.7); - position: absolute; - bottom: 0px; - padding-left: 5em; - padding-right: 10em; - padding-top: 2em; - padding-bottom: 2em; -} - -.explore-dmp-content { - padding: 30px 15px; -} - -::ng-deep .mat-paginator { - margin-top: 1em; -} - -::ng-deep .mat-paginator-container { - flex-direction: row-reverse !important; - justify-content: space-between !important; - background-color: #f6f6f6; - height: 30px; - min-height: 30px !important; -} - -::ng-deep .mat-paginator-page-size { - height: 43px; -} - -::ng-deep .mat-icon-button { - height: 30px !important; - font-size: 12px !important; -} - -::ng-deep .mat-paginator-range-label { - margin: 15px 32px 0 24px !important; -} - -::ng-deep .mat-paginator-range-actions { - width: auto !important; - min-width: 55% !important; - min-height: 43px !important; - justify-content: space-between; -} - -::ng-deep .mat-paginator-navigation-previous { - margin-left: auto !important; -} - -.all-versions { - color: #999999 !important; -} - -.dmp-label { - color: #089dbb !important; -} diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts deleted file mode 100644 index 360e6abde..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts +++ /dev/null @@ -1,198 +0,0 @@ - -import { Component, OnInit, ViewChild } from "@angular/core"; -import { MatPaginator } from "@angular/material/paginator"; -import { MatSort } from "@angular/material/sort"; -import { ActivatedRoute, Router } from "@angular/router"; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; -// import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-explore-dmp-listing-component', - templateUrl: 'explore-dmp-listing.component.html', - styleUrls: ['./explore-dmp-listing.component.scss'], -}) -export class ExploreDmpListingComponent extends BaseComponent implements OnInit { //IBreadCrumbComponent - - @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; - sort = new MatSort(); - - exploreDmpCriteriaModel: ExploreDmpCriteriaModel = new ExploreDmpCriteriaModel(); - titlePrefix: string; - totalCount: number; - listingItems: DmpListingModel[] = []; - // breadCrumbs: Observable; - linkToDmpId: string; - groupId: string; - allVersions: boolean = false; - groupLabel: string; - - constructor( - private dmpService: DmpService, - private router: Router, - private route: ActivatedRoute, - private language: TranslateService, - ) { - super(); - this.sort.direction = 'desc'; - this.sort.active = "publishedAt"; - } - - ngOnInit() { - this.route.params - .pipe(takeUntil(this._destroyed)) - .subscribe(params => { - if (params['groupId']) { - this.groupId = params['groupId']; - this.exploreDmpCriteriaModel.groupIds.push(this.groupId); - this.exploreDmpCriteriaModel.allVersions = true; - this.allVersions = true; - this.route.queryParams - .pipe(takeUntil(this._destroyed)) - .subscribe(queryParams => { - if (queryParams["groupLabel"]) { - this.groupLabel = queryParams["groupLabel"]; - } - }) - } - - this.refresh(); - // const breadCrumbs = []; - // breadCrumbs.push({ - // parentComponentName: null, - // label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), - // url: "/explore-plans" - // }) - // this.breadCrumbs = observableOf(breadCrumbs); - }) - } - - refresh() { - if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10; - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array(); - if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this.exploreDmpCriteriaModel || this.getDefaultCriteria(); - this.dmpService.getPublicPaged(request, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - this.listingItems = result.data; - }); - } - - - getDefaultCriteria(): ExploreDmpCriteriaModel { - const defaultCriteria = new ExploreDmpCriteriaModel(); - return defaultCriteria; - } - - onCriteriaChange(event: ExploreDmpCriteriaModel) { - this.exploreDmpCriteriaModel = event; - if (this.allVersions == true) this.exploreDmpCriteriaModel.allVersions = this.allVersions; - if (this.groupId) this.exploreDmpCriteriaModel.groupIds.push(this.groupId); - this._paginator.pageIndex = 0; - this.refresh(); - } - - pageThisEvent(event) { - this.refresh(); - } - - // rowClicked(dmp: DmpListingModel) { - // this.router.navigate(['overview', dmp.id], { relativeTo: this.route }); - // } - - // @ViewChild(MatPaginator) _paginator: MatPaginator; - // @ViewChild(MatSort) sort: MatSort; - // criteria: ExploreDmpCriteriaModel = new ExploreDmpCriteriaModel(); - - // dataSource: DmpDataSource | null; - // displayedColumns: String[] = ['name', 'grant', 'organisations', 'created']; - // pageEvent: PageEvent; - // titlePrefix: String; - // dmpId: string; - - // constructor( - // public dmpService: DmpService, - // private router: Router, - // private languageService: TranslateService, - // public snackBar: MatSnackBar, - // public route: ActivatedRoute - // ) { - // super(); - // } - - // ngOnInit() { - // this.refresh(); - // } - - // rowClick(rowId: String) { - // this.router.navigate(['/plans/publicEdit/' + rowId]); - // } - - // refresh() { - // this.dataSource = new DmpDataSource(this.dmpService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); - // } - - // getDefaultCriteria(dmpId: String): DmpCriteria { - // const defaultCriteria = new DmpCriteria(); - // return defaultCriteria; - // } - - // onCriteriaChange(event: ExploreDmpCriteriaModel) { - // //console.log(event) - // this.criteria = event; - // this.refresh(); - // } -} - -// export class DmpDataSource extends DataSource { - -// totalCount = 0; - -// constructor( -// private _service: DmpService, -// private _paginator: MatPaginator, -// private _sort: MatSort, -// private _languageService: TranslateService, -// private _snackBar: MatSnackBar, -// private _criteria: ExploreDmpCriteriaModel, -// ) { -// super(); -// } - -// connect(): Observable { -// const displayDataChanges = [ -// this._paginator.page -// ]; - -// return Observable.merge(...displayDataChanges) -// .startWith(null) -// .switchMap(() => { -// const startIndex = this._paginator.pageIndex * this._paginator.pageSize; -// let fields: Array = new Array(); -// if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } -// const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); -// request.criteria = this._criteria; -// //if (this.dmpId) request.criteria.allVersions = true; -// return this._service.getPublicPaged(request); -// }) -// .map(result => { -// if (!result) { return []; } -// if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } -// return result.data; -// }); -// } - -// disconnect(): void { -// // No-op -// } -// } diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.module.ts b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.module.ts deleted file mode 100644 index 51046c470..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NgModule } from "@angular/core"; -import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; -import { DmpOverviewModule } from '@app/ui/dmp/overview/dmp-overview.module'; -import { ExploreDmpFilterItemComponent } from '@app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filter-item/explore-dmp-filter-item.component'; -import { ExploreDmpFiltersComponent } from '@app/ui/explore-dmp/dmp-explore-filters/explore-dmp-filters.component'; -import { ExploreDmpListingComponent } from '@app/ui/explore-dmp/explore-dmp-listing.component'; -import { ExploreDmpRoutingModule } from '@app/ui/explore-dmp/explore-dmp.routing'; -import { ExploreDmpListingItemComponent } from '@app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - AutoCompleteModule, - ExploreDmpRoutingModule, - DmpOverviewModule - ], - declarations: [ - ExploreDmpListingComponent, - ExploreDmpFiltersComponent, - ExploreDmpFilterItemComponent, - ExploreDmpListingItemComponent - ] -}) -export class ExploreDmpModule { } diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts deleted file mode 100644 index 4918a250d..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { ExploreDmpListingComponent } from './explore-dmp-listing.component'; -import { DmpOverviewComponent } from '../dmp/overview/dmp-overview.component'; - -const routes: Routes = [ - { - path: '', - component: ExploreDmpListingComponent, - data: { - breadcrumb: true - } - }, - { - path: 'versions/:groupId', - component: ExploreDmpListingComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'overview/:publicId', - component: DmpOverviewComponent, - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.EXPLORE-PLANS-OVERVIEW' - }, - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class ExploreDmpRoutingModule { } diff --git a/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.html b/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.html deleted file mode 100644 index e7bf1a5d0..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - diff --git a/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.scss b/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.scss deleted file mode 100644 index 8e71079de..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.scss +++ /dev/null @@ -1,142 +0,0 @@ -.gray-container { - letter-spacing: 5px; - color: #aaaaaa; -} - -.container-header { - display: flex; - align-items: baseline; - margin-top: 0px; - text-transform: uppercase; -} - -.about-item { - display: flex; - flex-wrap: wrap; -} - -.about-item h4 { - font-size: 1rem; - line-height: 1.25em; - font-weight: 500; -} - -.about-item .length { - color: var(--primary-color-3); - // color: #089dbb; -} - -.about-item .title { - margin: 2px 10px; -} - -.about-item p { - margin-left: auto; - margin-bottom: 0px; - padding-top: 7px; - color: #aaaaaa; -} - -.draft-icon { - color: #aaaaaa; -} - -.more-horiz { - font-size: 28px; - color: #aaaaaa; -} - -.custom-published-icon { - width: 20px; - height: 20px; - border-radius: 50%; - background-color: #08bd6342; - margin-top: 3px; -} - -.published-icon { - color: #08bd63; - font-size: 12px; - margin-left: 4px; - padding-bottom: 7px; - // padding-top: 2px; - // padding-left: 4px; - // color: #92d050; -} - -.outer-circle { - background: #08bd6342; - border-radius: 50%; - width: 20px; - height: 20px; - position: relative; - margin-top: 3px; -} - -.inner-circle { - position: absolute; - background: #08bd63; - border-radius: 50%; - height: 10px; - width: 10px; - top: 50%; - left: 50%; - margin: -5px 0px 0px -5px; -} - -h4 { - display: inline; - padding-left: 1em; - line-height: 1.7em; -} - -h4 > span { - text-transform: uppercase; -} - -p { - color: #333333; -} - -.description { - margin-bottom: 0.4em; -} - -// .explore-dmp-listing-item { -// margin-top: 2em; -// margin-bottom: 2em; -// cursor: pointer; - -// .title { -// color: black; -// } - -// .grant-title { -// color: rgb(93, 125, 173); -// } - -// .gray-icon { -// color: rgb(191, 191, 191); -// } - -// .explore-dmp-chip { -// padding: 0.1em 1em; -// border: 0.1em solid rgb(236, 241, 249); -// border-radius: 10em; -// background-color: rgb(236, 241, 249); -// color: rgb(68, 114, 196); -// } - -// .explore-dmp-squared-chip { -// padding: 0.1em 1em; -// border: 0.1em solid rgb(236, 241, 249); -// border-radius: 0.5em; -// background-color: rgb(246, 246, 246); -// color: rgb(127, 127, 127); -// } - -// mat-icon { -// width: auto; -// height: auto; -// } -// } diff --git a/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.ts deleted file mode 100644 index 663db64f7..000000000 --- a/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { DmpListingModel } from '../../../core/model/dmp/dmp-listing'; -import { Principal } from '../../../core/model/auth/principal'; -import { AuthService } from '../../../core/services/auth/auth.service'; -import { TranslateService } from '@ngx-translate/core'; -import { Router, ActivatedRoute } from '@angular/router'; - -@Component({ - selector: 'app-explore-dmp-listing-item-component', - templateUrl: './explore-dmp-listing-item.component.html', - styleUrls: ['./explore-dmp-listing-item.component.scss'], -}) -export class ExploreDmpListingItemComponent implements OnInit { - - @Input() dmp: DmpListingModel; - @Input() showDivider: boolean = true; - @Output() onClick: EventEmitter = new EventEmitter(); - - constructor( - private authentication: AuthService, - private translate: TranslateService, - private router: Router, - private route: ActivatedRoute - ) { } - - ngOnInit() { - } - - // itemClicked() { - // this.onClick.emit(this.dmp); - // } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId().toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.translate.instant('DMP-PUBLIC-LISTING.OWNER'); - } - else if (role === 1) { - return this.translate.instant('DMP-PUBLIC-LISTING.MEMBER'); - } - else { - return this.translate.instant('DMP-PUBLIC-LISTING.VIEW-ONLY'); - } - } -} diff --git a/dmp-frontend/src/app/ui/language/language-content/language.component.ts b/dmp-frontend/src/app/ui/language/language-content/language.component.ts index 2bc6e76fc..d3e083826 100644 --- a/dmp-frontend/src/app/ui/language/language-content/language.component.ts +++ b/dmp-frontend/src/app/ui/language/language-content/language.component.ts @@ -1,13 +1,10 @@ -import { Component, OnInit, Output, EventEmitter } from '@angular/core'; +import { Component, EventEmitter, OnInit, Output } from '@angular/core'; +import { MatButtonToggleChange } from '@angular/material/button-toggle'; import { Router } from '@angular/router'; import { AuthService } from '@app/core/services/auth/auth.service'; import { LanguageService } from '@app/core/services/language/language.service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { takeUntil } from 'rxjs/operators'; -import { BaseComponent } from '@common/base/base.component'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { MatButtonToggleChange } from '@angular/material/button-toggle'; import { UserService } from '@app/core/services/user/user.service'; +import { BaseComponent } from '@common/base/base.component'; @Component({ selector: 'app-language', diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html deleted file mode 100644 index 567ff7d61..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html +++ /dev/null @@ -1,15 +0,0 @@ -
-
-
- close -
-
-
- -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts deleted file mode 100644 index 9648f1c31..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import {Component, Inject} from "@angular/core"; -import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; -import { VisibilityRulesService } from "@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service"; - -@Component({ - selector: 'app-form-composite-field-dialog', - templateUrl: 'form-composite-field-dialog.component.html' -}) -export class FormCompositeFieldDialogComponent { - - public visibilityRulesService: VisibilityRulesService; - - constructor( - private dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { - this.visibilityRulesService = data.visibilityRulesService; - } - - cancel() { - this.dialogRef.close(); - } - - save() { - this.dialogRef.close(this.data.formGroup); - } - - public close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html deleted file mode 100644 index 471e5623b..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html +++ /dev/null @@ -1,74 +0,0 @@ -
- -
-
-
- -
-
-
- -
- -
-
-
- - -
-
- -
-
-
- -
-
-
- -
-
{{this.fieldFormGroup.get('data').value.label}}
-
- - -
-
-
- -
-
-
-
- - - {{fieldFormGroup.getRawValue() | fieldValue | translate}} - - - - - - diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.scss deleted file mode 100644 index a6df1bcca..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.scss +++ /dev/null @@ -1,17 +0,0 @@ -.compositeField { - padding-left: 0em !important; -// padding-top: 2em !important; -} - -// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { -// background: #fafafa !important; -// } - -// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { -// font-size: 1rem; -// padding: 0.6em 0 1em 0 !important; -// } - -.actions { - width: 110px; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.ts deleted file mode 100644 index f902aefdd..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.ts +++ /dev/null @@ -1,125 +0,0 @@ -import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input} from '@angular/core'; -import {UntypedFormArray, UntypedFormGroup} from '@angular/forms'; -import {BaseComponent} from '@common/base/base.component'; -import {takeUntil} from 'rxjs/operators'; -import {ToCEntry} from '../../dataset-description.component'; -import { - FormCompositeFieldDialogComponent -} from "@app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component"; -import {MatDialog} from "@angular/material/dialog"; -import {cloneAbstractControl} from "@app/utilities/enhancers/utils"; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - -@Component({ - selector: 'app-form-composite-field, [app-form-composite-field]', - templateUrl: './form-composite-field.component.html', - styleUrls: ['./form-composite-field.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class FormCompositeFieldComponent extends BaseComponent { - - @Input() datasetProfileId: String; - @Input() form: UntypedFormGroup; - @Input() isChild: Boolean = false; - @Input() showDelete: Boolean = false; - @Input() tocentry: ToCEntry; - @Input() tableRow: boolean = false; - @Input() showTitle: boolean = true; - @Input() placeholderTitle: boolean = false; - @Input() altVisibilityRulesService: VisibilityRulesService; - - constructor( - private dialog: MatDialog, - public visibilityRulesService: VisibilityRulesService, - private changeDetector: ChangeDetectorRef - ) { - super(); - } - - ngOnInit() { - if(this.altVisibilityRulesService) { - this.visibilityRulesService = this.altVisibilityRulesService; - } - this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - this.changeDetector.markForCheck(); - }); - if (this.tocentry) { - this.form = this.tocentry.form as UntypedFormGroup; - } - } - - // addMultipleField(fieldIndex: number) { - // const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldIndex) as FormGroup).getRawValue(); - // const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned); - // ((this.form.get('compositeFields').get('' + fieldIndex).get('multiplicityItems'))).push(compositeField.buildForm()); - // } - - // markForConsideration() { - // this.markForConsiderationService.markForConsideration(this.compositeField); - // } - - editCompositeFieldInDialog() { - const dialogRef = this.dialog.open(FormCompositeFieldDialogComponent, { - width: '750px', - disableClose: true, - data: { - formGroup: cloneAbstractControl(this.form), - datasetProfileId: this.datasetProfileId, - visibilityRulesService: this.visibilityRulesService - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { - if (data) { - this.form.patchValue(data.value); - this.changeDetector.detectChanges(); - } - }); - } - - deleteCompositeField() { - if (this.isChild) { - this.deleteMultipeFieldFromCompositeFormGroup(); - } else { - this.deleteCompositeFieldFormGroup(); - } - } - - deleteCompositeFieldFormGroup() { - - const compositeFieldId = ((this.form.get('multiplicityItems') as UntypedFormArray).get('' + 0) as UntypedFormGroup).getRawValue().id; - const fieldIds = (this.form.get('fields') as UntypedFormArray).controls.map(control => control.get('id').value) as string[]; - - const numberOfItems = this.form.get('multiplicityItems').get('' + 0).get('fields').value.length; - for (let i = 0; i < numberOfItems; i++) { - const multiplicityItem = this.form.get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; - this.form.get('fields').get('' + i).patchValue(multiplicityItem); - } - ((this.form.get('multiplicityItems'))).removeAt(0); - - - this.visibilityRulesService.removeAllIdReferences(compositeFieldId); - fieldIds.forEach(x => this.visibilityRulesService.removeAllIdReferences(x)); - } - - deleteMultipeFieldFromCompositeFormGroup() { - const parent = this.form.parent; - const index = (parent as UntypedFormArray).controls.indexOf(this.form); - - const currentId = this.form.get('id').value; - const fieldIds = (this.form.get('fields') as UntypedFormArray).controls.map(control => control.get('id').value) as string[]; - - - this.visibilityRulesService.removeAllIdReferences(currentId); - fieldIds.forEach(x => this.visibilityRulesService.removeAllIdReferences(x)); - - (parent as UntypedFormArray).removeAt(index); - (parent as UntypedFormArray).controls.forEach((control, i) => { - try { - control.get('ordinal').setValue(i); - } catch { - throw 'Could not find ordinal'; - } - }); - // ((this.form as AbstractControl)).removeAt(fildIndex); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.html deleted file mode 100644 index fc710c640..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.html +++ /dev/null @@ -1,27 +0,0 @@ -
-
-
- {{tocentry? tocentry.numbering :form.get('numbering').value}} - {{form.get('title').value}} - -
- info -
-
- - -
- -
-
- {{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-MORE' | translate}} -
-
-
- - {{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-LESS' | translate}} - -
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.scss deleted file mode 100644 index 356217a1e..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.scss +++ /dev/null @@ -1,31 +0,0 @@ -.compositeField { - // font-weight: bold; - // color: #3a3737; - // max-width: 100%; - // padding-top: 1em; - text-align: left; - font-weight: 700; - font-size: 18px; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-top: 1.625rem; - margin-bottom: 0.625rem; -} - -.info-icon{ - margin-top: 1.625rem; -} - -h6 { - text-transform: none; - font-weight: 400; -} - -.more { - text-decoration: underline; - color: var(--secondary-color); - cursor: pointer; - font-size: 1rem; - font-weight: 400; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.ts deleted file mode 100644 index 5cfc7027a..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-title/form-composite-title.component.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { ToCEntry } from '../../dataset-description.component'; - -@Component({ - selector: 'app-form-composite-title', - templateUrl: './form-composite-title.component.html', - styleUrls: ['./form-composite-title.component.scss'] -}) -export class FormCompositeTitleComponent implements OnInit { - - @Input() form: UntypedFormGroup; - @Input() isChild: Boolean = false; - @Input() tocentry:ToCEntry; - - public showExtendedDescription: boolean = false; - - constructor() { } - - ngOnInit() { - if(this.tocentry){ - this.form = this.tocentry.form as UntypedFormGroup; - } - } - -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html deleted file mode 100644 index e24890e11..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html +++ /dev/null @@ -1,484 +0,0 @@ -
- -
{{this.form.get('title').value}}
- info - -
{{this.form.get('description').value}} -
-
- {{this.form.get('extendedDescription').value}} -
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - {{'GENERAL.VALIDATION.URL.MESSAGE' | translate}} - - -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - - - - {{opt.label}} - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - - - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - - - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
- - {{form.get('data').value.label}} -
- - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - -
-
- {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
-
-
- -
- - - {{ form.value.value.name }} - - -
-
- - - -
-
- - - - - - - - - -
- - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }} - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
- -
- - {{option.label}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} * -
- - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
-
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
-
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - -
-
- -
-
- - - - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - - - - - - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} - -
-
- -
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{ type.name }} - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
- -
-
- - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
-
- -
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - - - {{ type.name }} - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - -
- - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
- - {{validationIcon}} -
-
-
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.scss deleted file mode 100644 index 0213cb51f..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.scss +++ /dev/null @@ -1,105 +0,0 @@ -.dynamic-form-field { - .radio-button-item { - margin-right: 1em; - } - - .full-width { - width: 100%; - } - - .text-area { - box-sizing: content-box; - } - - .success { - color: green; - } - - .fail { - color: red; - } -} - -::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} - - -.attach-btn { - top: -20px; -} - -.attach-file-btn { - min-width: 156px; - height: 44px; - color: #ffffff; - background: var(--primary-color) 0% 0% no-repeat padding-box; - box-shadow: 0px 3px 6px #1e202029; - border-radius: 30px; -} - -.attach-file-btn:hover { - background-color: #ffffff; - border: 1px solid var(--primary-color); - color: var(--primary-color); -} - -.attach-file-btn.mdc-button-disabled, .attach-file-btn.mdc-button-disabled:hover { - background-color: #ffffff; - border: 1px solid darkgray; - color: darkgrey !important; -} -// -//.mdc-button-disabled .attach-file-btn > ::ng-deep mdc-button-wrapper:hover > * { -// color: darkgrey !important; -//} - -.drop-file { - background-color: #fafafa; - border: 1px dashed #d1d1d1; - border-radius: 4px; - //max-width: 480px; - height: 98px; - margin-top: 0.5rem; -} - -.file-preview { - height: auto !important; - width: auto !important; - max-width: 500px !important; - min-height: 1rem !important; - - background-color: #e0e0e0 !important; - background-image: none !important; - color: rgba(0, 0, 0, 0.87) !important; - font-weight: 500 !important; - border-radius: 24px !important; - line-height: 1.25 !important; -} - -.file-label { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - font-size: 14px !important; -} - -::ng-deep ngx-dropzone-remove-badge { - opacity: 1 !important; - margin-left: .5rem !important; - position: initial !important; -} - -::ng-deep .upload-form .mat-form-field-appearance-outline .mat-form-field-outline { - background: #fafafa !important; -} - -::ng-deep .upload-form .mat-form-field-appearance-outline .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts deleted file mode 100644 index 041711468..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts +++ /dev/null @@ -1,766 +0,0 @@ - -import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges} from '@angular/core'; -import { UntypedFormGroup, FormArray, UntypedFormControl } from '@angular/forms'; -import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type'; -import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '@app/core/query/dataset/daatset-external-autocomplete-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { ResearcherCriteria } from '@app/core/query/researcher/researcher-criteria'; -import { DatasetExternalAutocompleteService } from '@app/core/services/dataset/dataset-external-autocomplete.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -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 { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from '@ngx-translate/core'; -import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators'; -import { Observable } from 'rxjs'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalDatasetCriteria } from '@app/core/query/external-dataset/external-dataset-criteria'; -import { DataRepositoryCriteria } from '@app/core/query/data-repository/data-repository-criteria'; -import { RegistryCriteria } from '@app/core/query/registry/registry-criteria'; -import { ServiceCriteria } from '@app/core/query/service/service-criteria'; -import { TagCriteria } from '@app/core/query/tag/tag-criteria'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; -import { ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { MatChipInputEvent } from '@angular/material/chips'; -import { ENTER, COMMA } from '@angular/cdk/keycodes'; -import { DatasetIdModel } from '@app/core/model/dataset/dataset-id.model'; -import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; -import { CurrencyService } from '@app/core/services/currency/currency.service'; -import { AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data'; -import {LicenseCriteria} from "@app/core/query/license/license-criteria"; -import {TaxonomyCriteria} from "@app/core/query/taxonomy/taxonomy-criteria"; -import {PublicationCriteria} from "@app/core/query/publication/publication-criteria"; -import {FileService} from "@app/core/services/file/file.service"; -import { - SnackBarNotificationLevel, - UiNotificationService -} from "@app/core/services/notification/ui-notification-service"; -import {FormValidationErrorsDialogComponent} from "@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component"; -import {MatDialog} from "@angular/material/dialog"; -import {HttpError} from "@common/modules/errors/error-handling/http-error-handling.service"; -import {HttpErrorResponse} from "@angular/common/http"; -import * as FileSaver from "file-saver"; -import { FetcherReference, Reference } from '@app/core/model/reference/reference'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup'; -import { lookup } from 'dns'; -import { ReferenceService } from '@app/core/services/reference/reference.service'; - -@Component({ - selector: 'app-form-field', - templateUrl: './form-field.component.html', - styleUrls: ['./form-field.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class FormFieldComponent extends BaseComponent implements OnInit { - - // @Input() field: Field; - @Input() form: UntypedFormGroup; - @Input() datasetProfileId: any; - @Input() isChild: Boolean = false; - autocompleteOptions: AutoCompleteSingleData[]; - - visible: boolean = true; - _renderStyle: DatasetProfileFieldViewStyle = null; - - get renderStyle() { - //console.log('renderStyle'); - return this._renderStyle; - } - - // change: Subscription; - // trackByFn = (index, item) => item ? item['id'] : null; - - public singleAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - public multipleAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - datasetProfileFieldViewStyleEnum = DatasetProfileFieldViewStyle; - datasetProfileComboBoxTypeEnum = DatasetProfileComboBoxType; - datasetProfileInternalDmpEntitiesTypeEnum = DatasetProfileInternalDmpEntitiesType; - externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - pubRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - journalRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - taxonomiesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - licensesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - publicationsAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - tagsAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - currencyAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - - readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - tags: ExternalTagEditorModel[] = []; - - datasetIdInitialized: boolean = false; - - validationIcon; - - readonly datasetIdTypes: any[] = [ - { name: 'Handle', value: 'handle' }, - { name: 'DOI', value: 'doi' }, - { name: 'Ark', value: 'ark' }, - { name: 'Url', value: 'url' }, - { name: 'Other', value: 'other' } - ]; - - - readonly validationTypes: any[] = [ - { name: 'Zenodo', value: 'zenodo' } - ]; - - filesToUpload: FileList; - - constructor( - public visibilityRulesService: VisibilityRulesService, - private datasetExternalAutocompleteService: DatasetExternalAutocompleteService, - private externalSourcesService: ExternalSourcesService, - private language: TranslateService, - private datasetService: DatasetService, - private dmpService: DmpService, - private currencyService: CurrencyService, - private fileService: FileService, - private cdr: ChangeDetectorRef, - private uiNotificationService: UiNotificationService, - public dialog: MatDialog, - private fileUtils: FileUtils, - private referenceService: ReferenceService - ) { - super(); - - this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - this.visible = this.visibilityRulesService.checkElementVisibility(this.form?.get('id')?.value); - }); - } - - ngOnChanges(changes: SimpleChanges) { - if (changes['form']) { - this._renderStyle = this.form.get('viewStyle')?.value?.renderStyle; - } - } - - ngOnInit() { - - if (this.form.get('value').value) { - this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, this.form.get('value').value); - } - - if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList) { - if (this.form.get('data').value.multiList) { - const originalValue = this.form.get('value').value; - if (originalValue !== null && typeof originalValue === 'string') { - let values = (this.form.get('value').value).slice(1, -1).split(', ').filter((value) => !value.includes('"')); - let specialValue = (this.form.get('value').value).split('"').filter((value) => !value.startsWith('[') && !value.endsWith(']') && !values.includes(value) && value !== ', '); - specialValue.forEach(value => values.push(value)); - if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) { - values = undefined; - values = [originalValue]; - } - this.form.patchValue({ 'value': values }); - values.forEach(element => { - this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, element); - }); - } - } - } - - // Setup autocomplete configuration if needed - if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.Autocomplete) { - if (!(this.form.controls['data'].value.multiAutoComplete)) { - this.singleAutoCompleteConfiguration = { - filterFn: this.searchFromAutocomplete.bind(this), - initialItems: () => this.searchFromAutocomplete(''), - displayFn: (item) => { try { return (item != null && item.length > 1) ? JSON.parse(item).label : item['label'] } catch { return '' } }, - titleFn: (item) => { try { return item['label'] } catch { return '' } }, - valueAssign: (item) => { try { return JSON.stringify(item) } catch { return '' } }, - subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } } - }; - } - else { - this.multipleAutoCompleteConfiguration = { - filterFn: this.searchFromAutocomplete.bind(this), - initialItems: () => this.searchFromAutocomplete(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label'] } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label'] } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }, - subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } } - } - } - if(isNullOrUndefined(this.datasetProfileId)){ - this.autocompleteOptions = this.form.get('data').value.autoCompleteSingleDataList; - } - } - - switch (this.form.get('viewStyle').value.renderStyle) { - case DatasetProfileFieldViewStyle.ExternalDatasets: - this.externalDatasetAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDatasets.bind(this), - initialItems: () => this.searchDatasetExternalDatasets(''),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.DataRepositories: - this.dataRepositoriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalDataRepositories.bind(this), - initialItems: () => this.searchDatasetExternalDataRepositories(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.PubRepositories: - this.pubRepositoriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalPubRepositories.bind(this), - initialItems: () => this.searchDatasetExternalPubRepositories(''), - displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - subtitleFn: (item) => { try{return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')}catch{return''}}, - valueAssign: (item) => { try{return typeof (item) == 'string' ? item : JSON.stringify(item)}catch{return''}} - }; - break; - case DatasetProfileFieldViewStyle.JournalRepositories: - this.journalRepositoriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalJournalRepositories.bind(this), - initialItems: () => this.searchDatasetExternalJournalRepositories(''), - displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - subtitleFn: (item) => { try{return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')}catch{return''}}, - valueAssign: (item) => { try{return typeof (item) == 'string' ? item : JSON.stringify(item)}catch{return''}} - }; - break; - case DatasetProfileFieldViewStyle.Taxonomies: - this.taxonomiesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalTaxonomies.bind(this), - initialItems: () => this.searchDatasetExternalTaxonomies(''), - displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - subtitleFn: (item) => { try{return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')}catch{return''}}, - valueAssign: (item) => { try{return typeof (item) == 'string' ? item : JSON.stringify(item)}catch{return''}} - }; - break; - case DatasetProfileFieldViewStyle.Licenses: - this.licensesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalLicences.bind(this), - initialItems: () => this.searchDatasetExternalLicences(''), - displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - subtitleFn: (item) => { try{return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')}catch{return''}}, - valueAssign: (item) => { try{return typeof (item) == 'string' ? item : JSON.stringify(item)}catch{return''}} - }; - break; - case DatasetProfileFieldViewStyle.Publications: - this.publicationsAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalPublications.bind(this), - initialItems: () => this.searchDatasetExternalPublications(''), - displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name}catch{return''}}, - subtitleFn: (item) => { try{return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')}catch{return''}}, - valueAssign: (item) => { try{return typeof (item) == 'string' ? item : JSON.stringify(item)}catch{return''}} - }; - break; - case DatasetProfileFieldViewStyle.Registries: - this.registriesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalRegistries.bind(this), - initialItems: () => this.searchDatasetExternalRegistries(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.Services: - this.servicesAutoCompleteConfiguration = { - filterFn: this.searchDatasetExternalServices.bind(this), - initialItems: () => this.searchDatasetExternalServices(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - subtitleFn: (item) => { try { return item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.Tags: - this.tagsAutoCompleteConfiguration = { - filterFn: this.filterTags.bind(this), - initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => { try { return this.showTag(item) } catch { return '' } }, - titleFn: (item) => { try { return item['name'] } catch { return '' } }, - valueAssign: (item) => { try { return this.addTag(item) } catch { return '' } } - }; - this.parseTags(); - break; - case DatasetProfileFieldViewStyle.Researchers: - this.researchersAutoCompleteConfiguration = { - filterFn: this.filterResearchers.bind(this), - initialItems: (excludedItems: any[]) => this.filterResearchers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.Organizations: - this.organisationsAutoCompleteConfiguration = { - filterFn: this.filterOrganisations.bind(this), - initialItems: (excludedItems: any[]) => this.filterOrganisations('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - subtitleFn: (item) => { try { return item['tag'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['tag'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')) } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.DatasetIdentifier: - const value = this.form.get('value').value; - const disabled = this.form.disabled; - this.form.removeControl('value'); - this.form.addControl('value', new DatasetIdModel(value).buildForm()); - if(disabled) { - this.form.disable(); - } - this.datasetIdInitialized = true; - break; - case DatasetProfileFieldViewStyle.Currency: - this.currencyAutoCompleteConfiguration = { - filterFn: this.searchCurrency.bind(this), - initialItems: () => this.searchCurrency(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } } - }; - break; - case DatasetProfileFieldViewStyle.Validation: - const value1 = this.form.get('value').value; - const disabled1 = this.form.disabled; - this.form.removeControl('value'); - this.form.addControl('value', new DatasetIdModel(value1).buildForm()); - if(disabled1) { - this.form.disable(); - } - //this.datasetIdInitialized = true; - break; - } - - if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) { - if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Researchers) { - this.makeAutocompleteConfiguration(this.searchResearchers.bind(this), "name", "tag"); - } - else if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Datasets) { - this.makeAutocompleteConfiguration(this.searchDatasets.bind(this), "label"); - } - else if (this.form.get('data').value.type === DatasetProfileInternalDmpEntitiesType.Dmps) { - this.makeAutocompleteConfiguration(this.searchDmps.bind(this), "label"); - } - } - - // this.form = this.visibilityRulesService.getFormGroup(this.field.id); - this.form.get('value').valueChanges - .pipe( - takeUntil(this._destroyed), - distinctUntilChanged() - ) - .subscribe(item => { - // if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.ComboBox && this.form.get('data').value.type === DatasetProfileComboBoxType.WordList && this.form.get('data').value.multiList) { - // item.forEach(element => { - // this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, element); - // }); - - // } else { - this.visibilityRulesService.updateValueAndVisibility(this.form.get('id').value, item); - // } - }); - } - - // _optionRemove(event) { - // const array = JSON.parse(this.form.get('value').value); - // if (array) { - // const index = array.map(x => x.id).indexOf(event.id); - // if (index >= 0) { - // array.splice(index, 1); - // } - // this.form.get('value').patchValue(JSON.stringify(array)); - // } - // } - - searchFromAutocomplete(query: string) { - - if (this.autocompleteOptions) { - const autocompleteRequestItem: RequestItem = new RequestItem(); - autocompleteRequestItem.criteria = new DatasetExternalAutocompleteOptionsCriteria(); - autocompleteRequestItem.criteria.autoCompleteSingleDataList = this.autocompleteOptions; - autocompleteRequestItem.criteria.like = query; - return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem); - } - else{ - const autocompleteRequestItem: RequestItem = new RequestItem(); - autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria(); - let parseIdArray: string[] = this.form.get('id').value.split('_'); - if(parseIdArray.length > 1) { - autocompleteRequestItem.criteria.fieldID = parseIdArray[parseIdArray.length - 1]; - } else { - autocompleteRequestItem.criteria.fieldID = this.form.get('id').value; - } - if (typeof this.datasetProfileId === 'string') { - autocompleteRequestItem.criteria.profileID = this.datasetProfileId; - } - else if (this.datasetProfileId != null) { - autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id; - } - autocompleteRequestItem.criteria.like = query; - return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem); - } - } - - searchResearchers(query: string) { - const reasearcherAutocompleteRequestItem: RequestItem = new RequestItem(); - reasearcherAutocompleteRequestItem.criteria = new ResearcherCriteria; - reasearcherAutocompleteRequestItem.criteria.name = query; - return this.externalSourcesService.searchDMPResearchers(reasearcherAutocompleteRequestItem); - } - - searchDatasets(query: string) { - let fields: Array = new Array(); - const datasetsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); - datasetsAutocompleteRequestItem.criteria = new DatasetCriteria(); - datasetsAutocompleteRequestItem.criteria.like = query; - return this.datasetService.getPaged(datasetsAutocompleteRequestItem).pipe(map(item => item.data)); - } - - searchDmps(query: string) { - let fields: Array = new Array(); - const dmpsAutocompleteRequestItem: DataTableRequest = new DataTableRequest(0, 25, { fields: fields }); - dmpsAutocompleteRequestItem.criteria = new DmpCriteria(); - dmpsAutocompleteRequestItem.criteria.like = query; - return this.dmpService.getPaged(dmpsAutocompleteRequestItem).pipe(map(item => item.data)); - } - - makeAutocompleteConfiguration(myfunc: Function, title: string, subtitle?: string): void { - if (!(this.form.controls['data'].value.multiAutoComplete)) { - this.singleAutoCompleteConfiguration = { - filterFn: myfunc.bind(this), - initialItems: (extraData) => myfunc(''), - displayFn: (item) => { try { return (item != null && item.length > 1) ? JSON.parse(item)[title] : item[title] } catch { return '' } }, - titleFn: (item) => { try { return item[title] } catch { return '' } }, - valueAssign: (item) => JSON.stringify(item), - subtitleFn: (item) => { try { return item[subtitle] } catch { return '' } } - }; - } - else { - this.multipleAutoCompleteConfiguration = { - filterFn: myfunc.bind(this), - initialItems: (extraData) => myfunc(''), - displayFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)[title] : item[title] } catch { return '' } }, - titleFn: (item) => { try { return typeof (item) == 'string' ? JSON.parse(item)[title] : item[title] } catch { return '' } }, - valueAssign: (item) => { try { return typeof (item) == 'string' ? item : JSON.stringify(item) } catch { return '' } }, - subtitleFn: (item) => { try { return item[subtitle] } catch { return '' } } - } - } - } - - searchDatasetExternalDatasets(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new ExternalDatasetCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // //return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); - // return this.externalSourcesService.listExternal(ReferenceType.Datasets, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Datasets; - return this.referenceService.search(lookup); - } - - searchDatasetExternalDataRepositories(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.DataRepositories, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.DataRepositories; - return this.referenceService.search(lookup); - } - searchDatasetExternalPubRepositories(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.PubRepositories, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.PubRepositories; - return this.referenceService.search(lookup); - } - searchDatasetExternalJournalRepositories(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.Journals, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Journals; - return this.referenceService.search(lookup); - } - searchDatasetExternalTaxonomies(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new TaxonomyCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.listExternal(ReferenceType.Taxonomies, requestItem.criteria.like, requestItem.criteria.type); - } - searchDatasetExternalLicences(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new LicenseCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - // return this.externalSourcesService.listExternal(ReferenceType.Licenses, requestItem.criteria.like, requestItem.criteria.type); - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Licenses; - return this.referenceService.search(lookup); - } - searchDatasetExternalPublications(query: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new PublicationCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = ''; - //return this.externalSourcesService.listExternal(ReferenceType.Publications, requestItem.criteria.like, requestItem.criteria.type); - - const lookup = new ReferenceSearchLookup(); - lookup.like = query; - lookup.key = ''; - lookup.type = ReferenceType.Publications; - return this.referenceService.search(lookup); - } - - searchDatasetExternalRegistries(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new RegistryCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.listExternal(ReferenceType.Registries, requestItem.criteria.like, requestItem.criteria.type); - } - - searchDatasetExternalServices(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new ServiceCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.listExternal(ReferenceType.Services, requestItem.criteria.like, requestItem.criteria.type); - } - - searchDatasetTags(query: string): Observable { - const requestItem: RequestItem = new RequestItem(); - requestItem.criteria = new TagCriteria(); - requestItem.criteria.like = query; - requestItem.criteria.type = ''; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - parseTags() { - try { - - - let stringValue = this.form.get('value').value; - if (typeof stringValue === 'string') { - stringValue = (stringValue).replace(new RegExp('{', 'g'), '{"').replace(new RegExp('=', 'g'), '":"').replace(new RegExp(',', 'g'), '",').replace(new RegExp(', ', 'g'), ', "').replace(new RegExp('}', 'g'), '"}'); - stringValue = stringValue.replace(new RegExp('}"', 'g'), '}').replace(new RegExp('"{', 'g'), '{'); - } else if (stringValue instanceof Array) { - const tempArray = new Array(); - for (let stringTag of stringValue) { - tempArray.push(JSON.parse(stringTag)); - } - stringValue = JSON.stringify(tempArray); - } - const tagArray = JSON.parse(stringValue); - this.form.patchValue({ 'value': tagArray }); - } catch (e) { - console.warn('Could not parse tags'); - } - } - - filterTags(value: string): Observable { - const requestItem: RequestItem = new RequestItem(); - const criteria: TagCriteria = new TagCriteria(); - criteria.like = value; - requestItem.criteria = criteria; - return this.externalSourcesService.searchDatasetTags(requestItem); - } - - showTag(ev: any) { - if (typeof ev === 'string') { - return ev; - } else { - return ev.name; - } - } - - addTag(ev: any) { - let item: ExternalTagEditorModel; - //this.filteredTags = this.formGroup.get('tags').value; - if (typeof ev === 'string') { - item = new ExternalTagEditorModel('', ev); - } else { - item = ev; - } - if (item.name !== '') { - return item; - } - } - - filterOrganisations(value: string): Observable { - //return this.externalSourcesService.searchDMPOrganizations(value); - //return this.externalSourcesService.listExternal(ReferenceType.Organizations, value, ''); - const lookup = new ReferenceSearchLookup(); - lookup.like = value; - lookup.key = ''; - lookup.type = ReferenceType.Organizations; - return this.referenceService.search(lookup); - } - - filterResearchers(value: string): Observable { - //return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }); - //return this.externalSourcesService.listExternal(ReferenceType.Researcher, value, ''); - const lookup = new ReferenceSearchLookup(); - lookup.like = value; - lookup.key = ''; - lookup.type = ReferenceType.Researcher; - return this.referenceService.search(lookup); - } - - getDatasetIdControl(name: string): UntypedFormControl { - return this.form.get('value').get(name) as UntypedFormControl; - } - - searchCurrency(query: string): Observable { - return this.currencyService.get(query); - } - - validateId() { - const identifier = this.getDatasetIdControl('identifier').value; - const type = this.getDatasetIdControl('type').value; - this.validationIcon = 'loading'; - this.externalSourcesService.validateIdentifier(identifier, type).pipe(takeUntil(this._destroyed)).subscribe(result => { - this.validationIcon = result === true ? 'done' : 'clear'; - }); - - } - - public upload() { - this.fileService.upload(this.filesToUpload[0], this.datasetProfileId.id, this.form.value.id).subscribe((fileId: string) => { - this.form.get("value").patchValue( - {"name": this.filesToUpload[0].name, "id": fileId+"", "type": this.filesToUpload[0].type}); - this.cdr.detectChanges(); - }, error => { - this.onCallbackUploadFail(error.error); - }) - } - - - private onCallbackUploadFail(error: any) { - this.makeFilesNull(); - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - } - - fileChangeEvent(fileInput: any, dropped: boolean = false) { - if(this.form.value.value) { - this.onRemove(false); - } - - if(dropped) { - this.filesToUpload = fileInput.addedFiles; - } else { - this.filesToUpload = fileInput.target.files; - } - - - let messages: string[] = []; - if (this.filesToUpload.length == 0) { - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.NO-FILES-SELECTED')); - return; - } else { - let fileToUpload = this.filesToUpload[0]; - if (this.form.get("data") && this.form.get("data").value.types - && this.form.get("data").value.types.map(type => type.value).includes(fileToUpload.type) - && this.form.get("data").value.maxFileSizeInMB - && this.form.get("data").value.maxFileSizeInMB*1048576 >= fileToUpload.size) { - this.upload(); - } else { - this.filesToUpload = null; - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.LARGE-FILE-OR-UNACCEPTED-TYPE')); - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.MAX-FILE-SIZE', {'maxfilesize': this.form.get("data").value.maxFileSizeInMB})); - messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.ACCEPTED-FILE-TYPES')+ this.form.get("data").value.types.map(type => type.value).join(", ")); - } - - if(messages && messages.length > 0) { - this.dialog.open(FormValidationErrorsDialogComponent, { - data: { - errorMessages: messages - } - }) - } - } - } - - onRemove(makeFilesNull: boolean = true) { - // delete from tmp folder - subscribe call - this.fileService.deleteFromTempFolder(this.form.value.value.id).subscribe(res => { - if(makeFilesNull) { - this.makeFilesNull(); - } - this.cdr.detectChanges(); - }, error => { - if(makeFilesNull) { - this.makeFilesNull(); - } - }) - } - - makeFilesNull() { - this.filesToUpload = null; - this.form.value.value = null; - this.form.get("value").patchValue(null); - } - - typesToString() { - return this.form.get("data").value.types.map(type => type.value).toString(); - } - - download(): void { - this.fileService.download(this.form.value.value.id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], {type: this.form.value.value.type}); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - }); - } - - // isImageFile(fileType: string) { - // if(!fileType) { - // return false; - // } - // return fileType.startsWith("image/"); - // } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.html deleted file mode 100644 index 56966d9ab..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
-
{{progressSoFar}} {{'GENERAL.PREPOSITIONS.OF' | translate}} {{total}}
- -
{{value}}%
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.scss deleted file mode 100644 index a15510639..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.scss +++ /dev/null @@ -1,16 +0,0 @@ -.percentage { - color: #212121; - opacity: 0.7; - font-weight: 400; - font-size: 0.875rem; -} - -.progress-bar { - border-radius: 20px; - height: 11px; - -} - -::ng-deep .mat-progress-bar .mat-progress-bar-fill::after { - border-radius: 20px !important; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts deleted file mode 100644 index 68c83b2d9..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component.ts +++ /dev/null @@ -1,211 +0,0 @@ -import {ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-form-progress-indication', - templateUrl: './form-progress-indication.component.html', - styleUrls: ['./form-progress-indication.component.scss'] -}) -export class FormProgressIndicationComponent extends BaseComponent implements OnInit, OnChanges { - @Input() formGroup: UntypedFormGroup; - @Input() isDmpEditor: boolean; - @Input() isDatasetEditor: boolean; - @Input() public progressValueAccuracy = 2; - determinateProgressValue: number; - progressSoFar: number; - total: number; - percent: number; - - constructor(private visibilityRulesService: VisibilityRulesService) { super(); } - - public value = 0; - ngOnInit() { - this.init(); - } - - ngOnChanges(changes: SimpleChanges) { - if(changes.formGroup) { - this.init(); - } - } - - init() { - setTimeout(() => {this.calculateValueForProgressbar();}); - this.formGroup - .valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(control => { - setTimeout(() => {this.calculateValueForProgressbar();}); - }); - } - - calculateValueForProgressbar() { - if (this.isDmpEditor) { - this.progressSoFar = this.countFormControlsValidForProgress(this.formGroup); - this.total = this.countFormControlsRequiredFieldsForTotal(this.formGroup); - } else if (this.isDatasetEditor) { - this.progressSoFar = this.countFormControlsValidForProgress(this.formGroup) + this.countFormControlsWithValueForProgress(this.formGroup); - this.total = this.countFormControlsRequiredFieldsForTotal(this.formGroup, true) + this.CountFormControlDepthLengthFotTotal(this.formGroup); - } else { - this.progressSoFar = this.countFormControlsWithValueForProgress(this.formGroup); - this.total = this.CountFormControlDepthLengthFotTotal(this.formGroup); - } - this.percent = (this.progressSoFar / this.total) * 100; - this.value = Number.parseFloat(this.percent.toPrecision(this.progressValueAccuracy)); - } - - countFormControlsWithValueForProgress(formControl: AbstractControl): number { - let valueCurent = 0; - if (formControl instanceof UntypedFormGroup) { - if (this.checkFormsIfIsFieldsAndVisible(formControl) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { - if (this.hasValue(formControl)) - valueCurent++; - } - if (this.chechFieldIfIsFieldSetAndVisible((formControl as UntypedFormGroup)) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { - valueCurent = valueCurent + this.compositeFieldsGetChildsForProgress(formControl); - } else { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - valueCurent = valueCurent + this.countFormControlsWithValueForProgress(control); - }); - } - } else if (formControl instanceof UntypedFormArray) { - formControl.controls.forEach(item => { - valueCurent = valueCurent + this.countFormControlsWithValueForProgress(item); - }); - } - return valueCurent; - } - private hasValue(formGroup: UntypedFormGroup): boolean { - return formGroup.get('value').valid && formGroup.get('value').value != null && formGroup.get('value').value !== '' && this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value); - } - - private compositeFieldsGetChildsForProgress(formGroup: UntypedFormGroup): number { - let valueCurent = 0; - if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { - (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { - valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); - }); - - (formGroup.get('multiplicityItems') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { - valueCurent = valueCurent + this.countFormControlsWithValueForProgress(element); - }); - } - return valueCurent; - } - - private checkIfIsRequired(formControl: UntypedFormGroup): boolean { - return !!(formControl.get('validationRequired') && formControl.get('validationRequired').value); - - } - - private checkFormsIfIsFieldsAndVisible(formControl: UntypedFormGroup): boolean { - if (formControl.contains('id') && formControl.contains('value')) { - return true; - } - return false; - } - private chechFieldIfIsFieldSetAndVisible(formControl: UntypedFormGroup): boolean { - if (formControl.contains('id') && formControl.contains('fields')) { - return true; - } - return false; - } - - CountFormControlDepthLengthFotTotal(formControl: AbstractControl): number { - let valueCurent = 0; - if (formControl instanceof UntypedFormArray) { - formControl.controls.forEach(item => { - valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(item); - }); - } else if (formControl instanceof UntypedFormGroup) { - if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (this.visibilityRulesService.checkElementVisibility((formControl as UntypedFormGroup).get('id').value)) && this.checkIfIsRequired((formControl as UntypedFormGroup))) { - valueCurent++; - } else if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields')) { - valueCurent = valueCurent + this.compositeFieldsGetChildsForTotal(formControl); - } else { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(control); - }); - } - } - - return valueCurent; - } - - private compositeFieldsGetChildsForTotal(formGroup: UntypedFormGroup): number { - let valueCurent = 0; - if (this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { - (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { - valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); - }); - (formGroup.get('multiplicityItems') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { - valueCurent = valueCurent + this.CountFormControlDepthLengthFotTotal(element); - }); - } - return valueCurent; - } - - countFormControlsValidForProgress(formControl: AbstractControl): number { - let valueCurrent = 0; - if (formControl instanceof UntypedFormControl) { - if (this.controlRequired(formControl) && this.controlEnabled(formControl) && formControl.valid) { - valueCurrent++; - } - } else if (formControl instanceof UntypedFormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - valueCurrent = valueCurrent + this.countFormControlsValidForProgress(control); - }); - } else if (formControl instanceof UntypedFormArray) { - formControl.controls.forEach(item => { - valueCurrent = valueCurrent + this.countFormControlsValidForProgress(item); - }); - } - return valueCurrent; - } - - countFormControlsRequiredFieldsForTotal(formControl: AbstractControl, checkVisibility = false): number { - let valueCurrent = 0; - if (formControl instanceof UntypedFormControl) { - if (this.controlRequired(formControl) && this.controlEnabled(formControl)) { - valueCurrent++; - } - } else if (formControl instanceof UntypedFormGroup) { - if(!checkVisibility || (!formControl.get('id')?.value || this.visibilityRulesService.checkElementVisibility(formControl.get('id').value))) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - valueCurrent = valueCurrent + this.countFormControlsRequiredFieldsForTotal(control, checkVisibility); - }); - } - } else if (formControl instanceof UntypedFormArray) { - formControl.controls.forEach(item => { - valueCurrent = valueCurrent + this.countFormControlsRequiredFieldsForTotal(item, checkVisibility); - }); - } - return valueCurrent; - } - - controlRequired(formControl: AbstractControl) { - if (formControl.validator) { - const validator = formControl.validator({} as AbstractControl); - if (validator && validator.required) { - return true; - } - } else { return false } - } - - controlEnabled(formControl: AbstractControl) { - if (formControl.enabled) { - return true; - } else { return false } - } - - isEditor(): boolean { - return this.isDmpEditor || this.isDatasetEditor; - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module.ts deleted file mode 100644 index f287d329d..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-progress-indication/form-progress-indication.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { FormProgressIndicationComponent } from './form-progress-indication.component'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule - ], - declarations: [ - FormProgressIndicationComponent - ], - exports: [ - FormProgressIndicationComponent - ] -}) -export class FormProgressIndicationModule { } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.html deleted file mode 100644 index f620d2d6c..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.html +++ /dev/null @@ -1,80 +0,0 @@ - -
- -
- -
-
- -
- -
-
- -
-
- - - - - - - - - - - - - - -
{{fieldFormGroup.get('data').value.label}}
- - - {{compositeFieldFormGroup.get('multiplicity').value.placeholder}} - {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (compositeFieldFormGroup.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} - -
-
-
- -
-
-
-
- -
-
-
- - - {{compositeFieldFormGroup.get('multiplicity').value.placeholder}} - {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (compositeFieldFormGroup.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} - -
- - - - - - - -
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.scss deleted file mode 100644 index 7d7f80f08..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.scss +++ /dev/null @@ -1,49 +0,0 @@ -.dynamic-form-section { - .expansion-panel { - // background-color: #eeeeee54; - background-color: white; - margin-top: 1em; - margin-bottom: 1em; - // margin-bottom: 1em; - } - .addOneFieldButton { - margin-top: -15px; - margin-left: -11px; - color: var(--primary-color); - } - .panel-title, - .panel-desc { - text-align: left; - font-weight: 700; - font-size: 1rem; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-top: 1.625rem; - margin-bottom: 0.625rem; - } - - .panel-desc { - text-transform: capitalize; - font-weight: 400; - margin-top: .5rem; - } -} -.styleBorder { - border: 0.2em solid lightgray; - border-radius: 0.5em; - margin-bottom: 0.5em; -} -.mat-expansion-panel-header-description { - padding-bottom: 18px; - color: black; -} - -::ng-deep .mat-expansion-panel-header { - height: auto !important; - min-height: 48px; -} - -.actions { - width: 110px; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.ts deleted file mode 100644 index 122fdc6c6..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section-inner/form-section-inner.component.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { DatasetDescriptionCompositeFieldEditorModel } from '../../../dataset-description-form.model'; -import { FormFocusService } from '../../../form-focus/form-focus.service'; -import { LinkToScroll } from '../../../tableOfContentsMaterial/table-of-contents'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - -@Component({ - selector: 'app-form-section-inner', - templateUrl: './form-section-inner.component.html', - styleUrls: ['./form-section-inner.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class FormSectionInnerComponent extends BaseComponent implements OnInit, OnChanges { - - //@Input() section: DatasetDescriptionSectionEditorModel; - @Input() datasetProfileId: String; - // @Input() compositeFieldFormGroup: FormGroup; - @Input() form: UntypedFormGroup; - @Input() pathName: string; - @Input() path: string; - // @Input() i: number; - @Input() linkToScroll: LinkToScroll; - @Input() tableView: boolean = false; - //trackByFn = (index, item) => item ? item['id'] : null; - panelExpanded = true; - // sub = true; - subsectionLinkToScroll: LinkToScroll; - - constructor( - public visibilityRulesService: VisibilityRulesService, - private changeDetector: ChangeDetectorRef, - private formFocusService: FormFocusService - ) { - super(); - this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - this.changeDetector.markForCheck(); - }); - } - - ngOnInit() { - // if (this.section) { - // this.form = this.visibilityRulesService.getFormGroup(this.section.id); - // } - } - - ngOnChanges(changes: SimpleChanges) { - - // if (changes['linkToScroll']) { - // if (changes['linkToScroll'].currentValue && changes['linkToScroll'].currentValue.section) { - - // if (this.pathName === changes['linkToScroll'].currentValue.section) { - // this.panelExpanded = true; - // } else if (changes['linkToScroll'].currentValue.section.includes(this.pathName)) { - // this.subsectionLinkToScroll = changes['linkToScroll'].currentValue; - // this.panelExpanded = true; - // } - // } - // } - } - - // ngAfterViewInit() { - // this.visibilityRulesService.triggerVisibilityEvaluation(); - // } - - addMultipleField(fieldsetIndex: number) { - const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as UntypedFormGroup).getRawValue(); - const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))); - const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, multiplicityItemsArray.length); - multiplicityItemsArray.push(compositeField.buildForm()); - } - - deleteCompositeFieldFormGroup(compositeFildIndex: number) { - const numberOfItems = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').value.length; - for (let i = 0; i < numberOfItems; i++) { - const multiplicityItem = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; - this.form.get('compositeFields').get('' + compositeFildIndex).get('fields').get('' + i).patchValue(multiplicityItem); - } - ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(0); - } - - deleteMultipeFieldFromCompositeFormGroup(compositeFildIndex: number, fildIndex: number) { - const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))) - multiplicityItemsArray.removeAt(fildIndex); - multiplicityItemsArray.controls.forEach((control, i) => { - try { - control.get('ordinal').setValue(i); - } catch { - throw 'Could not find ordinal'; - } - }); - } - - // isElementVisible(fieldSet: CompositeField): boolean { - // return fieldSet && fieldSet.fields && fieldSet.fields.length > 0 - // } - - // next(compositeField: CompositeField) { - // this.formFocusService.focusNext(compositeField); - // } - visibleControls(controls: any[]) { - return controls.filter(control => this.visibilityRulesService.checkElementVisibility(control.get('id').value)); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html deleted file mode 100644 index 43c45f710..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html +++ /dev/null @@ -1,188 +0,0 @@ -
- - - - -
{{tocentry? tocentry.numbering :form.get('numbering').value}}. {{form.get('title').value}}
-
-
- -
-
- -
- - -
- -
-
- -
-
- -
-
-
-
- -
-
-
- - - {{compositeFieldFormGroup.get('multiplicity').value.placeholder}} - {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (compositeFieldFormGroup.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} - -
-
- - - - -
- -
-
- -
-
-
-
- -
-
-
-
-
-
- - - - - - - - - - - - - - - - -
- - -
- -
-
- -
- -
-
- -
-
- - - - - - - - - - - - - - -
{{fieldFormGroup.get('data').value.label}}
- - - {{fieldsetEntry.form.get('multiplicity').value.placeholder}} - {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (fieldsetEntry.form.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} - -
-
-
- -
-
-
-
- -
-
-
- - - {{fieldsetEntry.form.get('multiplicity').value.placeholder}} - {{('DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' + (fieldsetEntry.form.get('multiplicity').value.tableView?'-TABLEVIEW':'')) | translate}} - -
-
- - - - -
- -
-
- -
-
- -
- - - - -
- -
- -
-
-
-
- -
- -
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.scss deleted file mode 100644 index cb676cf4c..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.scss +++ /dev/null @@ -1,46 +0,0 @@ -.dynamic-form-section { - .expansion-panel { - // background-color: #eeeeee54; - background-color: white; - margin-top: 1em; - margin-bottom: 1em; - // margin-bottom: 1em; - } - .addOneFieldButton { - margin-top: -15px; - margin-left: -11px; - color: var(--primary-color); - } - .panel-title, - .panel-desc { - text-align: left; - font-weight: 700; - font-size: 1rem; - letter-spacing: 0px; - color: #212121; - opacity: 0.81; - margin-top: 1.625rem; - margin-bottom: 0.625rem; - } - - .panel-desc { - // text-transform: capitalize; - text-transform: none; - font-weight: 400; - margin-top: .5rem; - } -} -.styleBorder { - border: 0.2em solid lightgray; - border-radius: 0.5em; - margin-bottom: 0.5em; -} -.mat-expansion-panel-header-description { - padding-bottom: 18px; - color: black; -} - -::ng-deep .mat-expansion-panel-header { - height: auto !important; - min-height: 48px; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.ts deleted file mode 100644 index e9f44beba..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.ts +++ /dev/null @@ -1,276 +0,0 @@ -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - EventEmitter, - Input, - OnChanges, - OnInit, - Output, - SimpleChanges -} from '@angular/core'; -import {UntypedFormArray, UntypedFormGroup} from '@angular/forms'; -import {Rule} from '@app/core/model/dataset-profile-definition/rule'; -import {BaseComponent} from '@common/base/base.component'; -import {takeUntil} from 'rxjs/operators'; -import {DatasetDescriptionCompositeFieldEditorModel} from '../../dataset-description-form.model'; -import {ToCEntry, ToCEntryType} from '../../dataset-description.component'; -import {FormFocusService} from '../../form-focus/form-focus.service'; -import {LinkToScroll} from '../../tableOfContentsMaterial/table-of-contents'; -import {VisibilityRuleSource} from '../../visibility-rules/models/visibility-rule-source'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - - -@Component({ - selector: 'app-form-section', - templateUrl: './form-section.component.html', - styleUrls: ['./form-section.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class FormSectionComponent extends BaseComponent implements OnInit, OnChanges { - - //@Input() section: DatasetDescriptionSectionEditorModel; - @Input() datasetProfileId: String; - @Input() form: UntypedFormGroup; - @Input() tocentry: ToCEntry; - @Input() pathName: string; - @Input() path: string; - @Input() linkToScroll: LinkToScroll; - @Input() hiddenEntriesIds: string[] = []; - //trackByFn = (index, item) => item ? item['id'] : null; - panelExpanded = true; - // sub = true; - subsectionLinkToScroll: LinkToScroll; - - - @Output() askedToScroll = new EventEmitter(); - - tocentriesType = ToCEntryType; - @Input() TOCENTRY_ID_PREFIX = ""; - - constructor( - public visibilityRulesService: VisibilityRulesService, - private formFocusService: FormFocusService, - private changeDetector: ChangeDetectorRef - ) { - super(); - this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - this.changeDetector.markForCheck(); - }); - } - - ngOnInit() { - // if (this.section) { - // this.form = this.visibilityRulesService.getFormGroup(this.section.id); - // } - - if (this.tocentry) {//maybe not needed as well - this.form = this.tocentry.form as UntypedFormGroup; - } - this.initMultipleFieldsVisibility(); - } - - ngOnChanges(changes: SimpleChanges) { - - if (changes['linkToScroll']) { - if (changes['linkToScroll'].currentValue && changes['linkToScroll'].currentValue.section) { - - if (this.pathName === changes['linkToScroll'].currentValue.section) { - this.panelExpanded = true; - } else if (changes['linkToScroll'].currentValue.section.includes(this.pathName)) { - this.subsectionLinkToScroll = changes['linkToScroll'].currentValue; - this.panelExpanded = true; - } - } - } - } - - // ngAfterViewInit() { - // this.visibilityRulesService.triggerVisibilityEvaluation(); - // } - - setMultipleFieldVisibility(parentCompositeField, compositeField: DatasetDescriptionCompositeFieldEditorModel, idMappings: { old: string, new: string }[]) { - // ** COMPOSITE FIELD IS SHOWN OR HIDDEN FROM ANOTHER ELEMENT - const compositeFieldVisibilityDependencies = this.visibilityRulesService.getVisibilityDependency(parentCompositeField); - if (compositeFieldVisibilityDependencies && compositeFieldVisibilityDependencies.length) { - - compositeFieldVisibilityDependencies.forEach(x => { - const visRule: Rule = { - targetField: compositeField.id, - sourceField: x.sourceControlId, - requiredValue: x.sourceControlValue - } - this.visibilityRulesService.addNewRule(visRule); - }); - } - - // console.log('idMappings ', idMappings); - parentCompositeField.fields.forEach(element => { - // console.log(this.visibilityRulesService.getVisibilityDependency(element.id)); - const dependency = this.visibilityRulesService.getVisibilityDependency(element.id); - if (dependency && dependency.length) { - // * INNER VISIBILITY DEPENDENCIES - // * IF INNER INPUT HIDES ANOTHER INNER INPUT - const innerDependency = parentCompositeField.fields.reduce((innerD, currentElement) => { - const innerDependecies = dependency.filter(d => d.sourceControlId === currentElement.id); - return [...innerD, ...innerDependecies]; - }, []) as VisibilityRuleSource[]; - if (innerDependency.length) { - //Build visibility source - const updatedRules = innerDependency.map(x => { - const newId = idMappings.find(y => y.old === x.sourceControlId); - return {...x, sourceControlId: newId.new}; - }); - // const visRule: VisibilityRule = { - // targetControlId: idMappings.find(x => x.old === element.id).new, - // sourceVisibilityRules: updatedRules - // } - - - const rules = updatedRules.map(x => { - return { - requiredValue: x.sourceControlValue, - sourceField: x.sourceControlId, - targetField: idMappings.find(l => l.old === element.id).new, - type: '' - } as Rule; - }); - - rules.forEach(rule => { - this.visibilityRulesService.addNewRule(rule); - }) - - // this.visibilityRulesService.appendVisibilityRule(visRule); - } - - } - - - // * OUTER DEPENDENCIES - - // * IF INNER INPUT HIDES OUTER INPUTS - const innerIds = idMappings.map(x => x.old) as string[]; - - const outerTargets = this.visibilityRulesService.getVisibilityTargets(element.id).filter(x => !innerIds.includes(x)); - - outerTargets.forEach(target => { - - const outerRules = (this.visibilityRulesService.getVisibilityDependency(target) as VisibilityRuleSource[]).filter(x => x.sourceControlId === element.id); - const updatedRules = outerRules.map(x => { - return {...x, sourceControlId: idMappings.find(y => y.old === element.id).new}; - }); - - // const visRule: VisibilityRule = { - // targetControlId: target, - // sourceVisibilityRules: updatedRules - // } - - - const rules = updatedRules.map(x => { - return { - requiredValue: x.sourceControlValue, - sourceField: x.sourceControlId, - targetField: target, - type: '' - } as Rule; - }) - rules.forEach(rule => { - this.visibilityRulesService.addNewRule(rule); - }) - // this.visibilityRulesService.appendVisibilityRule(visRule); - }); - // * IF INNER INPUT IS HIDDEN BY OUTER INPUT - if (dependency && dependency.length) { - const fieldsThatHideInnerElement = dependency.filter(x => !innerIds.includes(x.sourceControlId)); - if (fieldsThatHideInnerElement.length) { - fieldsThatHideInnerElement.forEach(x => { - const visRule: Rule = { - targetField: idMappings.find(l => l.old === element.id).new, - sourceField: x.sourceControlId, - requiredValue: x.sourceControlValue - } - const shouldBeVisibile = this.visibilityRulesService.checkTargetVisibilityProvidedBySource(x.sourceControlId, element.id); - this.visibilityRulesService.addNewRule(visRule, shouldBeVisibile); - }); - } - } - // console.log(`for ${element.id} targets are`, outerTargets); - }); - } - - initMultipleFieldsVisibility() { - (this.form.get('compositeFields') as UntypedFormArray).controls.forEach(control => { - let parentCompositeField = (control as UntypedFormGroup).getRawValue(); - if (parentCompositeField.multiplicityItems && parentCompositeField.multiplicityItems.length > 0) { - parentCompositeField.multiplicityItems.forEach(compositeField => { - let idMappings: { old: string, new: string }[] = [{old: parentCompositeField.id, new: compositeField.id}]; - parentCompositeField.fields.forEach((field, index) => { - idMappings.push({ old: field.id, new: compositeField.fields[index].id }); - }); - this.setMultipleFieldVisibility(parentCompositeField, compositeField, idMappings); - }) - } - }); - } - - addMultipleField(fieldsetIndex: number) { - if(this.form.get('compositeFields').get('' + fieldsetIndex).disabled) { - return; - } - const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as UntypedFormGroup).getRawValue(); - const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))); - - const ordinal = multiplicityItemsArray.length ? multiplicityItemsArray.controls.reduce((ordinal, currentControl) => { - const currentOrdinal = currentControl.get('ordinal').value as number; - - if (currentOrdinal >= ordinal) { - return currentOrdinal + 1; - } - return ordinal as number; - }, 0) : 0; - const idMappings = [] as { old: string, new: string }[]; - const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, ordinal, idMappings); - - this.setMultipleFieldVisibility(compositeFieldToBeCloned, compositeField, idMappings); - multiplicityItemsArray.push(compositeField.buildForm()); - } - - deleteCompositeFieldFormGroup(compositeFildIndex: number) { - const numberOfItems = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').value.length; - for (let i = 0; i < numberOfItems; i++) { - const multiplicityItem = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').get('' + i).value; - this.form.get('compositeFields').get('' + compositeFildIndex).get('fields').get('' + i).patchValue(multiplicityItem); - } - ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(0); - } - - deleteMultipeFieldFromCompositeFormGroup(compositeFildIndex: number, fildIndex: number) { - const multiplicityItemsArray = ((this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))); - multiplicityItemsArray.removeAt(fildIndex); - multiplicityItemsArray.controls.forEach((control, i) => { - try { - control.get('ordinal').setValue(i); - } catch { - throw 'Could not find ordinal'; - } - }); - } - - // isElementVisible(fieldSet: CompositeField): boolean { - // return fieldSet && fieldSet.fields && fieldSet.fields.length > 0 - // } - - // next(compositeField: CompositeField) { - // this.formFocusService.focusNext(compositeField); - // } - - - onAskedToScroll(id: string) { - this.panelExpanded = true; - this.askedToScroll.emit(id); - } - - visibleControls(controls: any[]) { - return controls.filter(control => this.visibilityRulesService.checkElementVisibility(control.get('id').value)); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html deleted file mode 100644 index dc09daefb..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html +++ /dev/null @@ -1,25 +0,0 @@ -
- {{'DMP-EDITOR.DATASET-DESCRIPTION.INTRO' | translate}} -
-
- -
-
-
- -
-
- - {{pageFormGroup.get('title').value}} - -
- -
-
-
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.scss deleted file mode 100644 index 955e5fed6..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.scss +++ /dev/null @@ -1,31 +0,0 @@ -@media (max-width: 768px) { - .dynamic-form-editor { - .form-container { - padding: 0px; - } - } -} - -.form-container { -} - -.intro { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - opacity: 1; - margin: 3rem 0rem 3rem 0rem; -} - -.dynamic-form-editor { - mat-vertical-stepper { - background-color: #ffffff; - } -} - -.mat-step-header .mat-step-icon-selected, -.mat-step-header .mat-step-icon-state-done, -.mat-step-header .mat-step-icon-state-edit { - background-color: var(--primary-color) !important; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.ts deleted file mode 100644 index c4029e35d..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MatStepper } from '@angular/material/stepper'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { LinkToScroll } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { BaseComponent } from '@common/base/base.component'; - -@Component({ - selector: 'app-dataset-description-form', - templateUrl: './dataset-description-form.component.html', - styleUrls: ['./dataset-description-form.component.scss'] -}) -export class DatasetDescriptionFormComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges { - - @ViewChild('stepper') stepper: MatStepper; - @Input() path: string; - @Input() form: UntypedFormGroup; - @Input() visibilityRules: Rule[] = []; - @Input() datasetProfileId: String; - @Input() linkToScroll: LinkToScroll; - - constructor( - private visibilityRulesService: VisibilityRulesService, - ) { - super(); - } - - ngOnInit() { - this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.form); - } - - ngOnChanges(changes: SimpleChanges) { - - // When the form is changed set stepper index to 0. - if (this.stepper && changes['form'] && !changes['form'].isFirstChange()) { - this.stepper.selectedIndex = 0; - } else if (this.stepper && changes['linkToScroll'] && changes['linkToScroll'].currentValue) { - if (changes['linkToScroll'].currentValue.page >= 0) { - this.stepper.selectedIndex = changes['linkToScroll'].currentValue.page; - } - } - } - - ngAfterViewInit() { - - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts deleted file mode 100644 index 030196340..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ /dev/null @@ -1,375 +0,0 @@ -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, ValidatorFn, Validators } from "@angular/forms"; -import { Guid } from '@common/types/guid'; -import { ValidationType, ValidatorURL } from "../../../core/common/enum/validation-type"; -import { BaseFormModel } from "../../../core/model/base-form-model"; -import { CompositeField } from "../../../core/model/dataset-profile-definition/composite-field"; -import { DatasetProfileDefinitionModel } from "../../../core/model/dataset-profile-definition/dataset-profile-definition"; -import { DefaultValue } from "../../../core/model/dataset-profile-definition/default-value"; -import { Field } from "../../../core/model/dataset-profile-definition/field"; -import { Multiplicity } from "../../../core/model/dataset-profile-definition/multiplicity"; -import { Page } from "../../../core/model/dataset-profile-definition/page"; -import { Rule } from "../../../core/model/dataset-profile-definition/rule"; -import { Section } from "../../../core/model/dataset-profile-definition/section"; -import { ViewStyle } from "../../../core/model/dataset-profile-definition/view-style"; -import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; - -export class DatasetDescriptionFormEditorModel extends BaseFormModel { - - public status: number; - public pages: Array = []; - public rules: Rule[] = []; - public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - - fromModel(item: DatasetProfileDefinitionModel): DatasetDescriptionFormEditorModel { - this.status = item.status; - this.rules = item.rules; - if (item.pages) { item.pages.map(x => this.pages.push(new DatasetDescriptionPageEditorModel().fromModel(x))); } - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({ - rules: [{ value: this.rules, disabled: false }, BackendErrorValidator(this.validationErrorModel, 'rules')] - }); - const pagesFormArray = new Array(); - - this.pages.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - pagesFormArray.push(form); - }); - formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); - return formGroup; - } -} - -export class DatasetDescriptionPageEditorModel extends BaseFormModel { - public ordinal: number; - public title: string; - public sections: DatasetDescriptionSectionEditorModel[] = []; - - fromModel(item: Page): DatasetDescriptionPageEditorModel { - this.ordinal = item.ordinal; - this.title = item.title; - if (item.sections) { item.sections.map(x => this.sections.push(new DatasetDescriptionSectionEditorModel().fromModel(x))); } - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({}); - const sectionsFormArray = new Array(); - this.sections.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - sectionsFormArray.push(form); - }); - formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - formGroup.addControl('title', new UntypedFormControl({ value: this.title, disabled: true })); - formGroup.addControl('ordinal', new UntypedFormControl({ value: this.ordinal, disabled: true })); - return formGroup; - } -} - -export class DatasetDescriptionSectionEditorModel extends BaseFormModel { - - sections: Array = new Array(); - defaultVisibility: boolean; - page: number; - numbering: string; - ordinal: number; - id: string; - title: string; - description: string; - compositeFields: Array = new Array(); - - fromModel(item: Section): DatasetDescriptionSectionEditorModel { - if (item.sections) { item.sections.map(x => this.sections.push(new DatasetDescriptionSectionEditorModel().fromModel(x))); } - this.page = item.page; - this.defaultVisibility = item.defaultVisibility; - this.numbering = item.numbering; - this.id = item.id; - this.title = item.title; - this.ordinal = item.ordinal; - this.description = item.description; - if (item.compositeFields) { item.compositeFields.map(x => this.compositeFields.push(new DatasetDescriptionCompositeFieldEditorModel().fromModel(x))); } - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup: UntypedFormGroup = new UntypedFormBuilder().group({}); - const sectionsFormArray = new Array(); - if (this.sections) { - this.sections.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - sectionsFormArray.push(form); - }); - } - const compositeFieldsFormArray = new Array(); - if (this.compositeFields) { - this.compositeFields.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - compositeFieldsFormArray.push(form); - }); - } - formGroup.addControl('compositeFields', this.formBuilder.array(compositeFieldsFormArray)); - formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); - formGroup.addControl('description', new UntypedFormControl({ value: this.description, disabled: true })); - formGroup.addControl('numbering', new UntypedFormControl({ value: this.numbering, disabled: true })); - formGroup.addControl('title', new UntypedFormControl({ value: this.title, disabled: true })); - formGroup.addControl('id', new UntypedFormControl({ value: this.id, disabled: false })); - formGroup.addControl('ordinal', new UntypedFormControl({ value: this.ordinal, disabled: true })); - return formGroup; - } -} - -export class DatasetDescriptionCompositeFieldEditorModel extends BaseFormModel { - - fields: Array = new Array(); - ordinal: number; - id: string; - numbering: string; - multiplicity: DatasetDescriptionMultiplicityEditorModel; - multiplicityItems: DatasetDescriptionCompositeFieldEditorModel[] = []; - title: string; - description: string; - extendedDescription: string; - additionalInformation: string; - hasCommentField: boolean; - commentFieldValue: string; - - fromModel(item: CompositeField): DatasetDescriptionCompositeFieldEditorModel { - - if (item.fields) { item.fields.map(x => this.fields.push(new DatasetDescriptionFieldEditorModel().fromModel(x))); } - this.ordinal = item.ordinal; - this.id = item.id; - this.title = item.title; - this.numbering = item.numbering; - this.description = item.description; - this.extendedDescription = item.extendedDescription; - this.additionalInformation = item.additionalInformation; - this.hasCommentField = item.hasCommentField; - this.commentFieldValue = item.commentFieldValue; - if (item.multiplicity) this.multiplicity = new DatasetDescriptionMultiplicityEditorModel().fromModel(item.multiplicity); - if (item.multiplicityItems) { item.multiplicityItems.map(x => this.multiplicityItems.push(new DatasetDescriptionCompositeFieldEditorModel().fromModel(x))); } - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - id: this.id, - ordinal: this.ordinal, - extendedDescription: this.extendedDescription, - additionalInformation: this.additionalInformation, - hasCommentField: this.hasCommentField, - commentFieldValue: this.commentFieldValue, - multiplicity: [{ value: this.multiplicity, disabled: true }], - title: [{ value: this.title, disabled: true }], - description: [{ value: this.description, disabled: true }], - numbering: [{ value: this.numbering, disabled: true }], - }); - - const fieldsFormArray = new Array(); - this.fields.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - fieldsFormArray.push(form); - }); - formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); - - const multiplicityItemsFormArray = new Array(); - this.multiplicityItems.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - multiplicityItemsFormArray.push(form); - }); - formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray)); - - return formGroup; - } - - // cloneForMultiplicity(index: number): DatasetDescriptionCompositeFieldEditorModel { - // const newItem: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel(); - // newItem.id = 'multiple_' + this.id + '_' + index; - // this.fields.forEach(field => { - // newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + '_')); - // }); - // newItem.ordinal = this.ordinal; - // return newItem; - // } - - cloneForMultiplicity(item: CompositeField, ordinal: number, idMappings: { old: string, new: string }[] = []): DatasetDescriptionCompositeFieldEditorModel { - const newItem: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel(); - newItem.id = 'multiple_' + item.id + '_' + Guid.create() + '_' + ordinal; - - idMappings.push({ old: item.id, new: newItem.id }); - item.fields.forEach((field, index) => { - - const clonedItem = new DatasetDescriptionFieldEditorModel().cloneForMultiplicity(field, newItem.id) - newItem.fields.push(clonedItem); - - idMappings.push({ old: field.id, new: clonedItem.id }); - }); - newItem.ordinal = ordinal; - return newItem; - } -} - -export class DatasetDescriptionFieldEditorModel extends BaseFormModel { - - public id: string; - public title: string; - public value: any; - public defaultValue: DefaultValue; - public description: string; - public numbering: string; - public extendedDescription: string; - public additionalInformation: string; - public viewStyle: ViewStyle; - public defaultVisibility: boolean; - public page: number; - public multiplicity: DatasetDescriptionMultiplicityEditorModel; - public multiplicityItems: Array = new Array(); - public data: any; - public validations: Array; - public validationRequired = false; - public validationURL = false; - public ordinal: number; - - fromModel(item: Field): DatasetDescriptionFieldEditorModel { - this.id = item.id; - this.ordinal = item.ordinal; - this.title = item.title; - this.numbering = item.numbering; - this.description = item.description; - this.extendedDescription = item.extendedDescription; - this.additionalInformation = item.additionalInformation; - this.viewStyle = item.viewStyle; - this.defaultVisibility = item.defaultVisibility; - this.page = item.page; - this.validations = item.validations; - if (item.multiplicity) this.multiplicity = new DatasetDescriptionMultiplicityEditorModel().fromModel(item.multiplicity); - if (item.defaultValue) this.defaultValue = new DatasetDescriptionDefaultValueEditorModel().fromModel(item.defaultValue); - this.value = item.value ? item.value : (this.defaultValue.value ? this.defaultValue.value : undefined); - if (this.viewStyle.renderStyle === 'checkBox' && (item.value !== true)) { this.value = this.value === 'true'; } //Cover both posibilites of boolean true or false and string 'true' or 'false' - if (item.multiplicityItems) { item.multiplicityItems.map(x => this.multiplicityItems.push(new DatasetDescriptionFieldEditorModel().fromModel(x))); } - this.data = item.data; - return this; - } - - buildForm(): UntypedFormGroup { - if (this.validations) { - this.validations.forEach(validation => { - if (validation === ValidationType.Required) { - this.validationRequired = true; - } else if (validation === ValidationType.URL) { - this.validationURL = true; - } - }); - } - let validators: any[] = []; - if (this.validationRequired) { - validators.push(Validators.required) - } - if (this.validationURL) { - validators.push(ValidatorURL.validator); - } - const formGroup = this.formBuilder.group({ - value: [this.value, validators], - id: [{ value: this.id, disabled: false }], - viewStyle: [{ value: this.viewStyle, disabled: true }], - data: [{ value: this.data, disabled: true }], - validationRequired: [{ value: this.validationRequired, disabled: true }], - validationURL: [{ value: this.validationURL, disabled: true }], - description: [{ value: this.description, disabled: true }], - extendedDescription: [{ value: this.extendedDescription, disabled: true }], - additionalInformation: [{ value: this.additionalInformation, disabled: true }], - title: [{ value: this.title, disabled: true }], - defaultValue: [{ value: this.defaultValue, disabled: true }], - ordinal: [{ value: this.ordinal, disabled: true }] - }); - - const multiplicityItemsFormArray = new Array(); - this.multiplicityItems.forEach(item => { - const form: UntypedFormGroup = item.buildForm(); - multiplicityItemsFormArray.push(form); - }); - formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray)); - - return formGroup; - } - - // cloneForMultiplicity(index: number, idPath: string): DatasetDescriptionFieldEditorModel { - // const newItem: DatasetDescriptionFieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - // newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index; - // newItem.title = this.title; - // newItem.description = this.description; - // newItem.extendedDescription = this.extendedDescription; - // newItem.viewStyle = this.viewStyle; - // newItem.defaultVisibility = this.defaultVisibility; - // newItem.page = this.page; - // newItem.multiplicity = null; - // newItem.data = this.data; - - // return newItem; - // } - cloneForMultiplicity(item: Field, idPath: string): DatasetDescriptionFieldEditorModel { - const newItem: DatasetDescriptionFieldEditorModel = new DatasetDescriptionFieldEditorModel(); - - //newItem.id = idPath ? idPath : 'multiple_' + item.id + '_' + Guid.create(); - newItem.id = idPath ? idPath + '_' + item.id : 'multiple_' + Guid.create() + '_' + item.id; - newItem.title = item.title; - newItem.description = item.description; - newItem.extendedDescription = item.extendedDescription; - newItem.additionalInformation = item.additionalInformation; - newItem.viewStyle = item.viewStyle; - newItem.defaultVisibility = item.defaultVisibility; - newItem.page = item.page; - newItem.multiplicity = null; - newItem.data = item.data; - - return newItem; - } -} - - -export class DatasetDescriptionMultiplicityEditorModel extends BaseFormModel { - public min: number; - public max: number; - public placeholder: string; - public tableView: boolean; - - fromModel(item: Multiplicity): DatasetDescriptionMultiplicityEditorModel { - this.min = item.min; - this.max = item.max; - this.placeholder = item.placeholder; - this.tableView = item.tableView; - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - min: [this.min], - max: [this.max], - placeholder: [this.placeholder], - tableView: [this.tableView] - }); - return formGroup; - } -} - -export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { - public type: string; - public value: string; - - fromModel(item: DefaultValue): DatasetDescriptionDefaultValueEditorModel { - this.type = item.type; - this.value = item.value; - return this; - } - - buildForm(): UntypedFormGroup { - const formGroup = this.formBuilder.group({ - type: [this.type], - value: [this.value] - }); - return formGroup; - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.module.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.module.ts deleted file mode 100644 index 3df559ca9..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.module.ts +++ /dev/null @@ -1,68 +0,0 @@ -import {NgModule} from '@angular/core'; -import {AutoCompleteModule} from '@app/library/auto-complete/auto-complete.module'; -import { - FormCompositeFieldComponent -} from '@app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component'; -import {FormFieldComponent} from '@app/ui/misc/dataset-description-form/components/form-field/form-field.component'; -import { - FormSectionComponent -} from '@app/ui/misc/dataset-description-form/components/form-section/form-section.component'; -import { - DatasetDescriptionFormComponent -} from '@app/ui/misc/dataset-description-form/dataset-description-form.component'; -import {FormFocusService} from '@app/ui/misc/dataset-description-form/form-focus/form-focus.service'; -import {CommonFormsModule} from '@common/forms/common-forms.module'; -import {CommonUiModule} from '@common/ui/common-ui.module'; -import {FormCompositeTitleComponent} from './components/form-composite-title/form-composite-title.component'; -import {ExternalSourcesModule} from '../external-sources/external-sources.module'; -import {DatasetDescriptionComponent} from './dataset-description.component'; -import {FormProgressIndicationModule} from './components/form-progress-indication/form-progress-indication.module'; -import {FormSectionInnerComponent} from './components/form-section/form-section-inner/form-section-inner.component'; -import {RichTextEditorModule} from "@app/library/rich-text-editor/rich-text-editor.module"; -// import {TableEditorModule} from "@app/library/table-editor/table-editor.module"; -import {FileService} from "@app/core/services/file/file.service"; -import {NgxDropzoneModule} from "ngx-dropzone"; -import { - FormCompositeFieldDialogComponent -} from "@app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component"; -import {FormattingModule} from "@app/core/formatting.module"; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - AutoCompleteModule, - ExternalSourcesModule, - FormProgressIndicationModule, - RichTextEditorModule, - // TableEditorModule, - NgxDropzoneModule, - FormattingModule - ], - declarations: [ - DatasetDescriptionFormComponent, - DatasetDescriptionComponent, - FormSectionComponent, - FormSectionInnerComponent, - FormCompositeFieldComponent, - FormFieldComponent, - FormCompositeTitleComponent, - FormCompositeFieldDialogComponent - ], - exports: [ - DatasetDescriptionFormComponent, - DatasetDescriptionComponent, - FormCompositeFieldComponent, - FormFieldComponent, - FormSectionInnerComponent - ], - providers: [ - VisibilityRulesService, - FormFocusService, - FileService - ] -}) -export class DatasetDescriptionFormModule { } - diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.html deleted file mode 100644 index ca244cf88..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.html +++ /dev/null @@ -1,56 +0,0 @@ - - - -
-
-
-
-
- -
-
-
- -
-
-
-
- - - - - - - - - - -

- {{pageEntry.numbering}}. {{pageEntry.label |uppercase}} -

-
-
- - -
- -
-
-
-
-
-
- -
-
-
-
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.scss deleted file mode 100644 index 3b8872d71..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.scss +++ /dev/null @@ -1,47 +0,0 @@ -@media (max-width: 768px) { - .dynamic-form-editor { - .form-container { - padding: 0px; - } - } -} - -.form-container { -} - -.intro { - text-align: left; - font-weight: 400; - letter-spacing: 0px; - color: #212121; - opacity: 1; - margin: 3rem 0rem 3rem 0rem; -} - -.dynamic-form-editor { - mat-vertical-stepper { - background-color: #ffffff; - } -} - -// ::ng-deep .mat-form-field-flex > .mat-form-field-infix {padding: 0.4em 0px !important;} -// ::ng-deep .mat-form-field-label-wrapper { -// top: -1.5em; -// } - -// ::ng-deep -// .mat-form-field-appearance-outline.mat-form-field-can-float.mat-form-field-should-float -// .mat-form-field-label { -// transform: translateY(-1.1em) scale(0.75); -// width: 133.33333%; -// } - -// ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { -// background: #fafafa !important; -// } - -// ::ng-deep .mat-step-header .mat-step-icon-selected, -// .mat-step-header .mat-step-icon-state-done, -// .mat-step-header .mat-step-icon-state-edit { -// background-color: var(--primary-color) !important; -// } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts deleted file mode 100644 index 76910c75d..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts +++ /dev/null @@ -1,418 +0,0 @@ -import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild, Output, EventEmitter } from '@angular/core'; -import { AbstractControl, AbstractControlOptions, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { MatExpansionPanel } from '@angular/material/expansion'; -import { MatStepper } from '@angular/material/stepper'; -import { CompositeField } from '@app/core/model/dataset-profile-definition/composite-field'; -import { Field } from '@app/core/model/dataset-profile-definition/field'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { DatasetProfileTableOfContentsInternalSection } from '@app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section'; -import { LinkToScroll } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; -import { BaseComponent } from '@common/base/base.component'; -import { debounceTime, takeUntil } from 'rxjs/operators'; -import { VisibilityRuleSource } from './visibility-rules/models/visibility-rule-source'; - -@Component({ - selector: 'app-dataset-description', - templateUrl: './dataset-description.component.html', - styleUrls: ['./dataset-description.component.scss'] -}) -export class DatasetDescriptionComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges { - - // @ViewChild('stepper', { static: false }) stepper: MatStepper; - @Input() path: string; - @Input() visibilityRules: Rule[] = []; - @Input() datasetProfileId: String; - @Input() datasetDescription: String; - @Input() linkToScroll: LinkToScroll; - @Output() formChanged: EventEmitter = new EventEmitter(); - @Output() fieldsetFocusChange: EventEmitter = new EventEmitter(); - - tocentries: ToCEntry[]; - @Input() form: UntypedFormGroup; - - @Input() TOCENTRY_ID_PREFIX=""; - @Output() visibilityRulesInstance = new EventEmitter(); - - public hiddenEntriesIds:string[] = []; - - constructor( - private visibilityRulesService: VisibilityRulesService, - ) { - super(); - - } - - ngOnInit() { - this.init(); - } - - ngOnChanges(changes: SimpleChanges) { - this.init(); - // When the form is changed set stepper index to 0. - // if (this.stepper && changes['form'] && !changes['form'].isFirstChange()) { - // this.stepper.selectedIndex = 0; - // } else if (this.stepper && changes['linkToScroll'] && changes['linkToScroll'].currentValue) { - // if (changes['linkToScroll'].currentValue.page >= 0) { - // this.stepper.selectedIndex = changes['linkToScroll'].currentValue.page; - // } - // } - } - - ngAfterViewInit() { - - } - - init() { - this.tocentries = this.getTocEntries(); - const rules_to_append = this._enrichWithMultiplicityRules(this.tocentries); - - this.visibilityRulesService.buildVisibilityRules([...this.visibilityRules, ...rules_to_append ], this.form); - - // if (this.form) { - // this.form.valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(val => { - // this.formChanged.emit(val); - // }); - // } - this.visibilityRulesInstance.emit(this.visibilityRulesService); - - - - - this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries); - - this.visibilityRulesService.visibilityChange - .pipe( - takeUntil(this._destroyed), - debounceTime(100) - ) - .subscribe(_=>{ - this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries); - }) - } - - onAskedToScroll(panel: MatExpansionPanel, id?:string){ - panel.open(); - this.fieldsetFocusChange.emit(id); - } - - - - private _enrichWithMultiplicityRules(tocentries: ToCEntry[]) : Rule[] { - if (tocentries){ - return tocentries.map(entry => { - if(entry.type === ToCEntryType.Field) return []; // * TODO Me to tora implementation den tha ftasei pote edo - - - if(entry.type === ToCEntryType.FieldSet){ - // if(multiplicity: ) - try { - // TODO OTAN KANW HIDE MULTIPLE PEDIO TOTE STO ON SHOW HANO TA VALUES (AUTO MPOREI NA EINAI KAI LEGIT) ('NA DOUME AN ONTOS DIAGRAFONTAI I APLA DEN TA DEIXNOUME') - // * UPDATE KANEI DESTROY TO COMPONENT H NGIF . PITHANOTATA NA XREIASTEI NA TO KANOUME HIDDEN AN THELOUME KATI ALLO - const multiplicity = entry.form.get('multiplicity').value; - if( (multiplicity.max > 1 ) && (multiplicity.min> 0) && (multiplicity.max >= multiplicity.min)){ // has valid multiplicity - return this._createAndAppendVisibilityRule(entry); - } - } catch { - - } - return []; - } - - if(entry.subEntries){ - return this._enrichWithMultiplicityRules(entry.subEntries); - } - }) - .reduce((r,c)=>{ return [...c, ...r]},[]); - } - return []; - } - - private _createAndAppendVisibilityRule(entry: ToCEntry): Rule[]{ - - - const rules_to_append = []; - - if(entry && (entry.type === ToCEntryType.FieldSet)){ - - //childs that are either target or source - const childIdsWithVisRules = (entry.form.get('fields') as UntypedFormArray).controls.reduce((all, s) => - { - const sval = s.value as Field; - return this.visibilityRules.find(x => (x.targetField === sval.id) || (x.sourceField === sval.id)) ? [...all, sval] : all; - },[]) as Field[]; - - - const innerCompositeFieldOriginalIds = (entry.form.get('fields') as UntypedFormArray).controls.map( x=> x.get('id').value) as string[]; - - //multiplicity items - const multiplicityItemsValue = entry.form.get('multiplicityItems').value as CompositeField[]; - - - // ********* FIELDS OF FIELDSET ARE EITHER TARGETS OR SOURCES ***** - - - if( childIdsWithVisRules.length && multiplicityItemsValue && multiplicityItemsValue.length ){ - //check each multiplicity item composite field - multiplicityItemsValue.forEach( mi =>{ - - const multiplicityCompositeFieldIds = mi.fields.map(x => x.id); - const idMappings = multiplicityCompositeFieldIds.map(x => { - return { - original: innerCompositeFieldOriginalIds.find( l => x.includes(l)), - multiplicityIdValue: x - } - }) as {original: string, multiplicityIdValue: string}[]; - - //each field of mutliplicity item - mi.fields.forEach(field =>{ - - - //get original visibility rules (original field) - - //original id - const original_id = childIdsWithVisRules.find(x=> field.id.includes(x.id)).id; - - - //get vis rules - - //as source - const original_as_source = this.visibilityRules.filter( x => x.sourceField === original_id); - const original_as_target = this.visibilityRules.filter( x => x.targetField === original_id); - - - - if(original_as_source.length){ - - //inner dependencies - const innerDep = original_as_source.filter(x => innerCompositeFieldOriginalIds.includes(x.targetField)); - innerDep.forEach(x =>{ - const newRule = {...x, sourceField: field.id, targetField: idMappings.find(l => l.original === x.targetField).multiplicityIdValue} as Rule; - rules_to_append.push(newRule); - }) - - - //outer dependencies - const outerDep = original_as_source.filter(x => !innerCompositeFieldOriginalIds.includes(x.targetField)); - outerDep.forEach(x =>{ - const newRule = {...x, sourceField: field.id}; - rules_to_append.push(newRule); - }) - } - - - - if( original_as_target.length){ - - //inner dependencies - const innerDep = original_as_target.filter( x=> innerCompositeFieldOriginalIds.includes(x.sourceField)); - innerDep.forEach(x =>{ - const newRule = {...x, targetField: field.id, sourceField: idMappings.find(l => l.original === x.sourceField).multiplicityIdValue} as Rule; - rules_to_append.push(newRule); - }) - - //outer dependencies - const outerDep = original_as_target.filter( x=> !innerCompositeFieldOriginalIds.includes(x.sourceField)); - outerDep.forEach(x=>{ - const newRule = {...x, targetField: field.id} as Rule; - rules_to_append.push(newRule); - }) - } - - }) - }); - } - - - - - // ** FIELDSET ITSELF IS TARGET - // ** source it can never be - - const compositeFieldAsTargetRules = this.visibilityRules.filter(x => x.targetField === entry.id); - const idCompositeFieldMappings = multiplicityItemsValue.map(x =>{ - return { - originalValue: entry.id, - newValue:x.id - } - }) as {originalValue: string, newValue: string}[]; - - - if(compositeFieldAsTargetRules.length){ - - compositeFieldAsTargetRules.forEach(x =>{ - idCompositeFieldMappings.forEach(l=>{ - const newRule = {...x, targetField: l.newValue}; - rules_to_append.push(newRule); - }); - }); - } - - - } - - return rules_to_append; - } - - private _buildRecursively(form: UntypedFormGroup,whatAmI:ToCEntryType):ToCEntry{ - if(!form) return null; - - switch(whatAmI){ - case ToCEntryType.Section: - const sections = form.get('sections') as UntypedFormArray; - const fieldsets = form.get('compositeFields') as UntypedFormArray; - - - const tempResult:ToCEntry[] = []; - - if(sections &§ions.length){ - sections.controls.forEach(section=>{ - tempResult.push(this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section)); - }); - - }else if(fieldsets && fieldsets.length){ - fieldsets.controls.forEach(fieldset=>{ - tempResult.push(this._buildRecursively(fieldset as UntypedFormGroup, ToCEntryType.FieldSet)); - }); - } - return { - form: form, - id: form.get('id').value, - label: form.get('title').value, - numbering: '', - subEntries:tempResult, - subEntriesType: sections &§ions.length? ToCEntryType.Section: ToCEntryType.FieldSet, - type: ToCEntryType.Section, - ordinal: form.get('ordinal').value - } - case ToCEntryType.FieldSet: - return { - form: form, - label:form.get('title').value, - id: form.get('id').value, - numbering:'s', - subEntries:[], - subEntriesType: ToCEntryType.Field, - type: ToCEntryType.FieldSet, - ordinal: form.get('ordinal').value - } - } - } - - private _sortByOrdinal(tocentries: ToCEntry[]){ - - if(!tocentries || !tocentries.length) return; - - tocentries.sort(this._customCompare); - tocentries.forEach(entry=>{ - this._sortByOrdinal(entry.subEntries); - }); - } - - private _customCompare(a,b){ - return a.ordinal - b.ordinal; - } - - private _calculateNumbering(tocentries: ToCEntry[], depth:number[] = []){ - if(!tocentries || !tocentries.length){ - return; - } - - let prefixNumbering = depth.length? depth.join('.'): ''; - - if(depth.length) prefixNumbering = prefixNumbering+"."; - tocentries.forEach((entry,i)=>{ - entry.numbering = prefixNumbering + (i+1); - this._calculateNumbering(entry.subEntries, [...depth, i+1]) - }); - } - - getTocEntries(): ToCEntry[] { - if (!this.form) { return []; } - const result: ToCEntry[] = []; - - //build parent pages - (this.form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { - result.push({ - id: i+'id', - label: pageElement.get('title').value, - type: ToCEntryType.Page, - form: pageElement, - numbering: (i + 1).toString(), - subEntriesType: ToCEntryType.Section, - subEntries:[], - ordinal: pageElement.get('ordinal').value - } as ToCEntry) - }); - - - - result.forEach((entry,i)=>{ - - const sections = entry.form.get('sections') as UntypedFormArray; - - sections.controls.forEach(section=>{ - const tempResults = this._buildRecursively(section as UntypedFormGroup,ToCEntryType.Section); - entry.subEntries.push(tempResults); - }); - - }); - - this._sortByOrdinal(result); - //calculate numbering - this._calculateNumbering(result); - return result; - - } - private _findHiddenEntries(tocentries:ToCEntry[]):string[]{ - if(!tocentries) return []; - - const invisibleEntries:string[] = [] - tocentries.forEach(entry=>{ - if(entry.type === ToCEntryType.FieldSet){ - const isVisible = this.visibilityRulesService.checkElementVisibility(entry.id); - if(!isVisible){ - invisibleEntries.push(entry.id); - }else{ - //check field inputs - const fields = entry.form.get('fields') as UntypedFormArray; - - const oneFieldAtLeastIsVisible = fields.controls.some(field=> this.visibilityRulesService.checkElementVisibility(field.get('id').value)); - if(!oneFieldAtLeastIsVisible){ - invisibleEntries.push(entry.id); - } - } - }else{ - const hiddenEntries = this._findHiddenEntries(entry.subEntries); - - if(entry.subEntries&& (entry.subEntries.every(e=> hiddenEntries.includes(e.id)))){ - //all children all hidden then hide parent node; - invisibleEntries.push(entry.id); - }else{ - invisibleEntries.push(...hiddenEntries); - } - } - }) - - return invisibleEntries; - } - -} -export interface ToCEntry { - id: string; - label: string; - subEntriesType: ToCEntryType; - subEntries: ToCEntry[]; - type: ToCEntryType; - form: AbstractControl; - numbering: string; - ordinal: number; -} -export enum ToCEntryType { - Page = 0, - Section = 1, - FieldSet = 2, - Field = 3 -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/form-focus/form-focus.service.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/form-focus/form-focus.service.ts deleted file mode 100644 index 83ac3113b..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/form-focus/form-focus.service.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { Pair } from '../../../../../common/types/pair'; -import { CompositeField } from '../../../../core/model/dataset-profile-definition/composite-field'; -import { groupBy } from 'lodash'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - -@Injectable() -export class FormFocusService { - - private compositeFields: Pair[] = []; - - constructor( - private router: Router, - private route: ActivatedRoute, - private visibilityService: VisibilityRulesService - ) { - - } - - setFields(compositeFields: Pair[]) { - this.compositeFields = compositeFields; - } - - focusNext(field: CompositeField) { - const flattenedCompositeFields = groupBy(this.compositeFields, x => x.right) - .map(x => x.reduce((first: Pair, second: Pair) => - (new Pair(first.left.concat(second.left), first.right)))); - const page = flattenedCompositeFields.filter(x => x['left'].map(y => y.id).indexOf(field.id) !== -1)[0]; - let pageIndex = page['right']; - const currentFields = page['left'].filter(x => this.visibilityService.checkElementVisibility(x.id)).map(x => x.id); - const fieldIndex = currentFields.indexOf(field.id); - if (fieldIndex === currentFields.length - 1) { pageIndex = pageIndex + 1; } - this.router.navigate(['datasets/' + this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { fragment: page['left'].filter(x => this.visibilityService.checkElementVisibility(x.id))[fieldIndex].id, queryParams: { page: pageIndex } }); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.html deleted file mode 100644 index 8f25dd2bf..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.ts deleted file mode 100644 index 59628e26d..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/helpers/dynamic-form-pending-questions/dynamic-form-pending-questions-display.component.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import { CompositeField } from '../../../../../core/model/dataset-profile-definition/composite-field'; -import { DatasetProfileDefinitionModel } from '../../../../../core/model/dataset-profile-definition/dataset-profile-definition'; -import { Rule } from '../../../../../core/model/dataset-profile-definition/rule'; -import { Section } from '../../../../../core/model/dataset-profile-definition/section'; -import { DatasetWizardModel } from '../../../../../core/model/dataset/dataset-wizard'; -import { MarkForConsiderationService } from '../../mark-for-consideration/mark-for-consideration.service'; -import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; - -// @Component({ -// selector: 'app-dynamic-form-pending-questions-display', -// templateUrl: './dynamic-form-pending-questions-display.component.html', -// styleUrls: ['./dynamic-form-pending-questions-display.component.scss'] -// }) -export class DynamicFormPendingQuestionsDisplayComponent implements OnInit { - - constructor( - private visibilityRulesService: VisibilityRulesService, - public markForConsideration: MarkForConsiderationService) { - } - - datasetProfileDefinitionModel: DatasetProfileDefinitionModel; - - @Input() - form: FormGroup; - - @Input() dataModel: DatasetWizardModel; - - fields: CompositeField[]; - - ngOnInit(): void { - const rules: Rule[] = this.dataModel.datasetProfileDefinition.rules; - this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition; - const sections: Section[] = this.datasetProfileDefinitionModel.pages.flatMap(page => page.sections).filter(x => x); - const compositeFields: CompositeField[] = sections.flatMap(section => section.compositeFields).filter(x => x); - const nestedSections: Section[] = sections.flatMap(section => section.sections).filter(x => x); - const nestedCompositeFiels: CompositeField[] = nestedSections.flatMap(section => section.compositeFields).filter(x => x); - const compositeFieldsUnion = compositeFields.concat(nestedCompositeFiels); - //const fields: Field[] = compositeFields.flatMap(composite => composite.fields).concat(nestedCompositeFiels.flatMap(composite => composite.fields)); - // const fields = compositeFieldsUnion.filter(compositeField => this.visibilityRulesService.checkElementVisibility(compositeField.id)) - // .filter(compositeField => compositeField.fields.filter(x => x && x.validationRequired && this.visibilityRulesService.getFormGroup(x.id).value == null).length > 0); - // fields.forEach(x => this.markForConsideration.markForConsideration(x)); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/mark-for-consideration/mark-for-consideration.service.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/mark-for-consideration/mark-for-consideration.service.ts deleted file mode 100644 index 30673abeb..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/mark-for-consideration/mark-for-consideration.service.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Injectable } from '@angular/core'; -import { CompositeField } from '../../../../core/model/dataset-profile-definition/composite-field'; - -@Injectable() -export class MarkForConsiderationService { - - private compositeFields: CompositeField[] = []; - - markForConsideration(field: CompositeField) { - if (this.exists(field)) { - this.compositeFields.push(field); - } - } - - getFields() { - return this.compositeFields; - } - - exists(field: CompositeField) { - return this.compositeFields.map(x => x.id).indexOf(field.id) === -1; - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/base-table-of-content.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/base-table-of-content.component.ts deleted file mode 100644 index 05a0bd107..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/base-table-of-content.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router'; - -export class BaseTableOfContent { - constructor(public router: Router, public route: ActivatedRoute) { } - - scrollToId(elementId, page: number) { - //this.paginationService.setCurrentIndex(page-1); - this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } }); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-field/table-of-content-field.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-field/table-of-content-field.component.html deleted file mode 100644 index 991aa1a51..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-field/table-of-content-field.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-field/table-of-content-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-field/table-of-content-field.component.ts deleted file mode 100644 index 85af69dcb..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-field/table-of-content-field.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { Field } from '../../../../../core/model/dataset-profile-definition/field'; -import { BaseTableOfContent } from '../base-table-of-content.component'; - - -// @Component({ -// selector: 'app-table-of-contents-field', -// templateUrl: './table-of-content-field.component.html' -// }) -export class TableOfContentsFieldComponent extends BaseTableOfContent { - @Input() model: Field; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - constructor(public router: Router, public route: ActivatedRoute, ) { - super(router, route); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html deleted file mode 100644 index 0e42a2a00..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts deleted file mode 100644 index e3b181e94..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { CompositeField } from '../../../../../core/model/dataset-profile-definition/composite-field'; -import { BaseTableOfContent } from '../base-table-of-content.component'; - -// @Component({ -// selector: 'app-table-of-contents-fieldset', -// templateUrl: './table-of-content-fieldset.component.html' -// }) -export class TableOfContentsFieldSetComponent extends BaseTableOfContent { - - @Input() model: CompositeField; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - constructor(public router: Router, public route: ActivatedRoute) { - super(router, route); - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-group/table-of-content-group.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-group/table-of-content-group.component.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-group/table-of-content-group.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-group/table-of-content-group.component.ts deleted file mode 100644 index 6b1a5428c..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-group/table-of-content-group.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -// import { Component, Input } from '@angular/core'; -// import { ActivatedRoute, Router } from '@angular/router'; -// import { BaseTableOfContent } from '../base-table-of-content.component'; - -// @Component({ -// selector: 'app-table-of-contents-group', -// templateUrl: './table-of-content-group.component.html' -// }) -// export class TableOfContentsGroupComponent extends BaseTableOfContent { - -// @Input() model: FieldGroup; -// @Input() index: number; -// @Input() public path: string; -// @Input() public page: number; -// /* @Output() -// setPage:EventEmitter = new EventEmitter(); - -// */ -// constructor(public router: Router, public route: ActivatedRoute) { -// super(router, route); -// } - - -// } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-section/table-of-content-section.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-section/table-of-content-section.component.html deleted file mode 100644 index 8c8c36131..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-section/table-of-content-section.component.html +++ /dev/null @@ -1,10 +0,0 @@ - -{{path + ' ' + model.title}} - - - -
    -
  • - -
  • -
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-section/table-of-content-section.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-section/table-of-content-section.component.ts deleted file mode 100644 index 2819e461f..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-content-section/table-of-content-section.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { Section } from '../../../../../core/model/dataset-profile-definition/section'; -import { BaseTableOfContent } from '../base-table-of-content.component'; - -// @Component({ -// selector: 'app-table-of-contents-section', -// templateUrl: './table-of-content-section.component.html' -// }) -export class TableOfContentsSectionComponent extends BaseTableOfContent implements OnInit { - - @Input() model: Section; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - constructor(public router: Router, public route: ActivatedRoute) { - super(router, route); - } - ngOnInit() { - - } - -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-contents.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-contents.component.html deleted file mode 100644 index d4bf4f719..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-contents.component.html +++ /dev/null @@ -1,7 +0,0 @@ - -
    -
  • - - -
  • -
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-contents.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-contents.component.ts deleted file mode 100644 index ffb9c7fc3..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/table-of-contents.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { DatasetProfileDefinitionModel } from '../../../../core/model/dataset-profile-definition/dataset-profile-definition'; - -// @Component({ -// selector: 'app-table-of-content', -// templateUrl: './table-of-contents.component.html', -// styleUrls: ['./toc.component.css'] -// }) -export class TableOfContentsComponent implements OnInit { - - @Input() - public model: DatasetProfileDefinitionModel; - public path = ''; - - ngOnInit() { - - } - -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/toc.component.css b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/toc.component.css deleted file mode 100644 index 50768fefa..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContents/toc.component.css +++ /dev/null @@ -1,10 +0,0 @@ -.cursor-hand{ - cursor: pointer; -} - -.toc-toggler { - position: absolute; - left: 0%; - top: 50%; - transform: translate(-50%, -50%); -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html deleted file mode 100644 index f78625aa2..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html +++ /dev/null @@ -1,49 +0,0 @@ -
- - - - - - - - - {{entry.numbering}}. {{entry.label}} - - - - - -
- - - -
-
- - - -
- -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.scss deleted file mode 100644 index 91152786d..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.scss +++ /dev/null @@ -1,33 +0,0 @@ - -.internal-table{ - margin-left: 1em; - padding-left: 0.2rem; - -} -.table-entry{ - - text-overflow: ellipsis; - overflow: hidden; - padding-left: 0.2rem; - color: rgba(0, 0, 0, 0.54); - transition: color 100ms; - - display: block; - span{ - white-space: nowrap; - } -} - -.table-entry:hover{ - background-color: #ececec; - border-radius: 6px; -} -.selected { - color: #212121 !important; - font-weight: 700 !important; - opacity: 1 !important; -} - -.section{ - line-height: 1.7em; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.ts deleted file mode 100644 index 4290acae2..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.ts +++ /dev/null @@ -1,165 +0,0 @@ -import {Component, EventEmitter, Inject, OnInit, Output, Input, ViewChildren, QueryList} from '@angular/core'; -import { SimpleChanges } from '@angular/core'; -import { UntypedFormArray } from '@angular/forms'; -import { ToCEntry, ToCEntryType } from '../../dataset-description.component'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - -@Component({ - selector: 'table-of-contents-internal', - styleUrls: ['./table-of-contents-internal.scss'], - templateUrl: './table-of-contents-internal.html' -}) -export class TableOfContentsInternal implements OnInit { - - @Input() tocentries: ToCEntry[] = null; - @Input() selected: ToCEntry = null; - // @Input() visibilityRules:Rule[] = []; - @Output() entrySelected = new EventEmitter(); - - expandChildren:boolean[]; - tocEntryTypeEnum = ToCEntryType; - @Input() TOCENTRY_ID_PREFIX=""; - @Input() showErrors: boolean = false; - @Input() hiddenEntries: string[] =[]; - @Input() visibilityRulesService: VisibilityRulesService; - @ViewChildren(TableOfContentsInternal) internalTables: QueryList; - - constructor(){ - } - ngOnInit(): void { - // console.log('component created'); - if(this.tocentries){ - this.expandChildren = this.tocentries.map(()=>false); - if(this.selected){ - for(let i=0; i 0) { - // this.links.forEach(link => { - // link.selected = false; - // }) - // this.links[0].selected = true; - // } - } - - toggleExpand(index){ - this.expandChildren[index] = !this.expandChildren[index]; - // console.log(this.expandChildren); - } - - navigateToFieldSet(entry:ToCEntry, event){ - if(entry.type === ToCEntryType.FieldSet){ - - const fieldSetId = entry.id; - const element = document.getElementById(this.TOCENTRY_ID_PREFIX+fieldSetId); - if(element){ - element.click();//open mat expansion panel - - //scroll asyn in 200 ms so the expansion panel is expanded and the element coordinates are updated - setTimeout(() => { - const element = document.getElementById(this.TOCENTRY_ID_PREFIX+fieldSetId); - if(element){ - element.scrollIntoView({behavior:'smooth'}); - } - }, 300); - } - - } - } - - - onEntrySelected(entry:ToCEntry){ - this.entrySelected.emit(entry); - } - - - calculateStyle(entry: ToCEntry){ - const style = {}; - style['font-size'] = entry.type ===this.tocEntryTypeEnum.FieldSet? '.9em': '1em'; - return style; - } - - calculateClass(entry:ToCEntry){ - const myClass= {}; - - if(this.selected && entry.id === this.selected.id){ - myClass['selected'] = true; - } - - if(entry.type != this.tocEntryTypeEnum.FieldSet){ - myClass['section'] = true; - } - - return myClass; - } - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ - if(!tocentries || !tocentries.length){ - return null; - } - - let tocEntryFound = tocentries.find(entry=>entry.id === id); - - if(tocEntryFound){ - return tocEntryFound; - } - - for(let entry of tocentries){ - const result = this._findTocEntryById(id, entry.subEntries); - if(result){ - tocEntryFound = result; - break; - } - } - - return tocEntryFound? tocEntryFound: null; - } - public invalidChildsVisible(entry: ToCEntry):boolean { - if(!entry || !this.visibilityRulesService){ - return false; - } - - if(entry.type!= this.tocEntryTypeEnum.FieldSet){ - return entry.subEntries.some(_ => this.invalidChildsVisible(_)); - } - if(entry.type === this.tocEntryTypeEnum.FieldSet){ - const id = entry.form.get('id').value - if(!this.visibilityRulesService.checkElementVisibility(id)){ - return false; - } - const fieldsArray = entry.form.get('fields') as UntypedFormArray; - const hasError = !fieldsArray.controls.every(field=>{//every invalid field should be invisible - if(field.invalid){ - const id = field.get('id').value; - const isVisible = this.visibilityRulesService.checkElementVisibility(id); - if(isVisible){ - return false; - } - } - return true; - }); - return hasError; - } - return false; - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.html deleted file mode 100644 index 6a10aeaac..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.html +++ /dev/null @@ -1,40 +0,0 @@ -
- - - -
- - {{link.name}} - - -
-
- - - -
- -
- - - -
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module.ts deleted file mode 100644 index 47b3a1069..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {CommonModule} from '@angular/common'; -import {NgModule} from '@angular/core'; -import {TableOfContents} from './table-of-contents'; -import {RouterModule} from '@angular/router'; -import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal'; -import { MatIconModule } from '@angular/material/icon'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - -@NgModule({ - imports: [CommonModule, RouterModule, MatIconModule], - declarations: [TableOfContents, TableOfContentsInternal], - exports: [TableOfContents], - providers: [VisibilityRulesService] -}) -export class TableOfContentsModule { } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.scss b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.scss deleted file mode 100644 index 7dbc877af..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.scss +++ /dev/null @@ -1,80 +0,0 @@ -.docs-toc-container { - width: 100%; - padding: 5px 0 10px 0px; - cursor: pointer; - // border-left: solid 4px #0c7489; - - .scroll-container { - overflow-y: auto; - // calc(100vh - 250px) - // height: calc(100vh - 250px); - } - - .docs-link { - color: rgba(0, 0, 0, 0.54); - // color: mat-color($app-blue-theme-foreground, secondary-text); - transition: color 100ms; - - &:hover, - &.docs-active { - .link-name { - background-color: #ececec; - border-radius: 6px; - // color: #0c7489; - } - // color: mat-color($primary, if($is-dark-theme, 200, default)); - } - } -} - -.docs-toc-heading { - margin: 0; - padding: 0; - font-size: 13px; - font-weight: bold; -} - -span { - line-height: 16px; - margin: 6px 0 0; - position: relative; - text-decoration: none; - display: block; - overflow: hidden; - color: #21212194; - font-weight: 400; - max-width: 290px; - min-width: 290px; - padding: 0rem .4rem; - span { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - display: inline-block; - width: 100%; - } -} - -.selected { - color: #212121 !important; - font-weight: 700 !important; - opacity: 1 !important; -} - -// .docs-level-mat-expansion-panel { -// margin-left: 12px; -// } - -.docs-level-h5 { - margin-left: 24px; -} - -// .internal-table-outer{ -// padding-left: 1.1em; -// width: 100%; -// } - -.internal-table{ - max-width: 320px; - min-width: 320px; -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts deleted file mode 100644 index cc65be560..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts +++ /dev/null @@ -1,512 +0,0 @@ -import { DOCUMENT } from '@angular/common'; -import { Component, EventEmitter, Inject, OnInit, Output, Input, OnChanges, ViewChild } from '@angular/core'; -import { BaseComponent } from '@common/base/base.component'; -import { interval, Subject, Subscription } from 'rxjs'; -import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; -import { type } from 'os'; -import { SimpleChanges } from '@angular/core'; -import { ToCEntry, ToCEntryType } from '../dataset-description.component'; -import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -import { Rule } from '@app/core/model/dataset-profile-definition/rule'; -import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal'; -import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; - -export interface Link { - /* id of the section*/ - id: string; - /* header type h3/h4 */ - type: string; - /* If the anchor is in view of the page */ - active: boolean; - /* name of the anchor */ - name: string; - /* top offset px of the anchor */ - top: number; - page: number; - section: number; - show: boolean; - selected: boolean; -} - -@Component({ - selector: 'table-of-contents', - styleUrls: ['./table-of-contents.scss'], - templateUrl: './table-of-contents.html' -}) -export class TableOfContents extends BaseComponent implements OnInit, OnChanges { - - @ViewChild('internalTable') internalTable: TableOfContentsInternal; - - - @Input() links: Link[]; - container: string; - headerSelectors = '.toc-page-header, .toc-section-header, .toc-compositeField-header'; - @Output() stepFound = new EventEmitter(); - @Output() currentLinks = new EventEmitter(); - @Output() entrySelected = new EventEmitter(); - subscription: Subscription; - linksSubject: Subject = new Subject(); - - @Input() isActive: boolean; - - tocentries: ToCEntry[] = null; - @Input() TOCENTRY_ID_PREFIX = ''; - // visibilityRules:Rule[] = []; - @Input() visibilityRules: Rule[] = []; - @Input() showErrors: boolean = false; - @Input() selectedFieldsetId: string; - - private _tocentrySelected: ToCEntry = null; - private isSelecting: boolean = false; - private _intersectionObserver: IntersectionObserver; - private _actOnObservation: boolean = true; - public hiddenEntries: string[] = []; - get tocentrySelected() { - return this.hasFocus ? this._tocentrySelected : null; - } - set tocentrySelected(value) { - this._tocentrySelected = value; - } - - @Input() formGroup: UntypedFormGroup; - @Input() hasFocus: boolean = false; - @Input() visibilityRulesService: VisibilityRulesService; - show: boolean = false; - - constructor( - @Inject(DOCUMENT) private _document: Document, - // public visibilityRulesService: VisibilityRulesService - ) { - super(); - } - - - ngOnInit(): void { - - // this.visibilityRulesService.visibilityChange - // .pipe(takeUntil(this._destroyed)) - // .pipe(debounceTime(200)) - // .subscribe(_=>{ - // if(this.hasFocus){ - // this._resetObserver(); - // this.hiddenEntries = this._findHiddenEntries(this.tocentries); - // } - // }) - - if (this.formGroup) { - this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition')); - const fg = this.formGroup.get('datasetProfileDefinition'); - // this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, fg); - if (this.visibilityRulesService) { - this.hiddenEntries = this._findHiddenEntries(this.tocentries); - } - - } else { - - //emit value every 500ms - const source = interval(500); - this.subscription = source.subscribe(val => { - const headers = Array.from(this._document.querySelectorAll(this.headerSelectors)) as HTMLElement[]; - this.linksSubject.next(headers); - }); - - if (!this.links || this.links.length === 0) { - this.linksSubject.asObservable() - .pipe(distinctUntilChanged((p: HTMLElement[], q: HTMLElement[]) => JSON.stringify(p) == JSON.stringify(q))) - .subscribe(headers => { - const links: Array = []; - - if (headers.length) { - let page; - let section; - let show - for (const header of headers) { - let name; - let id; - if (header.classList.contains('toc-page-header')) { // deprecated after removing stepper - name = header.innerText.trim().replace(/^link/, ''); - id = header.id; - page = header.id.split('_')[1]; - section = undefined; - show = true; - } else if (header.classList.contains('toc-section-header')) { - name = header.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue.trim().replace(/^link/, ''); - id = header.id; - page = header.id.split('.')[1]; - section = header.id; - if (header.id.split('.')[4]) { show = false; } - else { show = true; } - } else if (header.classList.contains('toc-compositeField-header')) { - name = (header.childNodes[0]).nodeValue.trim().replace(/^link/, ''); - id = header.id; - // id = header.parentElement.parentElement.parentElement.id; - show = false; - } - const { top } = header.getBoundingClientRect(); - links.push({ - name, - id, - type: header.tagName.toLowerCase(), - top: top, - active: false, - page: page, - section: section, - show: show, - selected: false - }); - } - } - this.links = links; - // Initialize selected for button next on dataset wizard component editor - this.links.length > 0 ? this.links[0].selected = true : null; - }) - } - } - - } - - private _findHiddenEntries(tocentries: ToCEntry[]): string[] { - if (!tocentries) return []; - - const invisibleEntries: string[] = [] - tocentries.forEach(entry => { - if (entry.type === ToCEntryType.FieldSet) { - const isVisible = this.visibilityRulesService.checkElementVisibility(entry.id); - if (!isVisible) { - invisibleEntries.push(entry.id); - } else { - //check field inputs - const fields = entry.form.get('fields') as UntypedFormArray; - - const oneFieldAtLeastIsVisible = fields.controls.some(field => this.visibilityRulesService.checkElementVisibility(field.get('id').value)); - if (!oneFieldAtLeastIsVisible) { - invisibleEntries.push(entry.id); - } - } - } else { - const hiddenEntries = this._findHiddenEntries(entry.subEntries); - - if (entry.subEntries && (entry.subEntries.every(e => hiddenEntries.includes(e.id)))) { - //all children all hidden then hide parent node; - invisibleEntries.push(entry.id); - } else { - invisibleEntries.push(...hiddenEntries); - } - } - }) - - return invisibleEntries; - } - - private _visibilityRulesSubscription: Subscription; - ngOnChanges(changes: SimpleChanges) { - - if (this.selectedFieldsetId) { - this.onToCentrySelected(this._findTocEntryById(this.selectedFieldsetId, this.tocentries), false); - this._actOnObservation = false; - setTimeout(() => { - this._actOnObservation = true; - }, 1000); - - } - - - if (changes['hasFocus'] && changes.hasFocus.currentValue) { - this._resetObserver(); - - } - - if ('visibilityRulesService') { - if (this._visibilityRulesSubscription) { - this._visibilityRulesSubscription.unsubscribe(); - this._visibilityRulesSubscription = null; - } - - if (!this.visibilityRulesService) return; - - this._visibilityRulesSubscription = this.visibilityRulesService.visibilityChange - .pipe(takeUntil(this._destroyed)) - .pipe(debounceTime(200)) - .subscribe(_ => { - if (this.hasFocus) { - this._resetObserver(); - this.hiddenEntries = this._findHiddenEntries(this.tocentries); - } - }); - this.hiddenEntries = this._findHiddenEntries(this.tocentries); - } - // if (!this.isActive && this.links && this.links.length > 0) { - // this.links.forEach(link => { - // link.selected = false; - // }) - // this.links[0].selected = true; - // } - } - - - private _resetObserver() { - if (this._intersectionObserver) {//clean up - this._intersectionObserver.disconnect(); - this._intersectionObserver = null; - } - - const options = { - root: null, - rootMargin: '-38% 0px -60% 0px', - threshold: 0 - } - - this._intersectionObserver = new IntersectionObserver((entries, observer) => { - if (!this._actOnObservation) { - return; - } - - entries.forEach(ie => { - if (ie.isIntersecting) { - try { - const target_id = ie.target.id.replace(this.TOCENTRY_ID_PREFIX, ''); - if (this.visibilityRulesService.checkElementVisibility(target_id)) { - this.onToCentrySelected(this._findTocEntryById(target_id, this.tocentries)); - } - } catch { - - } - } - }) - }, options); - - const fieldsetsEtries = this._getAllFieldSets(this.tocentries); - - fieldsetsEtries.forEach(e => { - if (e.type === ToCEntryType.FieldSet) { - try { - const targetElement = document.getElementById(this.TOCENTRY_ID_PREFIX + e.id); - this._intersectionObserver.observe(targetElement); - } catch { - console.log('element not found'); - } - } - }); - } - - goToStep(link: Link) { - this.stepFound.emit({ - page: link.page, - section: link.section - }); - this.currentLinks.emit(this.links); - - setTimeout(() => { - const target = document.getElementById(link.id); - target.scrollIntoView(true); - - var scrolledY = window.scrollY; - if (scrolledY) { - window.scroll(0, scrolledY - 70); - } - }, 500); - } - - toggle(headerLink: Link) { - const headerPage = +headerLink.name.split(" ", 1); - let innerPage; - for (const link of this.links) { - link.selected = false; - if (link.type === 'mat-expansion-panel') { - innerPage = +link.name.split(".", 1)[0]; - if (isNaN(innerPage)) { innerPage = +link.name.split(" ", 1) } - } else if (link.type === 'h5') { - innerPage = +link.name.split(".", 1)[0]; - } - if (headerPage === innerPage && (link.type !== 'mat-expansion-panel' || (link.type === 'mat-expansion-panel' && link.id.split(".")[4]))) { - link.show = !link.show; - } - } - headerLink.selected = true; - } - - // getIndex(link: Link): number { - // return +link.id.split("_", 2)[1]; - // } - - - private _buildRecursively(form: UntypedFormGroup, whatAmI: ToCEntryType): ToCEntry { - if (!form) return null; - - switch (whatAmI) { - case ToCEntryType.Section: - const sections = form.get('sections') as UntypedFormArray; - const fieldsets = form.get('compositeFields') as UntypedFormArray; - - - const tempResult: ToCEntry[] = []; - - if (sections && sections.length) { - sections.controls.forEach(section => { - tempResult.push(this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section)); - }); - - } else if (fieldsets && fieldsets.length) { - fieldsets.controls.forEach(fieldset => { - tempResult.push(this._buildRecursively(fieldset as UntypedFormGroup, ToCEntryType.FieldSet)); - }); - } - return { - form: form, - id: form.get('id').value, - label: form.get('title').value, - numbering: '', - subEntries: tempResult, - subEntriesType: sections && sections.length ? ToCEntryType.Section : ToCEntryType.FieldSet, - type: ToCEntryType.Section, - ordinal: form.get('ordinal').value - } - case ToCEntryType.FieldSet: - return { - form: form, - label: form.get('title').value, - id: form.get('id').value, - numbering: 's', - subEntries: [], - subEntriesType: ToCEntryType.Field, - type: ToCEntryType.FieldSet, - ordinal: form.get('ordinal').value - } - } - } - - private _sortByOrdinal(tocentries: ToCEntry[]) { - - if (!tocentries || !tocentries.length) return; - - tocentries.sort(this._customCompare); - tocentries.forEach(entry => { - this._sortByOrdinal(entry.subEntries); - }); - } - - private _customCompare(a, b) { - return a.ordinal - b.ordinal; - } - - private _calculateNumbering(tocentries: ToCEntry[], depth: number[] = []) { - if (!tocentries || !tocentries.length) { - return; - } - - let prefixNumbering = depth.length ? depth.join('.') : ''; - - if (depth.length) prefixNumbering = prefixNumbering + "."; - tocentries.forEach((entry, i) => { - entry.numbering = prefixNumbering + (i + 1); - this._calculateNumbering(entry.subEntries, [...depth, i + 1]) - }); - } - - - getTocEntries(form): ToCEntry[] { - if (form == null) { return []; } - const result: ToCEntry[] = []; - - //build parent pages - (form.get('pages') as UntypedFormArray).controls.forEach((pageElement, i) => { - result.push({ - id: i + 'id', - label: pageElement.get('title').value, - type: ToCEntryType.Page, - form: pageElement, - numbering: (i + 1).toString(), - subEntriesType: ToCEntryType.Section, - subEntries: [], - ordinal: pageElement.get('ordinal').value - } as ToCEntry) - }); - - - - result.forEach((entry, i) => { - - const sections = entry.form.get('sections') as UntypedFormArray; - - sections.controls.forEach(section => { - const tempResults = this._buildRecursively(section as UntypedFormGroup, ToCEntryType.Section); - entry.subEntries.push(tempResults); - }); - - }); - - this._sortByOrdinal(result); - //calculate numbering - this._calculateNumbering(result); - return result; - - } - - onToCentrySelected(entry: ToCEntry = null, execute: boolean = true) { - if (!this.isSelecting) { - this.isSelecting = true; - this.tocentrySelected = entry; - this.entrySelected.emit({ entry: entry, execute: execute }); - setTimeout(() => { - this.isSelecting = false; - }, 600); - } - } - - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry { - if (!tocentries || !tocentries.length) { - return null; - } - - let tocEntryFound = tocentries.find(entry => entry.id === id); - - if (tocEntryFound) { - return tocEntryFound; - } - - for (let entry of tocentries) { - const result = this._findTocEntryById(id, entry.subEntries); - if (result) { - tocEntryFound = result; - break; - } - } - - return tocEntryFound ? tocEntryFound : null; - } - /** - * Get all filedsets in a tocentry array; - * @param entries Tocentries to search in - * @returns The tocentries that are Fieldsets provided in the entries - */ - private _getAllFieldSets(entries: ToCEntry[]): ToCEntry[] { - - const fieldsets: ToCEntry[] = []; - if (!entries || !entries.length) return fieldsets; - - - entries.forEach(e => { - if (e.type === ToCEntryType.FieldSet) { - fieldsets.push(e); - } else { - fieldsets.push(...this._getAllFieldSets(e.subEntries)); - } - }); - return fieldsets; - } - - - public hasVisibleInvalidFields(): boolean { - if (!this.internalTable || !this.tocentries) { - return false; - } - return this.tocentries.some(e => this.internalTable.invalidChildsVisible(e)); - } - - protected readonly console = console; -} - -export interface LinkToScroll { - page: number; - section: number; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule-source.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule-source.ts deleted file mode 100644 index 2db9978a3..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule-source.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class VisibilityRuleSource { - public sourceControlId: string; - public sourceControlValue: string; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule.ts deleted file mode 100644 index b2fba603b..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rule.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { VisibilityRuleSource } from "./visibility-rule-source"; - -export class VisibilityRule { - public targetControlId: string; - public sourceVisibilityRules: Array; -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rules-context.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rules-context.ts deleted file mode 100644 index 2eba9ff10..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/models/visibility-rules-context.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Rule } from "../../../../../core/model/dataset-profile-definition/rule"; -import { VisibilityRule } from "./visibility-rule"; - -export class VisibilityRulesContext { - - public rules: Array = new Array(); - - constructor() { } - - public getRulesFromKey(id: string): VisibilityRule { - - for (let i = 0; i < this.rules.length; i++) { - if (id === this.rules[i].targetControlId) { return this.rules[i]; } - } - return null; - } - - public buildVisibilityRuleContext(items: Array) { - items.forEach(item => { - this.addToVisibilityRulesContext(item); - }); - } - - public addToVisibilityRulesContext(item: Rule): void { - for (let i = 0; i < this.rules.length; i++) { - if (this.rules[i].targetControlId === item.targetField) { - - const newRule = { sourceControlId: item.sourceField, sourceControlValue: item.requiredValue }; - const ruleExists = this.rules[i].sourceVisibilityRules.find(x =>{ - return Object.keys(x).reduce((exact, key)=>{ - if(!exact) return false; - return x[key] === newRule[key]; - },true); - }) - - if(!ruleExists){ - this.rules[i].sourceVisibilityRules.push(newRule); - } - - return; - } - } - const newVisibilityRuleArray = [({ sourceControlId: item.sourceField, sourceControlValue: item.requiredValue })]; - this.rules.push({ targetControlId: item.targetField, sourceVisibilityRules: newVisibilityRuleArray }); - return; - } -} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts deleted file mode 100644 index 2d5ad4d68..000000000 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts +++ /dev/null @@ -1,407 +0,0 @@ -// import { ApplicationRef, Injectable, NgZone } from '@angular/core'; -// import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; -// import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style'; -// import { isNumeric } from '@app/utilities/enhancers/utils'; -// import { Observable, Subject } from 'rxjs'; -// import { Rule } from '../../../../core/model/dataset-profile-definition/rule'; -// import { VisibilityRule } from './models/visibility-rule'; -// import { VisibilityRuleSource } from './models/visibility-rule-source'; -// import { VisibilityRulesContext } from './models/visibility-rules-context'; -// import { DescriptionTemplate, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; - -// @Injectable() -// export class VisibilityRulesService { - -// private readonly VISIBILITY_RULE_LOGIC: 'OR' | 'AND' = 'OR'; -// private readonly DEFAULTVISIBILITY = false; - -// private visibilityRuleContext: VisibilityRulesContext; -// private form: AbstractControl; -// public elementVisibilityMap = new Map(); -// private elementVisibilityMapSubject = new Subject>(); -// private elementComputationalMap = new Map>(); /// keep saved the values of each form control validity value -// private _changeMade$ = new Subject(); - - -// constructor( -// public applicationReference: ApplicationRef, -// public ngZone: NgZone -// ) { - -// } - -// getElementVisibilityMapObservable(): Observable> { -// return this.elementVisibilityMapSubject.asObservable(); -// } - -// public checkElementVisibility(id: string): boolean { -// if (this.visibilityRuleContext.rules.filter(item => item.targetControlId === id).length === 0) { return true; } -// return this.elementVisibilityMap.has(id) ? this.elementVisibilityMap.get(id) : false; -// } - -// public buildVisibilityRules(item: Array, form: AbstractControl) { -// this.visibilityRuleContext = new VisibilityRulesContext(); -// this.visibilityRuleContext.buildVisibilityRuleContext(item || []); -// this.form = form; -// this.resetVisibilityRules(); -// } - -// public updateValueAndVisibility(id: string, value: any) { -// const visibilityRules = this.visibilityRuleContext.rules.filter(item => item.sourceVisibilityRules.filter(source => source.sourceControlId === id).length > 0); -// if (visibilityRules.length > 0) { -// visibilityRules.forEach(item => this.evaluateVisibility(item, value, id)); -// this.elementVisibilityMapSubject.next(this.elementVisibilityMap); -// } -// } - -// private evaluateVisibility(visibilityRule: VisibilityRule, value: any, sourceId: string) {// source controlId is the same - -// const targetId = visibilityRule.targetControlId; -// const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); - - -// if (value instanceof Array) { - -// const parsedSourceControlValues = visibilityRule.sourceVisibilityRules.map(e => this.parseValue(e.sourceControlValue)); -// const parsedValues = value.map(e => this.parseValue(e)); - -// const isVisible = parsedValues.map(v => parsedSourceControlValues.includes(v)).reduce((acc, current) => acc || current, false); - - -// // if(isVisible){ -// // this._emitChangesIfNeeded(visibilityRule.targetControlId, true); -// // this.elementVisibilityMap.set(visibilityRule.targetControlId, true); -// // return; -// // } -// visibilityMap.set(sourceId, isVisible); - -// } else { -// const visibilityDependencySource = visibilityRule.sourceVisibilityRules.filter(x => x.sourceControlId === sourceId); - -// const shouldBeVisible = visibilityDependencySource.reduce((isVisible, x) => { - -// const shouldBeHidden = value !== null && (this.parseValue(value) !== this.parseValue(x.sourceControlValue)); -// return this.VISIBILITY_RULE_LOGIC === 'OR' ? (isVisible || !shouldBeHidden) : (isVisible && !shouldBeHidden); -// // if(value !== null && ) -// }, this.VISIBILITY_RULE_LOGIC === 'AND'); -// visibilityMap.set(sourceId, shouldBeVisible); -// } - - -// this.elementComputationalMap.set(targetId, visibilityMap);// unnessecary - - -// const isVisible = this._computeVisibility(targetId); -// this._emitChangesIfNeeded(targetId, isVisible); -// const previousVisibility = this.elementVisibilityMap.get(targetId); -// this.elementVisibilityMap.set(targetId, isVisible); - -// if (!isVisible && previousVisibility !== isVisible) { -// this.resetControlWithId(this.form, targetId); -// } - - -// // for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) { -// // if (value != null && (this.parseValue(value) !== this.parseValue(visibilityRule.sourceVisibilityRules[i].sourceControlValue))) { -// // this._emitChangesIfNeeded(visibilityRule.targetControlId, false); -// // this.elementVisibilityMap.set(visibilityRule.targetControlId, false); -// // this.resetControlWithId(this.form, visibilityRule.targetControlId); -// // //this.updateValueAndVisibility(visibilityRule.targetControlId, null); -// // // this.clearValues(targetPathKey); -// // return; -// // } -// // } -// // this._emitChangesIfNeeded(visibilityRule.targetControlId, true); -// // this.elementVisibilityMap.set(visibilityRule.targetControlId, true); - -// // this.updateValueAndVisibility(visibilityRule.targetControlId, null); -// } - - -// private _computeVisibility(targetId: string): boolean { -// const visibilityMap = this.elementComputationalMap.get(targetId); -// const values = visibilityMap.values(); -// let currentVal = values.next(); -// let visibilityValues: boolean[] = []; -// while (!currentVal.done) { -// visibilityValues.push(currentVal.value); -// currentVal = values.next(); -// } - - -// if (visibilityValues.length) { -// return visibilityValues.reduce((r, c) => { -// if (this.VISIBILITY_RULE_LOGIC === 'OR') { -// return r || c; -// } else { -// return r && c; -// } -// }, visibilityValues[0]); -// } - -// return this.DEFAULTVISIBILITY; -// } - -// private resetVisibilityRules() { -// this.elementVisibilityMap.clear(); -// this.elementVisibilityMap = new Map(); -// this.elementComputationalMap.clear(); -// this.elementComputationalMap = new Map>(); -// this._populateComputationMap(); /// !IMPORTANT FOR THE AND LOGIC -// this._changeMade$.next(); -// } - -// private _populateComputationMap(): void { -// this.visibilityRuleContext.rules.forEach(rule => { -// const targetId = rule.targetControlId; -// const visibilityMap = this.elementComputationalMap.get(targetId) ? this.elementComputationalMap.get(targetId) : new Map(); -// rule.sourceVisibilityRules.forEach(vr => { -// visibilityMap.set(vr.sourceControlId, this.DEFAULTVISIBILITY); -// }); -// this.elementComputationalMap.set(targetId, visibilityMap); -// }); -// } - -// parseValue(value: any) { -// if (typeof value === 'string') { -// if (isNumeric(value)) { return value; } -// else if (value === 'true') { -// return true; -// } -// else if (value === 'false') { -// return false; -// } -// else { return this.translate(value); } -// } else { return value; } -// } - -// search(path, obj, target) { -// for (const k in obj) { -// if (obj.hasOwnProperty(k)) { -// if (obj[k] === target) { -// return path + '.' + k; -// } else if (typeof obj[k] === 'object') { -// const result = this.search(path + '.' + k, obj[k], target); -// if (result) { -// return result; -// } -// } -// } -// } -// return false; -// } - -// scanIfChildsOfCompositeFieldHasVisibleItems(compositeFieldParent: UntypedFormGroup): boolean { -// let isVisible = false; -// ((compositeFieldParent.get('fields'))).controls.forEach(element => { -// if (this.checkElementVisibility(element.get('id').value)) { -// isVisible = true; -// } -// }); -// return isVisible; -// } - -// private translate(item: any) { -// try { -// return JSON.parse(item).value; -// } catch (error) { -// return item; -// } -// } - -// private resetControlWithId(formControl: AbstractControl, id: string) { -// if (formControl instanceof UntypedFormGroup) { -// if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('value') && (formControl as UntypedFormGroup).get('id').value === id) { -// this.resetFieldFormGroup(formControl); -// } if ((formControl as UntypedFormGroup).contains('id') && (formControl as UntypedFormGroup).contains('fields') && (formControl as UntypedFormGroup).get('id').value === id) { -// this.resetCompositeFieldFormGroup(formControl); -// } else { -// Object.keys(formControl.controls).forEach(item => { -// const control = formControl.get(item); -// this.resetControlWithId(control, id); -// }); -// } -// } else if (formControl instanceof UntypedFormArray) { -// formControl.controls.forEach(item => { -// this.resetControlWithId(item, id); -// }); -// } -// } - -// private resetFieldFormGroup(formGroup: UntypedFormGroup) { -// const renderStyle = formGroup.getRawValue().viewStyle.renderStyle; -// if (renderStyle === DatasetProfileFieldViewStyle.Validation || renderStyle === DatasetProfileFieldViewStyle.DatasetIdentifier) { -// formGroup.get('value').setValue({ identifier: '', type: '' }); -// } else { -// formGroup.get('value').setValue(formGroup.get('defaultValue').value ? this.parseValue(formGroup.get('defaultValue').value.value) : undefined); -// } - -// } - -// private resetCompositeFieldFormGroup(formGroup: UntypedFormGroup) { -// (formGroup.get('fields') as UntypedFormArray).controls.forEach((element: UntypedFormGroup) => { -// this.resetFieldFormGroup(element); -// }); -// (formGroup.get('multiplicityItems') as UntypedFormArray).controls.splice(0); -// } -// private _emitChangesIfNeeded(id: string, valueToBeSet: boolean) { -// if (this.elementVisibilityMap.has(id)) { -// if (this.elementVisibilityMap.get(id) != valueToBeSet) { -// this._changeMade$.next(); -// } -// } else { -// this._changeMade$.next(); -// } -// } -// public get visibilityChange() { -// return this._changeMade$.asObservable(); -// } -// public getVisibilityDependency(targetId: string): VisibilityRuleSource[] | null { -// return this.visibilityRuleContext.rules.reduce((hasDependency, rule) => { -// if (hasDependency) return hasDependency; - -// if (rule.targetControlId === targetId) { -// return rule.sourceVisibilityRules; -// } - -// return null; -// }, null) as VisibilityRuleSource[]; -// } - -// public getVisibilityTargets(sourceId: string): string[] { -// return this.visibilityRuleContext.rules.filter(x => { -// const result = x.sourceVisibilityRules.filter(y => y.sourceControlId === sourceId); -// return result.length; -// }).map(x => x.targetControlId); -// } - -// // public appendVisibilityRule(rule: VisibilityRule): void{ - -// // const existingTargetRule = this.visibilityRuleContext.rules.find( r => r.targetControlId === rule.targetControlId); - -// // if(existingTargetRule){ -// // rule.sourceVisibilityRules.forEach(svr =>{ -// // existingTargetRule.sourceVisibilityRules.push(svr); -// // }); -// // }else{ -// // this.visibilityRuleContext.rules.push(rule); -// // } - - -// // } - - -// //removes rule that has the specific id either as a source either as a target -// public removeAllIdReferences(id: string): void { - -// // * Remove from visibility rues and visibility rules context - -// //remove as a target -// const temp = this.visibilityRuleContext.rules.map((x, i) => (x.targetControlId === id) ? i : null); -// const indexes = temp.filter(x => x !== null); -// indexes.reverse().forEach(index => this.visibilityRuleContext.rules.splice(index, 1)); -// this.elementVisibilityMap.delete(id); - - - -// //remove as a source -// const tbd = this.visibilityRuleContext.rules.reduce((to_be_deleted, rule, ruleIdx) => { -// const idxs = rule.sourceVisibilityRules.map((x, i) => (x.sourceControlId === id) ? i : null).filter(x => x !== null); -// idxs.reverse().forEach(index => rule.sourceVisibilityRules.splice(index, 1)); - -// if (!rule.sourceVisibilityRules.length) { -// to_be_deleted.push(ruleIdx); -// } -// return to_be_deleted -// }, []); - - -// //clean up empty -// tbd.reverse().forEach(index => { -// this.visibilityRuleContext.rules.splice(index, 1); -// }); - - - -// // * Remove from computational map - -// // as a target -// if (this.elementComputationalMap.get(id)) { -// this.elementComputationalMap.delete(id); -// } - - -// // as a source -// const keyIterator = this.elementComputationalMap.keys(); -// let currentKey = keyIterator.next(); - - -// while (!currentKey.done) { -// const currentVals = this.elementComputationalMap.get(currentKey.value); -// currentVals.delete(id); -// currentKey = keyIterator.next(); -// } -// } - - -// public addNewRule(rule: Rule, currentVisibility = this.DEFAULTVISIBILITY): void { -// const targetId = rule.targetField; -// const sourceId = rule.sourceField; -// this.visibilityRuleContext.addToVisibilityRulesContext(rule); - - -// let visibilityMap = this.elementComputationalMap.get(targetId); - -// if (!visibilityMap) { -// visibilityMap = new Map(); -// this.elementComputationalMap.set(targetId, visibilityMap); -// } - -// visibilityMap.set(sourceId, currentVisibility); -// const isVisible = this._computeVisibility(targetId); - -// this._emitChangesIfNeeded(targetId, isVisible); -// this.elementVisibilityMap.set(targetId, isVisible); -// this.elementVisibilityMapSubject.next(this.elementVisibilityMap); -// } - - -// /** -// * Check what sourceId hides or shows the target field -// * return true if no rule found -// */ -// public checkTargetVisibilityProvidedBySource(sourceId: string, targetId: string): boolean { - -// const computationalMap = this.elementComputationalMap.get(targetId); -// if (computationalMap) { -// return !!computationalMap.get(sourceId); -// } - -// return true; -// } - -// public getVisibilityRulesFromDescriptionTempalte(descriptionTemplate: DescriptionTemplate): Rule[] { -// const result: Rule[] = this.getVisibilityRulesFromDescriptionTempalteSections(descriptionTemplate?.definition?.sections); -// return result; -// } - -// public getVisibilityRulesFromDescriptionTempalteSections(sections: DescriptionTemplateSection[]): Rule[] { -// const result: Rule[] = []; - -// sections.forEach(section => { -// if (section.sections != null) { result.push(...this.getVisibilityRulesFromDescriptionTempalteSections(section.sections)); }; -// section?.fieldSets?.forEach(fieldSet => { -// fieldSet?.fields?.forEach(field => { -// field.visibilityRules?.forEach(visibilityRule => { -// result.push({ -// sourceField: field.id.toString(), -// targetField: visibilityRule.target, -// requiredValue: visibilityRule.value -// }) -// }); -// }); -// }); -// }); -// return result; -// } -// } diff --git a/dmp-frontend/src/app/ui/misc/help-content/help-content.component.ts b/dmp-frontend/src/app/ui/misc/help-content/help-content.component.ts deleted file mode 100644 index 5ca816123..000000000 --- a/dmp-frontend/src/app/ui/misc/help-content/help-content.component.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Created by stefania on 7/17/17. - */ -import { Component, Input, OnInit } from '@angular/core'; -import { ActivatedRoute, NavigationStart, Router } from '@angular/router'; -import { PageHelpContent } from '@app/core/model/help-content/page-help-content'; -import { HelpContentService } from '@app/core/services/help-content/help-content.service'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-help-content', - template: ` - - -
-
-
- `, -}) -export class HelpContentComponent extends BaseComponent implements OnInit { - @Input() position: string; - contents: any[]; - errorMessage: string = null; - constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) { - super(); - } - - ngOnInit() { - this.errorMessage = null; - this.router.events - .pipe(takeUntil(this._destroyed)) - .subscribe(event => { - if (event instanceof NavigationStart) { - // this._helpContentService.getActivePageContent(event['url']) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // pageContent => this.shiftThroughContent(pageContent), - // error => this.handleError(error)); - } - }); - } - shiftThroughContent(pageContent: PageHelpContent) { - this.contents = pageContent.content[this.position]; - } - isPresent() { - return (this.contents && this.contents.length > 0); - } - handleError(error) { - this.contents = []; - this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')'; - } -} - -// @Component({ -// selector: 'app-aside-help-content', -// template: ` -// -// -//
-//
-//
-// `, -// }) -// export class AsideHelpContentComponent extends HelpContentComponent { -// } diff --git a/dmp-frontend/src/app/ui/misc/help-content/help-content.module.ts b/dmp-frontend/src/app/ui/misc/help-content/help-content.module.ts deleted file mode 100644 index de7863976..000000000 --- a/dmp-frontend/src/app/ui/misc/help-content/help-content.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import { HelpContentComponent } from '@app/ui/misc/help-content/help-content.component'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [ - CommonUiModule - ], - declarations: [ - HelpContentComponent - ], - exports: [HelpContentComponent] -}) -export class HelpContentModule { } diff --git a/dmp-frontend/src/app/ui/misc/navigation/navigation.component.html b/dmp-frontend/src/app/ui/misc/navigation/navigation.component.html deleted file mode 100644 index 08e41f183..000000000 --- a/dmp-frontend/src/app/ui/misc/navigation/navigation.component.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - -
- - -
- - - - -
-
- -
diff --git a/dmp-frontend/src/app/ui/misc/navigation/navigation.component.scss b/dmp-frontend/src/app/ui/misc/navigation/navigation.component.scss deleted file mode 100644 index 01d53a206..000000000 --- a/dmp-frontend/src/app/ui/misc/navigation/navigation.component.scss +++ /dev/null @@ -1,45 +0,0 @@ -@use '@angular/material' as mat; -@mixin navigation-component-theme($theme) { - $accent: map-get($theme, accent); - - .navigation-bar { - overflow: hidden; - position: fixed; - width: 100%; - top: 0; - left: 0; - z-index: 1000; - - .active { - color: mat.get-color-from-palette($accent); - } - - .user-label { - font-size: 14px; - } - - .app-logo { - margin-right: 30px; - margin-left: 20px; - } - } - - .progress-bar { - top: 64px; - left: 0; - position: fixed; - width: 100%; - z-index: 4; - } -} -.two-line-mat-option { - // height: 3.5em; - line-height: 1.2em; -} -.buttonNav:hover { - color: aliceblue; -} - -.login-label { - text-transform: uppercase; -} diff --git a/dmp-frontend/src/app/ui/misc/navigation/navigation.component.ts b/dmp-frontend/src/app/ui/misc/navigation/navigation.component.ts deleted file mode 100644 index f6a999dc3..000000000 --- a/dmp-frontend/src/app/ui/misc/navigation/navigation.component.ts +++ /dev/null @@ -1,126 +0,0 @@ - -import { Component, OnInit } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; -import { AppRole } from '@app/core/common/enum/app-role'; -import { SearchBarItem } from '@app/core/model/dashboard/search-bar-item'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { RequestItem } from '@app/core/query/request-item'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { ProgressIndicationService } from '@app/core/services/progress-indication/progress-indication-service'; -import { SearchBarService } from '@app/core/services/search-bar/search-bar.service'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { UserDialogComponent } from '@app/ui/misc/navigation/user-dialog/user-dialog.component'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable } from 'rxjs'; -import { debounceTime, distinctUntilChanged, mergeMap, takeUntil } from 'rxjs/operators'; - -export enum SearchBarType { - Dataset = 0, - Dmp = 1, - Grant = 2 -} - -@Component({ - selector: 'app-navigation', - templateUrl: 'navigation.component.html', - styleUrls: ['./navigation.component.scss'] -}) -export class NavigationComponent extends BaseComponent implements OnInit { - progressIndication = false; - public search = false; - grantAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - public searchControl = new UntypedFormControl(); - filteredOptions: Observable; - - events: string[] = []; - opened: boolean; - constructor( - private authentication: AuthService, - private dialog: MatDialog, - private grantService: GrantService, - private searchBarService: SearchBarService, - private router: Router, - private progressIndicationService: ProgressIndicationService - ) { - super(); - } - - ngOnInit() { - this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => { - setTimeout(() => { this.progressIndication = x; }); - }); - - this.grantAutoCompleteConfiguration = { - filterFn: this.searchGrant.bind(this), - initialItems: (extraData) => this.searchGrant(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] - }; - - this.filteredOptions = this.searchControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged(), mergeMap(x => { - return this.searchBarService.search(x); - })); - } - - searchGrant(query: string) { - const grantRequestItem: RequestItem = new RequestItem(); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - return this.grantService.getWithExternal(grantRequestItem); - } - - public logout(): void { - this.router.navigate(['/logout']); - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - public isAdmin(): boolean { - return this.authentication.hasRole(AppRole.Admin); - } - - public principalHasAvatar(): boolean { - return this.authentication.getUserProfileAvatarUrl() && this.authentication.getUserProfileAvatarUrl().length > 0; - } - - public getPrincipalAvatar(): string { - return this.authentication.getUserProfileAvatarUrl(); - } - - public getDefaultAvatar(): string { - return 'assets/images/profile-placeholder.png'; - } - - openProfile() { - const dialogRef = this.dialog.open(UserDialogComponent, { - hasBackdrop: true, - autoFocus: false, - closeOnNavigation: true, - disableClose: false, - position: { top: '64px', right: '1em' }, - panelClass: 'custom-userbox' - }); - } - - onOptionSelected(event: any) { - this.search = false; - this.searchControl.patchValue(null); - const selectedSearchBarItem = event.option.value; - if (selectedSearchBarItem.type === SearchBarType.Dataset) { this.router.navigate(['datasets/edit/' + selectedSearchBarItem.id]); } - if (selectedSearchBarItem.type === SearchBarType.Grant) { this.router.navigate(['grants/edit/' + selectedSearchBarItem.id]); } - if (selectedSearchBarItem.type === SearchBarType.Dmp) { this.router.navigate(['plans/edit/' + selectedSearchBarItem.id]); } - } - - transformType(type) { - switch (type) { - case SearchBarType.Dataset: return 'Dataset'; - case SearchBarType.Dmp: return 'DMP'; - case SearchBarType.Grant: return 'Grant'; - } - } -} diff --git a/dmp-frontend/src/app/ui/misc/navigation/navigation.module.ts b/dmp-frontend/src/app/ui/misc/navigation/navigation.module.ts deleted file mode 100644 index f5ac2ff9d..000000000 --- a/dmp-frontend/src/app/ui/misc/navigation/navigation.module.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; -import { NavigationComponent } from '@app/ui/misc/navigation/navigation.component'; -import { UserDialogComponent } from '@app/ui/misc/navigation/user-dialog/user-dialog.component'; -import { CommonFormsModule } from '@common/forms/common-forms.module'; -import { CommonUiModule } from '@common/ui/common-ui.module'; - -@NgModule({ - imports: [ - CommonUiModule, - CommonFormsModule, - RouterModule, - ], - declarations: [ - NavigationComponent, - UserDialogComponent - ], - exports: [NavigationComponent] -}) -export class NavigationModule { } diff --git a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html b/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html deleted file mode 100644 index 492232686..000000000 --- a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html +++ /dev/null @@ -1,48 +0,0 @@ -
- - -
- - - - - - - diff --git a/dmp-frontend/src/app/ui/misc/search/search.component.css b/dmp-frontend/src/app/ui/misc/search/search.component.css deleted file mode 100644 index d16d59fd3..000000000 --- a/dmp-frontend/src/app/ui/misc/search/search.component.css +++ /dev/null @@ -1,28 +0,0 @@ -.input-search { - width: 150px; - /* width: 300px; */ - border: 1px solid rgb(218, 218, 218); - border-radius: 6px; - padding-left: 10px; - margin-right: 20px; -} - -.input-search input { - padding-top: 15px; -} - -.option { - line-height: inherit; - height: 50px; -} - - -@media screen and (max-width: 1136px) { - .input-search { - width: 150px; - border: 1px solid rgb(218, 218, 218); - border-radius: 6px; - padding-left: 10px; - margin-right: 20px; - } -} diff --git a/dmp-frontend/src/app/ui/misc/search/search.component.html b/dmp-frontend/src/app/ui/misc/search/search.component.html deleted file mode 100644 index 47230806e..000000000 --- a/dmp-frontend/src/app/ui/misc/search/search.component.html +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/dmp-frontend/src/app/ui/misc/search/search.component.spec.ts b/dmp-frontend/src/app/ui/misc/search/search.component.spec.ts deleted file mode 100644 index fc21494f0..000000000 --- a/dmp-frontend/src/app/ui/misc/search/search.component.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { SearchComponent } from './search.component'; - -describe('SearchComponent', () => { - let component: SearchComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [SearchComponent], - teardown: { destroyAfterEach: false } -}) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SearchComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/dmp-frontend/src/app/ui/misc/search/search.component.ts b/dmp-frontend/src/app/ui/misc/search/search.component.ts deleted file mode 100644 index e9afb7306..000000000 --- a/dmp-frontend/src/app/ui/misc/search/search.component.ts +++ /dev/null @@ -1,81 +0,0 @@ - -import { mergeMap, distinctUntilChanged, debounceTime } from 'rxjs/operators'; -import { Component, OnInit } from "@angular/core"; -import { AuthService } from '../../../core/services/auth/auth.service'; -import { UntypedFormControl } from "@angular/forms"; -import { SearchBarService } from '../../../core/services/search-bar/search-bar.service'; -import { Router } from '@angular/router'; -import { Observable } from "rxjs"; -import { SearchBarItem } from "../../../core/model/dashboard/search-bar-item"; -import { TranslateService } from "@ngx-translate/core"; - -export enum SearchBarType { - Dataset = 0, - Dmp = 1, - Grant = 2 -} - -@Component({ - selector: "app-search", - templateUrl: "./search.component.html", - styleUrls: ["./search.component.css"] -}) -export class SearchComponent implements OnInit { - public search = false; - public searchControl = new UntypedFormControl(); - filteredOptions: Observable; - - constructor( - private authentication: AuthService, - private router: Router, - private searchBarService: SearchBarService, - private language: TranslateService - ) { } - - ngOnInit() { - this.filteredOptions = this.searchControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged(), mergeMap(x => { - return this.searchBarService.search(x); - })); - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - onOptionSelected(event: any) { - this.search = false; - this.searchControl.patchValue(null); - const selectedSearchBarItem = event.option.value; - if (!selectedSearchBarItem.isPublished) { - if (selectedSearchBarItem.type === SearchBarType.Dataset) { this.router.navigate(['datasets/edit/' + selectedSearchBarItem.id]); } - if (selectedSearchBarItem.type === SearchBarType.Grant) { this.router.navigate(['plans/grant/' + selectedSearchBarItem.id]); } - if (selectedSearchBarItem.type === SearchBarType.Dmp) { this.router.navigate(['plans/overview/' + selectedSearchBarItem.id]); } - } else { - if (selectedSearchBarItem.type === SearchBarType.Dataset) { this.router.navigate(['datasets/publicEdit/' + selectedSearchBarItem.id]); } - if (selectedSearchBarItem.type === SearchBarType.Dmp) { this.router.navigate(['explore-plans/overview/' + selectedSearchBarItem.id]); } - } - } - - transformType(type, isPublished) { - let subtitle: string; - switch (type) { - case SearchBarType.Dataset: { - subtitle = this.language.instant('NAV-BAR.SEARCH.DATASET'); - break; - } - case SearchBarType.Dmp: { - subtitle = this.language.instant('NAV-BAR.SEARCH.DMP'); - break; - } - case SearchBarType.Grant: { - subtitle = this.language.instant('NAV-BAR.SEARCH.GRANT'); - break; - } - } - if (isPublished) { - return subtitle + " - " + this.language.instant('NAV-BAR.SEARCH.PUBLISHED') - } else { - return subtitle; - } - } -} diff --git a/dmp-frontend/src/app/ui/navbar/navbar.component.ts b/dmp-frontend/src/app/ui/navbar/navbar.component.ts index 68c251ad7..d46499f7d 100644 --- a/dmp-frontend/src/app/ui/navbar/navbar.component.ts +++ b/dmp-frontend/src/app/ui/navbar/navbar.component.ts @@ -1,24 +1,22 @@ import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatMenuTrigger } from '@angular/material/menu'; import { Router } from '@angular/router'; import { AppRole } from '@app/core/common/enum/app-role'; -import { UserListingModel } from '@app/core/model/user/user-listing'; +import { User } from '@app/core/model/user/user'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { LanguageService } from '@app/core/services/language/language.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { ProgressIndicationService } from '@app/core/services/progress-indication/progress-indication-service'; import { SideNavService } from '@app/core/services/sidenav/side-nav.sevice'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; import { BaseComponent } from '@common/base/base.component'; import { takeUntil } from 'rxjs/operators'; import { StartNewDmpDialogComponent } from '../dmp/new/start-new-dmp-dialogue/start-new-dmp-dialog.component'; import { FaqDialogComponent } from '../faq/dialog/faq-dialog.component'; -import { UserDialogComponent } from '../misc/navigation/user-dialog/user-dialog.component'; +import { UserDialogComponent } from './user-dialog/user-dialog.component'; import { DATASETS_ROUTES, DMP_ROUTES, GENERAL_ROUTES } from '../sidebar/sidebar.component'; + @Component({ selector: 'app-navbar', templateUrl: './navbar.component.html', @@ -34,7 +32,7 @@ export class NavbarComponent extends BaseComponent implements OnInit { languages = []; currentRoute: string; selectedLanguage: string; - private user: UserListingModel; + private user: User; @Output() sidebarToggled: EventEmitter = new EventEmitter(); @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; @@ -45,11 +43,8 @@ export class NavbarComponent extends BaseComponent implements OnInit { private dialog: MatDialog, private progressIndicationService: ProgressIndicationService, private languageService: LanguageService, - public userService: UserServiceOld, - private httpClient: HttpClient, private matomoService: MatomoService, private sidenavService: SideNavService, - private configurationService: ConfigurationService ) { super(); this.location = location; diff --git a/dmp-frontend/src/app/ui/navbar/navbar.module.ts b/dmp-frontend/src/app/ui/navbar/navbar.module.ts index f0be977ae..21ffdf8f3 100644 --- a/dmp-frontend/src/app/ui/navbar/navbar.module.ts +++ b/dmp-frontend/src/app/ui/navbar/navbar.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { SearchComponent } from '@app/ui/misc/search/search.component'; import { NavbarComponent } from '@app/ui/navbar/navbar.component'; import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; import { LanguageModule } from '../language/language.module'; +import { UserDialogComponent } from './user-dialog/user-dialog.component'; @NgModule({ imports: [ @@ -15,7 +15,7 @@ import { LanguageModule } from '../language/language.module'; ], declarations: [ NavbarComponent, - SearchComponent + UserDialogComponent ], exports: [NavbarComponent] }) diff --git a/dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.html b/dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.html new file mode 100644 index 000000000..2f9d7bdad --- /dev/null +++ b/dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.html @@ -0,0 +1,16 @@ +
+ + +
diff --git a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.scss b/dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.scss similarity index 100% rename from dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.scss rename to dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.scss diff --git a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.ts b/dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.ts similarity index 95% rename from dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.ts rename to dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.ts index 8d0a66187..0c68bc7fc 100644 --- a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.ts +++ b/dmp-frontend/src/app/ui/navbar/user-dialog/user-dialog.component.ts @@ -2,7 +2,7 @@ import { Component, Inject, OnInit } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Router } from '@angular/router'; -import { AuthService } from '../../../../core/services/auth/auth.service'; +import { AuthService } from '../../../core/services/auth/auth.service'; @Component({ selector: 'app-user-dialog-component', diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html b/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html deleted file mode 100644 index 2367cc238..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss b/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts deleted file mode 100644 index 9c53aa709..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/data-repository/dataset-external-data-repository-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalDataRepositoryService } from '@app/core/services/external-sources/data-repository/extternal-data-repository.service'; -import { ExternalDataRepositoryEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: 'dataset-external-data-repository-dialog-editor.component.html', - styleUrls: ['./dataset-external-data-repository-dialog-editor.component.scss'] -}) -export class DatasetExternalDataRepositoryDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalDataRepositoryService: ExternalDataRepositoryService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const datarepo = new ExternalDataRepositoryEditorModel(); - this.formGroup = datarepo.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalDataRepositoryService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html b/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html deleted file mode 100644 index 530a33bd4..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss b/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts deleted file mode 100644 index 676181d56..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/external-dataset/dataset-external-dataset-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalDatasetService } from '@app/core/services/external-sources/dataset/external-dataset.service'; -import { ExternalDatasetEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { FormService } from '@common/forms/form-service'; - -@Component({ - templateUrl: 'dataset-external-dataset-dialog-editor.component.html', - styleUrls: ['./dataset-external-dataset-dialog-editor.component.scss'] -}) -export class DatasetExternalDatasetDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalDatasetService: ExternalDatasetService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const externalDatasetModel = new ExternalDatasetEditorModel(); - this.formGroup = externalDatasetModel.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalDatasetService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.html b/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.html deleted file mode 100644 index 111e52fc6..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.REGISTRY.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.scss b/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.ts deleted file mode 100644 index 9179bdbc7..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/registry/dataset-external-registry-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalRegistryService } from '@app/core/services/external-sources/registry/external-registry.service'; -import { ExternalRegistryEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: 'dataset-external-registry-dialog-editor.component.html', - styleUrls: ['./dataset-external-registry-dialog-editor.component.scss'] -}) -export class DatasetExternalRegistryDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalRegistryService: ExternalRegistryService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const registryModel = new ExternalRegistryEditorModel(); - this.formGroup = registryModel.buildForm(); - } - - send(value: any) { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalRegistryService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.html b/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.html deleted file mode 100644 index 994c214e7..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
- {{'DATASET-REFERENCED-MODELS.SERVICES.TITLE' | translate}} -
-
- close -
-
-
- - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.scss b/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.scss deleted file mode 100644 index b1538a730..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.close-btn { - cursor: pointer; -} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.ts deleted file mode 100644 index 5da9f1b59..000000000 --- a/dmp-frontend/src/app/ui/reference/reference-field/editors/service/dataset-external-service-dialog-editor.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { ExternalServiceService } from '@app/core/services/external-sources/service/external-service.service'; -import { ExternalServiceEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; -import { FormService } from '@common/forms/form-service'; - -@Component({ - templateUrl: 'dataset-external-service-dialog-editor.component.html', - styleUrls: ['./dataset-external-service-dialog-editor.component.scss'] -}) -export class DatasetExternalServiceDialogEditorComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - - constructor( - private externalServiceService: ExternalServiceService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private formService: FormService - ) { super(); } - - ngOnInit(): void { - const serviceModel = new ExternalServiceEditorModel(); - this.formGroup = serviceModel.buildForm(); - } - - send() { - this.formService.touchAllFormFields(this.formGroup); - if (!this.formGroup.valid) { return; } - this.externalServiceService.create(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - (item) => this.dialogRef.close(item) - ); - } - - close() { - this.dialogRef.close(false); - } -} diff --git a/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts b/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts index 2bbfb7f7c..76c6c70f6 100644 --- a/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts +++ b/dmp-frontend/src/app/ui/sidebar/sidebar.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { TranslateService } from '@ngx-translate/core'; import { AuthService } from '../../core/services/auth/auth.service'; -import { UserDialogComponent } from '../misc/navigation/user-dialog/user-dialog.component'; +import { UserDialogComponent } from '../navbar/user-dialog/user-dialog.component'; import { AppRole } from '../../core/common/enum/app-role'; import { Router } from '@angular/router'; import { Location } from '@angular/common'; diff --git a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts index 1a98e1de5..ad4712467 100644 --- a/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/add-account/add-account-dialog.component.ts @@ -1,9 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { UserMergeRequestModel } from '@app/core/model/merge/user-merge-request'; -import { MergeLoginService } from '@app/ui/auth/login/utilities/merge-login.service'; -import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; @Component({ selector: 'app-add-account-dialog-component', @@ -12,14 +9,15 @@ import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-descript }) export class AddAccountDialogComponent implements OnInit { - datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel; + //TODO: refactor + datasetProfileDefinitionModel: any; datasetProfileDefinitionFormGroup: UntypedFormGroup; progressIndication = false; public hasEmail = true; - private request: UserMergeRequestModel; + //TODO: refactor + private request: any; constructor( - private mergeLoginService: MergeLoginService, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any ) { @@ -27,16 +25,17 @@ export class AddAccountDialogComponent implements OnInit { } ngOnInit(): void { - this.mergeLoginService.getObservable().subscribe(result => { - if (result !== undefined) { - if (!(result.email !== undefined && result.email !== null)) { - this.request = result; - this.hasEmail = false; - } else { - this.dialogRef.close(result); - } - } - }); + //TODO refactor + // this.mergeLoginService.getObservable().subscribe(result => { + // if (result !== undefined) { + // if (!(result.email !== undefined && result.email !== null)) { + // this.request = result; + // this.hasEmail = false; + // } else { + // this.dialogRef.close(result); + // } + // } + // }); } add(): void { diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts b/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts index 6856a565e..f5fcd46b7 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile-editor.model.ts @@ -1,25 +1,26 @@ import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; -import { OrganizationModel } from '@app/core/model/organisation/organization'; -import { UserListingModel } from '@app/core/model/user/user-listing'; +import { Reference } from '@app/core/model/reference/reference'; +import { User } from '@app/core/model/user/user'; +import { Guid } from '@common/types/guid'; export class UserProfileEditorModel { - public id: String; + public id: Guid; public name: String; public language: any; public culture: any; public timezone: String; - public organization: OrganizationModel; + public organization: Reference; public roleOrganization: RoleOrganizationType; - fromModel(item: UserListingModel): UserProfileEditorModel { + fromModel(item: User): UserProfileEditorModel { this.id = item.id; this.name = item.name; - this.language = item.language; - this.timezone = item.timezone; - this.culture = item.culture; - this.organization = item.organization; - this.roleOrganization = item.roleOrganization; + this.language = item.additionalInfo.language; + this.timezone = item.additionalInfo.timezone; + this.culture = item.additionalInfo.culture; + this.organization = item.additionalInfo.organization; + this.roleOrganization = item.additionalInfo.roleOrganization; return this; } diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.html b/dmp-frontend/src/app/ui/user-profile/user-profile.component.html index 81472e5dd..c8bb717cb 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.html +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.html @@ -7,13 +7,9 @@
-
{{formGroup.get('name').value}}
-
@@ -26,7 +22,6 @@
- {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -34,7 +29,8 @@
-
+ +
{{userCredential.email}}
@@ -58,7 +53,6 @@ - @@ -74,7 +68,7 @@
-
+
-->
@@ -85,8 +79,6 @@
-
@@ -193,134 +185,4 @@
-
- - - +
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index d9c547946..5091cfe19 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -1,38 +1,31 @@ +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { Component, OnDestroy, OnInit } from '@angular/core'; -import { UntypedFormArray, FormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms'; +import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; +import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; import { CultureInfo } from '@app/core/model/culture-info'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { UserListingModel } from '@app/core/model/user/user-listing'; +import { Reference } from '@app/core/model/reference/reference'; +import { User } from '@app/core/model/user/user'; import { AuthService } from '@app/core/services/auth/auth.service'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { CultureService } from '@app/core/services/culture/culture-service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; +import { LanguageService } from '@app/core/services/language/language.service'; +import { MatomoService } from '@app/core/services/matomo/matomo-service'; +import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { UserService } from '@app/core/services/user/user.service'; +import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component"; import { BaseComponent } from '@common/base/base.component'; +import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; +import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { TranslateService } from '@ngx-translate/core'; import * as moment from 'moment-timezone'; import { Observable, of } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; -import { LanguageService } from '@app/core/services/language/language.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; -import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item'; -import { ExternalSourcesService } from '@app/core/services/external-sources/external-sources.service'; -import { UserProfileEditorModel } from './user-profile-editor.model'; -import { RoleOrganizationType } from '@app/core/common/enum/role-organization-type'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { AddAccountDialogComponent } from './add-account/add-account-dialog.component'; -import { MatDialog } from '@angular/material/dialog'; -import { UserCredentialModel } from '@app/core/model/user/user-credential'; -import { AuthProvider } from '@app/core/common/enum/auth-provider'; -import { MergeEmailConfirmationService } from '@app/core/services/merge-email-confirmation/merge-email-confirmation.service'; -import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component"; -import { UnlinkAccountRequestModel } from '@app/core/model/unlink-account/unlink-account'; -import { UnlinkAccountEmailConfirmationService } from '@app/core/services/unlink-account-email-confirmation/unlink-account-email-confirmation.service'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import { UserProfileEditorModel } from './user-profile-editor.model'; @Component({ selector: 'app-user-profile', @@ -42,16 +35,15 @@ import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog export class UserProfileComponent extends BaseComponent implements OnInit, OnDestroy { userProfileEditorModel: UserProfileEditorModel; - user: Observable; - userCredentials: UserCredentialModel[]; + user: Observable; + //TODO: refactor + // userCredentials: UserCredentialModel[]; currentUserId: string; cultures: Observable; timezones: Observable; editMode = false; languages = []; roleOrganizationEnum = RoleOrganizationType; - authProviderEnum = AuthProvider; - private oauthLock: boolean; errorMessages = []; nestedCount = []; nestedIndex = 0; @@ -66,21 +58,18 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes formGroup: UntypedFormGroup; constructor( - private userService: UserServiceOld, + private userService: UserService, private route: ActivatedRoute, private router: Router, private authService: AuthService, private language: TranslateService, private cultureService: CultureService, - private externalSourcesService: ExternalSourcesService, private authentication: AuthService, private languageService: LanguageService, private configurationService: ConfigurationService, private uiNotificationService: UiNotificationService, private dialog: MatDialog, public enumUtils: EnumUtils, - private mergeEmailConfirmation: MergeEmailConfirmationService, - private unlinkAccountEmailConfirmation: UnlinkAccountEmailConfirmationService, private httpClient: HttpClient, private matomoService: MatomoService ) { @@ -95,7 +84,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes .subscribe((params: Params) => { this.currentUserId = this.authService.userId()?.toString(); const userId = !params['id'] ? 'me' : params['id']; - this.user = this.userService.getUser(userId).pipe(map(result => { + this.user = this.userService.getSingle(userId).pipe(map(result => { //result['additionalinfo'] = JSON.parse(result['additionalinfo']); this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result); @@ -118,14 +107,16 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes return result; })); - this.userService.getEmails(userId).pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.user.subscribe(x => { - const mainEmail = result.filter(el => el.email === x.email) - const otherEmails = result.filter(el => el.email !== x.email) - this.userCredentials = [...mainEmail, ...otherEmails]; - } - )}); + //TODO: refactor + // this.userService.getEmails(userId).pipe(takeUntil(this._destroyed)) + // .subscribe(result => { + // this.user.subscribe(x => { + // const mainEmail = result.filter(el => el.email === x.email) + // const otherEmails = result.filter(el => el.email !== x.email) + // this.userCredentials = [...mainEmail, ...otherEmails]; + // } + // ) + // }); }); } @@ -133,28 +124,10 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes ngOnDestroy(): void { } - logout(): void { - this.router.navigate(['/logout']); - } - - getUserRole(dmp: DmpModel) { - if (dmp.creator.id === this.currentUserId) { - return this.language.instant('USER-PROFILE.DMPS.CREATOR'); - } else if (dmp.associatedUsers.map(x => x.id).indexOf(this.currentUserId) !== -1) { - return this.language.instant('USER-PROFILE.DMPS.MEMBER'); - } - } - - showAllDmps() { - this.router.navigate(['/plans']); - } - - navigateToDmp(dmp: DmpModel) { - this.router.navigate(['/plans/edit/' + dmp.id]); - } - - private filterOrganisations(value: string): Observable { - return this.externalSourcesService.searchDMPOrganizations(value); + private filterOrganisations(value: string): Observable { + //TODO: refactor + // return this.externalSourcesService.searchDMPOrganizations(value); + return null; } private _filterTimezone(value: string): Observable { @@ -180,31 +153,32 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes } save() { - if (!this.formGroup.valid) { - this.printErrors(this.formGroup); - this.showValidationErrorsDialog(); - this.nestedCount = []; - this.nestedIndex = 0; - this.errorMessages = []; - return; - } - this.userService.updateUserSettings(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - x => { - this.editMode = false; - this.languageService.changeLanguage(this.formGroup.value.language.value); - this.authService.refresh() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/profile']); - }); - // .subscribe(result => window.location.reload()); - }, - error => { - console.log(error); - }); + //TODO: refactor + // if (!this.formGroup.valid) { + // this.printErrors(this.formGroup); + // this.showValidationErrorsDialog(); + // this.nestedCount = []; + // this.nestedIndex = 0; + // this.errorMessages = []; + // return; + // } + // this.userService.updateUserSettings(this.formGroup.value) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // x => { + // this.editMode = false; + // this.languageService.changeLanguage(this.formGroup.value.language.value); + // this.authService.refresh() + // .pipe(takeUntil(this._destroyed)) + // .subscribe(result => { + // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + // this.router.navigate(['/profile']); + // }); + // // .subscribe(result => window.location.reload()); + // }, + // error => { + // console.log(error); + // }); } public unlock() { @@ -218,21 +192,22 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes public lock() { if (!this.formGroup.valid) { return; } - this.userService.updateUserSettings(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - x => { - this.editMode = false; - this.languageService.changeLanguage(this.formGroup.value.language.value); - this.formGroup.disable(); - this.authService.refresh() - .pipe(takeUntil(this._destroyed)) - .subscribe(result => this.router.navigate(['/profile'])); - // .subscribe(result => window.location.reload()); - }, - error => { - console.log(error); - }); + //TODO: refactor + // this.userService.updateUserSettings(this.formGroup.value) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // x => { + // this.editMode = false; + // this.languageService.changeLanguage(this.formGroup.value.language.value); + // this.formGroup.disable(); + // this.authService.refresh() + // .pipe(takeUntil(this._destroyed)) + // .subscribe(result => this.router.navigate(['/profile'])); + // // .subscribe(result => window.location.reload()); + // }, + // error => { + // console.log(error); + // }); } private showValidationErrorsDialog(projectOnly?: boolean) { @@ -251,36 +226,37 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes (ev.target as HTMLImageElement).src = 'assets/images/profile-placeholder.png'; } - public removeAccount(userCredential :UserCredentialModel) { + public removeAccount(userCredential: any) { this.dialog.open(ConfirmationDialogComponent, { - data:{ + data: { message: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT-DIALOG.MESSAGE'), confirmButton: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT-DIALOG.CONFIRM'), cancelButton: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT-DIALOG.CANCEL') }, - maxWidth:'35em' + maxWidth: '35em' }) - .afterClosed() - .subscribe(confirm=>{ - if(confirm){ - const unlinkAccountModel: UnlinkAccountRequestModel = { - userId: this.currentUserId, - email: userCredential.email, - provider: userCredential.provider - }; - this.unlinkAccountEmailConfirmation.sendConfirmationEmail(unlinkAccountModel).pipe(takeUntil(this._destroyed)).subscribe( - result => { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.TITLE'), - message: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.MESSAGE', {'accountToBeUnlinked': userCredential.email}) - }, maxWidth: '35em' - }); - }, - error => { this.onCallbackError(error); } - ); - } - }); + .afterClosed() + .subscribe(confirm => { + if (confirm) { + //TODO: refactor + // const unlinkAccountModel: UnlinkAccountRequestModel = { + // userId: this.currentUserId, + // email: userCredential.email, + // provider: userCredential.provider + // }; + // this.unlinkAccountEmailConfirmation.sendConfirmationEmail(unlinkAccountModel).pipe(takeUntil(this._destroyed)).subscribe( + // result => { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.TITLE'), + // message: this.language.instant('USER-PROFILE.UNLINK-ACCOUNT.MESSAGE', { 'accountToBeUnlinked': userCredential.email }) + // }, maxWidth: '35em' + // }); + // }, + // error => { this.onCallbackError(error); } + // ); + } + }); } onCallbackError(errorResponse: HttpErrorResponse) { @@ -298,15 +274,16 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - this.mergeEmailConfirmation.sendConfirmationEmail(result).pipe(takeUntil(this._destroyed)) - .subscribe(res => { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.TITLE'), - message: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.MESSAGE') - }, maxWidth: '30em' - }); - }, err => { }); + //TODO refactor + // this.mergeEmailConfirmation.sendConfirmationEmail(result).pipe(takeUntil(this._destroyed)) + // .subscribe(res => { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.TITLE'), + // message: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.MESSAGE') + // }, maxWidth: '30em' + // }); + // }, err => { }); } }); } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 587a42ea0..d76411232 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1746,6 +1746,40 @@ "MESSAGE": "Somebody else is modifying the DMP at this moment. You may view the dataset but you cannot make any changes." } }, + "DMP-CLONE-DIALOG": { + "TITLE": "Clone", + "FIELDS": { + "LABEL": "Title of DMP", + "DESCRIPTION": "Description", + "DESCRIPTION-HINT": "A brief description of what the DMP is about, it’s scope and objectives.", + "DESCRIPTION-PLACEHOLDER": "Fill with Description", + "DESCRIPTIONS": "Descriptions", + "DESCRIPTIONS-HINT": "Select which descriptions to include in the new DMP. Selected descriptions will be editable." + }, + "NO-DESCRIPTIONS": "Not available Descriptions for this DMP.", + "ACTIONS": { + "CANCEL": "Cancel", + "CLONE": "Clone" + } + }, + "DMP-NEW-VERSION-DIALOG": { + "TITLE": "New Version", + "FIELDS": { + "LABEL": "Title of DMP", + "DESCRIPTION": "Description", + "DESCRIPTION-HINT": "A brief description of what the DMP is about, it’s scope and objectives.", + "DESCRIPTION-PLACEHOLDER": "Fill with Description", + "DESCRIPTIONS": "Descriptions", + "DESCRIPTIONS-HINT": "Select which descriptions to include in the new DMP. Selected descriptions will be editable.", + "BLUEPRINT": "DMP Blueprint", + "BLUEPRINT-PLACEHOLDER": "DMP Blueprint" + }, + "NO-DESCRIPTIONS": "Not available Descriptions for this DMP.", + "ACTIONS": { + "CANCEL": "Cancel", + "NEW-VERSION": "Create New Version" + } + }, "DMP-BLUEPRINT-LISTING": { "TITLE": "DMP Blueprints", "CREATE-DMP-BLUEPRINT": "Create DMP Blueprint", diff --git a/dmp-frontend/src/assets/scss/blue-theme.scss b/dmp-frontend/src/assets/scss/blue-theme.scss index 1c770e3e2..f7fd23ce1 100644 --- a/dmp-frontend/src/assets/scss/blue-theme.scss +++ b/dmp-frontend/src/assets/scss/blue-theme.scss @@ -1,5 +1,4 @@ @use '@angular/material' as mat; -@import "app/ui/misc/navigation/navigation.component.scss"; @import "@angular/material/theming"; // @import '../../../node_modules/@angular/material/theming'; $app-blue-theme-primary-palette: ( @@ -134,7 +133,6 @@ $custom-typography: mat.define-legacy-typography-config( @include mat.legacy-core(); @include mat.all-legacy-component-themes($custom-theme); - @include navigation-component-theme($custom-theme); // Override typography CSS classes (e.g., mat-h1, mat-display-1, mat-typography, etc.). @include mat.legacy-typography-hierarchy($custom-typography); diff --git a/dmp-frontend/src/assets/scss/green-theme.scss b/dmp-frontend/src/assets/scss/green-theme.scss index e61bf71f9..84da95ce6 100644 --- a/dmp-frontend/src/assets/scss/green-theme.scss +++ b/dmp-frontend/src/assets/scss/green-theme.scss @@ -1,5 +1,4 @@ @use '@angular/material' as mat; -@import "app/ui/misc/navigation/navigation.component.scss"; @import "@angular/material/theming"; // @import '../../../node_modules/@angular/material/theming'; $app-green-theme-primary-palette: ( @@ -134,7 +133,6 @@ $custom-typography: mat.define-legacy-typography-config( @include mat.legacy-core(); @include mat.all-legacy-component-themes($custom-theme); - @include navigation-component-theme($custom-theme); // Override typography CSS classes (e.g., mat-h1, mat-display-1, mat-typography, etc.). @include mat.legacy-typography-hierarchy($custom-typography); From de67f176037cf1ce4674ab7735f907d04bdc3506 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Fri, 29 Dec 2023 18:36:02 +0200 Subject: [PATCH 5/5] more frontend changes --- .../eudat/controllers/v2/DmpController.java | 2 +- dmp-frontend/src/app/core/model/dmp/dmp.ts | 13 +- .../src/app/core/services/dmp/dmp.service.ts | 17 +- .../description-listing-item.component.ts | 2 +- dmp-frontend/src/app/ui/dmp/dmp.module.ts | 1 - .../dmp-invitation-dialog.component.html | 32 ++++ .../dmp-invitation-dialog.component.scss | 150 ++++++++++++++++++ .../dmp-invitation-dialog.component.ts | 139 ++++++++-------- .../dmp-invitation-dialog.editor.model.ts | 34 ++++ .../dialog/dmp-invitation-dialog.module.ts | 15 ++ .../dmp-invitation-dialog.component.html | 75 --------- .../dmp-invitation-dialog.component.scss | 135 ---------------- .../app/ui/dmp/listing/dmp-listing.module.ts | 2 + .../dmp-listing-item.component.html | 2 +- .../dmp-listing-item.component.ts | 23 ++- dmp-frontend/src/assets/i18n/en.json | 11 ++ 16 files changed, 348 insertions(+), 305 deletions(-) create mode 100644 dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.html create mode 100644 dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.scss rename dmp-frontend/src/app/ui/dmp/invitation/{ => dialog}/dmp-invitation-dialog.component.ts (56%) create mode 100644 dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.editor.model.ts create mode 100644 dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.module.ts delete mode 100644 dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.html delete mode 100644 dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.scss diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java index 3d2d360c2..e2d21174f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java @@ -229,7 +229,7 @@ public class DmpController { @GetMapping("{id}/token/{token}/invite-accept") @Transactional - public ResponseEntity inviteUsers(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException { + public ResponseEntity acceptInvitation(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException { logger.debug(new MapLogEntry("inviting users to dmp").And("id", id)); this.dmpService.dmpInvitationAccept(token); diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 764d103a7..aa6452d44 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -97,4 +97,15 @@ export interface DmpUserRemovePersist { id: Guid; dmpId: Guid; role: DmpUserRole; -} \ No newline at end of file +} + +export interface DmpUserInvitePersist { + users: DmpUserInviteTypePersist[]; + role: DmpUserRole; +} + +export interface DmpUserInviteTypePersist { + userId: Guid; + email: string; +} + diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 9045ecf8d..722cd8ac9 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -3,7 +3,6 @@ import { Injectable } from '@angular/core'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { IsActive } from '@app/core/common/enum/is-active.enum'; -import { FileFormat } from '@app/core/model/file/file-format.model'; import { DmpDescriptionTemplateLookup } from '@app/core/query/dmp-description-template.lookup'; import { DmpLookup } from '@app/core/query/dmp.lookup'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; @@ -16,7 +15,7 @@ import { catchError, map } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { BaseHttpParams } from '../../../../common/http/base-http-params'; import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; -import { CloneDmpPersist, Dmp, DmpPersist, DmpUser, DmpUserPersist, DmpUserRemovePersist, NewVersionDmpPersist } from '../../model/dmp/dmp'; +import { CloneDmpPersist, Dmp, DmpPersist, DmpUser, DmpUserInvitePersist, DmpUserPersist, DmpUserRemovePersist, NewVersionDmpPersist } from '../../model/dmp/dmp'; import { AuthService } from '../auth/auth.service'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; @@ -111,6 +110,20 @@ export class DmpService { catchError((error: any) => throwError(error))); } + inviteUsers(dmpId: Guid, item: DmpUserInvitePersist): Observable { + const url = `${this.apiBase}/${dmpId}/invite-users`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + + acceptInvitation(dmpId: Guid, token: string): Observable { + const url = `${this.apiBase}/${dmpId}/token/${token}/invite-accept`; + + return this.http.get(url).pipe(catchError((error: any) => throwError(error))); + } + public download(id: string, format: string): Observable> { //let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword') return this.httpClient.get(`${this.apiBase}/${id}/export/${format}`, { responseType: 'blob', observe: 'response', headers: this.headers }); diff --git a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts index 98146d878..f4c5e3bc9 100644 --- a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts @@ -17,7 +17,7 @@ import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/serv import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; +import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component'; import { BaseComponent } from '@common/base/base.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { Guid } from '@common/types/guid'; diff --git a/dmp-frontend/src/app/ui/dmp/dmp.module.ts b/dmp-frontend/src/app/ui/dmp/dmp.module.ts index 4162dbf3f..f1ab651c3 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp.module.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp.module.ts @@ -36,7 +36,6 @@ import { CommonUiModule } from '@common/ui/common-ui.module'; // DmpListingComponent, // DmpCriteriaComponent, // DmpEditorComponent, - // DmpInvitationDialogComponent, // InvitationAcceptedComponent, // DmpToDatasetDialogComponent, // DmpWizardComponent, diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.html b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.html new file mode 100644 index 000000000..a38fae529 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.html @@ -0,0 +1,32 @@ +
+
+
+

{{'DMP-USER-INVITATION-DIALOG.TITLE' | translate}}

+
+
+ close +
+
+
+ + + + +

+ info_outlined + {{'DMP-USER-INVITATION-DIALOG.FIELDS.USERS-HINT' | translate}} +

+
+
+ + + {{enumUtils.toDmpUserRoleString(dmpUserRoleEnum.Owner)}} + {{enumUtils.toDmpUserRoleString(dmpUserRoleEnum.Member)}} + + +
+
+ +
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.scss b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.scss new file mode 100644 index 000000000..78ac33791 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.scss @@ -0,0 +1,150 @@ +.dmp-invitation-dialog { + padding: 2.5rem; + + .form-container { + width: 33em; + min-height: 14em; + padding: 0.28em 0.34em 0em 1.125em; + } + + .close-icon { + cursor: pointer; + // margin-right: 20px; + padding: .4rem; + width: auto !important; + height: auto !important; + } + + .close-icon:hover { + background-color: #ECECED !important; + border-radius: 50%; + } + + .title { + font-size: 2.375em; + font-weight: lighter; + color: #000000; + opacity: 0.8; + margin-bottom: 0.842em; + } + + .content { + width: 31em; + margin: 0px; + padding: 0px; + } + + // .mat-form-field { + // background: #fafafa; + // border: 1px solid #d1d1d1; + // border-radius: 4px; + // } + + .hint { + font-size: 0.875rem; + font-weight: 500; + color: #212121; + opacity: 0.81; + } + + ::ng-deep .mat-dialog-container { + border-radius: 8px; + } + + .search { + padding: 2px !important; + } + + ::ng-deep .search { + .mat-form-field-infix { + font-size: 1rem; + padding: 0.6em 0 1em 0 !important; + } + + // .mat-form-field-underline { + // display: none; + // } + // .mat-form-field-flex { + // padding: 0em; + // } + // .align-arrow-right { + // display: none; + // } + } + + .select-role { + width: 20% !important; + font-size: 14px; + color: #848484; + height: min-content; + margin-right: 2rem; + border: none; + background-color: transparent; + } + + ::ng-deep .select-role { + + .mat-form-field-outline-start, + .mat-form-field-outline-gap, + .mat-form-field-outline-end { + border: none !important; + } + + .mat-select-arrow-wrapper { + transform: none !important; + } + } + + ::ng-deep .select-role .mat-form-field-wrapper { + padding-bottom: 0 !important; + } + + .invite-btn { + background: #ffffff 0% 0% no-repeat padding-box; + border: 1px solid var(--primary-color); + border-radius: 30px; + opacity: 1; + min-width: 101px; + height: 43px; + color: var(--primary-color); + font-weight: 500; + } + + .invite-btn-disabled { + min-width: 6.64em; + height: 2.93em; + background: #ffffff; + border: 1px solid #b5b5b5; + border-radius: 30px; + font-weight: bold; + letter-spacing: -0.35px; + color: #b5b5b5; + margin-bottom: 0.25em; + cursor: default; + } + + .invite-btn:hover { + background: var(--primary-color); + color: #ffffff; + } + + @keyframes blink { + 0% { + border: 1px solid rgba(255, 0, 0, 0.2); + } + + 50% { + border: 1px solid rgba(255, 0, 0, 0.5); + } + + 100% { + border: 1px solid rgba(255, 0, 0, 0.2); + } + } + + :host ::ng-deep .invalid-email { + border: 1px solid red; + // animation: blink 1.4s infinite; + // animation-fill-mode: both; + } +} diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.ts similarity index 56% rename from dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts rename to dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.ts index b7b19a9ff..3378c5425 100644 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.component.ts @@ -2,19 +2,26 @@ import { COMMA, ENTER } from '@angular/cdk/keycodes'; import { Component, Inject, OnInit } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; -import { MatChipInputEvent } from '@angular/material/chips'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { DmpUserInvitePersist } from '@app/core/model/dmp/dmp'; import { User } from '@app/core/model/user/user'; -import { RequestItem } from '@app/core/query/request-item'; +import { UserLookup } from '@app/core/query/user.lookup'; +import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { UserService } from '@app/core/services/user/user.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; +import { FilterService } from '@common/modules/text-filter/filter-service'; +import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; +import { DmpInvitationDialogEditorModel } from './dmp-invitation-dialog.editor.model'; @Component({ selector: 'app-invitation-dialog-component', @@ -23,37 +30,12 @@ import { map, takeUntil } from 'rxjs/operators'; }) export class DmpInvitationDialogComponent extends BaseComponent implements OnInit { - public formGroup: UntypedFormGroup; - public filteredUsersAsync = false; - public filteredUsers: User[]; - public emails: string[] = []; - public roles = DmpUserRole; - visible = true; - selectable = true; - removable = true; - addOnBlur = true; + dmpId: Guid; + editorModel: DmpInvitationDialogEditorModel; + formGroup: UntypedFormGroup; + dmpUserRoleEnum = DmpUserRole; readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - constructor( - public enumUtils: EnumUtils, - public route: ActivatedRoute, - public router: Router, - private language: TranslateService, - public dialogRef: MatDialogRef, - private uiNotificationService: UiNotificationService, - @Inject(MAT_DIALOG_DATA) public data: any - ) { - super(); - } - - ngOnInit(): void { - //TODO refactor - // const invitation = new DmpInvitation(); - // invitation.dataManagementPlan = this.data.dmpId; - // invitation.role = Role.Member; - // this.formGroup = invitation.buildForm(); - } - usersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { filterFn: this.filterUsers.bind(this), initialItems: (excludedItems: any[]) => this.filterUsers('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), @@ -74,61 +56,67 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni }] }; - add(event: MatChipInputEvent): void { - const input = event.input; - const value = event.value; - if ((value || '').trim()) { - this.emails.push(value.trim()); - } - if (input) { - input.value = ''; - } + constructor( + public enumUtils: EnumUtils, + public route: ActivatedRoute, + public router: Router, + private language: TranslateService, + public dialogRef: MatDialogRef, + private uiNotificationService: UiNotificationService, + private dmpService: DmpService, + private userService: UserService, + private filterService: FilterService, + @Inject(MAT_DIALOG_DATA) public data: any + ) { + super(); + this.dmpId = data.dmpId; } - remove(email: string): void { - const index = this.emails.indexOf(email); - if (index >= 0) { - this.emails.splice(index, 1); - } + ngOnInit() { + this.editorModel = new DmpInvitationDialogEditorModel(); + this.formGroup = this.editorModel.buildForm(); } - send(value: any) { - let invitationObject: any = {}; - invitationObject.dataManagementPlan = this.data.dmpId; - invitationObject.role = this.formGroup.get('role').value; - invitationObject.users = []; - invitationObject.users.push(...(this.formGroup.get('users').value).filter(user => typeof (user) === 'string').map(email => ({ email: email, name: email }))); - invitationObject.users.push(...(this.formGroup.get('users').value).filter(user => typeof (user) !== 'string')); - //invitationObject.users.push(...this.formGroup.get('users').value); - this.emails.forEach(email => { - invitationObject.users.push({ email: email, name: email }); - }); + send() { + if (!this.formGroup.valid) { return; } + const value: DmpUserInvitePersist = this.formGroup.value; + // invitationObject.users.push(...(this.formGroup.get('users').value).filter(user => typeof (user) === 'string').map(email => ({ email: email, name: email }))); + // invitationObject.users.push(...(this.formGroup.get('users').value).filter(user => typeof (user) !== 'string')); + // this.emails.forEach(email => { + // invitationObject.users.push({ email: email, name: email }); + // }); - //TODO refactor - // this.invitationService.inviteDmpInvitationUsers(invitationObject) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => { - // this.dialogRef.close(); - // this.onCallbackSuccess(); - // }, - // error => this.onCallbackError(error) - // ); + this.dmpService.inviteUsers(this.dmpId, value) + .pipe(takeUntil(this._destroyed)) + .subscribe( + complete => { + this.dialogRef.close(); + this.onCallbackSuccess(); + }, + error => this.onCallbackError(error) + ); } closeDialog(): void { this.dialogRef.close(); } - filterUsers(value: string): Observable { - this.filteredUsers = undefined; - this.filteredUsersAsync = true; - //TODO refactor - // const request = new RequestItem(); - // request.criteria = { like: value }; - // return this.invitationService.getDmpInvitationUsers(request) - // .pipe(takeUntil(this._destroyed)); - return null; + filterUsers(like: string): Observable { + //TODO: refactor. Change with a service that provides a list of the users assosiated with your account. + const lookup: UserLookup = new UserLookup(); + 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.name) + ] + }; + lookup.order = { items: [nameof(x => x.name)] }; + if (like) { lookup.like = this.filterService.transformLike(like); } + return this.userService.query(lookup).pipe(takeUntil(this._destroyed), map(x => x.items)); } hasValue(): boolean { @@ -142,5 +130,4 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni onCallbackError(errorResponse: any) { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.INVITATION-DIALOG.ERROR'), SnackBarNotificationLevel.Error); } - } diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.editor.model.ts b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.editor.model.ts new file mode 100644 index 000000000..088131fdc --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.editor.model.ts @@ -0,0 +1,34 @@ +import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; +import { DmpUserRole } from "@app/core/common/enum/dmp-user-role"; +import { DmpUserInvitePersist, DmpUserInviteTypePersist } from "@app/core/model/dmp/dmp"; +import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; +import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; +import { Validation, ValidationContext } from '@common/forms/validation/validation-context'; + +export class DmpInvitationDialogEditorModel implements DmpUserInvitePersist { + users: DmpUserInviteTypePersist[]; + role: DmpUserRole = DmpUserRole.User; + + public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); + protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); + + constructor() { } + + buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup { + if (context == null) { context = this.createValidationContext(); } + + return this.formBuilder.group({ + users: [{ value: this.users, disabled: disabled }, context.getValidation('users').validators], + role: [{ value: this.role, disabled: disabled }, context.getValidation('role').validators], + }); + } + + createValidationContext(): ValidationContext { + const baseContext: ValidationContext = new ValidationContext(); + const baseValidationArray: Validation[] = new Array(); + baseValidationArray.push({ key: 'users', validators: [BackendErrorValidator(this.validationErrorModel, 'users')] }); + baseValidationArray.push({ key: 'role', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'role')] }); + baseContext.validation = baseValidationArray; + return baseContext; + } +} diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.module.ts b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.module.ts new file mode 100644 index 000000000..f3e47a248 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/invitation/dialog/dmp-invitation-dialog.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; +import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DmpInvitationDialogComponent } from './dmp-invitation-dialog.component'; + +@NgModule({ + imports: [CommonUiModule, FormsModule, ReactiveFormsModule, AutoCompleteModule, RichTextEditorModule], + declarations: [DmpInvitationDialogComponent], + exports: [DmpInvitationDialogComponent] +}) +export class DmpInvitationDialogModule { + constructor() { } +} diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.html b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.html deleted file mode 100644 index 8d9829904..000000000 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.html +++ /dev/null @@ -1,75 +0,0 @@ -
-
-
- close -
-
-

{{'DMP-LISTING.ACTIONS.INVITE-AUTHORS' | translate}}

-
-
- - - - - -

- info_outlined - {{'GENERAL.INVITATION-DIALOG.HINT' | translate}} -

-
- - - {{enumUtils.toRoleString(roles.Owner)}} - {{enumUtils.toRoleString(roles.Member)}} - - - - -
-
-
-
- - - - - - - - - - - - - diff --git a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.scss b/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.scss deleted file mode 100644 index 6a4ec26e4..000000000 --- a/dmp-frontend/src/app/ui/dmp/invitation/dmp-invitation-dialog.component.scss +++ /dev/null @@ -1,135 +0,0 @@ -.form-container { - width: 33em; - min-height: 14em; - padding: 0.28em 0.34em 0em 1.125em; -} - -.close-icon { - cursor: pointer; - // margin-right: 20px; - padding: .4rem; - width: auto !important; - height: auto !important; -} - -.close-icon:hover { - background-color: #ECECED !important; - border-radius: 50%; -} - -.title { - font-size: 2.375em; - font-weight: lighter; - color: #000000; - opacity: 0.8; - margin-bottom: 0.842em; -} - -.content { - width: 31em; - margin: 0px; - padding: 0px; -} - -// .mat-form-field { -// background: #fafafa; -// border: 1px solid #d1d1d1; -// border-radius: 4px; -// } - -.hint { - font-size: 0.875rem; - font-weight: 500; - color: #212121; - opacity: 0.81; -} - -::ng-deep .mat-dialog-container { - border-radius: 8px; -} - -.search { - padding: 2px !important; -} - -::ng-deep .search { - .mat-form-field-infix { - font-size: 1rem; - padding: 0.6em 0 1em 0 !important; - } - // .mat-form-field-underline { - // display: none; - // } - // .mat-form-field-flex { - // padding: 0em; - // } - // .align-arrow-right { - // display: none; - // } -} - -.select-role { - width: 20% !important; - font-size: 14px; - color: #848484; - height: min-content; - margin-right: 2rem; - border: none; - background-color: transparent; -} - -::ng-deep .select-role { - .mat-form-field-outline-start, - .mat-form-field-outline-gap, - .mat-form-field-outline-end { - border: none !important; - } - .mat-select-arrow-wrapper { - transform: none !important; - } -} - -::ng-deep .select-role .mat-form-field-wrapper { - padding-bottom: 0 !important; -} - -.invite-btn { - background: #ffffff 0% 0% no-repeat padding-box; - border: 1px solid var(--primary-color); - border-radius: 30px; - opacity: 1; - min-width: 101px; - height: 43px; - color: var(--primary-color); - font-weight: 500; -} - -.invite-btn-disabled { - min-width: 6.64em; - height: 2.93em; - background: #ffffff; - border: 1px solid #b5b5b5; - border-radius: 30px; - font-weight: bold; - letter-spacing: -0.35px; - color: #b5b5b5; - margin-bottom: 0.25em; - cursor: default; -} - -.invite-btn:hover { - background: var(--primary-color); - color: #ffffff; -} - -@keyframes blink{ - 0% {border: 1px solid rgba(255, 0, 0, 0.2);} - 50% {border: 1px solid rgba(255, 0, 0, 0.5);} - 100% {border: 1px solid rgba(255, 0, 0, 0.2);} -} - -:host ::ng-deep .invalid-email{ - border: 1px solid red; - // animation: blink 1.4s infinite; - // animation-fill-mode: both; -} diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts index 148a6688e..3831394e5 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.module.ts @@ -7,6 +7,7 @@ import { CommonUiModule } from '@common/ui/common-ui.module'; import { CloneDmpDialogModule } from '../clone-dialog/dmp-clone-dialog.module'; import { NewVersionDmpDialogModule } from '../new-version-dialog/dmp-new-version-dialog.module'; import { DmpListingRoutingModule } from './dmp-listing.routing'; +import { DmpInvitationDialogModule } from '../invitation/dialog/dmp-invitation-dialog.module'; @NgModule({ imports: [ @@ -15,6 +16,7 @@ import { DmpListingRoutingModule } from './dmp-listing.routing'; FormattingModule, CloneDmpDialogModule, NewVersionDmpDialogModule, + DmpInvitationDialogModule, DmpListingRoutingModule ], declarations: [ diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index 876abaf1a..568017f76 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -30,7 +30,7 @@
open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} add{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}} - group_add{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}} + group_add{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}} filter_none{{'DMP-LISTING.ACTIONS.CLONE' | translate}} library_books{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index d5f2a7556..9cc02a874 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -27,6 +27,7 @@ import { FileFormat } from '@app/core/model/file/file-format.model'; import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { CloneDmpDialogComponent } from '../../clone-dialog/dmp-clone-dialog.component'; import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-version-dialog.component'; +import { DmpInvitationDialogComponent } from '../../invitation/dialog/dmp-invitation-dialog.component'; @Component({ selector: 'app-dmp-listing-item-component', @@ -84,18 +85,16 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { return this.authentication.currentAccountIsAuthenticated(); } - openShareDialog(rowId: any, rowName: any) { - //TODO: add this. - // const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // // height: '250px', - // // width: '700px', - // autoFocus: false, - // restoreFocus: false, - // data: { - // dmpId: rowId, - // dmpName: rowName - // } - // }); + inviteToDmp() { + const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { + // height: '250px', + // width: '700px', + autoFocus: false, + restoreFocus: false, + data: { + dmpId: this.dmp.id + } + }); } editClicked(dmpId: String) { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index d76411232..6cff527c2 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1780,6 +1780,17 @@ "NEW-VERSION": "Create New Version" } }, + "DMP-USER-INVITATION-DIALOG": { + "TITLE": "Invite authors", + "FIELDS": { + "USERS": "Kat or kat@example.com", + "USERS-PLACEHOLDER": "Kat or kat@example.com", + "USERS-HINT": "Press comma or enter between authors" + }, + "ACTIONS": { + "INVITE": "Invite" + } + }, "DMP-BLUEPRINT-LISTING": { "TITLE": "DMP Blueprints", "CREATE-DMP-BLUEPRINT": "Create DMP Blueprint",