@uwdata/mosaic-inputs 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/Table.js +11 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uwdata/mosaic-inputs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Mosaic input components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"inputs",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"prepublishOnly": "npm run test && npm run lint"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@uwdata/mosaic-core": "^0.
|
|
26
|
-
"@uwdata/mosaic-sql": "^0.
|
|
25
|
+
"@uwdata/mosaic-core": "^0.15.0",
|
|
26
|
+
"@uwdata/mosaic-sql": "^0.15.0",
|
|
27
27
|
"isoformat": "^0.2.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "671ad1ba86749a8435bd4aa7e722e2a8553f2cb0"
|
|
30
30
|
}
|
package/src/Table.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Selection, clausePoints, coordinator, isParam, isSelection, toDataColumns } from '@uwdata/mosaic-core';
|
|
1
|
+
import { Selection, clausePoints, coordinator, isParam, isSelection, queryFieldInfo, toDataColumns } from '@uwdata/mosaic-core';
|
|
2
2
|
import { Query, desc } from '@uwdata/mosaic-sql';
|
|
3
3
|
import { formatDate, formatLocaleAuto, formatLocaleNumber } from './util/format.js';
|
|
4
4
|
import { Input, input } from './input.js';
|
|
@@ -186,18 +186,18 @@ export class Table extends Input {
|
|
|
186
186
|
coordinator().prefetch(query.clone().offset(offset + this.limit));
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
async prepare() {
|
|
190
|
+
// query for column scheam information
|
|
190
191
|
const table = this.sourceTable();
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
fieldInfo(info) {
|
|
195
|
-
this.schema = info;
|
|
192
|
+
const fields = this.columns.map(column => ({ column, table }));
|
|
193
|
+
const schema = await queryFieldInfo(this.coordinator, fields);
|
|
194
|
+
this.schema = schema;
|
|
196
195
|
|
|
196
|
+
// create table header row
|
|
197
197
|
const thead = this.head;
|
|
198
198
|
thead.innerHTML = '';
|
|
199
199
|
const tr = document.createElement('tr');
|
|
200
|
-
for (const { column } of
|
|
200
|
+
for (const { column } of schema) {
|
|
201
201
|
const th = document.createElement('th');
|
|
202
202
|
th.addEventListener('click', evt => this.sort(evt, column));
|
|
203
203
|
th.appendChild(document.createElement('span'));
|
|
@@ -207,16 +207,14 @@ export class Table extends Input {
|
|
|
207
207
|
thead.appendChild(tr);
|
|
208
208
|
|
|
209
209
|
// get column formatters
|
|
210
|
-
this.formats = formatof(this.format,
|
|
210
|
+
this.formats = formatof(this.format, schema);
|
|
211
211
|
|
|
212
212
|
// get column alignment style
|
|
213
213
|
this.style.innerText = tableCSS(
|
|
214
214
|
this.id,
|
|
215
|
-
alignof(this.align,
|
|
216
|
-
widthof(this.widths,
|
|
215
|
+
alignof(this.align, schema),
|
|
216
|
+
widthof(this.widths, schema)
|
|
217
217
|
);
|
|
218
|
-
|
|
219
|
-
return this;
|
|
220
218
|
}
|
|
221
219
|
|
|
222
220
|
query(filter = []) {
|