drg_cms 0.6.1.0 → 0.6.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -10
  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 +178 -55
  10. data/app/assets/stylesheets/drg_cms/drg_cms.css +218 -94
  11. data/app/assets/stylesheets/drg_cms/select-multiple.css +1 -1
  12. data/app/controllers/cmsedit_controller.rb +29 -24
  13. data/app/controllers/dc_application_controller.rb +78 -166
  14. data/app/controllers/dc_common_controller.rb +56 -47
  15. data/app/controls/dc_help_control.rb +12 -0
  16. data/app/controls/dc_report.rb +7 -9
  17. data/app/controls/design_element_settings_control.rb +1 -1
  18. data/app/forms/all_options.yml +25 -6
  19. data/app/forms/dc_big_table.yml +0 -2
  20. data/app/forms/dc_big_table_value.yml +0 -2
  21. data/app/forms/dc_design.yml +1 -2
  22. data/app/forms/dc_folder_permission.yml +0 -2
  23. data/app/forms/dc_help_1.yml +2 -1
  24. data/app/forms/dc_json_ld.yml +0 -3
  25. data/app/forms/dc_menu.yml +6 -12
  26. data/app/forms/dc_menu_item.yml +1 -3
  27. data/app/forms/dc_page.yml +5 -2
  28. data/app/forms/dc_policy.yml +2 -5
  29. data/app/forms/dc_poll.yml +10 -16
  30. data/app/forms/dc_seo.yml +1 -2
  31. data/app/forms/dc_simple_menu.yml +1 -2
  32. data/app/forms/dc_site.yml +5 -7
  33. data/app/helpers/cms_common_helper.rb +2 -3
  34. data/app/helpers/cms_edit_helper.rb +41 -31
  35. data/app/helpers/cms_helper.rb +6 -6
  36. data/app/helpers/cms_index_helper.rb +79 -34
  37. data/app/helpers/dc_application_helper.rb +99 -85
  38. data/app/models/concerns/dc_page_concern.rb +3 -2
  39. data/app/models/concerns/dc_piece_concern.rb +1 -1
  40. data/app/models/concerns/dc_site_concern.rb +10 -4
  41. data/app/models/concerns/dc_user_concern.rb +3 -3
  42. data/app/models/dc_big_table.rb +2 -2
  43. data/app/models/dc_filter.rb +28 -22
  44. data/app/models/dc_site.rb +0 -1
  45. data/app/models/dc_temp.rb +7 -0
  46. data/app/models/drgcms_form_fields/comment.rb +11 -2
  47. data/app/models/drgcms_form_fields/date_picker.rb +2 -0
  48. data/app/models/drgcms_form_fields/drgcms_field.rb +2 -1
  49. data/app/models/drgcms_form_fields/embedded.rb +4 -2
  50. data/app/models/drgcms_form_fields/number_field.rb +4 -3
  51. data/app/models/drgcms_form_fields/readonly.rb +13 -17
  52. data/app/models/drgcms_form_fields/select.rb +16 -18
  53. data/app/models/drgcms_form_fields/text_autocomplete.rb +39 -23
  54. data/app/renderers/dc_page_renderer.rb +7 -6
  55. data/app/renderers/dc_poll_renderer.rb +16 -20
  56. data/app/views/cmsedit/_edit_stuff.html.erb +5 -2
  57. data/app/views/cmsedit/_form.html.erb +3 -2
  58. data/app/views/cmsedit/_result.html.erb +21 -18
  59. data/app/views/cmsedit/edit.html.erb +2 -1
  60. data/app/views/cmsedit/index.html.erb +1 -1
  61. data/app/views/cmsedit/new.html.erb +3 -2
  62. data/app/views/dc_common/_help.html.erb +12 -3
  63. data/app/views/layouts/cms.html.erb +3 -5
  64. data/config/locales/drgcms_en.yml +5 -2
  65. data/config/locales/drgcms_sl.yml +5 -2
  66. data/config/locales/models_en.yml +2 -0
  67. data/config/locales/models_sl.yml +5 -3
  68. data/drg_cms.gemspec +16 -16
  69. data/lib/drg_cms/version.rb +1 -1
  70. data/lib/drg_cms.rb +46 -12
  71. metadata +35 -29
@@ -31,12 +31,17 @@ module DrgcmsFormFields
31
31
  # * +type:+ comment (required)
32
32
  # * +caption:+ Caption text written in label place. If set to false comment
33
33
  # will occupy whole row. (required)
34
- #
34
+ # * +html:+ Optional html attributes will be added to div surrounding the comment.
35
+ #
35
36
  # Form example:
36
37
  # 30:
37
38
  # type: comment
38
39
  # text: myapp.comment_text
39
40
  # caption: false
41
+ # html:
42
+ # style: 'color: red'
43
+ # class: some_class
44
+ # id: some_id
40
45
  ###########################################################################
41
46
  class Comment < DrgcmsField
42
47
 
@@ -45,7 +50,11 @@ class Comment < DrgcmsField
45
50
  ###########################################################################
46
51
  def render
47
52
  comment = @yaml['comment'] || @yaml['text']
48
- @html << "<div class=\"dc-comment\">#{t(comment, comment).gsub("\n",'<br>')}</div>"
53
+ @yaml['html'] ||= {}
54
+ @yaml['html']['class'] = 'dc-comment ' + @yaml['html']['class'].to_s
55
+ html = @yaml['html'].inject('') { |r, e| r << %( #{e[0]}="#{e[1]}") }
56
+
57
+ @html << %(<div #{html}>#{t(comment, comment).gsub("\n",'<br>')}</div>)
49
58
  self
50
59
  end
51
60
  end
@@ -78,6 +78,8 @@ def render
78
78
  @yaml['options']['lang'] ||= "'#{I18n.locale}'"
79
79
  @yaml['options']['format'] ||= "'#{t('datetimepicker.formats.date')}'"
80
80
  @yaml['options']['timepicker'] = false
81
+ @yaml['options']['scrollMonth'] ||= false
82
+ @yaml['options']['scrollInput'] ||= false
81
83
 
82
84
  record = record_text_for(@yaml['name'])
83
85
  @html << @parent.text_field(record, @yaml['name'], @yaml['html'])
@@ -135,7 +135,8 @@ def ro_standard(value=nil)
135
135
  @record.respond_to?(@yaml['name']) ? @record.send(@yaml['name']) : nil
136
136
  end
137
137
  end
138
- @html << (value.blank? ? '' : "<div class='dc-readonly'>#{value}</div>")
138
+ #@html << (value.blank? ? '' : "<div class='dc-readonly'>#{value}</div>")
139
+ @html << %(<div id="#{@yaml['name']}" class="dc-readonly">#{value}</div>)
139
140
  self
140
141
  end
141
142
 
@@ -67,9 +67,11 @@ def render
67
67
  tables = @parent.tables.inject('') { |r,v| r << "#{v[1]};" } + @yaml['table']
68
68
  ids = @parent.ids.inject('') { |r,v| r << "#{v};" } + @record.id
69
69
  end
70
- opts = { controller: 'cmsedit', action: @yaml['action'],
70
+ # edit enabled embedded form on a readonly form
71
+ readonly = @yaml['readonly'].class == FalseClass ? nil : @readonly
72
+ opts = { controller: 'cmsedit', action: @yaml['action'],
71
73
  ids: ids, table: tables, form_name: @yaml['form_name'],
72
- field_name: @yaml['name'], iframe: "if_#{@yaml['name']}", readonly: @readonly }
74
+ field_name: @yaml['name'], iframe: "if_#{@yaml['name']}", readonly: readonly }
73
75
  # additional parameters if specified
74
76
  @yaml['params'].each { |k,v| opts[k] = @parent.dc_value_for_parameter(v) } if @yaml['params']
75
77
 
@@ -69,14 +69,14 @@ def render
69
69
  @yaml['html']['data-delimiter'] = @yaml.dig('format','delimiter') || I18n.t('number.currency.format.delimiter')
70
70
  @yaml['html']['data-separator'] = @yaml.dig('format','separator') || I18n.t('number.currency.format.separator')
71
71
  # @yaml['html']['data-currency'] = @yaml.dig('format','currency') == 'yes' ? I18n.t('number.currency.format.currency') : @yaml.dig('format','currency')
72
- value = @record[@yaml['name']] || 0
72
+ value = @yaml['html']['value'] || @record[@yaml['name']] || 0
73
73
  @yaml['html']['value'] = @parent.dc_format_number(value, @yaml['html']['data-decimal'], @yaml['html']['data-separator'], @yaml['html']['data-delimiter'] )
74
74
 
75
75
  return ro_standard(@yaml['html']['value']) if @readonly
76
76
 
77
77
  @yaml['html']['autocomplete'] ||= 'off'
78
78
  @html << @parent.hidden_field( record, @yaml['name'], value: value )
79
- @html << @parent.text_field( nil,"record_#{@yaml['name']}_", @yaml['html'])
79
+ @html << @parent.text_field( nil, "record_#{@yaml['name']}_", @yaml['html'])
80
80
  self
81
81
  end
82
82
 
@@ -85,7 +85,8 @@ end
85
85
  ###########################################################################
86
86
  def self.get_data(params, name)
87
87
  return 0 if params['record'][name].blank?
88
- params['record'][name].match('.') ? params['record'][name].to_f : Integer.new(params['record'][name])
88
+
89
+ params['record'][name].match('.') ? params['record'][name].to_f : params['record'][name].to_i
89
90
  end
90
91
 
91
92
  end
@@ -51,29 +51,25 @@ class Readonly < DrgcmsField
51
51
  ###########################################################################
52
52
  # Render readonly field html code
53
53
  ###########################################################################
54
- def render
54
+ def render
55
55
  @html << @parent.hidden_field('record', @yaml['name']) # retain field as hidden field
56
56
  @html << '<div class="dc-readonly">'
57
-
57
+
58
58
  @html << if @yaml['eval']
59
- if @yaml['eval'].match('dc_name4_id')
60
- a = @yaml['eval'].split(',')
61
- if a.size == 3
62
- @parent.dc_name4_id(a[1], a[2], nil, @record[ @yaml['name'] ])
63
- else
64
- @parent.dc_name4_id(a[1], a[2], a[3], @record[ @yaml['name'] ])
65
- end
66
-
67
- # @parent.dc_name4_id(a[1], a[2], @record[ @yaml['name'] ])
68
- else
69
- eval( "#{@yaml['eval']} '#{@record.send(@yaml['name'])}'")
70
- end
71
- else
72
- @parent.dc_format_value(@record.send(@yaml['name']),@yaml['format'])
73
- end
59
+ if @yaml['eval'].match(/dc_name4_id|dc_name_for_id/)
60
+ parms = @parent.dc_eval_to_array(@yaml['eval'])
61
+ parms << nil if parms.size == 3
62
+ @parent.dc_name_for_id(parms[1], parms[2], parms[3], @record[@yaml['name']])
63
+ else
64
+ eval( "#{@yaml['eval']} '#{@record.send(@yaml['name'])}'")
65
+ end
66
+ else
67
+ @parent.dc_format_value(@record.send(@yaml['name']), @yaml['format'])
68
+ end
74
69
  @html << '</div>'
75
70
  self
76
71
  end
72
+
77
73
  end
78
74
 
79
75
  end
@@ -96,7 +96,7 @@ def choices_in_eval(e)
96
96
  if @yaml['depend'].nil?
97
97
  method = e.split(/\ |\(/).first
98
98
  return eval(e) if respond_to?(method) # id method defined here
99
- return eval('@parent.'+e) if @parent.respond_to?(method) # is method defined in helpers
99
+ return eval('@parent.' + e) if @parent.respond_to?(method) # is method defined in helpers
100
100
  # eval whatever it is there
101
101
  eval e
102
102
  else
@@ -120,19 +120,18 @@ end
120
120
  ###########################################################################
121
121
  def get_choices
122
122
  begin
123
- choices = case
124
- when @yaml['choices'] then
125
- @yaml['choices'].match('helpers.') ? choices_in_helper(@yaml['choices']) : @yaml['choices']
123
+ choices = case
126
124
  when @yaml['eval'] then
127
125
  choices_in_eval(@yaml['eval'])
126
+ when @yaml['choices'] then
127
+ @yaml['choices'].match('helpers.') ? choices_in_helper(@yaml['choices']) : @yaml['choices']
128
128
  else
129
129
  choices_in_helper()
130
130
  end
131
- # Convert string to Array
132
- choices.class == String ?
133
- choices.chomp.split(',').inject([]) { |r,v| r << (v.match(':') ? v.split(':') : v ) } :
134
- choices
135
- rescue Exception => e
131
+ return choices unless choices.class == String
132
+
133
+ choices.chomp.split(',').map { |e| e.match(':') ? e.split(':') : e }
134
+ rescue Exception => e
136
135
  Rails.logger.debug "\nError in select eval. #{e.message}\n"
137
136
  Rails.logger.debug(e.backtrace.join($/)) if Rails.env.development?
138
137
  ['error'] # return empty array when error occures
@@ -145,8 +144,7 @@ end
145
144
  def add_view_code
146
145
  return '' if (data = @record.send(@yaml['name'])).blank?
147
146
 
148
- ar = @yaml['view'].split(/\ |\,/).delete_if {|e| e.blank?}
149
- table, form_name = *ar
147
+ table, form_name = @yaml['view'].split(/\ |\,/).delete_if { |e| e.blank? }
150
148
  url = @parent.url_for(controller: :cmsedit, id: data, action: :edit, table: table, form_name: form_name, readonly: true, window_close: 1 )
151
149
  icon = @parent.fa_icon('eye')
152
150
  %(<span class="dc-window-open" data-url="#{url}">#{icon}</span>)
@@ -159,9 +157,9 @@ def ro_standard
159
157
  value = @record.respond_to?(@yaml['name']) ? @record.send(@yaml['name']) : nil
160
158
  return self if value.blank?
161
159
 
160
+ html = ''
162
161
  choices = get_choices()
163
162
  if value.class == Array # multiple choices
164
- html = ''
165
163
  value.each do |element|
166
164
  choices.each do |choice|
167
165
  if choice.to_s == element.to_s
@@ -170,17 +168,17 @@ def ro_standard
170
168
  end
171
169
  end
172
170
  end
173
- return super(html)
174
171
  else
175
172
  choices.each do |choice|
176
173
  if choice.class == Array
177
- return super(choice.first) if choice.last.to_s == value.to_s
174
+ (html = choice.first; break) if choice.last.to_s == value.to_s
178
175
  else
179
- return super(choice) if choice.to_s == value.to_s
176
+ (html = choice; break) if choice.to_s == value.to_s
180
177
  end
181
178
  end
179
+ html << add_view_code if @yaml['view']
182
180
  end
183
- super('')
181
+ super(html)
184
182
  end
185
183
 
186
184
  ###########################################################################
@@ -193,9 +191,8 @@ def render
193
191
  # separate options and html part
194
192
  html_part = {}
195
193
  @yaml['html'].symbolize_keys!
196
- %i(class id style required).each { |sym| html_part[sym] = @yaml['html'].delete(sym) if html_part[sym]}
194
+ %i(class id style required).each { |sym| html_part[sym] = @yaml['html'].delete(sym) if @yaml['html'][sym] }
197
195
  html_part[:multiple] = true if @yaml['multiple']
198
-
199
196
  record = record_text_for(@yaml['name'])
200
197
  if html_part[:multiple]
201
198
  @html << @parent.select(record, @yaml['name'], get_choices, @yaml['html'], html_part)
@@ -224,4 +221,5 @@ def self.get_data(params, name)
224
221
  end
225
222
 
226
223
  end
224
+
227
225
  end
@@ -29,7 +29,8 @@ module DrgcmsFormFields
29
29
  # * +name:+ field name (required)
30
30
  # * +type:+ text_autocomplete (required)
31
31
  # * +table+ Collection (table) name. When defined search must contain field name
32
- # * +with_new+ Will add an icon for shortcut to add new document to collection
32
+ # * +with_new+ Will add an icon for shortcut to add new document to related collection
33
+ # * +with_edit+ Will add an icon for shortcut to edit (view) related document
33
34
  # * +is_id+ Field value represent value as id. If false, field will use entered value and not value selected with autocomplete. Default is true.
34
35
  # * +search:+ Search may consist of three parameters from which are separated either by dot (.)
35
36
  # * search_field_name; when table option is defined search must define field name which will be used for search query
@@ -43,8 +44,9 @@ module DrgcmsFormFields
43
44
  # type: text_autocomplete
44
45
  # search: dc_user.name
45
46
  # is_id: false
46
- # html:
47
- # size: 30
47
+ # size: 30
48
+ # with_new: user
49
+ # with_edit: user
48
50
  ###########################################################################
49
51
  class TextAutocomplete < DrgcmsField
50
52
 
@@ -58,8 +60,8 @@ def render
58
60
  table = @yaml['search']['table']
59
61
  ret_name = @yaml['search']['field']
60
62
  method = @yaml['search']['method']
61
- elsif @yaml['search'].match(/\./)
62
- table, ret_name, method = @yaml['search'].split(/\.|\,/).map(&:strip)
63
+ elsif @yaml['search'].match(/\.|\,| /)
64
+ table, ret_name, method = @yaml['search'].split(/\.|\,| /).map(&:strip)
63
65
  else
64
66
  ret_name = @yaml['search']
65
67
  end
@@ -76,51 +78,62 @@ def render
76
78
  end
77
79
  return ro_standard 'Table or field keyword not defined!' unless (table && ret_name)
78
80
  # TODO check if table exists
79
- t = table.classify.constantize
81
+ model_klass = table.classify.constantize
80
82
  # find record and return value of field
81
83
  value_send_as = 'p_' + @yaml['name']
82
84
  value = if @parent.params[value_send_as]
83
- @parent.params[value_send_as]
84
- elsif @record and @record[@yaml['name']]
85
- @record[@yaml['name']]
86
- end
85
+ @parent.params[value_send_as]
86
+ elsif @record && @record[@yaml['name']]
87
+ @record[@yaml['name']]
88
+ end
89
+ not_id = @parent.dc_dont?(@yaml['is_id'], false)
87
90
  # Found value to be written in field. If field is not found write out value.
88
- if value
89
- record = t.find(value) unless @yaml['not_id'] # don't if it's is not an id
90
- value_displayed = record ? record.send(ret_name) : value
91
+ value_displayed = value
92
+ if value && !not_id
93
+ if BSON::ObjectId.legal?(value)
94
+ record = model_klass.find(value)
95
+ value_displayed = record.send(ret_name) if record
96
+ else
97
+ value_displayed = model_klass.send(ret_name, method, @parent, value)
98
+ end
91
99
  end
92
- # return if readonly
93
100
  return ro_standard(value_displayed) if @readonly
101
+
94
102
  # Add method back, so autocomplete will know that it must search for method inside class
95
103
  ret_name = "#{ret_name}.#{method}" if method
96
104
  @yaml['html'] ||= {}
97
105
  @yaml['html']['value'] = value_displayed
98
106
  @yaml['html']['placeholder'] ||= t('drgcms.search_placeholder') || nil
99
- #
107
+
100
108
  _name = '_' + @yaml['name']
101
109
  record = record_text_for(@yaml['name'])
102
110
  @html << '<span class="dc-text-autocomplete">' + @parent.text_field(record, _name, @yaml['html']) + '<span></span>'
111
+ # with new icon
103
112
  if @yaml['with_new']
104
- @html << ' ' +
105
- @parent.fa_icon('plus-square lg', class: 'in-edit-add', title: t('drgcms.new'),
106
- style: "vertical-align: top;", 'data-table' => @yaml['with_new'] )
113
+ @html << ' ' + @parent.fa_icon('plus-square lg', class: 'in-edit-add', title: t('drgcms.new'),
114
+ style: "vertical-align: top;", 'data-table' => @yaml['with_new'] )
115
+ end
116
+ # with edit icon
117
+ if @yaml['with_edit'] && @record[@yaml['name']].present?
118
+ @html << ' ' + @parent.fa_icon('edit lg', class: 'in-edit-add', title: t('drgcms.edit'),
119
+ style: "vertical-align: top;", 'data-table' => @yaml['with_edit'], 'data-id' => @record[@yaml['name']] )
107
120
  end
108
- @html << '</span>' + @parent.hidden_field(record, @yaml['name'], value: value) # actual value will be in hidden field
121
+ @html << '</span>' + @parent.hidden_field(record, @yaml['name'], value: value) # actual value will be in hidden field
122
+
109
123
  # JS stuff
110
124
  # allow unselected values on is_id: false option
111
- not_id = @parent.dc_dont?(@yaml['is_id'], false)
112
125
  not_id_code = %(
113
126
  if (ui.item == null) {
114
127
  $("##{record}_#{@yaml['name']}").val($("##{record}__#{@yaml['name']}").val() );
115
128
  return;
116
129
  } ) if not_id
117
- #
130
+
118
131
  @js << <<EOJS
119
132
  $(document).ready(function() {
120
133
  $("##{record}_#{_name}").autocomplete( {
121
134
  source: function(request, response) {
122
135
  $.ajax({
123
- url: '/dc_common/autocomplete',
136
+ url: "/dc_common/autocomplete",
124
137
  type: "POST",
125
138
  dataType: "json",
126
139
  data: { input: request.term, table: "#{table}", search: "#{ret_name}" #{(',id: "'+@yaml['id'] + '"') if @yaml['id']} },
@@ -131,11 +144,13 @@ $(document).ready(function() {
131
144
  }
132
145
  });
133
146
  },
147
+
134
148
  change: function (event, ui) {
135
149
  #{not_id_code}
150
+ if (ui.item == null) return;
136
151
  $("##{record}_#{@yaml['name']}").val(ui.item.id);
137
-
138
152
  },
153
+
139
154
  minLength: 2
140
155
  });
141
156
  });
@@ -152,4 +167,5 @@ def self.get_data(params, name)
152
167
  end
153
168
 
154
169
  end
170
+
155
171
  end
@@ -72,6 +72,7 @@ end
72
72
  #########################################################################
73
73
  def iframe
74
74
  return '' if @page.if_url.blank?
75
+
75
76
  html = "\n<iframe"
76
77
  html << " id=\"#{@page.if_id}\"" unless @page.if_id.blank?
77
78
  html << " class=\"#{@page.if_class}\"" unless @page.if_class.blank?
@@ -79,7 +80,7 @@ def iframe
79
80
  html << " height=\"#{@page.if_height}\"" unless @page.if_height.blank?
80
81
  html << " width=\"#{@page.if_width}\"" unless @page.if_width.blank?
81
82
  html << " scrolling=\"#{@page.if_scroll}\""
82
- # Parameters
83
+ # Parameters
83
84
  parameters = @page.if_url.match(/\?/) ? '' : '?'
84
85
  params = YAML.load(@page.if_params) rescue {}
85
86
  params = {} unless params.class == Hash
@@ -98,20 +99,20 @@ end
98
99
  def default
99
100
  can_view, msg = dc_user_can_view(@parent, @page)
100
101
  return msg unless can_view
101
- #
102
- html = ''
102
+
103
+ html = "<div class=\"#{@page.div_class} #{@opts[:div_class]}\">"
103
104
  html << dc_page_edit_menu() if @opts[:edit_mode] > 1
104
105
  @parent.page_title = @page.title.blank? ? @page.subject : @page.title
105
106
  html << @page.body
106
- # render poll if defined
107
+ # render poll if defined
107
108
  if @page.dc_poll_id
108
109
  @opts.merge!(:poll_id => @page.dc_poll_id, :return_to => @parent.request.url, method: nil)
109
110
  comment = DcPollRenderer.new(@parent, @opts)
110
111
  html << "<div class='wrap row'>#{comment.render_html}</div>"
111
112
  @css << "\n#{comment.render_css}"
112
113
  end
113
- # also add iframe
114
- html << iframe()
114
+ # also add iframe
115
+ html << iframe() << '</div>'
115
116
  end
116
117
 
117
118
  #########################################################################
@@ -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
@@ -38,11 +38,14 @@
38
38
 
39
39
  </div>
40
40
  </div>
41
-
42
- <div class="cmsedit-container">
41
+
42
+ <div id="menu-hamburger"><%= fa_icon('bars') %></div>
43
+
44
+ <div class="cmsedit-container">
43
45
  <div id="menu">
44
46
  <%= dc_choices4_cmsmenu.html_safe %>
45
47
  </div>
48
+
46
49
  <div class="cmsedit-iframe" style="width: 99%;">
47
50
  <iframe id="iframe_cms" name="iframe_cms"></iframe>
48
51
  </div>
@@ -1,6 +1,7 @@
1
1
 
2
- <%= dc_flash_messages %>
3
- <%= dc_error_messages_for @record %>
2
+ <%= dc_flash_messages %>
3
+ <%= dc_error_messages_for @record %>
4
+ <%= dc_warning_messages_for @record %>
4
5
 
5
6
  <div class="dc-form-frame">
6
7
 
@@ -1,24 +1,27 @@
1
1
 
2
2
  <div class="dc-table-frame">
3
3
 
4
- <% unless @records.nil? %>
5
- <%= dc_background_for_result(:start) %>
6
-
7
- <%= dc_header_for_result %>
8
- <% for document in @records %>
9
- <%= dc_row_for_result(document) %>
10
- <%= dc_actions_for_result(document) %>
11
- <%= dc_columns_for_result(document) %>
12
- </div>
13
- <% end %>
14
- <% if @record_footer %>
15
- <div class="dc-result-data footer">
16
- <%= dc_actions_column_for_footer() %>
17
- <%= dc_columns_for_result(@record_footer) %>
18
- </div>
19
- <% end %>
20
-
21
- <%= dc_background_for_result(:end) %>
4
+ <% if @form['result_set']['type'] == 'method' %>
5
+ <%= dc_process_result_set_method %>
6
+ <% elsif @records %>
7
+ <%= dc_background_for_result(:start) %>
8
+ <%= dc_header_for_result %>
9
+
10
+ <% for document in @records %>
11
+ <%= dc_row_for_result(document) %>
12
+ <%= dc_actions_for_result(document) %>
13
+ <%= dc_columns_for_result(document) %>
14
+ </div>
15
+ <% end %>
16
+
17
+ <% if @record_footer %>
18
+ <div class="dc-result-data footer">
19
+ <%= dc_actions_column_for_footer() %>
20
+ <%= dc_columns_for_result(@record_footer) %>
21
+ </div>
22
+ <% end %>
23
+
24
+ <%= dc_background_for_result(:end) %>
22
25
  <% end %>
23
26
  <%= dc_filter_popup() %>
24
27
 
@@ -1,7 +1,8 @@
1
1
  <%= dc_head_for_form %>
2
2
  <%= dc_table_title dc_edit_title() %>
3
3
 
4
- <%= form_tag( @parms, method: :put, id: 'cmsform', multipart: @form['form']['multipart'] ) do %>
4
+ <%= form_tag( @parms, method: :put, id: params['form_name'] || params['table'],
5
+ class: 'cmsform', multipart: @form['form']['multipart'] ) do %>
5
6
  <%= render partial: 'form' %>
6
7
  <% end %>
7
8
 
@@ -1,4 +1,4 @@
1
- <div class="dc-form-frame">
1
+ <div id="<%= params['form_name'] || params['table'] %>" class="dc-form-frame">
2
2
  <%= dc_title_for_index @records %>
3
3
 
4
4
  <%= dc_actions_for_index %>
@@ -1,6 +1,7 @@
1
- <%= dc_table_title dc_new_title() %>
1
+ <%= dc_table_title dc_new_title %>
2
2
 
3
- <%= form_tag( @parms, method: :post, id: 'cmsform', multipart: @form['form']['multipart'] ) do %>
3
+ <%= form_tag(@parms, method: :post, id: params['form_name'] || params['table'],
4
+ class: 'cmsform', multipart: @form['form']['multipart']) do %>
4
5
  <%= render partial: 'form' %>
5
6
  <% end %>
6
7
 
@@ -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>
@@ -3,15 +3,13 @@
3
3
  <head>
4
4
  <title><%= @page_title %></title>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+
6
8
  <%= stylesheet_link_tag "cms", media: 'all' %>
7
- <% if false %> not require in cms mode
8
- <style type="text/css" media="all"><%= "#{@site.css if @site}#{@design.css if @design}\n#{@page.css if @page}".html_safe %></style>
9
- <%= @site.header.html_safe if @site %>
10
- <% end %>
11
9
  <%= javascript_include_tag "cms" %>
12
10
  <%= csrf_meta_tags %>
13
11
  </head>
14
- <body>
12
+ <body id="body-cms">
15
13
 
16
14
  <%= yield %>
17
15