compass-jquery-plugin 0.3.2.3 → 0.3.2.4
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.
- data/README.md +54 -37
- data/VERSION.yml +1 -1
- data/lib/handle_attributes.rb +4 -4
- data/lib/handle_js_files.rb +5 -5
- data/lib/jqtouch_theme.rb +2 -2
- data/lib/jquery/dynatree.rb +2 -2
- data/lib/jquery/emulators.rb +1 -1
- data/lib/jquery/flash_messages.rb +6 -6
- data/lib/jquery/graphics.rb +5 -0
- data/lib/jquery/gridify/assertions.rb +1 -1
- data/lib/jquery/gridify/grid.rb +76 -59
- data/lib/jquery/gridify/grid_column.rb +73 -67
- data/lib/jquery/gridify/grid_finder.rb +79 -79
- data/lib/jquery/gridify/grid_options.rb +154 -149
- data/lib/jquery/gridify/grid_view.rb +143 -143
- data/lib/jquery/gridify.rb +25 -25
- data/lib/jquery/ical/calendar.rb +2 -2
- data/lib/jquery/ical/event.rb +48 -44
- data/lib/jquery/ical/helpers/ui_event_helper.rb +3 -3
- data/lib/jquery/jqgrid/jqgrid.rb +58 -58
- data/lib/jquery/jqgrid.rb +1 -1
- data/lib/jquery/jqtouch.rb +1 -1
- data/lib/jquery/jquery.rb +117 -117
- data/lib/jquery/jquery_auto_complete.rb +9 -9
- data/lib/jquery/jquery_json_response.rb +12 -12
- data/lib/jquery/jquery_selector_assertions.rb +55 -53
- data/lib/jquery/jstree.rb +2 -2
- data/lib/jquery/mobile.rb +1 -1
- data/lib/jquery/ribbon.rb +2 -2
- data/lib/jquery/secret_sauce/controller/ui_dialog_controls.rb +5 -5
- data/lib/jquery/secret_sauce/controller/ui_grid_controls.rb +5 -5
- data/lib/jquery/secret_sauce/helpers/ui_dialog_helper.rb +1 -1
- data/lib/jquery/secret_sauce/helpers/ui_form_helper.rb +39 -39
- data/lib/jquery/secret_sauce/helpers/ui_grid_helper.rb +74 -74
- data/lib/jquery/secret_sauce/model/find_for_grid.rb +21 -21
- data/lib/jquery/secret_sauce.rb +1 -1
- data/lib/jquery/tools.rb +1 -1
- data/lib/jquery_mobile_theme.rb +2 -2
- data/lib/jquery_ui_theme.rb +12 -12
- data/templates/dynatree/config/initializers/dynatree.rb +3 -3
- data/templates/dynatree/jquery/dynatree/aero.scss +16 -16
- data/templates/dynatree/jquery/dynatree/aqua.scss +16 -16
- data/templates/dynatree/jquery/dynatree/crystal.scss +16 -16
- data/templates/dynatree/jquery/dynatree/xp.scss +17 -17
- data/templates/dynatree/jquery.dynatree.js +2926 -2912
- data/templates/emulators/config/initializers/emulators.rb +6 -6
- data/templates/graphics/config/initializers/graphics.rb +5 -0
- data/templates/graphics/jquery/ganttView.scss +89 -0
- data/templates/graphics/jquery.ganttView.js +1669 -0
- data/templates/graphics/jquery.ganttView.min.js +70 -0
- data/templates/{jquery → graphics}/jquery.sparkline.js +466 -438
- data/templates/{jquery → graphics}/jquery.sparkline.min.js +0 -0
- data/templates/graphics/manifest.rb +9 -0
- data/templates/jqgrid/config/initializers/jqgrid.rb +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-ar.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-bg.js +135 -131
- data/templates/jqgrid/i18n/jqgrid/locale-bg1251.js +135 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cat.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-cn.js +137 -131
- data/templates/jqgrid/i18n/jqgrid/locale-cs.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-da.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-de.js +138 -132
- data/templates/jqgrid/i18n/jqgrid/locale-el.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-en.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-es.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-fa.js +19 -16
- data/templates/jqgrid/i18n/jqgrid/locale-fi.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-fr.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-gl.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-he.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-hu.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-is.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-it.js +8 -1
- data/templates/jqgrid/i18n/jqgrid/locale-ja.js +139 -136
- data/templates/jqgrid/i18n/jqgrid/locale-nl.js +4 -1
- data/templates/jqgrid/i18n/jqgrid/locale-no.js +14 -1
- data/templates/jqgrid/i18n/jqgrid/locale-pl.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-pt-br.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-pt.js +130 -124
- data/templates/jqgrid/i18n/jqgrid/locale-ro.js +144 -138
- data/templates/jqgrid/i18n/jqgrid/locale-ru.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-sk.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-sr.js +133 -127
- data/templates/jqgrid/i18n/jqgrid/locale-sv.js +132 -126
- data/templates/jqgrid/i18n/jqgrid/locale-tr.js +131 -125
- data/templates/jqgrid/i18n/jqgrid/locale-ua.js +132 -126
- data/templates/jqgrid/jquery.jqGrid.js +12735 -10444
- data/templates/jqgrid/jquery.jqGrid.min.js +477 -469
- data/templates/jqgrid/public/stylesheets/ellipsis-xbl.xml +12 -10
- data/templates/jqtouch/config/initializers/jqtouch.rb +3 -3
- data/templates/jqtouch/jquery/touch/jqtouch.scss +1 -1
- data/templates/jqtouch/jquery.jqtouch.js +10025 -10043
- data/templates/jquery/config/initializers/jquery.rb +2 -4
- data/templates/jquery/history.adapter.jquery.js +71 -0
- data/templates/jquery/history.adapter.jquery.min.js +4 -0
- data/templates/jquery/history.html4.js +690 -0
- data/templates/jquery/history.html4.min.js +21 -0
- data/templates/jquery/history.js +1297 -0
- data/templates/jquery/history.min.js +29 -0
- data/templates/jquery/i18n/jquery.ui/datepicker-af.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ar-DZ.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-ar.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-az.js +19 -19
- data/templates/jquery/i18n/jquery.ui/datepicker-bg.js +8 -8
- data/templates/jquery/i18n/jquery.ui/datepicker-bs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ca.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-cs.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-da.js +14 -14
- data/templates/jquery/i18n/jquery.ui/datepicker-de.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-el.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-AU.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-GB.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-en-NZ.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-es.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-et.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-eu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fa.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-fi.js +15 -15
- data/templates/jquery/i18n/jquery.ui/datepicker-fo.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr-CH.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-fr.js +22 -22
- data/templates/jquery/i18n/jquery.ui/datepicker-gl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-he.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-hu.min.js +1 -1
- data/templates/jquery/i18n/jquery.ui/datepicker-hy.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-id.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-is.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-it.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ja.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ko.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-kz.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-lt.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-lv.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ml.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ms.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-no.js +16 -16
- data/templates/jquery/i18n/jquery.ui/datepicker-no.min.js +2 -2
- data/templates/jquery/i18n/jquery.ui/datepicker-pl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-pt-BR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-pt.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-rm.js +18 -18
- data/templates/jquery/i18n/jquery.ui/datepicker-ro.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-ru.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sk.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sl.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sq.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr-SR.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-sv.js +14 -14
- data/templates/jquery/i18n/jquery.ui/datepicker-ta.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-th.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-tr.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-uk.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-vi.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-CN.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-HK.js +20 -20
- data/templates/jquery/i18n/jquery.ui/datepicker-zh-TW.js +20 -20
- data/templates/jquery/{partials → jquery/ui}/_flash_messages.scss +0 -0
- data/templates/jquery/jquery/ui/_theme.scss +14 -13
- data/templates/jquery/jquery/ui/contextMenu/configure.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/copy.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/cut.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/delete.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/edit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/exit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/new.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/paste.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/rename.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/show.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/trash.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu.scss +16 -10
- data/templates/jquery/jquery-ui.js +11839 -23066
- data/templates/jquery/jquery-ui.min.js +401 -795
- data/templates/jquery/jquery.bgiframe.js +27 -25
- data/templates/jquery/jquery.contextMenu.js +209 -196
- data/templates/jquery/jquery.cookie.js +3 -1
- data/templates/jquery/jquery.dotimeout.js +236 -228
- data/templates/jquery/jquery.dst.js +154 -151
- data/templates/jquery/jquery.farbtastic.js +293 -293
- data/templates/jquery/jquery.flashMessages.js +26 -0
- data/templates/jquery/jquery.flashMessages.min.js +1 -0
- data/templates/jquery/jquery.form.js +803 -786
- data/templates/jquery/jquery.haml.js +248 -247
- data/templates/jquery/jquery.hotkeys.js +89 -89
- data/templates/jquery/jquery.js +8141 -8106
- data/templates/jquery/jquery.layout.js +2451 -2415
- data/templates/jquery/jquery.min.js +167 -166
- data/templates/jquery/jquery.mousewheel.js +62 -54
- data/templates/jquery/jquery.offline.js +171 -171
- data/templates/jquery/jquery.pngFix.js +76 -76
- data/templates/jquery/jquery.replacetext.js +83 -83
- data/templates/jquery/jquery.themeswitchertool.js +202 -177
- data/templates/jquery/jquery.tmpl.js +478 -473
- data/templates/jquery/jquery.tmplPlus.js +82 -81
- data/templates/jquery/jrails.js +178 -175
- data/templates/jquery/json.js +77 -7
- data/templates/jquery/json2.js +480 -0
- data/templates/jquery/json2.min.js +7 -0
- data/templates/jquery/lib/tasks/haml.rake +2 -2
- data/templates/jquery/manifest.rb +21 -17
- data/templates/jstree/jquery.jstree.js +5967 -4536
- data/templates/mobile/config/initializers/mobile.rb +1 -1
- data/templates/mobile/jquery/mobile/_base.scss +944 -927
- data/templates/mobile/jquery/mobile/default.scss +61 -48
- data/templates/mobile/jquery/mobile/valencia.scss +56 -42
- data/templates/mobile/jquery.mobile.js +4461 -4347
- data/templates/mobile/jquery.mobile.min.js +11 -2
- data/templates/mobile/lib/tasks/jquery.mobile.rake +12 -12
- data/templates/ribbon/config/initializers/ribbon.rb +2 -2
- data/templates/ribbon/jquery.ribbon.js +50 -29
- data/templates/secret_sauce/secret_sauce.js +8 -8
- data/templates/tools/flowplayer.js +945 -1
- data/templates/tools/jquery.tools.js +4645 -4335
- data/templates/tools/jquery.tools.min.js +37 -37
- data/templates/tools/lib/tasks/jquery.tools.rake +4 -4
- data/templates/tools/swfobject.js +813 -773
- metadata +33 -21
- data/templates/jquery/haml.js +0 -506
- data/templates/jquery/haml.min.js +0 -5
- data/templates/jquery/jquery/ui/contextMenu/door.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_copy.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_delete.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_edit.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_new.png +0 -0
- data/templates/jquery/jquery/ui/contextMenu/page_white_paste.png +0 -0
- data/templates/jquery/jquery.compat-1.3.js +0 -291
- data/templates/jquery/jquery.compat-1.3.min.js +0 -6
- data/templates/jquery/jquery.flash_messages.js +0 -5
- data/templates/jquery/jquery.flash_messages.min.js +0 -1
- data/templates/jquery/jquery.history.js +0 -194
- data/templates/jquery/jquery.history.min.js +0 -5
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
module Gridify
|
|
2
2
|
class GridColumn
|
|
3
|
-
|
|
4
|
-
attr_accessor :name,
|
|
3
|
+
|
|
4
|
+
attr_accessor :name, # attribute name (required)
|
|
5
5
|
:label,
|
|
6
|
-
:ar_column,
|
|
7
|
-
:value_type,
|
|
8
|
-
:key,
|
|
9
|
-
|
|
6
|
+
:ar_column, # active_record column
|
|
7
|
+
:value_type, # active_record data type :string, :text, :integer, :float, :boolean, + :currency
|
|
8
|
+
:key, # true if this is the key (only :id)
|
|
9
|
+
|
|
10
10
|
# column formatting
|
|
11
|
-
:width,
|
|
12
|
-
:fixed_width,
|
|
13
|
-
:formatter,
|
|
14
|
-
:format_options,
|
|
15
|
-
:align,
|
|
11
|
+
:width, # initial width (150)
|
|
12
|
+
:fixed_width, # true = not resized when recalc fit to width
|
|
13
|
+
:formatter, # see jqGrid doc (based on value_type)
|
|
14
|
+
:format_options, # hash, see jqGrid doc (based on value_type)
|
|
15
|
+
:align, # 'left', 'right', 'center' (left for strings, right for numerics)
|
|
16
16
|
#:classes, # optional classes to add to column
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
# column actions
|
|
19
|
-
:resizable,
|
|
20
|
-
:sortable,
|
|
21
|
-
:searchable,
|
|
19
|
+
:resizable, # t/f (true)
|
|
20
|
+
:sortable, # t/f (true) or jqGrid sorttype: :integer, :float, :currency, :date, :text (true)
|
|
21
|
+
:searchable, # true/false (true) or text or select
|
|
22
22
|
#:search_options,
|
|
23
|
-
:editable,
|
|
24
|
-
:edit_type,
|
|
25
|
-
:edit_options,
|
|
26
|
-
:validations,
|
|
27
|
-
|
|
28
|
-
:form_options,
|
|
23
|
+
:editable, # true/false (false),
|
|
24
|
+
:edit_type, # text, textarea, select, checkbox, password, button, image and file (based on value_type)
|
|
25
|
+
:edit_options, # html input field options, depends on editable type (eg {"size" => 10, "maxlength" => 15}) see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
|
|
26
|
+
:validations, # jqGrid editrules (TODO derive from AR model validations) see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
|
|
27
|
+
# "required" "integer" "email" "url" etc
|
|
28
|
+
:form_options, # jqGrid formoptions for formatting input forms
|
|
29
29
|
# select types
|
|
30
30
|
#:select_url, # url to dynamically get select options
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# visiblity
|
|
33
33
|
#:always_hidden, # (false)
|
|
34
34
|
:sort_type,
|
|
35
35
|
:summary_type,
|
|
36
36
|
:summary_tpl,
|
|
37
|
-
:hidden
|
|
38
|
-
|
|
37
|
+
:hidden # initial hide state (false)
|
|
38
|
+
|
|
39
39
|
def initialize(options)
|
|
40
40
|
update options
|
|
41
41
|
end
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
def update(options)
|
|
44
|
-
options.each {|atr, val| send(
|
|
44
|
+
options.each { |atr, val| send("#{atr}=", val) }
|
|
45
45
|
end
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
def to_json
|
|
48
48
|
properties.to_json #_with_js
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
def properties
|
|
52
52
|
jqgrid_properties
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
def resizable
|
|
56
56
|
if @resizable==false
|
|
57
57
|
false
|
|
@@ -60,7 +60,7 @@ module Gridify
|
|
|
60
60
|
true
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
def fixed_width
|
|
65
65
|
if @fixed_width==false
|
|
66
66
|
false
|
|
@@ -70,63 +70,69 @@ module Gridify
|
|
|
70
70
|
@fixed_width
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
# ----------------
|
|
75
75
|
private
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
def jqgrid_type
|
|
78
78
|
return sortable unless sortable==true
|
|
79
79
|
case value_type
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
when :string :
|
|
81
|
+
'text'
|
|
82
|
+
when :text :
|
|
83
|
+
'text'
|
|
84
|
+
when :integer :
|
|
85
|
+
'integer'
|
|
86
|
+
when :float :
|
|
87
|
+
'float'
|
|
88
|
+
when :boolean :
|
|
89
|
+
'boolean'
|
|
90
|
+
when :datetime :
|
|
91
|
+
'date'
|
|
86
92
|
end
|
|
87
93
|
end
|
|
88
|
-
|
|
94
|
+
|
|
89
95
|
# note, we dont vals[:foo] = foo because dont want to bother generating key if its same as jqGrid default
|
|
90
96
|
def jqgrid_properties
|
|
91
97
|
vals = {
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
:name => name.gsub(".", "__"),
|
|
99
|
+
:index => name
|
|
94
100
|
}
|
|
95
101
|
#xmlmap not required when same as :name
|
|
96
102
|
# vals[:xmlmap] = name if data_type == :xml
|
|
97
103
|
# vals[:jsonmap] = name if data_type == :json
|
|
98
|
-
|
|
99
|
-
vals[:label]
|
|
100
|
-
vals[:resizable]
|
|
101
|
-
vals[:fixed]
|
|
102
|
-
vals[:sortable]
|
|
103
|
-
vals[:sort_type]
|
|
104
|
-
vals[:search]
|
|
105
|
-
vals[:editable]
|
|
106
|
-
vals[:align]
|
|
104
|
+
|
|
105
|
+
vals[:label] = label || name.titleize
|
|
106
|
+
vals[:resizable] = false if resizable==false
|
|
107
|
+
vals[:fixed] = fixed_width unless fixed_width==false
|
|
108
|
+
vals[:sortable] = false if sortable==false
|
|
109
|
+
vals[:sort_type] = jqgrid_type if sortable
|
|
110
|
+
vals[:search] = false if searchable==false
|
|
111
|
+
vals[:editable] = true if editable
|
|
112
|
+
vals[:align] = align if align
|
|
107
113
|
#vals[:align] = 'right' if [:integer, :float, :currency].include?(value_type)
|
|
108
114
|
case value_type
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
when :datetime
|
|
116
|
+
vals[:formatter] = 'date'
|
|
117
|
+
vals[:formatoptions] = {:srcformat => 'UniversalSortableDateTime', :newformat => 'FullDateTime'}
|
|
112
118
|
end
|
|
113
|
-
vals[:hidden]
|
|
114
|
-
vals[:width]
|
|
115
|
-
vals[:formatter]
|
|
116
|
-
vals[:formatoptions]
|
|
117
|
-
vals[:edittype]
|
|
118
|
-
vals[:formoptions]
|
|
119
|
-
vals[:editoptions]
|
|
120
|
-
vals[:editrules]
|
|
121
|
-
|
|
122
|
-
vals[:sort_type]
|
|
123
|
-
vals[:summaryType]
|
|
124
|
-
vals[:summaryTpl]
|
|
119
|
+
vals[:hidden] = true if hidden
|
|
120
|
+
vals[:width] = width if width
|
|
121
|
+
vals[:formatter] = formatter if formatter
|
|
122
|
+
vals[:formatoptions] = format_options if format_options
|
|
123
|
+
vals[:edittype] = edit_type if editable && edit_type
|
|
124
|
+
vals[:formoptions] = form_options if editable && form_options
|
|
125
|
+
vals[:editoptions] = edit_options if editable && edit_options
|
|
126
|
+
vals[:editrules] = validations if editable && validations
|
|
127
|
+
|
|
128
|
+
vals[:sort_type] = sort_type if sort_type
|
|
129
|
+
vals[:summaryType] = summary_type if summary_type
|
|
130
|
+
vals[:summaryTpl] = summary_tpl if summary_tpl
|
|
125
131
|
# and more...
|
|
126
|
-
|
|
132
|
+
|
|
127
133
|
vals
|
|
128
134
|
end
|
|
129
|
-
|
|
135
|
+
|
|
130
136
|
end
|
|
131
137
|
end
|
|
132
138
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module Gridify
|
|
2
2
|
class Grid
|
|
3
3
|
|
|
4
|
-
attr_accessor :search_rules,
|
|
5
|
-
:search_rules_op
|
|
4
|
+
attr_accessor :search_rules, # current search/filter rules, as hash
|
|
5
|
+
:search_rules_op # :and, :or
|
|
6
6
|
|
|
7
7
|
# finds records based on request params
|
|
8
8
|
# e.g. params from jqGrid
|
|
@@ -13,19 +13,19 @@ module Gridify
|
|
|
13
13
|
# :rows number of items to get ["20"]
|
|
14
14
|
# :page page number (starts at 1) ["1"]
|
|
15
15
|
|
|
16
|
-
def update_from_params(
|
|
16
|
+
def update_from_params(params)
|
|
17
17
|
params.symbolize_keys!
|
|
18
18
|
params_to_rules params
|
|
19
|
-
self.data_type
|
|
20
|
-
self.sort_by
|
|
21
|
-
self.sort_order
|
|
22
|
-
self.current_page
|
|
19
|
+
self.data_type = params[:datatype] if params[:datatype]
|
|
20
|
+
self.sort_by = params[:sidx] if params[:sidx]
|
|
21
|
+
self.sort_order = params[:sord] if params[:sord]
|
|
22
|
+
self.current_page = params[:page].to_i if params[:page]
|
|
23
23
|
self.rows_per_page = params[:rows].to_i if params[:rows]
|
|
24
|
-
self.total_rows
|
|
24
|
+
self.total_rows = params[:total_rows].to_i if params[:total_rows]
|
|
25
25
|
if tree_grid
|
|
26
|
-
self.nodeid
|
|
26
|
+
self.nodeid = params[:nodeid].to_i if params[:nodeid]
|
|
27
27
|
self.n_level = params[:n_level].to_i if params[:n_level]
|
|
28
|
-
self.n_left
|
|
28
|
+
self.n_left = params[:n_left].to_i if params[:n_left]
|
|
29
29
|
self.n_right = params[:n_right].to_i if params[:n_right]
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -49,7 +49,7 @@ module Gridify
|
|
|
49
49
|
find_args[:order] = "upper(#{sort_by}) #{sort_order}"
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
if total_rows.present? && total_rows > 0
|
|
54
54
|
find_args[:limit] = total_rows
|
|
55
55
|
offset = (current_page.to_i-1) * rows_per_page if current_page.present?
|
|
@@ -59,123 +59,123 @@ module Gridify
|
|
|
59
59
|
offset = (current_page.to_i-1) * rows_per_page if current_page.present?
|
|
60
60
|
find_args[:offset] = offset if offset && offset > 0
|
|
61
61
|
end
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
cond = rules_to_conditions
|
|
64
64
|
find_args[:conditions] = cond unless cond.blank?
|
|
65
65
|
find_args
|
|
66
66
|
end
|
|
67
|
-
|
|
68
|
-
def find(
|
|
67
|
+
|
|
68
|
+
def find(params)
|
|
69
69
|
#debugger
|
|
70
70
|
update_from_params params
|
|
71
71
|
klass = resource.classify.constantize
|
|
72
|
-
records = klass.send(
|
|
72
|
+
records = klass.send(finder, :all, current_scope)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def encode_records(
|
|
75
|
+
def encode_records(records, userdata=nil, total_count=nil)
|
|
76
76
|
#debugger
|
|
77
77
|
klass = resource.classify.constantize
|
|
78
78
|
total_count ||= klass.count
|
|
79
79
|
total_pages = total_count / rows_per_page + 1
|
|
80
80
|
#TODO: :only => [attributes], :methods => [virtual attributes]
|
|
81
81
|
case data_type
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
when :xml
|
|
83
|
+
if colInclude
|
|
84
|
+
xml = records.to_xml(:include => colInclude, :skip_types => true, :dasherize => false) do |xml|
|
|
85
|
+
if rows_per_page > 0
|
|
86
|
+
xml.page current_page
|
|
87
|
+
xml.total total_pages
|
|
88
|
+
xml.records total_count
|
|
89
|
+
end
|
|
89
90
|
end
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
else
|
|
92
|
+
xml = records.to_xml(:skip_types => true, :dasherize => false) do |xml|
|
|
93
|
+
if rows_per_page > 0
|
|
94
|
+
xml.page current_page
|
|
95
|
+
xml.total total_pages
|
|
96
|
+
xml.records total_count
|
|
97
|
+
end
|
|
97
98
|
end
|
|
98
99
|
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
records.to_s
|
|
100
|
+
when :json
|
|
101
|
+
#debugger
|
|
102
|
+
data = {resource => records}
|
|
103
|
+
if rows_per_page > 0
|
|
104
|
+
data.merge!(
|
|
105
|
+
:page => current_page,
|
|
106
|
+
:total => total_pages,
|
|
107
|
+
:records => total_count
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
data.merge!(:userdata => userdata) if userdata
|
|
111
|
+
save = ActiveRecord::Base.include_root_in_json
|
|
112
|
+
ActiveRecord::Base.include_root_in_json = false
|
|
113
|
+
if colInclude
|
|
114
|
+
json = build_json(data);
|
|
115
|
+
else
|
|
116
|
+
json = data.to_json
|
|
117
|
+
end
|
|
118
|
+
ActiveRecord::Base.include_root_in_json = save
|
|
119
|
+
json
|
|
120
|
+
#others...
|
|
121
|
+
else #nop ?
|
|
122
|
+
records.to_s
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
def find_and_encode(
|
|
127
|
-
encode_records(
|
|
126
|
+
def find_and_encode(params)
|
|
127
|
+
encode_records(find(params))
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
# grid doesnt nest attributes inside the resource
|
|
131
131
|
# could change this behavior in jqGrid, see grid.postext.js ?
|
|
132
132
|
# http://www.trirand.com/jqgridwiki/doku.php?id=wiki:post_data_module
|
|
133
133
|
#
|
|
134
|
-
def member_params(
|
|
135
|
-
params.inject({}) {|h, (name, value)| h[name] = value if columns_hash[name]; h }
|
|
134
|
+
def member_params(params)
|
|
135
|
+
params.inject({}) { |h, (name, value)| h[name] = value if columns_hash[name]; h }
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
protected
|
|
139
139
|
|
|
140
|
-
OPS = {
|
|
140
|
+
OPS = {'eq' => '=', 'lt' => '<', 'le' => '<=', 'gt' => '>', 'ge' => '>=', 'ne' => '!='}
|
|
141
141
|
#['eq','ne','lt','le','gt','ge',
|
|
142
142
|
# 'bw','bn','in','ni','ew','en','cn','nc']
|
|
143
143
|
#['equal','not equal', 'less', 'less or equal','greater','greater or equal',
|
|
144
144
|
# 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain']
|
|
145
145
|
|
|
146
146
|
OPS_PATTERN = {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
'bw' => '?%',
|
|
148
|
+
'bn' => '?%',
|
|
149
|
+
# 'in'
|
|
150
|
+
# 'ni'
|
|
151
|
+
'ew' => '%?',
|
|
152
|
+
'en' => '%?',
|
|
153
|
+
'cn' => '%?%',
|
|
154
|
+
'nc' => '%?%',
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
STRING_OPS = {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
'bw' => 'LIKE',
|
|
159
|
+
'bn' => 'NOT LIKE',
|
|
160
|
+
'ew' => 'LIKE',
|
|
161
|
+
'en' => 'NOT LIKE',
|
|
162
|
+
'cn' => 'LIKE',
|
|
163
|
+
'nc' => 'NOT LIKE',
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
# params[:filters] => {"groupOp"=>"AND",
|
|
167
167
|
# "rules"=>[{"data"=>"b", "op"=>"ge", "field"=>"title"}, {"data"=>"f", "op"=>"le", "field"=>"title"}] }
|
|
168
|
-
def params_to_rules(
|
|
168
|
+
def params_to_rules(params)
|
|
169
169
|
#debugger
|
|
170
170
|
if params[:_search]=='true' || params[:_search]==true
|
|
171
171
|
if params[:filters]
|
|
172
172
|
# advanced search
|
|
173
|
-
filters = ActiveSupport::JSON.decode(
|
|
173
|
+
filters = ActiveSupport::JSON.decode(params[:filters])
|
|
174
174
|
self.search_rules = filters['rules']
|
|
175
175
|
self.search_rules_op = filters['groupOp']
|
|
176
176
|
elsif params[:searchField]
|
|
177
177
|
# simple search
|
|
178
|
-
self.search_rules = [{
|
|
178
|
+
self.search_rules = [{"field" => params[:searchField], "op" => params[:searchOper], "data" => params[:searchString]}]
|
|
179
179
|
else
|
|
180
180
|
# toolbar search
|
|
181
181
|
self.search_rules = []
|
|
@@ -183,7 +183,7 @@ module Gridify
|
|
|
183
183
|
colModel.each do |col|
|
|
184
184
|
name = col.name
|
|
185
185
|
data = params[name.to_sym]
|
|
186
|
-
self.search_rules << {
|
|
186
|
+
self.search_rules << {"field" => name, "op" => "cn", "data" => data} if data
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
end
|
|
@@ -213,9 +213,9 @@ module Gridify
|
|
|
213
213
|
vals << OPS_PATTERN[rule['op']].gsub('?', rule['data'])
|
|
214
214
|
end
|
|
215
215
|
end
|
|
216
|
-
cond = [
|
|
216
|
+
cond = [expr] + vals
|
|
217
217
|
end
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
def build_json(data)
|
|
220
220
|
raw_data = JSON.parse(data.to_json(:include => colInclude))
|
|
221
221
|
raw_data[resource].each do |row|
|