cartodb-4.42/lib/assets/javascripts/builder/components/modals/add-analysis/analysis-options-collection.js

29 lines
714 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var _ = require('underscore');
var Backbone = require('backbone');
var AnalysisOptionModel = require('./analysis-option-models/analysis-option-model');
module.exports = Backbone.Collection.extend({
model: function (d, opts) {
var Model = d.Model || AnalysisOptionModel;
var attrs = _.omit(d, 'Model', 'nodeAttrs');
return new Model(attrs, {nodeAttrs: d.nodeAttrs});
},
initialize: function (models, opts) {
this.on('change:selected', this._onSelectedChange, this);
},
_onSelectedChange: function (changedModel, isSelected) {
if (isSelected) {
this.each(function (m) {
if (m !== changedModel) {
m.set('selected', false);
}
});
}
}
});