tableling-rails 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTUxMzMyYjBkZDk5OGVhMTQwZTljNzNjNDE2ZTNkOGE1ZDllMzU2NA==
4
+ Y2M5OTYxOGJlMmYyNmVmYWUyNDcxYTg3ZTU1YzA3YTIzNmM1Yzg3YQ==
5
5
  data.tar.gz: !binary |-
6
- ZGMzZjA0ODRiZTEzZTZlNjVjMWQzYmQyOWZmNGI2NDgwY2ZmMzY0YQ==
6
+ Y2M5MTI1NTJiZGYyMDkzYTdkYjE3NGQ2YjA2ZDIzYzQ4NDQyMDVkMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTE4NGRjZjVhMzBhMGM4NWE5MmZkZGI3NTMwYmExNTA3NDg2ZDNkN2JlYzBj
10
- YzNhNmY3M2ZlNWY0ZmVkNzljYzg1YjgwNzZmMzA3OWMyYWMzZWRkYzZlMDM3
11
- NDUxMzliNDM4Nzk0Y2U2ODRhMjI1Zjk0ZmYzZWI5MTgxODI1MDI=
9
+ MmM2ZjZiNDA2NzYzZTY1MzdkMDFiMWYxNzdhNTkzMTRlNDE1YmY1ZTMxMDA0
10
+ ODA3ZDc0MTA2Njc3ODZhZDY1ODQ5MDQwNTQzYjU3MWQzOTI0MzM2Y2I4YTRl
11
+ YTg0ODNkNWQ0ZDQ2NjdjYzc3NTJkM2VjYmI5MDU4YTY4OTRjNmU=
12
12
  data.tar.gz: !binary |-
13
- YTMwYjEwNTQwYzY4ZTQ4ZWVmZmVmZmU2NmI4OWRmMWNhZmI5OTA3NmI4ZGI0
14
- OGQzMmJkY2YxZjM0YzMyYjNmOTBiN2U3NTAxZGE1MTZhM2ZiNWI0Y2IwMWU4
15
- MjNmOGQ0M2FkNmIzNTE0MmYxNGE5MWZlY2U5MDc4ODJiMzIyY2U=
13
+ ZjI1MWE1MWYyNTE4NzU0Mjc1NzRlZmE1NTRjNGUxNWQ2NDM4ZWVmYWMxNGM5
14
+ Zjk1YWI4OTY1ZWMwZTM0YzIzMzIyNDdkMGFjNmYxM2RiM2Q4N2YzMGE4ZGUx
15
+ NTAyZWUzNjA3MjBjYWM3MzNiNWIxOTFkZDI0OGM4ZWIwODFjNjY=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.24
1
+ 0.0.25
@@ -1,3 +1,3 @@
1
1
  module Tableling
2
- VERSION = "0.0.24"
2
+ VERSION = "0.0.25"
3
3
  end
@@ -4090,7 +4090,7 @@ _.extend(Marionette.Module, {
4090
4090
  })(this, Backbone, _);
4091
4091
 
4092
4092
  /*!
4093
- * Tableling v0.0.24
4093
+ * Tableling v0.0.25
4094
4094
  * Copyright (c) 2012-2014 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
4095
4095
  * Distributed under MIT license
4096
4096
  * https://github.com/AlphaHydrae/tableling
@@ -4098,7 +4098,7 @@ _.extend(Marionette.Module, {
4098
4098
  Backbone.Tableling = Tableling = (function(Backbone, _, $){
4099
4099
 
4100
4100
  var Tableling = {
4101
- version : "0.0.24"
4101
+ version : "0.0.25"
4102
4102
  };
4103
4103
 
4104
4104
  // Tableling
@@ -4118,7 +4118,9 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
4118
4118
  initialize: function(options) {
4119
4119
  options = options || {};
4120
4120
 
4121
- this.collection = options.collection;
4121
+ if (!this.getCollection(this.getResource())) {
4122
+ throw new Error('Missing collection; pass it to the constructor or override #getCollection');
4123
+ }
4122
4124
 
4123
4125
  // Table options can also be overriden for each instance at construction.
4124
4126
  this.config = _.extend(_.clone(this.config || {}), _.result(options, 'config') || {});
@@ -4156,8 +4158,12 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
4156
4158
  }
4157
4159
  },
4158
4160
 
4161
+ getResource: function() {
4162
+ return this.collection || this.model;
4163
+ },
4164
+
4159
4165
  // Subclasses must return the Backbone.Collection used to fetch data.
4160
- getCollection: function() {
4166
+ getCollection: function(resource) {
4161
4167
  return this.collection;
4162
4168
  },
4163
4169
 
@@ -4212,7 +4218,7 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
4212
4218
  // The first argument is the request data.
4213
4219
  this.ventTrigger('table:refreshing', options.data);
4214
4220
 
4215
- this.getCollection().fetch(options);
4221
+ this.getResource().fetch(options);
4216
4222
  },
4217
4223
 
4218
4224
  // ### Request
@@ -4221,9 +4227,9 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
4221
4227
  },
4222
4228
 
4223
4229
  // ### Response
4224
- processResponse: function(collection, response) {
4230
+ processResponse: function(resource, response) {
4225
4231
 
4226
- this.config.length = collection.length;
4232
+ this.config.length = this.getCollection(resource).length;
4227
4233
 
4228
4234
  // Tableling expects the response from a fetch to have a `total` property
4229
4235
  // which is the total number of items (not just in the current page).
@@ -4319,7 +4325,7 @@ Tableling.Modular = Tableling.Table.extend({
4319
4325
  var options = _.extend(this.getModuleOptions(name), { vent: this.vent });
4320
4326
 
4321
4327
  // The collection is also passed to view classes.
4322
- _.defaults(options, { collection: this.getCollection() });
4328
+ _.defaults(options, { collection: this.getCollection(this.getResource()) });
4323
4329
 
4324
4330
  var view = new viewClass(options);
4325
4331
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Tableling v0.0.24
2
+ * Tableling v0.0.25
3
3
  * Copyright (c) 2012-2014 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
4
4
  * Distributed under MIT license
5
5
  * https://github.com/AlphaHydrae/tableling
@@ -7,7 +7,7 @@
7
7
  Backbone.Tableling = Tableling = (function(Backbone, _, $){
8
8
 
9
9
  var Tableling = {
10
- version : "0.0.24"
10
+ version : "0.0.25"
11
11
  };
12
12
 
13
13
  // Tableling
@@ -27,7 +27,9 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
27
27
  initialize: function(options) {
28
28
  options = options || {};
29
29
 
30
- this.collection = options.collection;
30
+ if (!this.getCollection(this.getResource())) {
31
+ throw new Error('Missing collection; pass it to the constructor or override #getCollection');
32
+ }
31
33
 
32
34
  // Table options can also be overriden for each instance at construction.
33
35
  this.config = _.extend(_.clone(this.config || {}), _.result(options, 'config') || {});
@@ -65,8 +67,12 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
65
67
  }
66
68
  },
67
69
 
70
+ getResource: function() {
71
+ return this.collection || this.model;
72
+ },
73
+
68
74
  // Subclasses must return the Backbone.Collection used to fetch data.
69
- getCollection: function() {
75
+ getCollection: function(resource) {
70
76
  return this.collection;
71
77
  },
72
78
 
@@ -121,7 +127,7 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
121
127
  // The first argument is the request data.
122
128
  this.ventTrigger('table:refreshing', options.data);
123
129
 
124
- this.getCollection().fetch(options);
130
+ this.getResource().fetch(options);
125
131
  },
126
132
 
127
133
  // ### Request
@@ -130,9 +136,9 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
130
136
  },
131
137
 
132
138
  // ### Response
133
- processResponse: function(collection, response) {
139
+ processResponse: function(resource, response) {
134
140
 
135
- this.config.length = collection.length;
141
+ this.config.length = this.getCollection(resource).length;
136
142
 
137
143
  // Tableling expects the response from a fetch to have a `total` property
138
144
  // which is the total number of items (not just in the current page).
@@ -228,7 +234,7 @@ Tableling.Modular = Tableling.Table.extend({
228
234
  var options = _.extend(this.getModuleOptions(name), { vent: this.vent });
229
235
 
230
236
  // The collection is also passed to view classes.
231
- _.defaults(options, { collection: this.getCollection() });
237
+ _.defaults(options, { collection: this.getCollection(this.getResource()) });
232
238
 
233
239
  var view = new viewClass(options);
234
240
 
@@ -14966,7 +14966,7 @@ _.extend(Marionette.Module, {
14966
14966
  })(this, Backbone, _);
14967
14967
 
14968
14968
  /*!
14969
- * Tableling v0.0.24
14969
+ * Tableling v0.0.25
14970
14970
  * Copyright (c) 2012-2014 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
14971
14971
  * Distributed under MIT license
14972
14972
  * https://github.com/AlphaHydrae/tableling
@@ -14974,7 +14974,7 @@ _.extend(Marionette.Module, {
14974
14974
  Backbone.Tableling = Tableling = (function(Backbone, _, $){
14975
14975
 
14976
14976
  var Tableling = {
14977
- version : "0.0.24"
14977
+ version : "0.0.25"
14978
14978
  };
14979
14979
 
14980
14980
  // Tableling
@@ -14994,7 +14994,9 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
14994
14994
  initialize: function(options) {
14995
14995
  options = options || {};
14996
14996
 
14997
- this.collection = options.collection;
14997
+ if (!this.getCollection(this.getResource())) {
14998
+ throw new Error('Missing collection; pass it to the constructor or override #getCollection');
14999
+ }
14998
15000
 
14999
15001
  // Table options can also be overriden for each instance at construction.
15000
15002
  this.config = _.extend(_.clone(this.config || {}), _.result(options, 'config') || {});
@@ -15032,8 +15034,12 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
15032
15034
  }
15033
15035
  },
15034
15036
 
15037
+ getResource: function() {
15038
+ return this.collection || this.model;
15039
+ },
15040
+
15035
15041
  // Subclasses must return the Backbone.Collection used to fetch data.
15036
- getCollection: function() {
15042
+ getCollection: function(resource) {
15037
15043
  return this.collection;
15038
15044
  },
15039
15045
 
@@ -15088,7 +15094,7 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
15088
15094
  // The first argument is the request data.
15089
15095
  this.ventTrigger('table:refreshing', options.data);
15090
15096
 
15091
- this.getCollection().fetch(options);
15097
+ this.getResource().fetch(options);
15092
15098
  },
15093
15099
 
15094
15100
  // ### Request
@@ -15097,9 +15103,9 @@ Tableling.Table = Backbone.Marionette.Layout.extend({
15097
15103
  },
15098
15104
 
15099
15105
  // ### Response
15100
- processResponse: function(collection, response) {
15106
+ processResponse: function(resource, response) {
15101
15107
 
15102
- this.config.length = collection.length;
15108
+ this.config.length = this.getCollection(resource).length;
15103
15109
 
15104
15110
  // Tableling expects the response from a fetch to have a `total` property
15105
15111
  // which is the total number of items (not just in the current page).
@@ -15195,7 +15201,7 @@ Tableling.Modular = Tableling.Table.extend({
15195
15201
  var options = _.extend(this.getModuleOptions(name), { vent: this.vent });
15196
15202
 
15197
15203
  // The collection is also passed to view classes.
15198
- _.defaults(options, { collection: this.getCollection() });
15204
+ _.defaults(options, { collection: this.getCollection(this.getResource()) });
15199
15205
 
15200
15206
  var view = new viewClass(options);
15201
15207
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tableling-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Oulevay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails