|
|
|
@ -6,7 +6,8 @@ import { |
|
|
|
each, |
|
|
|
includes, |
|
|
|
extend, |
|
|
|
flatten |
|
|
|
flatten, |
|
|
|
debounce |
|
|
|
} from 'underscore'; |
|
|
|
|
|
|
|
let Component; |
|
|
|
@ -173,8 +174,9 @@ export default Backbone.Collection.extend({ |
|
|
|
.filter(i => i) |
|
|
|
.map(model => this.processDef(model)); |
|
|
|
models = isMult ? flatten(models, 1) : models[0]; |
|
|
|
|
|
|
|
return Backbone.Collection.prototype.add.apply(this, [models, opt]); |
|
|
|
const result = Backbone.Collection.prototype.add.apply(this, [models, opt]); |
|
|
|
this.__firstAdd = result; |
|
|
|
return result; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -249,5 +251,27 @@ export default Backbone.Collection.extend({ |
|
|
|
model.setStyle({}); |
|
|
|
model.addClass(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.__onAddEnd(); |
|
|
|
}, |
|
|
|
|
|
|
|
__onAddEnd: debounce(function() { |
|
|
|
const { domc } = this; |
|
|
|
const allComp = (domc && domc.allById()) || {}; |
|
|
|
const firstAdd = this.__firstAdd; |
|
|
|
const toCheck = isArray(firstAdd) ? firstAdd : [firstAdd]; |
|
|
|
const onAll = comps => { |
|
|
|
comps.forEach(comp => { |
|
|
|
const symbol = comp.get('__symbol'); |
|
|
|
if (symbol && (isString(symbol) || isString(symbol[0]))) { |
|
|
|
const result = isArray(symbol) |
|
|
|
? symbol.map(smb => allComp[smb]).filter(i => i) |
|
|
|
: allComp[symbol]; |
|
|
|
comp.set('__symbol', result, { silent: true }); |
|
|
|
} |
|
|
|
onAll(comp.components()); |
|
|
|
}); |
|
|
|
}; |
|
|
|
onAll(toCheck); |
|
|
|
}) |
|
|
|
}); |
|
|
|
|