From 95b937cfcc6dfcda1e3ab7d41756b7b1a1947bc1 Mon Sep 17 00:00:00 2001 From: annabakouli Date: Mon, 27 Nov 2017 15:40:16 +0200 Subject: [PATCH] no message --- .gitignore | 1 + dmp-backend/dmp-backend.iml | 88 ++++ .../components/datasetprofile/Field.java | 64 +++ .../components/datasetprofile/FieldSet.java | 17 + .../components/datasetprofile/Group.java | 70 ++++ .../components/datasetprofile/Section.java | 57 +++ .../java/models/composite/DatasetProfile.java | 17 + .../src/main/java/rest/entities/Admin.java | 28 ++ .../main/java/utilities/XmlSerializable.java | 6 + .../java/utilities/builders/ModelBuilder.java | 5 + dmp-backend/src/main/resources/dmp.properties | 6 +- dmp-frontend/src/app/app.component.ts | 2 - dmp-frontend/src/app/app.module.ts | 59 +-- dmp-frontend/src/app/entities/DataModel.ts | 62 --- .../src/app/entities/model/section.ts | 2 - .../autocomplete-remote.component.css | 0 .../autocomplete-remote.component.html | 5 + .../autocomplete-remote.component.spec.ts | 0 .../autocomplete-remote.component.ts | 95 +++++ ...amic-field-boolean-decision.component.html | 4 + ...ynamic-field-boolean-decision.component.ts | 17 + .../dynamic-field-checkbox.css} | 0 .../dynamic-field-checkbox.html | 5 + .../dynamic-field-checkbox.ts | 14 + .../dynamic-field-dropdown.css} | 0 .../dynamic-field-dropdown.html | 5 + .../dynamic-field-dropdown.ts | 17 + .../dynamic-field-radiobox.component.html | 5 + .../dynamic-field-radiobox.component.ts | 17 + .../field-radiobox.css} | 0 .../dynamic-field-textarea}/textarea.ts | 0 .../dynamic-field-textbox/field-textbox.css | 1 + .../dynamic-field-textbox}/field-textbox.html | 0 .../dynamic-field-textbox}/field-textbox.ts | 20 +- .../dynamic-form-field.component.html | 282 +++++++------ .../dynamic-form-field.component.ts | 48 +++ .../{fields => dynamic-fields}/field-base.ts | 100 ++--- .../dynamic-form-composite-field.ts | 1 - .../dynamic-form-group.component.ts | 5 - .../app/form/dynamic-form-group/group-base.ts | 47 --- .../dynamic-form-section.ts | 1 - .../src/app/form/dynamic-form.component.html | 2 +- .../src/app/form/dynamic-form.component.ts | 9 +- .../autocomplete-remote.component.html | 4 - .../autocomplete-remote.component.ts | 97 ----- .../form/fields/checkbox/field-checkbox.html | 1 - .../form/fields/checkbox/field-checkbox.ts | 11 - .../form/fields/dropdown/field-dropdown.ts | 4 +- .../fields/dynamic-form-field.component.ts | 229 ----------- .../src/app/form/fields/label/label.ts | 11 - .../form/fields/radiobox/field-radiobox.html | 1 - .../form/fields/radiobox/field-radiobox.ts | 13 - .../app/form/tableOfContents/toc.component.ts | 8 +- dmp-frontend/src/app/models/Field.ts | 6 +- .../app/services/dataModelBuilder.service.ts | 383 ------------------ .../src/app/services/field-control.service.ts | 5 +- dmp-frontend/src/app/services/rest-base.ts | 2 +- .../src/app/services/server.service.ts | 3 - dmp-frontend/src/app/testModel/testmodel.ts | 159 +++++--- .../visibility-rules.service.ts | 5 +- dmp-frontend/src/index.html | 9 - 61 files changed, 951 insertions(+), 1184 deletions(-) create mode 100644 dmp-backend/dmp-backend.iml create mode 100644 dmp-backend/src/main/java/models/components/datasetprofile/Field.java create mode 100644 dmp-backend/src/main/java/models/components/datasetprofile/FieldSet.java create mode 100644 dmp-backend/src/main/java/models/components/datasetprofile/Group.java create mode 100644 dmp-backend/src/main/java/models/components/datasetprofile/Section.java create mode 100644 dmp-backend/src/main/java/models/composite/DatasetProfile.java create mode 100644 dmp-backend/src/main/java/rest/entities/Admin.java create mode 100644 dmp-backend/src/main/java/utilities/XmlSerializable.java create mode 100644 dmp-backend/src/main/java/utilities/builders/ModelBuilder.java delete mode 100644 dmp-frontend/src/app/entities/DataModel.ts rename dmp-frontend/src/app/form/{fields/autocomplete-remote => dynamic-fields/dynamic-field-autocomplete}/autocomplete-remote.component.css (100%) create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.html rename dmp-frontend/src/app/form/{fields/autocomplete-remote => dynamic-fields/dynamic-field-autocomplete}/autocomplete-remote.component.spec.ts (100%) create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts rename dmp-frontend/src/app/form/{fields/checkbox/field-checkbox.css => dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.css} (100%) create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts rename dmp-frontend/src/app/form/{fields/radiobox/field-radiobox.css => dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css} (100%) create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.html create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts rename dmp-frontend/src/app/form/{fields/textbox/field-textbox.css => dynamic-fields/dynamic-field-radiobox/field-radiobox.css} (100%) rename dmp-frontend/src/app/form/{fields/textarea => dynamic-fields/dynamic-field-textarea}/textarea.ts (100%) create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.css rename dmp-frontend/src/app/form/{fields/textbox => dynamic-fields/dynamic-field-textbox}/field-textbox.html (100%) rename dmp-frontend/src/app/form/{fields/textbox => dynamic-fields/dynamic-field-textbox}/field-textbox.ts (95%) rename dmp-frontend/src/app/form/{fields => dynamic-fields}/dynamic-form-field.component.html (80%) create mode 100644 dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts rename dmp-frontend/src/app/form/{fields => dynamic-fields}/field-base.ts (96%) delete mode 100644 dmp-frontend/src/app/form/dynamic-form-group/group-base.ts delete mode 100644 dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.html delete mode 100644 dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.ts delete mode 100644 dmp-frontend/src/app/form/fields/checkbox/field-checkbox.html delete mode 100644 dmp-frontend/src/app/form/fields/checkbox/field-checkbox.ts delete mode 100644 dmp-frontend/src/app/form/fields/dynamic-form-field.component.ts delete mode 100644 dmp-frontend/src/app/form/fields/label/label.ts delete mode 100644 dmp-frontend/src/app/form/fields/radiobox/field-radiobox.html delete mode 100644 dmp-frontend/src/app/form/fields/radiobox/field-radiobox.ts delete mode 100644 dmp-frontend/src/app/services/dataModelBuilder.service.ts diff --git a/.gitignore b/.gitignore index d150e2eb8..bc031a640 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ dmp-frontend/dist.7z +.idea/ diff --git a/dmp-backend/dmp-backend.iml b/dmp-backend/dmp-backend.iml new file mode 100644 index 000000000..2f2c5871c --- /dev/null +++ b/dmp-backend/dmp-backend.iml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dmp-backend/src/main/java/models/components/datasetprofile/Field.java b/dmp-backend/src/main/java/models/components/datasetprofile/Field.java new file mode 100644 index 000000000..1e11400ac --- /dev/null +++ b/dmp-backend/src/main/java/models/components/datasetprofile/Field.java @@ -0,0 +1,64 @@ +package models.components.datasetprofile; + +public class Field { + private String id; + private String title; + private String value; + private String description; + private String extendedDescription; + private String viewStyle; + private boolean defaultVisibility; + private int page; + public Object data; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getExtendedDescription() { + return extendedDescription; + } + public void setExtendedDescription(String extendedDescription) { + this.extendedDescription = extendedDescription; + } + public String getViewStyle() { + return viewStyle; + } + public void setViewStyle(String viewStyle) { + this.viewStyle = viewStyle; + } + public boolean isDefaultVisibility() { + return defaultVisibility; + } + public void setDefaultVisibility(boolean defaultVisibility) { + this.defaultVisibility = defaultVisibility; + } + public int getPage() { + return page; + } + public void setPage(int page) { + this.page = page; + } + + +} diff --git a/dmp-backend/src/main/java/models/components/datasetprofile/FieldSet.java b/dmp-backend/src/main/java/models/components/datasetprofile/FieldSet.java new file mode 100644 index 000000000..a73bb648f --- /dev/null +++ b/dmp-backend/src/main/java/models/components/datasetprofile/FieldSet.java @@ -0,0 +1,17 @@ +package models.components.datasetprofile; + +import java.util.List; + +public class FieldSet { + private List fields; + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + +} diff --git a/dmp-backend/src/main/java/models/components/datasetprofile/Group.java b/dmp-backend/src/main/java/models/components/datasetprofile/Group.java new file mode 100644 index 000000000..02cc2dd14 --- /dev/null +++ b/dmp-backend/src/main/java/models/components/datasetprofile/Group.java @@ -0,0 +1,70 @@ +package models.components.datasetprofile; + +import java.util.List; + +public class Group { + private String id; + private String title; + private String section; + private String value; + private String description; + private String extendedDescription; + private boolean defaultVisibility; + private int page; + private List
compositeFields; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getSection() { + return section; + } + public void setSection(String section) { + this.section = section; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getExtendedDescription() { + return extendedDescription; + } + public void setExtendedDescription(String extendedDescription) { + this.extendedDescription = extendedDescription; + } + public boolean isDefaultVisibility() { + return defaultVisibility; + } + public void setDefaultVisibility(boolean defaultVisibility) { + this.defaultVisibility = defaultVisibility; + } + public int getPage() { + return page; + } + public void setPage(int page) { + this.page = page; + } + public List
getCompositeFields() { + return compositeFields; + } + public void setCompositeFields(List
compositeFields) { + this.compositeFields = compositeFields; + } +} diff --git a/dmp-backend/src/main/java/models/components/datasetprofile/Section.java b/dmp-backend/src/main/java/models/components/datasetprofile/Section.java new file mode 100644 index 000000000..f4636f80f --- /dev/null +++ b/dmp-backend/src/main/java/models/components/datasetprofile/Section.java @@ -0,0 +1,57 @@ +package models.components.datasetprofile; + +import java.util.List; + +public class Section { + private List
sections; + private List fieldGroups; + private Boolean defaultVisibility; + private int page; + private String id; + private String title; + private String description; + public List
getSections() { + return sections; + } + public void setSections(List
sections) { + this.sections = sections; + } + public List getFieldGroups() { + return fieldGroups; + } + public void setFieldGroups(List fieldGroups) { + this.fieldGroups = fieldGroups; + } + public Boolean getDefaultVisibility() { + return defaultVisibility; + } + public void setDefaultVisibility(Boolean defaultVisibility) { + this.defaultVisibility = defaultVisibility; + } + public int getPage() { + return page; + } + public void setPage(int page) { + this.page = page; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + 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; + } + + +} diff --git a/dmp-backend/src/main/java/models/composite/DatasetProfile.java b/dmp-backend/src/main/java/models/composite/DatasetProfile.java new file mode 100644 index 000000000..bb5eb9960 --- /dev/null +++ b/dmp-backend/src/main/java/models/composite/DatasetProfile.java @@ -0,0 +1,17 @@ +package models.composite; + +import models.components.datasetprofile.*; +import java.util.List; + +public class DatasetProfile { + private List
sections; + + public List
getSections() { + return sections; + } + + public void setSections(List
sections) { + this.sections = sections; + } + +} diff --git a/dmp-backend/src/main/java/rest/entities/Admin.java b/dmp-backend/src/main/java/rest/entities/Admin.java new file mode 100644 index 000000000..09cb9dc94 --- /dev/null +++ b/dmp-backend/src/main/java/rest/entities/Admin.java @@ -0,0 +1,28 @@ +package rest.entities; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import models.composite.DatasetProfile; + +@RestController +@CrossOrigin +public class Admin { + + @RequestMapping(method = RequestMethod.POST, value = { "/admin/addDmp" },consumes = "application/json", produces="application/json") + public ResponseEntity addDmp(@RequestBody DatasetProfile profile){ + try{ + return ResponseEntity.status(HttpStatus.OK).body(profile); + }catch(Exception ex){ + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\""+ex.getMessage()+"\"}"); + } + } + +} diff --git a/dmp-backend/src/main/java/utilities/XmlSerializable.java b/dmp-backend/src/main/java/utilities/XmlSerializable.java new file mode 100644 index 000000000..be5ba1086 --- /dev/null +++ b/dmp-backend/src/main/java/utilities/XmlSerializable.java @@ -0,0 +1,6 @@ +package utilities; + +public interface XmlSerializable { + String toXml(T item); + T fromXml(String xml); +} diff --git a/dmp-backend/src/main/java/utilities/builders/ModelBuilder.java b/dmp-backend/src/main/java/utilities/builders/ModelBuilder.java new file mode 100644 index 000000000..71b068f09 --- /dev/null +++ b/dmp-backend/src/main/java/utilities/builders/ModelBuilder.java @@ -0,0 +1,5 @@ +package utilities.builders; + +public class ModelBuilder { + +} diff --git a/dmp-backend/src/main/resources/dmp.properties b/dmp-backend/src/main/resources/dmp.properties index ddd3aa620..1481b852f 100644 --- a/dmp-backend/src/main/resources/dmp.properties +++ b/dmp-backend/src/main/resources/dmp.properties @@ -5,9 +5,9 @@ ##########################Persistence########################################## persistence.jdbc.driver = org.postgresql.Driver -persistence.jdbc.url = jdbc:postgresql://HOST:PORT/DB -persistence.dbusername = USER -persistence.dbpassword = PASS +persistence.jdbc.url = jdbc:postgresql://develdb1.madgik.di.uoa.gr:5432/dmptool +persistence.dbusername = dmptool +persistence.dbpassword = dmpt00lu$r ##########################/Persistence########################################## ###################Allowed Proxy Service Host ############################ diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index d7749bc34..1d8e42668 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit} from '@angular/core'; import { ServerService } from './services/server.service'; -import { FieldBase } from '../app/form/fields/field-base'; import { JsonObjest } from '../app/entities/JsonObject.class'; import { TokenService, TokenProvider } from './services/login/token.service'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router'; @@ -9,7 +8,6 @@ import {BreadcrumbModule,MenuItem} from 'primeng/primeng'; import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component'; -import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/autocomplete-remote.component'; declare var $ :any; diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index e0ebc2023..c9795b030 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -1,3 +1,12 @@ +import { + DynamicFieldRadioBoxComponent, +} from './form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component'; +import { + DynamicFieldBooleanDecisionComponent, +} from './form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component'; +import { AutocompleteRemoteComponent } from './form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component'; +import { DynamicFieldDropdownComponent } from './form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown'; +import { DynamicFieldCheckBoxComponent } from './form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox'; import { VisibilityRulesService } from './visibility-rules/visibility-rules.service'; import { DynamicFormSectionComponent } from './form/dynamic-form-section/dynamic-form-section'; import { DynamicFormCompositeFieldComponent } from './form/dynamic-form-composite-field/dynamic-form-composite-field'; @@ -15,17 +24,16 @@ import { DataTableModule } from "angular2-datatable"; import { AppComponent } from './app.component'; import { RestBase } from './services/rest-base'; import { DynamicFormComponent } from './form/dynamic-form.component'; -import { DynamicFormFieldComponent } from './form/fields/dynamic-form-field.component'; +import { DynamicFormFieldComponent } from './form/dynamic-fields/dynamic-form-field.component'; import { ServerService } from './services/server.service'; import { GlobalVariables } from './services/global-variables.service'; import { TokenService, TokenProvider } from './services/login/token.service'; import { LocalStorageService } from 'ngx-webstorage'; -import { dataModelBuilder } from './services/dataModelBuilder.service'; import { DynamicFormGroupComponent } from './form/dynamic-form-group/dynamic-form-group.component'; -import { AppRoutingModule } from './app-routing.module'; +import { AppRoutingModule } from './app-routing.module'; import { AuthGuard } from './guards/auth.guard'; -import { PageNotFoundComponent } from './not-found.component'; -import { HomepageComponent } from './homepage/homepage.component'; +import { PageNotFoundComponent } from './not-found.component'; +import { HomepageComponent } from './homepage/homepage.component'; import { TocComponent } from './form/tableOfContents/toc.component'; import { ConfirmationComponent } from './widgets/confirmation/confirmation.component'; @@ -45,30 +53,29 @@ import { NguiAutoCompleteModule } from '@ngui/auto-complete'; import { HTTP_INTERCEPTORS } from '@angular/common/http'; -import {BreadcrumbModule,MenuItem} from 'primeng/primeng'; +import { BreadcrumbModule, MenuItem } from 'primeng/primeng'; -import { CommonModule } from '@angular/common'; +import { CommonModule } from '@angular/common'; import { DatasetTableFilterPipe } from './pipes/dataset-table-filter.pipe'; import { DatasetStatusFilterPipe } from './pipes/dataset-status-filter.pipe'; -import { DatasetsComponent } from './datasets/dataset.component'; +import { DatasetsComponent } from './datasets/dataset.component'; -import { DmpComponent } from './dmps/dmp.component'; +import { DmpComponent } from './dmps/dmp.component'; import { DmpTableFilterPipe } from './pipes/dmp-table-filter.pipe'; import { DmpStatusFilterPipe } from './pipes/dmp-status-filter.pipe'; import { DmpVersionFilterPipe } from './pipes/dmp-version-filter.pipe'; import { ProjectTableFilterPipe } from './pipes/project-table-filter.pipe'; -import { ProjectsComponent } from './projects/projects.component'; +import { ProjectsComponent } from './projects/projects.component'; import { ProjectDetailComponent } from './projects/project.detail'; import { ModalComponent } from './modal/modal.component'; import { NgDatepickerModule } from 'ng2-datepicker'; import { StatusToString } from './pipes/various/status-to-string'; import { SidebarModule } from 'ng-sidebar'; -import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/autocomplete-remote.component'; import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner'; import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component'; @@ -85,6 +92,8 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det DynamicFormFieldComponent, DynamicFormGroupComponent, DynamicFormCompositeFieldComponent, + DynamicFieldBooleanDecisionComponent, + DynamicFieldRadioBoxComponent, TocComponent, GooggleSignInComponent, MainSignInComponent, @@ -97,14 +106,16 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det DatasetsComponent, ConfirmationComponent, AutocompleteRemoteComponent, + DynamicFieldDropdownComponent, DynamicFormSectionComponent, - ProjectTableFilterPipe, - DmpVersionFilterPipe, - DmpStatusFilterPipe, + ProjectTableFilterPipe, + DmpVersionFilterPipe, + DmpStatusFilterPipe, DmpTableFilterPipe, - DatasetTableFilterPipe, - DatasetStatusFilterPipe, - StatusToString, + DatasetTableFilterPipe, + DatasetStatusFilterPipe, + StatusToString, + DynamicFieldCheckBoxComponent, BreadcrumbComponent, DmpDetailedComponent, ProjectDetailedComponent ], imports: [ @@ -123,15 +134,15 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det NguiAutoCompleteModule, BreadcrumbModule, SidebarModule.forRoot() - + ], providers: [{ - provide: HTTP_INTERCEPTORS, - useClass: GlobalInterceptor, - multi: true, - }, - ServerService, dataModelBuilder,VisibilityRulesService, GlobalVariables, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService,NativeLoginService - ], + provide: HTTP_INTERCEPTORS, + useClass: GlobalInterceptor, + multi: true, + }, + ServerService, VisibilityRulesService, GlobalVariables, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService, NativeLoginService + ], bootstrap: [AppComponent] }) export class AppModule { diff --git a/dmp-frontend/src/app/entities/DataModel.ts b/dmp-frontend/src/app/entities/DataModel.ts deleted file mode 100644 index bd3c66386..000000000 --- a/dmp-frontend/src/app/entities/DataModel.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { GroupBase } from '../form/dynamic-form-group/group-base'; -import { FieldBase } from '../form/fields/field-base'; -import { Attribute } from './model/attribute'; -import { Source } from './model/source'; -import { Section } from './model/section'; - -export class DataModel { - - private fIndex : Map>; - private fIndSources : Map; - - groups: GroupBase[] = []; - fields: FieldBase[] = []; - semanticAttr: Attribute[]; - sections: Section[]; - - //need to add more class fields to describe the remaining elements of the json object fetched from the service. - //e.g. the current dataset's metadata information, the DataRepository description information, etc - - constructor(){ - - } - - public buildIndex(){ - - - this.fIndex = new Map>(); - - this.fields.forEach((field) => { - //console.log("fieldid:" +field.key); - this.fIndex.set(field.key, field); - }); - - this.groups.forEach((group) => { - group.groupFields.forEach((field) => { - //console.log("groupid: "+group.key + "fieldid:" +field.key); - this.fIndex.set(field.key, field); - }); - }); - - - this.groups.forEach((group) => { - if (group.compositeFields != undefined){ - group.compositeFields.groupFields.forEach((field) => { - //console.log("groupid: "+group.key + "fieldid:" +field.key); - this.fIndex.set(field.key, field); - }); - } - }); - - } - - public getFieldByKey(key){ - return this.fIndex.get(key); - } - - - - - - -} diff --git a/dmp-frontend/src/app/entities/model/section.ts b/dmp-frontend/src/app/entities/model/section.ts index fe540dd8c..67cae3207 100644 --- a/dmp-frontend/src/app/entities/model/section.ts +++ b/dmp-frontend/src/app/entities/model/section.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { GroupBase } from '../../form/dynamic-form-group/group-base'; @Injectable() export class Section { @@ -8,6 +7,5 @@ export class Section { id: string; defaultVisibility: boolean; ordinal: number; - groupFields: GroupBase[]; page:number; } \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.css b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.css similarity index 100% rename from dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.css rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.css diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.html new file mode 100644 index 000000000..9476988dc --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.html @@ -0,0 +1,5 @@ + +
+ + +
diff --git a/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.spec.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.spec.ts similarity index 100% rename from dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.spec.ts rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.spec.ts diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts new file mode 100644 index 000000000..1e95a360e --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts @@ -0,0 +1,95 @@ +import { Field } from '../../../models/Field'; +import { Component, OnInit, Input, Output, EventEmitter, forwardRef } from '@angular/core'; +import { ControlValueAccessor, FormControl, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms'; + +import { ServerService } from '../../../services/server.service'; +import { UUID } from 'angular2-uuid'; +import { NguiAutoCompleteModule } from '@ngui/auto-complete'; + +declare var $: any; + + +@Component({ + selector: 'df-autocomplete', + templateUrl: './autocomplete-remote.component.html', + styleUrls: ['./autocomplete-remote.component.css'] +}) + + + +export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAccessor */ { + + + @Input() field: Field; + @Input() form: FormGroup; + + private textFormGroup = new FormGroup({text:new FormControl("")}); + private loading: boolean; + values: any[] = new Array(); + typeaheadMS: number = 1400; + + constructor(private serverService: ServerService) { + + } + + + ngOnInit() { + let valueChanges = this.textFormGroup.controls['text'].valueChanges.share(); + valueChanges.subscribe(searchTerm => { + this.loading = true; + if (this.form.controls['text'].value) + this.resetFormGroupValue(); + }); + + valueChanges + .debounceTime(this.typeaheadMS) + .subscribe(searchTerm => { + if (typeof searchTerm === 'string') { + this.updateByQuery(searchTerm) + } + }); + + + } + + + resetFormGroupValue() { + this.form.patchValue({ value: null }, { emitEvent: false }); + } + + + updateByQuery(query: string) { + this.serverService.getThroughProxy(this.field.data.url, query).subscribe( + response => { + this.values.length = 0; + response.data.forEach(element => { + this.values.push(element.attributes.name); + }); + }, + error => { + console.log(error); + } + ); + } + + + onChange: any = () => { }; + onTouched: any = () => { }; + + + registerOnChange(fn) { + this.onChange = fn; + } + + registerOnTouched(fn) { + this.onTouched = fn; + } + + /* writeValue(value) { + if (value) { + this.value = value; + } + } */ + +} + diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html new file mode 100644 index 000000000..121286071 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html @@ -0,0 +1,4 @@ +
+ Yes
+ No +
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts new file mode 100644 index 000000000..3366c2912 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts @@ -0,0 +1,17 @@ +import { FormGroup } from '@angular/forms'; +import { Field } from '../../../models/Field'; +import { Component, Input, OnInit } from '@angular/core'; +import { FieldBase } from '../field-base'; + +@Component({ + selector: 'df-booleanDecision', + templateUrl: './dynamic-field-boolean-decision.component.html' +}) +export class DynamicFieldBooleanDecisionComponent implements OnInit{ + @Input() field: Field; + @Input() form: FormGroup; + + ngOnInit(){ + + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/checkbox/field-checkbox.css b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.css similarity index 100% rename from dmp-frontend/src/app/form/fields/checkbox/field-checkbox.css rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.css diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html new file mode 100644 index 000000000..19f506eaf --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.html @@ -0,0 +1,5 @@ + +
+ + +
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts new file mode 100644 index 000000000..0d5060d29 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts @@ -0,0 +1,14 @@ +import { Field } from '../../../models/Field'; +import { FormGroup } from '@angular/forms'; +import { Component, Input } from '@angular/core'; +import {FieldBase} from '../field-base'; + +@Component({ + selector: 'df-checkbox', + templateUrl: './dynamic-field-checkbox.html' +}) +export class DynamicFieldCheckBoxComponent{ + @Input() field:Field; + @Input() form:FormGroup; + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.css b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css similarity index 100% rename from dmp-frontend/src/app/form/fields/radiobox/field-radiobox.css rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.css diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html new file mode 100644 index 000000000..c175f323d --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.html @@ -0,0 +1,5 @@ +
+ +
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts new file mode 100644 index 000000000..902c56fb4 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts @@ -0,0 +1,17 @@ +import { FormGroup } from '@angular/forms'; +import { Field } from '../../../models/Field'; +import { Component, Input, OnInit } from '@angular/core'; +import { FieldBase } from '../field-base'; + +@Component({ + selector: 'df-dropdown', + templateUrl: './dynamic-field-dropdown.html' +}) +export class DynamicFieldDropdownComponent implements OnInit{ + @Input() field: Field; + @Input() form: FormGroup; + + ngOnInit(){ + + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.html new file mode 100644 index 000000000..7ad83def8 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.html @@ -0,0 +1,5 @@ +
+
+ {{option.label}}
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts new file mode 100644 index 000000000..fd3a4e1fc --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts @@ -0,0 +1,17 @@ +import { FormGroup } from '@angular/forms'; +import { Field } from '../../../models/Field'; +import { Component, Input, OnInit } from '@angular/core'; +import { FieldBase } from '../field-base'; + +@Component({ + selector: 'df-radiobox', + templateUrl: './dynamic-field-radiobox.component.html' +}) +export class DynamicFieldRadioBoxComponent implements OnInit{ + @Input() field: Field; + @Input() form: FormGroup; + + ngOnInit(){ + + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/textbox/field-textbox.css b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/field-radiobox.css similarity index 100% rename from dmp-frontend/src/app/form/fields/textbox/field-textbox.css rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/field-radiobox.css diff --git a/dmp-frontend/src/app/form/fields/textarea/textarea.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textarea/textarea.ts similarity index 100% rename from dmp-frontend/src/app/form/fields/textarea/textarea.ts rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textarea/textarea.ts diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.css b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.css new file mode 100644 index 000000000..bf67b66d0 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.css @@ -0,0 +1 @@ +@CHARSET "UTF-8"; \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/textbox/field-textbox.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.html similarity index 100% rename from dmp-frontend/src/app/form/fields/textbox/field-textbox.html rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.html diff --git a/dmp-frontend/src/app/form/fields/textbox/field-textbox.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.ts similarity index 95% rename from dmp-frontend/src/app/form/fields/textbox/field-textbox.ts rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.ts index 6e5ebe6f0..4d7f0d88d 100644 --- a/dmp-frontend/src/app/form/fields/textbox/field-textbox.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-textbox/field-textbox.ts @@ -1,11 +1,11 @@ -import {FieldBase} from '../field-base'; - -export class TextboxField extends FieldBase { - controlType = 'textbox'; - type: string; - - constructor (options: {} = {}) { - super(options); - this.type = options['type'] || ''; - } +import {FieldBase} from '../field-base'; + +export class TextboxField extends FieldBase { + controlType = 'textbox'; + type: string; + + constructor (options: {} = {}) { + super(options); + this.type = options['type'] || ''; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html similarity index 80% rename from dmp-frontend/src/app/form/fields/dynamic-form-field.component.html rename to dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html index 3f13037ee..4ca6e9c2e 100644 --- a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html @@ -1,144 +1,140 @@ - - -
-
- - -
{{field.extendedDescription}}
- -
- -
- - - - - -
- - - - -
- - - - -
- -
- -
- -
- - - -
- -
- - -
-
-
-
- -
- - -
-
The field "{{field.label}}" is required
-
The field {{field.label}} must match a regular expression {{field.regex}}
-
The field {{field.label}} custom Validation
-
- - -
- - + +
+
+ + +
{{field.extendedDescription}}
+ +
+ +
+ + + + + +
+ +
+ +
+
+ +
+
+ + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+
The field "{{field.label}}" is required
+
The field {{field.label}} must match a regular expression {{field.regex}}
+
The field {{field.label}} custom Validation
+
+ + +
+ + \ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts new file mode 100644 index 000000000..fd2ce1078 --- /dev/null +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts @@ -0,0 +1,48 @@ +import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; +import { VisibilityRuleSource } from '../../visibility-rules/models/VisibilityRuleSource'; +import { Field } from '../../models/Field'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormGroup, ValidatorFn, AbstractControl, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; + +import { FieldBase } from './field-base'; +import { RuleStyle } from '../../entities/common/rulestyle'; + + +@Component({ + selector: 'df-field', + templateUrl: './dynamic-form-field.component.html', + styles: ['.checkBoxLabelCustom {font-weight: 700;}'] +}) + +export class DynamicFormFieldComponent { + @Input() field: Field; + @Input() form: FormGroup; + @Input() pathName:string; + + private fragment: string; + + constructor(private route: ActivatedRoute,private visibilityRulesService:VisibilityRulesService) { } + + ngOnChanges(changeRecord) { + } + + + get isValid() { + return this.form.get("value").valid; + } + get isValidRequired() { + return this.form.get("value").hasError("required"); + } + get isValidPattern() { + return this.form.get("value").hasError("pattern"); + } + get isValidCustom() { + return this.form.get("value").hasError("forbiddenName"); + } + + public ngOnInit() { + this.route.fragment.subscribe(fragment => { this.fragment = fragment; }); //navigate to certain section of the page + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/field-base.ts b/dmp-frontend/src/app/form/dynamic-fields/field-base.ts similarity index 96% rename from dmp-frontend/src/app/form/fields/field-base.ts rename to dmp-frontend/src/app/form/dynamic-fields/field-base.ts index 3b4e8aa5e..21882a23f 100644 --- a/dmp-frontend/src/app/form/fields/field-base.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/field-base.ts @@ -1,51 +1,51 @@ -import { Rule } from '../../entities/common/rule'; -import { Attribute } from '../../entities/model/attribute'; - -export class FieldBase{ - value: T; - key: string; - label: string; - required:boolean; - order:number; - rules: Rule[]; - visible: boolean | string; - controlType:string; - group:string; - description:string; - attributes: Attribute; - regex:string; - url: string; - datatype: string; - - constructor(options: { - value?: T, - key?: string, - label?: string, - required?:boolean, - order?: number, - rules?: Rule[], - visible?: boolean | string, - controlType?: string - group?: string - description?: string, - attributes?: Attribute, - regex?:string, - url?: string, - datatype?:string - } = {}) { - this.value = options.value; - this.key = options.key || ''; - this.label = options.label || ''; - this.required = !! options.required; - this.order = options.order === undefined ? 1 : options.order; - this.rules = options.rules; - this.visible = options.visible; - this.controlType = options.controlType || ''; - this.group = options.group || ''; - this.description = options.description || ''; - this.attributes = options.attributes || new Attribute(); - this.regex = options.regex || ''; - this.url = options.url || ""; - this.datatype = options.datatype || ""; - } +import { Rule } from '../../entities/common/rule'; +import { Attribute } from '../../entities/model/attribute'; + +export class FieldBase{ + value: T; + key: string; + label: string; + required:boolean; + order:number; + rules: Rule[]; + visible: boolean | string; + controlType:string; + group:string; + description:string; + attributes: Attribute; + regex:string; + url: string; + datatype: string; + + constructor(options: { + value?: T, + key?: string, + label?: string, + required?:boolean, + order?: number, + rules?: Rule[], + visible?: boolean | string, + controlType?: string + group?: string + description?: string, + attributes?: Attribute, + regex?:string, + url?: string, + datatype?:string + } = {}) { + this.value = options.value; + this.key = options.key || ''; + this.label = options.label || ''; + this.required = !! options.required; + this.order = options.order === undefined ? 1 : options.order; + this.rules = options.rules; + this.visible = options.visible; + this.controlType = options.controlType || ''; + this.group = options.group || ''; + this.description = options.description || ''; + this.attributes = options.attributes || new Attribute(); + this.regex = options.regex || ''; + this.url = options.url || ""; + this.datatype = options.datatype || ""; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts index 71f24d670..dccd82325 100644 --- a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts +++ b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts @@ -1,7 +1,6 @@ import { CompositeField } from '../../models/CompositeField'; import { FormGroup } from '@angular/forms'; import { Section } from '../../entities/model/section'; -import { DataModel } from '../../entities/DataModel'; import { Component, Input, OnInit } from '@angular/core'; @Component({ selector: 'df-composite-field', diff --git a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts index 49b624e1b..f90638974 100644 --- a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts @@ -1,11 +1,7 @@ import { FieldGroup } from '../../models/FieldGroup'; -import { DataModel } from '../../entities/DataModel'; -import { GroupBase } from './group-base'; import { Component, Input, OnInit } from '@angular/core'; import { FormGroup, Validators, FormControl } from '@angular/forms'; import { NgForm } from '@angular/forms'; -import { FieldBase } from '../fields/field-base'; -import { TextboxField } from '../fields/textbox/field-textbox'; import { Rule } from '../../entities/common/rule'; @@ -16,7 +12,6 @@ import { Rule } from '../../entities/common/rule'; styleUrls: ['./dynamic-form-group.component.css'] }) export class DynamicFormGroupComponent implements OnInit { - @Input() dataModel: DataModel; @Input() group: FieldGroup @Input() form: FormGroup; @Input() pathName:string; diff --git a/dmp-frontend/src/app/form/dynamic-form-group/group-base.ts b/dmp-frontend/src/app/form/dynamic-form-group/group-base.ts deleted file mode 100644 index 6b40acb5b..000000000 --- a/dmp-frontend/src/app/form/dynamic-form-group/group-base.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Rule } from '../../entities/common/rule'; -import { FieldBase } from '../fields/field-base'; -export class GroupBase{ - value: T; - key: string; - title: string; - rules: Rule[]; - groupFields: FieldBase[]; - visible: boolean; - order:number; - controlType:string; - section:string; - style:string; - class: string; - page: number; - compositeFields: GroupBase; - - constructor(options: { - value?: T, - key?: string, - title?: string, - rules?: Rule[], - groupFields?: FieldBase[], - visible?: boolean, - order?: number, - controlType?: string - section?: string, - style?:string - class?:string, - page?:number, - compositeFields?:GroupBase - } = {}) { - this.value = options.value; - this.key = options.key || ''; - this.title = options.title || ''; - this.rules = options.rules; - this.groupFields = options.groupFields; - this.visible = options.visible; - this.order = options.order === undefined ? 1 : options.order; - this.controlType = options.controlType || ''; - this.section = options.section || ''; - this.style = options.style || ''; - this.class = options.class || ''; - this.page = options.page || 1; - this.compositeFields = options.compositeFields; - } -} diff --git a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts index 383f93850..798c451bc 100644 --- a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts +++ b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts @@ -1,6 +1,5 @@ import { FormGroup } from '@angular/forms'; import { Section } from '../../entities/model/section'; -import { DataModel } from '../../entities/DataModel'; import { Component, Input, OnInit } from '@angular/core'; @Component({ selector: 'df-section', diff --git a/dmp-frontend/src/app/form/dynamic-form.component.html b/dmp-frontend/src/app/form/dynamic-form.component.html index 9a3e00441..60fe2fc6a 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.html +++ b/dmp-frontend/src/app/form/dynamic-form.component.html @@ -7,7 +7,7 @@
- +
visible must update the validators - - } - - } - - forbiddenNameValidator(nameRe: RegExp): ValidatorFn { - return (control: AbstractControl): { [key: string]: any } => { - const forbidden = nameRe.test(control.value); - return forbidden ? { 'forbiddenName': { value: control.value } } : null; - }; - } - - -} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/label/label.ts b/dmp-frontend/src/app/form/fields/label/label.ts deleted file mode 100644 index 7c888ed78..000000000 --- a/dmp-frontend/src/app/form/fields/label/label.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {FieldBase} from '../field-base'; - -export class LabelField extends FieldBase { - controlType = 'label'; - type: string; - - constructor (options: {} = {}) { - super(options); - this.type = options['type'] || ''; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.html b/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.html deleted file mode 100644 index 4782d55a7..000000000 --- a/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.ts b/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.ts deleted file mode 100644 index 94be627eb..000000000 --- a/dmp-frontend/src/app/form/fields/radiobox/field-radiobox.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {FieldBase} from '../field-base'; - -export class RadioBoxField extends FieldBase{ - controlType = 'radiobox'; - type: "radio"; - answers: Array; - - constructor(options: {} = {}){ - super(options); - this.type = options['type'] || []; - this.answers = options['answers'] || [] - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/tableOfContents/toc.component.ts b/dmp-frontend/src/app/form/tableOfContents/toc.component.ts index db1cb50cf..35853cc17 100644 --- a/dmp-frontend/src/app/form/tableOfContents/toc.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/toc.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { DataModel } from '../../entities/DataModel'; //import * as $ from '../../../../node_modules/jquery/dist/jquery' @@ -13,17 +12,12 @@ import * as scroll from '../../../assets/jquery.scrollTo.min.js'; }) export class TocComponent implements OnInit{ - @Input() dataModel: DataModel; private headers = new Array(); @Output() setPage:EventEmitter = new EventEmitter(); - ngOnInit(){ - var len = this.dataModel.groups.length; // I don't use headers , I use datamodel.groupfields - for (var i=0; i,FormGenerato public viewStyle:string; public defaultVisibility:boolean; public page:number; - + public data:any; fromJSONObject(item:any):Field{ this.id = item.id; this.title = item.title; @@ -23,6 +23,7 @@ export class Field extends BaseModel implements Serializable,FormGenerato this.viewStyle = item.viewStyle; this.defaultVisibility = item.defaultVisibility; this.page = item.page; + this.data = item.data; return this; } @@ -35,7 +36,8 @@ export class Field extends BaseModel implements Serializable,FormGenerato extendedDescription:[this.extendedDescription], viewStyle: [this.viewStyle], defaultVisibility:[this.defaultVisibility], - page:[this.page] + page:[this.page], + data:[this.data] }); return formGroup; } diff --git a/dmp-frontend/src/app/services/dataModelBuilder.service.ts b/dmp-frontend/src/app/services/dataModelBuilder.service.ts deleted file mode 100644 index d5ea40346..000000000 --- a/dmp-frontend/src/app/services/dataModelBuilder.service.ts +++ /dev/null @@ -1,383 +0,0 @@ -import { Injectable } from '@angular/core'; -import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; -import { FieldBase } from '../../app/form/fields/field-base'; -import { TextboxField } from '../../app/form/fields/textbox/field-textbox'; -import { CheckBoxField } from '../../app/form/fields/checkbox/field-checkbox'; -import { RadioBoxField } from '../../app/form/fields/radiobox/field-radiobox'; -import { TextAreaField } from '../../app/form/fields/textarea/textarea'; -import { LabelField } from '../../app/form/fields/label/label'; -import { DataModel } from '../entities/DataModel'; -import { Rule } from '../entities/common/rule'; -import { GroupBase } from '../form/dynamic-form-group/group-base'; -import { Attribute } from '../entities/model/attribute'; -import { Param } from '../entities/model/param'; -import { Section } from '../entities/model/section'; -import { RestBase } from '../services/rest-base'; - -@Injectable() -export class dataModelBuilder { - - private dataModel: DataModel; - private fields: FieldBase[]; - - constructor(private restBase: RestBase) { } - - public getDataModel(data, dataValues) { - - if (this.dataModel != null) - return this.dataModel; - - this.dataModel = new DataModel(); - this.fields = this.buildFields(data.viewstyle.definition.root.fields.field); - - this.dataModel.semanticAttr = new Array(new Attribute); - this.dataModel.semanticAttr = this.getFieldsAttributes(data.definition.root.fields.fieldset, data.ruleset.definition.root.functions.function, this.fields); - this.dataModel.groups = this.getGroups(data.viewstyle.definition.root.fieldGroups.fieldGroup, this.fields, dataValues); - this.dataModel.sections = this.getSections(data.viewstyle.definition.root.sections.section, this.dataModel.groups); - this.dataModel.buildIndex(); - - this.checkDuplicateInObject('order', this.dataModel.groups[13].groupFields); //for future use , for composite field - - return this.dataModel; - } - - - private buildFields(fields: any[]) { - let fieldsVisible: FieldBase[] = []; - fields.forEach(element => { - if (element.viewStyle._renderstyle == "freetext") { - let newfield: FieldBase; - let rule = new Rule(); - newfield = new TextboxField({ - label: element.title.__cdata, - key: element._id, - value: element.value, - order: element._ordinal, - rules: element.visible.rule != undefined ? element.visible.rule : rule, - visible: element._defaultVisibility, - group: element._group, - description: element.description.__cdata - }); - - fieldsVisible.push(newfield); - } - else if (element.viewStyle._renderstyle == "dropdown" || element.viewStyle._renderstyle == "combobox") {//to choose one of these in xml - let newfield: DropdownField; - let rule = new Rule(); - newfield = new DropdownField({ - label: element.title.__cdata, - key: element._id, - value: element.value, - order: element._ordinal, - rules: element.visible.rule != undefined ? element.visible.rule : rule, - visible: element._defaultVisibility, - description: element.description.__cdata, - group: element._group - }); - fieldsVisible.push(newfield); - } - else if (element.viewStyle._renderstyle == "checkbox" || element.viewStyle._renderstyle == "checkBox") { - let newfield: CheckBoxField; - let rule = new Array(); - newfield = new CheckBoxField({ - label: element.title.__cdata, - key: element._id, - value: false, - order: element._ordinal, - rules: element.visible.rule != undefined ? element.visible.rule : rule, - visible: element._defaultVisibility, - group: element._group, - description: element.description.__cdata, - type: "checkbox" - }); - fieldsVisible.push(newfield); - } - else if (element.viewStyle._renderstyle == "booleanDesicion") { - let newfield: RadioBoxField; - let rule = new Array(); - newfield = new RadioBoxField({ - label: element.title.__cdata, - key: element._id, - value: element.value, - order: element._ordinal, - rules: element.visible.rule != undefined ? element.visible.rule : rule, - visible: element._defaultVisibility, - group: element._group, - type: "radio", - description: element.description.__cdata, - answers: [ - { - id: 1, - answer: "Yes", - value: true - }, - { - id: 2, - answer: "No", - value: false - }] - }); - fieldsVisible.push(newfield); - } else if (element.viewStyle._renderstyle == "textarea") { - let newfield: FieldBase; - let rule = new Rule(); - newfield = new TextAreaField({ - label: element.title.__cdata, - key: element._id, - value: element.value, - order: element._ordinal, - rules: element.visible.rule != undefined ? element.visible.rule : rule, - visible: element._defaultVisibility, - group: element._group, - description: element.description.__cdata - }); - - fieldsVisible.push(newfield); - } - - else if (element.viewStyle._renderstyle == "label") { - let newfield: FieldBase; - let rule = new Rule(); - newfield = new LabelField({ - label: element.title.__cdata, - key: element._id, - value: element.value, - order: element._ordinal, - rules: element.visible.rule != undefined ? element.visible.rule : rule, - visible: element._defaultVisibility, - group: element._group, - description: element.description.__cdata - }); - - fieldsVisible.push(newfield); - } - }); - fieldsVisible.sort((a, b) => a.order - b.order); - return fieldsVisible; - } - - private getGroups(fieldGroups: any, fields: any[], dataValues) { - let groups: GroupBase[] = []; - - if (fieldGroups.length > 1) { - fieldGroups.forEach(fieldGroup => { // each fiedgroup fills with its fields from json - let newfldGroup = new GroupBase(); - let compositeFields = new GroupBase(); - newfldGroup.groupFields = new Array(); - compositeFields.groupFields = new Array(); - - - fields.forEach(field => { - if (fieldGroup._id == field.group) { - if (dataValues != "")//--------------------------SET VALUES--------------------------------------------------------------------------------------- - if (dataValues[fieldGroup._id][field.key] != undefined) // to put values in fields - field.value = dataValues[fieldGroup._id][field.key].value == undefined ? dataValues[fieldGroup._id][field.key] : dataValues[fieldGroup._id][field.key].value; - - if(field.order.toString().split(".").length > 1){//--------------Composite Fields Multiplicity -------------------------------------------------- - compositeFields.groupFields.push(field); - newfldGroup.compositeFields = compositeFields; - }else - newfldGroup.groupFields.push(field); - } else { - //this.dataModel.fields.push(field); - } - //TO DO FIELDSET WITH MULTIPLICITY - // if (dataValues != "") - // if (dataValues[fieldGroup._id][field.key] != undefined){ - // let keys = new Array(); - // Object.keys(dataValues[fieldGroup._id]).forEach(key=>{if(key.startsWith(field.key+"_"))keys.push(key)}) - // if (keys.length) - // if (field.controlType == "textbox") { - // let newfield: FieldBase; - // let rule = new Rule(); - // newfield = new TextboxField({ - // label: field.label+"_"+ 1, - // key: keys[0], - // value: dataValues[fieldGroup._id][keys[0]].value, - // order: field.order, - // rules: field.rules, - // visible: field.visible, - // group: field.group, - // description: field.description - // });debugger; - // newfldGroup.groupFields.push(newfield); - // } - // } - - - - - }); - - newfldGroup.title = fieldGroup.title.__cdata; - newfldGroup.key = fieldGroup._id; - newfldGroup.section = fieldGroup._section; - newfldGroup.style = fieldGroup.visible._style; - newfldGroup.class = fieldGroup.visible._cssclass; - newfldGroup.page = fieldGroup._page; - groups.push(newfldGroup) - }); - } - - else { - let newfldGroup = new GroupBase(); - newfldGroup.groupFields = new Array(); - fields.forEach(field => { //for one fieldgroup, because xml to json transformation doesn't create array of one fieldfroup - if (fieldGroups._id == field.group) { - newfldGroup.groupFields.push(field); - } else - this.dataModel.fields.push(field); - }); - newfldGroup.title = fieldGroups.title.__cdata; - newfldGroup.key = fieldGroups._id; - newfldGroup.section = fieldGroups._section; - groups.push(newfldGroup) - } - return groups; - } - - addAttributesToFields(attr, functions, fields, multiplicity){ - - let newAttribute = new Attribute(); - newAttribute.datatype = attr._datatype; - newAttribute.defaultValue = attr.defaultValue._value; - newAttribute.id = attr._id; - newAttribute.multiplicityMax = attr.multiplicity._max; - newAttribute.multiplicityMin = attr.multiplicity._min; - newAttribute.ordinal = attr._ordinal - if (multiplicity){ - fields.find(x => x.key == newAttribute.id).order = fields.find(x => x.key == newAttribute.id).order +'.'+ newAttribute.ordinal; - fields.find(x => x.key == newAttribute.id).multiplicity = true; - } - newAttribute.ordinal = attr._ordinal; - newAttribute.sources = new Array(); - newAttribute.validation = new Array(); - //newAttribute.validation.push(attr.validation.rule); - //-----------------Sources--------------------------------------------------------------- - if (attr.sources) { - newAttribute.sources.push(attr.sources.source); - if (attr.sources.source.length != undefined) { - for (var i = 0; i < attr.sources.source.length; i++) { - if (attr.sources.source[i]._type == "url") { - newAttribute.url = attr.sources.source[i].value._value; - break; - } - } - } - if (attr.sources.source._type == "url") { - newAttribute.url = attr.sources.source.value._value; - } - } - //-----------Rules------------------------------------------------------------------------ - if(attr.validation.rule != undefined) - if (attr.validation.rule.length) - for (var i = 0, len = attr.validation.rule.length; i < len; i++) { - let rule = new Rule(); - rule.ruleStyle = attr.validation.rule[i]._ruleStyle; - rule.ruleType = attr.validation.rule[i]._type; - if (attr.validation.rule[i]._ruleStyle == "regex") - rule.regex = attr.validation.rule[i].__cdata; - if (attr.validation.rule[i]._ruleStyle == "customValidation") { - rule.method = attr.validation.rule[i]._method; - functions.forEach(fnc => { - if (fnc._id == rule.method) - rule.methodJs = fnc.script.__cdata; - }); - } - newAttribute.validation.push(rule); - } - else { - if (attr.validation.rule) { - let rule = new Rule(); - rule.ruleStyle = attr.validation.rule._ruleStyle; - rule.ruleType = attr.validation.rule._type; - if (attr.validation.rule._ruleStyle == "regex") - rule.regex = attr.validation.rule.__cdata; - if (attr.validation.rule._ruleStyle == "customValidation") { - rule.method = attr.validation.rule._method; - functions.forEach(fnc => { - if (fnc._id == rule.method) - rule.methodJs = fnc.__cdata; - }); - } - newAttribute.validation.push(rule); } - } - - - - fields.sort((a, b) => a.order - b.order); - - return newAttribute; - } - - private getFieldsAttributes(fieldsets: any, functions: any, fields: any[]) { - let attribute: Attribute[] = []; - let newAttribute = new Attribute(); - let multiplicityParam = false; - fieldsets.forEach(fieldset => { - let multiplicityParam = false; - if (fieldset.fields.field.length){ - if(fieldset.multiplicity._max >1 || fieldset.multiplicity._max == "n") - multiplicityParam = true; - fieldset.fields.field.forEach(fieldAttribute=>{ - newAttribute = this.addAttributesToFields(fieldAttribute, functions, fields, multiplicityParam) - attribute.push(newAttribute); - if (newAttribute.url !== undefined) - fields.find(x => x.key == newAttribute.id).url = newAttribute.url; - fields.find(x => x.key == newAttribute.id).attributes.sources = newAttribute.sources; - fields.find(x => x.key == newAttribute.id).attributes.validation = newAttribute.validation; - }) - }else{ - if(fieldset.multiplicity._max >1 || fieldset.multiplicity._max == "n") - multiplicityParam = true; - newAttribute = this.addAttributesToFields(fieldset.fields.field, functions, fields, multiplicityParam) - attribute.push(newAttribute); - if (newAttribute.url !== undefined) - fields.find(x => x.key == newAttribute.id).url = newAttribute.url; - fields.find(x => x.key == newAttribute.id).attributes.sources = newAttribute.sources; - fields.find(x => x.key == newAttribute.id).attributes.validation = newAttribute.validation; - } - }); - return attribute; - - } - - private getSections(sections: any, fieldGroups: GroupBase[]) { - let sects: Section[] = []; - - if (sections.length) { - sections.forEach(section => { - let newSection = new Section(); - newSection.defaultVisibility = section.defaultVisibility; - newSection.description = section.description; - newSection.id = section._id; - newSection.title = section.title; - newSection.ordinal = section._ordinal; - newSection.page = section._page; - newSection.groupFields = new Array(); - fieldGroups.forEach(fldgroup => { - if (fldgroup.section == newSection.id) - newSection.groupFields.push(fldgroup); - }) - sects.push(newSection); - }); - } - sects.sort((a, b) => a.ordinal - b.ordinal); - return sects; - } - - - checkDuplicateInObject(propertyName, inputArray) { - let DuplicateArray = []; - inputArray.forEach(item => { - for(var i=0; i[], groups: GroupBase[]){ + toFormGroup(fields: any, groups:any){ let form: any = {}; diff --git a/dmp-frontend/src/app/services/rest-base.ts b/dmp-frontend/src/app/services/rest-base.ts index 1d4bef211..e8972ef1a 100644 --- a/dmp-frontend/src/app/services/rest-base.ts +++ b/dmp-frontend/src/app/services/rest-base.ts @@ -19,7 +19,7 @@ export class RestBase { protocol: string = "http"; hostname: string ="localhost" - port: number = 7070; + port: number = 8080; webappname: string = "dmp-backend"; /* diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index f035a6028..00e13924d 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -1,9 +1,6 @@ import {Injectable, ReflectiveInjector, Injector} from '@angular/core'; -import {FieldBase} from '../../app/form/fields/field-base'; import {JsonObjest} from '../../app/entities/JsonObject.class'; -import {dataModelBuilder} from '../../app/services/dataModelBuilder.service'; import { DatasetProfile } from '../entities/datasetprofile'; -import {DataModel} from '../entities/DataModel'; import {Project} from '../entities/model/project'; import {RestBase} from './rest-base'; import 'rxjs/Rx'; diff --git a/dmp-frontend/src/app/testModel/testmodel.ts b/dmp-frontend/src/app/testModel/testmodel.ts index 4bf94995f..9da85c44e 100644 --- a/dmp-frontend/src/app/testModel/testmodel.ts +++ b/dmp-frontend/src/app/testModel/testmodel.ts @@ -1,11 +1,17 @@ export const TestModel = { "rules": [ { - "sourceField": "useMetadataQ211", + "sourceField": "dataSummary", "targetField": "metadataStandarsA211", "requiredValue": "true", "type": "visibility", }, + { + "sourceField": "radioChoices", + "targetField": "notlistedUrlA211", + "requiredValue": "between15and18", + "type": "visibility", + }, { "sourceField": "dataSummary", "targetField": "freeOfChargeGroupCommentA213", @@ -17,13 +23,7 @@ export const TestModel = { "targetField": "noMetadata", "requiredValue": "true", "type": "visibility", - }, - { - "sourceField": "FindDataMetadataGroup", - "targetField": "notlistedUrlA211", - "requiredValue": "true", - "type": "visibility", - }, + }, { "sourceField": "FindDataMetadataGroup", "targetField": "notlistedCommentA211", @@ -31,7 +31,7 @@ export const TestModel = { "type": "visibility", }, { - "sourceField": "useVocabulariesQ212", + "sourceField": "dataSummary", "targetField": "standardisedVocabulariesA212", "requiredValue": "true", "type": "visibility", @@ -88,7 +88,25 @@ export const TestModel = { "title": "", "description": "", "extendedDescription": "", - "viewStyle": "checkBox" + "viewStyle": "checkBox", + "data": { + + } + }, + { + "id": "radioChoices", + "defaultVisibility": "true", + "title": "", + "description": "", + "extendedDescription": "", + "viewStyle": "radiobox", + "data": { + "options": [ + { "label": "Over 18", "value": "over18" }, + { "label": "Under 15", "value": "under15" }, + { "label": "Between 15 - 18", "value": "between15and18" } + ] + } } ] } @@ -128,7 +146,10 @@ export const TestModel = { "title": "Q2.1.1 Will you use metadata to describe the data?", "description": "User can select from a list of metadata standards. If they cannot find the standard in the list provided then they should choose \"not listed\". Selecting this will result in a field in which the user can insert the URL to the description of the metadata scheme used. A \"comments\" box should exist to allow users to add comments. They may select more than one metadata standard. They may specify more than one URL when selecting \"not listed\". They are also presented with a field in which to specify the location of the metadata service. Users can select the \"no metadata\" button to specify no metadata will be used to describe the data.", "extendedDescription": "FieldGroup Description", - "viewStyle": "booleanDesicion" + "viewStyle": "booleanDecision", + "data": { + + } } ] }, @@ -137,11 +158,15 @@ export const TestModel = { [ { "id": "metadataStandarsA211", - "defaultVisibility": "false", + "defaultVisibility": "true", "title": "Metadata standards", "description": "The data will be described by metadata that follows the metadata standards described in , , ? The data will be described by metadata that follows the metadata schema described in , . The metadata will be stored in the service located at ", "extendedDescription": "", - "viewStyle": "combobox" + "viewStyle": "combobox", + "data": { + "type": "autocomplete", + "url": "http://dionysus.di.uoa.gr:8080/dmp-backend/rest/external/datarepos?query=gree" + } }] }, { @@ -153,8 +178,12 @@ export const TestModel = { "title": "Not listed", "description": "", "extendedDescription": "", - "viewStyle": "checkBox" - }] + "viewStyle": "checkBox", + "data": { + + } + } + ] }, { "fields": @@ -165,7 +194,10 @@ export const TestModel = { "title": "Url", "description": "URL to the description of the metadata scheme used", "extendedDescription": "", - "viewStyle": "freetext" + "viewStyle": "freetext", + "data": { + + } }] }, { @@ -177,7 +209,10 @@ export const TestModel = { "title": "Comments", "description": "", "extendedDescription": "", - "viewStyle": "freetext" + "viewStyle": "freetext", + "data": { + + } }] }, { @@ -189,7 +224,10 @@ export const TestModel = { "title": "The data will not be described by any metadata.", "description": "", "extendedDescription": "", - "viewStyle": "checkBox" + "viewStyle": "checkBox", + "data": { + + } } ] } @@ -211,7 +249,10 @@ export const TestModel = { "title": "Q2.1.2 Will your metadata use standardised vocabularies?", "description": "User selects from a drop-down list of existing standardised vocabularies or \"not listed\" or \"none\". There should be a \"comments\" fields for additional information. If \"not listed\" is selected the user is presented with two additional fields in which the user can put the URL to the new vocabulary along with a short description. The user should be allowed to select more than one option.", "extendedDescription": "FieldGroup Description", - "viewStyle": "booleanDesicion" + "viewStyle": "booleanDesicion", + "data": { + + } }] }, { @@ -222,7 +263,15 @@ export const TestModel = { "title": "Existing standardised vocabularies", "description": "The metadata will make use of the standardised vocabulary ", "extendedDescription": "", - "viewStyle": "combobox" + "viewStyle": "combobox", + "data": { + "type": "wordlist", + "values": [ + { "label": "Mitsos", "value": "mitsakos" }, + { "label": "Kitsos", "value": "kitsakos" }, + { "label": "Panagiotis", "value": "mpotis" } + ] + } }] }, { @@ -233,7 +282,10 @@ export const TestModel = { "title": "Not listed vocabulary", "description": "", "extendedDescription": "", - "viewStyle": "checkBox" + "viewStyle": "checkBox", + "data": { + + } }] }, { @@ -244,7 +296,10 @@ export const TestModel = { "title": "Vocabulary Url", "description": "The user can put the URL to the new vocabulary", "extendedDescription": "", - "viewStyle": "freetext" + "viewStyle": "freetext", + "data": { + + } }] }, { @@ -255,7 +310,10 @@ export const TestModel = { "title": "Comments", "description": "Vocabulary short description", "extendedDescription": "", - "viewStyle": "freetext" + "viewStyle": "freetext", + "data": { + + } }] }, { @@ -266,7 +324,10 @@ export const TestModel = { "title": "The metadata will not make use of any vocabulary", "description": "", "extendedDescription": "", - "viewStyle": "checkBox" + "viewStyle": "checkBox", + "data": { + + } } ] } @@ -281,28 +342,34 @@ export const TestModel = { "extendedDescription": "FieldGroup Description", "compositeFields": [ { - "fields": [ - { - "id": "freeOfChargeGroupQ213", - "defaultVisibility": "true", - "title": "Q2.1.3 Will you use standardised formats for some or all of your data.", - "description": "User is presented with a choice of ?yes?, ?no?. There should be a ?comments? field for additional information.", - "extendedDescription": "Field Description", - "viewStyle": "booleanDesicion" - }] - }, - { - "fields": [ - { - "id": "freeOfChargeGroupCommentA213", - "defaultVisibility": "true", - "title": "Comments", - "description": "", - "extendedDescription": "", - "viewStyle": "freetext" - } - ] - } + "fields": [ + { + "id": "freeOfChargeGroupQ213", + "defaultVisibility": "true", + "title": "Q2.1.3 Will you use standardised formats for some or all of your data.", + "description": "User is presented with a choice of ?yes?, ?no?. There should be a ?comments? field for additional information.", + "extendedDescription": "Field Description", + "viewStyle": "booleanDesicion", + "data": { + + } + }] + }, + { + "fields": [ + { + "id": "freeOfChargeGroupCommentA213", + "defaultVisibility": "true", + "title": "Comments", + "description": "", + "extendedDescription": "", + "viewStyle": "freetext", + "data": { + + } + } + ] + } ] } ] diff --git a/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts index 49a9333ea..372a4617a 100644 --- a/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts +++ b/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts @@ -9,6 +9,7 @@ export class VisibilityRulesService { public formGroup: FormGroup; public visibilityRuleContext: VisibilityRulesContext; public fieldsPathMemory: any = {}; + public isElementVisible(pathKey: string, id: string) { if (!this.fieldsPathMemory[id]) this.fieldsPathMemory[id] = pathKey; let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id); @@ -20,8 +21,8 @@ export class VisibilityRulesService { let sourceVisibilityRules = visibilityRule.sourceVisibilityRules; for (let i = 0; i < sourceVisibilityRules.length; i++) { let sourceVisibilityRule = sourceVisibilityRules[i]; - if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value')|| - (sourceVisibilityRule.sourceControlValue != this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value)) return false; + if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value'))continue; + if(sourceVisibilityRule.sourceControlValue != ''+this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value) return false; } return true; } diff --git a/dmp-frontend/src/index.html b/dmp-frontend/src/index.html index f78ba51f8..638a7992b 100644 --- a/dmp-frontend/src/index.html +++ b/dmp-frontend/src/index.html @@ -51,15 +51,6 @@ -