Generalized table to not depend on project id

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

View File

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

View File

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