diff --git a/.idea/AngularCounterInput.iml b/.idea/AngularDynFormModule.iml similarity index 100% rename from .idea/AngularCounterInput.iml rename to .idea/AngularDynFormModule.iml diff --git a/.idea/modules.xml b/.idea/modules.xml index bc8c5e8..7ad5aee 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d9206a4..66c870f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,15 +1,10 @@ - - + - - - - - + @@ -24,26 +19,27 @@ - + - - + + - - - + + + + - + - - + + @@ -51,27 +47,22 @@ - - + + - - - - - - + + + - - + + - - - - - + + + @@ -80,7 +71,7 @@ - + @@ -101,8 +92,8 @@ - - + + @@ -172,16 +163,16 @@ @@ -542,7 +533,7 @@ - + 1496129612668 @@ -565,11 +556,18 @@ - \ No newline at end of file diff --git a/src/app/modules/dyn-form/dyn-form.component.ts b/src/app/modules/dyn-form/dyn-form.component.ts index d7604d1..c5d8c5c 100644 --- a/src/app/modules/dyn-form/dyn-form.component.ts +++ b/src/app/modules/dyn-form/dyn-form.component.ts @@ -6,9 +6,10 @@ import {FormControl, FormGroup} from '@angular/forms'; selector: 'dyn-form', template: `
- + +
@@ -40,7 +41,18 @@ export class DynFormComponent implements OnChanges { } private submit() { - if (this.form.valid) - this.onSubmit.emit(this.form.value); + if (this.form.valid) { + let vals = {}; + let type: string = this.form.value.type; + for (let question of this.questions) { + let specType = question.properties.spezialization; + let methods = question.properties.methods; + let key = question.properties.key; + if (!(methods && methods.indexOf(this.type)==-1 || specType && type!=specType)) { + vals[key] = this.form.value[key]; + } + } + this.onSubmit.emit(vals); + } } } diff --git a/src/app/modules/dyn-form/services/question.service.ts b/src/app/modules/dyn-form/services/question.service.ts index d392974..8013126 100644 --- a/src/app/modules/dyn-form/services/question.service.ts +++ b/src/app/modules/dyn-form/services/question.service.ts @@ -26,7 +26,7 @@ export class QuestionService { type: 'dropdown', description: 'Cool dropdown', properties: { - key: 'cooldrop', + key: 'type', label: 'Dropdown', order: 2, methods: ['insert'], @@ -51,7 +51,8 @@ export class QuestionService { properties: { key: 'textarea', label: 'Textareaaaa', - order: 4 + order: 4, + spezialization: 'world' }, constraints: { optional: false } @@ -59,7 +60,7 @@ export class QuestionService { ]), null), 10); } - private static orderItems(list: Array ) { + private static orderItems(list: QuestionInterface[]): QuestionInterface[] { function compare(a: any, b: any) { if (a.properties.order < b.properties.order) return -1;