Vue Attract: Sort/filterable table based on Vue

Initial commit implementing sortable and filterable tables for attract
using Vue.
This commit is contained in:
2019-02-12 09:08:37 +01:00
parent a5bae513e1
commit 2f5f73843d
29 changed files with 776 additions and 30 deletions

View File

@@ -0,0 +1,31 @@
class RowBase {
constructor(underlyingObject) {
this.underlyingObject = underlyingObject;
this.isInitialized = false;
}
thenInit() {
this.isInitialized = true
return Promise.resolve();
}
getName() {
return this.underlyingObject.name;
}
getId() {
return this.underlyingObject._id;
}
getProperties() {
return this.underlyingObject.properties;
}
getRowClasses() {
return {
"is-busy": !this.isInitialized
}
}
}
export { RowBase }

View File

@@ -0,0 +1,13 @@
class RowObjectsSourceBase {
constructor(projectId) {
this.projectId = projectId;
this.rowObjects = [];
}
// Override this
thenInit() {
throw Error('Not implemented');
}
}
export { RowObjectsSourceBase }

View File

@@ -0,0 +1,18 @@
import '../../cells/renderer/HeadCell'
const TEMPLATE =`
<div class="pillar-table-head">
<pillar-head-cell
v-for="c in columns"
:column="c"
key="c._id"
@sort="(column, direction) => $emit('sort', column, direction)"
/>
</div>
`;
Vue.component('pillar-table-head', {
template: TEMPLATE,
props: {
columns: Array
}
});

View File

@@ -0,0 +1,27 @@
import '../../cells/renderer/CellProxy'
const TEMPLATE =`
<div class="pillar-table-row"
:class="rowClasses"
>
<pillar-cell-proxy
v-for="c in columns"
:rowObject="rowObject"
:column="c"
:key="c._id"
/>
</div>
`;
Vue.component('pillar-table-row', {
template: TEMPLATE,
props: {
rowObject: Object,
columns: Array
},
computed: {
rowClasses() {
return this.rowObject.getRowClasses();
}
}
});