|
|
|
@ -1,28 +1,29 @@ |
|
|
|
var Component = require('./Component'); |
|
|
|
const Component = require('./Component'); |
|
|
|
|
|
|
|
module.exports = Component.extend({ |
|
|
|
|
|
|
|
defaults: _.extend({}, Component.prototype.defaults, { |
|
|
|
defaults: { ...Component.prototype.defaults, |
|
|
|
type: 'tbody', |
|
|
|
tagName: 'tbody', |
|
|
|
draggable: ['table'], |
|
|
|
droppable: ['tr'], |
|
|
|
columns: 1, |
|
|
|
rows: 1, |
|
|
|
}), |
|
|
|
}, |
|
|
|
|
|
|
|
initialize(o, opt) { |
|
|
|
Component.prototype.initialize.apply(this, arguments); |
|
|
|
var components = this.get('components'); |
|
|
|
var rows = this.get('rows'); |
|
|
|
var columns = this.get('columns'); |
|
|
|
const components = this.get('components'); |
|
|
|
let columns = this.get('columns'); |
|
|
|
let rows = this.get('rows'); |
|
|
|
|
|
|
|
// Init components if empty
|
|
|
|
if(!components.length){ |
|
|
|
var rowsToAdd = []; |
|
|
|
if (!components.length) { |
|
|
|
const rowsToAdd = []; |
|
|
|
|
|
|
|
while(rows--){ |
|
|
|
var columnsToAdd = []; |
|
|
|
var clm = columns; |
|
|
|
while (rows--) { |
|
|
|
const columnsToAdd = []; |
|
|
|
let clm = columns; |
|
|
|
|
|
|
|
while (clm--) { |
|
|
|
columnsToAdd.push({ |
|
|
|
@ -37,25 +38,20 @@ module.exports = Component.extend({ |
|
|
|
components: columnsToAdd |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
components.add(rowsToAdd); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
/** |
|
|
|
* Detect if the passed element is a valid component. |
|
|
|
* In case the element is valid an object abstracted |
|
|
|
* from the element will be returned |
|
|
|
* @param {HTMLElement} |
|
|
|
* @return {Object} |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
isComponent(el) { |
|
|
|
var result = ''; |
|
|
|
if(el.tagName == 'TBODY'){ |
|
|
|
result = {type: 'tbody'}; |
|
|
|
let result = ''; |
|
|
|
|
|
|
|
if (el.tagName == 'TBODY') { |
|
|
|
result = { type: 'tbody' }; |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
}, |
|
|
|
|
|
|
|
|