drg_cms 0.6.1.5 → 0.6.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +203 -24
- data/app/assets/fonts/ibm-plex-sans-300.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-400.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-500.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-600.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-700.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-italic.woff2 +0 -0
- data/app/assets/javascripts/drg_cms/drg_cms.js +253 -106
- data/app/assets/stylesheets/drg_cms/drg_cms.css +670 -521
- data/app/assets/stylesheets/drg_cms_application.css +1 -1
- data/app/assets/stylesheets/drg_cms_cms.css +1 -4
- data/app/controllers/cmsedit_controller.rb +33 -211
- data/app/controllers/dc_application_controller.rb +98 -22
- data/app/controllers/dc_common_controller.rb +9 -22
- data/app/controls/browse_models_control.rb +18 -27
- data/app/controls/cmsedit_control.rb +129 -0
- data/app/controls/dc_help_control.rb +1 -1
- data/app/controls/dc_page_control.rb +0 -1
- data/app/controls/dc_poll_result_control.rb +1 -1
- data/app/controls/dc_report.rb +2 -2
- data/app/controls/design_element_settings_control.rb +1 -1
- data/app/forms/all_options.yml +25 -7
- data/app/forms/cms_menu.yml +24 -24
- data/app/forms/dc_browse_fields.yml +13 -9
- data/app/forms/dc_browse_models.yml +24 -2
- data/app/forms/dc_poll_result_export.yml +1 -1
- data/app/forms/dc_site.yml +2 -5
- data/app/forms/dc_steps_template.yml +51 -0
- data/app/helpers/cms_common_helper.rb +73 -6
- data/app/helpers/cms_edit_helper.rb +275 -159
- data/app/helpers/cms_helper.rb +152 -59
- data/app/helpers/cms_index_helper.rb +220 -172
- data/app/helpers/dc_application_helper.rb +40 -67
- data/app/models/concerns/dc_page_concern.rb +1 -1
- data/app/models/concerns/dc_site_concern.rb +9 -3
- data/app/models/dc_filter.rb +30 -22
- data/app/models/dc_journal.rb +2 -2
- data/app/models/dc_json_ld.rb +19 -42
- data/app/models/dc_part.rb +19 -9
- data/app/models/dc_site.rb +0 -1
- data/app/models/drgcms_form_fields/drgcms_field.rb +10 -4
- data/app/models/drgcms_form_fields/link_to.rb +1 -1
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +5 -5
- data/app/models/drgcms_form_fields/readonly.rb +4 -1
- data/app/models/drgcms_form_fields/select.rb +10 -9
- data/app/models/drgcms_form_fields/text_autocomplete.rb +20 -12
- data/app/models/drgcms_form_fields/text_with_select.rb +1 -0
- data/app/renderers/dc_common_renderer.rb +20 -3
- data/app/renderers/dc_part_renderer.rb +1 -1
- data/app/renderers/dc_poll_renderer.rb +1 -1
- data/app/views/cmsedit/_edit_stuff.html.erb +12 -12
- data/app/views/cmsedit/_form.html.erb +19 -12
- data/app/views/cmsedit/edit.html.erb +10 -6
- data/app/views/cmsedit/index.html.erb +5 -3
- data/app/views/cmsedit/login.html.erb +1 -1
- data/app/views/cmsedit/new.html.erb +9 -5
- data/app/views/dc_common/_help.html.erb +1 -0
- data/app/views/dc_common/paste_clipboard.html.erb +1 -1
- data/app/views/layouts/cms.html.erb +3 -5
- data/config/locales/drgcms_en.yml +7 -1
- data/config/locales/drgcms_sl.yml +7 -1
- data/config/locales/kaminari.yml +1 -1
- data/drg_cms.gemspec +2 -2
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +4 -4
- metadata +16 -10
- data/app/views/cmsedit/__remove_edit_stuff.js.erb +0 -6
- data/app/views/cmsedit/__show.html.erb +0 -21
@@ -50,12 +50,7 @@ def dc_actions_for_index
|
|
50
50
|
actions['standard'] = nil
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
html = %(
|
55
|
-
<form id="dc-action-menu">
|
56
|
-
<span class="dc-spinner">#{fa_icon('spinner lg spin')}</span>
|
57
|
-
<ul class="dc-action-menu">)
|
58
|
-
|
53
|
+
html_left, html_right = '', ''
|
59
54
|
# Remove actions settings and sort
|
60
55
|
only_actions = []
|
61
56
|
actions.each { |key, value| only_actions << [key, value] if key.class == Integer }
|
@@ -64,7 +59,7 @@ def dc_actions_for_index
|
|
64
59
|
session[:form_processing] = "index:actions: #{key}=#{options}"
|
65
60
|
next if options.nil? # must be
|
66
61
|
|
67
|
-
url = @
|
62
|
+
url = @form_params.clone
|
68
63
|
yaml = options.class == String ? {'type' => options} : options # if single definition simulate type parameter
|
69
64
|
action = yaml['type'].to_s.downcase
|
70
65
|
if action == 'url'
|
@@ -72,7 +67,7 @@ def dc_actions_for_index
|
|
72
67
|
action = 'link'
|
73
68
|
end
|
74
69
|
# if return_to is present link directly to URL
|
75
|
-
if action == 'link'
|
70
|
+
if action == 'link' && yaml['url']
|
76
71
|
url = yaml['url']
|
77
72
|
else
|
78
73
|
url['controller'] = yaml['controller'] if yaml['controller']
|
@@ -82,85 +77,98 @@ def dc_actions_for_index
|
|
82
77
|
url['control'] = yaml['control'] if yaml['control']
|
83
78
|
end
|
84
79
|
# html link options
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
html_options = yaml['html'] || {}
|
81
|
+
html_options['title'] = yaml['title'] if yaml['title']
|
82
|
+
case
|
88
83
|
# sort
|
89
|
-
when action == 'sort'
|
90
|
-
choices = [[
|
84
|
+
when action == 'sort'
|
85
|
+
choices = [%w[id id]]
|
91
86
|
if @form['index']['sort']
|
92
|
-
@form['index']['sort'].split(',').each do |
|
93
|
-
|
94
|
-
choices << [ t("helpers.label.#{@form['table']}.#{
|
87
|
+
@form['index']['sort'].split(',').each do |e|
|
88
|
+
e.strip!
|
89
|
+
choices << [ t("helpers.label.#{@form['table']}.#{e}"), e ]
|
95
90
|
end
|
96
91
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
92
|
+
data = t('drgcms.sort') + select('sort', 'sort', choices, { include_blank: true }, { class: 'dc-sort-select',
|
93
|
+
'data-table' => @form['table'], 'data-form' => CmsHelper.form_param(params)} )
|
94
|
+
data = mi_icon('sort') + select('sort', 'sort', choices, { include_blank: true }, { class: 'dc-sort-select',
|
95
|
+
'data-table' => @form['table'], 'data-form' => CmsHelper.form_param(params)} )
|
96
|
+
html_right << %(<li title="#{t('drgcms.sort')}"><div class="dc-sort">#{data}</li>)
|
100
97
|
|
101
98
|
# filter
|
102
|
-
when action == 'filter'
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
99
|
+
when action == 'filter'
|
100
|
+
table = session[@form['table']]
|
101
|
+
url = table&.dig(:filter) ?
|
102
|
+
url_for(controller: 'cmsedit', action: 'run', control: 'cmsedit.filter_off', t: @form['table'], f: CmsHelper.form_param(params)) :
|
103
|
+
''
|
104
|
+
html_right << %(
|
105
|
+
<li>
|
106
|
+
<div class="dc-filter" title="#{DcFilter.title4_filter_off(table)}" data-url="#{url.html_safe}">
|
107
|
+
#{mi_icon(url.blank? ? 'search' : 'filter_alt_off') }#{DcFilter.menu_filter(self).html_safe}
|
108
|
+
</div>
|
109
|
+
</li>#{DcFilter.get_filter_field(self)}).html_safe
|
113
110
|
|
114
111
|
# new
|
115
|
-
when action == 'new'
|
112
|
+
when action == 'new'
|
116
113
|
caption = yaml['caption'] || 'drgcms.new'
|
117
|
-
|
118
|
-
|
114
|
+
html_options['class'] = 'dc-link'
|
115
|
+
html_left << "<li>#{dc_link_to(caption, 'add', url, html_options)}</li>"
|
116
|
+
|
117
|
+
when action == 'close'
|
118
|
+
html_left << %(<li><div class="dc-link" onclick="window.close();"'>#{fa_icon('close')} #{t('drgcms.close')}</div></li>)
|
119
119
|
|
120
|
-
when action == '
|
121
|
-
|
122
|
-
next
|
120
|
+
when action == 'back'
|
121
|
+
html_left << %(<li><div class="dc-link" onclick="history.back();"'>#{fa_icon('arrow_back')} #{t('drgcms.back')}</div></li>)
|
123
122
|
|
124
123
|
# menu
|
125
|
-
when action == 'menu'
|
126
|
-
if options['caption']
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
124
|
+
when action == 'menu'
|
125
|
+
code = if options['caption']
|
126
|
+
caption = t(options['caption'], options['caption']) + ' ' + fa_icon('caret-down')
|
127
|
+
caption + eval(options['eval'])
|
128
|
+
else # when caption is false, provide own actions
|
129
|
+
eval(options['eval'])
|
130
|
+
end
|
131
|
+
html_left << %(<li><div class="dc-link">#{code}</div></li>)
|
132
|
+
|
132
133
|
=begin
|
133
134
|
# reorder
|
134
135
|
when action == 'reorder' then
|
135
136
|
caption = t('drgcms.reorder')
|
136
|
-
parms = @
|
137
|
+
parms = @form_params.clone
|
137
138
|
parms['operation'] = v
|
138
139
|
parms['id'] = params[:ids]
|
139
140
|
parms['table'] = @form['table']
|
140
141
|
dc_link_to( caption, 'reorder', parms, method: :delete )
|
141
142
|
=end
|
142
143
|
when action == 'script'
|
143
|
-
|
144
|
-
next
|
144
|
+
html_left << dc_script_action(options)
|
145
145
|
|
146
146
|
when action == 'field'
|
147
|
-
|
148
|
-
next
|
147
|
+
html_right << dc_field_action(yaml)
|
149
148
|
|
150
|
-
when %w(ajax link window submit).include?(action)
|
151
|
-
|
152
|
-
next
|
149
|
+
when %w(ajax link window popup submit).include?(action)
|
150
|
+
html_left << dc_link_ajax_window_submit_action(options, nil)
|
153
151
|
|
154
152
|
else
|
155
|
-
caption = yaml
|
156
|
-
icon = yaml['icon']
|
157
|
-
|
153
|
+
caption = dc_get_caption(yaml) || t("drgcms.#{action}")
|
154
|
+
icon = yaml['icon'] || action
|
155
|
+
html_options['class'] = 'dc-link'
|
156
|
+
code = dc_link_to(caption, icon, url, html_options)
|
157
|
+
html_left << %(<li>#{code}</li>)
|
158
158
|
end
|
159
|
-
html << "<li class=\"dc-link dc-animate\">#{code}</li>"
|
160
|
-
html << DcFilter.get_filter_field(self) if action == 'filter'
|
161
159
|
end
|
162
|
-
|
163
|
-
|
160
|
+
|
161
|
+
%(
|
162
|
+
<form id="dc-action-menu">
|
163
|
+
<span class="dc-spinner">#{fa_icon('settings-o spin')}</span>
|
164
|
+
|
165
|
+
<div class="dc-action-menu">
|
166
|
+
<ul class="dc-left">#{html_left}</ul>
|
167
|
+
<ul class="dc-right">#{html_right}</ul>
|
168
|
+
</div>
|
169
|
+
<div style="clear: both;"></div>
|
170
|
+
</form>
|
171
|
+
).html_safe
|
164
172
|
end
|
165
173
|
|
166
174
|
############################################################################
|
@@ -168,53 +176,53 @@ end
|
|
168
176
|
############################################################################
|
169
177
|
def dc_div_filter
|
170
178
|
choices = []
|
171
|
-
filter =
|
179
|
+
filter = @form['index'] && @form['index']['filter'] ? @form['index']['filter'] + ',' : ''
|
172
180
|
filter << 'id as text_field' # filter id is added by default
|
173
181
|
filter.split(',').each do |f|
|
174
182
|
f.strip!
|
175
183
|
name = f.match(' as ') ? f.split(' ').first : f
|
176
184
|
# like another field on the form
|
177
|
-
if f.match(' like ')
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
choices << [ t("helpers.label.#{@form['table']}.#{name}", name), f ]
|
185
|
+
name, like, f = f.split(' ') if f.match(' like ')
|
186
|
+
choices << [ t("helpers.label.#{@form['table']}.#{name}", name), f ]
|
187
|
+
end
|
188
|
+
choices4_operators = t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) do |r, v|
|
189
|
+
r << (v.match(':') ? v.split(':') : v )
|
183
190
|
end
|
184
|
-
choices4_operators = t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )}
|
185
191
|
# currently selected options
|
186
|
-
if session[@form['table']]
|
192
|
+
if session[@form['table']] && session[@form['table']][:filter]
|
187
193
|
field_name, operators_value, dummy = session[@form['table']][:filter].split("\t")
|
188
194
|
else
|
189
195
|
field_name, operators_value = nil, nil
|
190
196
|
end
|
191
|
-
|
192
|
-
|
193
|
-
|
197
|
+
url_on = url_for(controller: 'cmsedit', action: :run, control: 'cmsedit.filter_on' ,
|
198
|
+
t: CmsHelper.table_param(params), f: CmsHelper.form_param(params), filter_input: 1)
|
199
|
+
url_off = url_for(controller: 'cmsedit', action: :run, control: 'cmsedit.filter_off',
|
200
|
+
t: CmsHelper.table_param(params), f: CmsHelper.form_param(params))
|
201
|
+
%(
|
194
202
|
<div id="drgcms_filter" class="div-hidden">
|
195
203
|
<h1>#{t('drgcms.filter_set')}</h1>
|
196
204
|
|
197
205
|
#{ select(nil, 'filter_field1', options_for_select(choices, field_name), { include_blank: true }) }
|
198
206
|
#{ select(nil, 'filter_oper', options_for_select(choices4_operators, operators_value)) }
|
199
207
|
<div class="dc-menu">
|
200
|
-
<div class="dc-link dc-
|
201
|
-
<div class="dc-link
|
208
|
+
<div class="dc-link dc-filter-set" data-url="#{url_on}">#{fa_icon('done')} #{t('drgcms.filter_on')}</div>
|
209
|
+
<div class="dc-link-ajax" data-url="#{url_off}">
|
210
|
+
#{mi_icon('close')}#{t('drgcms.filter_off')}
|
211
|
+
</div>
|
202
212
|
</div>
|
203
|
-
</div>
|
204
|
-
EOT
|
205
|
-
html.html_safe
|
213
|
+
</div>).html_safe
|
206
214
|
end
|
207
215
|
|
208
216
|
############################################################################
|
209
217
|
# Creates popup div for setting filter on result set header.
|
210
218
|
############################################################################
|
211
219
|
def dc_filter_popup
|
212
|
-
html = %
|
213
|
-
|
214
|
-
|
215
|
-
|
220
|
+
html = %(<div class="filter-popup" style="display: none;"><div>#{t('drgcms.filter_set')}</div><ul>)
|
221
|
+
url = url_for(controller: 'cmsedit', action: 'run', control: 'cmsedit.filter_on',
|
222
|
+
t: @form['table'], f: params['form_name'], filter_input: 1)
|
223
|
+
|
216
224
|
t('drgcms.choices4_filter_operators').chomp.split(',').each do |operator_choice|
|
217
|
-
caption,choice = operator_choice.split(':')
|
225
|
+
caption, choice = operator_choice.split(':')
|
218
226
|
html << %Q[<li data-operator="#{choice}" data-url="#{url}">#{caption}</li>]
|
219
227
|
end
|
220
228
|
html << "</ul></div>"
|
@@ -245,18 +253,20 @@ end
|
|
245
253
|
############################################################################
|
246
254
|
def dc_actions_column
|
247
255
|
actions = @form['result_set']['actions']
|
248
|
-
return [{}, 0] if actions.nil? || dc_dont?(actions)
|
256
|
+
return [{}, 0, false] if actions.nil? || dc_dont?(actions)
|
249
257
|
|
250
258
|
# standard actions
|
251
|
-
actions = {'standard' => true} if actions.class == String && actions == 'standard'
|
259
|
+
actions = { 'standard' => true } if actions.class == String && actions == 'standard'
|
252
260
|
std_actions = { 2 => 'edit', 5 => 'delete' }
|
253
261
|
if actions['standard']
|
254
|
-
actions.merge!(std_actions)
|
262
|
+
actions.merge!(std_actions)
|
255
263
|
actions.delete('standard')
|
256
264
|
end
|
257
|
-
|
258
|
-
|
259
|
-
|
265
|
+
# check must be first action
|
266
|
+
has_check = actions[0] && actions[0]['type'] == 'check'
|
267
|
+
width = actions.size == 1 ? 22 : 44
|
268
|
+
width = 22 if actions.size > 2 && !has_check
|
269
|
+
[actions, width, has_check]
|
260
270
|
end
|
261
271
|
|
262
272
|
############################################################################
|
@@ -265,8 +275,8 @@ end
|
|
265
275
|
def dc_actions_column_for_footer
|
266
276
|
return '' unless @form['result_set']['actions']
|
267
277
|
|
268
|
-
ignore, width = dc_actions_column
|
269
|
-
%
|
278
|
+
ignore, width, ignore2 = dc_actions_column
|
279
|
+
%(<div class="dc-result-actions" style="width: #{width}px;"></div>).html_safe
|
270
280
|
end
|
271
281
|
|
272
282
|
############################################################################
|
@@ -276,57 +286,75 @@ def dc_actions_for_result(document)
|
|
276
286
|
actions = @form['result_set']['actions']
|
277
287
|
return '' if actions.nil? || @form['readonly']
|
278
288
|
|
279
|
-
actions, width = dc_actions_column()
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
289
|
+
actions, width, has_check = dc_actions_column()
|
290
|
+
has_sub_menu = actions.size > 2 || (has_check && actions.size > 1)
|
291
|
+
|
292
|
+
main_menu, sub_menu = '', ''
|
293
|
+
actions.sort_by(&:first).each do |num, action|
|
294
|
+
session[:form_processing] = "result_set:actions: #{num}=#{action}"
|
295
|
+
parms = @form_params.clone
|
284
296
|
# if single definition simulate type parameter
|
285
|
-
yaml =
|
286
|
-
|
287
|
-
if %w(ajax link window submit).include?(yaml['type'])
|
297
|
+
yaml = action.class == String ? { 'type' => action } : action
|
298
|
+
|
299
|
+
if %w(ajax link window popup submit).include?(yaml['type'])
|
288
300
|
@record = document # otherwise document fields can't be used as parameters
|
289
|
-
html
|
301
|
+
html = dc_link_ajax_window_submit_action(yaml, document)
|
290
302
|
else
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
when
|
303
|
+
caption = dc_get_caption(yaml) || "drgcms.#{yaml['type']}"
|
304
|
+
title = t(yaml['help'] || caption, '')
|
305
|
+
caption = has_sub_menu ? t(caption, '') : nil
|
306
|
+
html = '<li>'
|
307
|
+
html << case yaml['type']
|
308
|
+
when 'check' then
|
309
|
+
main_menu << '<li>' + check_box_tag("check-#{document.id}", false, false, { class: 'dc-check' }) + '</li>'
|
310
|
+
next
|
311
|
+
|
312
|
+
when 'edit' then
|
297
313
|
parms['action'] = 'edit'
|
298
|
-
parms['id']
|
299
|
-
dc_link_to(
|
314
|
+
parms['id'] = document.id
|
315
|
+
dc_link_to( caption, 'edit-o', parms, title: title )
|
316
|
+
|
317
|
+
when 'show' then
|
318
|
+
parms['action'] = 'show'
|
319
|
+
parms['id'] = document.id
|
320
|
+
parms['readonly'] = true
|
321
|
+
dc_link_to( caption, 'eye', parms, title: title )
|
300
322
|
|
301
|
-
when
|
302
|
-
parms['id']
|
323
|
+
when 'duplicate' then
|
324
|
+
parms['id'] = document.id
|
303
325
|
# duplicate string will be added to these fields.
|
304
326
|
parms['dup_fields'] = yaml['dup_fields']
|
305
327
|
parms['action'] = 'create'
|
306
|
-
dc_link_to(
|
328
|
+
dc_link_to( caption, 'content_copy-o', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post, title: title )
|
307
329
|
|
308
|
-
when
|
330
|
+
when 'delete' then
|
309
331
|
parms['action'] = 'destroy'
|
310
|
-
parms['id']
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
# undocumented so far
|
315
|
-
when yaml['type'] == 'edit_embedded'
|
316
|
-
parms['controller'] = 'cmsedit'
|
317
|
-
parms['table'] += ";#{yaml['table']}"
|
318
|
-
parms['ids'] ||= ''
|
319
|
-
parms['ids'] += "#{document.id};"
|
320
|
-
dc_link_to( nil, 'table lg', parms, method: :get )
|
321
|
-
|
332
|
+
parms['id'] = document.id
|
333
|
+
dc_link_to( caption, 'delete-o', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete, title: title )
|
334
|
+
|
322
335
|
else # error.
|
323
336
|
yaml['type'].to_s
|
324
337
|
end
|
325
338
|
html << '</li>'
|
326
339
|
end
|
340
|
+
|
341
|
+
if has_sub_menu
|
342
|
+
sub_menu << html
|
343
|
+
else
|
344
|
+
main_menu << html
|
345
|
+
end
|
327
346
|
end
|
328
|
-
|
329
|
-
|
347
|
+
|
348
|
+
if has_sub_menu
|
349
|
+
%(
|
350
|
+
<ul class="dc-result-actions" style="width: #{width}px;">#{main_menu}
|
351
|
+
<li><div class="dc-result-submenu">#{fa_icon('more_vert')}
|
352
|
+
<ul id="menu-#{document.id}">#{sub_menu}</ul>
|
353
|
+
</div></li>
|
354
|
+
</ul>)
|
355
|
+
else
|
356
|
+
%(<ul class="dc-result-actions" style="width: #{width}px;">#{main_menu}</ul>)
|
357
|
+
end.html_safe
|
330
358
|
end
|
331
359
|
|
332
360
|
############################################################################
|
@@ -334,12 +362,10 @@ end
|
|
334
362
|
############################################################################
|
335
363
|
def dc_header_for_result
|
336
364
|
html = '<div class="dc-result-header">'
|
337
|
-
if @form['result_set']['actions']
|
338
|
-
ignore, width = dc_actions_column()
|
339
|
-
|
340
|
-
|
341
|
-
end
|
342
|
-
html << %Q[<div class="actions" style="width:#{width}px;">#{check_all}</div>]
|
365
|
+
if @form['result_set']['actions'] && !@form['readonly']
|
366
|
+
ignore, width, has_check = dc_actions_column()
|
367
|
+
check_all = fa_icon('check-box-o', class: 'dc-check-all') if has_check
|
368
|
+
html << %(<div class="dc-result-actions" style="width:#{width}px;">#{check_all}</div>)
|
343
369
|
end
|
344
370
|
# preparation for sort icon
|
345
371
|
sort_field, sort_direction = nil, nil
|
@@ -348,29 +374,34 @@ def dc_header_for_result
|
|
348
374
|
end
|
349
375
|
|
350
376
|
if (columns = @form['result_set']['columns'])
|
351
|
-
columns.sort.each do |
|
352
|
-
session[:form_processing] = "result_set:columns: #{
|
353
|
-
next if
|
354
|
-
|
355
|
-
th = %
|
356
|
-
label =
|
357
|
-
|
358
|
-
|
359
|
-
# no sorting when embedded documents or custom filter is active
|
360
|
-
#sort_ok = @form['result_set'].nil? || (@form['result_set'] && @form['result_set']['filter'].nil?)
|
361
|
-
sort_ok = true
|
377
|
+
columns.sort.each do |key, options|
|
378
|
+
session[:form_processing] = "result_set:columns: #{key}=#{options}"
|
379
|
+
next if options['width'].to_s.match(/hidden|none/i)
|
380
|
+
|
381
|
+
th = %(<div class="th" style="width:#{options['width'] || '15%'};text-align:#{options['align'] || 'left'};" data-name="#{options['name']}")
|
382
|
+
label = t_label_for_column(options)
|
383
|
+
# no sorting when embedded documents or custom filter is active
|
384
|
+
sort_ok = !dc_dont?(@form['result_set']['sort'], false)
|
362
385
|
sort_ok = sort_ok || (@form['index'] && @form['index']['sort'])
|
363
|
-
sort_ok = sort_ok && !dc_dont?(
|
364
|
-
if @tables.size == 1
|
365
|
-
icon = '
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
386
|
+
sort_ok = sort_ok && !dc_dont?(options['sort'], false)
|
387
|
+
if @tables.size == 1 && sort_ok
|
388
|
+
icon = 'sort_unset md-18'
|
389
|
+
filter_class = form_has_input_field?(options['name']) ? nil : 'no-filter'
|
390
|
+
if options['name'] == sort_field
|
391
|
+
icon = sort_direction == '1' ? 'sort_down md-18' : 'sort_up md-18'
|
392
|
+
else
|
393
|
+
# no icon if filter can not be set
|
394
|
+
icon = nil if filter_class
|
395
|
+
end
|
396
|
+
# sort and filter icon
|
397
|
+
icon = mi_icon(icon, class: filter_class) if icon
|
398
|
+
url = url_for(controller: 'cmsedit', action: 'run', control: 'cmsedit.sort', sort: options['name'],
|
399
|
+
t: CmsHelper.table_param(params), f: CmsHelper.form_param(params))
|
400
|
+
th << %(><span data-url="#{url}">#{label}</span>#{icon}</div>)
|
370
401
|
else
|
371
402
|
th << ">#{label}</div>"
|
372
403
|
end
|
373
|
-
html <<
|
404
|
+
html << %(<div class="spacer"></div>) + th
|
374
405
|
end
|
375
406
|
end
|
376
407
|
(html << '</div>').html_safe
|
@@ -386,8 +417,8 @@ def dc_clicks_for_result(document)
|
|
386
417
|
opts = {}
|
387
418
|
opts[:controller] = yaml['controller'] || 'cmsedit'
|
388
419
|
opts[:action] = yaml['action']
|
389
|
-
opts[:table] = yaml['table']
|
390
|
-
opts[:form_name] = yaml['form_name']
|
420
|
+
opts[:table] = yaml['table'] || CmsHelper.table_param(params)
|
421
|
+
opts[:form_name] = yaml['form_name'] || CmsHelper.form_param(params) || opts[:table]
|
391
422
|
opts[:method] = yaml['method'] || 'get'
|
392
423
|
opts[:id] = document['id']
|
393
424
|
opts[:readonly] = yaml['readonly'] if yaml['readonly']
|
@@ -396,8 +427,8 @@ def dc_clicks_for_result(document)
|
|
396
427
|
else
|
397
428
|
html << (' data-dblclick=' +
|
398
429
|
url_for(action: 'show', controller: 'cmsedit', id: document.id, ids: params[:ids],
|
399
|
-
readonly: (params[:readonly] ? 2 : 1),
|
400
|
-
|
430
|
+
readonly: (params[:readonly] ? 2 : 1), t: CmsHelper.table_param(params),
|
431
|
+
f: CmsHelper.form_param(params)) ) if @form['form']
|
401
432
|
end
|
402
433
|
html
|
403
434
|
end
|
@@ -441,27 +472,29 @@ end
|
|
441
472
|
def dc_columns_for_result(document)
|
442
473
|
return '' unless @form['result_set']['columns']
|
443
474
|
|
444
|
-
html = ''
|
445
|
-
@form['result_set']['columns'].sort.each do |k,v|
|
475
|
+
html, index = '', 0
|
476
|
+
@form['result_set']['columns'].sort.each do |k, v|
|
446
477
|
session[:form_processing] = "result_set:columns: #{k}=#{v}"
|
447
478
|
next if v['width'].to_s.match(/hidden|none/i)
|
448
479
|
|
449
480
|
# convert shortcut to hash
|
450
481
|
v = {'name' => v} if v.class == String
|
451
482
|
begin
|
452
|
-
|
453
|
-
value = if
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
483
|
+
# as Array (footer)
|
484
|
+
value = if document.class == Array
|
485
|
+
dc_format_value(document[index], v['format']) if document[index]
|
486
|
+
# as Hash (dc_memory)
|
487
|
+
elsif document.class == Hash
|
488
|
+
dc_format_value(document[ v['name'] ], v['format'])
|
489
|
+
# eval
|
490
|
+
elsif v['eval']
|
491
|
+
dc_process_column_eval(v, document)
|
492
|
+
# as field
|
493
|
+
elsif document.respond_to?(v['name'])
|
494
|
+
dc_format_value(document.send( v['name'] ), v['format'])
|
495
|
+
else
|
496
|
+
"??? #{v['name']}"
|
497
|
+
end
|
465
498
|
rescue Exception => e
|
466
499
|
dc_log_exception(e, 'dc_columns_for_result')
|
467
500
|
value = '!!!Error'
|
@@ -476,6 +509,7 @@ def dc_columns_for_result(document)
|
|
476
509
|
style = "style=\"#{width_align}#{style}\" "
|
477
510
|
|
478
511
|
html << "<div class=\"td #{clas}\" #{style}>#{value}</div>"
|
512
|
+
index += 1
|
479
513
|
end
|
480
514
|
html.html_safe
|
481
515
|
end
|
@@ -532,7 +566,7 @@ def dc_process_column_eval(yaml, document)
|
|
532
566
|
|
533
567
|
# defined in helpers. For example dc_icon_for_boolean
|
534
568
|
elsif respond_to?(yaml['eval'])
|
535
|
-
send(yaml['eval'], document
|
569
|
+
send(yaml['eval'], document, yaml['name'])
|
536
570
|
|
537
571
|
# defined in model
|
538
572
|
elsif document.respond_to?(yaml['eval'])
|
@@ -606,12 +640,26 @@ end
|
|
606
640
|
# When result set is to be drawn by Rails helper method.
|
607
641
|
############################################################################
|
608
642
|
def dc_process_result_set_method
|
609
|
-
|
610
|
-
|
611
|
-
send method
|
643
|
+
if @form['result_set']['view']
|
644
|
+
render partial: @form['result_set']['view']
|
612
645
|
else
|
613
|
-
|
646
|
+
method = @form['result_set']['eval'] || 'result_set_eval_misssing'
|
647
|
+
if respond_to?(method)
|
648
|
+
send method
|
649
|
+
else
|
650
|
+
I18n.t('drgcms.no_method', method: method)
|
651
|
+
end
|
614
652
|
end
|
615
653
|
end
|
616
654
|
|
655
|
+
############################################################################
|
656
|
+
# Check if form has defined input field for field_name and that is not readonly field.
|
657
|
+
############################################################################
|
658
|
+
def form_has_input_field?(field_name)
|
659
|
+
field = dc_get_field_form_definition(field_name)
|
660
|
+
return if field.nil?
|
661
|
+
|
662
|
+
!(field['type'] == 'readonly' || field['readonly'])
|
663
|
+
end
|
664
|
+
|
617
665
|
end
|