[model][s]: add a constructor with the name of the object for better debugging.
This commit is contained in:
30
src/model.js
30
src/model.js
@@ -6,7 +6,9 @@ this.recline.Model = this.recline.Model || {};
|
|||||||
|
|
||||||
// ## <a id="dataset">Dataset</a>
|
// ## <a id="dataset">Dataset</a>
|
||||||
my.Dataset = Backbone.Model.extend({
|
my.Dataset = Backbone.Model.extend({
|
||||||
__type__: 'Dataset',
|
constructor: function Dataset() {
|
||||||
|
Backbone.Model.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
// ### initialize
|
// ### initialize
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
@@ -331,7 +333,10 @@ my.Dataset.restore = function(state) {
|
|||||||
//
|
//
|
||||||
// A single entry or row in the dataset
|
// A single entry or row in the dataset
|
||||||
my.Record = Backbone.Model.extend({
|
my.Record = Backbone.Model.extend({
|
||||||
__type__: 'Record',
|
constructor: function Record() {
|
||||||
|
Backbone.Model.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
_.bindAll(this, 'getFieldValue');
|
_.bindAll(this, 'getFieldValue');
|
||||||
},
|
},
|
||||||
@@ -369,14 +374,21 @@ my.Record = Backbone.Model.extend({
|
|||||||
destroy: function() { this.trigger('destroy', this); }
|
destroy: function() { this.trigger('destroy', this); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ## A Backbone collection of Records
|
// ## A Backbone collection of Records
|
||||||
my.RecordList = Backbone.Collection.extend({
|
my.RecordList = Backbone.Collection.extend({
|
||||||
__type__: 'RecordList',
|
constructor: function RecordList() {
|
||||||
|
Backbone.Collection.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
model: my.Record
|
model: my.Record
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ## <a id="field">A Field (aka Column) on a Dataset</a>
|
// ## <a id="field">A Field (aka Column) on a Dataset</a>
|
||||||
my.Field = Backbone.Model.extend({
|
my.Field = Backbone.Model.extend({
|
||||||
|
constructor: function Field() {
|
||||||
|
Backbone.Model.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
// ### defaults - define default values
|
// ### defaults - define default values
|
||||||
defaults: {
|
defaults: {
|
||||||
label: null,
|
label: null,
|
||||||
@@ -445,11 +457,17 @@ my.Field = Backbone.Model.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
my.FieldList = Backbone.Collection.extend({
|
my.FieldList = Backbone.Collection.extend({
|
||||||
|
constructor: function FieldList() {
|
||||||
|
Backbone.Collection.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
model: my.Field
|
model: my.Field
|
||||||
});
|
});
|
||||||
|
|
||||||
// ## <a id="query">Query</a>
|
// ## <a id="query">Query</a>
|
||||||
my.Query = Backbone.Model.extend({
|
my.Query = Backbone.Model.extend({
|
||||||
|
constructor: function Query() {
|
||||||
|
Backbone.Model.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
defaults: function() {
|
defaults: function() {
|
||||||
return {
|
return {
|
||||||
size: 100,
|
size: 100,
|
||||||
@@ -534,6 +552,9 @@ my.Query = Backbone.Model.extend({
|
|||||||
|
|
||||||
// ## <a id="facet">A Facet (Result)</a>
|
// ## <a id="facet">A Facet (Result)</a>
|
||||||
my.Facet = Backbone.Model.extend({
|
my.Facet = Backbone.Model.extend({
|
||||||
|
constructor: function Facet() {
|
||||||
|
Backbone.Model.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
defaults: function() {
|
defaults: function() {
|
||||||
return {
|
return {
|
||||||
_type: 'terms',
|
_type: 'terms',
|
||||||
@@ -547,6 +568,9 @@ my.Facet = Backbone.Model.extend({
|
|||||||
|
|
||||||
// ## A Collection/List of Facets
|
// ## A Collection/List of Facets
|
||||||
my.FacetList = Backbone.Collection.extend({
|
my.FacetList = Backbone.Collection.extend({
|
||||||
|
constructor: function FacetList() {
|
||||||
|
Backbone.Collection.prototype.constructor.apply(this, arguments);
|
||||||
|
},
|
||||||
model: my.Facet
|
model: my.Facet
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user