changeset 56:b22e52a128a8 ng2-table

query from url fragment works now somewhat (only for id_is).
author casties
date Tue, 28 Mar 2017 20:03:36 +0200
parents 308c96f734c8
children d7c947909ab8
files src/app/query-app.component.ts src/app/query-select.component.ts
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/query-app.component.ts	Mon Mar 27 14:17:55 2017 +0200
+++ b/src/app/query-app.component.ts	Tue Mar 28 20:03:36 2017 +0200
@@ -41,16 +41,20 @@
         this._queryService.setup(newState);
         this.queryStepList = [];
         if (this._queryService.state.getNumSteps() > 0) {
+            // use state from URL
             this._queryService.state.steps
                 .forEach((elem) => this.queryStepList.push('param'));
+        } else {
+            // new empty state
+            this.addQueryStep();
         }
-        this.addQueryStep();
     }
     
     getStateStringFromFragment(): string {
         let hash: string = window.location.hash;
         if (hash) {
             let frag: string = hash.substr(1);
+            frag = decodeURIComponent(frag);
             // base64 decode
             return frag;
         }
--- a/src/app/query-select.component.ts	Mon Mar 27 14:17:55 2017 +0200
+++ b/src/app/query-select.component.ts	Tue Mar 28 20:03:36 2017 +0200
@@ -17,7 +17,8 @@
     <form (ngSubmit)="onSubmit()">
         <select name="mode" (change)="onSelectMode($event)">
             <option></option>
-            <option *ngFor="let mode of getQueryModes()" [value]="mode.id">
+            <option *ngFor="let mode of getQueryModes()" 
+                [selected]="mode.id==selectedMode?.id" [value]="mode.id">
                 {{mode.label}}
             </option>
         </select>
@@ -98,8 +99,12 @@
     
     setup() {
         console.log("query-select setup step=", this.queryStep);
-        var step = this._queryService.state.steps[this.index-1];
+        var step = this._queryService.state.steps[this.index]; // i-1?
         if (step != null) {
+            this.selectedMode = step.mode;
+            if (step.mode.id === 'id_is') {
+                this.queryInput = step.params.value;
+            }
             this.resultInfo = step.resultInfo;
         }
     }