cartodb-4.42/lib/assets/javascripts/builder/components/notifier/notifier-collection.js

23 lines
586 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var Backbone = require('backbone');
var NotifierModel = require('./notifier-model');
module.exports = Backbone.Collection.extend({
model: function (attrs, opts) {
return new NotifierModel(attrs, opts);
},
findById: function (id) {
return this.findWhere({id: id});
},
addNotification: function (attrs, options) {
var notification = this._findNotificationByAttrs(attrs);
return notification ? notification.update(attrs) : this.add(attrs, options);
},
_findNotificationByAttrs: function (attrs) {
return this.findWhere({ info: attrs.info });
}
});