cartodb-4.42/lib/assets/javascripts/builder/components/modals/add-analysis/analysis-options-collection.js
2024-04-06 05:25:13 +00:00

29 lines
714 B
JavaScript
Executable File

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);
}
});
}
}
});