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

View File

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

View File

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

View File

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

View File

@@ -7,18 +7,22 @@ let ColumnFactoryBase = pillar.vuecomponents.table.columns.ColumnFactoryBase;
class ShotsColumnFactory extends ColumnFactoryBase{
constructor(project) {
super();
this.project = project;
}
thenGetColumns() {
return this.thenGetProject()
.then((project) => {
let taskTypes = project.extension_props.attract.task_types.attract_shot;
let taskTypes = this.project.extension_props.attract.task_types.attract_shot;
let taskColumns = taskTypes.map((tType) => {
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([new NextTaskDueDate(),]);
})
.concat([new NextTaskDueDate(),])
);
}
}

View File

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

View File

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