drg_cms 0.6.0.8 → 0.6.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -10
  3. data/app/assets/javascripts/drg_cms/drg_cms.js +208 -81
  4. data/app/assets/stylesheets/drg_cms/drg_cms.css +298 -93
  5. data/app/assets/stylesheets/drg_cms/select-multiple.css +1 -1
  6. data/app/controllers/cmsedit_controller.rb +174 -167
  7. data/app/controllers/dc_application_controller.rb +230 -196
  8. data/app/controllers/dc_common_controller.rb +88 -50
  9. data/app/controls/dc_help_control.rb +138 -0
  10. data/app/controls/dc_report.rb +12 -16
  11. data/app/forms/all_options.yml +14 -5
  12. data/app/forms/cms_menu.yml +7 -1
  13. data/app/forms/dc_big_table.yml +0 -2
  14. data/app/forms/dc_big_table_value.yml +0 -2
  15. data/app/forms/dc_category.yml +2 -1
  16. data/app/forms/dc_design.yml +2 -2
  17. data/app/forms/dc_folder_permission.yml +0 -2
  18. data/app/forms/dc_help_1.yml +110 -0
  19. data/app/forms/dc_journal.yml +3 -1
  20. data/app/forms/dc_json_ld.yml +0 -3
  21. data/app/forms/dc_link.yml +1 -1
  22. data/app/forms/dc_menu.yml +8 -12
  23. data/app/forms/dc_menu_item.yml +2 -3
  24. data/app/forms/dc_page.yml +7 -2
  25. data/app/forms/dc_part.yml +1 -0
  26. data/app/forms/dc_piece.yml +1 -0
  27. data/app/forms/dc_policy.yml +2 -5
  28. data/app/forms/dc_poll.yml +13 -16
  29. data/app/forms/dc_seo.yml +1 -2
  30. data/app/forms/dc_simple_menu.yml +3 -2
  31. data/app/forms/dc_site.yml +5 -8
  32. data/app/forms/dc_user.yml +27 -11
  33. data/app/forms/dc_user_role.yml +3 -0
  34. data/app/helpers/cms_common_helper.rb +68 -4
  35. data/app/helpers/cms_edit_helper.rb +73 -55
  36. data/app/helpers/cms_helper.rb +70 -32
  37. data/app/helpers/cms_index_helper.rb +155 -102
  38. data/app/helpers/dc_application_helper.rb +132 -109
  39. data/app/models/concerns/dc_page_concern.rb +14 -4
  40. data/app/models/concerns/dc_piece_concern.rb +1 -1
  41. data/app/models/concerns/dc_policy_rule_concern.rb +20 -8
  42. data/app/models/concerns/dc_site_concern.rb +56 -44
  43. data/app/models/concerns/dc_user_concern.rb +58 -19
  44. data/app/models/dc_big_table.rb +2 -2
  45. data/app/models/dc_design.rb +29 -19
  46. data/app/models/dc_filter.rb +28 -22
  47. data/app/models/dc_key_value_store.rb +1 -0
  48. data/app/models/dc_permission.rb +19 -9
  49. data/app/models/dc_policy.rb +25 -14
  50. data/app/models/dc_policy_role.rb +22 -11
  51. data/app/models/dc_temp.rb +8 -1
  52. data/app/models/dc_user_role.rb +2 -2
  53. data/app/models/drgcms_form_fields/comment.rb +11 -2
  54. data/app/models/drgcms_form_fields/date_picker.rb +2 -0
  55. data/app/models/drgcms_form_fields/drgcms_field.rb +2 -1
  56. data/app/models/drgcms_form_fields/embedded.rb +9 -10
  57. data/app/models/drgcms_form_fields/file_field.rb +1 -1
  58. data/app/models/drgcms_form_fields/file_select.rb +2 -2
  59. data/app/models/drgcms_form_fields/hash_field.rb +11 -7
  60. data/app/models/drgcms_form_fields/link_to.rb +2 -2
  61. data/app/models/drgcms_form_fields/method.rb +5 -4
  62. data/app/models/drgcms_form_fields/multitext_autocomplete.rb +1 -1
  63. data/app/models/drgcms_form_fields/number_field.rb +4 -3
  64. data/app/models/drgcms_form_fields/readonly.rb +13 -17
  65. data/app/models/drgcms_form_fields/select.rb +24 -25
  66. data/app/models/drgcms_form_fields/text_autocomplete.rb +22 -14
  67. data/app/renderers/dc_page_renderer.rb +7 -6
  68. data/app/renderers/dc_poll_renderer.rb +16 -20
  69. data/app/views/cmsedit/_edit_stuff.html.erb +5 -2
  70. data/app/views/cmsedit/_form.html.erb +3 -2
  71. data/app/views/cmsedit/_result.html.erb +21 -18
  72. data/app/views/cmsedit/edit.html.erb +4 -1
  73. data/app/views/cmsedit/index.html.erb +3 -2
  74. data/app/views/cmsedit/new.html.erb +5 -2
  75. data/app/views/dc_common/_help.html.erb +17 -0
  76. data/app/views/layouts/models.html.erb +2 -1
  77. data/config/locales/drgcms_en.yml +17 -2
  78. data/config/locales/drgcms_sl.yml +20 -2
  79. data/config/locales/models_en.yml +7 -5
  80. data/config/locales/models_sl.yml +12 -9
  81. data/drg_cms.gemspec +16 -16
  82. data/lib/drg_cms/version.rb +1 -1
  83. data/lib/drg_cms.rb +94 -2
  84. metadata +32 -30
  85. data/app/models/__dc_dummy.rb +0 -102
@@ -33,11 +33,13 @@ module CmsEditHelper
33
33
  # Will return value when internal or additional parameters are defined in action
34
34
  # Subroutine of dc_actions_for_form.
35
35
  ############################################################################
36
- def dc_value_for_parameter(param)#:nodoc:
36
+ def dc_value_for_parameter(param, current_document = nil)#:nodoc:
37
37
  if param.class == Hash
38
- dc_internal_var(param['object'] || 'record', param['method'])
38
+ dc_internal_var(param['object'] ||= 'record', param['method'], current_document)
39
+ elsif param.to_s.match(/record|document/)
40
+ current_document ? current_document : @record
39
41
  else
40
- param
42
+ param
41
43
  end
42
44
  end
43
45
 
@@ -51,9 +53,10 @@ end
51
53
  def dc_is_action_active?(options)
52
54
  if options['when_new']
53
55
  dc_deprecate("when_option will be deprecated and replaced by active: not_new_record! Form #{params[:form_name]}")
54
- return !(dc_dont?(options['when_new']) and @record.new_record?)
56
+ return !(dc_dont?(options['when_new']) && @record.new_record?)
55
57
  end
56
58
  return true unless options['active']
59
+
57
60
  # alias record and document so both can be used in eval
58
61
  record = document = @record
59
62
  option = options['active']
@@ -65,8 +68,7 @@ def dc_is_action_active?(options)
65
68
  (@record.new_record? && option == 'new_record') || (!@record.new_record? && option == 'not_new_record')
66
69
  elsif option.match(/\./)
67
70
  # shortcut for method and eval option
68
- parms = @record ? @record : params
69
- dc_process_eval(option,parms)
71
+ dc_process_eval(option, self)
70
72
  else
71
73
  eval(option['eval'])
72
74
  end
@@ -74,9 +76,8 @@ def dc_is_action_active?(options)
74
76
  when option['eval'] then
75
77
  eval(option['eval'])
76
78
  when option['method'] then
77
- # if record present send record otherwise send params as parameter
78
- parms = @record ? @record : params
79
- dc_process_eval(option['method'],parms)
79
+ # if record present send record otherwise send self as parameter
80
+ dc_process_eval(option['method'], self)
80
81
  else
81
82
  false
82
83
  end
@@ -90,32 +91,40 @@ end
90
91
  # normal link.
91
92
  ############################################################################
92
93
  def dc_actions_for_form(position)
93
- # create standard actions
94
+ # create standard actions
94
95
  std_actions = {1 => 'back', 2 => {'type' => 'submit', 'caption' => 'drgcms.save'},
95
96
  3 => {'type' => 'submit', 'caption' => 'drgcms.save&back'} }
96
- # when edit only
97
+ # when edit only
97
98
  unless @record.try(:id).nil?
98
99
  std_actions.merge!({6 => 'new'} )
99
100
  std_actions.merge!(@record.active ? {5 => 'disable'} : {5 => 'enable'} ) if @record.respond_to?('active')
100
101
  std_actions.merge!({7 => 'refresh'} )
101
102
  end
103
+ # readonly
104
+ std_actions = { 1 => 'back' } if @form['readonly']
105
+
102
106
  actions = @form['form']['actions']
103
- # shortcut for actions: standard
107
+ # shortcut for actions: standard
104
108
  actions = nil if actions.class == String && actions == 'standard'
105
- # standard actions
106
109
  actions = std_actions if actions.nil?
107
- # readonly
108
- actions = {1 => 'back'} if @form['readonly']
109
- actions = {1 => 'close'} if params[:window_close]
110
- # Actions are strictly forbidden
111
- if @form['form']['actions'] and dc_dont?(@form['form']['actions'])
110
+
111
+ # Actions are strictly forbidden
112
+ if @form['form']['actions'] && dc_dont?(@form['form']['actions'])
112
113
  actions = []
113
114
  elsif actions['standard']
114
115
  actions.merge!(std_actions)
115
116
  actions['standard'] = nil
116
117
  end
117
- # Update save and save&back
118
- actions.each do |k,v|
118
+ # request for close window button present
119
+ if actions.class == Hash
120
+ case params[:window_close]
121
+ when '0' then actions[1] = 'close'; actions[3] = nil
122
+ when '1' then actions = { 1 => 'close' }
123
+ when '2' then actions = { 1 => 'close' }
124
+ end
125
+ end
126
+ # Update save and save&back
127
+ actions.each do |k, v|
119
128
  if v.class == String
120
129
  if v.match(/save\&back/i)
121
130
  actions[k] = {'type' => 'submit', 'caption' => 'drgcms.save&back'}
@@ -124,23 +133,23 @@ def dc_actions_for_form(position)
124
133
  end
125
134
  end
126
135
  end
127
- # remove standard option and sort so that standard actions come first
136
+ # remove standard option and sort so that standard actions come first
128
137
  actions.delete('standard')
129
- actions = actions.to_a.sort {|x,y| x[0] <=> y[0]}
130
- # Add spinner to the beginning
138
+ actions = actions.to_a.sort { |x, y| x[0] <=> y[0] }
139
+ # Add spinner to the beginning
131
140
  html = %Q[<span class="dc-spinner">#{fa_icon('spinner lg spin')}</span><ul class="dc-menu #{position}">]
132
-
141
+
133
142
  actions.each do |key, options|
134
143
  session[:form_processing] = "form:actions: #{key} #{options}"
135
- next if options.nil? # yes it happends
144
+ next if options.nil? # yes it happens
136
145
  parms = @parms.clone
137
146
  if options.class == String
138
- next if params[:readonly] and !options.match(/back|close/)
147
+ next if @form['readonly'] and !options.match(/back|close/)
139
148
 
140
149
  html << '<li class="dc-link dc-animate">'
141
150
  html << case
142
151
  when (options == 'back' or options == 'cancle') then
143
- # If return_to is present link directly to URL
152
+ # If return_to is present link directly to URL
144
153
  if parms['xreturn_to'] # disabled for now
145
154
  dc_link_to( 'drgcms.back','arrow-left', parms['return_to'] )
146
155
  else
@@ -185,6 +194,9 @@ def dc_actions_for_form(position)
185
194
  html << '</td>'
186
195
  # non standard actions
187
196
  else
197
+ # action will be displayed when show: always or readonly option is declared and form is readonly
198
+ next if @form['readonly'] && !%w[readonly always].include?(options['show'].to_s)
199
+
188
200
  options['title'] = t("#{options['title'].downcase}", options['title']) if options['title']
189
201
  html << case
190
202
  # submit button
@@ -233,7 +245,7 @@ def dc_background_for_result(start)
233
245
  if start == :start
234
246
  html = '<div class="dc-result-div" '
235
247
  html << (@form['result_set']['table_style'] ? 'style="overflow-x: scroll;" >' : '>')
236
- #
248
+
237
249
  html << "\n<div class=\"dc-result #{@form['result_set']['table_class']}\" "
238
250
  html << (@form['result_set']['table_style'] ? "style=\"#{@form['result_set']['table_style']}\" >" : '>')
239
251
  else
@@ -295,13 +307,13 @@ def dc_fields_for_tab(fields_on_tab) #:nodoc:
295
307
  group_count = options['group'] || 1
296
308
  group_option = options['group'] || 1
297
309
  end
298
- #
310
+
299
311
  html << if labels_pos == 'top'
300
- %Q[
312
+ %(
301
313
  <div class="dc-form-label-top dc-color-#{odd_even} dc-align-left" title="#{help}">
302
314
  <label for="record_#{options['name']}">#{label} </label>
303
315
  <div id="td_record_#{options['name']}">#{field_html}</div>
304
- </div> ]
316
+ </div> )
305
317
  else
306
318
  # no label
307
319
  if dc_dont?(options['caption'])
@@ -314,13 +326,14 @@ def dc_fields_for_tab(fields_on_tab) #:nodoc:
314
326
  else
315
327
  label_width = 14
316
328
  data_width = 85
317
- end
318
- %Q[
329
+ end
330
+ help.gsub!('<br>',"\n") if help.present?
331
+ %(
319
332
  <div class="dc-form-label dc-color-#{odd_even} dc-align-#{labels_pos} dc-width-#{label_width}" title="#{help}">
320
333
  <label for="record_#{options['name']}">#{label} </label>
321
334
  </div>
322
335
  <div id="td_record_#{options['name']}" class="dc-form-field dc-color-#{odd_even} dc-width-#{data_width}">#{field_html}</div>
323
- ]
336
+ )
324
337
  end
325
338
  # check if group end
326
339
  if (group_count -= 1) == 0
@@ -335,9 +348,9 @@ def dc_fields_for_tab(fields_on_tab) #:nodoc:
335
348
  end
336
349
 
337
350
  ############################################################################
338
- # Creates edit form div.
351
+ # Creates edit form from fields or tabs options
339
352
  ############################################################################
340
- def dc_fields_for_form()
353
+ def dc_fields_for_form
341
354
  html, tabs, tab_data = '',[], ''
342
355
  @js ||= ''
343
356
  @css ||= ''
@@ -350,10 +363,10 @@ def dc_fields_for_form()
350
363
  first = true # first tab
351
364
  @form['form']['tabs'].keys.sort.each do |tab_name|
352
365
  next if tab_name.match('actions')
353
- # Tricky. If field name is not on the tab skip to next tab
366
+ # Tricky when editing single field. If field is not present on the tab skip to next tab
354
367
  if params[:edit_only]
355
368
  is_on_tab = false
356
- @form['form']['tabs'][tab_name].each {|k,v| is_on_tab = true if params[:edit_only] == v['name'] }
369
+ @form['form']['tabs'][tab_name].each { |k, v| is_on_tab = true if params[:edit_only] == v['name'] }
357
370
  next unless is_on_tab
358
371
  end
359
372
  # first div is displayed, all others are hidden
@@ -361,17 +374,18 @@ def dc_fields_for_form()
361
374
  tab_data << ' class="div-hidden"' unless first
362
375
  tab_data << " style=\"height: #{@form['form']['height']}px;\"" if @form['form']['height']
363
376
  tab_data << ">#{dc_fields_for_tab(@form['form']['tabs'][tab_name])}</div>"
364
- tab_label = @form['form']['tabs'][tab_name]['caption'] || tab_name
365
- tabs << [tab_name, tab_label]
377
+
378
+ tab_label, tab_title = dc_tab_label_help(tab_name)
379
+ tabs << [tab_name, tab_label, tab_title]
366
380
  first = false
367
381
  end
368
382
  # make it all work together
369
383
  html << '<ul class="dc-form-ul" >'
370
384
  first = true # first tab must be selected
371
- tabs.each do |tab_name, tab_label|
372
- html << "<li id=\"li_#{tab_name}\" data-div=\"#{tab_name.delete("\s\n")}\" class=\"dc-form-li"
373
- html << ' dc-form-li-selected' if first
374
- html << "\">#{t(tab_label, t_name(tab_label, tab_label))}</li>"
385
+ tabs.each do |tab_name, tab_label, tab_title|
386
+ html << %(<li id="li_#{tab_name}" data-div="#{tab_name.delete("\s\n")}" title="#{tab_title}" class="dc-form-li)
387
+ html << ' dc-form-li-selected' if first
388
+ html << "\">#{tab_label}</li>"
375
389
  first = false
376
390
  end
377
391
  html << '</ul>'
@@ -391,11 +405,11 @@ end
391
405
  # Creates head form div. Head form div is used to display header data usefull
392
406
  # to be seen even when tabs are switched.
393
407
  ############################################################################
394
- def dc_head_for_form()
408
+ def dc_head_for_form
395
409
  @css ||= ''
396
410
  head = @form['form']['head']
397
411
  return '' if head.nil?
398
- html = %Q[<div class="dc-head #{head['class']}">\n<div class="dc-row">]
412
+ html = %(<div class="dc-head #{head['class']}">\n<div class="dc-row">)
399
413
  split = head['split'] || 4
400
414
  percent = 100/split
401
415
  current = 0
@@ -421,7 +435,7 @@ def dc_head_for_form()
421
435
  @record.send(options['name'])
422
436
  end
423
437
  rescue Exception => e
424
- dc_log_exception(e)
438
+ dc_log_exception(e, 'dc_head_for_form')
425
439
  field = '!!!Error'
426
440
  end
427
441
  #
@@ -429,7 +443,7 @@ def dc_head_for_form()
429
443
  style = dc_style_or_class(nil, options['style'], field, @record)
430
444
  html << %Q[<div class="dc-column #{klass}" style="width:#{percent*span}%;#{style}">
431
445
  #{label.blank? ? '' : "<span class=\"label\">#{label}</span>"}
432
- <span class="field">#{field}</span>
446
+ <span id="head-#{options['name']}" class="field">#{field}</span>
433
447
  </div>]
434
448
  current += span
435
449
  if current == split
@@ -445,11 +459,10 @@ end
445
459
  # Returns username for id. Subroutine of dc_document_statistics
446
460
  ###########################################################################
447
461
  def dc_document_user_for(field_name) #:nodoc:
448
- if @record[field_name]
449
- u = DcUser.find(@record[field_name])
450
- return u ? u.name : @record[field_name]
451
- end
452
- # nil
462
+ return if @record[field_name].nil?
463
+
464
+ user = DcUser.find(@record[field_name])
465
+ user ? user.name : @record[field_name]
453
466
  end
454
467
 
455
468
  ############################################################################
@@ -471,8 +484,14 @@ def dc_document_statistics
471
484
  parms[:controller] = 'dc_common'
472
485
  parms[:action] = 'copy_clipboard'
473
486
  url = url_for(parms.permit!)
474
- html << fa_icon('copy 2x', class: 'dc-link-img dc-link-ajax dc-animate',
487
+ html << fa_icon('copy lg', class: 'dc-link-img dc-link-ajax dc-animate',
475
488
  'data-url' => url, 'data-request' => 'get', title: t('drgcms.doc_copy_clipboard') )
489
+
490
+ url = url_for(controller: :cmsedit, action: :index, table: 'dc_journal', filter: 'on',
491
+ filter_oper: 'eq', filter_field: 'doc_id', filter_value: @record.id)
492
+ html << fa_icon('history lg', class: 'dc-link-img dc-animate dc-window-open',
493
+ 'data-url' => url, title: t('helpers.label.dc_journal.tabletitle') )
494
+
476
495
  (html << '</div></div>').html_safe
477
496
  end
478
497
 
@@ -494,5 +513,4 @@ def dc_top_bottom_line(location, options)
494
513
  end
495
514
  end
496
515
 
497
-
498
516
  end
@@ -37,7 +37,7 @@ def dc_script_action(yaml)
37
37
  # data = {'request' => 'script', 'script' => yaml['js'] || yaml['script'] }
38
38
  # %Q[<li class="dc-link-ajax with-link dc-animate">#{ dc_link_to(yaml['caption'], yaml['icon'], '#', data: data ) }</li>]
39
39
  icon = dc_icon_for_link yaml['icon']
40
- data = %Q[data-request="script" data-script="#{yaml['js'] || yaml['script']}"]
40
+ data = %(data-request="script" data-script="#{yaml['js'] || yaml['script']}" data-url="script")
41
41
  %Q[<li class="dc-link-ajax dc-animate" #{data}>#{icon} #{ t(yaml['caption'],yaml['caption']) }</li>]
42
42
  end
43
43
 
@@ -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 nil if @form['form'].nil?
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
- # no label or help in comments
77
- unless %w(comment action).include?(options['type'])
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
  ############################################################################
@@ -147,9 +182,10 @@ end
147
182
  # Returns:
148
183
  # String : HTML code for action
149
184
  ############################################################################
150
- def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
185
+ def dc_link_ajax_window_submit_action(yaml, record = nil, action_active = true)
151
186
  parms = {}
152
- caption = yaml['caption'] ? t("#{yaml['caption'].downcase}", yaml['caption']) : nil
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) unless confirm.blank?
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['controller'] = yaml['url']
168
- parms['idr'] = dc_document_path(record) if record
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"
@@ -203,8 +241,8 @@ def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
203
241
  data-request="#{request}" title="#{yaml['title']}">#{icon}#{caption}</li>]
204
242
 
205
243
  elsif yaml['type'] == 'link' # link button
206
- clas = "dc-link dc-animate"
207
- link = dc_link_to(yaml['caption'], yaml['icon'], parms, html_data )
244
+ clas = "dc-link plus-link dc-animate"
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'
@@ -218,10 +256,10 @@ def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
218
256
  end
219
257
 
220
258
  ############################################################################
221
- #
259
+ # Log exception to rails log. Usefull for debugging eval errors.
222
260
  ############################################################################
223
- def dc_log_exception(exception)
224
- log = exception ? "\n!!!Error: #{exception.message}\n#{exception.backtrace.first.inspect}\n" : ''
261
+ def dc_log_exception(exception, where = '')
262
+ log = exception ? "\n*** Error:#{where + ':'} #{exception.message}\n#{exception.backtrace.first.inspect}\n" : ''
225
263
  log << "DRG Form processing line: #{session[:form_processing]}\n"
226
264
 
227
265
  logger.error log