diff app/query-select.component.ts @ 8:fa646ee46c19

more query generation.
author casties
date Mon, 18 Jan 2016 09:52:46 +0100
parents 6cd6c09032aa
children 66dce99cef4e
line wrap: on
line diff
--- a/app/query-select.component.ts	Fri Jan 15 20:00:47 2016 +0100
+++ b/app/query-select.component.ts	Mon Jan 18 09:52:46 2016 +0100
@@ -9,27 +9,31 @@
 @Component({
     selector: 'query-select',
     template: `
-        <p>Selected option: {{selectedQuery}}</p>
+        <div>
         <select (change)="onSelectMode($event)">
             <option></option>
             <option *ngFor="#mode of queryModes" [value]="mode.id">
                 {{mode.label}}
             </option>
         </select>
-        <select (change)="onSelectOption($event)">
+        <select *ngIf="query2Options" (change)="onSelectOption($event)">
+            <option></option>
             <option *ngFor="#option of query2Options" [value]="option">
                 {{option}}
             </option>
         </select>
-        `
-    //outputs: ['queryChanged']
+        </div>
+        `,
+    inputs: ['index']
+    //outputs: ['queryChanged'] // this should work but doesn't
 })
    
 export class QuerySelectComponent implements OnInit { 
-    public queryModes;
-    public selectedMode;
-    public selectedQuery = 'unknown';
-    public query2Options;
+    public queryStep: QueryStep;
+    public index: number;
+    public queryModes: QueryMode[];
+    public selectedMode: QueryMode;
+    public query2Options: string[];
     
     @Output('queryChanged') queryChanged = new EventEmitter<QueryState>();
     
@@ -40,7 +44,7 @@
     }
     
     setup() {
-        this._queryService.setupIsmiObjectTypes();
+        console.log("query-select setup step=", this.queryStep);
         this.queryModes = this._queryService.getQueryModes();
         // select first mode (too early?)
         this.selectedMode = this.queryModes[0];
@@ -55,10 +59,9 @@
     
     onSelectOption(event: any) {
         var selected = event.target.value;
-        this.selectedQuery = selected;
         console.debug("selected option:", selected);
-        var query: QueryStep = {'mode': this.selectedMode, 'objectType': selected};
-        this._queryService.setQueryStep(0, query);
+        var step = {'mode': this.selectedMode, 'objectType': selected};
+        this._queryService.setQueryStep(this.index, step);
         this.queryChanged.emit(this._queryService.getState());
     }
 }