Generalized table to not depend on project id

This commit is contained in:
Tobias Johansson 2019-03-15 10:18:23 +01:00
parent ace091c998
commit 58ff236a99
3 changed files with 5 additions and 22 deletions

View File

@ -75,8 +75,6 @@ const TEMPLATE =`
let PillarTable = Vue.component('pillar-table-base', {
template: TEMPLATE,
mixins: [UnitOfWorkTracker],
// columnFactory,
// rowsSource,
props: {
projectId: String,
selectedIds: Array,
@ -94,7 +92,8 @@ let PillarTable = Vue.component('pillar-table-base', {
columns: [],
visibleColumns: [],
visibleRowObjects: [],
rowsSource: {},
rowsSource: undefined, // Override with your implementations of ColumnFactoryBase
columnFactory: undefined, // Override with your implementations of RowSource
isInitialized: false,
compareRowsCB: (row1, row2) => 0
}
@ -137,14 +136,11 @@ let PillarTable = Vue.component('pillar-table-base', {
}
},
created() {
let columnFactory = new this.$options.columnFactory(this.projectId);
this.rowsSource = new this.$options.rowsSource(this.projectId);
let tableState = new TableState(this.selectedIds);
this.unitOfWork(
Promise.all([
columnFactory.thenGetColumns(),
this.columnFactory.thenGetColumns(),
this.rowsSource.thenGetRowObjects()
])
.then((resp) => {
@ -160,6 +156,7 @@ let PillarTable = Vue.component('pillar-table-base', {
this.rowAndChildObjects.forEach(tableState.applyRowState.bind(tableState));
this.isInitialized = true;
})
.catch((err) => {toastr.error(pillar.utils.messageFromError(err), 'Loading table failed')})
);
},
methods: {

View File

@ -2,11 +2,6 @@
* Provides the columns that are available in a table.
*/
class ColumnFactoryBase{
constructor(projectId) {
this.projectId = projectId;
this.projectPromise;
}
/**
* To be overridden for your purposes
* @returns {Promise(ColumnBase)} The columns that are available in the table.
@ -14,14 +9,6 @@ class ColumnFactoryBase{
thenGetColumns() {
throw Error('Not implemented')
}
thenGetProject() {
if (this.projectPromise) {
return this.projectPromise;
}
this.projectPromise = pillar.api.thenGetProject(this.projectId);
return this.projectPromise;
}
}
export { ColumnFactoryBase }

View File

@ -3,8 +3,7 @@
* Extend to fit your purpose.
*/
class RowObjectsSourceBase {
constructor(projectId) {
this.projectId = projectId;
constructor() {
this.rowObjects = [];
}