Vue Attract: Sort/filterable table based on Vue
Initial commit implementing sortable and filterable tables for attract using Vue.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
let RowObjectsSourceBase = pillar.vuecomponents.table.rows.RowObjectsSourceBase;
|
||||
|
||||
class AttractRowsSourceBase extends RowObjectsSourceBase {
|
||||
constructor(projectId, node_type, rowClass) {
|
||||
super(projectId);
|
||||
this.node_type = node_type;
|
||||
this.rowClass = rowClass;
|
||||
}
|
||||
|
||||
createRow(node) {
|
||||
let row = new this.rowClass(node);
|
||||
row.thenInit();
|
||||
this.registerListeners(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
initRowObjects(nodes) {
|
||||
this.rowObjects = nodes.map(this.createRow.bind(this));
|
||||
pillar.events.Nodes.onCreated(this.node_type, this.onNodeCreated.bind(this));
|
||||
}
|
||||
|
||||
registerListeners(rowObject) {
|
||||
pillar.events.Nodes.onDeleted(rowObject.getId(), this.onNodeDeleted.bind(this));
|
||||
}
|
||||
|
||||
onNodeDeleted(event, nodeId) {
|
||||
this.rowObjects = this.rowObjects.filter((rowObj) => {
|
||||
return rowObj.getId() !== nodeId;
|
||||
});
|
||||
}
|
||||
|
||||
onNodeCreated(event, node) {
|
||||
let rowObj = this.createRow(node);
|
||||
this.rowObjects = this.rowObjects.concat(rowObj);
|
||||
}
|
||||
}
|
||||
|
||||
export { AttractRowsSourceBase }
|
Reference in New Issue
Block a user