optimacms 0.1.15 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/optimacms/admin/pages_controller.rb +93 -81
- data/app/controllers/optimacms/admin/templates_controller.rb +22 -4
- data/app/controllers/optimacms/application_controller.rb +2 -1
- data/app/helpers/optimacms/application_helper.rb +3 -2
- data/app/helpers/optimacms/forms_helper.rb +52 -6
- data/app/models/optimacms/page.rb +16 -9
- data/app/models/optimacms/template.rb +11 -31
- data/app/views/optimacms/admin/pages/index.html.haml +15 -3
- data/app/views/optimacms/admin/templates/index.html.haml +6 -2
- data/config/initializers/simple_form_simple_search_boostrap.rb +6 -0
- data/lib/optimacms/engine.rb +2 -0
- data/lib/optimacms/filters/form_filter.rb +5 -2
- data/lib/optimacms/mycontroller.rb +29 -29
- data/lib/optimacms/version.rb +1 -1
- data/test/dummy/app/controllers/application_controller.rb +13 -0
- data/test/dummy/app/views/pages/about.html.erb +6 -1
- data/test/dummy/config/routes.rb +3 -2
- data/test/dummy/log/development.log +877 -189112
- data/test/dummy/tmp/cache/assets/development/sass/7f871ea7e3a8127767d5a5868622ef2909611f26/noskin.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/admin.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/admin_tpl.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_and_overrides.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_custom.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_variables.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/colors.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/tinymce.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/tpl.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/053f826d1ea01a2fac355de0755e5c40 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0a470277dd21c166b9dfb68b03d34d5c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3240ef40c1dc9d13156bbd790ec2651a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/529a74a4530de52f6c3ebbf107ffe9f2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/56c7eb172a7423728c45d0a751d198e3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6cdbd6f171a27a578bcb07dd5bfa83a2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6f943f22c610e6417422e4a13e0bcc0d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8956737a82f17db48d50e13f133aeefc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8b5a7992567ebbeb9a882d074778f8c8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/97c1e12a09973e0fb97f23a1dc496443 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/99e8d6370ba85ec4a61d953f5ed261af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a64dbcf0e4afe0985b1abd3e209d17cd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a6d357fbe03dae6f590180f6c5e0e148 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/aa58fb159780a7200a1bc4c6844cc5c4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ba9859d0d2b7d4d7d5b03ff3a71ed478 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e3dd086dd858b5bff9cfd60a031c2091 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ec33505f0e2ed4dd12951ecceffa3695 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -1
- metadata +69 -7
- data/app/views/tableview/_buttons_apply_clear.html.haml +0 -2
- data/app/views/tableview/_filter.html.haml +0 -0
- data/app/views/tableview/_filter_field.html.haml +0 -15
- data/app/views/tableview/_filter_fields.html.haml +0 -3
- data/lib/simple_filter/filter.rb +0 -223
data/lib/simple_filter/filter.rb
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
module SimpleFilter
|
2
|
-
class Filter
|
3
|
-
|
4
|
-
FIELD_TYPE_TEXT = 'text'
|
5
|
-
FIELD_TYPE_HIDDEN = 'hidden'
|
6
|
-
FIELD_TYPE_SELECT_AUTO = 'select_auto' # text with autocomplete
|
7
|
-
|
8
|
-
DBTYPE_STRING = 'string'
|
9
|
-
DBTYPE_INT = 'int'
|
10
|
-
DBTYPE_DATE = 'date'
|
11
|
-
|
12
|
-
#
|
13
|
-
attr_accessor :prefix # session prefix
|
14
|
-
attr_accessor :fields
|
15
|
-
attr_accessor :data
|
16
|
-
#attr_accessor :order # [ ["order_column", "asc|desc"], ..]
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def initialize(_session, _prefix)
|
21
|
-
@prefix = _prefix
|
22
|
-
@session = _session
|
23
|
-
|
24
|
-
@fields ||={}
|
25
|
-
|
26
|
-
# init data
|
27
|
-
data()
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
############
|
32
|
-
# fields
|
33
|
-
############
|
34
|
-
|
35
|
-
def add_field(f)
|
36
|
-
@fields[f[:name]] = f
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def add_fields_from_array(a)
|
41
|
-
a.each do |fa|
|
42
|
-
add_field fa
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
def field_def_value(name)
|
49
|
-
if (@fields.has_key? name) && (@fields[name].has_key? :def)
|
50
|
-
return @fields[name][:def]
|
51
|
-
end
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
|
55
|
-
############
|
56
|
-
# sessions
|
57
|
-
############
|
58
|
-
|
59
|
-
def session_get(name, def_value)
|
60
|
-
@session[prefix+name] || def_value
|
61
|
-
end
|
62
|
-
|
63
|
-
def session_save(name, v)
|
64
|
-
@session[prefix+name] = v
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
############
|
69
|
-
# data
|
70
|
-
############
|
71
|
-
|
72
|
-
|
73
|
-
def data
|
74
|
-
return @data unless @data.nil?
|
75
|
-
|
76
|
-
# from session
|
77
|
-
@data_sess = session_get 'data', nil
|
78
|
-
unless @data_sess.nil?
|
79
|
-
@data = @data_sess
|
80
|
-
else
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
@data ||= {}
|
86
|
-
|
87
|
-
session_save('data', @data)
|
88
|
-
|
89
|
-
#
|
90
|
-
@data
|
91
|
-
end
|
92
|
-
|
93
|
-
def v(name, v_def=nil)
|
94
|
-
if (data.has_key? name) && (!data[name].nil?)
|
95
|
-
return data[name]
|
96
|
-
end
|
97
|
-
|
98
|
-
field_def_value(name) || v_def
|
99
|
-
end
|
100
|
-
|
101
|
-
def v_empty?(name)
|
102
|
-
if (data.has_key? name) && (!data[name].nil?)
|
103
|
-
return true
|
104
|
-
end
|
105
|
-
|
106
|
-
# if v == default value
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
def set(field_name,v)
|
111
|
-
data[field_name] = v
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
def clear_data
|
116
|
-
session_save 'data', {}
|
117
|
-
end
|
118
|
-
|
119
|
-
def set_data_from_form(params)
|
120
|
-
# search for fields like filter[XXX]
|
121
|
-
params.each do |name, v|
|
122
|
-
#if f =~ /^filter\[([^\]]+)\]$/
|
123
|
-
#name = Regexp.last_match(1)
|
124
|
-
|
125
|
-
next unless @fields.has_key? name
|
126
|
-
|
127
|
-
if @fields[name][:dbtype]==DBTYPE_INT
|
128
|
-
data[name] = (v.to_i rescue 0)
|
129
|
-
else
|
130
|
-
data[name] = v
|
131
|
-
end
|
132
|
-
|
133
|
-
#end
|
134
|
-
end
|
135
|
-
|
136
|
-
# default values from fields
|
137
|
-
@fields.each do |name, f|
|
138
|
-
next if @data.has_key? name
|
139
|
-
|
140
|
-
@data[name] = field_def_value name
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
####
|
148
|
-
# order
|
149
|
-
####
|
150
|
-
|
151
|
-
def order
|
152
|
-
return @order unless @order.nil?
|
153
|
-
|
154
|
-
# from session
|
155
|
-
@v_sess = session_get 'order', nil
|
156
|
-
@order = @v_sess unless @v_sess.nil?
|
157
|
-
|
158
|
-
#
|
159
|
-
@order ||= []
|
160
|
-
|
161
|
-
session_save 'order', @order
|
162
|
-
|
163
|
-
#
|
164
|
-
@order
|
165
|
-
end
|
166
|
-
|
167
|
-
def order= (value)
|
168
|
-
@order = value
|
169
|
-
|
170
|
-
session_save 'order', @order
|
171
|
-
end
|
172
|
-
|
173
|
-
def set_order_default(order_by, order_dir)
|
174
|
-
return false if !order.nil? && !order.empty?
|
175
|
-
|
176
|
-
set_order(order_by, order_dir)
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
def set_order(order_by, order_dir)
|
182
|
-
self.order = [[order_by, order_dir]]
|
183
|
-
end
|
184
|
-
|
185
|
-
def get_order
|
186
|
-
order[0] if order.count>0
|
187
|
-
order[0]
|
188
|
-
end
|
189
|
-
|
190
|
-
|
191
|
-
def get_opposite_order_dir_for_column(name)
|
192
|
-
return 'asc' if order.empty?
|
193
|
-
|
194
|
-
|
195
|
-
if order[0][0] == name
|
196
|
-
return opposite_order_dir(order[0][1])
|
197
|
-
end
|
198
|
-
|
199
|
-
return 'asc'
|
200
|
-
end
|
201
|
-
|
202
|
-
def opposite_order_dir(order_dir)
|
203
|
-
return 'asc' if order_dir=='desc'
|
204
|
-
return 'desc' if order_dir=='asc'
|
205
|
-
'asc'
|
206
|
-
end
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
#helper methods
|
211
|
-
|
212
|
-
def html_style(name)
|
213
|
-
return '' unless @fields[name].has_key?(:opt)
|
214
|
-
|
215
|
-
s = ''
|
216
|
-
opt = @fields[name][:opt]
|
217
|
-
unless opt[:width].nil?
|
218
|
-
s << "width: #{opt[:width]}px; "
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|