cartodb/lib/assets/javascripts/builder/data/organization-assets-collection.js

32 lines
787 B
JavaScript
Raw Normal View History

2020-06-15 10:58:47 +08:00
var Backbone = require('backbone');
var AssetModel = require('./asset-model');
var checkAndBuildOpts = require('builder/helpers/required-opts');
var REQUIRED_OPTS = [
'configModel',
'orgId'
];
module.exports = Backbone.Collection.extend({
model: AssetModel,
url: function (method) {
var baseUrl = this._configModel.get('base_url');
var version = this._configModel.urlVersion('organization-assets', method);
return baseUrl + '/api/' + version + '/organization/' + this._orgId + '/assets';
},
initialize: function (models, opts) {
checkAndBuildOpts(opts, REQUIRED_OPTS, this);
},
deselectAll: function (m) {
this.each(function (mdl) {
if (mdl !== m && mdl.get('state') === 'selected') {
mdl.set('state', '');
}
});
}
});