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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +203 -24
  3. data/app/assets/fonts/ibm-plex-sans-300.woff2 +0 -0
  4. data/app/assets/fonts/ibm-plex-sans-400.woff2 +0 -0
  5. data/app/assets/fonts/ibm-plex-sans-500.woff2 +0 -0
  6. data/app/assets/fonts/ibm-plex-sans-600.woff2 +0 -0
  7. data/app/assets/fonts/ibm-plex-sans-700.woff2 +0 -0
  8. data/app/assets/fonts/ibm-plex-sans-italic.woff2 +0 -0
  9. data/app/assets/javascripts/drg_cms/drg_cms.js +253 -106
  10. data/app/assets/stylesheets/drg_cms/drg_cms.css +670 -521
  11. data/app/assets/stylesheets/drg_cms_application.css +1 -1
  12. data/app/assets/stylesheets/drg_cms_cms.css +1 -4
  13. data/app/controllers/cmsedit_controller.rb +33 -211
  14. data/app/controllers/dc_application_controller.rb +98 -22
  15. data/app/controllers/dc_common_controller.rb +9 -22
  16. data/app/controls/browse_models_control.rb +18 -27
  17. data/app/controls/cmsedit_control.rb +129 -0
  18. data/app/controls/dc_help_control.rb +1 -1
  19. data/app/controls/dc_page_control.rb +0 -1
  20. data/app/controls/dc_poll_result_control.rb +1 -1
  21. data/app/controls/dc_report.rb +2 -2
  22. data/app/controls/design_element_settings_control.rb +1 -1
  23. data/app/forms/all_options.yml +25 -7
  24. data/app/forms/cms_menu.yml +24 -24
  25. data/app/forms/dc_browse_fields.yml +13 -9
  26. data/app/forms/dc_browse_models.yml +24 -2
  27. data/app/forms/dc_poll_result_export.yml +1 -1
  28. data/app/forms/dc_site.yml +2 -5
  29. data/app/forms/dc_steps_template.yml +51 -0
  30. data/app/helpers/cms_common_helper.rb +73 -6
  31. data/app/helpers/cms_edit_helper.rb +275 -159
  32. data/app/helpers/cms_helper.rb +152 -59
  33. data/app/helpers/cms_index_helper.rb +220 -172
  34. data/app/helpers/dc_application_helper.rb +40 -67
  35. data/app/models/concerns/dc_page_concern.rb +1 -1
  36. data/app/models/concerns/dc_site_concern.rb +9 -3
  37. data/app/models/dc_filter.rb +30 -22
  38. data/app/models/dc_journal.rb +2 -2
  39. data/app/models/dc_json_ld.rb +19 -42
  40. data/app/models/dc_part.rb +19 -9
  41. data/app/models/dc_site.rb +0 -1
  42. data/app/models/drgcms_form_fields/drgcms_field.rb +10 -4
  43. data/app/models/drgcms_form_fields/link_to.rb +1 -1
  44. data/app/models/drgcms_form_fields/multitext_autocomplete.rb +5 -5
  45. data/app/models/drgcms_form_fields/readonly.rb +4 -1
  46. data/app/models/drgcms_form_fields/select.rb +10 -9
  47. data/app/models/drgcms_form_fields/text_autocomplete.rb +20 -12
  48. data/app/models/drgcms_form_fields/text_with_select.rb +1 -0
  49. data/app/renderers/dc_common_renderer.rb +20 -3
  50. data/app/renderers/dc_part_renderer.rb +1 -1
  51. data/app/renderers/dc_poll_renderer.rb +1 -1
  52. data/app/views/cmsedit/_edit_stuff.html.erb +12 -12
  53. data/app/views/cmsedit/_form.html.erb +19 -12
  54. data/app/views/cmsedit/edit.html.erb +10 -6
  55. data/app/views/cmsedit/index.html.erb +5 -3
  56. data/app/views/cmsedit/login.html.erb +1 -1
  57. data/app/views/cmsedit/new.html.erb +9 -5
  58. data/app/views/dc_common/_help.html.erb +1 -0
  59. data/app/views/dc_common/paste_clipboard.html.erb +1 -1
  60. data/app/views/layouts/cms.html.erb +3 -5
  61. data/config/locales/drgcms_en.yml +7 -1
  62. data/config/locales/drgcms_sl.yml +7 -1
  63. data/config/locales/kaminari.yml +1 -1
  64. data/drg_cms.gemspec +2 -2
  65. data/lib/drg_cms/version.rb +1 -1
  66. data/lib/drg_cms.rb +4 -4
  67. metadata +16 -10
  68. data/app/views/cmsedit/__remove_edit_stuff.js.erb +0 -6
  69. 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
- # start div with hidden spinner image
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 = @parms.clone
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' and yaml['url']
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
- yhtml = yaml['html'] || {}
86
- yhtml['title'] = yaml['title'] if yaml['title']
87
- code = case
80
+ html_options = yaml['html'] || {}
81
+ html_options['title'] = yaml['title'] if yaml['title']
82
+ case
88
83
  # sort
89
- when action == 'sort' then
90
- choices = [['id','id']]
84
+ when action == 'sort'
85
+ choices = [%w[id id]]
91
86
  if @form['index']['sort']
92
- @form['index']['sort'].split(',').each do |s|
93
- s.strip!
94
- choices << [ t("helpers.label.#{@form['table']}.#{s}"), s ]
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
- fa_icon('sort-alpha-asc') + ' ' + t('drgcms.sort') + ' ' +
98
- select('sort', 'sort', choices, { include_blank: true },
99
- { class: 'drgcms_sort', 'data-table' => @form['table'], 'data-form' => params['form_name']} )
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' then
103
- caption = t('drgcms.filter')
104
- caption << '&nbsp;' + fa_icon('caret-down lg') + DcFilter.menu_filter(self)
105
- # add filter OFF link
106
- sess = session[@form['table']]
107
- if sess and sess[:filter]
108
- caption << '&nbsp;&nbsp;' + dc_link_to(nil,'remove lg',
109
- { controller: 'cmsedit', filter: 'off', table: @form['table'], form_name: params['form_name'] },
110
- { title: DcFilter.title4_filter_off(sess[:filter]) })
111
- end
112
- caption
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' then
112
+ when action == 'new'
116
113
  caption = yaml['caption'] || 'drgcms.new'
117
- html << "<li class=\"dc-link plus-link dc-animate\">#{dc_link_to(caption, 'plus', url, yhtml )}</li>"
118
- next
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 == 'close' then
121
- html << %(<li class="dc-link dc-animate" onclick="window.close();"'>#{fa_icon('close')} #{t('drgcms.close')}</li>)
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' then
126
- if options['caption']
127
- caption = t(options['caption'], options['caption']) + '&nbsp;' + fa_icon('caret-down lg')
128
- caption + eval(options['eval'])
129
- else # when caption is false, provide own actions
130
- eval(options['eval'])
131
- end
124
+ when action == 'menu'
125
+ code = if options['caption']
126
+ caption = t(options['caption'], options['caption']) + '&nbsp;' + 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 = @parms.clone
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
- html << dc_script_action(options)
144
- next
144
+ html_left << dc_script_action(options)
145
145
 
146
146
  when action == 'field'
147
- html << dc_field_action(yaml)
148
- next
147
+ html_right << dc_field_action(yaml)
149
148
 
150
- when %w(ajax link window submit).include?(action)
151
- html << dc_link_ajax_window_submit_action(options, nil)
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['caption'] || yaml['text']
156
- icon = yaml['icon'] ? yaml['icon'] : action
157
- dc_link_to(caption, icon, url, yhtml)
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
- html << '</ul></form>'
163
- html.html_safe
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 = (@form['index'] and @form['index']['filter']) ? @form['index']['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
- a = f.split(' ')
179
- name = a.first
180
- f = a.last
181
- end
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']] and session[@form['table']][:filter]
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
- #{ form_tag :table => @form['table'], filter: :on, filter_input: 1, action: :index, method: :post }
192
- url = url_for(table: @form['table'],form_name: params['form_name'], filter: :on, filter_input: 1, action: :index, controller: :cmsedit)
193
- html =<<EOT
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-animate drgcms_popup_submit" data-url="#{url}">#{fa_icon('check-square-o')} #{t('drgcms.filter_on')}</div>
201
- <div class="dc-link dc-animate">#{dc_link_to('drgcms.filter_off','close', {action: :index, filter: 'off', table: @form['table'], form_name: params['form_name']}) }</div>
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 = %Q[<div class="filter-popup" style="display: none;">
213
- <div>#{t('drgcms.filter_set')}</div>
214
- <ul>]
215
- url = url_for(table: @form['table'],form_name: params['form_name'], filter: :on, filter_input: 1, action: :index, controller: :cmsedit)
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
- width = @form['result_set']['actions_width'] || 18*actions.size
259
- [actions, width]
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
- %Q[<div class="actions" style="width: #{width}px;"></div>].html_safe
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
- html = %Q[<ul class="actions" style="width: #{width}px;">]
281
- actions.sort_by(&:first).each do |k, v|
282
- session[:form_processing] = "result_set:actions: #{k}=#{v}"
283
- parms = @parms.clone
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 = v.class == String ? { 'type' => v } : v
286
- # code already includes li tag
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 << dc_link_ajax_window_submit_action(yaml, document)
301
+ html = dc_link_ajax_window_submit_action(yaml, document)
290
302
  else
291
- html << '<li class="dc-link">'
292
- html << case
293
- when yaml['type'] == 'check' then
294
- check_box_tag("check-#{document.id}", false,false,{ class: 'dc-check' })
295
-
296
- when yaml['type'] == 'edit' then
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'] = document.id
299
- dc_link_to( nil, 'pencil lg', parms )
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 yaml['type'] == 'duplicate' then
302
- parms['id'] = document.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( nil, 'copy lg', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post )
328
+ dc_link_to( caption, 'content_copy-o', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post, title: title )
307
329
 
308
- when yaml['type'] == 'delete' then
330
+ when 'delete' then
309
331
  parms['action'] = 'destroy'
310
- parms['id'] = document.id
311
- #parms['return_to'] = request.url
312
- dc_link_to( nil, 'remove lg', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete )
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
- html << '</ul>'
329
- html.html_safe
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'] and !@form['readonly']
338
- ignore, width = dc_actions_column()
339
- if width > 0 && @form['result_set']['actions'][0].to_s == 'check'
340
- check_all = fa_icon('check-square-o', class: 'dc-check-all')
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 |k, v|
352
- session[:form_processing] = "result_set:columns: #{k}=#{v}"
353
- next if v['width'].to_s.match(/hidden|none/i)
354
-
355
- th = %Q[<div class="th" style="width:#{v['width'] || '15%'};text-align:#{v['align'] || 'left'};" data-name="#{v['name']}"]
356
- label = v['caption'] || v['label']
357
- label = (v['name'] ? "helpers.label.#{@form['table']}.#{v['name']}" : '') if label.nil?
358
- label = t(label) if label.match(/\./)
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?(v['sort'], false)
364
- if @tables.size == 1 and sort_ok
365
- icon = 'sort lg'
366
- if v['name'] == sort_field
367
- icon = sort_direction == '1' ? 'sort-alpha-asc lg' : 'sort-alpha-desc lg'
368
- end
369
- th << ">#{dc_link_to(label, icon, sort: v['name'], table: params[:table], form_name: params[:form_name], action: :index, icon_pos: :last )}</div>"
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 << "<div class=\"spacer\"></div>" + th
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), table: params[:table],
400
- form_name: params[:form_name]) ) if @form['form']
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
- # eval
453
- value = if v['eval']
454
- dc_process_column_eval(v, document)
455
- # as field
456
- elsif document.respond_to?(v['name'])
457
- dc_format_value(document.send( v['name'] ), v['format'])
458
- # as hash (dc_memory)
459
- elsif document.class == Hash
460
- dc_format_value(document[ v['name'] ], v['format'])
461
- # error
462
- else
463
- "??? #{v['name']}"
464
- end
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[yaml['name']])
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
- method = @form['result_set']['eval']
610
- if respond_to?(method)
611
- send method
643
+ if @form['result_set']['view']
644
+ render partial: @form['result_set']['view']
612
645
  else
613
- I18n.t('drgcms.no_method', method: method)
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