diff --git a/dmp-admin/src/app/autocomplete/autocomplete-component.ts b/dmp-admin/src/app/autocomplete/autocomplete-component.ts index 2f4c09d74..01c75b904 100644 --- a/dmp-admin/src/app/autocomplete/autocomplete-component.ts +++ b/dmp-admin/src/app/autocomplete/autocomplete-component.ts @@ -17,9 +17,8 @@ export class AutocompleteComponent implements OnInit{ ngOnInit(){ this.data.type= "autocomplete"; let autocomplete: AutocompleteData = new AutocompleteData(); - this.dataModel.data = new JsonSerializer().fromJSONObject(this.data,AutocompleteData); - //(this.form.get("data")).push(autocomplete.buildForm()); - if (this.form.get("data")) this.form.removeControl("data"); + //this.dataModel.data = new JsonSerializer().fromJSONObject(this.data,AutocompleteData); + //(this.form.get("data")).push(autocomplete.buildForm()); this.form.addControl("data", this.data.buildForm()); } } \ No newline at end of file diff --git a/dmp-admin/src/app/combobox/combobox-component.html b/dmp-admin/src/app/combobox/combobox-component.html index 38f4c9a73..a3eb851a1 100644 --- a/dmp-admin/src/app/combobox/combobox-component.html +++ b/dmp-admin/src/app/combobox/combobox-component.html @@ -1,14 +1,14 @@
- -
+
-
+
diff --git a/dmp-admin/src/app/combobox/combobox-component.ts b/dmp-admin/src/app/combobox/combobox-component.ts index abd17c00c..9441f28be 100644 --- a/dmp-admin/src/app/combobox/combobox-component.ts +++ b/dmp-admin/src/app/combobox/combobox-component.ts @@ -9,10 +9,17 @@ import { Component, Input, OnInit } from '@angular/core'; export class ComboboxComponent implements OnInit{ @Input() dataModel: Field; @Input() form: FormGroup; - + type: string; options = [{id:"autocomplete", value: "autocomplete"}, {id:"wordlist", value: "wordlist"}]; ngOnInit(){ + if (this.dataModel.data){ + this.type = this.form.get("data").get("type").value; + } } + + onchangeCombo(){ + if (this.form.get("data")) this.form.removeControl("data"); + } } \ No newline at end of file diff --git a/dmp-admin/src/app/wordlist/wordlist-component.ts b/dmp-admin/src/app/wordlist/wordlist-component.ts index 203c8cd6a..5946a083c 100644 --- a/dmp-admin/src/app/wordlist/wordlist-component.ts +++ b/dmp-admin/src/app/wordlist/wordlist-component.ts @@ -18,9 +18,10 @@ export class WordlistComponent implements OnInit{ ngOnInit(){ this.data.type = "wordlist"; - if (this.form.get("data")) this.form.removeControl("data"); + // if (this.form.get("data")) this.form.removeControl("data"); this.form.addControl("data", this.data.buildForm()); - this.addNewRow(); + if(!this.dataModel.data) + this.addNewRow(); } addNewRow(){ diff --git a/dmp-backend/src/main/java/rest/entities/DMPs.java b/dmp-backend/src/main/java/rest/entities/DMPs.java index ce132625d..7bbc0a352 100644 --- a/dmp-backend/src/main/java/rest/entities/DMPs.java +++ b/dmp-backend/src/main/java/rest/entities/DMPs.java @@ -217,7 +217,7 @@ public class DMPs { DMP d = dMPDao.read(dmp.getId()); d.setStatus(new Short("-1")); dMPDao.update(d); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\""); + return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"deleted DMP!\""); } catch (Exception e) { e.printStackTrace(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\""); diff --git a/dmp-frontend/src/app/app.component.css b/dmp-frontend/src/app/app.component.css index 31b04e3cf..d7088dd4e 100644 --- a/dmp-frontend/src/app/app.component.css +++ b/dmp-frontend/src/app/app.component.css @@ -18,5 +18,5 @@ app-root { } html { - overflow-y: hidden + /* overflow-y: hidden */ } \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index 50eb6e366..7a50eea47 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -134,9 +134,9 @@ export class DatasetsComponent implements OnInit { properties: '', profile: { "id": '' }, dmp: { "id": '' }, - services:[], - registries:[], - dataRepositories:[] + services: [], + registries: [], + dataRepositories: [] } } @@ -203,7 +203,6 @@ export class DatasetsComponent implements OnInit { this.serverService.getDatasetForDmp({ "id": dmpid }).subscribe( response => { this.tableData = response; - }, error => { console.log("could not retrieve dataset for dpm: " + dmpid); @@ -216,14 +215,15 @@ export class DatasetsComponent implements OnInit { editRow(item, event) { if (event.toElement.id == "editDataset") { - //this.dataset = item; - - this.serverService.getDatasetByID(item.id).subscribe(item=>{ - this.dataset = item; - this.dataset.profile = item.profile.id; - $("#newDatasetModal").modal("show"); - } - ) + this.spinnerService.show(); + this.serverService.getDatasetByID(item.id).subscribe(item => { + this.dataset = item; + this.dataset.profile = item.profile.id; + $("#newDatasetModal").modal("show"); + }, + error => simple_notifier("danger", null, "Could not Open Dataset"), + () => this.spinnerService.hide() + ) } else if (event.toElement.id == "describeDataset") { this.describeDataset(item); diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index 5f0fe7e0d..789baef11 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -17,6 +17,7 @@ import { NgForm } from '@angular/forms'; import { DatasetsComponent } from '../datasets/dataset.component'; import { StatusToString } from '../pipes/various/status-to-string'; import { MenuItem } from 'primeng/primeng'; +import { Ng4LoadingSpinnerService } from 'ng4-loading-spinner'; declare var $: any; @@ -59,7 +60,9 @@ export class DmpComponent implements OnInit { constructor( private serverService: ServerService, private route: ActivatedRoute, - private router: Router) { + private router: Router, + private spinnerService: Ng4LoadingSpinnerService + ) { this.projectsDropDown = new DropdownField(); this.projectsDropDown.options = []; this.statusDropDown = new DropdownField(); @@ -190,12 +193,16 @@ export class DmpComponent implements OnInit { editDmp(item) { - this.serverService.getDmp(item.id).subscribe(result=>{ + this.spinnerService.show(); + this.serverService.getDmp(item.id).subscribe(result => { this.dmp = result; this.dmp.project = result.project.id $("#newDmpModal").modal("show"); - }) - + }, + error => simple_notifier("danger", null, "Failed to Open DMP"), + () => this.spinnerService.hide() + ) + } cloneDmp(item) { 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 fca9cd0be..36f9d389e 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 @@ -6,7 +6,16 @@ {{group.extendedDescription}} -->
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts index 7c59a7047..510785611 100644 --- a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts @@ -1,9 +1,10 @@ import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; import { FieldGroup } from '../../models/FieldGroup'; import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; -import { FormGroup, Validators, FormControl } from '@angular/forms'; +import { FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; import { NgForm } from '@angular/forms'; import { Rule } from '../../entities/common/rule'; +import { CompositeField } from '../../models/CompositeField'; @@ -16,12 +17,12 @@ import { Rule } from '../../entities/common/rule'; export class DynamicFormGroupComponent implements OnInit { @Input() group: FieldGroup @Input() form: FormGroup; - @Input() pathName:string; - - @Input() path:string; - + @Input() pathName: string; - constructor(private visibilityRulesService:VisibilityRulesService) { + @Input() path: string; + + + constructor(private visibilityRulesService: VisibilityRulesService) { } ngOnInit() { @@ -43,6 +44,12 @@ export class DynamicFormGroupComponent implements OnInit { } + addMultipleField(fieldsetIndex: number) { + let compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(); + this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField); + ((this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm()); + } + addFieldSet() { /* debugger; let subgroup: any = {}; diff --git a/dmp-frontend/src/app/form/dynamic-form.component.css b/dmp-frontend/src/app/form/dynamic-form.component.css index d4039005e..b2147ae04 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.css +++ b/dmp-frontend/src/app/form/dynamic-form.component.css @@ -17,3 +17,11 @@ .ui-steps .ui-steps-item { min-width: 10%; } + +ng-sidebar-container { + overflow: inherit !important; +} + +/* .ng-sidebar__content { + overflow: inherit !important; +} */ \ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-form.component.html b/dmp-frontend/src/app/form/dynamic-form.component.html index f0c098fd1..f57a29612 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.html +++ b/dmp-frontend/src/app/form/dynamic-form.component.html @@ -19,8 +19,8 @@
- +
diff --git a/dmp-frontend/src/app/models/CompositeField.ts b/dmp-frontend/src/app/models/CompositeField.ts index 9b7cca106..46c2629d4 100644 --- a/dmp-frontend/src/app/models/CompositeField.ts +++ b/dmp-frontend/src/app/models/CompositeField.ts @@ -2,30 +2,56 @@ import { FormGroup } from '@angular/forms'; import { JsonSerializer } from '../utilities/JsonSerializer'; import { Serializable } from './interfaces/Serializable'; import { BaseModel } from './BaseModel'; -import {Field} from './Field' +import { Field } from './Field' +import { Multiplicity } from './Multiplicity'; export class CompositeField extends BaseModel implements Serializable { - public fields:Array = new Array(); - public ordinal:number - public id:number - fromJSONObject(item:any):CompositeField{ - - this.fields = new JsonSerializer().fromJSONArray(item.fields,Field); + public fields: Array = new Array(); + public ordinal: number + public id: number + public multiplicity: Multiplicity; + public multiplicityItems: Array = new Array(); + + fromJSONObject(item: any): CompositeField { + + this.fields = new JsonSerializer().fromJSONArray(item.fields, Field); this.ordinal = item.ordinal; this.id = item.id; + //this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); + this.multiplicity = new Multiplicity(); + this.multiplicity.max = 2; + this.multiplicityItems = new JsonSerializer().fromJSONArray(item.multiplicityItems, CompositeField); return this; } - buildForm():FormGroup{ + buildForm(): FormGroup { let formGroup = this.formBuilder.group({ - ordinal:this.ordinal + ordinal: this.ordinal }); - let fieldsFormArray = new Array(); + let fieldsFormArray = new Array(); this.fields.forEach(item => { let form: FormGroup = item.buildForm(); fieldsFormArray.push(form) }) formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); + + let multiplicityItemsFormArray = new Array(); + this.multiplicityItems.forEach(item => { + let form: FormGroup = item.buildForm(); + multiplicityItemsFormArray.push(form) + }) + formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray)); + return formGroup; } + + cloneForMultiplicity(): CompositeField { + let newItem: CompositeField = new CompositeField(); + this.fields.forEach(field => { + newItem.fields.push(field.cloneForMultiplicity()); + }); + newItem.ordinal = this.ordinal; + + return newItem; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/models/Field.ts b/dmp-frontend/src/app/models/Field.ts index ad4c93edc..d12c22a50 100644 --- a/dmp-frontend/src/app/models/Field.ts +++ b/dmp-frontend/src/app/models/Field.ts @@ -3,42 +3,61 @@ import { FormGroup } from '@angular/forms'; import { FormGenerator } from './interfaces/FormGenerator'; import { JsonSerializer } from '../utilities/JsonSerializer'; import { Serializable } from './interfaces/Serializable'; -export class Field extends BaseModel implements Serializable,FormGenerator{ +import { Multiplicity } from './Multiplicity'; +export class Field extends BaseModel implements Serializable, FormGenerator{ - public id:string; - public title:string; - public value:string; - public description:string; - public extendedDescription:string; - public viewStyle:string; - public defaultVisibility:boolean; - public page:number; - public data:any; - fromJSONObject(item:any):Field{ + public id: string; + public title: string; + public value: string; + public description: string; + public extendedDescription: string; + public viewStyle: string; + public defaultVisibility: boolean; + public page: number; + public multiplicity: Multiplicity; + public data: any; + fromJSONObject(item: any): Field { this.id = item.id; this.title = item.title; this.value = item.value; this.description = item.description; - this.extendedDescription = item.extendedDescription; + this.extendedDescription = item.extendedDescription; this.viewStyle = item.viewStyle; this.defaultVisibility = item.defaultVisibility; this.page = item.page; + this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); this.data = item.data; return this; } - buildForm():FormGroup{ + buildForm(): FormGroup { let formGroup = this.formBuilder.group({ - id: [this.id], - /* title: [this.title], */ + 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; } + + cloneForMultiplicity(): Field { + let newItem: Field = new Field(); + + newItem.id = this.id; + newItem.title = this.title; + newItem.description = this.description; + newItem.extendedDescription = this.extendedDescription; + newItem.viewStyle = this.viewStyle; + newItem.defaultVisibility = this.defaultVisibility; + newItem.page = this.page; + newItem.multiplicity = null; + newItem.data = this.data; + + return newItem; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/models/Multiplicity.ts b/dmp-frontend/src/app/models/Multiplicity.ts new file mode 100644 index 000000000..268de5fea --- /dev/null +++ b/dmp-frontend/src/app/models/Multiplicity.ts @@ -0,0 +1,23 @@ +import { BaseModel } from './BaseModel'; +import { FormGroup } from '@angular/forms'; +import { FormGenerator } from './interfaces/FormGenerator'; +import { Serializable } from './interfaces/Serializable'; +export class Multiplicity extends BaseModel implements Serializable, FormGenerator{ + public min: number; + public max: number; + + fromJSONObject(item: any): Multiplicity { + this.min = item.min; + this.max = item.max; + return this; + } + + buildForm(): FormGroup { + let formGroup = this.formBuilder.group({ + min: [this.min], + max: [this.max] + + }); + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/utilities/JsonSerializer.ts b/dmp-frontend/src/app/utilities/JsonSerializer.ts index 4222500ef..b3b23d812 100644 --- a/dmp-frontend/src/app/utilities/JsonSerializer.ts +++ b/dmp-frontend/src/app/utilities/JsonSerializer.ts @@ -2,7 +2,7 @@ import { Serializable } from '../models/interfaces/Serializable'; export class JsonSerializer>{ public fromJSONArray(items: any[], type: { new(): T; }): T[] { - if(!items)return null; + if(!items)return new Array(); const objectList: T[] = new Array(); for (let i = 0; i < items.length; i++) { objectList.push(new type().fromJSONObject(items[i])) diff --git a/dmp-frontend/src/index.html b/dmp-frontend/src/index.html index 6ec9a46e2..44d57e08e 100644 --- a/dmp-frontend/src/index.html +++ b/dmp-frontend/src/index.html @@ -1,56 +1,59 @@ - - - - - Data Management Plans Creator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + - + + \ No newline at end of file