drg_cms 0.6.1.6 → 0.6.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +203 -24
  3. data/app/assets/javascripts/drg_cms/drg_cms.js +183 -95
  4. data/app/assets/stylesheets/drg_cms/drg_cms.css +542 -509
  5. data/app/assets/stylesheets/drg_cms_application.css +1 -1
  6. data/app/assets/stylesheets/drg_cms_cms.css +1 -4
  7. data/app/controllers/cmsedit_controller.rb +25 -103
  8. data/app/controllers/dc_common_controller.rb +6 -5
  9. data/app/controls/browse_models_control.rb +15 -26
  10. data/app/controls/cmsedit_control.rb +125 -0
  11. data/app/controls/dc_help_control.rb +1 -1
  12. data/app/controls/dc_page_control.rb +0 -1
  13. data/app/controls/dc_poll_result_control.rb +1 -1
  14. data/app/controls/dc_report.rb +1 -1
  15. data/app/forms/all_options.yml +1 -1
  16. data/app/forms/cms_menu.yml +24 -24
  17. data/app/forms/dc_browse_fields.yml +13 -9
  18. data/app/forms/dc_poll_result_export.yml +1 -1
  19. data/app/helpers/cms_common_helper.rb +7 -5
  20. data/app/helpers/cms_edit_helper.rb +52 -45
  21. data/app/helpers/cms_helper.rb +76 -40
  22. data/app/helpers/cms_index_helper.rb +180 -139
  23. data/app/helpers/dc_application_helper.rb +37 -43
  24. data/app/models/concerns/dc_page_concern.rb +1 -1
  25. data/app/models/dc_filter.rb +30 -22
  26. data/app/models/dc_json_ld.rb +1 -1
  27. data/app/models/dc_part.rb +19 -9
  28. data/app/models/drgcms_form_fields/drgcms_field.rb +10 -4
  29. data/app/models/drgcms_form_fields/link_to.rb +1 -1
  30. data/app/models/drgcms_form_fields/multitext_autocomplete.rb +5 -5
  31. data/app/models/drgcms_form_fields/readonly.rb +3 -0
  32. data/app/models/drgcms_form_fields/select.rb +8 -7
  33. data/app/models/drgcms_form_fields/text_autocomplete.rb +2 -2
  34. data/app/renderers/dc_part_renderer.rb +1 -1
  35. data/app/renderers/dc_poll_renderer.rb +1 -1
  36. data/app/views/cmsedit/_edit_stuff.html.erb +12 -12
  37. data/app/views/cmsedit/login.html.erb +1 -1
  38. data/app/views/dc_common/paste_clipboard.html.erb +1 -1
  39. data/config/locales/drgcms_en.yml +2 -1
  40. data/config/locales/drgcms_sl.yml +2 -1
  41. data/config/locales/kaminari.yml +1 -1
  42. data/drg_cms.gemspec +1 -1
  43. data/lib/drg_cms/version.rb +1 -1
  44. data/lib/drg_cms.rb +4 -4
  45. metadata +4 -5
  46. data/app/views/cmsedit/__remove_edit_stuff.js.erb +0 -6
  47. 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 }
@@ -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,53 +77,57 @@ 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
+ html_right << %(<li><div class="dc-sort">#{data}</li>)
100
95
 
101
96
  # 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
97
+ when action == 'filter'
98
+ table = session[@form['table']]
99
+ url = table&.dig(:filter) ?
100
+ url_for(controller: 'cmsedit', action: 'run', control: 'cmsedit.filter_off', t: @form['table'], f: CmsHelper.form_param(params)) :
101
+ ''
102
+ html_right << %(
103
+ <li>
104
+ <div class="dc-filter" title="#{DcFilter.title4_filter_off(table)}" data-url="#{url.html_safe}">
105
+ #{mi_icon(url.blank? ? 'search' : 'search_off') }#{DcFilter.menu_filter(self).html_safe}
106
+ </div>
107
+ </li>#{DcFilter.get_filter_field(self)}).html_safe
113
108
 
114
109
  # new
115
- when action == 'new' then
110
+ when action == 'new'
116
111
  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
112
+ html_options['class'] = 'dc-link'
113
+ html_left << "<li>#{dc_link_to(caption, 'add', url, html_options)}</li>"
114
+
115
+ when action == 'close'
116
+ html_left << %(<li><div class="dc-link" onclick="window.close();"'>#{fa_icon('close')} #{t('drgcms.close')}</div></li>)
119
117
 
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
118
+ when action == 'back'
119
+ html_left << %(<li><div class="dc-link" onclick="history.back();"'>#{fa_icon('arrow_back')} #{t('drgcms.back')}</div></li>)
123
120
 
124
121
  # 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
122
+ when action == 'menu'
123
+ code = if options['caption']
124
+ caption = t(options['caption'], options['caption']) + '&nbsp;' + fa_icon('caret-down')
125
+ caption + eval(options['eval'])
126
+ else # when caption is false, provide own actions
127
+ eval(options['eval'])
128
+ end
129
+ html_left << %(<li><div class="dc-link">#{code}</div></li>)
130
+
132
131
  =begin
133
132
  # reorder
134
133
  when action == 'reorder' then
@@ -140,27 +139,34 @@ def dc_actions_for_index
140
139
  dc_link_to( caption, 'reorder', parms, method: :delete )
141
140
  =end
142
141
  when action == 'script'
143
- html << dc_script_action(options)
144
- next
142
+ html_left << dc_script_action(options)
145
143
 
146
144
  when action == 'field'
147
- html << dc_field_action(yaml)
148
- next
145
+ html_right << dc_field_action(yaml)
149
146
 
150
- when %w(ajax link window submit).include?(action)
151
- html << dc_link_ajax_window_submit_action(options, nil)
152
- next
147
+ when %w(ajax link window popup submit).include?(action)
148
+ html_left << dc_link_ajax_window_submit_action(options, nil)
153
149
 
154
150
  else
155
- caption = yaml['caption'] || yaml['text']
156
- icon = yaml['icon'] ? yaml['icon'] : action
157
- dc_link_to(caption, icon, url, yhtml)
151
+ caption = dc_get_caption(yaml) || t("drgcms.#{action}")
152
+ icon = yaml['icon'] || action
153
+ html_options['class'] = 'dc-link'
154
+ code = dc_link_to(caption, icon, url, html_options)
155
+ html_left << %(<li>#{code}</li>)
158
156
  end
159
- html << "<li class=\"dc-link dc-animate\">#{code}</li>"
160
- html << DcFilter.get_filter_field(self) if action == 'filter'
161
157
  end
162
- html << '</ul></form>'
163
- html.html_safe
158
+
159
+ %(
160
+ <form id="dc-action-menu">
161
+ <span class="dc-spinner">#{fa_icon('settings-o spin')}</span>
162
+
163
+ <div class="dc-action-menu">
164
+ <ul class="dc-left">#{html_left}</ul>
165
+ <ul class="dc-right">#{html_right}</ul>
166
+ </div>
167
+ <div style="clear: both;"></div>
168
+ </form>
169
+ ).html_safe
164
170
  end
165
171
 
166
172
  ############################################################################
@@ -168,53 +174,53 @@ end
168
174
  ############################################################################
169
175
  def dc_div_filter
170
176
  choices = []
171
- filter = (@form['index'] and @form['index']['filter']) ? @form['index']['filter'] + ',' : ''
177
+ filter = @form['index'] && @form['index']['filter'] ? @form['index']['filter'] + ',' : ''
172
178
  filter << 'id as text_field' # filter id is added by default
173
179
  filter.split(',').each do |f|
174
180
  f.strip!
175
181
  name = f.match(' as ') ? f.split(' ').first : f
176
182
  # 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 ]
183
+ name, like, f = f.split(' ') if f.match(' like ')
184
+ choices << [ t("helpers.label.#{@form['table']}.#{name}", name), f ]
185
+ end
186
+ choices4_operators = t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) do |r, v|
187
+ r << (v.match(':') ? v.split(':') : v )
183
188
  end
184
- choices4_operators = t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )}
185
189
  # currently selected options
186
- if session[@form['table']] and session[@form['table']][:filter]
190
+ if session[@form['table']] && session[@form['table']][:filter]
187
191
  field_name, operators_value, dummy = session[@form['table']][:filter].split("\t")
188
192
  else
189
193
  field_name, operators_value = nil, nil
190
194
  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
195
+ url_on = url_for(controller: 'cmsedit', action: :run, control: 'cmsedit.filter_on' ,
196
+ t: CmsHelper.table_param(params), f: CmsHelper.form_param(params), filter_input: 1)
197
+ url_off = url_for(controller: 'cmsedit', action: :run, control: 'cmsedit.filter_off',
198
+ t: CmsHelper.table_param(params), f: CmsHelper.form_param(params))
199
+ %(
194
200
  <div id="drgcms_filter" class="div-hidden">
195
201
  <h1>#{t('drgcms.filter_set')}</h1>
196
202
 
197
203
  #{ select(nil, 'filter_field1', options_for_select(choices, field_name), { include_blank: true }) }
198
204
  #{ select(nil, 'filter_oper', options_for_select(choices4_operators, operators_value)) }
199
205
  <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>
206
+ <div class="dc-link dc-filter-set" data-url="#{url_on}">#{fa_icon('done')} #{t('drgcms.filter_on')}</div>
207
+ <div class="dc-link-ajax" data-url="#{url_off}">
208
+ #{mi_icon('close')}#{t('drgcms.filter_off')}
209
+ </div>
202
210
  </div>
203
- </div>
204
- EOT
205
- html.html_safe
211
+ </div>).html_safe
206
212
  end
207
213
 
208
214
  ############################################################################
209
215
  # Creates popup div for setting filter on result set header.
210
216
  ############################################################################
211
217
  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)
218
+ html = %(<div class="filter-popup" style="display: none;"><div>#{t('drgcms.filter_set')}</div><ul>)
219
+ url = url_for(controller: 'cmsedit', action: 'run', control: 'cmsedit.filter_on',
220
+ t: @form['table'], f: params['form_name'], filter_input: 1)
221
+
216
222
  t('drgcms.choices4_filter_operators').chomp.split(',').each do |operator_choice|
217
- caption,choice = operator_choice.split(':')
223
+ caption, choice = operator_choice.split(':')
218
224
  html << %Q[<li data-operator="#{choice}" data-url="#{url}">#{caption}</li>]
219
225
  end
220
226
  html << "</ul></div>"
@@ -245,18 +251,20 @@ end
245
251
  ############################################################################
246
252
  def dc_actions_column
247
253
  actions = @form['result_set']['actions']
248
- return [{}, 0] if actions.nil? || dc_dont?(actions)
254
+ return [{}, 0, false] if actions.nil? || dc_dont?(actions)
249
255
 
250
256
  # standard actions
251
- actions = {'standard' => true} if actions.class == String && actions == 'standard'
257
+ actions = { 'standard' => true } if actions.class == String && actions == 'standard'
252
258
  std_actions = { 2 => 'edit', 5 => 'delete' }
253
259
  if actions['standard']
254
260
  actions.merge!(std_actions)
255
261
  actions.delete('standard')
256
262
  end
257
-
258
- width = @form['result_set']['actions_width'] || 18*actions.size
259
- [actions, width]
263
+ # check must be first action
264
+ has_check = actions.first[1] == 'check'
265
+ width = actions.size == 1 ? 22 : 44
266
+ width = 22 if actions.size > 2 and !has_check
267
+ [actions, width, has_check]
260
268
  end
261
269
 
262
270
  ############################################################################
@@ -265,8 +273,8 @@ end
265
273
  def dc_actions_column_for_footer
266
274
  return '' unless @form['result_set']['actions']
267
275
 
268
- ignore, width = dc_actions_column
269
- %Q[<div class="actions" style="width: #{width}px;"></div>].html_safe
276
+ ignore, width, ignore2 = dc_actions_column
277
+ %(<div class="dc-result-actions" style="width: #{width}px;"></div>).html_safe
270
278
  end
271
279
 
272
280
  ############################################################################
@@ -276,57 +284,75 @@ def dc_actions_for_result(document)
276
284
  actions = @form['result_set']['actions']
277
285
  return '' if actions.nil? || @form['readonly']
278
286
 
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}"
287
+ actions, width, has_check = dc_actions_column()
288
+ has_sub_menu = actions.size > 2 || (has_check && actions.size > 1)
289
+
290
+ main_menu, sub_menu = '', ''
291
+ actions.sort_by(&:first).each do |num, action|
292
+ session[:form_processing] = "result_set:actions: #{num}=#{action}"
283
293
  parms = @parms.clone
284
294
  # 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'])
295
+ yaml = action.class == String ? { 'type' => action } : action
296
+
297
+ if %w(ajax link window popup submit).include?(yaml['type'])
288
298
  @record = document # otherwise document fields can't be used as parameters
289
- html << dc_link_ajax_window_submit_action(yaml, document)
299
+ html = dc_link_ajax_window_submit_action(yaml, document)
290
300
  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
301
+ caption = dc_get_caption(yaml) || "drgcms.#{yaml['type']}"
302
+ title = t(yaml['help'] || caption, '')
303
+ caption = has_sub_menu ? t(caption, '') : nil
304
+ html = '<li>'
305
+ html << case yaml['type']
306
+ when 'check' then
307
+ main_menu << '<li>' + check_box_tag("check-#{document.id}", false, false, { class: 'dc-check' }) + '</li>'
308
+ next
309
+
310
+ when 'edit' then
297
311
  parms['action'] = 'edit'
298
- parms['id'] = document.id
299
- dc_link_to( nil, 'pencil lg', parms )
312
+ parms['id'] = document.id
313
+ dc_link_to( caption, 'edit-o', parms, title: title )
314
+
315
+ when 'show' then
316
+ parms['action'] = 'show'
317
+ parms['id'] = document.id
318
+ parms['readonly'] = true
319
+ dc_link_to( caption, 'eye', parms, title: title )
300
320
 
301
- when yaml['type'] == 'duplicate' then
302
- parms['id'] = document.id
321
+ when 'duplicate' then
322
+ parms['id'] = document.id
303
323
  # duplicate string will be added to these fields.
304
324
  parms['dup_fields'] = yaml['dup_fields']
305
325
  parms['action'] = 'create'
306
- dc_link_to( nil, 'copy lg', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post )
326
+ dc_link_to( caption, 'content_copy-o', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post, title: title )
307
327
 
308
- when yaml['type'] == 'delete' then
328
+ when 'delete' then
309
329
  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
-
330
+ parms['id'] = document.id
331
+ dc_link_to( caption, 'delete-o', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete, title: title )
332
+
322
333
  else # error.
323
334
  yaml['type'].to_s
324
335
  end
325
336
  html << '</li>'
326
337
  end
338
+
339
+ if has_sub_menu
340
+ sub_menu << html
341
+ else
342
+ main_menu << html
343
+ end
327
344
  end
328
- html << '</ul>'
329
- html.html_safe
345
+
346
+ if has_sub_menu
347
+ %(
348
+ <ul class="dc-result-actions" style="width: #{width}px;">#{main_menu}
349
+ <li><div class="dc-result-submenu">#{fa_icon('more_vert')}
350
+ <ul id="menu-#{document.id}">#{sub_menu}</ul>
351
+ </div></li>
352
+ </ul>)
353
+ else
354
+ %(<ul class="dc-result-actions" style="width: #{width}px;">#{main_menu}</ul>)
355
+ end.html_safe
330
356
  end
331
357
 
332
358
  ############################################################################
@@ -334,12 +360,10 @@ end
334
360
  ############################################################################
335
361
  def dc_header_for_result
336
362
  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>]
363
+ if @form['result_set']['actions'] && !@form['readonly']
364
+ ignore, width, has_check = dc_actions_column()
365
+ check_all = fa_icon('check-square-o', class: 'dc-check-all') if has_check
366
+ html << %(<div class="dc-result-actions" style="width:#{width}px;">#{check_all}</div>)
343
367
  end
344
368
  # preparation for sort icon
345
369
  sort_field, sort_direction = nil, nil
@@ -352,25 +376,32 @@ def dc_header_for_result
352
376
  session[:form_processing] = "result_set:columns: #{k}=#{v}"
353
377
  next if v['width'].to_s.match(/hidden|none/i)
354
378
 
355
- th = %Q[<div class="th" style="width:#{v['width'] || '15%'};text-align:#{v['align'] || 'left'};" data-name="#{v['name']}"]
379
+ th = %(<div class="th" style="width:#{v['width'] || '15%'};text-align:#{v['align'] || 'left'};" data-name="#{v['name']}")
356
380
  label = v['caption'] || v['label']
357
381
  label = (v['name'] ? "helpers.label.#{@form['table']}.#{v['name']}" : '') if label.nil?
358
382
  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?)
383
+ # no sorting when embedded documents or custom filter is active
361
384
  sort_ok = !dc_dont?(@form['result_set']['sort'], false)
362
385
  sort_ok = sort_ok || (@form['index'] && @form['index']['sort'])
363
386
  sort_ok = sort_ok && !dc_dont?(v['sort'], false)
364
- if @tables.size == 1 and sort_ok
365
- icon = 'sort lg'
387
+ if @tables.size == 1 && sort_ok
388
+ icon = 'sort_unset md-18'
389
+ filter_class = form_has_input_field?(v['name']) ? nil : 'no-filter'
366
390
  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>"
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: v['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
@@ -532,7 +563,7 @@ def dc_process_column_eval(yaml, document)
532
563
 
533
564
  # defined in helpers. For example dc_icon_for_boolean
534
565
  elsif respond_to?(yaml['eval'])
535
- send(yaml['eval'], document[yaml['name']])
566
+ send(yaml['eval'], document, yaml['name'])
536
567
 
537
568
  # defined in model
538
569
  elsif document.respond_to?(yaml['eval'])
@@ -618,4 +649,14 @@ def dc_process_result_set_method
618
649
  end
619
650
  end
620
651
 
652
+ ############################################################################
653
+ # Check if form has defined input field for field_name and that is not readonly field.
654
+ ############################################################################
655
+ def form_has_input_field?(field_name)
656
+ field = dc_get_field_form_definition(field_name)
657
+ return if field.nil?
658
+
659
+ !(field['type'] == 'readonly' || field['readonly'])
660
+ end
661
+
621
662
  end