prime-rails 0.0.15 → 0.0.16

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGQ5YTY2MjVjZDk0MzkzMDkwZjY3MTk2NThlYTBhNzZmZTczMThlMw==
4
+ Njk3NTUwYWNiNzMyZmVlNDY5N2IyNzI4M2VmNzlmNWUwZDQ0ZDA2ZA==
5
5
  data.tar.gz: !binary |-
6
- NGZhOTdiYmIwNzIxNmY4YTkxYjY4YTFiY2Y1ODZjOGRmZjQ5ZWNhMg==
6
+ NGZjNmU5Mjg4N2E4YmVmNWEyNGNmOGEyY2U4MGViZTdjOWJiYWEwOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODY1YzJhY2UxMzg0NjY0OGEyZjVhMGVjZTg2NmEzMDQ1NTkwM2Y5MTljOWQ5
10
- OTdhYzY0ZjU4YmM3ZjQ2YmE1NGQ5ZTBmMGU2OWQ0YTE4NWE2MDJiYThjNWE3
11
- ZDY5MjM0Y2QyYzI5ZGNjZWFiNWVkMDQ1MDA3ZmNlN2I3N2Y5OTk=
9
+ NTFkNjVlZTc5YTcyZWY0M2YxZDg2ZDM4MWFkNDdlZDAyNTQyYTNkMDlmNTAz
10
+ MzA3OTI5NDc3OWIyZDc5NzI0NDIxYTc0ZjhjOWQ2YzY5ODdkNDMxY2ZmNGI5
11
+ YTU1YmI3MGI5ZmI0ZjkxYjVlMDM0MTBlMmM3NGQ1ODA0MzA4Zjc=
12
12
  data.tar.gz: !binary |-
13
- NmFkZTRjMzQ0ZjRkMjliZDM2YWFjNzE4Yzc1MzQyZjE0YjE2OTdmZTI0MjM4
14
- NmU4ZGJlMWRiYzg5MTgzNmE2NzgxOTg5MWViYTJhMDk4ZDFmNWY3MjA4ODc3
15
- MjUzZTFlYTkyZTk0NWYyMmQ0ZTgzYzg0Mzk0MzE1MTVlNzM1YWY=
13
+ OGNjNzViYjk4MjNmNDQ2YzEyMGFhY2U2OWIyMDk2ZTIxMDViMGM0ODlhYzUz
14
+ OWViMWVjYTk5ZWViODQ5NDRmNThmODQ5NDE2ZDRlMTNiM2FiODljODlkZWU4
15
+ ODQyMDA3YmE0YzJiOTg2ZjI4Zjc1ZDcyYmYzMDJmNjhhNGJiMGM=
@@ -208,7 +208,7 @@ PrimeFaces.widget.RadioButton = PrimeFaces.widget.BaseWidget.extend({
208
208
  PrimeFaces.widget.Growl = PrimeFaces.widget.BaseWidget.extend({
209
209
  init: function(cfg) {
210
210
  this._super(cfg);
211
- _self = this;
211
+ var _self = this;
212
212
 
213
213
  this.jq.puigrowl(cfg);
214
214
 
@@ -393,7 +393,7 @@ PrimeFaces.widget.Paginator = PrimeFaces.widget.BaseWidget.extend({
393
393
  this._super(cfg);
394
394
  this.inputPage = $(this.jqId + '_page');
395
395
  this.form = this.jq.parents('form:first');
396
- _self = this;
396
+ var _self = this;
397
397
 
398
398
  cfg.paginate = function(event,state){
399
399
  _self.inputPage.val(state.page +1);
@@ -401,8 +401,65 @@ PrimeFaces.widget.Paginator = PrimeFaces.widget.BaseWidget.extend({
401
401
  };
402
402
 
403
403
  this.jq.puipaginator(cfg);
404
-
404
+
405
+ }
406
+ });
407
+
408
+ /**
409
+ * PrimeFaces SplitButton Widget
410
+ */
411
+ PrimeFaces.widget.DataTable = PrimeFaces.widget.BaseWidget.extend({
412
+ init: function(cfg) {
413
+ this._super(cfg);
414
+ this.selectionHolder = $(this.jqId + '_selection');
415
+ this.selection = []
416
+ var _self = this;
417
+
418
+ cfg.rowSelect = function(event, data) {
419
+ _self.selection = [];
420
+ _self.addSelection(data[cfg.rowkey]);
421
+ _self.writeSelections();
422
+ },
423
+
424
+ cfg.rowUnselect = function(event, data) {
425
+ _self.removeSelection(data[cfg.rowkey]);
426
+ _self.writeSelections();
427
+ },
405
428
 
429
+ this.jq.puidatatable(cfg);
406
430
 
407
- }
431
+
432
+
433
+ },
434
+
435
+ /**
436
+ * Writes selected row ids to state holder
437
+ */
438
+ writeSelections: function() {
439
+ $(this.selectionHolder).val(this.selection.join(','));
440
+ },
441
+
442
+ /**
443
+ * Remove given rowIndex from selection
444
+ */
445
+ removeSelection: function(rowIndex) {
446
+ this.selection = $.grep(this.selection, function(value) {
447
+ return value != rowIndex;
448
+ });
449
+ },
450
+
451
+ /**
452
+ * Adds given rowIndex to selection if it doesn't exist already
453
+ */
454
+ addSelection: function(rowIndex) {
455
+ this.selection.push(rowIndex);
456
+ },
457
+
458
+ isSingleSelection: function() {
459
+ return this.cfg.selectionMode == 'single';
460
+ },
461
+
462
+ isMultipleSelection: function() {
463
+ return this.cfg.selectionMode == 'multiple';
464
+ }
408
465
  });
@@ -0,0 +1,44 @@
1
+ module DatatableHelper
2
+
3
+ def p_datatable(id,options={})
4
+ decoded_options = datatable_decode(id,options)
5
+ output = datatable_encode_markup(id,decoded_options)
6
+ output += datatable_encode_script(id,decoded_options)
7
+ end
8
+
9
+ protected
10
+
11
+ def datatable_decode(id,options={})
12
+ clientid = sanitize_to_id(id)
13
+ param_selection = params[clientid+'_selection']
14
+ options = options.merge(:selection => param_selection)
15
+ options
16
+ end
17
+
18
+ def datatable_encode_markup(id,options={})
19
+ clientid = sanitize_to_id(id)
20
+ options = options.stringify_keys
21
+ options = options.merge(:id => clientid)
22
+ options.delete('columns')
23
+ options.delete('datasource')
24
+ output = content_tag('div', options) do
25
+ text_field_tag(clientid+'_selection',options['selection'],type: 'hidden')
26
+ end
27
+ output.html_safe
28
+ end
29
+
30
+ def datatable_encode_script(id,options={})
31
+ options = options.stringify_keys
32
+ clientid = sanitize_to_id(id)
33
+ widgetvar = options.has_key?("widgetVar") ? options["widgetVar"] : "widget_"+clientid
34
+ options_ui = options
35
+ options_ui = options_ui.merge(:id => clientid)
36
+ options_ui = options_ui.to_json
37
+
38
+ script = '$(function() {'
39
+ script += "PrimeFaces.cw('DataTable','#{widgetvar}',#{options_ui})"
40
+ script += '});'
41
+ p_javascript_tag(script, "id" => clientid+"_s")
42
+ end
43
+
44
+ end
@@ -10,7 +10,7 @@ module PaginatorHelper
10
10
 
11
11
  def paginator_decode(id,options={})
12
12
  clientid = sanitize_to_id(id)
13
- param_page = params[clientid+'_page'].nil? ? 0 : (params[clientid+'_page'].to_i) -1
13
+ param_page = params[clientid+'_page'].nil? ? 0 : (params[clientid+'_page'].to_i) -1
14
14
  options = options.merge(:page => param_page)
15
15
  options
16
16
  end
@@ -20,7 +20,7 @@ module PaginatorHelper
20
20
  options = options.stringify_keys
21
21
  options = options.merge(:id => clientid)
22
22
  output = content_tag('div',options) do
23
- text_field_tag(clientid+'_page',nil,type: 'hidden')
23
+ text_field_tag(clientid+'_page',options['page'],type: 'hidden')
24
24
  end
25
25
  output.html_safe
26
26
  end
@@ -1,5 +1,5 @@
1
1
  module Prime
2
2
  module Rails
3
- VERSION = "0.0.15"
3
+ VERSION = "0.0.16"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prime-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lazaro Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-25 00:00:00.000000000 Z
11
+ date: 2013-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -655,6 +655,7 @@ files:
655
655
  - app/helpers/autocomplete_helper.rb
656
656
  - app/helpers/breadcrumb_helper.rb
657
657
  - app/helpers/context_menu_helper.rb
658
+ - app/helpers/datatable_helper.rb
658
659
  - app/helpers/dialog_helper.rb
659
660
  - app/helpers/fieldset_helper.rb
660
661
  - app/helpers/galleria_helper.rb