Initial commit
This commit is contained in:
39
lib/assets/javascripts/builder/data/user-notifications.js
Executable file
39
lib/assets/javascripts/builder/data/user-notifications.js
Executable file
@@ -0,0 +1,39 @@
|
||||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
/**
|
||||
* User Notifications
|
||||
*
|
||||
*/
|
||||
|
||||
var UserNotifications = Backbone.Model.extend({
|
||||
sync: function (method, model, options) {
|
||||
return Backbone.sync('update', model, options);
|
||||
},
|
||||
|
||||
url: function () {
|
||||
var baseUrl = this._configModel.get('base_url');
|
||||
return baseUrl + '/api/v3/notifications/' + this.get('key');
|
||||
},
|
||||
|
||||
initialize: function (attrs, opts) {
|
||||
if (!opts.key) throw new Error('key is required');
|
||||
if (!opts.configModel) throw new Error('configModel is required');
|
||||
|
||||
this._configModel = opts.configModel;
|
||||
this.attributes = _.extend({ notifications: attrs }, { key: opts.key });
|
||||
},
|
||||
|
||||
getKey: function (key) {
|
||||
var notifications = this.get('notifications') || {};
|
||||
return notifications[key];
|
||||
},
|
||||
|
||||
setKey: function (key, value) {
|
||||
var notifications = this.get('notifications') || {};
|
||||
notifications[key] = value;
|
||||
this.set('notifications', notifications);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = UserNotifications;
|
||||
Reference in New Issue
Block a user