table of contents + pagination

This commit is contained in:
annabakouli 2017-12-05 18:56:21 +02:00
parent 95c5dd4a60
commit 80115ed3cf
58 changed files with 767 additions and 273 deletions

View File

@ -89,12 +89,16 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
Element description = doc.createElement("description");
description.setTextContent(this.description);
Element title = doc.createElement("title");
title.setTextContent(this.title);
Element viewStyle = doc.createElement("viewStyle");
viewStyle.setAttribute("renderstyle", this.viewStyle.getRenderStyle());
viewStyle.setAttribute("cssClass", this.viewStyle.getCssClass());
Element visibility = this.visible.toXml(doc);
rootElement.appendChild(title);
rootElement.appendChild(visibility);
rootElement.appendChild(extendedDescription);
rootElement.appendChild(viewStyle);
@ -114,6 +118,9 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
Element description = (Element)element.getElementsByTagName("description").item(0);
this.description = description.getTextContent();
Element title = (Element)element.getElementsByTagName("title").item(0);
this.title = title.getTextContent();
this.viewStyle = new ViewStyle();
Element viewStyle = (Element)element.getElementsByTagName("viewStyle").item(0);
this.viewStyle.setRenderStyle(viewStyle.getAttribute("renderstyle"));

View File

@ -10,6 +10,7 @@ import org.w3c.dom.NodeList;
import entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
import utilities.XmlSerializable;
import utilities.builders.XmlBuilder;
public class FieldGroup implements DatabaseViewStyleDefinition,XmlSerializable<FieldGroup>{
private String id;
@ -97,6 +98,9 @@ public class FieldGroup implements DatabaseViewStyleDefinition,XmlSerializable<F
return root;
}
@Override
public FieldGroup fromXml(Element element) {
this.id = element.getAttribute("id");
@ -104,12 +108,15 @@ public class FieldGroup implements DatabaseViewStyleDefinition,XmlSerializable<F
this.defaultVisibility = Boolean.getBoolean(element.getAttribute("defaultVisibility"));
this.page = Integer.parseInt(element.getAttribute("page"));
Element title = (Element)element.getElementsByTagName("title").item(0);
Element title = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"title");
this.title = title.getTextContent();
Element extendedDescription = (Element)element.getElementsByTagName("extendedDescription").item(0);
Element extendedDescription = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"extendedDescription");
this.extendedDescription = extendedDescription.getTextContent();
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"description");
this.description = description .getTextContent();
this.fieldSets = new LinkedList();
Element fieldSets = (Element)element.getElementsByTagName("fieldsets").item(0);
if(fieldSets!=null){

View File

@ -10,6 +10,7 @@ import org.w3c.dom.NodeList;
import entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
import utilities.XmlSerializable;
import utilities.builders.XmlBuilder;
public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Section>{
private String id;
@ -91,6 +92,9 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
Element extendedDescription = doc.createElement("extendedDescription");
extendedDescription.setTextContent(this.extendedDescription);
Element title = doc.createElement("title");
title.setTextContent(this.title);
if(sections!=null){
Element sections = doc.createElement("sections");
for(Section section : this.sections){
@ -106,6 +110,8 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
}
rootElement.appendChild(formGroups);
}
rootElement.appendChild(title);
rootElement.appendChild(extendedDescription);
rootElement.appendChild(description);
@ -119,11 +125,14 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
this.defaultVisibility = Boolean.getBoolean(element.getAttribute("defaultVisibility"));
this.page = Integer.parseInt(element.getAttribute("page"));
Element description = (Element)element.getElementsByTagName("description").item(0);
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"description");
if(description!=null) this.description = description.getTextContent();
Element extendedDescription = (Element)element.getElementsByTagName("extendedDescription").item(0);
if(extendedDescription != null) this.extendedDescription = description.getTextContent();
Element extendedDescription = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"extendedDescription");
if(extendedDescription != null) this.extendedDescription = extendedDescription.getTextContent();
Element title =XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"title");
if(title!=null) this.title = title.getTextContent();
this.sections = new LinkedList<Section>();
Element sections = (Element)element.getElementsByTagName("sections").item(0);

View File

@ -33,7 +33,7 @@ public class AdminManager {
entities.DatasetProfile datasetProfile = new entities.DatasetProfile();
datasetProfile.setDefinition(xml);
datasetProfile.setStatus((short)1);
datasetProfile.setLabel("dasd");
datasetProfile.setLabel(profile.getLabel());
datasetProfile.setCreated(new Date());
return datasetProfile;
}
@ -48,7 +48,7 @@ public class AdminManager {
DatasetProfileViewstyle datasetProfileViewstyle = new DatasetProfileViewstyle();
datasetProfileViewstyle.setDefinition(xml);
datasetProfileViewstyle.setLabel("skdjal");
datasetProfileViewstyle.setLabel(profile.getLabel());
return datasetProfileViewstyle;
}

View File

@ -8,6 +8,7 @@ import java.util.List;
import models.admin.components.datasetprofile.*;
public class DatasetProfile {
private String label;
private List<Section> sections;
public List<Section> getSections() {
@ -16,9 +17,16 @@ public class DatasetProfile {
public void setSections(List<Section> sections) {
this.sections = sections;
}
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void buildProfile(entities.xmlmodels.modeldefinition.FieldGroup fieldGroup,entities.xmlmodels.viewstyledefinition.ViewStyleModel viewStyle){
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
updateProfile(fieldGroup,viewStyle);

View File

@ -102,11 +102,22 @@ public class ComboBoxData extends FieldData<ComboBoxData>{
}
@Override
public ComboBoxData fromData(Object data) {
this.options = new LinkedList();
if(data!=null){
this.type = (String)((Map<String,Object>)data).get("type");
this.url = (String)((Map<String,Object>)data).get("url");
this.options = (List<Option>)((Map<String,Object>)data).get("options");
List<Map<String,String>> options = ((Map<String,List<Map<String,String>>>)data).get("options");
if(options!=null){
for(Map<String,String> map : options){
Option newOption = new Option();
newOption.setLabel(map.get("label"));
newOption.setValue(map.get("value"));
this.options.add(newOption);
}
}
}
return this;
}
@Override

View File

@ -0,0 +1,41 @@
package models.properties;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import models.components.commons.DefaultValue;
import models.components.commons.Multiplicity;
import models.components.commons.ViewStyle;
import models.components.commons.Visibility;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Field implements PropertiesGenerator{
private String id;
private String value;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public void toMap(Map<String,String> fieldValues){
fieldValues.put(this.id, this.value);
}
}

View File

@ -0,0 +1,30 @@
package models.properties;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import models.components.commons.Multiplicity;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class FieldSet implements PropertiesGenerator{
private List<Field> fields;
public List<Field> getFields() {
return fields;
}
public void setFields(List<Field> fields) {
this.fields = fields;
}
@Override
public void toMap(Map<String, String> fieldValues) {
this.fields.forEach(item->item.toMap(fieldValues));
}
}

View File

@ -0,0 +1,28 @@
package models.properties;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import entities.xmlmodels.viewstyledefinition.FieldGroup;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Group implements PropertiesGenerator{
private List<FieldSet> compositeFields;
public List<FieldSet> getCompositeFields() {
return compositeFields;
}
public void setCompositeFields(List<FieldSet> compositeFields) {
this.compositeFields = compositeFields;
}
@Override
public void toMap(Map<String, String> fieldValues) {
this.compositeFields.forEach(item->item.toMap(fieldValues));
}
}

View File

@ -0,0 +1,7 @@
package models.properties;
import java.util.Map;
public interface PropertiesGenerator {
void toMap(Map<String,String> fieldValues);
}

View File

@ -0,0 +1,24 @@
package models.properties;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PropertiesModel implements PropertiesGenerator{
private List<Section> sections;
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
@Override
public void toMap(Map<String, String> fieldValues) {
this.sections.forEach(item->item.toMap(fieldValues));
}
}

View File

@ -0,0 +1,32 @@
package models.properties;
import java.util.List;
import java.util.Map;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Section implements PropertiesGenerator{
private List<Section> sections;
private List<Group> fieldGroups;
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;
}
@Override
public void toMap(Map<String, String> fieldValues) {
this.sections.forEach(item->item.toMap(fieldValues));
this.fieldGroups.forEach(item->item.toMap(fieldValues));
}
}

View File

@ -1,5 +1,7 @@
package models.user.components.datasetprofile;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@ -9,11 +11,12 @@ import models.components.commons.DefaultValue;
import models.components.commons.Multiplicity;
import models.components.commons.ViewStyle;
import models.components.commons.Visibility;
import models.user.composite.PropertiesModelBuilder;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>{
public class Field implements PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.Field>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Field>{
private String id;
private int ordinal;
private String title;
@ -150,6 +153,11 @@ public class Field implements ModelDefinition<entities.xmlmodels.modeldefinition
this.title = item.getTitle();
this.viewStyle = item.getViewStyle();
this.data = item.getData();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.value = (String)properties.get(this.id);
}
}

View File

@ -2,15 +2,17 @@ package models.user.components.datasetprofile;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import models.components.commons.Multiplicity;
import models.user.composite.PropertiesModelBuilder;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
public class FieldSet implements PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.FieldSet>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldSet>{
private String id;
private int ordinal;
private Multiplicity multiplicity;
@ -80,6 +82,12 @@ public class FieldSet implements ModelDefinition<entities.xmlmodels.modeldefinit
this.id = item.getId();
this.ordinal = item.getOrdinal();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.fields.forEach(item->item.fromJsonObject(properties));
}
}

View File

@ -1,15 +1,17 @@
package models.user.components.datasetprofile;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import entities.xmlmodels.viewstyledefinition.FieldGroup;
import models.user.composite.PropertiesModelBuilder;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Group implements ModelDefinition<entities.xmlmodels.modeldefinition.FieldGroup>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldGroup>{
public class Group implements PropertiesModelBuilder, ModelDefinition<entities.xmlmodels.modeldefinition.FieldGroup>,ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.FieldGroup>{
private String id;
private String title;
private String section;
@ -115,4 +117,9 @@ public class Group implements ModelDefinition<entities.xmlmodels.modeldefinition
// TODO Auto-generated method stub
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.compositeFields.forEach(item->item.fromJsonObject(properties));
}
}

View File

@ -1,12 +1,14 @@
package models.user.components.datasetprofile;
import java.util.List;
import java.util.Map;
import models.user.composite.PropertiesModelBuilder;
import utilities.ModelDefinition;
import utilities.ViewStyleDefinition;
import utilities.builders.ModelBuilder;
public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>{
public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyledefinition.Section>,PropertiesModelBuilder{
private List<Section> sections;
private List<Group> fieldGroups;
private Boolean defaultVisibility;
@ -87,6 +89,11 @@ public class Section implements ViewStyleDefinition<entities.xmlmodels.viewstyle
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(),Section.class);
this.title = item.getTitle();
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item->item.fromJsonObject(properties));
this.fieldGroups.forEach(item->item.fromJsonObject(properties));
}
}

View File

@ -4,11 +4,12 @@ import utilities.builders.ModelBuilder;
import utilities.helpers.ModelBuilderCollector;
import java.util.List;
import java.util.Map;
import models.user.components.datasetprofile.*;
import models.user.components.commons.Rule;
public class DatasetProfile {
public class DatasetProfile implements PropertiesModelBuilder{
private List<Section> sections;
private List<Rule> rules;
public List<Section> getSections() {
@ -38,5 +39,11 @@ public class DatasetProfile {
this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections());
}
@Override
public void fromJsonObject(Map<String, Object> properties) {
this.sections.forEach(item->item.fromJsonObject(properties));
}
}

View File

@ -0,0 +1,7 @@
package models.user.composite;
import java.util.Map;
public interface PropertiesModelBuilder {
void fromJsonObject(Map<String,Object> properties);
}

View File

@ -4,11 +4,10 @@ import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
@ -62,6 +61,34 @@ public class Admin {
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/admin/addDmp/{id}" },consumes = "application/json", produces="application/json")
public ResponseEntity<Object> updateDmp(@PathVariable String id,@RequestBody DatasetProfile profile){
try{
entities.DatasetProfile modelDefinition = AdminManager.generateModelDefinition(profile);
entities.DatasetProfileViewstyle viewStyleDefinition = AdminManager.generateViewStyleDefinition(profile);
entities.DatasetProfile datasetprofile = datasetProfileDao.read(UUID.fromString(id));
entities.DatasetProfileViewstyle oldviewStyle = datasetProfileViewstyleDao.read((datasetprofile.getViewstyle().getId()));
oldviewStyle.setDefinition(viewStyleDefinition.getDefinition());
datasetProfileViewstyleDao.update(oldviewStyle);
if(!datasetprofile.getDataset().isEmpty())throw new Exception ("Cannot edit a Profile that has Datasets assigned");
datasetprofile.setViewstyle(oldviewStyle);
datasetprofile.setDefinition(modelDefinition.getDefinition());
datasetProfileDao.update(datasetprofile);
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
}catch(Exception ex){
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\""+ex.getMessage()+"\"}");
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/admin/get/{id}" }, produces="application/json")
public ResponseEntity<Object> get(@PathVariable String id){
try{

View File

@ -1,23 +1,31 @@
package rest.entities;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
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.RestController;
import com.google.gson.JsonObject;
import dao.entities.DatasetDao;
import dao.entities.DatasetProfileDao;
import dao.entities.DatasetProfileRulesetDao;
import dao.entities.DatasetProfileViewstyleDao;
import helpers.SerializerProvider;
import managers.AdminManager;
import managers.UserManager;
import models.properties.PropertiesModel;
@RestController
@CrossOrigin
@ -26,17 +34,40 @@ public class DatasetProfileController {
@Autowired private DatasetProfileDao datasetProfileDao;
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/get/{id}" }, produces="application/json")
public ResponseEntity<Object> get(@PathVariable String id){
try {
entities.DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(profile);
@Autowired private DatasetDao datasetDao;
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/get/{id}" }, produces="application/json")
public ResponseEntity<Object> getSingle(@PathVariable String id){
try {
entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
if(dataset.getProperties()!=null){
JSONObject jobject = new JSONObject(dataset.getProperties());
Map<String,Object> properties = (Map<String, Object>)jobject.toMap();
datasetprofile.fromJsonObject(properties);
}
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/save/{id}" }, consumes="application/json",produces="application/json")
public ResponseEntity<Object> postDataset(@PathVariable String id,@RequestBody PropertiesModel properties){
try {
entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
Map<String,String> values = new HashMap();
properties.toMap(values);
JSONObject jobject = new JSONObject(values);
dataset.setProperties(jobject.toString());
datasetDao.update(dataset);
return ResponseEntity.status(HttpStatus.OK).body(properties);
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
}

View File

@ -15,9 +15,14 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import entities.xmlmodels.viewstyledefinition.FieldSet;
public class XmlBuilder {
@ -66,4 +71,14 @@ public class XmlBuilder {
return null;
}
}
public static Element getNodeFromListByTagName(NodeList list, String tagName) {
for (int temp = 0; temp < list.getLength(); temp++) {
Node element = list.item(temp);
if (element.getNodeType() == Node.ELEMENT_NODE) {
if(element.getNodeName().equals(tagName))return (Element) element;
}
}
return null;
}
}

1
dmp-frontend/asdk.json Normal file
View File

@ -0,0 +1 @@
{"sections":[{"sections":[],"fieldGroups":[{"id":"dataSummaryGroup","title":"Data Summary","value":null,"description":null,"extendedDescription":null,"defaultVisibility":true,"page":null,"ordinal":"1","compositeFields":[{"id":"dataSummaryFS","ordinal":1,"fields":[{"id":"dataSummary","title":null,"description":null,"extendedDescription":null,"defaultVisibility":null,"page":null,"ordinal":1,"multiplicity":{"min":1,"max":1},"defaultValue":{"type":null,"value":null},"viewStyle":{"cssClass":null,"renderStyle":"textarea"},"visible":{"style":null,"rules":[]}}],"multiplicity":{"min":1,"max":1}}]}],"defaultVisibility":true,"page":null,"id":"datasummary","title":"Data Summary","description":null,"ordinal":"1"},{"sections":[{"sections":[],"fieldGroups":[{"id":"FindDataMetadataGroup","title":null,"value":null,"description":null,"extendedDescription":null,"defaultVisibility":true,"page":null,"ordinal":"2","compositeFields":[{"id":"useMetadataQ211FS","ordinal":1,"fields":[{"id":"useMetadataQ211","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":null,"defaultVisibility":true,"page":null,"ordinal":1,"multiplicity":{"min":1,"max":1},"defaultValue":{"type":null,"value":null},"viewStyle":{"cssClass":null,"renderStyle":"booleanDesicion"},"visible":{"style":null,"rules":[]}}],"multiplicity":{"min":1,"max":1}}]}],"defaultVisibility":true,"page":null,"id":"dataMetadata","title":"2.1 Making data findable, including provisions for metadata","description":null,"ordinal":"3"}],"fieldGroups":[],"defaultVisibility":null,"page":null,"id":"fairData","title":"2 Fair Data","description":null,"ordinal":null}],"label":"Horizon 2020 template"}

View File

@ -49,7 +49,7 @@ const appRoutes: Routes = [
RouterModule.forRoot(
appRoutes
,{
useHash: true
useHash: false
//,enableTracing: true <-- debugging purposes only
}
)

View File

@ -1,3 +1,17 @@
import {
TableOfContentsFieldComponent,
} from './form/tableOfContents/table-of-content-field/table-of-content-field.component';
import { ProgressBarComponent } from './form/pprogress-bar/progress-bar.component';
import {
TableOfContentsSectionComponent,
} from './form/tableOfContents/table-of-content-section/table-of-content-section.component';
import {
TableOfContentsGroupComponent,
} from './form/tableOfContents/table-of-content-group/table-of-content-group.component';
import {
TableOfContentsFieldSetComponent,
} from './form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component';
import { TableOfContentsComponent } from './form/tableOfContents/table-of-contents.component';
import {
DynamicFieldRadioBoxComponent,
} from './form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component';
@ -19,7 +33,7 @@ import { RouterModule, Routes, Router } from '@angular/router';
//import {DataTableModule } from 'angular-4-data-table-bootstrap-4';
import { DataTableModule } from "angular2-datatable";
//import { OrganisationTableFilterPipe } from './pipes/organisation-table-filter.pipe';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { RestBase } from './services/rest-base';
@ -34,7 +48,6 @@ 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 { TocComponent } from './form/tableOfContents/toc.component';
import { ConfirmationComponent } from './widgets/confirmation/confirmation.component';
@ -53,7 +66,7 @@ import { NguiAutoCompleteModule } from '@ngui/auto-complete';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { BreadcrumbModule, MenuItem } from 'primeng/primeng';
import { BreadcrumbModule,PanelModule, MenuItem } from 'primeng/primeng';
import { CommonModule } from '@angular/common';
@ -81,8 +94,7 @@ import { BreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';
import { DmpDetailedComponent } from './viewers/dmp-detailed/dmp-detailed.component';
import { ProjectDetailedComponent } from './viewers/project-detailed/project-detailed.component';
import {ProgressBarModule} from 'primeng/primeng';
@NgModule({
declarations: [
@ -93,7 +105,10 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
DynamicFormCompositeFieldComponent,
DynamicFieldBooleanDecisionComponent,
DynamicFieldRadioBoxComponent,
TocComponent,
TableOfContentsComponent,
TableOfContentsFieldSetComponent,
TableOfContentsGroupComponent,
TableOfContentsSectionComponent,
GooggleSignInComponent,
MainSignInComponent,
PageNotFoundComponent,
@ -113,6 +128,8 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
DatasetTableFilterPipe,
DatasetStatusFilterPipe,
StatusToString,
TableOfContentsFieldComponent,
ProgressBarComponent,
DynamicFieldCheckBoxComponent,
BreadcrumbComponent, DmpDetailedComponent, ProjectDetailedComponent
],
@ -131,6 +148,9 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
Ng4LoadingSpinnerModule,
NguiAutoCompleteModule,
BreadcrumbModule,
ProgressBarModule,
PanelModule,
BrowserAnimationsModule,
SidebarModule.forRoot()
],

View File

@ -2,6 +2,6 @@
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<select class="form-control" formControlName="value">
<option *ngFor="let opt of field.data.values" [value]="opt.value">{{opt.label}}</option>
<option *ngFor="let opt of field.data.options" [value]="opt.value">{{opt.label}}</option>
</select>
</div>

View File

@ -2,6 +2,6 @@
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<div *ngFor="let option of this.field.data.options">
<input type="radio" formControlName="value" value="option.value">{{option.label}}<br>
<input type="radio" formControlName="value" [value]="option.value">{{option.label}}<br>
</div>
</div>

View File

@ -26,22 +26,21 @@
</div> -->
<div *ngIf="this.visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" class="form-group" [ngSwitch]="field.viewStyle.renderStyle">
<div [ngClass]="{true:'show', false:'hide'}[field.visible]">
<div [id]="field.id" *ngIf="visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" [ngSwitch]="field.viewStyle.renderStyle">
<label>{{field.title}}</label>
<div *ngSwitchCase="'freetext'">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<input class="form-control" formControlName="value">
</div>
<label>{{path+' '+field.title}}</label>
<!--input or change event
<div *ngSwitchCase="'freetext'">
<label>{{field.description}}</label>
<div>{{field.extendedDescription}}</div>
<input class="form-control" formControlName="value">
</div>
<!--input or change event
on change event the listener is triggered on blur -->
<!-- <div *ngSwitchCase="'dropdown'">
<!-- <div *ngSwitchCase="'dropdown'">
<autocomplete-remote *ngIf="field.url" formControlName="value" [url]="field.url" ></autocomplete-remote>
@ -50,51 +49,49 @@
</select>
</div> -->
<div *ngSwitchCase="'combobox'">
<!--TODO-->
<div *ngIf="this.field.data.type === 'autocomplete'">
<df-autocomplete [form]="form" [field]="field"></df-autocomplete>
</div>
<div *ngIf="this.field.data.type === 'wordlist'">
<df-dropdown [form]="form" [field]="field"></df-dropdown>
</div>
<div *ngSwitchCase="'combobox'">
<!--TODO-->
<div *ngIf="this.field.data.type === 'autocomplete'">
<df-autocomplete [form]="form" [field]="field"></df-autocomplete>
</div>
<div *ngIf="this.field.data.type === 'wordlist'">
<df-dropdown [form]="form" [field]="field"></df-dropdown>
</div>
</div>
<!-- <div *ngSwitchCase="'checkbox'" class="checkbox">
<!-- <div *ngSwitchCase="'checkbox'" class="checkbox">
<label class="checkBoxLabelCustom">
<input *ngSwitchCase="'checkbox'" class="form-check" formControlName="value" [type]="field.type"
(change)="toggleVisibility($event, field, true)" [required]="field.required" [checked]="form.get(field.key).value">{{field.label}}
</label>
</div> -->
<div *ngSwitchCase="'checkBox'" class="checkbox">
<df-checkbox [form]="form" [field]="field"></df-checkbox>
</div>
<div *ngSwitchCase="'textarea'">
<textarea class="form-control" formControlName="value"> </textarea>
</div>
<div *ngSwitchCase="'booleanDecision'">
<df-booleanDecision [form]="form" [field]="field"></df-booleanDecision>
</div>
<div *ngSwitchCase="'radiobox'">
<df-radiobox [form]="form" [field]="field"></df-radiobox>
</div>
<div *ngSwitchCase="'checkBox'" class="checkbox">
<df-checkbox [form]="form" [field]="field"></df-checkbox>
</div>
<div *ngSwitchCase="'label'"> </div>
<div [hidden]="isValid">
<div class="invalid-feedbackCustom" *ngIf="isValidRequired">The field "{{field.label}}" is required</div>
<div class="invalid-feedbackCustom" *ngIf="isValidPattern">The field {{field.label}} must match a regular expression {{field.regex}}</div>
<div class="invalid-feedbackCustom" *ngIf="isValidCustom">The field {{field.label}} custom Validation</div>
<div *ngSwitchCase="'textarea'">
<textarea class="form-control" formControlName="value"> </textarea>
</div>
<div *ngSwitchCase="'booleanDecision'">
<df-booleanDecision [form]="form" [field]="field"></df-booleanDecision>
</div>
<div *ngSwitchCase="'radiobox'">
<df-radiobox [form]="form" [field]="field"></df-radiobox>
</div>
<div *ngSwitchCase="'label'"> </div>
<div [hidden]="isValid">
<div class="invalid-feedbackCustom" *ngIf="isValidRequired">The field "{{field.label}}" is required</div>
<div class="invalid-feedbackCustom" *ngIf="isValidPattern">The field {{field.label}} must match a regular expression {{field.regex}}</div>
<div class="invalid-feedbackCustom" *ngIf="isValidCustom">The field {{field.label}} custom Validation</div>
</div>
</div>

View File

@ -19,9 +19,8 @@ export class DynamicFormFieldComponent {
@Input() field: Field;
@Input() form: FormGroup;
@Input() pathName:string;
@Input() path:string;
private fragment: string;
constructor(private route: ActivatedRoute,private visibilityRulesService:VisibilityRulesService) { }
ngOnChanges(changeRecord) {
@ -41,8 +40,4 @@ export class DynamicFormFieldComponent {
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,9 @@
<div [formGroup]="form">
<div [id]="compositeField.id" [formGroup]="form">
<h4>{{compositeField.title}}</h4>
<h4>{{compositeField.description}}</h4>
<h4>{{compositeField.extendedDescription}}</h4>
<div *ngFor="let field of compositeField.fields; let i = index;">
<df-field [field]="field" [form]="form.get('fields').get(''+i)" [pathName]="pathName+'.fields.'+i"></df-field>
<df-field [field]="field" [form]="form.get('fields').get(''+i)" [path]="path" [pathName]="pathName+'.fields.'+i"></df-field>
</div>
</div>

View File

@ -11,6 +11,7 @@ import { Component, Input, OnInit } from '@angular/core';
@Input() compositeField: CompositeField
@Input() form: FormGroup;
@Input() pathName:string;
@Input() path:string;
constructor(){}

View File

@ -1,7 +1,9 @@
<div [formGroup]="form" >
<h4 >{{group.title}}</h4>
<div [id]="group.id" [formGroup]="form" >
<h4 >{{path+' '+group.title}}</h4>
<h4 >{{group.description}}</h4>
<h4 >{{group.extendedDescription}}</h4>
<div *ngFor="let compositeField of group.compositeFields; let i = index;">
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path+'.'+(i+1)" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
</div>
</div>

View File

@ -16,8 +16,8 @@ export class DynamicFormGroupComponent implements OnInit {
@Input() form: FormGroup;
@Input() pathName:string;
@Input() customStyle: {};
@Input() classFromJson: string;
@Input() path:string;
constructor() {
}

View File

@ -1,13 +1,17 @@
<div [formGroup]="form">
<h3>{{section.title}}</h3>
<div *ngIf="section.fieldGroups">
<div *ngFor="let group of section.fieldGroups; let j = index;">
<df-group [group]="group" [form]="form.get('fieldGroups').get(''+j)" [pathName]="pathName+'.fieldGroups.'+j"></df-group>
<p-panel [header]="path+' '+section.title" [toggleable]="true">
<div [id]="section.id" [formGroup]="form">
<h4>{{section.description}}</h4>
<h4>{{section.extendedDescription}}</h4>
<div *ngIf="section.fieldGroups">
<div *ngFor="let group of section.fieldGroups; let j = index;">
<df-group [group]="group" [form]="form.get('fieldGroups').get(''+j)" [path]="path+'.'+(j+1)" [pathName]="pathName+'.fieldGroups.'+j"></df-group>
</div>
</div>
<div *ngIf="section.sections">
<div *ngFor="let itemsection of section.sections; let j = index;">
<df-section [section]="itemsection" [form]="form.get('sections').get(''+j)" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j"></df-section>
</div>
</div>
</div>
<div *ngIf="section.sections">
<div *ngFor="let itemsection of section.sections; let j = index;">
<df-section [section]="itemsection" [form]="form.get('sections').get(''+j)" [pathName]="pathName+'.sections.'+j"></df-section>
</div>
</div>
</div>
</p-panel>

View File

@ -10,7 +10,7 @@ import { Component, Input, OnInit } from '@angular/core';
@Input() section: Section
@Input() form: FormGroup;
@Input() pathName:string;
@Input() path:string;
constructor(){}
ngOnInit(){

View File

@ -1,53 +1,42 @@
<div class="parent-div">
<div class=" child-div-left" [ngClass]="{true:'col-md-8 col-sm-9', false:'col-md-12 col-sm-12'}[expandedToc]">
<div class="ui-g">
<div class="ui-g-8" >
<div class="col-md-12 form-body-container" id="form-container">
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
<div *ngFor = "let section of dataModel.sections; let i = index;">
<df-section [section]="section" [form]="form.get('sections').get(''+i)" [pathName]="'sections.'+i"></df-section>
<form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
<div *ngFor="let section of dataModel.sections; let i = index;">
<df-section [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1" [pathName]="'sections.'+i"></df-section>
</div>
<!-- <div *ngFor="let group of dataModel.groups">
<df-group [group]="group" [dataModel]="dataModel" [form]="getSubForm(group.key)"></df-group>
</div> -->
</form>
</div>
<div class="col-md-12 form-footer-container">
<div>
<progress-bar *ngIf="progressbar" [formGroup]=form></progress-bar>
</div>
</div>
<!-- <div class="col-md-12 form-footer-seperator" >
</div>
<div class="col-md-12 form-footer-container" >
<div >
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow= "" aria-valuemin="0" aria-valuemax="100" [ngStyle]="{'width': dirtyValues + '%'}">
</div>
</div>
</div>
<div>
<button type="button" class="btn btn-default btncustom" [disabled]="!form.valid || finalizeStatus" (click)="SaveForm();">Save</button>
<button type="button" class="btn btn-default btncustom" [disabled]="!form.valid || finalizeStatus" data-toggle="modal" data-target="#confirmModal">Finalize</button>
</div>
-->
<!--
<!--
<div *ngIf="payLoad" class="form-row">
<strong>Saved the following values</strong><br>{{payLoad}}
</div>
-->
<p>Form value: {{ form.value | json }}</p>
<!-- <div class="text-center">
<ul *ngIf="pagination.pages && pagination.pages.length" class="pagination">
<li [ngClass]="{disabled:pagination.currentPage === 1}">
@ -68,32 +57,35 @@
</ul>
</div> -->
</div>
</div>
<!-- <div *ngIf="!expandedToc" class="collapsed-div-caret" (click)="toggleTOC()">
--> <!--
<!-- <div *ngIf="!expandedToc" class="collapsed-div-caret" (click)="toggleTOC()">
-->
<!--
<i class="fa toc-toggler" [ngClass]="{true:'fa-arrow-right', false:'fa-arrow-left'}[expandedToc]" aria-hidden="true" ><div>Show ToC</div></i>
-->
<!-- <i class="fa toc-toggler" aria-hidden="true" ><div>Show ToC</div></i>
<!-- <i class="fa toc-toggler" aria-hidden="true" ><div>Show ToC</div></i>
</div>
<div *ngIf="expandedToc" class="col-md-12" style="width:200px; text-align: center;">
<h4 style="display: inline-block; text-align: center; width:150px;">Table of Contents</h4>
<div class="child-div-caret" style="display: inline-block; width:50px;" (click)="toggleTOC()"> -->
<!--
<!--
<i class="fa toc-toggler" [ngClass]="{true:'fa-arrow-right', false:'fa-arrow-left'}[expandedToc]" aria-hidden="true" ><div>Shrink</div></i>
-->
<!-- <i class="fa toc-toggler" aria-hidden="true"><div>(hide)</div></i>
<!-- <i class="fa toc-toggler" aria-hidden="true"><div>(hide)</div></i>
</div>
</div>
-->
<div class="ui-g-4">
<table-of-content [model]="dataModel"></table-of-content>
</div>
<div class="col-md-12 form-footer-container">
<button type="button" class="btn btn-primary" (click)="submit();">Save and Finalize</button>
</div>
<div class="child-div-right" [ngClass]="{true:'col-md-4 col-sm-3', false:'shrink-width' }[expandedToc]" id="toc-container">
<toc [dataModel]="dataModel" (setPage)="setPage($event)"></toc>
</div> -->
</div>
@ -116,5 +108,4 @@
</div>
</div>
</div>
</div> -->
</div> -->

View File

@ -17,36 +17,36 @@ import { PaginationService } from '../../app/services/pagination.service';
import { TokenService, TokenProvider } from '../services/login/token.service';
import { ModalComponent } from '../modal/modal.component';
import {Location} from '@angular/common';
import { Location } from '@angular/common';
import { AngularDraggableModule } from 'angular2-draggable';
import {MenuItem} from 'primeng/primeng';
import { MenuItem } from 'primeng/primeng';
import {PDFService} from '../services/transformers/pdf.service';
import { PDFService } from '../services/transformers/pdf.service';
import './../../assets/xml2json.min.js';
declare var X2JS: any;
var flatten = require('flat');
declare var $ :any;
declare var $: any;
import * as scroll from '../../assets/jquery.scrollTo.min.js';
import '../../assets/custom.js';
declare function simple_notifier(type: string, title: string, message:string): any;
declare function simple_notifier(type: string, title: string, message: string): any;
//import '../../assets/perfect-scrollbar/perfect-scrollbar.js';
declare var PerfectScrollbar : any;
declare var PerfectScrollbar: any;
@Component({
selector: 'dynamic-form',
templateUrl: './dynamic-form.component.html',
styleUrls: [
'./dynamic-form.component.css',
'./dynamic-form.component.css',
'../../assets/perfect-scrollbar/perfect-scrollbar.css'
],
providers: [
@ -56,27 +56,17 @@ declare var PerfectScrollbar : any;
export class DynamicFormComponent implements OnInit {
@Input() dataModel: DatasetModel = new DatasetModel();
@Input() path:string;
form: FormGroup;
payLoad = '';
@Input() dirtyValues: number = 0;
// pagination object
@Input() pagination: any = {};
finalizeStatus:boolean = false;
id: string;
datasetId: string;
pathName:string;
//datasetProperties:string;
pathName: string;
private fragment: string;
xml2jsonOBJ: any;
expandedToc : boolean = true;
private progressbar:boolean = false;
constructor(private qcs: FieldControlService, private serverService: ServerService, private router: Router, private pdfService : PDFService,
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.xml2jsonOBJ = new X2JS();
constructor(private qcs: FieldControlService, private serverService: ServerService, private router: Router, private pdfService: PDFService,
private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService, private visibilityRulesService: VisibilityRulesService) {
}
getSubForm(subformName) {
@ -85,13 +75,41 @@ export class DynamicFormComponent implements OnInit {
ngOnInit() {
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(TestModel,DatasetModel);
this.form = this.dataModel.buildForm();
this.visibilityRulesService.formGroup = this.form;
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
this.visibilityRulesService.buildVisibilityRules(rules)
//this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(new DatasetModel(), DatasetModel);
//this.form = this.dataModel.buildForm();
let sub = this.route.queryParams.subscribe(params => {
let dmpid = params.id;
this.datasetId = params.datasetId;
this.serverService.getDmp(this.datasetId).subscribe(
response => {
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
this.form = this.dataModel.buildForm();
this.visibilityRulesService.formGroup = this.form;
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules,Rule);
this.visibilityRulesService.buildVisibilityRules(rules)
this.progressbar = true;
},
error => {
console.log("Could not load dmp");
}
)
/* else{
this.addSection();
}
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(TestModel,DatasetModel);
this.form = this.dataModel.buildForm();
this.visibilityRulesService.formGroup = this.form;
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
this.visibilityRulesService.buildVisibilityRules(rules) */
});
}
submit(){
this.serverService.updateDataset(this.datasetId,this.form.value).subscribe()
}
/* scrollToElemID(elemID) {
scroll("#" + elemID);
}
@ -116,39 +134,7 @@ export class DynamicFormComponent implements OnInit {
} catch (e) { }
}
submitForm(final){
debugger;
this.serverService.getDatasetByID(this.datasetId).subscribe(
(data) => {
if (final) data.status = 2;
//data.properties = "<root><formValues><![CDATA["+JSON.stringify(this.form.value)+"]]></formValues><dataModel><![CDATA["+JSON.stringify(this.dataModel)+"]]></dataModel></root>";
data.properties = JSON.stringify(this.form.value);
data.profile = {"id": data.profile.id};
this.serverService.setDataset(data).subscribe(
(data) => {
console.log("Updated dataset");
if (final){
this._location.back();
simple_notifier("success",null,"Finalized form progress");
}
else{
simple_notifier("success",null,"Saved form progress");
}
},
(err) => {
simple_notifier("danger",null,"Could not save form progress");
});
},
(err) => {
simple_notifier("danger",null,"Could not save form progress");
});
}
SaveForm() {
let final = false;
@ -198,8 +184,8 @@ export class DynamicFormComponent implements OnInit {
*/
createPDF(elementID : string, pdffilename : string){
this.pdfService.toPDF(elementID, pdffilename);
}
this.pdfService.toPDF(elementID, pdffilename);
}
}

View File

@ -0,0 +1 @@
<p-progressBar [value]="value"></p-progressBar>

View File

@ -0,0 +1,51 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormControl, FormArray } from '@angular/forms'
@Component({
selector: 'progress-bar',
templateUrl: './progress-bar.component.html',
})
export class ProgressBarComponent implements OnInit {
@Input() formGroup: FormGroup
private value: number;
ngOnInit() {
this.formGroup
.valueChanges
.subscribe(control => {
this.value = (this.getDirtyValues(this.formGroup) / this.getFormControlDepthLength(this.formGroup)) * 100
})
}
getDirtyValues(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
let control = form.controls[key]
if (control instanceof FormGroup) value += this.getDirtyValues(control);
else if (control instanceof FormArray) {
let formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) {
value += this.getDirtyValues(<FormGroup>formArray.get("" + i))
}
}
else if (control.valid) value++;
});
return value;
}
getFormControlDepthLength(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
let control = form.controls[key]
if (control instanceof FormGroup) value += this.getFormControlDepthLength(control);
else if (control instanceof FormArray) {
let formArray = (<FormArray>control);
for (let i = 0; i < formArray.length; i++) {
value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
}
}
else if (control instanceof FormControl) value++;
});
return value;
}
}

View File

@ -0,0 +1,9 @@
import { ActivatedRouteSnapshot,Router,ActivatedRoute } from '@angular/router';
export class BaseTableOfContent{
constructor(public router: Router,public route:ActivatedRoute){}
scrollToId(elementId) {
this.router.navigate([this.route.snapshot.url], { fragment: elementId });
}
}

View File

@ -0,0 +1,2 @@
<a (click)="scrollToId(model.id)">{{path+' '+model.title}}</a>

View File

@ -0,0 +1,22 @@
import { BaseTableOfContent } from '../base-table-of-content.component';
import { CompositeField } from '../../../models/CompositeField';
import { Field } from '../../../models/Field';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router'
@Component({
selector: 'table-of-contents-field',
templateUrl: '/table-of-content-field.component.html',
providers: []
})
export class TableOfContentsFieldComponent extends BaseTableOfContent{
@Input() model:Field;
@Input() index:number;
@Input() public path:string;
constructor(public router: Router, public route: ActivatedRoute) {
super(router, route)
}
}

View File

@ -0,0 +1,7 @@
<!-- All contents in the first page -->
<ul>
<li *ngFor="let field of model.fields let i = index">
<table-of-contents-field [model]="field" [index]="i" [path]="path"> </table-of-contents-field>
</li>
</ul>

View File

@ -0,0 +1,25 @@
import { BaseTableOfContent } from '../base-table-of-content.component';
import { CompositeField } from '../../../models/CompositeField';
import { FieldGroup } from '../../../models/FieldGroup';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
@Component({
selector: 'table-of-contents-fieldset',
templateUrl: '/table-of-content-fieldset.component.html',
providers: []
})
export class TableOfContentsFieldSetComponent extends BaseTableOfContent {
@Input() model: CompositeField;
@Input() index: number;
@Input() public path: string;
constructor(public router: Router, public route: ActivatedRoute) {
super(router, route)
}
}

View File

@ -0,0 +1,5 @@
<a (click)="scrollToId(model.id)">{{path+' '+model.title}}</a>
<div *ngFor="let fieldsetModel of model.compositeFields let i = index">
<table-of-contents-fieldset [model]="fieldsetModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-fieldset>
</div>

View File

@ -0,0 +1,29 @@
import { BaseTableOfContent } from '../base-table-of-content.component';
import { FieldGroup } from '../../../models/FieldGroup';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router'
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
@Component({
selector: 'table-of-contents-group',
templateUrl: '/table-of-content-group.component.html',
providers: []
})
export class TableOfContentsGroupComponent extends BaseTableOfContent {
@Input() model: FieldGroup;
@Input() index: number;
@Input() public path: string;
/* @Output()
setPage:EventEmitter<number> = new EventEmitter<number>();
*/
constructor(public router: Router, public route: ActivatedRoute) {
super(router, route)
}
}

View File

@ -0,0 +1,14 @@
<!-- All contents in the first page -->
<a (click)="scrollToId(model.id)">{{path+' '+model.title}}</a>
<ul>
<li *ngFor="let groupModel of model.fieldGroups let i = index">
<table-of-contents-group [model]="groupModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-group>
</li>
</ul>
<!-- All contents in the first page -->
<ul>
<li *ngFor="let sectionModel of model.sections let i = index">
<table-of-contents-section [model]="sectionModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-section>
</li>
</ul>

View File

@ -0,0 +1,27 @@
import { BaseTableOfContent } from '../base-table-of-content.component';
import { Section } from '../../../models/Section';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ActivatedRouteSnapshot,Router,ActivatedRoute } from '@angular/router';
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
@Component({
selector: 'table-of-contents-section',
templateUrl: '/table-of-content-section.component.html',
providers: []
})
export class TableOfContentsSectionComponent extends BaseTableOfContent implements OnInit {
@Input() model: Section;
@Input() index: number;
@Input() public path: string;
constructor(public router: Router,public route:ActivatedRoute){
super(router,route)
}
ngOnInit() {
}
}

View File

@ -0,0 +1,7 @@
<!-- All contents in the first page -->
<ul>
<li *ngFor="let section of model.sections let i = index">
<!-- && field.label for sections without field label as data summery -->
<table-of-contents-section [model]="section" [index]="i+1" [path]="i+1"> </table-of-contents-section>
</li>
</ul>

View File

@ -0,0 +1,26 @@
import { Model } from '../../entities/model/model';
import { DatasetModel } from '../../models/DatasetModel';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
import * as scroll from '../../../assets/jquery.scrollTo.min.js';
@Component({
selector: 'table-of-content',
templateUrl: '/table-of-contents.component.html',
styleUrls: ['./toc.component.css'],
providers: []
})
export class TableOfContentsComponent implements OnInit{
@Input() model:DatasetModel;
public path:string="";
/* @Output()
setPage:EventEmitter<number> = new EventEmitter<number>();
*/ ngOnInit(){
}
}

View File

@ -1,20 +0,0 @@
<body data-spy="scroll" data-target="#toc">
<nav id="toc" data-toggle="toc">
<ul class="nav flex-column">
<li class="nav-item">
<div *ngFor="let group of dataModel.groups"> <!-- All contents in the first page -->
<ul>
<li>
<a class="cursor-hand" (click)='scrollToElemID(group.key, group.page)'>{{group.title}}</a>
<ul *ngFor="let field of group.groupFields">
<li *ngIf="field.visible == 'true' && field.label"> <!-- && field.label for sections without field label as data summery -->
<a class="cursor-hand" (click)='scrollToElemID(field.key, group.page)'>{{field.label}} </a>
</li>
</ul>
</li>
</ul>
</div>
</li>
</ul>
</nav>
</body>

View File

@ -1,31 +0,0 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
import * as scroll from '../../../assets/jquery.scrollTo.min.js';
@Component({
selector: 'toc',
templateUrl: '/toc.component.html',
styleUrls: ['./toc.component.css'],
providers: []
})
export class TocComponent implements OnInit{
private headers = new Array();
@Output()
setPage:EventEmitter<number> = new EventEmitter<number>();
ngOnInit(){
}
scrollToElemID(elemID, _page){
console.log("going to id:"+elemID)
var page = parseInt(_page)
this.setPage.emit(page);
scroll("#"+elemID, {}, {offset: top});
}
}

View File

@ -29,15 +29,15 @@ export class Field extends BaseModel implements Serializable<Field>,FormGenerato
buildForm():FormGroup{
let formGroup = this.formBuilder.group({
id: [this.id],
title: [this.title],
value: [this.value],
id: [this.id],
/* title: [this.title], */
value: [this.value]/* ,
description: [this.description],
extendedDescription:[this.extendedDescription],
viewStyle: [this.viewStyle],
defaultVisibility:[this.defaultVisibility],
page:[this.page],
data:[this.data]
data:[this.data] */
});
return formGroup;
}

View File

@ -33,13 +33,13 @@ export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, F
buildForm(): FormGroup {
let formGroup: FormGroup = this.formBuilder.group({
id: [this.id],
/* id: [this.id],
title: [this.title],
value: [this.value],
description: [this.description],
extendedDescription: [this.extendedDescription],
defaultVisibility: [this.defaultVisibility],
page: [this.page]
page: [this.page] */
});
let compositeFieldsFormArray = new Array<FormGroup>();
if (this.compositeFields) {

View File

@ -42,11 +42,11 @@ export class Section extends BaseModel implements Serializable<Section>, FormGen
}
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray));
formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility))
/* formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility))
formGroup.addControl('page', new FormControl(this.page))
formGroup.addControl('id', new FormControl(this.id))
formGroup.addControl('title', new FormControl(this.title))
formGroup.addControl('description', new FormControl(this.description))
formGroup.addControl('description', new FormControl(this.description)) */
return formGroup;
}
}

View File

@ -18,7 +18,7 @@ export class RestBase {
protocol: string = "http";
hostname: string ="dionysus.di.uoa.gr"
hostname: string ="localhost"
port: number = 8080;
webappname: string = "dmp-backend";

View File

@ -47,11 +47,8 @@ export class ServerService {
return this.restBase.get("dmp/listDMPLabelID");
}
public getDmp(dmpid : string, eager? : boolean){
if(eager && eager==true)
return this.restBase.get("dmps/"+dmpid, {"eager": true});
else
return this.restBase.get("dmps/"+dmpid, {"eager": false});
public getDmp(dmpid : string){
return this.restBase.get("datasetprofile/get/"+dmpid);
}
public getDmpHistory(dmpid: string){
@ -160,6 +157,9 @@ export class ServerService {
}
public updateDataset(id:string,properties:any){
return this.restBase.post("datasetprofile/save/"+id,properties);
}
/*
logOut() {
this.tokenService.logout();

View File

@ -30,7 +30,7 @@ export class DmpDetailedComponent implements OnInit {
let sub = this.route.queryParams.subscribe(params => {
let dmpid = params.dmpid;
this.serverService.getDmp(dmpid, true).subscribe(
this.serverService.getDmp(dmpid).subscribe(
response => {
this.dmp = response;

View File

@ -21,7 +21,7 @@ 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'))continue;
if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value'))return false; //TODO
if(sourceVisibilityRule.sourceControlValue != ''+this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value) return false;
}
return true;