This commit is contained in:
krommydas kyriakos 2017-12-11 16:22:02 +02:00
commit 8d6df43faa
17 changed files with 215 additions and 106 deletions

View File

@ -17,9 +17,8 @@ export class AutocompleteComponent implements OnInit{
ngOnInit(){
this.data.type= "autocomplete";
let autocomplete: AutocompleteData = new AutocompleteData();
this.dataModel.data = new JsonSerializer<AutocompleteData>().fromJSONObject(this.data,AutocompleteData);
//(<FormArray>this.form.get("data")).push(autocomplete.buildForm());
if (this.form.get("data")) this.form.removeControl("data");
//this.dataModel.data = new JsonSerializer<AutocompleteData>().fromJSONObject(this.data,AutocompleteData);
//(<FormArray>this.form.get("data")).push(autocomplete.buildForm());
this.form.addControl("data", this.data.buildForm());
}
}

View File

@ -1,14 +1,14 @@
<div class="form-group col-md-12">
<label>Type of Combobox</label>
<select class="form-control" [(ngModel)]="dataModel.data!=null?dataModel.data.type:type">
<select class="form-control" [(ngModel)]="type" (change)= "onchangeCombo($event)">
<option *ngFor="let option of options" [value]="option.value">{{option.value}}</option>
</select>
<div class="form-row" [ngSwitch]="dataModel.data!=null?dataModel.data.type:type">
<div class="form-row" [ngSwitch]="type">
<div *ngSwitchCase="'autocomplete'">
<autocomplete-component [form]="form" [dataModel]="dataModel"></autocomplete-component>
</div>
</div>
<div class="form-row" [ngSwitch]="dataModel.data!=null?dataModel.data.type:type">
<div class="form-row" [ngSwitch]="type">
<div *ngSwitchCase="'wordlist'">
<wordlist-component [form]="form" [dataModel]="dataModel"></wordlist-component>
</div>

View File

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

View File

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

View File

@ -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!\"");

View File

@ -18,5 +18,5 @@ app-root {
}
html {
overflow-y: hidden
/* overflow-y: hidden */
}

View File

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

View File

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

View File

@ -6,7 +6,16 @@
<i>{{group.extendedDescription}}</i>
</h5> -->
<div *ngFor="let compositeField of group.compositeFields; let i = index;">
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
<a (click)="addMultipleField(i)" style="cursor: pointer">
Add one more field +
</a>
</div>
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index;">
<df-composite-field [compositeField]="multipleCompositeField" [form]="form.get('compositeFields').get(''+i).get('multiplicityItems').get(''+j)"
[path]="path" [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
</div>
</div>
</div>
</div>

View File

@ -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);
(<FormArray>(this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
}
addFieldSet() {
/* debugger;
let subgroup: any = {};

View File

@ -17,3 +17,11 @@
.ui-steps .ui-steps-item {
min-width: 10%;
}
ng-sidebar-container {
overflow: inherit !important;
}
/* .ng-sidebar__content {
overflow: inherit !important;
} */

View File

@ -19,8 +19,8 @@
<form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
<div *ngFor="let section of dataModel.sections; let i = index;">
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)"
[path]="i+1" [pathName]="'sections.'+i"></df-section>
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1"
[pathName]="'sections.'+i"></df-section>
</div>
</form>
</div>

View File

@ -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<CompositeField> {
public fields:Array<Field> = new Array<Field>();
public ordinal:number
public id:number
fromJSONObject(item:any):CompositeField{
this.fields = new JsonSerializer<Field>().fromJSONArray(item.fields,Field);
public fields: Array<Field> = new Array<Field>();
public ordinal: number
public id: number
public multiplicity: Multiplicity;
public multiplicityItems: Array<CompositeField> = new Array<CompositeField>();
fromJSONObject(item: any): CompositeField {
this.fields = new JsonSerializer<Field>().fromJSONArray(item.fields, Field);
this.ordinal = item.ordinal;
this.id = item.id;
//this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
this.multiplicity = new Multiplicity();
this.multiplicity.max = 2;
this.multiplicityItems = new JsonSerializer<CompositeField>().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<FormGroup>();
let fieldsFormArray = new Array<FormGroup>();
this.fields.forEach(item => {
let form: FormGroup = item.buildForm();
fieldsFormArray.push(form)
})
formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray));
let multiplicityItemsFormArray = new Array<FormGroup>();
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;
}
}

View File

@ -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<Field>,FormGenerator<FormGroup>{
import { Multiplicity } from './Multiplicity';
export class Field extends BaseModel implements Serializable<Field>, FormGenerator<FormGroup>{
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<Multiplicity>().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;
}
}

View File

@ -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<Multiplicity>, FormGenerator<FormGroup>{
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;
}
}

View File

@ -2,7 +2,7 @@ import { Serializable } from '../models/interfaces/Serializable';
export class JsonSerializer<T extends Serializable<T>>{
public fromJSONArray(items: any[], type: { new(): T; }): T[] {
if(!items)return null;
if(!items)return new Array<T>();
const objectList: T[] = new Array<T>();
for (let i = 0; i < items.length; i++) {
objectList.push(new type().fromJSONObject(items[i]))

View File

@ -1,56 +1,59 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Data Management Plans Creator</title>
<base href="/">
<meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!--
<head>
<meta charset="utf-8">
<title>Data Management Plans Creator</title>
<base href="/">
<meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!--
<script src="https://apis.google.com/js/platform.js" ></script>
-->
<link rel="stylesheet" href="https://cdn.rawgit.com/afeld/bootstrap-toc/v0.4.1/dist/bootstrap-toc.min.css"><!--bootstrap plugin for ToC-->
<script src="https://cdn.rawgit.com/afeld/bootstrap-toc/v0.4.1/dist/bootstrap-toc.min.js"></script>
<!-- XML to json and vice versa lib -->
<script src="assets/xml2json.min.js"></script>
<!-- Json formatter lib -->
<link rel="stylesheet" type="text/css" href="assets/jquery.json-viewer.css">
<script src="assets/jquery.json-viewer.js"></script>
<!-- lib 4 pretty-printing xml and json -->
<script src="assets/vkbeautify.0.99.00.js"></script>
<!-- Nice BS notifications -->
<script src="assets/bootstrap-notify.min.js"></script>
<!-- that's google sign in library -->
<script src="https://apis.google.com/js/platform.js"></script>
<!-- font-awesome css -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.rawgit.com/afeld/bootstrap-toc/v0.4.1/dist/bootstrap-toc.min.css">
<!--bootstrap plugin for ToC-->
<script src="https://cdn.rawgit.com/afeld/bootstrap-toc/v0.4.1/dist/bootstrap-toc.min.js"></script>
<!-- Customized scrollbars source: https://github.com/utatti/perfect-scrollbar -->
<link rel="stylesheet" type="text/css" href="assets/perfect-scrollbar/perfect-scrollbar.css">
<script src="assets/perfect-scrollbar/perfect-scrollbar.js"></script>
<!-- XML to json and vice versa lib -->
<script src="assets/xml2json.min.js"></script>
<!-- Json formatter lib -->
<link rel="stylesheet" type="text/css" href="assets/jquery.json-viewer.css">
<script src="assets/jquery.json-viewer.js"></script>
<!-- lib 4 pretty-printing xml and json -->
<script src="assets/vkbeautify.0.99.00.js"></script>
<!-- Nice BS notifications -->
<script src="assets/bootstrap-notify.min.js"></script>
<!-- that's google sign in library -->
<script src="https://apis.google.com/js/platform.js"></script>
<!-- font-awesome css -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- my custom global code and css -->
<link rel="stylesheet" type="text/css" href="assets/custom.css">
<script src="assets/custom.js"></script>
<!-- Customized scrollbars source: https://github.com/utatti/perfect-scrollbar -->
<link rel="stylesheet" type="text/css" href="assets/perfect-scrollbar/perfect-scrollbar.css">
<script src="assets/perfect-scrollbar/perfect-scrollbar.js"></script>
<!-- my custom global code and css -->
<link rel="stylesheet" type="text/css" href="assets/custom.css">
<script src="assets/custom.js"></script>
</head>
<body>
<app-root class="full-height full-width"></app-root>
<app-root ></app-root>
</body>
</html>