Mercurial > hg > ng2-query-ismi
diff app/query.service.ts @ 30:193271b6b9d2
configure attributes per result type. select number of items per result page.
author | casties |
---|---|
date | Mon, 01 Feb 2016 17:29:04 +0100 |
parents | 0795207f3b90 |
children | 4c046f3244ec |
line wrap: on
line diff
--- a/app/query.service.ts Wed Jan 27 16:25:00 2016 +0100 +++ b/app/query.service.ts Mon Feb 01 17:29:04 2016 +0100 @@ -7,7 +7,8 @@ import {QueryMode, QUERY_MODES} from './query-mode'; import {QueryState} from './query-state'; import {QueryStep} from './query-step'; -import {ResultColumn} from './result-column'; +import {getResultType} from './result-type'; +import {ISMI_RESULT_TYPES} from './ismi-result-types'; @Injectable() export class QueryService { @@ -239,9 +240,14 @@ */ if (this.state.attributesCypherQuery) { resIdx += 1; - var atts = data.results[resIdx].data.map(elem => elem.row[0]); - this.state.resultAttributes = atts; - this.state.resultColumns = this.getColumns(atts); + let atts = data.results[resIdx].data.map(elem => elem.row[0]); + this.state.resultAttributes = atts; + // the following assumes only one type in the result + for (let t in resTypes) { + this.state.resultType = getResultType(t, ISMI_RESULT_TYPES); + break; + } + this.state.resultColumns = this.state.resultType.getColumns(atts); } /* * results for relations list @@ -276,26 +282,6 @@ } /** - * Return nice column objects - */ - getColumns(attributes: string[]) { - var cols = []; - if (attributes.indexOf('ismi_id') > -1) { - cols.push(new ResultColumn('ismi_id', 'ISMI ID')); - } - if (attributes.indexOf('label') > -1) { - cols.push(new ResultColumn('label', 'Label', 'asc')); - } - attributes.forEach((att) => { - if (att != 'ismi_id' && att != 'label' && att != 'type' && att[0] != '_') { - cols.push(new ResultColumn(att, att)); - } - }); - - return cols; - } - - /** * Run the given queries on the Neo4J server. * * Returns an Observable with the results.