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.
- checksums.yaml +4 -4
- data/README.md +25 -10
- data/app/assets/javascripts/drg_cms/drg_cms.js +208 -81
- data/app/assets/stylesheets/drg_cms/drg_cms.css +298 -93
- data/app/assets/stylesheets/drg_cms/select-multiple.css +1 -1
- data/app/controllers/cmsedit_controller.rb +174 -167
- data/app/controllers/dc_application_controller.rb +230 -196
- data/app/controllers/dc_common_controller.rb +88 -50
- data/app/controls/dc_help_control.rb +138 -0
- data/app/controls/dc_report.rb +12 -16
- data/app/forms/all_options.yml +14 -5
- data/app/forms/cms_menu.yml +7 -1
- data/app/forms/dc_big_table.yml +0 -2
- data/app/forms/dc_big_table_value.yml +0 -2
- data/app/forms/dc_category.yml +2 -1
- data/app/forms/dc_design.yml +2 -2
- data/app/forms/dc_folder_permission.yml +0 -2
- data/app/forms/dc_help_1.yml +110 -0
- data/app/forms/dc_journal.yml +3 -1
- data/app/forms/dc_json_ld.yml +0 -3
- data/app/forms/dc_link.yml +1 -1
- data/app/forms/dc_menu.yml +8 -12
- data/app/forms/dc_menu_item.yml +2 -3
- data/app/forms/dc_page.yml +7 -2
- data/app/forms/dc_part.yml +1 -0
- data/app/forms/dc_piece.yml +1 -0
- data/app/forms/dc_policy.yml +2 -5
- data/app/forms/dc_poll.yml +13 -16
- data/app/forms/dc_seo.yml +1 -2
- data/app/forms/dc_simple_menu.yml +3 -2
- data/app/forms/dc_site.yml +5 -8
- data/app/forms/dc_user.yml +27 -11
- data/app/forms/dc_user_role.yml +3 -0
- data/app/helpers/cms_common_helper.rb +68 -4
- data/app/helpers/cms_edit_helper.rb +73 -55
- data/app/helpers/cms_helper.rb +70 -32
- data/app/helpers/cms_index_helper.rb +155 -102
- data/app/helpers/dc_application_helper.rb +132 -109
- data/app/models/concerns/dc_page_concern.rb +14 -4
- data/app/models/concerns/dc_piece_concern.rb +1 -1
- data/app/models/concerns/dc_policy_rule_concern.rb +20 -8
- data/app/models/concerns/dc_site_concern.rb +56 -44
- data/app/models/concerns/dc_user_concern.rb +58 -19
- data/app/models/dc_big_table.rb +2 -2
- data/app/models/dc_design.rb +29 -19
- data/app/models/dc_filter.rb +28 -22
- data/app/models/dc_key_value_store.rb +1 -0
- data/app/models/dc_permission.rb +19 -9
- data/app/models/dc_policy.rb +25 -14
- data/app/models/dc_policy_role.rb +22 -11
- data/app/models/dc_temp.rb +8 -1
- data/app/models/dc_user_role.rb +2 -2
- data/app/models/drgcms_form_fields/comment.rb +11 -2
- data/app/models/drgcms_form_fields/date_picker.rb +2 -0
- data/app/models/drgcms_form_fields/drgcms_field.rb +2 -1
- data/app/models/drgcms_form_fields/embedded.rb +9 -10
- data/app/models/drgcms_form_fields/file_field.rb +1 -1
- data/app/models/drgcms_form_fields/file_select.rb +2 -2
- data/app/models/drgcms_form_fields/hash_field.rb +11 -7
- data/app/models/drgcms_form_fields/link_to.rb +2 -2
- data/app/models/drgcms_form_fields/method.rb +5 -4
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +1 -1
- data/app/models/drgcms_form_fields/number_field.rb +4 -3
- data/app/models/drgcms_form_fields/readonly.rb +13 -17
- data/app/models/drgcms_form_fields/select.rb +24 -25
- data/app/models/drgcms_form_fields/text_autocomplete.rb +22 -14
- data/app/renderers/dc_page_renderer.rb +7 -6
- data/app/renderers/dc_poll_renderer.rb +16 -20
- data/app/views/cmsedit/_edit_stuff.html.erb +5 -2
- data/app/views/cmsedit/_form.html.erb +3 -2
- data/app/views/cmsedit/_result.html.erb +21 -18
- data/app/views/cmsedit/edit.html.erb +4 -1
- data/app/views/cmsedit/index.html.erb +3 -2
- data/app/views/cmsedit/new.html.erb +5 -2
- data/app/views/dc_common/_help.html.erb +17 -0
- data/app/views/layouts/models.html.erb +2 -1
- data/config/locales/drgcms_en.yml +17 -2
- data/config/locales/drgcms_sl.yml +20 -2
- data/config/locales/models_en.yml +7 -5
- data/config/locales/models_sl.yml +12 -9
- data/drg_cms.gemspec +16 -16
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +94 -2
- metadata +32 -30
- data/app/models/__dc_dummy.rb +0 -102
@@ -49,20 +49,17 @@ class Embedded < DrgcmsField
|
|
49
49
|
###########################################################################
|
50
50
|
# Render embedded field html code
|
51
51
|
###########################################################################
|
52
|
-
def render
|
53
|
-
#return self if @record.new_record? # would be in error otherwise
|
52
|
+
def render
|
54
53
|
# HTML defaults. Some must be set
|
55
54
|
@yaml['html'] ||= {}
|
56
|
-
@yaml['html']['
|
57
|
-
@yaml['html']
|
55
|
+
@yaml['html']['width'] ||= '99%'
|
56
|
+
html = @yaml['html'].inject('') { |r, val| r << "#{val.first}=\"#{val.last}\" " }
|
57
|
+
|
58
58
|
@yaml['action'] ||= 'index'
|
59
59
|
# defaults both way
|
60
60
|
@yaml['table'] ||= @yaml['form_name'] if @yaml['form_name']
|
61
61
|
@yaml['form_name'] ||= @yaml['table'] if @yaml['table']
|
62
|
-
|
63
|
-
html = ''
|
64
|
-
@yaml['html'].each {|k,v| html << "#{k}=\"#{v}\" "}
|
65
|
-
#
|
62
|
+
|
66
63
|
if @yaml['name'] == @yaml['table'] or @yaml['table'] == 'dc_memory'
|
67
64
|
tables = @yaml['table']
|
68
65
|
ids = @record.id
|
@@ -70,9 +67,11 @@ def render
|
|
70
67
|
tables = @parent.tables.inject('') { |r,v| r << "#{v[1]};" } + @yaml['table']
|
71
68
|
ids = @parent.ids.inject('') { |r,v| r << "#{v};" } + @record.id
|
72
69
|
end
|
73
|
-
|
70
|
+
# edit enabled embedded form on a readonly form
|
71
|
+
readonly = @yaml['readonly'].class == FalseClass ? nil : @readonly
|
72
|
+
opts = { controller: 'cmsedit', action: @yaml['action'],
|
74
73
|
ids: ids, table: tables, form_name: @yaml['form_name'],
|
75
|
-
field_name: @yaml['name'], iframe: "if_#{@yaml['name']}", readonly:
|
74
|
+
field_name: @yaml['name'], iframe: "if_#{@yaml['name']}", readonly: readonly }
|
76
75
|
# additional parameters if specified
|
77
76
|
@yaml['params'].each { |k,v| opts[k] = @parent.dc_value_for_parameter(v) } if @yaml['params']
|
78
77
|
|
@@ -43,7 +43,7 @@ class FileField < DrgcmsField
|
|
43
43
|
###########################################################################
|
44
44
|
def render
|
45
45
|
return self if @readonly
|
46
|
-
|
46
|
+
|
47
47
|
@html << @parent.file_field(nil,@yaml['name'], @yaml['html'])
|
48
48
|
self
|
49
49
|
end
|
@@ -50,10 +50,10 @@ class FileSelect < DrgcmsField
|
|
50
50
|
###########################################################################
|
51
51
|
def render
|
52
52
|
return ro_standard if @readonly
|
53
|
-
# retrieve
|
53
|
+
# retrieve file_select component from site settings
|
54
54
|
selector_string = @parent.dc_get_site.params['file_select'] if @parent.dc_get_site
|
55
55
|
selector_string ||= 'elfinder'
|
56
|
-
|
56
|
+
|
57
57
|
klas_string = selector_string.camelize
|
58
58
|
if DrgcmsFormFields.const_defined?(klas_string)
|
59
59
|
klas = DrgcmsFormFields::const_get(klas_string)
|
@@ -45,6 +45,7 @@ class HashField < DrgcmsField
|
|
45
45
|
###########################################################################
|
46
46
|
def ro_standard()
|
47
47
|
return self if @record[@yaml['name']].nil?
|
48
|
+
|
48
49
|
html = ''
|
49
50
|
@record[@yaml['name']].each do |key, value|
|
50
51
|
html << "#{key}:#{value}<br>"
|
@@ -57,10 +58,10 @@ end
|
|
57
58
|
###########################################################################
|
58
59
|
def render
|
59
60
|
return ro_standard if @readonly
|
61
|
+
|
60
62
|
set_initial_value
|
61
|
-
#
|
62
63
|
record = record_text_for(@yaml['name'])
|
63
|
-
# Convert Hash to values separated by colon
|
64
|
+
# Convert Hash to values separated by colon
|
64
65
|
if @record[@yaml['name']]
|
65
66
|
@yaml['html']['value'] = @record[@yaml['name']].to_a.inject('') {|r, e| r << "#{e.first}:#{e.last}\n"}
|
66
67
|
end
|
@@ -73,12 +74,15 @@ end
|
|
73
74
|
###########################################################################
|
74
75
|
def self.get_data(params, name)
|
75
76
|
return nil if params['record'][name].blank?
|
76
|
-
|
77
|
-
result = params['record'][name].split("\n").select {|e| !e.blank? }
|
78
|
-
return
|
79
|
-
# convert to Hash
|
77
|
+
|
78
|
+
result = params['record'][name].split("\n").select { |e| !e.blank? }
|
79
|
+
return if result.size == 0
|
80
|
+
# convert to Hash
|
80
81
|
ret = {}
|
81
|
-
result.map
|
82
|
+
result.map do |e|
|
83
|
+
key, value = e.chomp.split(':')
|
84
|
+
ret[key.strip] = value.strip if value.present?
|
85
|
+
end
|
82
86
|
ret
|
83
87
|
end
|
84
88
|
|
@@ -53,13 +53,13 @@ def render
|
|
53
53
|
@yaml['html'] ||= {}
|
54
54
|
@yaml['html']['class'] ||= 'dc-link dc-animate'
|
55
55
|
@yaml['html'].symbolize_keys!
|
56
|
-
|
56
|
+
|
57
57
|
@yaml[:id] = record._id if @yaml[:id] == 'id'
|
58
58
|
url = @yaml['url'] || "#{@yaml[:controller]}/#{@yaml[:action]}/#{@yaml[:id]}"
|
59
59
|
url.gsub!('//','/') # no action and id
|
60
60
|
url = '/' + @yaml['url'] unless url[0,1] == '/' # no leading /
|
61
61
|
url.chop if url[0,-1] == '/' # remove trailing /
|
62
|
-
|
62
|
+
|
63
63
|
caption = @yaml['caption'] || @yaml['text']
|
64
64
|
@html << @parent.dc_link_to(caption, @yaml['icon'], url, @yaml['html'])
|
65
65
|
self
|
@@ -24,9 +24,10 @@ module DrgcmsFormFields
|
|
24
24
|
|
25
25
|
###########################################################################
|
26
26
|
# Implementation of custom DRG CMS form field. Method field will call method or class method
|
27
|
-
# defined in eval option and add returned code to HTML output code.
|
28
|
-
#
|
29
|
-
# be
|
27
|
+
# defined in eval option and add returned code to HTML output code.
|
28
|
+
#
|
29
|
+
# It can be used in case when form contains complex data structure. For example set of pictures which can not
|
30
|
+
# be simply displayed by any other DRG Forms field.
|
30
31
|
#
|
31
32
|
# Form example:
|
32
33
|
# 50:
|
@@ -44,7 +45,7 @@ class Method < DrgcmsField
|
|
44
45
|
###########################################################################
|
45
46
|
def render
|
46
47
|
# might be defined as my_method or MyClass.my_method
|
47
|
-
clas, method = @yaml['eval'].split(
|
48
|
+
clas, method = @yaml['eval'].split(/\.|\,/).map(&:strip)
|
48
49
|
if method.nil?
|
49
50
|
if @parent.respond_to?(clas)
|
50
51
|
@html << @parent.send(clas, @record, @yaml, @readonly)
|
@@ -77,7 +77,7 @@ def render
|
|
77
77
|
method = @yaml['search']['method']
|
78
78
|
search = method.nil? ? field_name : "#{field_name}.#{method}"
|
79
79
|
elsif @yaml['search'].to_s.match(/\./)
|
80
|
-
table, field_name, method = @yaml['search'].split(/\.|\,/)
|
80
|
+
table, field_name, method = @yaml['search'].split(/\.|\,/).map(&:strip)
|
81
81
|
search = method.nil? ? field_name : "#{field_name}.#{method}"
|
82
82
|
else # search and table name are separated
|
83
83
|
search = field_name = @yaml['search']
|
@@ -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
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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,20 +120,20 @@ 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
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
Rails.logger.debug
|
131
|
+
return choices unless choices.class == String
|
132
|
+
|
133
|
+
choices.chomp.split(',').map { |e| e.match(':') ? e.split(':') : e }
|
134
|
+
rescue Exception => e
|
135
|
+
Rails.logger.debug "\nError in select eval. #{e.message}\n"
|
136
|
+
Rails.logger.debug(e.backtrace.join($/)) if Rails.env.development?
|
137
137
|
['error'] # return empty array when error occures
|
138
138
|
end
|
139
139
|
end
|
@@ -143,8 +143,8 @@ end
|
|
143
143
|
###########################################################################
|
144
144
|
def add_view_code
|
145
145
|
return '' if (data = @record.send(@yaml['name'])).blank?
|
146
|
-
|
147
|
-
table, form_name =
|
146
|
+
|
147
|
+
table, form_name = @yaml['view'].split(/\ |\,/).delete_if { |e| e.blank? }
|
148
148
|
url = @parent.url_for(controller: :cmsedit, id: data, action: :edit, table: table, form_name: form_name, readonly: true, window_close: 1 )
|
149
149
|
icon = @parent.fa_icon('eye')
|
150
150
|
%(<span class="dc-window-open" data-url="#{url}">#{icon}</span>)
|
@@ -157,9 +157,9 @@ def ro_standard
|
|
157
157
|
value = @record.respond_to?(@yaml['name']) ? @record.send(@yaml['name']) : nil
|
158
158
|
return self if value.blank?
|
159
159
|
|
160
|
+
html = ''
|
160
161
|
choices = get_choices()
|
161
162
|
if value.class == Array # multiple choices
|
162
|
-
html = ''
|
163
163
|
value.each do |element|
|
164
164
|
choices.each do |choice|
|
165
165
|
if choice.to_s == element.to_s
|
@@ -168,17 +168,17 @@ def ro_standard
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
171
|
-
return super(html)
|
172
171
|
else
|
173
172
|
choices.each do |choice|
|
174
173
|
if choice.class == Array
|
175
|
-
|
174
|
+
(html = choice.first; break) if choice.last.to_s == value.to_s
|
176
175
|
else
|
177
|
-
|
176
|
+
(html = choice; break) if choice.to_s == value.to_s
|
178
177
|
end
|
179
178
|
end
|
179
|
+
html << add_view_code if @yaml['view']
|
180
180
|
end
|
181
|
-
super(
|
181
|
+
super(html)
|
182
182
|
end
|
183
183
|
|
184
184
|
###########################################################################
|
@@ -186,16 +186,16 @@ end
|
|
186
186
|
###########################################################################
|
187
187
|
def render
|
188
188
|
return ro_standard if @readonly
|
189
|
+
|
189
190
|
set_initial_value('html','selected')
|
190
191
|
# separate options and html part
|
191
|
-
@yaml['html'].symbolize_keys!
|
192
192
|
html_part = {}
|
193
|
-
|
194
|
-
html_part[
|
195
|
-
html_part[:
|
193
|
+
@yaml['html'].symbolize_keys!
|
194
|
+
%i(class id style required).each { |sym| html_part[sym] = @yaml['html'].delete(sym) if html_part[sym]}
|
195
|
+
html_part[:multiple] = true if @yaml['multiple']
|
196
|
+
|
196
197
|
record = record_text_for(@yaml['name'])
|
197
|
-
if
|
198
|
-
html_part[:multiple] = true
|
198
|
+
if html_part[:multiple]
|
199
199
|
@html << @parent.select(record, @yaml['name'], get_choices, @yaml['html'], html_part)
|
200
200
|
@js << "$('##{record}_#{@yaml['name']}').selectMultiple();"
|
201
201
|
else
|
@@ -212,12 +212,11 @@ end
|
|
212
212
|
def self.get_data(params, name)
|
213
213
|
if params['record'][name].class == Array
|
214
214
|
params['record'][name].delete_if {|e| e.blank? }
|
215
|
-
return
|
215
|
+
return if params['record'][name].size == 0
|
216
216
|
|
217
217
|
# convert to BSON objects
|
218
218
|
is_id = BSON::ObjectId.legal?(params['record'][name].first)
|
219
219
|
return params['record'][name].map{ |e| BSON::ObjectId.from_string(e) } if is_id
|
220
|
-
return params['record'][name]
|
221
220
|
end
|
222
221
|
params['record'][name]
|
223
222
|
end
|
@@ -59,7 +59,7 @@ def render
|
|
59
59
|
ret_name = @yaml['search']['field']
|
60
60
|
method = @yaml['search']['method']
|
61
61
|
elsif @yaml['search'].match(/\./)
|
62
|
-
table, ret_name, method = @yaml['search'].split(
|
62
|
+
table, ret_name, method = @yaml['search'].split(/\.|\,/).map(&:strip)
|
63
63
|
else
|
64
64
|
ret_name = @yaml['search']
|
65
65
|
end
|
@@ -74,23 +74,29 @@ def render
|
|
74
74
|
nil
|
75
75
|
end
|
76
76
|
end
|
77
|
-
return 'Table or field keyword not defined!' unless (table
|
77
|
+
return ro_standard 'Table or field keyword not defined!' unless (table && ret_name)
|
78
78
|
# TODO check if table exists
|
79
|
-
|
79
|
+
model_klass = table.classify.constantize
|
80
80
|
# find record and return value of field
|
81
81
|
value_send_as = 'p_' + @yaml['name']
|
82
82
|
value = if @parent.params[value_send_as]
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
@parent.params[value_send_as]
|
84
|
+
elsif @record && @record[@yaml['name']]
|
85
|
+
@record[@yaml['name']]
|
86
|
+
end
|
87
|
+
not_id = @parent.dc_dont?(@yaml['is_id'], false)
|
87
88
|
# Found value to be written in field. If field is not found write out value.
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
value_displayed = value
|
90
|
+
if value && !not_id
|
91
|
+
if BSON::ObjectId.legal?(value)
|
92
|
+
record = model_klass.find(value)
|
93
|
+
value_displayed = record.send(ret_name) if record
|
94
|
+
else
|
95
|
+
value_displayed = model_klass.send(ret_name, method, @parent, value)
|
96
|
+
end
|
91
97
|
end
|
92
|
-
# return if readonly
|
93
98
|
return ro_standard(value_displayed) if @readonly
|
99
|
+
|
94
100
|
# Add method back, so autocomplete will know that it must search for method inside class
|
95
101
|
ret_name = "#{ret_name}.#{method}" if method
|
96
102
|
@yaml['html'] ||= {}
|
@@ -108,7 +114,6 @@ def render
|
|
108
114
|
@html << '</span>' + @parent.hidden_field(record, @yaml['name'], value: value) # actual value will be in hidden field
|
109
115
|
# JS stuff
|
110
116
|
# allow unselected values on is_id: false option
|
111
|
-
not_id = @parent.dc_dont?(@yaml['is_id'], false)
|
112
117
|
not_id_code = %(
|
113
118
|
if (ui.item == null) {
|
114
119
|
$("##{record}_#{@yaml['name']}").val($("##{record}__#{@yaml['name']}").val() );
|
@@ -120,7 +125,7 @@ $(document).ready(function() {
|
|
120
125
|
$("##{record}_#{_name}").autocomplete( {
|
121
126
|
source: function(request, response) {
|
122
127
|
$.ajax({
|
123
|
-
url:
|
128
|
+
url: "/dc_common/autocomplete",
|
124
129
|
type: "POST",
|
125
130
|
dataType: "json",
|
126
131
|
data: { input: request.term, table: "#{table}", search: "#{ret_name}" #{(',id: "'+@yaml['id'] + '"') if @yaml['id']} },
|
@@ -131,11 +136,13 @@ $(document).ready(function() {
|
|
131
136
|
}
|
132
137
|
});
|
133
138
|
},
|
139
|
+
|
134
140
|
change: function (event, ui) {
|
135
141
|
#{not_id_code}
|
142
|
+
if (ui.item == null) return;
|
136
143
|
$("##{record}_#{@yaml['name']}").val(ui.item.id);
|
137
|
-
|
138
144
|
},
|
145
|
+
|
139
146
|
minLength: 2
|
140
147
|
});
|
141
148
|
});
|
@@ -152,4 +159,5 @@ def self.get_data(params, name)
|
|
152
159
|
end
|
153
160
|
|
154
161
|
end
|
162
|
+
|
155
163
|
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' ? ' *' : '<
|
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 <<
|
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
|
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
|
168
|
+
return %(<div class="dc-form-error">#{message}</div>) unless can_view
|
173
169
|
|
174
|
-
html = @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
|
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 <<
|
192
|
-
html <<
|
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 <<
|
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 <<
|
212
|
-
html << poll.sub_text
|
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
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
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(' ',' ')) # 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
|
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,24 +1,27 @@
|
|
1
1
|
|
2
2
|
<div class="dc-table-frame">
|
3
3
|
|
4
|
-
<%
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
|