Mercurial > hg > ng2-query-ismi
comparison app/query-select.component.ts @ 34:e19d4c5e10a1
restricted selectable options for first query step.
author | casties |
---|---|
date | Wed, 03 Feb 2016 16:18:46 +0100 |
parents | 4c046f3244ec |
children | 8e03b8fafb87 |
comparison
equal
deleted
inserted
replaced
33:739eb38ec2a2 | 34:e19d4c5e10a1 |
---|---|
14 <p *ngIf="resultInfo"> result: {{resultInfo}}</p> | 14 <p *ngIf="resultInfo"> result: {{resultInfo}}</p> |
15 <div> | 15 <div> |
16 <form (ngSubmit)="onSubmit()"> | 16 <form (ngSubmit)="onSubmit()"> |
17 <select (change)="onSelectMode($event)"> | 17 <select (change)="onSelectMode($event)"> |
18 <option></option> | 18 <option></option> |
19 <option *ngFor="#mode of queryModes" [value]="mode.id"> | 19 <option *ngFor="#mode of getQueryModes()" [value]="mode.id"> |
20 {{mode.label}} | 20 {{mode.label}} |
21 </option> | 21 </option> |
22 </select> | 22 </select> |
23 | 23 |
24 <span *ngIf="selectedMode?.id=='type_is' || selectedMode?.id=='relation_is'"> | 24 <span *ngIf="selectedMode?.id=='type_is' || selectedMode?.id=='relation_is'"> |
60 | 60 |
61 <button type="submit">Submit</button> | 61 <button type="submit">Submit</button> |
62 </form> | 62 </form> |
63 </div> | 63 </div> |
64 `, | 64 `, |
65 inputs: ['queryStep', 'index'] | 65 inputs: ['queryStep', 'index'], |
66 //outputs: ['queryChanged'] // this should work but doesn't | 66 outputs: ['queryChanged'] |
67 }) | 67 }) |
68 | 68 |
69 export class QuerySelectComponent implements OnInit { | 69 export class QuerySelectComponent implements OnInit { |
70 public queryStep: string; | 70 public queryStep: string; |
71 public index: number; | 71 public index: number; |
75 public queryOptions: string[]; | 75 public queryOptions: string[]; |
76 public selectedOption: string; | 76 public selectedOption: string; |
77 public queryInput: string; | 77 public queryInput: string; |
78 public queryInput2: string; | 78 public queryInput2: string; |
79 | 79 |
80 @Output('queryChanged') queryChanged = new EventEmitter<QueryState>(); | 80 // output queryChanged |
81 public queryChanged: EventEmitter<QueryState> = new EventEmitter<QueryState>(); | |
81 | 82 |
82 constructor(private _queryService: QueryService, private _normService: NormalizationService) {} | 83 constructor(private _queryService: QueryService, private _normService: NormalizationService) {} |
83 | 84 |
84 ngOnInit() { | 85 ngOnInit() { |
85 this.setup(); | 86 this.setup(); |
86 } | 87 } |
87 | 88 |
88 setup() { | 89 setup() { |
89 console.log("query-select setup step=", this.queryStep); | 90 console.log("query-select setup step=", this.queryStep); |
90 this.queryModes = this._queryService.getQueryModes(); | |
91 var step = this._queryService.state.steps[this.index-1]; | 91 var step = this._queryService.state.steps[this.index-1]; |
92 if (step != null) { | 92 if (step != null) { |
93 this.resultInfo = step.resultInfo; | 93 this.resultInfo = step.resultInfo; |
94 } | 94 } |
95 } | |
96 | |
97 getQueryModes(): QueryMode[] { | |
98 this.queryModes = this._queryService.getQueryModes(this.index); | |
99 return this.queryModes; | |
95 } | 100 } |
96 | 101 |
97 onSelectMode(event: any) { | 102 onSelectMode(event: any) { |
98 var selected = event.target.value; | 103 var selected = event.target.value; |
99 this.selectedMode = this.queryModes.find(mode => mode.id === selected); | 104 this.selectedMode = this.queryModes.find(mode => mode.id === selected); |