cartodb-4.42/lib/assets/javascripts/builder/data/users-group-collection.js

36 lines
966 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var Backbone = require('backbone');
var syncAbort = require('./backbone/sync-abort');
/**
* A collection representing a set of users in a group.
*/
module.exports = Backbone.Collection.extend({
sync: syncAbort,
initialize: function (models, opts) {
if (!opts.group) throw new Error('group is required');
this.group = opts.group;
this.configModel = opts.configModel;
this.organization = opts.organization;
},
url: function (method) {
var baseUrl = this.configModel.get('base_url');
var version = this.configModel.urlVersion('organizationGroups', method);
return baseUrl + '/api/' + version + '/organization/' + this.organization.id + '/groups/' + this.group.id + '/users';
},
parse: function (response) {
this.total_entries = response.total_entries;
this.total_user_entries = response.total_user_entries;
return response.users;
},
totalCount: function () {
return this.total_user_entries;
}
});