Generalized table to not depend on project id

This commit is contained in:
2019-03-15 10:18:23 +01:00
parent 4f5eee6705
commit 479b844174
8 changed files with 63 additions and 35 deletions

View File

@@ -10,7 +10,7 @@ const TEMPLATE =`
<div id="col_main"> <div id="col_main">
<component <component
:is="tableComponentName" :is="tableComponentName"
:projectId="projectId" :project="project"
:selectedIds="selectedIds" :selectedIds="selectedIds"
:canChangeSelectionCB="canChangeSelectionCB" :canChangeSelectionCB="canChangeSelectionCB"
@selectItemsChanged="onSelectItemsChanged" @selectItemsChanged="onSelectItemsChanged"
@@ -60,6 +60,7 @@ Vue.component('attract-app', {
return this.selectedItems.map(it => it.name); return this.selectedItems.map(it => it.name);
}, },
tableComponentName() { tableComponentName() {
if(!this.project) return '';
switch (this.contextType) { switch (this.contextType) {
case 'assets': return AssetsTable.options.name; case 'assets': return AssetsTable.options.name;
case 'tasks': return TasksTable.options.name; case 'tasks': return TasksTable.options.name;

View File

@@ -34,8 +34,15 @@ let TableActions = {
let AssetsTable = Vue.component('attract-assets-table', { let AssetsTable = Vue.component('attract-assets-table', {
extends: PillarTable, extends: PillarTable,
columnFactory: AssetColumnFactory, props: {
rowsSource: AssetRowsSource, project: Object
},
data() {
return {
columnFactory: new AssetColumnFactory(this.project),
rowsSource: new AssetRowsSource(this.project._id),
}
},
components: { components: {
'pillar-table-actions': TableActions, 'pillar-table-actions': TableActions,
'pillar-table-row-filter': RowFilter, 'pillar-table-row-filter': RowFilter,

View File

@@ -6,18 +6,22 @@ let ColumnFactoryBase = pillar.vuecomponents.table.columns.ColumnFactoryBase;
class AssetColumnFactory extends ColumnFactoryBase{ class AssetColumnFactory extends ColumnFactoryBase{
thenGetColumns() { constructor(project) {
return this.thenGetProject() super();
.then((project) => { this.project = project;
let taskTypes = project.extension_props.attract.task_types.attract_asset; }
let taskColumns = taskTypes.map((tType) => {
return new TaskColumn(tType, 'asset-task');
})
return [new Status(), new RowObject()] thenGetColumns() {
.concat(taskColumns) let taskTypes = this.project.extension_props.attract.task_types.attract_asset;
.concat([new NextTaskDueDate(),]); let taskColumns = taskTypes.map((tType) => {
return new TaskColumn(tType, 'asset-task');
}) })
return Promise.resolve(
[new Status(), new RowObject()]
.concat(taskColumns)
.concat([new NextTaskDueDate(),])
);
} }
} }

View File

@@ -6,7 +6,8 @@ let RowObjectsSourceBase = pillar.vuecomponents.table.rows.RowObjectsSourceBase;
*/ */
class AttractRowsSourceBase extends RowObjectsSourceBase { class AttractRowsSourceBase extends RowObjectsSourceBase {
constructor(projectId, node_type, rowClass) { constructor(projectId, node_type, rowClass) {
super(projectId); super();
this.projectId = projectId;
this.node_type = node_type; this.node_type = node_type;
this.rowClass = rowClass; this.rowClass = rowClass;
} }

View File

@@ -5,8 +5,15 @@ import {RowFilter} from '../attracttable/filter/RowFilter'
let ShotsTable = Vue.component('attract-shots-table', { let ShotsTable = Vue.component('attract-shots-table', {
extends: PillarTable, extends: PillarTable,
columnFactory: ShotsColumnFactory, props: {
rowsSource: ShotRowsSource, project: Object
},
data() {
return {
columnFactory: new ShotsColumnFactory(this.project),
rowsSource: new ShotRowsSource(this.project._id),
}
},
components: { components: {
'pillar-table-row-filter': RowFilter, 'pillar-table-row-filter': RowFilter,
}, },

View File

@@ -7,18 +7,22 @@ let ColumnFactoryBase = pillar.vuecomponents.table.columns.ColumnFactoryBase;
class ShotsColumnFactory extends ColumnFactoryBase{ class ShotsColumnFactory extends ColumnFactoryBase{
constructor(project) {
super();
this.project = project;
}
thenGetColumns() { thenGetColumns() {
return this.thenGetProject() let taskTypes = this.project.extension_props.attract.task_types.attract_shot;
.then((project) => {
let taskTypes = project.extension_props.attract.task_types.attract_shot;
let taskColumns = taskTypes.map((tType) => { let taskColumns = taskTypes.map((tType) => {
return new TaskColumn(tType, 'shot-task'); return new TaskColumn(tType, 'shot-task');
}) })
return [new Status(), new Picture(), new RowObject()] return Promise.resolve(
[new Status(), new Picture(), new RowObject()]
.concat(taskColumns) .concat(taskColumns)
.concat([new NextTaskDueDate(),]); .concat([new NextTaskDueDate(),])
}) );
} }
} }

View File

@@ -34,8 +34,15 @@ let TableActions = {
let TasksTable = Vue.component('attract-tasks-table', { let TasksTable = Vue.component('attract-tasks-table', {
extends: PillarTable, extends: PillarTable,
columnFactory: TasksColumnFactory, props: {
rowsSource: TaskRowsSource, project: Object
},
data() {
return {
columnFactory: new TasksColumnFactory(this.project),
rowsSource: new TaskRowsSource(this.project._id),
}
},
components: { components: {
'pillar-table-actions': TableActions, 'pillar-table-actions': TableActions,
'pillar-table-row-filter': RowFilter, 'pillar-table-row-filter': RowFilter,

View File

@@ -10,17 +10,14 @@ let ColumnFactoryBase = pillar.vuecomponents.table.columns.ColumnFactoryBase;
class TasksColumnFactory extends ColumnFactoryBase{ class TasksColumnFactory extends ColumnFactoryBase{
thenGetColumns() { thenGetColumns() {
return this.thenGetProject() return Promise.resolve([
.then((project) => { new Status(),
return [ new ParentName(),
new Status(), new RowObject(),
new ParentName(), new ShortCode(),
new RowObject(), new TaskType(),
new ShortCode(), new TaskDueDate(),
new TaskType(), ]);
new TaskDueDate(),
];
})
} }
} }