Generalized table to not depend on project id
This commit is contained in:
@@ -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;
|
||||||
|
@@ -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,
|
||||||
|
@@ -6,18 +6,22 @@ let ColumnFactoryBase = pillar.vuecomponents.table.columns.ColumnFactoryBase;
|
|||||||
|
|
||||||
|
|
||||||
class AssetColumnFactory extends ColumnFactoryBase{
|
class AssetColumnFactory extends ColumnFactoryBase{
|
||||||
|
constructor(project) {
|
||||||
|
super();
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
thenGetColumns() {
|
thenGetColumns() {
|
||||||
return this.thenGetProject()
|
let taskTypes = this.project.extension_props.attract.task_types.attract_asset;
|
||||||
.then((project) => {
|
|
||||||
let taskTypes = project.extension_props.attract.task_types.attract_asset;
|
|
||||||
let taskColumns = taskTypes.map((tType) => {
|
let taskColumns = taskTypes.map((tType) => {
|
||||||
return new TaskColumn(tType, 'asset-task');
|
return new TaskColumn(tType, 'asset-task');
|
||||||
})
|
})
|
||||||
|
|
||||||
return [new Status(), new RowObject()]
|
return Promise.resolve(
|
||||||
|
[new Status(), new RowObject()]
|
||||||
.concat(taskColumns)
|
.concat(taskColumns)
|
||||||
.concat([new NextTaskDueDate(),]);
|
.concat([new NextTaskDueDate(),])
|
||||||
})
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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,
|
||||||
},
|
},
|
||||||
|
@@ -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(),])
|
||||||
})
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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,
|
||||||
|
@@ -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) => {
|
|
||||||
return [
|
|
||||||
new Status(),
|
new Status(),
|
||||||
new ParentName(),
|
new ParentName(),
|
||||||
new RowObject(),
|
new RowObject(),
|
||||||
new ShortCode(),
|
new ShortCode(),
|
||||||
new TaskType(),
|
new TaskType(),
|
||||||
new TaskDueDate(),
|
new TaskDueDate(),
|
||||||
];
|
]);
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user