From 58ff236a998b12af902b22d3c636da46dfd543f6 Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Fri, 15 Mar 2019 10:18:23 +0100 Subject: [PATCH] Generalized table to not depend on project id --- .../js/es6/common/vuecomponents/table/Table.js | 11 ++++------- .../table/columns/ColumnFactoryBase.js | 13 ------------- .../table/rows/RowObjectsSourceBase.js | 3 +-- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/scripts/js/es6/common/vuecomponents/table/Table.js b/src/scripts/js/es6/common/vuecomponents/table/Table.js index a4674f42..a8eaed3a 100644 --- a/src/scripts/js/es6/common/vuecomponents/table/Table.js +++ b/src/scripts/js/es6/common/vuecomponents/table/Table.js @@ -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: { diff --git a/src/scripts/js/es6/common/vuecomponents/table/columns/ColumnFactoryBase.js b/src/scripts/js/es6/common/vuecomponents/table/columns/ColumnFactoryBase.js index 878782e9..6612a023 100644 --- a/src/scripts/js/es6/common/vuecomponents/table/columns/ColumnFactoryBase.js +++ b/src/scripts/js/es6/common/vuecomponents/table/columns/ColumnFactoryBase.js @@ -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 } diff --git a/src/scripts/js/es6/common/vuecomponents/table/rows/RowObjectsSourceBase.js b/src/scripts/js/es6/common/vuecomponents/table/rows/RowObjectsSourceBase.js index 429b733a..467d8e00 100644 --- a/src/scripts/js/es6/common/vuecomponents/table/rows/RowObjectsSourceBase.js +++ b/src/scripts/js/es6/common/vuecomponents/table/rows/RowObjectsSourceBase.js @@ -3,8 +3,7 @@ * Extend to fit your purpose. */ class RowObjectsSourceBase { - constructor(projectId) { - this.projectId = projectId; + constructor() { this.rowObjects = []; }