drg_cms 0.6.1.6 → 0.6.1.9
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 +203 -24
- data/app/assets/javascripts/drg_cms/drg_cms.js +183 -95
- data/app/assets/stylesheets/drg_cms/drg_cms.css +542 -509
- data/app/assets/stylesheets/drg_cms_application.css +1 -1
- data/app/assets/stylesheets/drg_cms_cms.css +1 -4
- data/app/controllers/cmsedit_controller.rb +25 -103
- data/app/controllers/dc_common_controller.rb +6 -5
- data/app/controls/browse_models_control.rb +15 -26
- data/app/controls/cmsedit_control.rb +125 -0
- data/app/controls/dc_help_control.rb +1 -1
- data/app/controls/dc_page_control.rb +0 -1
- data/app/controls/dc_poll_result_control.rb +1 -1
- data/app/controls/dc_report.rb +1 -1
- data/app/forms/all_options.yml +1 -1
- data/app/forms/cms_menu.yml +24 -24
- data/app/forms/dc_browse_fields.yml +13 -9
- data/app/forms/dc_poll_result_export.yml +1 -1
- data/app/helpers/cms_common_helper.rb +7 -5
- data/app/helpers/cms_edit_helper.rb +52 -45
- data/app/helpers/cms_helper.rb +76 -40
- data/app/helpers/cms_index_helper.rb +180 -139
- data/app/helpers/dc_application_helper.rb +37 -43
- data/app/models/concerns/dc_page_concern.rb +1 -1
- data/app/models/dc_filter.rb +30 -22
- data/app/models/dc_json_ld.rb +1 -1
- data/app/models/dc_part.rb +19 -9
- data/app/models/drgcms_form_fields/drgcms_field.rb +10 -4
- data/app/models/drgcms_form_fields/link_to.rb +1 -1
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +5 -5
- data/app/models/drgcms_form_fields/readonly.rb +3 -0
- data/app/models/drgcms_form_fields/select.rb +8 -7
- data/app/models/drgcms_form_fields/text_autocomplete.rb +2 -2
- data/app/renderers/dc_part_renderer.rb +1 -1
- data/app/renderers/dc_poll_renderer.rb +1 -1
- data/app/views/cmsedit/_edit_stuff.html.erb +12 -12
- data/app/views/cmsedit/login.html.erb +1 -1
- data/app/views/dc_common/paste_clipboard.html.erb +1 -1
- data/config/locales/drgcms_en.yml +2 -1
- data/config/locales/drgcms_sl.yml +2 -1
- data/config/locales/kaminari.yml +1 -1
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +4 -4
- metadata +4 -5
- data/app/views/cmsedit/__remove_edit_stuff.js.erb +0 -6
- data/app/views/cmsedit/__show.html.erb +0 -21
@@ -260,9 +260,9 @@ def dc_table_title(text, result_set = nil)
|
|
260
260
|
c = %(<div class="dc-title">#{text})
|
261
261
|
# help button
|
262
262
|
type = result_set.nil? ? 'form' : 'index'
|
263
|
-
form_name = params
|
264
|
-
url = url_for(controller: :dc_common, action: :help, type: type,
|
265
|
-
c << %(<div class="dc-help dc-link-ajax" data-url=#{url}>#{fa_icon('question-circle')}</div>)
|
263
|
+
form_name = CmsHelper.form_param(params) || CmsHelper.table_param(params)
|
264
|
+
url = url_for(controller: :dc_common, action: :help, type: type, f: form_name)
|
265
|
+
c << %(<div class="dc-help-icon dc-link-ajax" data-url=#{url}>#{fa_icon('question-circle')}</div>)
|
266
266
|
|
267
267
|
if result_set and result_set.respond_to?(:current_page)
|
268
268
|
c << %(<div class="dc-paginate">#{paginate(result_set, :params => {action: 'index', clear: 'no', filter: nil})}</div>)
|
@@ -281,21 +281,19 @@ def dc_edit_title
|
|
281
281
|
session[:form_processing] = "form:title:"
|
282
282
|
title = @form['form']['title']
|
283
283
|
# defined as form:title:edit
|
284
|
-
if title
|
284
|
+
if title && title['edit'] && !@form['readonly']
|
285
285
|
t( title['edit'], title['edit'] )
|
286
|
-
elsif title
|
286
|
+
elsif title && title['show'] && @form['readonly']
|
287
287
|
t( title['show'], title['show'] )
|
288
288
|
else
|
289
289
|
# concatenate title
|
290
290
|
c = (@form['readonly'] ? t('drgcms.show') : t('drgcms.edit')) + " : "
|
291
|
-
c << (@form['title'].class == String ? t( @form['title'], @form['title'] ) : t_tablename(@form['table']))
|
292
|
-
title = (
|
293
|
-
dc_deprecate('form:edit_title will be deprecated. Use form:title:field instead.') if @form['form']['edit_title']
|
291
|
+
c << (@form['title'].class == String ? t( @form['title'], @form['title'] ) : t_tablename(@form['table']))
|
292
|
+
title = title.try('field')
|
294
293
|
|
295
|
-
c << "#{@record[ title ]}
|
296
|
-
c
|
294
|
+
c << "#{@record[ title ]}" if title && @record.respond_to?(title)
|
295
|
+
c
|
297
296
|
end
|
298
|
-
c
|
299
297
|
end
|
300
298
|
|
301
299
|
############################################################################
|
@@ -341,10 +339,10 @@ end
|
|
341
339
|
# Similar to rails submit_tag, but also takes care of link icon, translation, ...
|
342
340
|
############################################################################
|
343
341
|
def dc_submit_tag(caption, icon, parms, rest={})
|
344
|
-
parms['class'] ||= 'dc-
|
342
|
+
parms['class'] ||= 'dc-link'
|
345
343
|
if icon
|
346
344
|
icon_image = if icon.match(/\./)
|
347
|
-
image_tag(icon
|
345
|
+
image_tag(icon)
|
348
346
|
elsif icon.match('<i')
|
349
347
|
icon
|
350
348
|
else
|
@@ -360,10 +358,10 @@ end
|
|
360
358
|
# Returns icon code if icon is specified
|
361
359
|
############################################################################
|
362
360
|
def dc_icon_for_link(icon)
|
363
|
-
return
|
361
|
+
return '' if icon.blank?
|
364
362
|
|
365
363
|
if icon.match(/\./)
|
366
|
-
_origin.image_tag(icon, class: 'dc-link-img
|
364
|
+
_origin.image_tag(icon, class: 'dc-link-img')
|
367
365
|
elsif icon.match('<i')
|
368
366
|
icon
|
369
367
|
else
|
@@ -379,20 +377,20 @@ def dc_link_to(caption, icon, parms, rest={})
|
|
379
377
|
if parms.class == Hash
|
380
378
|
parms.stringify_keys!
|
381
379
|
rest.stringify_keys!
|
382
|
-
|
380
|
+
url = parms.delete('url')
|
383
381
|
rest['target'] ||= parms.delete('target')
|
384
382
|
parms['controller'] ||= 'cmsedit'
|
385
383
|
icon_pos = parms.delete('icon_pos') || 'first'
|
386
384
|
end
|
387
|
-
|
385
|
+
|
388
386
|
icon_image = dc_icon_for_link(icon)
|
389
387
|
if caption
|
390
388
|
caption = t(caption, caption)
|
391
389
|
icon_image << ' ' if icon_image
|
392
390
|
end
|
393
|
-
|
394
|
-
|
395
|
-
|
391
|
+
|
392
|
+
body = (%w[first left].include?(icon_pos) ? "#{icon_image}#{caption}" : "#{caption} #{icon_image}").html_safe
|
393
|
+
url ? _origin.link_to(body, url, rest) : _origin.link_to(body, parms, rest)
|
396
394
|
end
|
397
395
|
|
398
396
|
####################################################################
|
@@ -417,7 +415,7 @@ def dc_flash_messages()
|
|
417
415
|
_origin.flash[:info] = nil
|
418
416
|
_origin.flash[:note] = nil
|
419
417
|
end
|
420
|
-
# Update fields on the form
|
418
|
+
# Update fields on the form
|
421
419
|
if _origin.flash[:update]
|
422
420
|
html << "<div class=\"dc-form-updates\">\n"
|
423
421
|
_origin.flash[:update].each do |field, value|
|
@@ -461,13 +459,11 @@ def dc_error_messages_for(doc)
|
|
461
459
|
r << "<li>#{label} : #{error.message}</li>"
|
462
460
|
end
|
463
461
|
|
464
|
-
|
462
|
+
%(
|
465
463
|
<div class="dc-form-error">
|
466
464
|
<h2>#{t('drgcms.errors_no')} #{doc.errors.size}</h2>
|
467
465
|
<ul>#{msgs}</ul>
|
468
|
-
</div>
|
469
|
-
eot
|
470
|
-
html.html_safe
|
466
|
+
</div>).html_safe
|
471
467
|
end
|
472
468
|
|
473
469
|
####################################################################
|
@@ -490,13 +486,11 @@ def dc_warning_messages_for(doc)
|
|
490
486
|
msgs << "<li>#{label} : #{error.message}</li>"
|
491
487
|
end
|
492
488
|
|
493
|
-
|
489
|
+
%(
|
494
490
|
<div class="dc-form-warning">
|
495
491
|
<h2>#{t('drgcms.warnings_no')} #{doc.warnings.size}</h2>
|
496
492
|
<ul>#{msgs}</ul>
|
497
|
-
</div>
|
498
|
-
eot
|
499
|
-
html.html_safe
|
493
|
+
</div>).html_safe
|
500
494
|
end
|
501
495
|
|
502
496
|
####################################################################
|
@@ -534,8 +528,8 @@ def dc_link_for_create(opts)
|
|
534
528
|
opts['action'] = 'new'
|
535
529
|
opts['controller'] ||= 'cmsedit'
|
536
530
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
537
|
-
dc_link_to(nil, _origin.fa_icon('plus-circle
|
538
|
-
{ onclick: js, title: title, alt: 'Create'}).html_safe
|
531
|
+
dc_link_to(nil, _origin.fa_icon('plus-circle'), '#',
|
532
|
+
{ onclick: js, title: title, alt: 'Create', class: 'dc-inline-link'}).html_safe
|
539
533
|
end
|
540
534
|
|
541
535
|
####################################################################
|
@@ -557,13 +551,13 @@ def dc_link_for_edit(opts)
|
|
557
551
|
title = opts.delete('title') #
|
558
552
|
title = t(title)
|
559
553
|
target = opts.delete('target') || 'iframe_cms'
|
560
|
-
icon = opts.delete('icon') || 'edit
|
554
|
+
icon = opts.delete('icon') || 'edit-o'
|
561
555
|
opts['controller'] ||= 'cmsedit'
|
562
556
|
opts['action'] ||= 'edit'
|
563
557
|
opts['form_name'] ||= opts['table'].to_s.split(';').last
|
564
558
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
565
|
-
dc_link_to(nil, _origin.fa_icon(icon
|
566
|
-
{ onclick: js, title: title, alt: 'Edit'})
|
559
|
+
dc_link_to(nil, _origin.fa_icon(icon), '#',
|
560
|
+
{ onclick: js, title: title, class: 'dc-inline-link', alt: 'Edit'})
|
567
561
|
end
|
568
562
|
|
569
563
|
####################################################################
|
@@ -572,8 +566,8 @@ end
|
|
572
566
|
def dc_link_menu_tag(title) #:nodoc:
|
573
567
|
html = %(
|
574
568
|
<dl>
|
575
|
-
<dt><div class='drgcms_popmenu' href="#">
|
576
|
-
#{_origin.fa_icon('file-text-o
|
569
|
+
<dt><div class='drgcms_popmenu dc-inline-link' href="#">
|
570
|
+
#{_origin.fa_icon('file-text-o', title: title)}
|
577
571
|
</div></dt>
|
578
572
|
<dd>
|
579
573
|
<ul class=' div-hidden drgcms_popmenu_class'>
|
@@ -628,17 +622,17 @@ def dc_page_edit_menu(opts = @opts)
|
|
628
622
|
title = "#{t('drgcms.edit')}: #{page.subject}"
|
629
623
|
opts[:editparams] ||= {}
|
630
624
|
dc_link_menu_tag(title) do |html|
|
631
|
-
opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', 'icon' => 'edit' )
|
632
|
-
opts[:editparams].merge!( :id => page.id, :
|
625
|
+
opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', 'icon' => 'edit-o' )
|
626
|
+
opts[:editparams].merge!( :id => page.id, :t => _origin.site.page_class.underscore, f: opts[:form_name], edit_only: 'body' )
|
633
627
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_content') )
|
634
628
|
|
635
|
-
opts[:editparams].merge!( edit_only: nil, 'icon' => '
|
629
|
+
opts[:editparams].merge!( edit_only: nil, 'icon' => 'edit-o' )
|
636
630
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_advanced') )
|
637
631
|
|
638
632
|
opts[:editparams].merge!( action: 'new', 'icon' => 'plus' )
|
639
633
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_page') )
|
640
634
|
|
641
|
-
opts[:editparams].merge!(ids: page.id, form_name: 'dc_part', 'icon' => 'plus
|
635
|
+
opts[:editparams].merge!(ids: page.id, form_name: 'dc_part', 'icon' => 'plus',
|
642
636
|
table: "#{_origin.site.page_class.underscore};dc_part" )
|
643
637
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_part') )
|
644
638
|
end.html_safe
|
@@ -785,7 +779,7 @@ def dc_choices4_cmsmenu
|
|
785
779
|
menus.to_a.sort.each do |index, menu| # sort menus, result is array of sorted hashes
|
786
780
|
next unless menu['caption']
|
787
781
|
icon = menu['icon'].match('/') ? image_tag(menu['icon']) : fa_icon(menu['icon']) #external or fa- image
|
788
|
-
html <<
|
782
|
+
html << %(<li class="cmsedit-top-level-menu"><div>#{icon}#{t(menu['caption'])}</div><ul>)
|
789
783
|
menu['items'].to_a.sort.each do |index1, value| # again, sort menu items first
|
790
784
|
html << if value['link']
|
791
785
|
opts = { target: value['target'] || 'iframe_cms' }
|
@@ -1085,9 +1079,9 @@ end
|
|
1085
1079
|
# Html code for edit iframe
|
1086
1080
|
########################################################################
|
1087
1081
|
def dc_iframe_edit(table, opts={})
|
1088
|
-
ret = if params.to_unsafe_h.size > 2
|
1082
|
+
ret = if params.to_unsafe_h.size > 2 && table # controller, action, path is minimal
|
1089
1083
|
params[:controller] = 'cmsedit'
|
1090
|
-
params[:action] = (params[:oper]
|
1084
|
+
params[:action] = (params[:oper] && (params[:oper] == 'edit')) ? 'edit' : 'index'
|
1091
1085
|
params[:action] = opts[:action] unless params[:oper]
|
1092
1086
|
params[:table] ||= table
|
1093
1087
|
params[:form_name] ||= opts[:form_name] || table
|
@@ -161,7 +161,7 @@ end
|
|
161
161
|
# Return filter options
|
162
162
|
########################################################################
|
163
163
|
def self.dc_filters
|
164
|
-
{'title' => 'drgcms.filters.this_site_only', 'operation' => 'eq',
|
164
|
+
{'title' => I18n.t('drgcms.filters.this_site_only'), 'operation' => 'eq',
|
165
165
|
'field' => 'dc_site_id', 'value' => '@current_site'}
|
166
166
|
end
|
167
167
|
|
data/app/models/dc_filter.rb
CHANGED
@@ -91,11 +91,11 @@ end
|
|
91
91
|
def self.get_field_form_definition(name, parent) #:nodoc:
|
92
92
|
form = parent.form
|
93
93
|
form['form']['tabs'].each do |tab|
|
94
|
-
# Array with 2 elements. First is tabname, second is data
|
94
|
+
# Array with 2 elements. First is tabname, second is data
|
95
95
|
my_fields = tab.last
|
96
96
|
my_fields.each {|k,v| return v if (k.class == Integer and v['name'] == name) }
|
97
97
|
end if form['form']['tabs'] # I know. But nice.
|
98
|
-
|
98
|
+
|
99
99
|
form['form']['fields'].each do |field|
|
100
100
|
next unless field.first.class == Integer # options
|
101
101
|
return field.last if field.last['name'] == name
|
@@ -133,15 +133,15 @@ def self.get_filter_field(parent)
|
|
133
133
|
field['type'] = filter['input'] if filter['input'].to_s.size > 5
|
134
134
|
field['type'] ||= 'text_field'
|
135
135
|
field['readonly'] = false # must be
|
136
|
+
# let text fields size be no more then 20
|
137
|
+
field['size'] = 20 if field['type'].match('text') && field['size'].to_i > 20
|
136
138
|
field['html'] ||= {}
|
137
|
-
field['html']['size'] = 20
|
138
139
|
# Start with last entered value
|
139
140
|
field['html']['value'] = filter['value'] unless filter['value'] == '#NIL'
|
140
141
|
field['html']['selected'] = field['html']['value'] # for select field
|
141
142
|
# url for filter ON action
|
142
|
-
field['html']['data-url'] = parent.url_for(
|
143
|
-
|
144
|
-
table: parent.form['table'], form_name: parent.params['form_name'])
|
143
|
+
field['html']['data-url'] = parent.url_for(controller: 'cmsedit', action: 'run', control: 'cmsedit.filter_on',
|
144
|
+
t: CmsHelper.table_param(parent.params), f: CmsHelper.form_param(parent.params))
|
145
145
|
url = field['html']['data-url']
|
146
146
|
# remove if present
|
147
147
|
field['with_new'] = nil if field['with_new']
|
@@ -155,7 +155,7 @@ def self.get_filter_field(parent)
|
|
155
155
|
js = drg_field.js.blank? ? '' : parent.javascript_tag(drg_field.js)
|
156
156
|
html = %(<li class="no-background">
|
157
157
|
<span class="filter_field" data-url="#{url}">#{drg_field.html}
|
158
|
-
#{parent.fa_icon('search
|
158
|
+
#{parent.fa_icon('search', class: 'record_filter_field_icon')}
|
159
159
|
#{js}</span></li>)
|
160
160
|
else
|
161
161
|
# Error. Forget filter
|
@@ -163,7 +163,7 @@ def self.get_filter_field(parent)
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
parent.form['readonly'] = saved_readonly
|
166
|
-
html
|
166
|
+
html.html_safe
|
167
167
|
end
|
168
168
|
|
169
169
|
######################################################################
|
@@ -178,41 +178,49 @@ def self.menu_filter(parent)
|
|
178
178
|
html << "<li data-filter=\"#{document.id}\">#{description}</li>"
|
179
179
|
end
|
180
180
|
|
181
|
-
# add filters defined in model
|
181
|
+
# add filters defined in model
|
182
182
|
model = table.classify.constantize
|
183
|
-
filters = model.dc_filters
|
183
|
+
filters = model.dc_filters if model.respond_to?(:dc_filters)
|
184
184
|
if filters
|
185
|
-
# only single defined. Convert to array.
|
185
|
+
# only single defined. Convert to array.
|
186
186
|
filters = [filters] if filters.class == Hash
|
187
|
-
filters.each do |filter|
|
188
|
-
url = parent.dc_link_to(filter['title'], nil,controller:
|
189
|
-
|
187
|
+
filters.each do |filter|
|
188
|
+
url = parent.dc_link_to(filter['title'], nil, controller: 'cmsedit', action: :run, t: table,
|
189
|
+
f: CmsHelper.form_param(parent.params),
|
190
|
+
control: 'cmsedit.filter_on',
|
191
|
+
filter_field: filter['field'],
|
192
|
+
filter_oper: filter['operation'],
|
193
|
+
filter_value: filter['value'])
|
194
|
+
|
195
|
+
url = parent.url_for(controller: 'cmsedit', action: :run, t: table, f: CmsHelper.form_param(parent.params),
|
196
|
+
control: 'cmsedit.filter_on',
|
190
197
|
filter_field: filter['field'],
|
191
198
|
filter_oper: filter['operation'],
|
192
|
-
filter_value: filter['value']
|
193
|
-
|
194
|
-
html << "<li>#{url}</li>"
|
199
|
+
filter_value: filter['value'])
|
200
|
+
html << %(<li class="dc-link-ajax in-menu" data-url="#{url}">#{filter['title']}</li>)
|
195
201
|
end
|
196
202
|
end
|
197
203
|
# divide standard and custom filter options
|
198
204
|
html << '<hr>' if html.size > 30 #
|
199
|
-
html <<
|
200
|
-
html
|
205
|
+
html << %(<li class="dc-link in-menu" id="open_drgcms_filter">#{I18n.t('drgcms.filter_set')}</li></ul>)
|
206
|
+
html.html_safe
|
201
207
|
end
|
202
208
|
|
203
209
|
######################################################################
|
204
210
|
# Creates title for turn filter off, which consists of displaying curently
|
205
211
|
# active filter and text to turn it off.
|
206
212
|
######################################################################
|
207
|
-
def self.title4_filter_off(
|
208
|
-
|
213
|
+
def self.title4_filter_off(filter_data)
|
214
|
+
return '' unless filter_data&.dig(:filter)
|
215
|
+
|
216
|
+
filter = YAML.load(filter_data[:filter])
|
209
217
|
operations = I18n.t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) {|r,v| r << v.split(':') }
|
210
218
|
operation = ''
|
211
219
|
if filter['operation'] == 'eval'
|
212
220
|
filter['field']
|
213
221
|
else
|
214
222
|
operations.each{|a| (operation = a.first; break) if a.last == filter['operation']}
|
215
|
-
|
223
|
+
|
216
224
|
'[ ' + I18n.t("helpers.label.#{filter['table']}.#{filter['field']}") +
|
217
225
|
" ] #{operation} [ #{filter['value'].to_s} ] : #{I18n.t('drgcms.filter_off')}"
|
218
226
|
end
|
data/app/models/dc_json_ld.rb
CHANGED
@@ -144,7 +144,7 @@ def self.add_schema_menu(parent)
|
|
144
144
|
yaml.each do |schema_name, schema_data|
|
145
145
|
next if level == 1 and schema_data['level'].nil?
|
146
146
|
url = "/dc_common/add_json_ld_schema?table=#{parent.params['table']}&ids=#{parent.params['ids']}&schema=#{schema_name}&url=#{parent.request.url}"
|
147
|
-
html << %Q[<li class="dc-link-ajax
|
147
|
+
html << %Q[<li class="dc-link-ajax in-menu" data-url="#{url}">#{schema_name}</li>]
|
148
148
|
end
|
149
149
|
html << '</ul>'
|
150
150
|
end
|
data/app/models/dc_part.rb
CHANGED
@@ -62,15 +62,25 @@
|
|
62
62
|
# taken into account when rendering part.
|
63
63
|
########################################################################
|
64
64
|
class DcPart
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
65
|
+
include DcPieceConcern
|
66
|
+
|
67
|
+
field :_type, type: String, default: 'DcPart' # needed when changed to Concern
|
68
|
+
field :policy_id, type: BSON::ObjectId
|
69
|
+
field :link, type: String
|
70
|
+
|
71
|
+
embedded_in :dc_parts, polymorphic: true
|
72
|
+
|
73
|
+
before_save :do_before_save
|
74
|
+
|
75
|
+
after_save :cache_clear
|
76
|
+
after_destroy :cache_clear
|
77
|
+
|
78
|
+
####################################################################
|
79
|
+
# Clear parent's record from cache if cache is configured
|
80
|
+
####################################################################
|
81
|
+
def cache_clear
|
82
|
+
_parent.cache_clear() if _parent&.respond_to?(:cache_clear)
|
83
|
+
end
|
74
84
|
|
75
85
|
######################################################################
|
76
86
|
# Implementation of before_save callback.
|
@@ -171,10 +171,16 @@ def set_default_value(opt1, opt2)
|
|
171
171
|
return if @record && @record[@yaml['name']].present?
|
172
172
|
|
173
173
|
@yaml[opt1][opt2] = if @yaml['default'].class == Hash
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
174
|
+
evaluate = @yaml['default']['eval']
|
175
|
+
return if evaluate.blank?
|
176
|
+
# add @parent if it's a method call and @parent is not present
|
177
|
+
if evaluate[0] != evaluate[0].upcase && !evaluate.match('@parent')
|
178
|
+
evaluate.prepend('@parent.')
|
179
|
+
end
|
180
|
+
eval(evaluate)
|
181
|
+
else
|
182
|
+
@yaml['default']
|
183
|
+
end
|
178
184
|
end
|
179
185
|
|
180
186
|
####################################################################
|
@@ -51,7 +51,7 @@ class LinkTo < DrgcmsField
|
|
51
51
|
###########################################################################
|
52
52
|
def render
|
53
53
|
@yaml['html'] ||= {}
|
54
|
-
@yaml['html']['class'] ||= 'dc-link
|
54
|
+
@yaml['html']['class'] ||= 'dc-link'
|
55
55
|
@yaml['html'].symbolize_keys!
|
56
56
|
|
57
57
|
@yaml[:id] = record._id if @yaml[:id] == 'id'
|
@@ -111,7 +111,7 @@ def render
|
|
111
111
|
@yaml['html']['placeholder'] = t('drgcms.search_placeholder')
|
112
112
|
_name = '_' + @yaml['name']
|
113
113
|
@html << '<div class="ui-autocomplete-border">'
|
114
|
-
@html << @parent.link_to(@parent.fa_icon('plus-square
|
114
|
+
@html << @parent.link_to(@parent.fa_icon('plus-square-o', class: 'dc-green'), '#',onclick: 'return false;') # dummy add. But it is usefull.
|
115
115
|
|
116
116
|
record = record_text_for(@yaml['name'])
|
117
117
|
# text field for autocomplete
|
@@ -119,7 +119,7 @@ def render
|
|
119
119
|
# direct link for adding new documents to collection
|
120
120
|
if @yaml['with_new'] and !@readonly
|
121
121
|
@html << ' ' +
|
122
|
-
@parent.fa_icon('plus-square
|
122
|
+
@parent.fa_icon('plus-square-o', class: 'in-edit-add', title: t('drgcms.new'),
|
123
123
|
style: "vertical-align: top;", 'data-table' => @yaml['with_new'] )
|
124
124
|
end
|
125
125
|
# div to list active selections
|
@@ -137,9 +137,9 @@ def render
|
|
137
137
|
end
|
138
138
|
# Related data is missing. It happends.
|
139
139
|
@html << if rec
|
140
|
-
link = @parent.link_to(@parent.fa_icon('
|
140
|
+
link = @parent.link_to(@parent.fa_icon('remove_circle', class: 'dc-red'), '#',
|
141
141
|
onclick: "$('##{rec.id}').hide(); var v = $('##{record}_#{@yaml['name']}_#{rec.id}'); v.val(\"-\" + v.val());return false;")
|
142
|
-
link = @parent.fa_icon('check
|
142
|
+
link = @parent.fa_icon('check', class: 'dc-green') if @readonly
|
143
143
|
field = @parent.hidden_field(record, "#{@yaml['name']}_#{rec.id}", value: element)
|
144
144
|
"<div id=\"#{rec.id}\" style=\"padding:4px;\">#{link} #{rec.send(field_name)}<br>#{field}</div>"
|
145
145
|
else
|
@@ -149,7 +149,7 @@ def render
|
|
149
149
|
end
|
150
150
|
@html << "</div></div>"
|
151
151
|
# Create text for div to be added when new category is selected
|
152
|
-
link = @parent.link_to(@parent.fa_icon('
|
152
|
+
link = @parent.link_to(@parent.fa_icon('remove_circle', class: 'dc-red'), '#',
|
153
153
|
onclick: "$('#rec_id').hide(); var v = $('##{record}_#{@yaml['name']}_rec_id'); v.val(\"-\" + v.val());return false;")
|
154
154
|
field = @parent.hidden_field(record, "#{@yaml['name']}_rec_id", value: 'rec_id')
|
155
155
|
one_div = "<div id=\"rec_id\" style=\"padding:4px;\">#{link} rec_search<br>#{field}</div>"
|
@@ -52,6 +52,9 @@ class Readonly < DrgcmsField
|
|
52
52
|
# Render readonly field html code
|
53
53
|
###########################################################################
|
54
54
|
def render
|
55
|
+
set_initial_value
|
56
|
+
@record[@yaml['name']] = @yaml['html']['value'] if @yaml['html']['value']
|
57
|
+
|
55
58
|
@html << @parent.hidden_field('record', @yaml['name']) # retain field as hidden field
|
56
59
|
@html << '<div class="dc-readonly">'
|
57
60
|
|
@@ -145,7 +145,7 @@ def add_view_code
|
|
145
145
|
return '' if (data = @record.send(@yaml['name'])).blank?
|
146
146
|
|
147
147
|
table, form_name = @yaml['view'].split(/\ |\,/).delete_if { |e| e.blank? }
|
148
|
-
url = @parent.url_for(controller:
|
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>)
|
151
151
|
end
|
@@ -189,16 +189,17 @@ def render
|
|
189
189
|
|
190
190
|
set_initial_value('html','selected')
|
191
191
|
# separate options and html part
|
192
|
-
|
192
|
+
options_part = {}
|
193
193
|
@yaml['html'].symbolize_keys!
|
194
|
-
%i(
|
195
|
-
|
194
|
+
%i(selected include_blank).each { |sym| options_part[sym] = @yaml['html'].delete(sym) if @yaml['html'][sym] }
|
195
|
+
@yaml['html'][:multiple] = true if @yaml['multiple']
|
196
|
+
|
196
197
|
record = record_text_for(@yaml['name'])
|
197
|
-
if
|
198
|
-
@html << @parent.select(record, @yaml['name'], get_choices, @yaml['html']
|
198
|
+
if @yaml['html'][:multiple]
|
199
|
+
@html << @parent.select(record, @yaml['name'], get_choices, options_part, @yaml['html'])
|
199
200
|
@js << "$('##{record}_#{@yaml['name']}').selectMultiple();"
|
200
201
|
else
|
201
|
-
@html << @parent.select(record, @yaml['name'], get_choices, @yaml['html']
|
202
|
+
@html << @parent.select(record, @yaml['name'], get_choices, options_part, @yaml['html'])
|
202
203
|
# add code for view more data
|
203
204
|
@html << add_view_code() if @yaml['view']
|
204
205
|
end
|
@@ -110,12 +110,12 @@ def render
|
|
110
110
|
@html << '<span class="dc-text-autocomplete">' + @parent.text_field(record, _name, @yaml['html']) + '<span></span>'
|
111
111
|
# with new icon
|
112
112
|
if @yaml['with_new']
|
113
|
-
@html << ' ' + @parent.fa_icon('plus-square
|
113
|
+
@html << ' ' + @parent.fa_icon('plus-square-o', class: 'in-edit-add', title: t('drgcms.new'),
|
114
114
|
style: "vertical-align: top;", 'data-table' => @yaml['with_new'] )
|
115
115
|
end
|
116
116
|
# with edit icon
|
117
117
|
if @yaml['with_edit'] && @record[@yaml['name']].present?
|
118
|
-
@html << ' ' + @parent.fa_icon('edit
|
118
|
+
@html << ' ' + @parent.fa_icon('edit-o', class: 'in-edit-add', title: t('drgcms.edit'),
|
119
119
|
style: "vertical-align: top;", 'data-table' => @yaml['with_edit'], 'data-id' => @record[@yaml['name']] )
|
120
120
|
end
|
121
121
|
@html << '</span>' + @parent.hidden_field(record, @yaml['name'], value: value) # actual value will be in hidden field
|
@@ -64,7 +64,7 @@ def render_particle(particle, opts)
|
|
64
64
|
return msg unless can_view
|
65
65
|
html = ''
|
66
66
|
if @opts[:edit_mode] > 1
|
67
|
-
opts[:editparams].merge!(title: "#{t('drgcms.edit')}: #{particle.name}", controller:
|
67
|
+
opts[:editparams].merge!(title: "#{t('drgcms.edit')}: #{particle.name}", controller: 'cmsedit')
|
68
68
|
html << dc_link_for_edit( opts[:editparams] )
|
69
69
|
end
|
70
70
|
#
|
@@ -120,7 +120,7 @@ def do_one_item(poll, yaml)
|
|
120
120
|
end
|
121
121
|
# submit and link tag
|
122
122
|
clas = yaml['type'].match(/submit_tag/) ? '' : 'dc-link-submit'
|
123
|
-
html << "<span class='#{clas}
|
123
|
+
html << "<span class='#{clas}'>#{field_html}#{yaml['separator']}</span>"
|
124
124
|
# other fields
|
125
125
|
else
|
126
126
|
html << case
|
@@ -2,36 +2,36 @@
|
|
2
2
|
<button class="cms-toggle mode-<%= session[:edit_mode] %>" title="<%= t('drgcms.toggle_cms')%>">CMS</button>
|
3
3
|
<% # = link_to('CMS', controller: 'dc_common', action: 'toggle_edit_mode', return_to: request.url) %>
|
4
4
|
<% if session[:edit_mode] > 1 %>
|
5
|
-
<div class="cmsedit-
|
6
|
-
<div id="menu">
|
5
|
+
<div class="cmsedit-top">
|
6
|
+
<div id="cms-top-menu">
|
7
7
|
|
8
8
|
<% if @page %>
|
9
|
-
<%= link_to( fa_icon('
|
9
|
+
<%= link_to( fa_icon('description-o', title: "#{t('drgcms.edit_page')}"),
|
10
10
|
{controller: 'cmsedit', action: 'edit', table: @site.page_class, id: @page._id}, target: 'iframe_cms') %>
|
11
11
|
<% end %>
|
12
12
|
|
13
13
|
<% if @design %>
|
14
|
-
<%= link_to( fa_icon('
|
14
|
+
<%= link_to( fa_icon('web', title: "#{t('drgcms.edit_design')}"),
|
15
15
|
{controller: 'cmsedit', action: 'edit', table: 'dc_design', id: @design._id}, target: 'iframe_cms') %>
|
16
16
|
<% end %>
|
17
17
|
|
18
18
|
<% if @site %>
|
19
|
-
<%= link_to( fa_icon('
|
19
|
+
<%= link_to( fa_icon('public', title: "#{t('drgcms.edit_site')}"),
|
20
20
|
{controller: 'cmsedit', action: 'edit', table: 'dc_site', id: @site._id}, target: 'iframe_cms') %>
|
21
21
|
<% end %>
|
22
|
-
<
|
22
|
+
<span>|</span>
|
23
23
|
|
24
|
-
<%= link_to( fa_icon('compress
|
24
|
+
<%= link_to( fa_icon('compress', title: t('drgcms.minimize')), '#',
|
25
25
|
onclick: "$('#iframe_cms').height(1); return false;" ) %>
|
26
26
|
|
27
|
-
<%= link_to( fa_icon('expand
|
27
|
+
<%= link_to( fa_icon('expand', title: t('drgcms.maximize')), '#',
|
28
28
|
onclick: "$('#iframe_cms').height( $('#iframe_cms').height() + 500);; return false;") %>
|
29
29
|
|
30
|
-
<%= link_to( fa_icon('refresh
|
30
|
+
<%= link_to( fa_icon('refresh', title: t('drgcms.reload')), '#',
|
31
31
|
onclick: "document.location.reload(true); return false;") %>
|
32
|
-
<
|
32
|
+
<span>|</span>
|
33
33
|
|
34
|
-
<%= link_to( fa_icon('
|
34
|
+
<%= link_to( fa_icon('content_paste-o', title: t('drgcms.doc_paste_title')),
|
35
35
|
{controller: 'dc_common', action: 'paste_clipboard'}, target: 'iframe_cms') %>
|
36
36
|
|
37
37
|
<%= DrgcmsFormFields::Elfinder.file_manager_url(self) %>
|
@@ -42,7 +42,7 @@
|
|
42
42
|
<div id="menu-hamburger"><%= fa_icon('bars') %></div>
|
43
43
|
|
44
44
|
<div class="cmsedit-container">
|
45
|
-
<div id="menu">
|
45
|
+
<div id="cms-menu">
|
46
46
|
<%= dc_choices4_cmsmenu.html_safe %>
|
47
47
|
</div>
|
48
48
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<div class="input"><%= password_field('record', 'password') %></div>
|
13
13
|
|
14
14
|
<div class="label"></div>
|
15
|
-
<div class="input"><%= submit_tag t('drgcms.login'), class: 'dc-
|
15
|
+
<div class="input"><%= submit_tag t('drgcms.login'), class: 'dc-submit' %></div>
|
16
16
|
<%= hidden_field_tag('return_to_error', request.url ) %>
|
17
17
|
<% end %>
|
18
18
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= dc_table_title t('drgcms.doc_paste_title') %>
|
3
3
|
|
4
4
|
<div class="dc-form-frame"><br>
|
5
|
-
<span class="dc-link
|
5
|
+
<span class="dc-link-ajax" data-request="post" title="<%= t('drgcms.doc_paste_clipboard') %>"
|
6
6
|
data-url="<%= url_for(controller: 'dc_common', action: 'paste_clipboard') %>"><%= t('drgcms.doc_paste_clipboard') %>
|
7
7
|
</span>
|
8
8
|
|
@@ -69,6 +69,7 @@ en:
|
|
69
69
|
toggle_cms: Toggle CMS edit/view mode
|
70
70
|
edit: Edit
|
71
71
|
show: Show
|
72
|
+
duplicate: Duplicate
|
72
73
|
new: New
|
73
74
|
sort: Sort
|
74
75
|
filter: Filter
|
@@ -117,7 +118,7 @@ en:
|
|
117
118
|
simple_message: Please write in the name of month no %{number} in a year.
|
118
119
|
|
119
120
|
filters:
|
120
|
-
this_site_only:
|
121
|
+
this_site_only: Only documents of currently selected web site
|
121
122
|
|
122
123
|
dc_help:
|
123
124
|
help: HELP
|