drg_cms 0.6.1.0 → 0.6.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdd59e26395442cc8bec436e5a05940e762f373bfd30a83d5ddca87b443627a4
4
- data.tar.gz: be25c10a78a2fc6ed37f5e02484cfbff1d28b8cadb8546432f5b67665578006f
3
+ metadata.gz: a424c5a9f1d427b775dfb3a6a7bfa8ea0624c47fb2f4381c0fd19120a2c8c678
4
+ data.tar.gz: 6f0918c0365fbed1ff81e31bcd55be432ae8c02520f3811b18087941913957f5
5
5
  SHA512:
6
- metadata.gz: 838507481e4d09277049b1468ddbc18b2e40cc32b5fdcac38224169ab1b761aee445ebd93c0747c409db4f87298e986c9472552bc60d69f7d73031bea58a9c31
7
- data.tar.gz: 41965e0a604a632d975d3081d85d4e1d775ccb01a7e6dbbfad49be732e89f1223b20376024897b13df742bd6b38eab8c4a8f541d5270f127660dfd23e5edd27e
6
+ metadata.gz: 149a134733c8190f6b29003493f664e16fa2efad6608fb04a8bb607b9e00cd11a1752ec3b860d57af76789868667de12597b2023391879ad683ace066f71c1ec
7
+ data.tar.gz: 104ba8f48a7ad665da2f8ea99d833e04c94db4dc89a6d6ccecfe313ee5a082d7800691a31b805fb5cd35450e7350750ed68c073ef3e2bbafc971cfc8ff1180f2
@@ -832,9 +832,16 @@ $(document).ready( function() {
832
832
  * work on all field types.
833
833
  *******************************************************************/
834
834
  $('.record_filter_field_icon').on('click', function(e) {
835
- var field = $('#_record__filter_field');
836
- var url = $(this).parents('span').attr("data-url");
837
- url = url + "&filter_value=" + field.val();
835
+ let field = $('#_record__filter_field');
836
+ let url = $(this).parents('span').attr("data-url");
837
+ let value = null;
838
+
839
+ if (field.is(':checkbox')) {
840
+ value = field.is(':checked'); }
841
+ else {
842
+ value = field.val();
843
+ }
844
+ url = url + "&filter_value=" + value;
838
845
  location.href = url;
839
846
  });
840
847
 
@@ -188,7 +188,7 @@ a.dc-animate:hover { color: #000; background: transparent;}
188
188
  .dc-image-preview img { max-height: 2rem; padding-left: 0.5rem;}
189
189
  .dc-image-preview img:hover { cursor: zoom-in;}
190
190
 
191
- .text-with-select { width: 24px; }
191
+ .text-with-select { width: 20px; }
192
192
 
193
193
  .no-borders {
194
194
  padding: 0;
@@ -795,6 +795,9 @@ border-top: 1px solid #ddd;
795
795
  display: flex;
796
796
  }
797
797
  .dc-head .dc-column {
798
+ white-space: nowrap;
799
+ overflow: hidden;
800
+ margin-right: 2px;
798
801
  }
799
802
  .dc-head .text {
800
803
  font-weight: normal;
@@ -1217,6 +1220,16 @@ background-color: transparent;
1217
1220
  min-width: 50%;
1218
1221
  }
1219
1222
 
1223
+ #popup .dc-help .help-top {
1224
+ position: absolute;
1225
+ bottom: 1rem;
1226
+ right: 1rem;
1227
+ padding: 2px 4px;
1228
+ border: 1px dotted #ccc;
1229
+ border-radius: 4px;
1230
+ background: rgba(76,154,255,0.2);
1231
+ }
1232
+
1220
1233
  #popup .dc-help {
1221
1234
  background: #fff;
1222
1235
  padding: 8px;
@@ -1228,8 +1241,10 @@ background-color: transparent;
1228
1241
  #popup .dc-help h1 {
1229
1242
  background: darkred;
1230
1243
  color: #fff;
1231
- font-weight: 700;
1232
- padding: 4px
1244
+ font-weight: 600;
1245
+ padding: 4px;
1246
+ font-size: 1.2em;
1247
+ border-radius: 2px;
1233
1248
  }
1234
1249
 
1235
1250
  #popup .dc-help h2 {
@@ -1246,21 +1261,12 @@ background-color: transparent;
1246
1261
  padding: 4px
1247
1262
  }
1248
1263
 
1249
- /*
1250
- #popup .dc-help .help-tab {
1251
- display: table;
1252
- padding-top: 4px;
1253
- border-bottom: 3px solid #000;
1254
- margin: 8px 0;
1255
- font-weight: 600;
1256
- }
1257
- */
1258
1264
  #popup .dc-help .help-tab {
1259
1265
  display: table;
1260
1266
  margin: 8px 0 0;
1261
1267
  padding: 3px 12px;
1262
1268
  color: #fff;
1263
- background: #444;
1269
+ background: #555;
1264
1270
  border-radius: 5px 5px 0 0;
1265
1271
  font-weight: 600;
1266
1272
  }
@@ -1268,10 +1274,15 @@ background-color: transparent;
1268
1274
  #popup .dc-help .help-tab-help {
1269
1275
  font-weight: 600;
1270
1276
  color: #fff;
1271
- background: #666;
1277
+ background: #777;
1272
1278
  padding: 3px 12px;
1273
1279
  }
1274
1280
 
1281
+ #popup .dc-help .help-fields {
1282
+ margin-top: 1rem;
1283
+ border-top: 1px solid #222;
1284
+ }
1285
+
1275
1286
  #popup .dc-help .help-field {
1276
1287
  display: flex;
1277
1288
  background-color: #eee;
@@ -1291,11 +1302,14 @@ background-color: transparent;
1291
1302
  }
1292
1303
 
1293
1304
  #popup .dc-help .help-body {
1294
- margin-top: 8px;
1295
1305
  border-top: 1px solid #222;
1296
1306
  padding-top: 8px;
1297
1307
  }
1298
1308
 
1309
+ #popup .dc-help .help-buttons {
1310
+ padding: 4px 0;
1311
+ }
1312
+
1299
1313
  #popup .dc-help .dc-link {
1300
1314
  display: inline-flex;
1301
1315
  }
@@ -28,7 +28,7 @@
28
28
  -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
29
29
  -o-transition: border linear 0.2s, box-shadow linear 0.2s;
30
30
  transition: border linear 0.2s, box-shadow linear 0.2s;
31
- border: 1px solid #ddd;
31
+ border: 1px dashed #888;
32
32
  -webkit-border-radius: 1px;
33
33
  -moz-border-radius: 1px;
34
34
  border-radius: 1px;
@@ -528,7 +528,7 @@ end
528
528
  #
529
529
  ####################################################################
530
530
  def dc_check_model(document, crash=false)
531
- DrgCms.check_model(document, crash=false)
531
+ DrgCms.model_check(document, crash)
532
532
  end
533
533
 
534
534
  ######################################################################
@@ -153,8 +153,9 @@ def export_to_excel(report_id)
153
153
  excel[n, i] = value
154
154
  end
155
155
  end
156
- workbook.write Rails.root.join("public/tmp/#{report_id}.xls")
157
- dc_render_ajax(operation: :window, value: "/tmp/#{report_id}.xls")
156
+ file_name = "#{report_id}-#{Time.now.to_i}.xls"
157
+ workbook.write Rails.root.join('public', 'tmp', file_name)
158
+ dc_render_ajax(operation: :window, value: "/tmp/#{file_name}")
158
159
  end
159
160
 
160
161
  ############################################################################
@@ -200,15 +201,12 @@ end
200
201
  # @param [Object] txt : Text or object. Result of to_s method of the object is
201
202
  # @param [Hash] opts
202
203
  ###############################################################################
203
- def pdf_text(txt, opts={})
204
- box_opts = {}
204
+ def pdf_text(txt, opts = {})
205
+ box_opts = opts.dup
205
206
  ypos = @pdf.cursor
206
207
  xpos = opts.delete(:atx) || 0
207
- box_opts.merge!(single_line: (opts.delete(:single_line) || true))
208
- box_opts.merge!(at: (opts.delete(:at) || [xpos, ypos]))
209
- box_opts.merge!(width: opts[:width]) if opts[:width]
210
- box_opts.merge!(align: opts[:align]) if opts[:align]
211
- box_opts.merge!(inline_format: opts[:inline_format]) if opts[:inline_format]
208
+ box_opts[:single_line] ||= true
209
+ box_opts[:at] ||= [xpos, ypos]
212
210
 
213
211
  @pdf.text_box(txt.to_s, box_opts)
214
212
  end
@@ -356,13 +356,12 @@ end
356
356
  def dc_help_fields
357
357
  return '' if @form['form'].nil?
358
358
 
359
- html = '<div class="dc-handle" data-div="#the1"></div><div id="the1">'
359
+ html = '<a id="fields"></a>'
360
360
  if @form['form']['tabs']
361
361
  @form['form']['tabs'].each { |tab| html << dc_help_for_tab(tab) }
362
362
  else
363
363
  html << dc_help_for_tab(@form['form']['fields'])
364
364
  end
365
- html << '</div>'
366
365
  html.html_safe
367
366
  end
368
367
 
@@ -423,7 +423,7 @@ def dc_head_for_form
423
423
  @record.send(options['name'])
424
424
  end
425
425
  rescue Exception => e
426
- dc_log_exception(e)
426
+ dc_log_exception(e, 'dc_head_for_form')
427
427
  field = '!!!Error'
428
428
  end
429
429
  #
@@ -256,10 +256,10 @@ def dc_link_ajax_window_submit_action(yaml, record=nil, action_active=true)
256
256
  end
257
257
 
258
258
  ############################################################################
259
- #
259
+ # Log exception to rails log. Usefull for debugging eval errors.
260
260
  ############################################################################
261
- def dc_log_exception(exception)
262
- 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" : ''
263
263
  log << "DRG Form processing line: #{session[:form_processing]}\n"
264
264
 
265
265
  logger.error log
@@ -291,7 +291,7 @@ def dc_actions_for_result(document)
291
291
  when yaml['type'] == 'delete' then
292
292
  parms['action'] = 'destroy'
293
293
  parms['id'] = document.id
294
- parms['return_to'] = request.url
294
+ #parms['return_to'] = request.url
295
295
  dc_link_to( nil, 'remove lg', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete )
296
296
  # undocumented so far
297
297
  when yaml['type'] == 'edit_embedded'
@@ -438,7 +438,7 @@ def dc_columns_for_result(document)
438
438
  "??? #{v['name']}"
439
439
  end
440
440
  rescue Exception => e
441
- dc_log_exception(e)
441
+ dc_log_exception(e, 'dc_columns_for_result')
442
442
  value = '!!!Error'
443
443
  end
444
444
  html << '<div class="spacer"></div>'
@@ -540,15 +540,19 @@ def dc_style_or_class(selector, yaml, value, record)
540
540
  # alias record and value so both names can be used in eval
541
541
  field, document = value, record
542
542
  html = selector ? "#{selector}=\"" : ''
543
- html << if yaml.class == String
544
- yaml
545
- # direct evaluate expression
546
- elsif yaml['eval']
547
- eval(yaml['eval']) rescue 'background-color:red;'
548
- elsif yaml['method']
549
- dc_process_eval(yaml['method'], record)
543
+ begin
544
+ html << if yaml.class == String
545
+ yaml
546
+ # direct evaluate expression
547
+ elsif yaml['eval']
548
+ eval(yaml['eval'])
549
+ elsif yaml['method']
550
+ dc_process_eval(yaml['method'], record)
551
+ end
552
+ rescue Exception => e
553
+ dc_log_exception(e, 'dc_style_or_class')
550
554
  end
551
- html << '"' if selector
555
+ html << '"' if selector
552
556
  html
553
557
  end
554
558
 
@@ -596,10 +596,11 @@ end
596
596
  # Returns:
597
597
  # String. HTML code required for manipulation of currently processed document.
598
598
  ########################################################################
599
- def dc_page_edit_menu(opts=@opts)
599
+ def dc_page_edit_menu(opts = @opts)
600
600
  opts[:edit_mode] ||= _origin.session[:edit_mode]
601
601
  return '' if opts[:edit_mode] < 2
602
- # save some data to cookie. This can not go to session.
602
+
603
+ # save some data to cookie. This can not go to session.
603
604
  page = opts[:page] || @page
604
605
  table = _origin.site.page_class.underscore
605
606
  kukis = { "#{table}.dc_design_id" => page.dc_design_id,
@@ -616,11 +617,9 @@ def dc_page_edit_menu(opts=@opts)
616
617
  opts[:editparams].merge!( :id => page.id, :table => _origin.site.page_class.underscore, form_name: opts[:form_name], edit_only: 'body' )
617
618
  html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_content') )
618
619
 
619
- # opts[:editparams][:edit_only] = nil
620
620
  opts[:editparams].merge!( edit_only: nil, 'icon' => 'pencil' )
621
621
  html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_advanced') )
622
622
 
623
- # opts[:editparams][:action] = 'new'
624
623
  opts[:editparams].merge!( action: 'new', 'icon' => 'plus' )
625
624
  html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_page') )
626
625
 
@@ -642,8 +641,7 @@ end
642
641
  # type: text_with_select
643
642
  # eval: 'dc_page_class.all_pages_for_site(@parent.dc_get_site)'
644
643
  ########################################################################
645
- def dc_page_class()
646
- # dc_get_site.page_class.classify.constantize
644
+ def dc_page_class
647
645
  dc_get_site.page_klass
648
646
  end
649
647
 
@@ -658,7 +656,7 @@ end
658
656
  # type: tree_view
659
657
  # eval: 'dc_menu_class.all_menus_for_site(@parent.dc_get_site)'
660
658
  ########################################################################
661
- def dc_menu_class()
659
+ def dc_menu_class
662
660
  dc_get_site.menu_class.classify.constantize
663
661
  end
664
662
 
@@ -672,23 +670,20 @@ end
672
670
  # Returns:
673
671
  # DCSite. Site document.
674
672
  ####################################################################
675
- def dc_get_site()
673
+ def dc_get_site
676
674
  return @site if @site # already cached
677
- #
675
+
678
676
  req = _origin.request.url # different when called from renderer
679
677
  uri = URI.parse(req)
680
678
  @site = DcSite.find_by(name: uri.host)
681
- # Site can be aliased
682
- if @site and !@site.alias_for.blank?
683
- @site = DcSite.find_by(name: @site.alias_for)
684
- end
685
- # Development environment. Check if site with name test exists and use
686
- # alias_for field as pointer to real site name.
687
- if @site.nil? and ENV["RAILS_ENV"] != 'production'
679
+ # Site can be aliased
680
+ @site = DcSite.find_by(name: @site.alias_for) if @site&.alias_for.present?
681
+ # Development. If site with name test exists use alias_for field as pointer to real site data
682
+ if @site.nil? && ENV["RAILS_ENV"] != 'production'
688
683
  @site = DcSite.find_by(name: 'test')
689
684
  @site = DcSite.find_by(name: @site.alias_for) if @site
690
685
  end
691
- @site = nil if @site and !@site.active # site is disabled
686
+ @site = nil if @site && !@site.active # site is disabled
692
687
  @site
693
688
  end
694
689
 
@@ -704,9 +699,9 @@ end
704
699
  # html:
705
700
  # include_blank: true
706
701
  ############################################################################
707
- def dc_choices4_site_policies()
702
+ def dc_choices4_site_policies
708
703
  site = dc_get_site()
709
- site.dc_policies.all.inject([]) { |r, policy| r << [ policy.name, policy.id] if policy.active }
704
+ site.dc_policies.where(active: true).order_by(name: 1).map { |policy| [ policy.name, policy.id] }
710
705
  end
711
706
 
712
707
  ############################################################################
@@ -727,7 +722,7 @@ def dc_choices4_all_collections
727
722
  DrgCms.paths(:forms).reverse.each do |path|
728
723
  filename = "#{path}/cms_menu.yml"
729
724
  next unless File.exist?(filename)
730
- #
725
+
731
726
  menu = YAML.load_file(filename) rescue nil # load menu
732
727
  next if menu.nil? or !menu['menu'] # not menu or error
733
728
  menu['menu'].each do |section|
@@ -754,8 +749,8 @@ def forms_merge(hash1, hash2) #:nodoc:
754
749
  end
755
750
  target[key] = hash2[key] == '/' ? nil : hash2[key]
756
751
  end
757
- # delete keys with nil value
758
- target.delete_if{ |k,v| v.nil? }
752
+ # delete keys with nil value
753
+ target.delete_if{ |k, v| v.nil? }
759
754
  end
760
755
 
761
756
  ##########################################################################
@@ -770,7 +765,7 @@ def dc_choices4_cmsmenu()
770
765
  next if menu.nil? or !menu['menu'] # not menu or error
771
766
  menus = forms_merge(menu['menu'], menus) # ignore top level part
772
767
  end
773
- #
768
+
774
769
  html = '<ul>'
775
770
  menus.to_a.sort.each do |index, menu| # sort menus, result is array of sorted hashes
776
771
  next unless menu['caption']
@@ -835,9 +830,11 @@ def dc_choices4(model, name, id='_id', options = {})
835
830
  sites << nil if param == :with_nil
836
831
  qry = qry.in(dc_site_id: sites) if sites
837
832
  end
838
- qry = qry.and(active: true) if model.method_defined?(:active)
839
- choices = qry.inject([]) {|result,e| result << [ e[name], e[id] ]}
840
- choices.sort_alphabetical_by(&:first) # use UTF-8 sort
833
+ qry = qry.and(active: true) if model.method_defined?(:active)
834
+ qry = qry.order_by(name => 1).collation(locale: I18n.locale.to_s)
835
+ #choices = qry.inject([]) {|result,e| result << [ e[name], e[id] ]}
836
+ #choices.sort_alphabetical_by(&:first) # use UTF-8 sort
837
+ qry.map { |e| [e[name], e[id]] }
841
838
  end
842
839
 
843
840
  ############################################################################
@@ -898,35 +895,35 @@ end
898
895
  ############################################################################
899
896
  def dc_user_can_view(ctrl, policy_id)
900
897
  policy_id = policy_id.policy_id if policy_id and policy_id.respond_to?(:policy_id)
901
- # Eventualy object without policy_id will be checked. This is to prevent error
898
+ # Eventualy object without policy_id will be checked. This is to prevent error
902
899
  policy_id = nil unless policy_id.class == BSON::ObjectId
903
- #
900
+
904
901
  site = ctrl.site
905
902
  policies = if site.inherit_policy.blank?
906
903
  site.dc_policies
907
904
  else
908
905
  Mongoid::QueryCache.cache { DcSite.find(site.inherit_policy) }.dc_policies
909
906
  end
910
- # permission defined by default policy
907
+ # permission defined by default policy
911
908
  default_policy = Mongoid::QueryCache.cache { policies.find_by(is_default: true) }
912
909
  return false, 'Default access policy not found for the site!' unless default_policy
913
- #
910
+
914
911
  permissions = {}
915
912
  default_policy.dc_policy_rules.to_a.each { |v| permissions[v.dc_policy_role_id] = v.permission }
916
- # update permissions with defined policy
913
+ # update permissions with defined policy
917
914
  part_policy = nil
918
915
  if policy_id
919
916
  part_policy = Mongoid::QueryCache.cache { policies.find(policy_id) }
920
917
  return false, 'Access policy not found for part!' unless part_policy
921
918
  part_policy.dc_policy_rules.to_a.each { |v| permissions[v.dc_policy_role_id] = v.permission }
922
919
  end
923
- # apply guest role if no roles defined
920
+ # apply guest role if no roles defined
924
921
  if ctrl.session[:user_roles].nil?
925
922
  role = Mongoid::QueryCache.cache { DcPolicyRole.find_by(system_name: 'guest', active: true) }
926
923
  return false, 'System guest role not defined!' unless role
927
924
  ctrl.session[:user_roles] = [role.id]
928
925
  end
929
- # Check if user has any role that allows him to view part
926
+ # Check if user has any role that allows him to view part
930
927
  can_view, msg = false,''
931
928
  ctrl.session[:user_roles].each do |role|
932
929
  next unless permissions[role] # role not yet defined. Will die in next line.
@@ -962,10 +959,10 @@ def dc_user_has_role( role, user=nil, roles=nil )
962
959
  roles = _origin.session[:user_roles] if roles.nil?
963
960
  user = _origin.session[:user_id] if user.nil?
964
961
  return false if user.nil? or roles.nil?
965
- #
962
+
966
963
  role = DcPolicyRole.get_role(role)
967
964
  return false if role.nil?
968
- # role is included in roles array
965
+ # role is included in roles array
969
966
  roles.include?(role._id)
970
967
  end
971
968
 
@@ -1004,6 +1001,7 @@ end
1004
1001
  ############################################################################
1005
1002
  def dc_limit_string(string, size)
1006
1003
  return string if string.size < size
1004
+
1007
1005
  string = string[0,size]
1008
1006
  string.chop! until (string[-1,1] == ' ' or string == '')
1009
1007
  string << '...'
@@ -1031,10 +1029,11 @@ def dc_big_table(key)
1031
1029
  bt = DcBigTable.find_by(key: key, site: dc_get_site._id, active: true)
1032
1030
  bt = DcBigTable.find_by(key: key, site: nil, active: true) if bt.nil?
1033
1031
  return ret if bt.nil?
1034
- #
1032
+
1035
1033
  locale = I18n.locale.to_s
1036
1034
  bt.dc_big_table_values.each do |v| # iterate each value
1037
1035
  next unless v.active
1036
+
1038
1037
  desc = ''
1039
1038
  v.dc_big_table_locales.each do |l| # iterate each locale
1040
1039
  if l.locale == locale
@@ -131,11 +131,13 @@ $(document).ready(function() {
131
131
  }
132
132
  });
133
133
  },
134
+
134
135
  change: function (event, ui) {
135
136
  #{not_id_code}
137
+ if (ui.item == null) return;
136
138
  $("##{record}_#{@yaml['name']}").val(ui.item.id);
137
-
138
139
  },
140
+
139
141
  minLength: 2
140
142
  });
141
143
  });
@@ -60,7 +60,7 @@ def do_one_item(poll, yaml)
60
60
  # label
61
61
  text = yaml['text'].match(/\./) ? t(yaml['text']) : yaml['text']
62
62
  if yaml['mandatory']
63
- text << ( poll.display == 'in' ? ' *' : '<font color="red"> *</font>' )
63
+ text << ( poll.display == 'in' ? ' *' : '<span class="required"> *</span>' )
64
64
  yaml['html'] ||= {}
65
65
  yaml['html']['required'] = true
66
66
  else
@@ -108,11 +108,7 @@ def do_one_item(poll, yaml)
108
108
  if yaml['type'].match(/submit_tag|link_to/)
109
109
  # There can be more than one links on form. End the data at first link or submit.
110
110
  if !@end_of_data
111
- html << if poll.display == 'lr'
112
- "</div><br>\n"
113
- else
114
- "</div>\n"
115
- end
111
+ html << (poll.display == 'lr' ? "</div><br>\n" : "</div>\n")
116
112
  # captcha
117
113
  if poll.captcha_type.to_s.size > 1
118
114
  @opts.merge!(:captcha_type => poll.captcha_type)
@@ -166,18 +162,18 @@ def default
166
162
 
167
163
  poll = DcPoll.find(poll_id)
168
164
  poll = DcPoll.find_by(name: poll_id) if poll.nil? # name instead of id
169
- return "<div class=\"dc-form-error\">Invalid Poll id #{poll_id}</div>" if poll.nil?
165
+ return %(<div class="dc-form-error">Invalid Poll id #{poll_id}</div>) if poll.nil?
170
166
  # If parent cant be seen. so cant be polls
171
167
  can_view, message = dc_user_can_view(@parent, @parent.page)
172
- return "<div class=\"dc-form-error\">#{message}</div>" unless can_view
168
+ return %(<div class="dc-form-error">#{message}</div>) unless can_view
173
169
 
174
- html = @opts[:div] ? "<div id='#{@opts[:div]}'>" : ''
170
+ html = @opts[:div] ? %(<div id="#{@opts[:div]}"'>) : ''
175
171
  html << '<a name="poll-top"></a>'
176
172
  unless poll.pre_display.blank?
177
173
  begin
178
174
  continue, message = eval_pre_display(poll.pre_display)
179
175
  rescue Exception => e
180
- return "<div class=\"dc-form-error\">Error! Poll pre display. Error: #{e.message}</div>"
176
+ return %(<div class="dc-form-error">Error! Poll pre display. Error: #{e.message}</div>)
181
177
  end
182
178
  return message unless continue
183
179
 
@@ -188,11 +184,11 @@ def default
188
184
  # If flash[:record] is present copy content to params record hash
189
185
  @parent.flash[:record].each {|k,v| @parent.params["p_#{k}"] = v } if @parent.flash[:record]
190
186
  # Error during procesing request
191
- html << "<div class=\"dc-form-error\">#{@parent.flash[:error]}</div>\n" if @parent.flash[:error].to_s.size > 0
192
- html << "<div class=\"dc-form-info\">#{@parent.flash[:info]}</div>\n" if @parent.flash[:info]
187
+ html << %(<div class="dc-form-error">#{@parent.flash[:error]}</div>\n) if @parent.flash[:error].to_s.size > 0
188
+ html << %(<div class="dc-form-info">#{@parent.flash[:info]}</div>\n) if @parent.flash[:info]
193
189
  end
194
190
  # div and form tag
195
- html << "<div class=\"poll-div\">\n"
191
+ html << %(<div class="poll-div">\n)
196
192
  # edit link
197
193
  if @opts[:edit_mode] > 1
198
194
  @opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', id: poll._id, table: 'dc_poll', form_name: 'dc_poll' )
@@ -208,13 +204,13 @@ def default
208
204
  @parent.form_tag( poll.parameters, method: :put)
209
205
  end
210
206
  # header, - on first position will not display title
211
- html << "<div class='poll-title'>#{poll.title}</div>" unless poll.title[0] == '-'
212
- html << poll.sub_text.to_s
207
+ html << %(<div class="poll-title">#{poll.title}</div>) unless poll.title[0] == '-'
208
+ html << %(<div class="poll-text">#{poll.sub_text}</div>)
213
209
  html << if poll.display == 'lr'
214
- "\n" + '<div class="poll-data-table">'
215
- else
216
- '<div class="poll-data-div">' + "\n"
217
- end
210
+ %(\n<div class="poll-data-table">)
211
+ else
212
+ %(<div class="poll-data-div">\n)
213
+ end
218
214
  # items. Convert each item to yaml
219
215
  @end_od_data = false
220
216
  if poll.form.to_s.size < 10
@@ -232,9 +228,9 @@ def default
232
228
  yaml['text'] = item.text
233
229
  yaml['mandatory'] = item.mandatory
234
230
  yaml['type'] = item.type
231
+
235
232
  html << do_one_item(poll, yaml)
236
233
  end
237
- # FORM. Just call do_one_item for each form item
238
234
  else
239
235
  yaml = YAML.load(poll.form.gsub('&nbsp;',' ')) # very annoying. They come with copy&paste ;-)
240
236
  # if entered without numbering yaml is returned as Hash otherwise as Array
@@ -1,8 +1,17 @@
1
- <%= javascript_include_tag "cms" %>
2
1
 
3
- <div class="dc-help">
2
+ <div class="dc-help"><a id="help-top"></a>
4
3
  <h1><%= t('drgcms.dc_help.help') %>: <%= dc_form_title %></h1>
4
+ <div class="help-buttons">
5
+ <% if params[:type] == 'form' %>
6
+ <button onclick="location.href='#fields'; return false;"><%= t('drgcms.dc_help.fields_button') %></button>
7
+ <% end %>
8
+ <% if @commnets %>
9
+ <button onclick="location.href='#comments'; return false;"><%= t('drgcms.dc_help.comments_button') %></button>
10
+ <% end %>
11
+ </div>
5
12
 
6
- <div class="help-fields"><%= dc_help_fields if params[:type] == 'form' %></div>
7
13
  <div class="help-body"><%= dc_help_body if @help %></div>
14
+ <div class="help-fields"><%= dc_help_fields if params[:type] == 'form' %></div>
15
+
16
+ <div class="help-top" onclick="location.href='#help-top'; return false;"><%= fa_icon('arrow-up') %></div>
8
17
  </div>
@@ -120,6 +120,8 @@ en:
120
120
 
121
121
  dc_help:
122
122
  help: HELP
123
+ fields_button: Data description
124
+ comments_button: Comments
123
125
  title: Manage help documents
124
126
  project: Project
125
127
  lang: Locale
@@ -117,6 +117,8 @@ sl:
117
117
 
118
118
  dc_help:
119
119
  help: POMOČ
120
+ fields_button: Opis podatkov
121
+ comments_button: Opombe
120
122
  title: Urejanje dokumentov pomoči
121
123
  project: Projekt
122
124
  lang: Jezik
@@ -23,5 +23,5 @@
23
23
 
24
24
  # drg_cms gem version
25
25
  module DrgCms #:nodoc:
26
- VERSION = '0.6.1.0'.freeze
26
+ VERSION = '0.6.1.1.1'.freeze
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.0
4
+ version: 0.6.1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damjan Rems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-20 00:00:00.000000000 Z
11
+ date: 2021-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails