prime-rails 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/primefaces-rails.js +61 -4
- data/app/helpers/datatable_helper.rb +44 -0
- data/app/helpers/paginator_helper.rb +2 -2
- data/lib/prime/rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Njk3NTUwYWNiNzMyZmVlNDY5N2IyNzI4M2VmNzlmNWUwZDQ0ZDA2ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGZjNmU5Mjg4N2E4YmVmNWEyNGNmOGEyY2U4MGViZTdjOWJiYWEwOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTFkNjVlZTc5YTcyZWY0M2YxZDg2ZDM4MWFkNDdlZDAyNTQyYTNkMDlmNTAz
|
10
|
+
MzA3OTI5NDc3OWIyZDc5NzI0NDIxYTc0ZjhjOWQ2YzY5ODdkNDMxY2ZmNGI5
|
11
|
+
YTU1YmI3MGI5ZmI0ZjkxYjVlMDM0MTBlMmM3NGQ1ODA0MzA4Zjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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',
|
23
|
+
text_field_tag(clientid+'_page',options['page'],type: 'hidden')
|
24
24
|
end
|
25
25
|
output.html_safe
|
26
26
|
end
|
data/lib/prime/rails/version.rb
CHANGED
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.
|
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-
|
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
|