diff --git a/dmp-backend/src/main/java/models/properties/PropertiesModel.java b/dmp-backend/src/main/java/models/properties/PropertiesModel.java index fd56cc7b0..f4a32fde7 100644 --- a/dmp-backend/src/main/java/models/properties/PropertiesModel.java +++ b/dmp-backend/src/main/java/models/properties/PropertiesModel.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; public class PropertiesModel implements PropertiesGenerator{ + private int status; private List
sections; public List
getSections() { @@ -15,6 +16,14 @@ public class PropertiesModel implements PropertiesGenerator{ this.sections = sections; } + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + @Override public void toMap(Map fieldValues) { this.sections.forEach(item->item.toMap(fieldValues)); diff --git a/dmp-backend/src/main/java/models/user/components/datasetprofile/Field.java b/dmp-backend/src/main/java/models/user/components/datasetprofile/Field.java index d4fc7afbf..bf5cda1e0 100644 --- a/dmp-backend/src/main/java/models/user/components/datasetprofile/Field.java +++ b/dmp-backend/src/main/java/models/user/components/datasetprofile/Field.java @@ -122,12 +122,12 @@ public class Field implements Comparable,PropertiesModelBuilder, ModelDefinition this.data = data; } - public Field cloneForMultiplicity(String id, Map properties){ + public Field cloneForMultiplicity(String key, Map properties){ Field newField = new Field(); - newField.id = id; + newField.id = key; newField.ordinal = this.ordinal; newField.title = this.title; - newField.value = (String)properties.get(id); + newField.value = (String)properties.get(key); newField.description = this.description; newField.extendedDescription = this.extendedDescription; newField.viewStyle = this.viewStyle; @@ -193,8 +193,8 @@ public class Field implements Comparable,PropertiesModelBuilder, ModelDefinition return this.ordinal.compareTo(((Field)o).getOrdinal()); } @Override - public void fromJsonObject(Map properties, int index) { - this.value = (String)properties.get("multiple_"+this.id+"_"+index); + public void fromJsonObject(Map properties, String path) { + this.value = (String)properties.get(path); } } \ No newline at end of file diff --git a/dmp-backend/src/main/java/models/user/components/datasetprofile/FieldSet.java b/dmp-backend/src/main/java/models/user/components/datasetprofile/FieldSet.java index 07974eee1..79667481a 100644 --- a/dmp-backend/src/main/java/models/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/src/main/java/models/user/components/datasetprofile/FieldSet.java @@ -110,19 +110,20 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ModelDefinit List compositeKeys = properties.keySet().stream().filter(keys->keys.startsWith("multiple_"+this.getId())).collect(Collectors.toList()); for (String key : compositeKeys) { - this.multiplicityItems.add(this.cloneForMultiplicity(key, properties)); + this.multiplicityItems.add(this.cloneForMultiplicity(key,compositeKeys.indexOf(key), properties)); } } - private FieldSet cloneForMultiplicity(String id, Map properties){ + private FieldSet cloneForMultiplicity(String key, int index,Map properties){ FieldSet newFieldSet = new FieldSet(); - newFieldSet.id = id; + newFieldSet.id = key; + newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); this.fields.forEach(item->{ - newFieldSet.fields.add(item.cloneForMultiplicity("multiple_"+item.getId()+"_"+this.fields.indexOf(item), properties)); + newFieldSet.fields.add(item.cloneForMultiplicity(key, properties)); }); - + //newFieldSet.fields.forEach(item->item.fromJsonObject(properties)); return newFieldSet; } @@ -139,7 +140,7 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ModelDefinit } @Override - public void fromJsonObject(Map properties, int index) { + public void fromJsonObject(Map properties, String path) { // TODO Auto-generated method stub } diff --git a/dmp-backend/src/main/java/models/user/components/datasetprofile/Group.java b/dmp-backend/src/main/java/models/user/components/datasetprofile/Group.java index 9fd78126c..8efe1a1c1 100644 --- a/dmp-backend/src/main/java/models/user/components/datasetprofile/Group.java +++ b/dmp-backend/src/main/java/models/user/components/datasetprofile/Group.java @@ -125,7 +125,7 @@ public class Group implements PropertiesModelBuilder, ModelDefinition properties, int index) { + public void fromJsonObject(Map properties, String index) { // TODO Auto-generated method stub } diff --git a/dmp-backend/src/main/java/models/user/components/datasetprofile/Section.java b/dmp-backend/src/main/java/models/user/components/datasetprofile/Section.java index 128c576ca..f0d72ae52 100644 --- a/dmp-backend/src/main/java/models/user/components/datasetprofile/Section.java +++ b/dmp-backend/src/main/java/models/user/components/datasetprofile/Section.java @@ -101,7 +101,7 @@ public class Section implements Comparable,ViewStyleDefinition properties, int index) { + public void fromJsonObject(Map properties, String index) { // TODO Auto-generated method stub } diff --git a/dmp-backend/src/main/java/models/user/composite/DatasetProfile.java b/dmp-backend/src/main/java/models/user/composite/DatasetProfile.java index 80fafa9c8..9619b63f4 100644 --- a/dmp-backend/src/main/java/models/user/composite/DatasetProfile.java +++ b/dmp-backend/src/main/java/models/user/composite/DatasetProfile.java @@ -12,6 +12,7 @@ import models.user.components.commons.Rule; public class DatasetProfile implements PropertiesModelBuilder{ private List
sections; private List rules; + private int status; public List
getSections() { return sections; } @@ -27,6 +28,14 @@ public class DatasetProfile implements PropertiesModelBuilder{ public void setRules(List rules) { this.rules = rules; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; } public void buildProfile(entities.xmlmodels.modeldefinition.FieldGroup fieldGroup,entities.xmlmodels.viewstyledefinition.ViewStyleModel viewStyle){ @@ -47,7 +56,7 @@ public class DatasetProfile implements PropertiesModelBuilder{ } @Override - public void fromJsonObject(Map properties, int index) { + public void fromJsonObject(Map properties, String index) { // TODO Auto-generated method stub } diff --git a/dmp-backend/src/main/java/models/user/composite/PropertiesModelBuilder.java b/dmp-backend/src/main/java/models/user/composite/PropertiesModelBuilder.java index b82f55277..2137eb686 100644 --- a/dmp-backend/src/main/java/models/user/composite/PropertiesModelBuilder.java +++ b/dmp-backend/src/main/java/models/user/composite/PropertiesModelBuilder.java @@ -4,5 +4,5 @@ import java.util.Map; public interface PropertiesModelBuilder { void fromJsonObject(Map properties); - void fromJsonObject(Map properties,int index); + void fromJsonObject(Map properties,String pathKey); } diff --git a/dmp-backend/src/main/java/rest/entities/DatasetProfileController.java b/dmp-backend/src/main/java/rest/entities/DatasetProfileController.java index a0e74378f..e02881b62 100644 --- a/dmp-backend/src/main/java/rest/entities/DatasetProfileController.java +++ b/dmp-backend/src/main/java/rest/entities/DatasetProfileController.java @@ -40,6 +40,7 @@ public class DatasetProfileController { try { entities.Dataset dataset = datasetDao.read(UUID.fromString(id)); models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile()); + datasetprofile.setStatus(dataset.getStatus()); if(dataset.getProperties()!=null){ JSONObject jobject = new JSONObject(dataset.getProperties()); Map properties = (Map)jobject.toMap(); @@ -61,6 +62,7 @@ public class DatasetProfileController { properties.toMap(values); JSONObject jobject = new JSONObject(values); dataset.setProperties(jobject.toString()); + dataset.setStatus((short)properties.getStatus()); datasetDao.update(dataset); return ResponseEntity.status(HttpStatus.OK).body(properties); diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html index 79540284d..1f1b688ad 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html @@ -1,7 +1,7 @@
-
{{path + ' ' + field.title}}
+
{{field.title}}
diff --git a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html index 22b0cce68..d77f30899 100644 --- a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html +++ b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html @@ -2,7 +2,7 @@ + [pathName]="pathName+'.fields.'+0">

{{compositeField.title}}

@@ -17,9 +17,9 @@ Add one more field +
- +
-
diff --git a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts index 0b405c712..191d01e16 100644 --- a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts +++ b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts @@ -26,7 +26,7 @@ export class DynamicFormCompositeFieldComponent implements OnInit { } addMultipleField(fieldIndex: number) { - let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex); + let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex,""); this.compositeField.fields[fieldIndex].multiplicityItems.push(field); ((this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm()); } diff --git a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html index 36f9d389e..32816727e 100644 --- a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html +++ b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html @@ -14,7 +14,7 @@
+ [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j">
diff --git a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html index d7d33753e..b21c29a4b 100644 --- a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html +++ b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html @@ -17,7 +17,7 @@

{{section.extendedDescription}}

- +
diff --git a/dmp-frontend/src/app/form/dynamic-form.component.html b/dmp-frontend/src/app/form/dynamic-form.component.html index 8b1c3b3f1..340420665 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.html +++ b/dmp-frontend/src/app/form/dynamic-form.component.html @@ -6,7 +6,10 @@
- + +
@@ -16,7 +19,6 @@
-
diff --git a/dmp-frontend/src/app/form/dynamic-form.component.ts b/dmp-frontend/src/app/form/dynamic-form.component.ts index 4ee7def0c..c00cc0499 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form.component.ts @@ -11,7 +11,7 @@ import { NgForm } from '@angular/forms'; import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router'; import 'rxjs/add/operator/switchMap'; -//import { FieldBase } from '../../app/form/fields/field-base'; +import { Ng4LoadingSpinnerService } from 'ng4-loading-spinner'; import { FieldControlService } from '../../app/services/field-control.service'; import { ServerService } from '../../app/services/server.service'; import { TokenService, TokenProvider } from '../services/login/token.service'; @@ -72,7 +72,9 @@ export class DynamicFormComponent implements OnInit { private fragment: string; constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService, private _location: Location, private route: ActivatedRoute, private tokenService: TokenService - , private visibilityRulesService: VisibilityRulesService + , private visibilityRulesService: VisibilityRulesService, + private spinnerService: Ng4LoadingSpinnerService + ) { this.datasetId = route.snapshot.params['id']; } @@ -120,11 +122,25 @@ export class DynamicFormComponent implements OnInit { let rules:Rule[] = new JsonSerializer().fromJSONArray(TestModel.rules,Rule); this.visibilityRulesService.buildVisibilityRules(rules) */ } - - submit() { - this.serverService.updateDataset(this.datasetId, this.form.value).subscribe() + save() { + let data = this.form.value; + data.status = 0; + this.spinnerService.show(); + this.serverService.updateDataset(this.datasetId, data).subscribe(item=>{ + this.spinnerService.hide() + this.router.navigate(["dmps"]); + }) } + submit() { + let data = this.form.value; + data.status = 1; + this.spinnerService.show(); + this.serverService.updateDataset(this.datasetId, data).subscribe(item=>{ + this.spinnerService.hide() + this.router.navigate(["dmps"]); + }) + } toggleSidebar() { this.visibleSidebar = !this.visibleSidebar; } @@ -173,78 +189,6 @@ export class DynamicFormComponent implements OnInit { if (pageIndex === -1) return; this.currentPageIndex = pageIndex; } - /* scrollToElemID(elemID) { - scroll("#" + elemID); - } - - - private patchForm(flatList: any) { - - - for (var prop in flatList) { - if (flatList.hasOwnProperty(prop)) { - if (prop.endsWith('.id') || prop.endsWith('.answer') || prop.endsWith('.value')) continue; - //console.log("updating value of "+prop +" to "+flatList[prop].valueOf()) - this.form.get(prop).setValue(flatList[prop].valueOf()); - } - } - - } - - ngAfterViewChecked(): void { //navigate to certain section of the page - try { - document.querySelector('#' + this.fragment).scrollIntoView(); - } catch (e) { } - } - - - - SaveForm() { - let final = false; - this.submitForm(false); - - this.payLoad = JSON.stringify(this.form.value); - } - - SaveFinalizeForm(){ - $("#confirmModal").modal("hide"); - let final = true; - this.submitForm(final); - } - - shouldIShow(element) { //pagination , pages are declared in xml for every groupfield - - if (this.pagination.currentPage == element.page){ - return true; - } - else - return false; - - } - - setPage(page: number) { - - if (page < 1 || page > this.pagination.totalPages) { - return; - } - var pagesize = 4; - // get pagination object from service - this.pagination = this.pagerService.getPagination(this.dataModel.groups, this.dataModel.groups.length, page, pagesize); - - //get current page of items - // this.dataModel.sections.forEach(section => { - // if (section.groupFields.length > 0) { - // section.groupFields = this.dataModel.groups.slice(this.pagination.startIndex, this.pagination.endIndex + 1); - // } - // }); - //this.dataModel.groups = this.dataModel.groups.slice(this.pagination.startIndex, this.pagination.endIndex + 1); - } - - - toggleTOC(){ - this.expandedToc = !this.expandedToc; - } - */ createPDF(elementID: string, pdffilename: string) { this.pdfService.toPDF(elementID, pdffilename); diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.html b/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.html index 9f1f17ae9..991aa1a51 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.html +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.html @@ -1,2 +1 @@ -{{path+' '+model.title}} \ No newline at end of file diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html b/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html index 0d638e32c..0e42a2a00 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.html @@ -1,10 +1 @@ - -
    -
    -
  • - - -
  • -
    -
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.html b/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.html index 08081cf53..e69de29bb 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.html +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.html @@ -1,5 +0,0 @@ -{{path+' '+model.title}} - -
- -
diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html b/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html index 758a6f56e..1dde97aeb 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html @@ -1,14 +1,6 @@ {{path + ' ' + model.title}} -
-
- - -
-
    diff --git a/dmp-frontend/src/app/models/CompositeField.ts b/dmp-frontend/src/app/models/CompositeField.ts index 78f3cae71..241bf52b1 100644 --- a/dmp-frontend/src/app/models/CompositeField.ts +++ b/dmp-frontend/src/app/models/CompositeField.ts @@ -25,6 +25,7 @@ export class CompositeField extends BaseModel implements Serializable { - newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field))); + newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + "_")); }); newItem.ordinal = this.ordinal; diff --git a/dmp-frontend/src/app/models/DatasetModel.ts b/dmp-frontend/src/app/models/DatasetModel.ts index 4b19d738d..b90cc1747 100644 --- a/dmp-frontend/src/app/models/DatasetModel.ts +++ b/dmp-frontend/src/app/models/DatasetModel.ts @@ -5,9 +5,10 @@ import { JsonSerializer } from '../utilities/JsonSerializer'; import { Section } from './Section'; import { Serializable } from './interfaces/Serializable'; export class DatasetModel extends BaseModel implements Serializable,FormGenerator{ - + public status:number public sections:Array
    fromJSONObject(item:any):DatasetModel{ + this.status = item.status; this.sections = new JsonSerializer
    ().fromJSONArray(item.sections,Section); return this; } diff --git a/dmp-frontend/src/app/models/Field.ts b/dmp-frontend/src/app/models/Field.ts index 0b11ebea1..080cb01e8 100644 --- a/dmp-frontend/src/app/models/Field.ts +++ b/dmp-frontend/src/app/models/Field.ts @@ -19,7 +19,7 @@ export class Field extends BaseModel implements Serializable, FormGenerat public multiplicity: Multiplicity; public multiplicityItems: Array = new Array(); public data: any; - + fromJSONObject(item: any): Field { this.id = item.id; this.title = item.title; @@ -30,8 +30,8 @@ export class Field extends BaseModel implements Serializable, FormGenerat this.defaultVisibility = item.defaultVisibility; this.page = item.page; //this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); - this.defaultValue = new JsonSerializer().fromJSONObject(item.defaultValue, DefaultValue); - this.value = this.defaultValue.value && !item.value? this.defaultValue.value: item.value; + this.defaultValue = new JsonSerializer().fromJSONObject(item.defaultValue, DefaultValue); + this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value; this.multiplicity = new Multiplicity(); this.multiplicity.max = 2; this.multiplicityItems = new JsonSerializer().fromJSONArray(item.multiplicityItems, Field); @@ -62,10 +62,10 @@ export class Field extends BaseModel implements Serializable, FormGenerat return formGroup; } - cloneForMultiplicity(index: number): Field { + cloneForMultiplicity(index: number, idPath: string): Field { let newItem: Field = new Field(); - newItem.id = 'multiple_' + this.id + '_' + index; + newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index; newItem.title = this.title; newItem.description = this.description; newItem.extendedDescription = this.extendedDescription;