tableling-rails 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Tableling
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -54,6 +54,9 @@ var BooksTable = Tableling.Bootstrap.Table.extend({
54
54
  collection: new BooksCollection({
55
55
  model: Book
56
56
  })
57
+ },
58
+ pageSizeViewOptions : {
59
+ sizes : [ 5, 10, 15 ]
57
60
  }
58
61
  });
59
62
 
@@ -7165,3 +7165,113 @@ Processing by BooksController#page as JSON
7165
7165
   (0.3ms) SELECT COUNT(*) FROM "books" 
7166
7166
  Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
7167
7167
  Completed 200 OK in 3ms (Views: 0.5ms | ActiveRecord: 0.4ms)
7168
+
7169
+
7170
+ Started GET "/" for 127.0.0.1 at 2012-10-17 11:17:04 +0200
7171
+ Processing by BooksController#index as HTML
7172
+ Rendered books/index.html.haml within layouts/application (1.0ms)
7173
+ Compiled tableling.world.js (38ms) (pid 6723)
7174
+ Compiled application.js (5ms) (pid 6723)
7175
+ Completed 200 OK in 87ms (Views: 87.3ms | ActiveRecord: 0.0ms)
7176
+
7177
+
7178
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:04 +0200
7179
+ Processing by BooksController#page as JSON
7180
+ Parameters: {"page"=>"1", "pageSize"=>"10"}
7181
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7182
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
7183
+ Completed 200 OK in 3ms (Views: 0.6ms | ActiveRecord: 0.3ms)
7184
+
7185
+
7186
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:08 +0200
7187
+ Processing by BooksController#page as JSON
7188
+ Parameters: {"page"=>"1", "pageSize"=>"15"}
7189
+  (0.1ms) SELECT COUNT(*) FROM "books" 
7190
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 15 OFFSET 0
7191
+ Completed 200 OK in 3ms (Views: 1.4ms | ActiveRecord: 0.3ms)
7192
+
7193
+
7194
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:09 +0200
7195
+ Processing by BooksController#page as JSON
7196
+ Parameters: {"page"=>"1", "pageSize"=>"10"}
7197
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7198
+ Book Load (0.2ms) SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
7199
+ Completed 200 OK in 2ms (Views: 0.7ms | ActiveRecord: 0.4ms)
7200
+
7201
+
7202
+ Started GET "/" for 127.0.0.1 at 2012-10-17 11:17:09 +0200
7203
+ Processing by BooksController#index as HTML
7204
+ Rendered books/index.html.haml within layouts/application (0.2ms)
7205
+ Completed 200 OK in 16ms (Views: 15.4ms | ActiveRecord: 0.0ms)
7206
+
7207
+
7208
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:09 +0200
7209
+ Processing by BooksController#page as JSON
7210
+ Parameters: {"page"=>"1", "pageSize"=>"10"}
7211
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7212
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
7213
+ Completed 200 OK in 3ms (Views: 0.9ms | ActiveRecord: 0.3ms)
7214
+
7215
+
7216
+ Started GET "/" for 127.0.0.1 at 2012-10-17 11:17:33 +0200
7217
+ Processing by BooksController#index as HTML
7218
+ Rendered books/index.html.haml within layouts/application (0.2ms)
7219
+ Compiled books.js (0ms) (pid 6723)
7220
+ Compiled application.js (8ms) (pid 6723)
7221
+ Completed 200 OK in 87ms (Views: 86.5ms | ActiveRecord: 0.0ms)
7222
+
7223
+
7224
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:33 +0200
7225
+ Processing by BooksController#page as JSON
7226
+ Parameters: {"page"=>"1", "pageSize"=>"5"}
7227
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7228
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
7229
+ Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
7230
+
7231
+
7232
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:35 +0200
7233
+ Processing by BooksController#page as JSON
7234
+ Parameters: {"page"=>"1", "pageSize"=>"10"}
7235
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7236
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
7237
+ Completed 200 OK in 2ms (Views: 0.8ms | ActiveRecord: 0.3ms)
7238
+
7239
+
7240
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:36 +0200
7241
+ Processing by BooksController#page as JSON
7242
+ Parameters: {"page"=>"1", "pageSize"=>"5"}
7243
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7244
+ Book Load (0.2ms) SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
7245
+ Completed 200 OK in 2ms (Views: 0.5ms | ActiveRecord: 0.4ms)
7246
+
7247
+
7248
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:37 +0200
7249
+ Processing by BooksController#page as JSON
7250
+ Parameters: {"page"=>"1", "pageSize"=>"5", "quickSearch"=>"tale"}
7251
+  (0.2ms) SELECT COUNT(*) FROM "books" WHERE (LOWER(books.title) LIKE '%tale%' OR LOWER(books.author) LIKE '%tale%')
7252
+ Book Load (0.1ms) SELECT "books".* FROM "books" WHERE (LOWER(books.title) LIKE '%tale%' OR LOWER(books.author) LIKE '%tale%') LIMIT 5 OFFSET 0
7253
+ Completed 200 OK in 2ms (Views: 0.2ms | ActiveRecord: 0.4ms)
7254
+
7255
+
7256
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:38 +0200
7257
+ Processing by BooksController#page as JSON
7258
+ Parameters: {"page"=>"1", "pageSize"=>"5"}
7259
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7260
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
7261
+ Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
7262
+
7263
+
7264
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:39 +0200
7265
+ Processing by BooksController#page as JSON
7266
+ Parameters: {"page"=>"2", "pageSize"=>"5"}
7267
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7268
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 5 OFFSET 5
7269
+ Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
7270
+
7271
+
7272
+ Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:40 +0200
7273
+ Processing by BooksController#page as JSON
7274
+ Parameters: {"page"=>"1", "pageSize"=>"5"}
7275
+  (0.2ms) SELECT COUNT(*) FROM "books" 
7276
+ Book Load (0.1ms) SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
7277
+ Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
@@ -3094,7 +3094,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
3094
3094
  return Marionette;
3095
3095
  })(Backbone, _, $ || window.jQuery || window.Zepto || window.ender);
3096
3096
  /*!
3097
- * Tableling v0.0.9
3097
+ * Tableling v0.0.10
3098
3098
  * Copyright (c) 2012 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
3099
3099
  * Distributed under MIT license
3100
3100
  * https://github.com/AlphaHydrae/tableling
@@ -3102,7 +3102,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
3102
3102
  Backbone.Tableling = Tableling = (function(Backbone, _, $){
3103
3103
 
3104
3104
  var Tableling = {
3105
- version : "0.0.9"
3105
+ version : "0.0.10"
3106
3106
  };
3107
3107
 
3108
3108
  // Tableling
@@ -3116,8 +3116,7 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3116
3116
 
3117
3117
  // Default table options can be overriden by subclasses.
3118
3118
  tableling : {
3119
- page : 1,
3120
- pageSize : 15
3119
+ page : 1
3121
3120
  },
3122
3121
 
3123
3122
  initialize : function(options) {
@@ -3141,8 +3140,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3141
3140
 
3142
3141
  // Called once rendering is complete. By default, it updates the table.
3143
3142
  setup : function() {
3144
- this.vent.trigger('table:setup', this.filterConfig(this.tableling, true));
3145
- this.vent.trigger('table:update');
3143
+ this.ventTrigger('table:setup', this.filterConfig(this.tableling, true));
3144
+ this.ventTrigger('table:update');
3146
3145
  },
3147
3146
 
3148
3147
  // Subclasses must return the Backbone.Collection used to fetch data.
@@ -3237,11 +3236,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3237
3236
  ventTrigger : function() {
3238
3237
 
3239
3238
  var args = Array.prototype.slice.call(arguments);
3240
- this.vent.trigger.apply(this.vent, args);
3241
-
3242
3239
  if (Tableling.debug) {
3243
- console.log(args.shift() + ' - ' + JSON.stringify(args));
3240
+ console.log(_.first(args) + ' - ' + JSON.stringify(args.slice(1)));
3244
3241
  }
3242
+
3243
+ this.vent.trigger.apply(this.vent, args);
3245
3244
  }
3246
3245
  });
3247
3246
 
@@ -3354,10 +3353,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3354
3353
  initialize : function(options) {
3355
3354
  this.vent = options.vent;
3356
3355
 
3357
- // The `refresh` method of the view is called once the view is rendered
3358
- // and every time the table is refreshed.
3356
+ // The `setup` method of the view is called when the table
3357
+ // is first set up.
3358
+ this.vent.on('table:setup', this.setup, this);
3359
+
3360
+ // The `refresh` method of the view is called every time the table
3361
+ // is refreshed.
3359
3362
  this.vent.on('table:refreshed', this.refresh, this);
3360
- this.on('render', this.refresh, this);
3361
3363
  },
3362
3364
 
3363
3365
  // Call `update` to trigger an update of the table.
@@ -3365,10 +3367,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3365
3367
  this.vent.trigger('table:update', this.config());
3366
3368
  },
3367
3369
 
3370
+ // Implementations should override this to set initial values.
3371
+ setup : function(config) {
3372
+ },
3373
+
3368
3374
  // Implementations should override this to stay up to date with
3369
- // the table state. Note that the data parameter will be undefined
3370
- // on the first refresh when the view is rendered.
3371
- refresh : function(data) {
3375
+ // the table state.
3376
+ refresh : function(config) {
3372
3377
  },
3373
3378
 
3374
3379
  // New table configuration to be sent on updates. For example,
@@ -3385,6 +3390,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3385
3390
  // defaults and only requires a `name` and a `template` parameter.
3386
3391
  Tableling.FieldModule = Tableling.Module.extend({
3387
3392
 
3393
+ // TODO: check name
3394
+
3388
3395
  initialize : function(options) {
3389
3396
 
3390
3397
  Tableling.Module.prototype.initialize.call(this, options);
@@ -3402,6 +3409,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3402
3409
  this.events['change [name="' + this.name + '"]'] = 'update';
3403
3410
  },
3404
3411
 
3412
+ setup : function(config) {
3413
+ this.ui.field.val(config[this.name]);
3414
+ this.vent.trigger('table:update', this.config(), { refresh : false });
3415
+ },
3416
+
3405
3417
  // The table property updated is the one with the same name as the module.
3406
3418
  config : function() {
3407
3419
  var config = {};
@@ -3514,7 +3526,26 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
3514
3526
  Tableling.Plain.PageSizeView = Tableling.Plain.Table.prototype.pageSizeView = Tableling.FieldModule.extend({
3515
3527
  // TODO: update current page intelligently
3516
3528
  name : 'pageSize',
3517
- template : _.template('<select name="pageSize"><option>5</option><option>10</option><option>15</option></select> entries per page')
3529
+ template : _.template('<select name="pageSize" /> entries per page'),
3530
+ sizes : [ 10, 15, 20, 25, 50 ],
3531
+
3532
+ ui : {
3533
+ field : 'select'
3534
+ },
3535
+
3536
+ initialize : function(options) {
3537
+ Tableling.FieldModule.prototype.initialize.call(this, options);
3538
+ this.sizes = _.clone(options.sizes || this.sizes);
3539
+ },
3540
+
3541
+ onRender : function() {
3542
+ this.ui.field.empty();
3543
+ _.each(this.sizes, _.bind(this.addSize, this));
3544
+ },
3545
+
3546
+ addSize : function(size) {
3547
+ $('<option />').text(size).appendTo(this.ui.field);
3548
+ }
3518
3549
  });
3519
3550
 
3520
3551
  Tableling.Plain.QuickSearchView = Tableling.Plain.Table.prototype.quickSearchView = Tableling.FieldModule.extend({
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Tableling v0.0.9
2
+ * Tableling v0.0.10
3
3
  * Copyright (c) 2012 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.9"
10
+ version : "0.0.10"
11
11
  };
12
12
 
13
13
  // Tableling
@@ -21,8 +21,7 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
21
21
 
22
22
  // Default table options can be overriden by subclasses.
23
23
  tableling : {
24
- page : 1,
25
- pageSize : 15
24
+ page : 1
26
25
  },
27
26
 
28
27
  initialize : function(options) {
@@ -46,8 +45,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
46
45
 
47
46
  // Called once rendering is complete. By default, it updates the table.
48
47
  setup : function() {
49
- this.vent.trigger('table:setup', this.filterConfig(this.tableling, true));
50
- this.vent.trigger('table:update');
48
+ this.ventTrigger('table:setup', this.filterConfig(this.tableling, true));
49
+ this.ventTrigger('table:update');
51
50
  },
52
51
 
53
52
  // Subclasses must return the Backbone.Collection used to fetch data.
@@ -142,11 +141,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
142
141
  ventTrigger : function() {
143
142
 
144
143
  var args = Array.prototype.slice.call(arguments);
145
- this.vent.trigger.apply(this.vent, args);
146
-
147
144
  if (Tableling.debug) {
148
- console.log(args.shift() + ' - ' + JSON.stringify(args));
145
+ console.log(_.first(args) + ' - ' + JSON.stringify(args.slice(1)));
149
146
  }
147
+
148
+ this.vent.trigger.apply(this.vent, args);
150
149
  }
151
150
  });
152
151
 
@@ -259,10 +258,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
259
258
  initialize : function(options) {
260
259
  this.vent = options.vent;
261
260
 
262
- // The `refresh` method of the view is called once the view is rendered
263
- // and every time the table is refreshed.
261
+ // The `setup` method of the view is called when the table
262
+ // is first set up.
263
+ this.vent.on('table:setup', this.setup, this);
264
+
265
+ // The `refresh` method of the view is called every time the table
266
+ // is refreshed.
264
267
  this.vent.on('table:refreshed', this.refresh, this);
265
- this.on('render', this.refresh, this);
266
268
  },
267
269
 
268
270
  // Call `update` to trigger an update of the table.
@@ -270,10 +272,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
270
272
  this.vent.trigger('table:update', this.config());
271
273
  },
272
274
 
275
+ // Implementations should override this to set initial values.
276
+ setup : function(config) {
277
+ },
278
+
273
279
  // Implementations should override this to stay up to date with
274
- // the table state. Note that the data parameter will be undefined
275
- // on the first refresh when the view is rendered.
276
- refresh : function(data) {
280
+ // the table state.
281
+ refresh : function(config) {
277
282
  },
278
283
 
279
284
  // New table configuration to be sent on updates. For example,
@@ -290,6 +295,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
290
295
  // defaults and only requires a `name` and a `template` parameter.
291
296
  Tableling.FieldModule = Tableling.Module.extend({
292
297
 
298
+ // TODO: check name
299
+
293
300
  initialize : function(options) {
294
301
 
295
302
  Tableling.Module.prototype.initialize.call(this, options);
@@ -307,6 +314,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
307
314
  this.events['change [name="' + this.name + '"]'] = 'update';
308
315
  },
309
316
 
317
+ setup : function(config) {
318
+ this.ui.field.val(config[this.name]);
319
+ this.vent.trigger('table:update', this.config(), { refresh : false });
320
+ },
321
+
310
322
  // The table property updated is the one with the same name as the module.
311
323
  config : function() {
312
324
  var config = {};
@@ -419,7 +431,26 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
419
431
  Tableling.Plain.PageSizeView = Tableling.Plain.Table.prototype.pageSizeView = Tableling.FieldModule.extend({
420
432
  // TODO: update current page intelligently
421
433
  name : 'pageSize',
422
- template : _.template('<select name="pageSize"><option>5</option><option>10</option><option>15</option></select> entries per page')
434
+ template : _.template('<select name="pageSize" /> entries per page'),
435
+ sizes : [ 10, 15, 20, 25, 50 ],
436
+
437
+ ui : {
438
+ field : 'select'
439
+ },
440
+
441
+ initialize : function(options) {
442
+ Tableling.FieldModule.prototype.initialize.call(this, options);
443
+ this.sizes = _.clone(options.sizes || this.sizes);
444
+ },
445
+
446
+ onRender : function() {
447
+ this.ui.field.empty();
448
+ _.each(this.sizes, _.bind(this.addSize, this));
449
+ },
450
+
451
+ addSize : function(size) {
452
+ $('<option />').text(size).appendTo(this.ui.field);
453
+ }
423
454
  });
424
455
 
425
456
  Tableling.Plain.QuickSearchView = Tableling.Plain.Table.prototype.quickSearchView = Tableling.FieldModule.extend({
@@ -14224,7 +14224,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
14224
14224
  return Marionette;
14225
14225
  })(Backbone, _, $ || window.jQuery || window.Zepto || window.ender);
14226
14226
  /*!
14227
- * Tableling v0.0.9
14227
+ * Tableling v0.0.10
14228
14228
  * Copyright (c) 2012 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
14229
14229
  * Distributed under MIT license
14230
14230
  * https://github.com/AlphaHydrae/tableling
@@ -14232,7 +14232,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
14232
14232
  Backbone.Tableling = Tableling = (function(Backbone, _, $){
14233
14233
 
14234
14234
  var Tableling = {
14235
- version : "0.0.9"
14235
+ version : "0.0.10"
14236
14236
  };
14237
14237
 
14238
14238
  // Tableling
@@ -14246,8 +14246,7 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14246
14246
 
14247
14247
  // Default table options can be overriden by subclasses.
14248
14248
  tableling : {
14249
- page : 1,
14250
- pageSize : 15
14249
+ page : 1
14251
14250
  },
14252
14251
 
14253
14252
  initialize : function(options) {
@@ -14271,8 +14270,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14271
14270
 
14272
14271
  // Called once rendering is complete. By default, it updates the table.
14273
14272
  setup : function() {
14274
- this.vent.trigger('table:setup', this.filterConfig(this.tableling, true));
14275
- this.vent.trigger('table:update');
14273
+ this.ventTrigger('table:setup', this.filterConfig(this.tableling, true));
14274
+ this.ventTrigger('table:update');
14276
14275
  },
14277
14276
 
14278
14277
  // Subclasses must return the Backbone.Collection used to fetch data.
@@ -14367,11 +14366,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14367
14366
  ventTrigger : function() {
14368
14367
 
14369
14368
  var args = Array.prototype.slice.call(arguments);
14370
- this.vent.trigger.apply(this.vent, args);
14371
-
14372
14369
  if (Tableling.debug) {
14373
- console.log(args.shift() + ' - ' + JSON.stringify(args));
14370
+ console.log(_.first(args) + ' - ' + JSON.stringify(args.slice(1)));
14374
14371
  }
14372
+
14373
+ this.vent.trigger.apply(this.vent, args);
14375
14374
  }
14376
14375
  });
14377
14376
 
@@ -14484,10 +14483,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14484
14483
  initialize : function(options) {
14485
14484
  this.vent = options.vent;
14486
14485
 
14487
- // The `refresh` method of the view is called once the view is rendered
14488
- // and every time the table is refreshed.
14486
+ // The `setup` method of the view is called when the table
14487
+ // is first set up.
14488
+ this.vent.on('table:setup', this.setup, this);
14489
+
14490
+ // The `refresh` method of the view is called every time the table
14491
+ // is refreshed.
14489
14492
  this.vent.on('table:refreshed', this.refresh, this);
14490
- this.on('render', this.refresh, this);
14491
14493
  },
14492
14494
 
14493
14495
  // Call `update` to trigger an update of the table.
@@ -14495,10 +14497,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14495
14497
  this.vent.trigger('table:update', this.config());
14496
14498
  },
14497
14499
 
14500
+ // Implementations should override this to set initial values.
14501
+ setup : function(config) {
14502
+ },
14503
+
14498
14504
  // Implementations should override this to stay up to date with
14499
- // the table state. Note that the data parameter will be undefined
14500
- // on the first refresh when the view is rendered.
14501
- refresh : function(data) {
14505
+ // the table state.
14506
+ refresh : function(config) {
14502
14507
  },
14503
14508
 
14504
14509
  // New table configuration to be sent on updates. For example,
@@ -14515,6 +14520,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14515
14520
  // defaults and only requires a `name` and a `template` parameter.
14516
14521
  Tableling.FieldModule = Tableling.Module.extend({
14517
14522
 
14523
+ // TODO: check name
14524
+
14518
14525
  initialize : function(options) {
14519
14526
 
14520
14527
  Tableling.Module.prototype.initialize.call(this, options);
@@ -14532,6 +14539,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14532
14539
  this.events['change [name="' + this.name + '"]'] = 'update';
14533
14540
  },
14534
14541
 
14542
+ setup : function(config) {
14543
+ this.ui.field.val(config[this.name]);
14544
+ this.vent.trigger('table:update', this.config(), { refresh : false });
14545
+ },
14546
+
14535
14547
  // The table property updated is the one with the same name as the module.
14536
14548
  config : function() {
14537
14549
  var config = {};
@@ -14644,7 +14656,26 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
14644
14656
  Tableling.Plain.PageSizeView = Tableling.Plain.Table.prototype.pageSizeView = Tableling.FieldModule.extend({
14645
14657
  // TODO: update current page intelligently
14646
14658
  name : 'pageSize',
14647
- template : _.template('<select name="pageSize"><option>5</option><option>10</option><option>15</option></select> entries per page')
14659
+ template : _.template('<select name="pageSize" /> entries per page'),
14660
+ sizes : [ 10, 15, 20, 25, 50 ],
14661
+
14662
+ ui : {
14663
+ field : 'select'
14664
+ },
14665
+
14666
+ initialize : function(options) {
14667
+ Tableling.FieldModule.prototype.initialize.call(this, options);
14668
+ this.sizes = _.clone(options.sizes || this.sizes);
14669
+ },
14670
+
14671
+ onRender : function() {
14672
+ this.ui.field.empty();
14673
+ _.each(this.sizes, _.bind(this.addSize, this));
14674
+ },
14675
+
14676
+ addSize : function(size) {
14677
+ $('<option />').text(size).appendTo(this.ui.field);
14678
+ }
14648
14679
  });
14649
14680
 
14650
14681
  Tableling.Plain.QuickSearchView = Tableling.Plain.Table.prototype.quickSearchView = Tableling.FieldModule.extend({
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tableling-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: