no message

This commit is contained in:
annabakouli 2017-11-27 15:40:16 +02:00
parent 2c47630087
commit 95b937cfcc
61 changed files with 951 additions and 1184 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
dmp-frontend/dist.7z dmp-frontend/dist.7z
.idea/

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.2.11.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.3.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.0" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-c3p0:5.2.11.Final" level="project" />
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:4.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:4.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:4.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:jstl:1.2" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:2.8.4" level="project" />
<orderEntry type="library" name="Maven: javax.transaction:jta:1.1" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20160810" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-jdbc:7.0.35" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-juli:7.0.35" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
<orderEntry type="library" name="Maven: org.postgresql:postgresql:9.4.1212" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:jcl-over-slf4j:1.7.12" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:slf4j-log4j12:1.7.12" level="project" />
<orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" name="Maven: com.google.apis:google-api-services-oauth2:v2-rev75-1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.api-client:google-api-client:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava-jdk5:13.0" level="project" />
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client-jackson2:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client:1.19.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client-jetty:1.19.0" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client-java6:1.19.0" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty:6.1.26" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty-util:6.1.26" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:servlet-api:2.5-20081211" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:23.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
</component>
</module>

View File

@ -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;
}
}

View File

@ -0,0 +1,17 @@
package models.components.datasetprofile;
import java.util.List;
public class FieldSet {
private List<Field> fields;
public List<Field> getFields() {
return fields;
}
public void setFields(List<Field> fields) {
this.fields = fields;
}
}

View File

@ -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<FieldSet> 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<FieldSet> getCompositeFields() {
return compositeFields;
}
public void setCompositeFields(List<FieldSet> compositeFields) {
this.compositeFields = compositeFields;
}
}

View File

@ -0,0 +1,57 @@
package models.components.datasetprofile;
import java.util.List;
public class Section {
private List<Section> sections;
private List<Group> fieldGroups;
private Boolean defaultVisibility;
private int page;
private String id;
private String title;
private String description;
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
public List<Group> getFieldGroups() {
return fieldGroups;
}
public void setFieldGroups(List<Group> 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;
}
}

View File

@ -0,0 +1,17 @@
package models.composite;
import models.components.datasetprofile.*;
import java.util.List;
public class DatasetProfile {
private List<Section> sections;
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
}

View File

@ -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<Object> 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()+"\"}");
}
}
}

View File

@ -0,0 +1,6 @@
package utilities;
public interface XmlSerializable <T>{
String toXml(T item);
T fromXml(String xml);
}

View File

@ -0,0 +1,5 @@
package utilities.builders;
public class ModelBuilder {
}

View File

@ -5,9 +5,9 @@
##########################Persistence########################################## ##########################Persistence##########################################
persistence.jdbc.driver = org.postgresql.Driver persistence.jdbc.driver = org.postgresql.Driver
persistence.jdbc.url = jdbc:postgresql://HOST:PORT/DB persistence.jdbc.url = jdbc:postgresql://develdb1.madgik.di.uoa.gr:5432/dmptool
persistence.dbusername = USER persistence.dbusername = dmptool
persistence.dbpassword = PASS persistence.dbpassword = dmpt00lu$r
##########################/Persistence########################################## ##########################/Persistence##########################################
###################Allowed Proxy Service Host ############################ ###################Allowed Proxy Service Host ############################

View File

@ -1,6 +1,5 @@
import { Component, OnInit} from '@angular/core'; import { Component, OnInit} from '@angular/core';
import { ServerService } from './services/server.service'; import { ServerService } from './services/server.service';
import { FieldBase } from '../app/form/fields/field-base';
import { JsonObjest } from '../app/entities/JsonObject.class'; import { JsonObjest } from '../app/entities/JsonObject.class';
import { TokenService, TokenProvider } from './services/login/token.service'; import { TokenService, TokenProvider } from './services/login/token.service';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute, NavigationExtras } from '@angular/router'; 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 { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/autocomplete-remote.component';
declare var $ :any; declare var $ :any;

View File

@ -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 { VisibilityRulesService } from './visibility-rules/visibility-rules.service';
import { DynamicFormSectionComponent } from './form/dynamic-form-section/dynamic-form-section'; import { DynamicFormSectionComponent } from './form/dynamic-form-section/dynamic-form-section';
import { DynamicFormCompositeFieldComponent } from './form/dynamic-form-composite-field/dynamic-form-composite-field'; 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 { AppComponent } from './app.component';
import { RestBase } from './services/rest-base'; import { RestBase } from './services/rest-base';
import { DynamicFormComponent } from './form/dynamic-form.component'; 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 { ServerService } from './services/server.service';
import { GlobalVariables } from './services/global-variables.service'; import { GlobalVariables } from './services/global-variables.service';
import { TokenService, TokenProvider } from './services/login/token.service'; import { TokenService, TokenProvider } from './services/login/token.service';
import { LocalStorageService } from 'ngx-webstorage'; import { LocalStorageService } from 'ngx-webstorage';
import { dataModelBuilder } from './services/dataModelBuilder.service';
import { DynamicFormGroupComponent } from './form/dynamic-form-group/dynamic-form-group.component'; 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 { AuthGuard } from './guards/auth.guard';
import { PageNotFoundComponent } from './not-found.component'; import { PageNotFoundComponent } from './not-found.component';
import { HomepageComponent } from './homepage/homepage.component'; import { HomepageComponent } from './homepage/homepage.component';
import { TocComponent } from './form/tableOfContents/toc.component'; import { TocComponent } from './form/tableOfContents/toc.component';
import { ConfirmationComponent } from './widgets/confirmation/confirmation.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 { 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 { DatasetTableFilterPipe } from './pipes/dataset-table-filter.pipe';
import { DatasetStatusFilterPipe } from './pipes/dataset-status-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 { DmpTableFilterPipe } from './pipes/dmp-table-filter.pipe';
import { DmpStatusFilterPipe } from './pipes/dmp-status-filter.pipe'; import { DmpStatusFilterPipe } from './pipes/dmp-status-filter.pipe';
import { DmpVersionFilterPipe } from './pipes/dmp-version-filter.pipe'; import { DmpVersionFilterPipe } from './pipes/dmp-version-filter.pipe';
import { ProjectTableFilterPipe } from './pipes/project-table-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 { ProjectDetailComponent } from './projects/project.detail';
import { ModalComponent } from './modal/modal.component'; import { ModalComponent } from './modal/modal.component';
import { NgDatepickerModule } from 'ng2-datepicker'; import { NgDatepickerModule } from 'ng2-datepicker';
import { StatusToString } from './pipes/various/status-to-string'; import { StatusToString } from './pipes/various/status-to-string';
import { SidebarModule } from 'ng-sidebar'; import { SidebarModule } from 'ng-sidebar';
import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/autocomplete-remote.component';
import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner'; import { Ng4LoadingSpinnerModule } from 'ng4-loading-spinner';
import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component'; import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
@ -85,6 +92,8 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
DynamicFormFieldComponent, DynamicFormFieldComponent,
DynamicFormGroupComponent, DynamicFormGroupComponent,
DynamicFormCompositeFieldComponent, DynamicFormCompositeFieldComponent,
DynamicFieldBooleanDecisionComponent,
DynamicFieldRadioBoxComponent,
TocComponent, TocComponent,
GooggleSignInComponent, GooggleSignInComponent,
MainSignInComponent, MainSignInComponent,
@ -97,6 +106,7 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
DatasetsComponent, DatasetsComponent,
ConfirmationComponent, ConfirmationComponent,
AutocompleteRemoteComponent, AutocompleteRemoteComponent,
DynamicFieldDropdownComponent,
DynamicFormSectionComponent, DynamicFormSectionComponent,
ProjectTableFilterPipe, ProjectTableFilterPipe,
DmpVersionFilterPipe, DmpVersionFilterPipe,
@ -105,6 +115,7 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
DatasetTableFilterPipe, DatasetTableFilterPipe,
DatasetStatusFilterPipe, DatasetStatusFilterPipe,
StatusToString, StatusToString,
DynamicFieldCheckBoxComponent,
BreadcrumbComponent, DmpDetailedComponent, ProjectDetailedComponent BreadcrumbComponent, DmpDetailedComponent, ProjectDetailedComponent
], ],
imports: [ imports: [
@ -126,12 +137,12 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
], ],
providers: [{ providers: [{
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: GlobalInterceptor, useClass: GlobalInterceptor,
multi: true, multi: true,
}, },
ServerService, dataModelBuilder,VisibilityRulesService, GlobalVariables, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService,NativeLoginService ServerService, VisibilityRulesService, GlobalVariables, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService, NativeLoginService
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { export class AppModule {

View File

@ -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<string, FieldBase<any>>;
private fIndSources : Map<string, Source>;
groups: GroupBase<any>[] = [];
fields: FieldBase<any>[] = [];
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<string, FieldBase<any>>();
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);
}
}

View File

@ -1,5 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { GroupBase } from '../../form/dynamic-form-group/group-base';
@Injectable() @Injectable()
export class Section { export class Section {
@ -8,6 +7,5 @@ export class Section {
id: string; id: string;
defaultVisibility: boolean; defaultVisibility: boolean;
ordinal: number; ordinal: number;
groupFields: GroupBase<any>[];
page:number; page:number;
} }

View File

@ -0,0 +1,5 @@
<div [formGroup]="textFormGroup">
<label >{{field.title}}</label>
<input auto-complete class="form-control autocomplete" formControlName="text" [source]="values" >
</div>

View File

@ -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;
}
} */
}

View File

@ -0,0 +1,4 @@
<div [formGroup]="form">
<input type="radio" formControlName="value" value="true">Yes<br>
<input type="radio" formControlName="value" value="false">No
</div>

View File

@ -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(){
}
}

View File

@ -0,0 +1,5 @@
<div [formGroup]="form" class="form-group" >
<label>{{field.title}}</label>
<input formControlName="value" type = "checkbox">
</div>

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
<div [formGroup]="form">
<select class="form-control" formControlName="value">
<option *ngFor="let opt of field.data.values" [value]="opt.value">{{opt.label}}</option>
</select>
</div>

View File

@ -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(){
}
}

View File

@ -0,0 +1,5 @@
<div [formGroup]="form">
<div *ngFor="let option of this.field.data.options">
<input type="radio" formControlName="value" value="option.value">{{option.label}}<br>
</div>
</div>

View File

@ -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(){
}
}

View File

@ -0,0 +1 @@
@CHARSET "UTF-8";

View File

@ -48,13 +48,14 @@
</select> </select>
</div> --> </div> -->
<div *ngSwitchCase="'comboBox'"> <div *ngSwitchCase="'combobox'">
<!--TODO--> <!--TODO-->
<autocomplete-remote *ngIf="field.url" formControlName="value" [url]="field.url"></autocomplete-remote> <div *ngIf="this.field.data.type === 'autocomplete'">
<df-autocomplete [form]="form" [field]="field"></df-autocomplete>
<select *ngIf="!field.url" class="form-control" [id]="field.key" formControlName="value"> </div>
<option *ngFor="let opt of field.options" >{{opt._label}}</option> <div *ngIf="this.field.data.type === 'wordlist'">
</select> <df-dropdown [form]="form" [field]="field"></df-dropdown>
</div>
</div> </div>
@ -66,26 +67,21 @@
</div> --> </div> -->
<div *ngSwitchCase="'checkBox'" class="checkbox"> <div *ngSwitchCase="'checkBox'" class="checkbox">
<label class="checkBoxLabelCustom"> <df-checkbox [form]="form" [field]="field"></df-checkbox>
<input class="form-check" formControlName="value" type="checkbox">{{field.title}}
</label>
</div> </div>
<div *ngSwitchCase="'textarea'"> <div *ngSwitchCase="'textarea'">
<textarea class="form-control" formControlName="value"> </textarea> <textarea class="form-control" formControlName="value"> </textarea>
</div> </div>
<div *ngSwitchCase="'booleanDecision'">
<df-booleanDecision [form]="form" [field]="field"></df-booleanDecision>
</div>
<div *ngSwitchCase="'radiobox'"> <div *ngSwitchCase="'radiobox'">
<ng-container *ngFor="let answrBase of field.answers"> <df-radiobox [form]="form" [field]="field"></df-radiobox>
<div style="display: inline-block;margin-right:10px;" [id]="field.key">
<label for="{{answrBase.id}}" style="padding: 8px 10px; padding-right:5px;">{{answrBase.answer}}</label>
<input type="radio" [formControlName]="value" [id]="answrBase.id" [value]="answrBase.value" [(ngModel)]="field.value" (change)="toggleVisibility($event, field,false)"
[required]="field.required" />
</div>
</ng-container>
</div> </div>
</div> </div>
<div *ngSwitchCase="'label'"> </div> <div *ngSwitchCase="'label'"> </div>

View File

@ -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
}
}

View File

@ -1,7 +1,6 @@
import { CompositeField } from '../../models/CompositeField'; import { CompositeField } from '../../models/CompositeField';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { Section } from '../../entities/model/section'; import { Section } from '../../entities/model/section';
import { DataModel } from '../../entities/DataModel';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'df-composite-field', selector: 'df-composite-field',

View File

@ -1,11 +1,7 @@
import { FieldGroup } from '../../models/FieldGroup'; import { FieldGroup } from '../../models/FieldGroup';
import { DataModel } from '../../entities/DataModel';
import { GroupBase } from './group-base';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, Validators, FormControl } from '@angular/forms'; import { FormGroup, Validators, FormControl } from '@angular/forms';
import { NgForm } 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'; import { Rule } from '../../entities/common/rule';
@ -16,7 +12,6 @@ import { Rule } from '../../entities/common/rule';
styleUrls: ['./dynamic-form-group.component.css'] styleUrls: ['./dynamic-form-group.component.css']
}) })
export class DynamicFormGroupComponent implements OnInit { export class DynamicFormGroupComponent implements OnInit {
@Input() dataModel: DataModel;
@Input() group: FieldGroup @Input() group: FieldGroup
@Input() form: FormGroup; @Input() form: FormGroup;
@Input() pathName:string; @Input() pathName:string;

View File

@ -1,47 +0,0 @@
import { Rule } from '../../entities/common/rule';
import { FieldBase } from '../fields/field-base';
export class GroupBase<T>{
value: T;
key: string;
title: string;
rules: Rule[];
groupFields: FieldBase<T>[];
visible: boolean;
order:number;
controlType:string;
section:string;
style:string;
class: string;
page: number;
compositeFields: GroupBase<T>;
constructor(options: {
value?: T,
key?: string,
title?: string,
rules?: Rule[],
groupFields?: FieldBase<T>[],
visible?: boolean,
order?: number,
controlType?: string
section?: string,
style?:string
class?:string,
page?:number,
compositeFields?:GroupBase<T>
} = {}) {
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;
}
}

View File

@ -1,6 +1,5 @@
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { Section } from '../../entities/model/section'; import { Section } from '../../entities/model/section';
import { DataModel } from '../../entities/DataModel';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'df-section', selector: 'df-section',

View File

@ -7,7 +7,7 @@
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> <form novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
<div *ngFor = "let section of dataModel.sections; let i = index;"> <div *ngFor = "let section of dataModel.sections; let i = index;">
<df-section [section]="section" [form]="form.get('sections').get(''+i)"></df-section> <df-section [section]="section" [form]="form.get('sections').get(''+i)" [pathName]="'sections.'+i"></df-section>
</div> </div>
<!-- <div *ngFor="let group of dataModel.groups"> <!-- <div *ngFor="let group of dataModel.groups">

View File

@ -13,13 +13,9 @@ import 'rxjs/add/operator/switchMap';
//import { FieldBase } from '../../app/form/fields/field-base'; //import { FieldBase } from '../../app/form/fields/field-base';
import { FieldControlService } from '../../app/services/field-control.service'; import { FieldControlService } from '../../app/services/field-control.service';
import { ServerService } from '../../app/services/server.service'; import { ServerService } from '../../app/services/server.service';
import { dataModelBuilder } from '../../app/services/dataModelBuilder.service';
import { DataModel } from '../entities/DataModel';
import { GroupBase } from './dynamic-form-group/group-base';
import { PaginationService } from '../../app/services/pagination.service'; import { PaginationService } from '../../app/services/pagination.service';
import { TokenService, TokenProvider } from '../services/login/token.service'; import { TokenService, TokenProvider } from '../services/login/token.service';
import { ModalComponent } from '../modal/modal.component'; import { ModalComponent } from '../modal/modal.component';
import { AutocompleteRemoteComponent } from './fields/autocomplete-remote/autocomplete-remote.component';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
@ -52,7 +48,7 @@ declare var PerfectScrollbar : any;
'../../assets/perfect-scrollbar/perfect-scrollbar.css' '../../assets/perfect-scrollbar/perfect-scrollbar.css'
], ],
providers: [ providers: [
FieldControlService, ServerService, dataModelBuilder FieldControlService, ServerService
] ]
}) })
export class DynamicFormComponent implements OnInit { export class DynamicFormComponent implements OnInit {
@ -66,6 +62,7 @@ export class DynamicFormComponent implements OnInit {
finalizeStatus:boolean = false; finalizeStatus:boolean = false;
id: string; id: string;
datasetId: string; datasetId: string;
pathName:string;
//datasetProperties:string; //datasetProperties:string;
private fragment: string; private fragment: string;
@ -74,7 +71,7 @@ export class DynamicFormComponent implements OnInit {
expandedToc : boolean = true; expandedToc : boolean = true;
constructor(private qcs: FieldControlService, private serverService: ServerService, private dataModelService: dataModelBuilder, private router: Router, constructor(private qcs: FieldControlService, private serverService: ServerService, private router: Router,
private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService,private visibilityRulesService:VisibilityRulesService) { private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService,private visibilityRulesService:VisibilityRulesService) {
this.form = this.qcs.toFormGroup(new Array(), new Array()); this.form = this.qcs.toFormGroup(new Array(), new Array());
this.xml2jsonOBJ = new X2JS(); this.xml2jsonOBJ = new X2JS();

View File

@ -1,4 +0,0 @@
<label *ngIf="label" for="{{id}}">{{label}}</label>
<input auto-complete class="form-control autocomplete" id="{{id}}" [(ngModel)]="value" (ngModelChange)="updateByQuery($event)" [source]="values" >

View File

@ -1,97 +0,0 @@
import { Component, OnInit,Input, Output, EventEmitter, forwardRef} from '@angular/core';
import { Validators, ControlValueAccessor, NG_VALUE_ACCESSOR } 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: 'autocomplete-remote',
templateUrl: './autocomplete-remote.component.html',
styleUrls: ['./autocomplete-remote.component.css'],
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => AutocompleteRemoteComponent),
multi: true
}
]
})
export class AutocompleteRemoteComponent implements OnInit, ControlValueAccessor {
id : string = UUID.UUID();
@Input() label : string;
@Input() url : string;
selectedValue : string;
values : any[] = new Array();
query : string = "";
constructor(private serverService :ServerService) {
}
ngOnInit() {
this.updateByQuery(this.query); //just to trigger the first call
}
updateByQuery(query : string){
this.serverService.getThroughProxy(this.url, query).subscribe(
response => {
this.values.length = 0; //clear array; -- this is quite a fast and memory efficient way
response.data.forEach(element => {
this.values.push(element.attributes.name);
});
},
error => {
console.log(error);
}
);
}
onChange: any = () => { };
onTouched: any = () => { };
get value() {
this.value = this.selectedValue;
return this.selectedValue;
}
set value(val) {
this.selectedValue = val;
this.onChange(val);
this.onTouched();
}
registerOnChange(fn) {
this.onChange = fn;
}
registerOnTouched(fn) {
this.onTouched = fn;
}
writeValue(value) {
if (value) {
this.value = value;
}
}
}

View File

@ -1 +0,0 @@
<input [formControlName]="field.key" [(ngModel)]="field.value" [id]="field.key" [type]="field.type" (change)="field.value = ckb.checked" #ckb>

View File

@ -1,11 +0,0 @@
import {FieldBase} from '../field-base';
export class CheckBoxField extends FieldBase<boolean>{
controlType = 'checkbox';
type: "checkbox";
constructor(options: {} = {}){
super(options);
this.type = options['type'] || [];
}
}

View File

@ -1,11 +1,9 @@
import {FieldBase} from '../field-base';
export class DropdownField extends FieldBase<string>{ export class DropdownField {
controlType = 'dropdown'; controlType = 'dropdown';
options: {key: string, value: string}[] =[]; options: {key: string, value: string}[] =[];
constructor(options: {} = {}){ constructor(options: {} = {}){
super(options);
this.options = options['options'] || []; this.options = options['options'] || [];
} }
} }

View File

@ -1,229 +0,0 @@
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
import { VisibilityRuleSource } from '../../visibility-rules/models/VisibilityRuleSource';
import { Field } from '../../models/Field';
import { DataModel } from '../../entities/DataModel';
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 { GroupBase } from '../../form/dynamic-form-group/group-base';
import { DropdownField } from '../../form/fields/dropdown/field-dropdown';
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() dataModel: DataModel;
@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
}
ngAfterViewChecked(): void { //navigate to certain section of the page
try {
document.querySelector('#' + this.fragment).scrollIntoView();
} catch (e) { }
}
ruleVisibleMethod(field, rule, dataModel) { //visibility rule -- checks if target field is visible
dataModel.fields.forEach(fld => {
if (fld.label == rule._target && fld.visible == true)
field.visible = true;
});
if (field.visible == true)
return true;
}
FieldValueRuleMethod(field, rule, targetField) { //fieldValue rule -- checks the value of target and apply rules, at the same time when the field becomes visible /calling the AddvalidationRules we apply the validation rules for the new field
var fieldValue = this.form.get(field.key).value;//to do: change field.value
if (rule._ruleStyle == "range") {
if (parseInt(rule._from) < parseInt(field.value) && parseInt(field.value) < parseInt(rule._to)) {
console.log("visible" + field.value)
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
if (rule._ruleStyle == "boolean" && field.value !== undefined) { //boolean Decision field
let ruleValue = rule.value.__text;
if (field.value.toString() == ruleValue) { //field.value.value.toString() == ruleValue
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
if (rule._ruleStyle == "checked") { //checkbox field
if (field.value == true) {
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
if (rule._ruleStyle == "unchecked") { //checkbox field
if (field.value !== "") {
if (field.value == false) {
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
}
if (rule._ruleStyle == "existence") {
if (field.visible == "true" || field.visible == true) {
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
if (rule._ruleStyle == "regex") {
if (new RegExp(rule.__cdata).test(field.value)) {
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
if (rule._ruleStyle == "dropdownValue") { //dropdown field
let fieldValue = this.form.get(field.key).value;
let ruleValue;
let ruleValueBoolean = false;
if (rule.value.length)
rule.value.forEach(value => {
if (fieldValue.toString() == value.__text)
ruleValueBoolean = true;
return;
});
else
ruleValue = rule.value.__text;
if (fieldValue.toString() == ruleValue || ruleValueBoolean.valueOf() == true) { //field.value.value.toString() == ruleValue
targetField.visible = true;
this.AddvalidationRules(targetField);
} else {
this.hideField(targetField, rule);
}
}
}
hideField(targetField, rule) {
targetField.visible = false;
targetField.value = ' ';
if (this.form.controls[targetField.key].hasError("pattern"))
this.form.controls[targetField.key].reset(); //the regex error message didn't remove without field reset
this.form.controls[targetField.key].clearValidators(); // when a field is hidden must clear the validators and the errors
this.form.controls[targetField.key].updateValueAndValidity();
}
findTargetField (field, rule){
// var targetField = this.dataModel.getFieldByKey(rule._target);
let targetFields = new Array();
if (this.dataModel.getFieldByKey(rule._target) == undefined) {
this.dataModel.groups.forEach(gr => {
if (gr.key == rule._target) {
gr.groupFields.forEach(field=>{
targetFields.push(field);
});
if(gr.compositeFields)
gr.compositeFields.groupFields.forEach(field=>{
targetFields.push(field);
});
}
})
} else {
targetFields.push(this.dataModel.getFieldByKey(rule._target));
}
return targetFields;
}
toggleVisibility(e, field, ckb) { //ckb the checkbox only send this parameter, it's essential to change the field value
if (ckb) {
if (e) this.form.get(field.key).patchValue(e.target.checked)
field.value = this.form.get(field.key).value;
}
if (field.rules.length != undefined && field.rules.length > 1)
field.rules.forEach(rule => {
if (rule._type == "fieldValue") {
let targetFieldsArray = this.findTargetField(field,rule);
targetFieldsArray.forEach(targetField =>{
this.FieldValueRuleMethod(field, rule, targetField);
})
}
});
else if (field.rules._type == "fieldValue") {
let targetFieldsArray = this.findTargetField(field,field.rules);
targetFieldsArray.forEach(targetField =>{
this.FieldValueRuleMethod(field, field.rules, targetField);
})
}
}
AddvalidationRules(field) {
if (this.dataModel.getFieldByKey(field.key).attributes.validation != undefined) {
let arrayVal = new Array();
this.dataModel.getFieldByKey(field.key).attributes.validation.forEach(rule => {
if (rule.ruleStyle.toString() == RuleStyle[RuleStyle.existence]) {
this.dataModel.getFieldByKey(field.key).required = true;
arrayVal.push(Validators.required);
}
if (rule.ruleStyle.toString() == RuleStyle[RuleStyle.regex]) {
this.dataModel.getFieldByKey(field.key).regex = rule.regex;
arrayVal.push(Validators.pattern(rule.regex));
}
if (rule.ruleStyle.toString() == RuleStyle[RuleStyle.customValidation]) {
arrayVal.push(this.forbiddenNameValidator(/nothing/i));
}
});
this.form.controls[field.key].setValidators(arrayVal); //Multiple Validators, Usage of array because setValidator override any validators that are provided during initialistaion
this.form.controls[field.key].updateValueAndValidity(); //hide--> 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;
};
}
}

View File

@ -1,11 +0,0 @@
import {FieldBase} from '../field-base';
export class LabelField extends FieldBase<string> {
controlType = 'label';
type: string;
constructor (options: {} = {}) {
super(options);
this.type = options['type'] || '';
}
}

View File

@ -1 +0,0 @@
<input [formControlName]="field.key" [(ngModel)]="field.value" [type]="field.type" >

View File

@ -1,13 +0,0 @@
import {FieldBase} from '../field-base';
export class RadioBoxField extends FieldBase<boolean>{
controlType = 'radiobox';
type: "radio";
answers: Array<any>;
constructor(options: {} = {}){
super(options);
this.type = options['type'] || [];
this.answers = options['answers'] || []
}
}

View File

@ -1,5 +1,4 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { DataModel } from '../../entities/DataModel';
//import * as $ from '../../../../node_modules/jquery/dist/jquery' //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{ export class TocComponent implements OnInit{
@Input() dataModel: DataModel;
private headers = new Array(); private headers = new Array();
@Output() @Output()
setPage:EventEmitter<number> = new EventEmitter<number>(); setPage:EventEmitter<number> = new EventEmitter<number>();
ngOnInit(){ ngOnInit(){
var len = this.dataModel.groups.length; // I don't use headers , I use datamodel.groupfields
for (var i=0; i<len; i++){
this.headers.push (this.dataModel.groups[i].title)
}
} }

View File

@ -13,7 +13,7 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
public viewStyle:string; public viewStyle:string;
public defaultVisibility:boolean; public defaultVisibility:boolean;
public page:number; public page:number;
public data:any;
fromJSONObject(item:any):Field{ fromJSONObject(item:any):Field{
this.id = item.id; this.id = item.id;
this.title = item.title; this.title = item.title;
@ -23,6 +23,7 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
this.viewStyle = item.viewStyle; this.viewStyle = item.viewStyle;
this.defaultVisibility = item.defaultVisibility; this.defaultVisibility = item.defaultVisibility;
this.page = item.page; this.page = item.page;
this.data = item.data;
return this; return this;
} }
@ -35,7 +36,8 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
extendedDescription:[this.extendedDescription], extendedDescription:[this.extendedDescription],
viewStyle: [this.viewStyle], viewStyle: [this.viewStyle],
defaultVisibility:[this.defaultVisibility], defaultVisibility:[this.defaultVisibility],
page:[this.page] page:[this.page],
data:[this.data]
}); });
return formGroup; return formGroup;
} }

View File

@ -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<any>[];
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<any>[] = [];
fields.forEach(element => {
if (element.viewStyle._renderstyle == "freetext") {
let newfield: FieldBase<any>;
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<Rule>();
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<Rule>();
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<any>;
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<any>;
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<any>[] = [];
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<string>();
// 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<any>;
// 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<any>[]) {
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<inputArray.length; i++){
if(item[propertyName] == inputArray[i][propertyName] && item['key'] != inputArray[i]['key']){
DuplicateArray.push(inputArray[i]);
}
}
});
console.log(DuplicateArray);
}
}

View File

@ -1,15 +1,12 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
import { FieldBase } from '../../app/form/fields/field-base';
import { GroupBase } from '../form/dynamic-form-group/group-base';
@Injectable() @Injectable()
export class FieldControlService { export class FieldControlService {
constructor(){ } constructor(){ }
toFormGroup(fields: FieldBase<any>[], groups: GroupBase<any>[]){ toFormGroup(fields: any, groups:any){
let form: any = {}; let form: any = {};

View File

@ -19,7 +19,7 @@ export class RestBase {
protocol: string = "http"; protocol: string = "http";
hostname: string ="localhost" hostname: string ="localhost"
port: number = 7070; port: number = 8080;
webappname: string = "dmp-backend"; webappname: string = "dmp-backend";
/* /*

View File

@ -1,9 +1,6 @@
import {Injectable, ReflectiveInjector, Injector} from '@angular/core'; import {Injectable, ReflectiveInjector, Injector} from '@angular/core';
import {FieldBase} from '../../app/form/fields/field-base';
import {JsonObjest} from '../../app/entities/JsonObject.class'; import {JsonObjest} from '../../app/entities/JsonObject.class';
import {dataModelBuilder} from '../../app/services/dataModelBuilder.service';
import { DatasetProfile } from '../entities/datasetprofile'; import { DatasetProfile } from '../entities/datasetprofile';
import {DataModel} from '../entities/DataModel';
import {Project} from '../entities/model/project'; import {Project} from '../entities/model/project';
import {RestBase} from './rest-base'; import {RestBase} from './rest-base';
import 'rxjs/Rx'; import 'rxjs/Rx';

View File

@ -1,11 +1,17 @@
export const TestModel = { export const TestModel = {
"rules": [ "rules": [
{ {
"sourceField": "useMetadataQ211", "sourceField": "dataSummary",
"targetField": "metadataStandarsA211", "targetField": "metadataStandarsA211",
"requiredValue": "true", "requiredValue": "true",
"type": "visibility", "type": "visibility",
}, },
{
"sourceField": "radioChoices",
"targetField": "notlistedUrlA211",
"requiredValue": "between15and18",
"type": "visibility",
},
{ {
"sourceField": "dataSummary", "sourceField": "dataSummary",
"targetField": "freeOfChargeGroupCommentA213", "targetField": "freeOfChargeGroupCommentA213",
@ -18,12 +24,6 @@ export const TestModel = {
"requiredValue": "true", "requiredValue": "true",
"type": "visibility", "type": "visibility",
}, },
{
"sourceField": "FindDataMetadataGroup",
"targetField": "notlistedUrlA211",
"requiredValue": "true",
"type": "visibility",
},
{ {
"sourceField": "FindDataMetadataGroup", "sourceField": "FindDataMetadataGroup",
"targetField": "notlistedCommentA211", "targetField": "notlistedCommentA211",
@ -31,7 +31,7 @@ export const TestModel = {
"type": "visibility", "type": "visibility",
}, },
{ {
"sourceField": "useVocabulariesQ212", "sourceField": "dataSummary",
"targetField": "standardisedVocabulariesA212", "targetField": "standardisedVocabulariesA212",
"requiredValue": "true", "requiredValue": "true",
"type": "visibility", "type": "visibility",
@ -88,7 +88,25 @@ export const TestModel = {
"title": "", "title": "",
"description": "", "description": "",
"extendedDescription": "", "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?", "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.", "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", "extendedDescription": "FieldGroup Description",
"viewStyle": "booleanDesicion" "viewStyle": "booleanDecision",
"data": {
}
} }
] ]
}, },
@ -137,11 +158,15 @@ export const TestModel = {
[ [
{ {
"id": "metadataStandarsA211", "id": "metadataStandarsA211",
"defaultVisibility": "false", "defaultVisibility": "true",
"title": "Metadata standards", "title": "Metadata standards",
"description": "The data will be described by metadata that follows the metadata standards described in <url1>, <url2>, ? The data will be described by metadata that follows the metadata schema described in <not-listed-url1>, <not-listed-url2>. The metadata will be stored in the service located at <metadata-repo-url>", "description": "The data will be described by metadata that follows the metadata standards described in <url1>, <url2>, ? The data will be described by metadata that follows the metadata schema described in <not-listed-url1>, <not-listed-url2>. The metadata will be stored in the service located at <metadata-repo-url>",
"extendedDescription": "", "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", "title": "Not listed",
"description": "", "description": "",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "checkBox" "viewStyle": "checkBox",
}] "data": {
}
}
]
}, },
{ {
"fields": "fields":
@ -165,7 +194,10 @@ export const TestModel = {
"title": "Url", "title": "Url",
"description": "URL to the description of the metadata scheme used", "description": "URL to the description of the metadata scheme used",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "freetext" "viewStyle": "freetext",
"data": {
}
}] }]
}, },
{ {
@ -177,7 +209,10 @@ export const TestModel = {
"title": "Comments", "title": "Comments",
"description": "", "description": "",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "freetext" "viewStyle": "freetext",
"data": {
}
}] }]
}, },
{ {
@ -189,7 +224,10 @@ export const TestModel = {
"title": "The data will not be described by any metadata.", "title": "The data will not be described by any metadata.",
"description": "", "description": "",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "checkBox" "viewStyle": "checkBox",
"data": {
}
} }
] ]
} }
@ -211,7 +249,10 @@ export const TestModel = {
"title": "Q2.1.2 Will your metadata use standardised vocabularies?", "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.", "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", "extendedDescription": "FieldGroup Description",
"viewStyle": "booleanDesicion" "viewStyle": "booleanDesicion",
"data": {
}
}] }]
}, },
{ {
@ -222,7 +263,15 @@ export const TestModel = {
"title": "Existing standardised vocabularies", "title": "Existing standardised vocabularies",
"description": "The metadata will make use of the standardised vocabulary <url>", "description": "The metadata will make use of the standardised vocabulary <url>",
"extendedDescription": "", "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", "title": "Not listed vocabulary",
"description": "", "description": "",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "checkBox" "viewStyle": "checkBox",
"data": {
}
}] }]
}, },
{ {
@ -244,7 +296,10 @@ export const TestModel = {
"title": "Vocabulary Url", "title": "Vocabulary Url",
"description": "The user can put the URL to the new vocabulary", "description": "The user can put the URL to the new vocabulary",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "freetext" "viewStyle": "freetext",
"data": {
}
}] }]
}, },
{ {
@ -255,7 +310,10 @@ export const TestModel = {
"title": "Comments", "title": "Comments",
"description": "Vocabulary short description", "description": "Vocabulary short description",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "freetext" "viewStyle": "freetext",
"data": {
}
}] }]
}, },
{ {
@ -266,7 +324,10 @@ export const TestModel = {
"title": "The metadata will not make use of any vocabulary", "title": "The metadata will not make use of any vocabulary",
"description": "", "description": "",
"extendedDescription": "", "extendedDescription": "",
"viewStyle": "checkBox" "viewStyle": "checkBox",
"data": {
}
} }
] ]
} }
@ -281,28 +342,34 @@ export const TestModel = {
"extendedDescription": "FieldGroup Description", "extendedDescription": "FieldGroup Description",
"compositeFields": [ "compositeFields": [
{ {
"fields": [ "fields": [
{ {
"id": "freeOfChargeGroupQ213", "id": "freeOfChargeGroupQ213",
"defaultVisibility": "true", "defaultVisibility": "true",
"title": "Q2.1.3 Will you use standardised formats for some or all of your data.", "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.", "description": "User is presented with a choice of ?yes?, ?no?. There should be a ?comments? field for additional information.",
"extendedDescription": "Field Description", "extendedDescription": "Field Description",
"viewStyle": "booleanDesicion" "viewStyle": "booleanDesicion",
}] "data": {
},
{ }
"fields": [ }]
{ },
"id": "freeOfChargeGroupCommentA213", {
"defaultVisibility": "true", "fields": [
"title": "Comments", {
"description": "", "id": "freeOfChargeGroupCommentA213",
"extendedDescription": "", "defaultVisibility": "true",
"viewStyle": "freetext" "title": "Comments",
} "description": "",
] "extendedDescription": "",
} "viewStyle": "freetext",
"data": {
}
}
]
}
] ]
} }
] ]

View File

@ -9,6 +9,7 @@ export class VisibilityRulesService {
public formGroup: FormGroup; public formGroup: FormGroup;
public visibilityRuleContext: VisibilityRulesContext; public visibilityRuleContext: VisibilityRulesContext;
public fieldsPathMemory: any = {}; public fieldsPathMemory: any = {};
public isElementVisible(pathKey: string, id: string) { public isElementVisible(pathKey: string, id: string) {
if (!this.fieldsPathMemory[id]) this.fieldsPathMemory[id] = pathKey; if (!this.fieldsPathMemory[id]) this.fieldsPathMemory[id] = pathKey;
let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id); let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id);
@ -20,8 +21,8 @@ export class VisibilityRulesService {
let sourceVisibilityRules = visibilityRule.sourceVisibilityRules; let sourceVisibilityRules = visibilityRule.sourceVisibilityRules;
for (let i = 0; i < sourceVisibilityRules.length; i++) { for (let i = 0; i < sourceVisibilityRules.length; i++) {
let sourceVisibilityRule = sourceVisibilityRules[i]; let sourceVisibilityRule = sourceVisibilityRules[i];
if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value')|| if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value'))continue;
(sourceVisibilityRule.sourceControlValue != this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value)) return false; if(sourceVisibilityRule.sourceControlValue != ''+this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value) return false;
} }
return true; return true;
} }

View File

@ -51,15 +51,6 @@
</head> </head>
<body> <body>
<script>
  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
      console.log('User signed out.');
localStorage.removeItem('currentUser');
    });
  }
</script>
<app-root></app-root> <app-root></app-root>