Generalized table to not depend on project id
This commit is contained in:
@@ -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: {
|
||||||
|
@@ -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 }
|
||||||
|
@@ -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 = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user