drg_cms 0.6.0.8 → 0.6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +100 -58
- data/app/assets/stylesheets/drg_cms/drg_cms.css +177 -43
- data/app/controllers/cmsedit_controller.rb +149 -145
- data/app/controllers/dc_application_controller.rb +235 -113
- data/app/controllers/dc_common_controller.rb +32 -3
- data/app/controls/dc_help_control.rb +126 -0
- data/app/controls/dc_report.rb +5 -7
- data/app/forms/all_options.yml +10 -4
- data/app/forms/cms_menu.yml +7 -1
- data/app/forms/dc_category.yml +2 -1
- data/app/forms/dc_design.yml +1 -0
- data/app/forms/dc_help_1.yml +109 -0
- data/app/forms/dc_journal.yml +3 -1
- data/app/forms/dc_link.yml +1 -1
- data/app/forms/dc_menu.yml +2 -0
- data/app/forms/dc_menu_item.yml +1 -0
- data/app/forms/dc_page.yml +2 -0
- data/app/forms/dc_part.yml +1 -0
- data/app/forms/dc_piece.yml +1 -0
- data/app/forms/dc_poll.yml +3 -0
- data/app/forms/dc_simple_menu.yml +2 -0
- data/app/forms/dc_site.yml +2 -6
- data/app/forms/dc_user.yml +27 -11
- data/app/forms/dc_user_role.yml +3 -0
- data/app/helpers/cms_common_helper.rb +69 -4
- data/app/helpers/cms_edit_helper.rb +32 -24
- data/app/helpers/cms_helper.rb +64 -26
- data/app/helpers/cms_index_helper.rb +84 -72
- data/app/helpers/dc_application_helper.rb +33 -24
- data/app/models/concerns/dc_page_concern.rb +11 -2
- data/app/models/concerns/dc_policy_rule_concern.rb +20 -8
- data/app/models/concerns/dc_site_concern.rb +56 -44
- data/app/models/concerns/dc_user_concern.rb +57 -18
- data/app/models/dc_design.rb +29 -19
- data/app/models/dc_key_value_store.rb +1 -0
- data/app/models/dc_permission.rb +19 -9
- data/app/models/dc_policy.rb +25 -14
- data/app/models/dc_policy_role.rb +22 -11
- data/app/models/dc_temp.rb +1 -1
- data/app/models/dc_user_role.rb +2 -2
- data/app/models/drgcms_form_fields/embedded.rb +5 -8
- data/app/models/drgcms_form_fields/file_field.rb +1 -1
- data/app/models/drgcms_form_fields/file_select.rb +2 -2
- data/app/models/drgcms_form_fields/hash_field.rb +11 -7
- data/app/models/drgcms_form_fields/link_to.rb +2 -2
- data/app/models/drgcms_form_fields/method.rb +5 -4
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +1 -1
- data/app/models/drgcms_form_fields/select.rb +10 -9
- data/app/models/drgcms_form_fields/text_autocomplete.rb +2 -2
- data/app/views/cmsedit/edit.html.erb +2 -0
- data/app/views/cmsedit/index.html.erb +2 -1
- data/app/views/cmsedit/new.html.erb +2 -0
- data/app/views/dc_common/_help.html.erb +8 -0
- data/app/views/layouts/models.html.erb +2 -1
- data/config/locales/drgcms_en.yml +12 -0
- data/config/locales/drgcms_sl.yml +15 -0
- data/config/locales/models_en.yml +5 -5
- data/config/locales/models_sl.yml +7 -6
- data/lib/drg_cms.rb +58 -0
- data/lib/drg_cms/version.rb +1 -1
- metadata +5 -3
- data/app/models/__dc_dummy.rb +0 -102
data/app/helpers/cms_helper.rb
CHANGED
@@ -46,7 +46,7 @@ end
|
|
46
46
|
# Field definition will be used for input field on the form.
|
47
47
|
############################################################################
|
48
48
|
def dc_get_field_form_definition(name) #:nodoc:
|
49
|
-
return
|
49
|
+
return if @form['form'].nil?
|
50
50
|
|
51
51
|
@form['form']['tabs'].each do |tab|
|
52
52
|
# Array with 2 elements. First is tabname, second is data
|
@@ -67,26 +67,14 @@ end
|
|
67
67
|
# Parameters:
|
68
68
|
# options : Hash : Field definition
|
69
69
|
#
|
70
|
-
# Returns:
|
70
|
+
# Returns: Array[3]
|
71
71
|
# field_html : String : HTML code for field definition
|
72
72
|
# label : String : Label text
|
73
73
|
# help : String : Help text
|
74
74
|
############################################################################
|
75
75
|
def dc_field_label_help(options)
|
76
|
-
|
77
|
-
|
78
|
-
label = options['caption'] || options['text'] || options['label']
|
79
|
-
label = if label.blank?
|
80
|
-
t_name(options['name'], options['name'].capitalize.gsub('_',' ') )
|
81
|
-
elsif options['name']
|
82
|
-
t(label, label)
|
83
|
-
end
|
84
|
-
# help text can be defined in form or in translations starting with helpers. or as helpers.help.collection.field
|
85
|
-
help = options['help']
|
86
|
-
help ||= "helpers.help.#{@form['table']}.#{options['name']}" if options['name']
|
87
|
-
help = t(help, ' ') if help.to_s.match(/helpers\./)
|
88
|
-
end
|
89
|
-
# create field object from type option and call its render method
|
76
|
+
label, help = dc_label_help(options)
|
77
|
+
# create field object from type and call its render method
|
90
78
|
if options['type'].present?
|
91
79
|
klass_string = options['type'].camelize
|
92
80
|
field_html = if DrgcmsFormFields.const_defined?(klass_string) # when field type defined
|
@@ -101,10 +89,57 @@ def dc_field_label_help(options)
|
|
101
89
|
else
|
102
90
|
"Error: Field type missing!"
|
103
91
|
end
|
104
|
-
|
105
92
|
[field_html, label, help]
|
106
93
|
end
|
107
94
|
|
95
|
+
############################################################################
|
96
|
+
# Return label and help text for a field defined on Form.
|
97
|
+
#
|
98
|
+
# Parameters:
|
99
|
+
# options : Hash : Field definition
|
100
|
+
#
|
101
|
+
# Returns:
|
102
|
+
# label : String : Label text
|
103
|
+
# help : String : Help text
|
104
|
+
############################################################################
|
105
|
+
def dc_label_help(options)
|
106
|
+
# no label or help in comments
|
107
|
+
return [nil, nil] if %w(comment action).include?(options['type'])
|
108
|
+
|
109
|
+
label = options['caption'] || options['text'] || options['label']
|
110
|
+
label = if label.blank?
|
111
|
+
t_name(options['name'], options['name'].capitalize.gsub('_',' ') )
|
112
|
+
elsif options['name']
|
113
|
+
t(label, label)
|
114
|
+
end
|
115
|
+
# help text can be defined in form or in translations starting with helpers. or as helpers.help.collection.field
|
116
|
+
help = options['help']
|
117
|
+
help ||= "helpers.help.#{@form['table']}.#{options['name']}" if options['name']
|
118
|
+
help = t(help, ' ') if help.to_s.match(/helpers\./)
|
119
|
+
[label, help]
|
120
|
+
end
|
121
|
+
|
122
|
+
############################################################################
|
123
|
+
# Return label and help for tab on Form.
|
124
|
+
#
|
125
|
+
# Parameters:
|
126
|
+
# options : String : Tab name on form
|
127
|
+
#
|
128
|
+
# Returns:
|
129
|
+
# label : String : Label text
|
130
|
+
# help : String : Help text
|
131
|
+
############################################################################
|
132
|
+
def dc_tab_label_help(tab_name)
|
133
|
+
label = @form['form']['tabs'][tab_name]['caption'] || tab_name
|
134
|
+
label = t(label, t_name(label, label))
|
135
|
+
|
136
|
+
help = @form['form']['tabs'][tab_name]['help'] || "helpers.help.#{@form['table']}.#{tab_name}"
|
137
|
+
help = t(help, t_name(help, help))
|
138
|
+
help = nil if help.match('helpers.') # help not found in translation
|
139
|
+
|
140
|
+
[label, help]
|
141
|
+
end
|
142
|
+
|
108
143
|
############################################################################
|
109
144
|
# Creates code for including data entry field in index actions.
|
110
145
|
############################################################################
|
@@ -149,7 +184,8 @@ end
|
|
149
184
|
############################################################################
|
150
185
|
def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
|
151
186
|
parms = {}
|
152
|
-
caption = yaml['caption']
|
187
|
+
caption = yaml['caption'] || yaml['text']
|
188
|
+
caption = caption ? t("#{caption.downcase}", caption) : nil
|
153
189
|
icon = yaml['icon'] ? "#{fa_icon(yaml['icon'])}" : ''
|
154
190
|
# action is not active
|
155
191
|
unless dc_is_action_active?(yaml)
|
@@ -158,14 +194,14 @@ def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
|
|
158
194
|
# set data-confirm when confirm
|
159
195
|
yaml['html'] ||= {}
|
160
196
|
confirm = yaml['html']['data-confirm'] || yaml['confirm']
|
161
|
-
yaml['html']['data-confirm'] = t(confirm)
|
197
|
+
yaml['html']['data-confirm'] = t(confirm) if confirm.present?
|
162
198
|
yaml['html']['title'] ||= yaml['title']
|
163
|
-
yaml['html']['title'] = t(yaml['title'])
|
199
|
+
yaml['html']['title'] = t(yaml['title']) if yaml['title'].present?
|
164
200
|
yaml['html']['target'] ||= yaml['target']
|
165
201
|
# direct url
|
166
202
|
if yaml['url']
|
167
|
-
parms['
|
168
|
-
parms['idr']
|
203
|
+
parms['url'] = yaml['url']
|
204
|
+
parms['idr'] = dc_document_path(record) if record
|
169
205
|
# make url from action controller
|
170
206
|
else
|
171
207
|
parms['controller'] = yaml['controller'] || 'cmsedit'
|
@@ -178,16 +214,18 @@ def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
|
|
178
214
|
# add current id to parameters
|
179
215
|
parms['id'] = dc_document_path(record) if record
|
180
216
|
# overwrite with or add additional parameters from environment or record
|
181
|
-
yaml['params'].each { |k,v| parms[k] = dc_value_for_parameter(v) } if yaml['params']
|
217
|
+
yaml['params'].each { |k, v| parms[k] = dc_value_for_parameter(v, record) } if yaml['params']
|
218
|
+
|
182
219
|
parms['table'] = parms['table'].underscore if parms['table'] # might be CamelCase
|
183
220
|
# error if controller parameter is missing
|
184
221
|
if parms['controller'].nil? && parms['url'].nil?
|
185
222
|
"<li>#{'Controller not defined'}</li>"
|
186
223
|
else
|
187
|
-
yaml['caption'] ||= yaml['text']
|
224
|
+
#yaml['caption'] ||= yaml['text']
|
188
225
|
html_data = dc_html_data(yaml['html'])
|
189
|
-
#
|
190
226
|
url = url_for(parms) rescue 'URL error'
|
227
|
+
url = nil if parms['url'] == '#'
|
228
|
+
|
191
229
|
request = yaml['request'] || yaml['method'] || 'get'
|
192
230
|
if yaml['type'] == 'ajax' # ajax button
|
193
231
|
clas = "dc-link-ajax dc-animate"
|
@@ -204,7 +242,7 @@ def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
|
|
204
242
|
|
205
243
|
elsif yaml['type'] == 'link' # link button
|
206
244
|
clas = "dc-link dc-animate"
|
207
|
-
link = dc_link_to(
|
245
|
+
link = dc_link_to(caption, yaml['icon'], parms, yaml['html'] )
|
208
246
|
%Q[<li class="#{clas}">#{action_active ? link : caption}</li>]
|
209
247
|
|
210
248
|
elsif yaml['type'] == 'window'
|
@@ -47,13 +47,13 @@ def dc_actions_for_index()
|
|
47
47
|
actions['standard'] = nil
|
48
48
|
end
|
49
49
|
|
50
|
-
# start div with hidden spinner image
|
51
|
-
html =
|
50
|
+
# start div with hidden spinner image
|
51
|
+
html = %(
|
52
52
|
<form id="dc-action-menu">
|
53
53
|
<span class="dc-spinner">#{fa_icon('spinner lg spin')}</span>
|
54
|
-
<ul class="dc-action-menu">
|
55
|
-
|
56
|
-
# Remove actions settings and sort
|
54
|
+
<ul class="dc-action-menu">)
|
55
|
+
|
56
|
+
# Remove actions settings and sort
|
57
57
|
only_actions = []
|
58
58
|
actions.each { |key, value| only_actions << [key, value] if key.class == Integer }
|
59
59
|
only_actions.sort_by!(&:first)
|
@@ -67,7 +67,7 @@ EOT
|
|
67
67
|
dc_deprecate "action: url will be deprecated. Use action: link in index: actions! Form #{params['form_name']}"
|
68
68
|
action = 'link'
|
69
69
|
end
|
70
|
-
# if return_to is present link directly to URL
|
70
|
+
# if return_to is present link directly to URL
|
71
71
|
if action == 'link' and yaml['url']
|
72
72
|
url = yaml['url']
|
73
73
|
else
|
@@ -77,11 +77,12 @@ EOT
|
|
77
77
|
url['form_name'] = yaml['form_name'] if yaml['form_name']
|
78
78
|
url['control'] = yaml['control'] if yaml['control']
|
79
79
|
end
|
80
|
-
# html link options
|
80
|
+
# html link options
|
81
81
|
yhtml = yaml['html'] || {}
|
82
82
|
yhtml['title'] = yaml['title'] if yaml['title']
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
code = case
|
85
|
+
# sort
|
85
86
|
when action == 'sort' then
|
86
87
|
choices = [['id','id']]
|
87
88
|
if @form['index']['sort']
|
@@ -93,11 +94,12 @@ EOT
|
|
93
94
|
fa_icon('sort-alpha-asc') + ' ' + t('drgcms.sort') + ' ' +
|
94
95
|
select('sort', 'sort', choices, { include_blank: true },
|
95
96
|
{ class: 'drgcms_sort', 'data-table' => @form['table'], 'data-form' => params['form_name']} )
|
96
|
-
|
97
|
+
|
98
|
+
# filter
|
97
99
|
when action == 'filter' then
|
98
100
|
caption = t('drgcms.filter')
|
99
101
|
caption << ' ' + fa_icon('caret-down lg') + DcFilter.menu_filter(self)
|
100
|
-
# add filter OFF link
|
102
|
+
# add filter OFF link
|
101
103
|
sess = session[@form['table']]
|
102
104
|
if sess and sess[:filter]
|
103
105
|
caption << ' ' + dc_link_to(nil,'remove lg',
|
@@ -105,11 +107,13 @@ EOT
|
|
105
107
|
{ title: DcFilter.title4_filter_off(sess[:filter]) })
|
106
108
|
end
|
107
109
|
caption
|
108
|
-
|
110
|
+
|
111
|
+
# new
|
109
112
|
when action == 'new' then
|
110
113
|
caption = yaml['caption'] || 'drgcms.new'
|
111
114
|
dc_link_to(caption,'plus', url, yhtml )
|
112
|
-
|
115
|
+
|
116
|
+
# menu
|
113
117
|
when action == 'menu' then
|
114
118
|
caption = t(options['caption'], options['caption']) + ' ' + fa_icon('caret-down lg')
|
115
119
|
caption + eval(options['eval'])
|
@@ -126,13 +130,16 @@ EOT
|
|
126
130
|
when action == 'script'
|
127
131
|
html << dc_script_action(options)
|
128
132
|
next
|
133
|
+
|
129
134
|
when action == 'field'
|
130
135
|
html << dc_field_action(yaml)
|
131
136
|
next
|
137
|
+
|
132
138
|
when %w(ajax link window submit).include?(action)
|
133
139
|
html << dc_link_ajax_window_submit_action(options, nil)
|
134
140
|
next
|
135
|
-
|
141
|
+
|
142
|
+
else
|
136
143
|
caption = yaml['caption'] || yaml['text']
|
137
144
|
icon = yaml['icon'] ? yaml['icon'] : action
|
138
145
|
dc_link_to(caption, icon, url, yhtml)
|
@@ -140,22 +147,21 @@ EOT
|
|
140
147
|
html << "<li class=\"dc-link dc-animate\">#{code}</li>"
|
141
148
|
html << DcFilter.get_filter_field(self) if action == 'filter'
|
142
149
|
end
|
143
|
-
html << '</ul>'
|
144
|
-
html << '</form>'
|
150
|
+
html << '</ul></form>'
|
145
151
|
html.html_safe
|
146
152
|
end
|
147
153
|
|
148
154
|
############################################################################
|
149
155
|
# Creates filter div for cmsedit index/filter action.
|
150
156
|
############################################################################
|
151
|
-
def dc_div_filter
|
157
|
+
def dc_div_filter
|
152
158
|
choices = []
|
153
159
|
filter = (@form['index'] and @form['index']['filter']) ? @form['index']['filter'] + ',' : ''
|
154
160
|
filter << 'id as text_field' # filter id is added by default
|
155
161
|
filter.split(',').each do |f|
|
156
162
|
f.strip!
|
157
163
|
name = f.match(' as ') ? f.split(' ').first : f
|
158
|
-
# like another field on the form
|
164
|
+
# like another field on the form
|
159
165
|
if f.match(' like ')
|
160
166
|
a = f.split(' ')
|
161
167
|
name = a.first
|
@@ -164,7 +170,7 @@ def dc_div_filter()
|
|
164
170
|
choices << [ t("helpers.label.#{@form['table']}.#{name}", name), f ]
|
165
171
|
end
|
166
172
|
choices4_operators = t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )}
|
167
|
-
# currently selected options
|
173
|
+
# currently selected options
|
168
174
|
if session[@form['table']] and session[@form['table']][:filter]
|
169
175
|
field_name, operators_value, dummy = session[@form['table']][:filter].split("\t")
|
170
176
|
else
|
@@ -190,7 +196,7 @@ end
|
|
190
196
|
############################################################################
|
191
197
|
# Creates popup div for setting filter on result set header.
|
192
198
|
############################################################################
|
193
|
-
def dc_filter_popup
|
199
|
+
def dc_filter_popup
|
194
200
|
html = %Q[<div class="filter-popup" style="display: none;">
|
195
201
|
<div>#{t('drgcms.filter_set')}</div>
|
196
202
|
<ul>]
|
@@ -204,20 +210,22 @@ def dc_filter_popup()
|
|
204
210
|
end
|
205
211
|
|
206
212
|
############################################################################
|
207
|
-
#
|
208
|
-
# options.
|
213
|
+
# Will return title based on @form['title']
|
209
214
|
############################################################################
|
210
|
-
def
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
215
|
+
def dc_form_title
|
216
|
+
return t("helpers.label.#{@form['table']}.tabletitle", @form['table']) if @form['title'].nil?
|
217
|
+
return t(@form['title'], @form['title']) if @form['title'].class == String
|
218
|
+
|
219
|
+
# Hash
|
220
|
+
dc_process_eval(@form['title']['eval'], [@form['title']['caption'] || @form['title']['text'], params])
|
221
|
+
end
|
222
|
+
|
223
|
+
############################################################################
|
224
|
+
# Creates title div for index action. Title div also includes paging options
|
225
|
+
# and help link
|
226
|
+
############################################################################
|
227
|
+
def dc_title_for_index(result = nil)
|
228
|
+
dc_table_title(dc_form_title(), result)
|
221
229
|
end
|
222
230
|
|
223
231
|
############################################################################
|
@@ -225,15 +233,16 @@ end
|
|
225
233
|
############################################################################
|
226
234
|
def dc_actions_column
|
227
235
|
actions = @form['result_set']['actions']
|
228
|
-
return [{}, 0] if actions.nil?
|
229
|
-
|
236
|
+
return [{}, 0] if actions.nil? || dc_dont?(actions)
|
237
|
+
|
238
|
+
# standard actions
|
230
239
|
actions = {'standard' => true} if actions.class == String && actions == 'standard'
|
231
240
|
std_actions = { 2 => 'edit', 5 => 'delete' }
|
232
241
|
if actions['standard']
|
233
242
|
actions.merge!(std_actions)
|
234
243
|
actions.delete('standard')
|
235
244
|
end
|
236
|
-
|
245
|
+
|
237
246
|
width = @form['result_set']['actions_width'] || 18*actions.size
|
238
247
|
[actions, width]
|
239
248
|
end
|
@@ -263,7 +272,7 @@ def dc_actions_for_result(document)
|
|
263
272
|
# if single definition simulate type parameter
|
264
273
|
yaml = v.class == String ? { 'type' => v } : v
|
265
274
|
# code already includes li tag
|
266
|
-
if %w(ajax link window submit).include?(yaml['type'])
|
275
|
+
if %w(ajax link window submit).include?(yaml['type'])
|
267
276
|
@record = document # otherwise document fields can't be used as parameters
|
268
277
|
html << dc_link_ajax_window_submit_action(yaml, document)
|
269
278
|
else
|
@@ -325,7 +334,7 @@ def dc_header_for_result()
|
|
325
334
|
th = %Q[<div class="th" style="width:#{v['width'] || '15%'};text-align:#{v['align'] || 'left'};" data-name="#{v['name']}"]
|
326
335
|
label = v['caption'] || v['label']
|
327
336
|
label = (v['name'] ? "helpers.label.#{@form['table']}.#{v['name']}" : '') if label.nil?
|
328
|
-
label = t(label) if label.match(
|
337
|
+
label = t(label) if label.match(/\./)
|
329
338
|
# no sorting when embedded documents or custom filter is active
|
330
339
|
sort_ok = @form['result_set'].nil? || (@form['result_set'] && @form['result_set']['filter'].nil?)
|
331
340
|
sort_ok = sort_ok || (@form['index'] && @form['index']['sort'])
|
@@ -364,9 +373,9 @@ def dc_clicks_for_result(document)
|
|
364
373
|
html << ' data-dblclick=' + url_for(opts)
|
365
374
|
else
|
366
375
|
html << (' data-dblclick=' +
|
367
|
-
|
368
|
-
|
369
|
-
|
376
|
+
url_for(action: 'show', controller: 'cmsedit', id: document.id, ids: params[:ids],
|
377
|
+
readonly: (params[:readonly] ? 2 : 1), table: params[:table],
|
378
|
+
form_name: params[:form_name]) ) if @form['form']
|
370
379
|
end
|
371
380
|
html
|
372
381
|
end
|
@@ -466,8 +475,8 @@ def dc_process_eval(evaluate, parameters)
|
|
466
475
|
end
|
467
476
|
|
468
477
|
############################################################################
|
469
|
-
#
|
470
|
-
# Will
|
478
|
+
# Split eval expression to array by parameters.
|
479
|
+
# Will split dc_name4_value(one ,"two") => ['dc_name4_value', 'one', 'two']
|
471
480
|
############################################################################
|
472
481
|
def dc_eval_to_array(expression)
|
473
482
|
expression.split(/\ |\,|\(|\)/).delete_if {|e| e.blank? }.map {|e| e.gsub(/\'|\"/,'').strip }
|
@@ -479,44 +488,46 @@ end
|
|
479
488
|
############################################################################
|
480
489
|
def dc_process_column_eval(yaml, document)
|
481
490
|
# dc_name_for_id
|
482
|
-
if yaml['eval'].match(
|
483
|
-
|
484
|
-
if
|
485
|
-
dc_name_for_id(
|
491
|
+
if yaml['eval'].match(/dc_name4_id|dc_name_for_id/)
|
492
|
+
parms = dc_eval_to_array(yaml['eval'])
|
493
|
+
if parms.size == 3
|
494
|
+
dc_name_for_id(parms[1], parms[2], nil, document[ yaml['name'] ])
|
495
|
+
else
|
496
|
+
dc_name_for_id(parms[1], parms[2], parms[3], document[ yaml['name'] ])
|
497
|
+
end
|
498
|
+
|
499
|
+
# dc_name_for_value from locale definition
|
500
|
+
elsif yaml['eval'].match(/dc_name4_value|dc_name_for_value/)
|
501
|
+
parms = dc_eval_to_array(yaml['eval'])
|
502
|
+
if parms.size == 1
|
503
|
+
dc_name_for_value( @form['table'], yaml['name'], document[ yaml['name'] ] )
|
486
504
|
else
|
487
|
-
|
505
|
+
dc_name_for_value( parms[1], parms[2], document[ yaml['name'] ] )
|
488
506
|
end
|
489
|
-
|
490
|
-
|
491
|
-
dc_name_for_value( @form['table'], yaml['name'], document[ yaml['name'] ] )
|
492
|
-
# dc_name_for_value from other model
|
493
|
-
elsif yaml['eval'].match('dc_name4_value') || yaml['eval'].match('dc_name_for_value')
|
494
|
-
prms = dc_eval_to_array(yaml['eval'])
|
495
|
-
dc_name_for_value( prms[1], prms[2], document[ yaml['name'] ] )
|
496
|
-
# for example dc_icon_for_boolean
|
507
|
+
|
508
|
+
# defined in helpers. For example dc_icon_for_boolean
|
497
509
|
elsif respond_to?(yaml['eval'])
|
498
|
-
send(yaml['eval'], document[
|
499
|
-
|
510
|
+
send(yaml['eval'], document[yaml['name']])
|
511
|
+
|
512
|
+
# defined in model
|
500
513
|
elsif document.respond_to?(yaml['eval'])
|
501
514
|
document.send(yaml['eval'])
|
515
|
+
|
502
516
|
# special eval
|
503
517
|
elsif yaml['eval'].match('eval ')
|
504
518
|
# TO DO evaluate with specified parameters
|
519
|
+
|
520
|
+
# eval with params
|
505
521
|
else
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
yaml['params'].chomp.split(',').inject([]) do |result,e|
|
512
|
-
result << document[e.strip]
|
513
|
-
end
|
514
|
-
end
|
522
|
+
parms = {}
|
523
|
+
if yaml['params'].class == String
|
524
|
+
parms = dc_value_for_parameter(yaml['params'], document)
|
525
|
+
elsif yaml['params'].class == Hash
|
526
|
+
yaml['params'].each { |k, v| parms[k] = dc_value_for_parameter(v) }
|
515
527
|
else
|
516
|
-
document[ yaml['name'] ]
|
528
|
+
parms = document[ yaml['name'] ]
|
517
529
|
end
|
518
|
-
|
519
|
-
dc_process_eval(yaml['eval'], parameters)
|
530
|
+
dc_process_eval(yaml['eval'], parms)
|
520
531
|
end
|
521
532
|
end
|
522
533
|
|
@@ -525,7 +536,8 @@ end
|
|
525
536
|
############################################################################
|
526
537
|
def dc_style_or_class(selector, yaml, value, record)
|
527
538
|
return '' if yaml.nil?
|
528
|
-
|
539
|
+
|
540
|
+
# alias record and value so both names can be used in eval
|
529
541
|
field, document = value, record
|
530
542
|
html = selector ? "#{selector}=\"" : ''
|
531
543
|
html << if yaml.class == String
|
@@ -534,7 +546,7 @@ def dc_style_or_class(selector, yaml, value, record)
|
|
534
546
|
elsif yaml['eval']
|
535
547
|
eval(yaml['eval']) rescue 'background-color:red;'
|
536
548
|
elsif yaml['method']
|
537
|
-
dc_process_eval(yaml['method'],record)
|
549
|
+
dc_process_eval(yaml['method'], record)
|
538
550
|
end
|
539
551
|
html << '"' if selector
|
540
552
|
html
|