Mercurial > hg > ng2-query-ismi
changeset 26:991bf349bb04
re-display table more often.
author | casties |
---|---|
date | Wed, 27 Jan 2016 13:30:38 +0100 |
parents | 0795207f3b90 |
children | c2946b7135cd |
files | app/query-app.component.ts app/query-result-table.component.ts package.json |
diffstat | 3 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/app/query-app.component.ts Tue Jan 26 19:19:23 2016 +0100 +++ b/app/query-app.component.ts Wed Jan 27 13:30:38 2016 +0100 @@ -16,6 +16,8 @@ template: ` <div class="container"> <h1>ISMI-Lab Query Builder</h1> + </div> + <div class="container"> <div>Select a query step:</div> <query-select *ngFor="#step of queryStepList; #i=index;" [queryStep]="step" [index]="i" @@ -24,6 +26,8 @@ <button (click)="addQueryStep()">add step</button> <button (click)="removeQueryStep()">remove step</button> </div> + </div> + <div class="container"> <query-result-table *ngIf="queryState && queryState.results" [queryState]="queryState" [data]="queryState.results" [columns]="queryState.resultColumns">
--- a/app/query-result-table.component.ts Tue Jan 26 19:19:23 2016 +0100 +++ b/app/query-result-table.component.ts Wed Jan 27 13:30:38 2016 +0100 @@ -9,6 +9,7 @@ selector: 'query-result-table', template: ` <div *ngIf="queryState && queryState.results"> + <span>Cypher query:</span> <pre>{{queryState.resultCypherQuery}}</pre> <h2>Query result</h2> <pre *ngIf="config.paging">{{queryState.resultInfo}}: page {{page}} of {{numPages}}</pre> @@ -56,13 +57,10 @@ ngOnChanges() { console.debug("result table changed! queryState=", this.queryState?this.queryState.resultColumns:''); this.config.sorting = this.queryState.resultColumns; + this.onChangeTable(this.config, null); } ngOnInit() { - this.setup(); - } - - setup() { console.debug("result table init!"); } @@ -73,19 +71,16 @@ } changeSort(data: any, config: any) { + console.debug("changeSort start"); if (!config.sorting) { return data; } let columns = this.columns.filter(c => c.sort); - // simple sorting - return data.sort((previous: any, current: any) => { - //let columns = this.config.sorting.columns || []; + let sorted = data.sort((previous: any, current: any) => { for (let i = 0; i < columns.length; i++) { let sort = columns[i].sort; - if (!sort) continue; let columnName = columns[i].name; - if (previous[columnName] > current[columnName]) { return sort === 'desc' ? -1 : 1; } else if (previous[columnName] < current[columnName]) { @@ -94,6 +89,8 @@ } return 0; }); + console.debug("changeSort done"); + return sorted; } changeFilter(data: any, config: any): any { @@ -108,7 +105,7 @@ } onChangeTable(config, page: any = config.paging) { - //console.debug("onChangeTable config=", config); + console.debug("onChangeTable config=", config); if (config.filtering) { Object.assign(this.config.filtering, config.filtering); }