ractive-ez-table
Version:
Ractive Ez UI Table
50 lines (36 loc) • 1.21 kB
JavaScript
import Ractive from 'ractive';
import utils from './utils.js';
const EzTableItems = Ractive.extend({
template: require("./EzTableItems.html"),
_getViewTemplate(column) {
return column.viewTemplate
|| "{{ item." + column.path + "}}";
},
viewTemplate(column) {
const name = "view-" + column.name;
if (!this.partials[name]) {
this.partials[name] = this._getViewTemplate(column);
}
return name;
},
dragStart(event, item) {
// TODO: refactor selectedItems out into table.handleDragStart?
const selectedItems = this.get("selectedItems");
if (selectedItems.indexOf(item) == -1) {
this.get("selectionCursor").handleClick(event, item);
}
this.findParent("EzTable")._handleDragStart(event, selectedItems);
},
dragEnter(event, item) {
this.set("_dragTarget", item);
},
dragLeave(event, item) {
if (this.get("_dragTarget") == item) {
this.set("_dragTarget", null);
}
},
drop(event, targetItem) {
this.findParent("EzTable")._handleDrop(event, targetItem);
}
});
export default EzTableItems;