optimacms 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5c71915c85fc8f8b2c3b927bc7fc5b7c44f91ac
4
- data.tar.gz: 2ff1155e854f1b56f6407ec212bcf585c8128a6b
3
+ metadata.gz: 7423961f90b9cefc9804eba62c7a24a34ab07cb5
4
+ data.tar.gz: c5db0f9c93e7397db548504094fbd9d038a7c1a7
5
5
  SHA512:
6
- metadata.gz: 86d108c522d1c97bd753052ae6e9988e17285d7f286385647dc233647e2a5ca6bbd15750252468647a32f572b831ce48ee4f0dc3c91b82406ef47402c33bd758
7
- data.tar.gz: e3af7c37bd671c11116fe67c6b7e4abdf0c87dfa83c2e1c7ac2f154f02e415ce76b572b263e5244b36772fc5e6402427c4a220c373d2e97a802307c090a531c3
6
+ metadata.gz: ae063cca5a45779f75f469eb98c16fa9f443261b066c7797b8c588b7bc128ebda303d4006cc2f5a1c4b5e70d96f0fc68d3e3ab744250b56498f864eec260b184
7
+ data.tar.gz: 5b36846f5bd8ba734bd139184291708f0dda10bb16200a9eb41092ef379597a876a413d49ca22dbde5e62c7a57b83682780d971dbbb5e92230be2001583eed98
@@ -138,7 +138,7 @@ module Optimacms
138
138
 
139
139
 
140
140
  # filter
141
- include SimpleFilters::Controller
141
+ #include SimpleFilters::Controller
142
142
 
143
143
 
144
144
  def init_tabledata
@@ -1,10 +1,12 @@
1
1
  module Optimacms
2
2
  module ApplicationHelper
3
3
 
4
+ include ActionView::Helpers::ApplicationHelper
5
+
4
6
  def method_missing(method, *args, &block)
5
- main_app.send(method, *args, &block)
6
- rescue NoMethodError
7
- super
7
+ main_app.send(method, *args, &block)
8
+ rescue NoMethodError
9
+ super
8
10
  end
9
11
 
10
12
  def tinymce_editor_insert_block
@@ -15,7 +15,7 @@
15
15
 
16
16
  = f.input :controller_action, as: :string, label: "Controller", :hint=>'controller#action. ex.: news#index'
17
17
 
18
- = f.association :layout, label: "Layout", collection: @layouts
18
+ = f.association :layout, label: "Layout", collection: @layouts, label_method: :title
19
19
 
20
20
  .form-group.page_template
21
21
  %label(for="inputTemplate" class="col-sm-2 col-md-1 control-label")
@@ -0,0 +1,224 @@
1
+ module Optimacms
2
+ module Filters
3
+ class FormFilter
4
+
5
+ FIELD_TYPE_TEXT = 'text'
6
+ FIELD_TYPE_HIDDEN = 'hidden'
7
+ FIELD_TYPE_SELECT_AUTO = 'select_auto' # text with autocomplete
8
+
9
+ DBTYPE_STRING = 'string'
10
+ DBTYPE_INT = 'int'
11
+ DBTYPE_DATE = 'date'
12
+
13
+ #
14
+ attr_accessor :prefix # session prefix
15
+ attr_accessor :fields
16
+ attr_accessor :data
17
+ #attr_accessor :order # [ ["order_column", "asc|desc"], ..]
18
+
19
+
20
+
21
+ def initialize(_session, _prefix)
22
+ @prefix = _prefix
23
+ @session = _session
24
+
25
+ @fields ||={}
26
+
27
+ # init data
28
+ data()
29
+ end
30
+
31
+
32
+ ############
33
+ # fields
34
+ ############
35
+
36
+ def add_field(f)
37
+ @fields[f[:name]] = f
38
+
39
+ end
40
+
41
+ def add_fields_from_array(a)
42
+ a.each do |fa|
43
+ add_field fa
44
+ end
45
+
46
+ end
47
+
48
+
49
+ def field_def_value(name)
50
+ if (@fields.has_key? name) && (@fields[name].has_key? :def)
51
+ return @fields[name][:def]
52
+ end
53
+ nil
54
+ end
55
+
56
+ ############
57
+ # sessions
58
+ ############
59
+
60
+ def session_get(name, def_value)
61
+ @session[prefix+name] || def_value
62
+ end
63
+
64
+ def session_save(name, v)
65
+ @session[prefix+name] = v
66
+ end
67
+
68
+
69
+ ############
70
+ # data
71
+ ############
72
+
73
+
74
+ def data
75
+ return @data unless @data.nil?
76
+
77
+ # from session
78
+ @data_sess = session_get 'data', nil
79
+ unless @data_sess.nil?
80
+ @data = @data_sess
81
+ else
82
+
83
+ end
84
+
85
+ #
86
+ @data ||= {}
87
+
88
+ session_save('data', @data)
89
+
90
+ #
91
+ @data
92
+ end
93
+
94
+ def v(name, v_def=nil)
95
+ if (data.has_key? name) && (!data[name].nil?)
96
+ return data[name]
97
+ end
98
+
99
+ field_def_value(name) || v_def
100
+ end
101
+
102
+ def v_empty?(name)
103
+ if (data.has_key? name) && (!data[name].nil?)
104
+ return true
105
+ end
106
+
107
+ # if v == default value
108
+
109
+ end
110
+
111
+ def set(field_name,v)
112
+ data[field_name] = v
113
+ end
114
+
115
+
116
+ def clear_data
117
+ session_save 'data', {}
118
+ end
119
+
120
+ def set_data_from_form(params)
121
+ # search for fields like filter[XXX]
122
+ params.each do |name, v|
123
+ #if f =~ /^filter\[([^\]]+)\]$/
124
+ #name = Regexp.last_match(1)
125
+
126
+ next unless @fields.has_key? name
127
+
128
+ if @fields[name][:dbtype]==DBTYPE_INT
129
+ data[name] = (v.to_i rescue 0)
130
+ else
131
+ data[name] = v
132
+ end
133
+
134
+ #end
135
+ end
136
+
137
+ # default values from fields
138
+ @fields.each do |name, f|
139
+ next if @data.has_key? name
140
+
141
+ @data[name] = field_def_value name
142
+ end
143
+
144
+ end
145
+
146
+
147
+
148
+ ####
149
+ # order
150
+ ####
151
+
152
+ def order
153
+ return @order unless @order.nil?
154
+
155
+ # from session
156
+ @v_sess = session_get 'order', nil
157
+ @order = @v_sess unless @v_sess.nil?
158
+
159
+ #
160
+ @order ||= []
161
+
162
+ session_save 'order', @order
163
+
164
+ #
165
+ @order
166
+ end
167
+
168
+ def order= (value)
169
+ @order = value
170
+
171
+ session_save 'order', @order
172
+ end
173
+
174
+ def set_order_default(order_by, order_dir)
175
+ return false if !order.nil? && !order.empty?
176
+
177
+ set_order(order_by, order_dir)
178
+
179
+ end
180
+
181
+
182
+ def set_order(order_by, order_dir)
183
+ self.order = [[order_by, order_dir]]
184
+ end
185
+
186
+ def get_order
187
+ order[0] if order.count>0
188
+ order[0]
189
+ end
190
+
191
+
192
+ def get_opposite_order_dir_for_column(name)
193
+ return 'asc' if order.empty?
194
+
195
+
196
+ if order[0][0] == name
197
+ return opposite_order_dir(order[0][1])
198
+ end
199
+
200
+ return 'asc'
201
+ end
202
+
203
+ def opposite_order_dir(order_dir)
204
+ return 'asc' if order_dir=='desc'
205
+ return 'desc' if order_dir=='asc'
206
+ 'asc'
207
+ end
208
+
209
+
210
+
211
+ #helper methods
212
+
213
+ def html_style(name)
214
+ return '' unless @fields[name].has_key?(:opt)
215
+
216
+ s = ''
217
+ opt = @fields[name][:opt]
218
+ unless opt[:width].nil?
219
+ s << "width: #{opt[:width]}px; "
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
@@ -1,3 +1,3 @@
1
1
  module Optimacms
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -1,2 +1,3 @@
1
1
  module ApplicationHelper
2
+ include FontAwesome::Rails::IconHelper
2
3
  end
@@ -2,4 +2,4 @@ Hello - this is APP
2
2
 
3
3
  home
4
4
 
5
- =home_path
5
+ =fa_icon 'folder-o'
@@ -1,3 +1,7 @@
1
1
  1
2
2
  2
3
- 3
3
+ 3
4
+ About
5
+ <%=fa_icon "folder-o" %>
6
+
7
+ 111