From e04c90dd2bc60da19da8ffbbfec1084052a4d745 Mon Sep 17 00:00:00 2001 From: annampak Date: Thu, 7 Dec 2017 15:44:17 +0200 Subject: [PATCH 1/2] minor fixes --- .../src/app/field-form/field-form.component.html | 2 +- dmp-admin/src/app/field-form/field-form.component.ts | 5 ++--- dmp-admin/src/app/form/form.component.ts | 11 +++++++---- dmp-admin/src/app/models/Field.ts | 4 +++- dmp-admin/src/app/models/FieldGroup.ts | 2 ++ dmp-admin/src/app/models/Section.ts | 5 ++++- dmp-admin/src/app/rule-component/rule.component.ts | 1 - 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/dmp-admin/src/app/field-form/field-form.component.html b/dmp-admin/src/app/field-form/field-form.component.html index fefbca431..68d14ab9b 100644 --- a/dmp-admin/src/app/field-form/field-form.component.html +++ b/dmp-admin/src/app/field-form/field-form.component.html @@ -15,7 +15,7 @@ Composite Field +
-
+
-
+
Multiplicity
@@ -16,11 +20,11 @@
-
+
-
+
@@ -28,24 +32,33 @@
-
-

Fields - -

- -
- - Add another field + - + + + -
+ diff --git a/dmp-admin/src/app/compositefield-form/compositefield-form.component.ts b/dmp-admin/src/app/compositefield-form/compositefield-form.component.ts index 782190da3..b0af6b0e2 100644 --- a/dmp-admin/src/app/compositefield-form/compositefield-form.component.ts +++ b/dmp-admin/src/app/compositefield-form/compositefield-form.component.ts @@ -2,7 +2,7 @@ import { Component, Input } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { CompositeField } from '../models/CompositeField'; import { Field } from '../models/Field'; -import { FormArray } from '@angular/forms/src/model'; +import { FormArray, FormControl } from '@angular/forms/src/model'; @Component({ selector: 'compositefield-form', @@ -11,22 +11,43 @@ import { FormArray } from '@angular/forms/src/model'; }) export class CompositeFieldFormComponent { -@Input() form: FormGroup; -@Input() dataModel: CompositeField; + @Input() form: FormGroup; + @Input() dataModel: CompositeField; + @Input() indexPath: string; + + isComposite: boolean = false; + isMultiplicityEnabled: boolean = false; -constructon(){} + constructon() { } -ngOnInit(){ - //this.addNewField(); -} + ngOnInit() { + //this.addNewField(); + } -addNewField(){ - let field: Field = new Field(); - this.dataModel.fields.push(field); - (this.form.get("fields")).push(field.buildForm()); -} -DeleteField(index){ - this.dataModel.fields.splice(index, 1); + onIsCompositeChange(isComposite: boolean) { + if (!isComposite && (this.form.get("fields")).length > 1) { + for(let i = 0; i < (this.form.get("fields")).length - 1; i++) { + (this.form.get("fields")).removeAt(1); + } + this.dataModel.fields.splice(1); + } + } + + onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { + if (!isMultiplicityEnabled) { + (this.form.get('multiplicity').get("min")).setValue(0); + (this.form.get('multiplicity').get("max")).setValue(0); + } + } + + addNewField() { + let field: Field = new Field(); + this.dataModel.fields.push(field); + (this.form.get("fields")).push(field.buildForm()); + } + + DeleteField(index) { + this.dataModel.fields.splice(index, 1); (this.form.get("fields")).removeAt(index); -} + } } \ No newline at end of file diff --git a/dmp-admin/src/app/field-form/field-form.component.html b/dmp-admin/src/app/field-form/field-form.component.html index fefbca431..7a24f0e84 100644 --- a/dmp-admin/src/app/field-form/field-form.component.html +++ b/dmp-admin/src/app/field-form/field-form.component.html @@ -1,6 +1,6 @@
-
+
@@ -25,15 +25,15 @@
-
+
- +
- -
+ +
-
+
@@ -43,8 +43,8 @@
-
-
+
+
Multiplicity
@@ -79,20 +79,32 @@
-
-
-

Rules

- -
- - Add another rule + - + + +
+
+
+ {{i + 1}}. Rule {{i + 1}} + +
+ +
+
+
+
+ +
+
-
- - Add another rule + + diff --git a/dmp-admin/src/app/field-form/field-form.component.ts b/dmp-admin/src/app/field-form/field-form.component.ts index de0733025..0f092c871 100644 --- a/dmp-admin/src/app/field-form/field-form.component.ts +++ b/dmp-admin/src/app/field-form/field-form.component.ts @@ -1,10 +1,10 @@ import { Component, Input } from '@angular/core'; -import { FormGroup } from '@angular/forms'; +import { FormGroup, FormControl } from '@angular/forms'; import { Field } from '../models/Field'; import { Rule } from '../models/Rule'; import { Multiplicity } from '../models/Multiplicity'; import { FormArray } from '@angular/forms/src/model'; -import {ComboboxComponent} from '../combobox/combobox-component'; +import { ComboboxComponent } from '../combobox/combobox-component'; @Component({ selector: 'field-form', @@ -13,25 +13,35 @@ import {ComboboxComponent} from '../combobox/combobox-component'; }) export class FieldFormComponent { -@Input() form: FormGroup; -@Input() dataModel: Field; + @Input() form: FormGroup; + @Input() dataModel: Field; + @Input() showMultiplicity: boolean = true; + @Input() indexPath: string; + + isFieldMultiplicityEnabled: boolean = false; -constructon(){} + constructon() { } -ngOnInit(){ - console.log("init field") - // this.addNewRule(); -} + ngOnInit() { + console.log("init field") + // this.addNewRule(); + } -addNewRule(){ - let rule: Rule = new Rule(); - this.dataModel.visible.rules.push(rule); - (this.form.get("visible").get("rules")).push(rule.buildForm()); -} + onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) { + if (!isFieldMultiplicityEnabled) { + (this.form.get('multiplicity').get("min")).setValue(0); + (this.form.get('multiplicity').get("max")).setValue(0); + } + } -DeleteRule(index){ - this.dataModel.visible.rules.splice(index, 1); - (this.form.get("visible").get("rules")).removeAt(index); -} - + addNewRule() { + let rule: Rule = new Rule(); + this.dataModel.visible.rules.push(rule); + (this.form.get("visible").get("rules")).push(rule.buildForm()); + } + + DeleteRule(index) { + this.dataModel.visible.rules.splice(index, 1); + (this.form.get("visible").get("rules")).removeAt(index); + } } \ No newline at end of file diff --git a/dmp-admin/src/app/form/form.component.html b/dmp-admin/src/app/form/form.component.html index 9de3ea02a..db6916000 100644 --- a/dmp-admin/src/app/form/form.component.html +++ b/dmp-admin/src/app/form/form.component.html @@ -1,32 +1,37 @@
-
+
-
-

Section - -

- - + - - -
+ diff --git a/dmp-admin/src/app/form/form.component.ts b/dmp-admin/src/app/form/form.component.ts index 8b388d545..31b0c22ca 100644 --- a/dmp-admin/src/app/form/form.component.ts +++ b/dmp-admin/src/app/form/form.component.ts @@ -1,6 +1,6 @@ import { DatasetProfileService } from '../services/dataset-profile.service'; import { Component, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; +import { FormGroup, FormControl } from '@angular/forms'; import { JsonSerializer } from '../utilities/JsonSerializer'; import { SectionFormComponent } from '../section-form/section-form.component'; import { Section } from '../models/Section'; @@ -48,6 +48,13 @@ export class FormComponent { // this.form = this.dataModel.buildForm(); } + onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { + if (!isMultiplicityEnabled) { + (this.form.get('multiplicity').get("min")).setValue(0); + (this.form.get('multiplicity').get("max")).setValue(0); + } + } + addSection() { let section: Section = new Section(); this.dataModel.sections.push(section); diff --git a/dmp-admin/src/app/groupfield-form/groupfield-form.component.html b/dmp-admin/src/app/groupfield-form/groupfield-form.component.html index 6dec8b40f..2bc5326fb 100644 --- a/dmp-admin/src/app/groupfield-form/groupfield-form.component.html +++ b/dmp-admin/src/app/groupfield-form/groupfield-form.component.html @@ -1,7 +1,7 @@
-
+
@@ -24,7 +24,7 @@
-
+
@@ -35,27 +35,33 @@
-
-

FieldSet - -

- -
- - Add another field Set (CompositeField) + - +
+
+
+ + {{i + 1}}. Field {{i + 1}} + +
+ +
+
+
+
+ +
+
-
- - \ No newline at end of file diff --git a/dmp-admin/src/app/groupfield-form/groupfield-form.component.ts b/dmp-admin/src/app/groupfield-form/groupfield-form.component.ts index cf599e739..bdf8f522b 100644 --- a/dmp-admin/src/app/groupfield-form/groupfield-form.component.ts +++ b/dmp-admin/src/app/groupfield-form/groupfield-form.component.ts @@ -14,7 +14,8 @@ import { Field } from '../models/Field'; export class GroupFieldFormComponent { @Input() form: FormGroup; @Input() dataModel: FieldGroup; - + @Input() indexPath: string; + constructor(){} ngOnInit(){ diff --git a/dmp-admin/src/app/section-form/section-form.component.css b/dmp-admin/src/app/section-form/section-form.component.css new file mode 100644 index 000000000..1ded10469 --- /dev/null +++ b/dmp-admin/src/app/section-form/section-form.component.css @@ -0,0 +1,5 @@ +.section-container { + background-color: #f5f5f5; + border: 1px solid #e3e3e3; + padding: 24px; +} \ No newline at end of file diff --git a/dmp-admin/src/app/section-form/section-form.component.html b/dmp-admin/src/app/section-form/section-form.component.html index 93cd6a372..df217bf85 100644 --- a/dmp-admin/src/app/section-form/section-form.component.html +++ b/dmp-admin/src/app/section-form/section-form.component.html @@ -1,7 +1,6 @@ -
- -
-
+
+
+
@@ -25,44 +24,29 @@
-
-
-

Section - -

- -
-
-
-
-

GroupFields - -

- -
- - Add group + - + - - - - \ No newline at end of file diff --git a/dmp-admin/src/app/section-form/section-form.component.ts b/dmp-admin/src/app/section-form/section-form.component.ts index 0ff8420cc..fd1f68d8d 100644 --- a/dmp-admin/src/app/section-form/section-form.component.ts +++ b/dmp-admin/src/app/section-form/section-form.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, ViewEncapsulation } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Section } from '../models/Section'; import { FieldGroup } from '../models/FieldGroup'; @@ -9,40 +9,42 @@ import { DatasetProfileModel } from '../models/DatasetProfileModel'; @Component({ selector: 'section-form', templateUrl: './section-form.component.html', - styleUrls: [] + styleUrls: ['./section-form.component.css'], + encapsulation: ViewEncapsulation.None }) export class SectionFormComponent { @Input() form: FormGroup; - @Input() dataModel:Section; - @Input() index:number; - constructor(){ } + @Input() dataModel: Section; + @Input() indexPath: string; - ngOnInit(){ + constructor() { } + + ngOnInit() { //this.addGroupField(); //for new DatasetProfile } - addGroupField(){ - let fieldGroup:FieldGroup = new FieldGroup(); - if(this.dataModel.fieldGroups) + addGroupField() { + let fieldGroup: FieldGroup = new FieldGroup(); + if (this.dataModel.fieldGroups) this.dataModel.fieldGroups.push(fieldGroup); (this.form.get("fieldGroups")).push(fieldGroup.buildForm()); } - DeleteFieldGroup(index){ + DeleteFieldGroup(index) { this.dataModel.fieldGroups.splice(index, 1); (this.form.get("fieldGroups")).removeAt(index) } - addSectioninSection(){ - let section:Section = new Section(); + addSectioninSection() { + let section: Section = new Section(); this.dataModel.sections.push(section); (this.form.get("sections")).push(section.buildForm()); } - DeleteSectionInSection(index){ + DeleteSectionInSection(index) { this.dataModel.sections.splice(index); (this.form.get("sections")).removeAt(index); } - + } \ No newline at end of file