2:cc1e5f212e6c
Anton Shestakov <engored@ya.ru>, Tue, 25 Dec 2012 17:09:32 +0900
Since CodernityDB 0.4.0 get_many is not limited to 1 item by default, so omit limit=-1.

next change 7:5c5d433b3a14
previous change 0:a02e94c5b96b

static/js/framework/models.js

Permissions: -rw-r--r--

Other formats: Feeds:
var Model = Backbone.Model.extend({
url: function() {
var url = Backbone.Model.prototype.url.call(this);
return url[url.length - 1] == '/' ? url : url + '/';
},
adhoc: function(data) {
var model = this;
var options = {
url: this.urlRoot + encodeURIComponent(this.id) + '/',
contentType: 'application/json',
data: JSON.stringify(data)
};
return (this.sync || Backbone.sync).call(this, 'update', model, options).then(function(serverAttrs) {
model.set(serverAttrs);
});
}
});
var Project = Model.extend({
idAttribute: '_id',
urlRoot: '/projects/',
switchColor: function() {
var colorChain = [null, 'info', 'success', 'warning', 'danger'];
var currentColorIndex = colorChain.indexOf(this.get('color') || null);
var nextColor = colorChain[(currentColorIndex + 1) % colorChain.length];
return this.adhoc({color: nextColor});
}
});
var Task = Model.extend({
idAttribute: '_id',
urlRoot: '/tasks/'
});