drg_cms 0.6.1.5 → 0.6.1.11
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/fonts/ibm-plex-sans-300.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-400.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-500.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-600.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-700.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-italic.woff2 +0 -0
- data/app/assets/javascripts/drg_cms/drg_cms.js +253 -106
- data/app/assets/stylesheets/drg_cms/drg_cms.css +670 -521
- 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 +33 -211
- data/app/controllers/dc_application_controller.rb +98 -22
- data/app/controllers/dc_common_controller.rb +9 -22
- data/app/controls/browse_models_control.rb +18 -27
- data/app/controls/cmsedit_control.rb +129 -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 +2 -2
- data/app/controls/design_element_settings_control.rb +1 -1
- data/app/forms/all_options.yml +25 -7
- data/app/forms/cms_menu.yml +24 -24
- data/app/forms/dc_browse_fields.yml +13 -9
- data/app/forms/dc_browse_models.yml +24 -2
- data/app/forms/dc_poll_result_export.yml +1 -1
- data/app/forms/dc_site.yml +2 -5
- data/app/forms/dc_steps_template.yml +51 -0
- data/app/helpers/cms_common_helper.rb +73 -6
- data/app/helpers/cms_edit_helper.rb +275 -159
- data/app/helpers/cms_helper.rb +152 -59
- data/app/helpers/cms_index_helper.rb +220 -172
- data/app/helpers/dc_application_helper.rb +40 -67
- data/app/models/concerns/dc_page_concern.rb +1 -1
- data/app/models/concerns/dc_site_concern.rb +9 -3
- data/app/models/dc_filter.rb +30 -22
- data/app/models/dc_journal.rb +2 -2
- data/app/models/dc_json_ld.rb +19 -42
- data/app/models/dc_part.rb +19 -9
- data/app/models/dc_site.rb +0 -1
- 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 +4 -1
- data/app/models/drgcms_form_fields/select.rb +10 -9
- data/app/models/drgcms_form_fields/text_autocomplete.rb +20 -12
- data/app/models/drgcms_form_fields/text_with_select.rb +1 -0
- data/app/renderers/dc_common_renderer.rb +20 -3
- 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/_form.html.erb +19 -12
- data/app/views/cmsedit/edit.html.erb +10 -6
- data/app/views/cmsedit/index.html.erb +5 -3
- data/app/views/cmsedit/login.html.erb +1 -1
- data/app/views/cmsedit/new.html.erb +9 -5
- data/app/views/dc_common/_help.html.erb +1 -0
- data/app/views/dc_common/paste_clipboard.html.erb +1 -1
- data/app/views/layouts/cms.html.erb +3 -5
- data/config/locales/drgcms_en.yml +7 -1
- data/config/locales/drgcms_sl.yml +7 -1
- data/config/locales/kaminari.yml +1 -1
- data/drg_cms.gemspec +2 -2
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +4 -4
- metadata +16 -10
- data/app/views/cmsedit/__remove_edit_stuff.js.erb +0 -6
- data/app/views/cmsedit/__show.html.erb +0 -21
@@ -242,7 +242,7 @@ end
|
|
242
242
|
# and renderers during page rendering.
|
243
243
|
########################################################################
|
244
244
|
def dc_page_bottom
|
245
|
-
%(<style
|
245
|
+
%(<style>#{@css}</style>#{javascript_tag @js}).html_safe
|
246
246
|
end
|
247
247
|
|
248
248
|
############################################################################
|
@@ -258,13 +258,9 @@ end
|
|
258
258
|
############################################################################
|
259
259
|
def dc_table_title(text, result_set = nil)
|
260
260
|
c = %(<div class="dc-title">#{text})
|
261
|
-
|
262
|
-
type = result_set.nil? ? 'form' : 'index'
|
263
|
-
form_name = params[:form_name] || params[:table]
|
264
|
-
url = url_for(controller: :dc_common, action: :help, type: type, form_name: form_name)
|
265
|
-
c << %(<div class="dc-help dc-link-ajax" data-url=#{url}>#{fa_icon('question-circle')}</div>)
|
261
|
+
c << dc_help_button(result_set)
|
266
262
|
|
267
|
-
if result_set
|
263
|
+
if result_set && result_set.respond_to?(:current_page)
|
268
264
|
c << %(<div class="dc-paginate">#{paginate(result_set, :params => {action: 'index', clear: 'no', filter: nil})}</div>)
|
269
265
|
end
|
270
266
|
c << '<div style="clear: both;"></div></div>'
|
@@ -281,21 +277,19 @@ def dc_edit_title
|
|
281
277
|
session[:form_processing] = "form:title:"
|
282
278
|
title = @form['form']['title']
|
283
279
|
# defined as form:title:edit
|
284
|
-
if title
|
280
|
+
if title && title['edit'] && !@form['readonly']
|
285
281
|
t( title['edit'], title['edit'] )
|
286
|
-
elsif title
|
282
|
+
elsif title && title['show'] && @form['readonly']
|
287
283
|
t( title['show'], title['show'] )
|
288
284
|
else
|
289
285
|
# concatenate title
|
290
286
|
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']
|
287
|
+
c << (@form['title'].class == String ? t( @form['title'], @form['title'] ) : t_tablename(@form['table']))
|
288
|
+
title = title.try('field')
|
294
289
|
|
295
|
-
c << "#{@record[ title ]}
|
296
|
-
c
|
290
|
+
c << "#{@record[ title ]}" if title && @record.respond_to?(title)
|
291
|
+
c
|
297
292
|
end
|
298
|
-
c
|
299
293
|
end
|
300
294
|
|
301
295
|
############################################################################
|
@@ -304,11 +298,11 @@ end
|
|
304
298
|
# Returns:
|
305
299
|
# String. HTML code for title.
|
306
300
|
############################################################################
|
307
|
-
def dc_new_title
|
301
|
+
def dc_new_title
|
308
302
|
session[:form_processing] = "form:title:"
|
309
303
|
title = @form['form']['title']
|
310
304
|
# defined as form:title:new
|
311
|
-
if title
|
305
|
+
if title && title['new']
|
312
306
|
t( title['new'], title['new'] )
|
313
307
|
else
|
314
308
|
# in memory structures
|
@@ -341,10 +335,10 @@ end
|
|
341
335
|
# Similar to rails submit_tag, but also takes care of link icon, translation, ...
|
342
336
|
############################################################################
|
343
337
|
def dc_submit_tag(caption, icon, parms, rest={})
|
344
|
-
parms['class'] ||= 'dc-
|
338
|
+
parms['class'] ||= 'dc-link'
|
345
339
|
if icon
|
346
340
|
icon_image = if icon.match(/\./)
|
347
|
-
image_tag(icon
|
341
|
+
image_tag(icon)
|
348
342
|
elsif icon.match('<i')
|
349
343
|
icon
|
350
344
|
else
|
@@ -360,10 +354,10 @@ end
|
|
360
354
|
# Returns icon code if icon is specified
|
361
355
|
############################################################################
|
362
356
|
def dc_icon_for_link(icon)
|
363
|
-
return
|
357
|
+
return '' if icon.blank?
|
364
358
|
|
365
359
|
if icon.match(/\./)
|
366
|
-
_origin.image_tag(icon, class: 'dc-link-img
|
360
|
+
_origin.image_tag(icon, class: 'dc-link-img')
|
367
361
|
elsif icon.match('<i')
|
368
362
|
icon
|
369
363
|
else
|
@@ -379,20 +373,20 @@ def dc_link_to(caption, icon, parms, rest={})
|
|
379
373
|
if parms.class == Hash
|
380
374
|
parms.stringify_keys!
|
381
375
|
rest.stringify_keys!
|
382
|
-
|
376
|
+
url = parms.delete('url')
|
383
377
|
rest['target'] ||= parms.delete('target')
|
384
378
|
parms['controller'] ||= 'cmsedit'
|
385
379
|
icon_pos = parms.delete('icon_pos') || 'first'
|
386
380
|
end
|
387
|
-
|
381
|
+
|
388
382
|
icon_image = dc_icon_for_link(icon)
|
389
383
|
if caption
|
390
384
|
caption = t(caption, caption)
|
391
385
|
icon_image << ' ' if icon_image
|
392
386
|
end
|
393
|
-
|
394
|
-
|
395
|
-
|
387
|
+
|
388
|
+
body = (%w[first left].include?(icon_pos) ? "#{icon_image}#{caption}" : "#{caption} #{icon_image}").html_safe
|
389
|
+
url ? _origin.link_to(body, url, rest) : _origin.link_to(body, parms, rest)
|
396
390
|
end
|
397
391
|
|
398
392
|
####################################################################
|
@@ -417,7 +411,7 @@ def dc_flash_messages()
|
|
417
411
|
_origin.flash[:info] = nil
|
418
412
|
_origin.flash[:note] = nil
|
419
413
|
end
|
420
|
-
# Update fields on the form
|
414
|
+
# Update fields on the form
|
421
415
|
if _origin.flash[:update]
|
422
416
|
html << "<div class=\"dc-form-updates\">\n"
|
423
417
|
_origin.flash[:update].each do |field, value|
|
@@ -461,13 +455,11 @@ def dc_error_messages_for(doc)
|
|
461
455
|
r << "<li>#{label} : #{error.message}</li>"
|
462
456
|
end
|
463
457
|
|
464
|
-
|
458
|
+
%(
|
465
459
|
<div class="dc-form-error">
|
466
460
|
<h2>#{t('drgcms.errors_no')} #{doc.errors.size}</h2>
|
467
461
|
<ul>#{msgs}</ul>
|
468
|
-
</div>
|
469
|
-
eot
|
470
|
-
html.html_safe
|
462
|
+
</div>).html_safe
|
471
463
|
end
|
472
464
|
|
473
465
|
####################################################################
|
@@ -490,13 +482,11 @@ def dc_warning_messages_for(doc)
|
|
490
482
|
msgs << "<li>#{label} : #{error.message}</li>"
|
491
483
|
end
|
492
484
|
|
493
|
-
|
485
|
+
%(
|
494
486
|
<div class="dc-form-warning">
|
495
487
|
<h2>#{t('drgcms.warnings_no')} #{doc.warnings.size}</h2>
|
496
488
|
<ul>#{msgs}</ul>
|
497
|
-
</div>
|
498
|
-
eot
|
499
|
-
html.html_safe
|
489
|
+
</div>).html_safe
|
500
490
|
end
|
501
491
|
|
502
492
|
####################################################################
|
@@ -534,8 +524,8 @@ def dc_link_for_create(opts)
|
|
534
524
|
opts['action'] = 'new'
|
535
525
|
opts['controller'] ||= 'cmsedit'
|
536
526
|
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
|
527
|
+
dc_link_to(nil, _origin.fa_icon('plus-circle'), '#',
|
528
|
+
{ onclick: js, title: title, alt: 'Create', class: 'dc-inline-link'}).html_safe
|
539
529
|
end
|
540
530
|
|
541
531
|
####################################################################
|
@@ -557,13 +547,13 @@ def dc_link_for_edit(opts)
|
|
557
547
|
title = opts.delete('title') #
|
558
548
|
title = t(title)
|
559
549
|
target = opts.delete('target') || 'iframe_cms'
|
560
|
-
icon = opts.delete('icon') || 'edit
|
550
|
+
icon = opts.delete('icon') || 'edit-o'
|
561
551
|
opts['controller'] ||= 'cmsedit'
|
562
552
|
opts['action'] ||= 'edit'
|
563
553
|
opts['form_name'] ||= opts['table'].to_s.split(';').last
|
564
554
|
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'})
|
555
|
+
dc_link_to(nil, _origin.fa_icon(icon), '#',
|
556
|
+
{ onclick: js, title: title, class: 'dc-inline-link', alt: 'Edit'})
|
567
557
|
end
|
568
558
|
|
569
559
|
####################################################################
|
@@ -572,8 +562,8 @@ end
|
|
572
562
|
def dc_link_menu_tag(title) #:nodoc:
|
573
563
|
html = %(
|
574
564
|
<dl>
|
575
|
-
<dt><div class='drgcms_popmenu' href="#">
|
576
|
-
#{_origin.fa_icon('file-text-o
|
565
|
+
<dt><div class='drgcms_popmenu dc-inline-link' href="#">
|
566
|
+
#{_origin.fa_icon('file-text-o', title: title)}
|
577
567
|
</div></dt>
|
578
568
|
<dd>
|
579
569
|
<ul class=' div-hidden drgcms_popmenu_class'>
|
@@ -628,17 +618,17 @@ def dc_page_edit_menu(opts = @opts)
|
|
628
618
|
title = "#{t('drgcms.edit')}: #{page.subject}"
|
629
619
|
opts[:editparams] ||= {}
|
630
620
|
dc_link_menu_tag(title) do |html|
|
631
|
-
opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', 'icon' => 'edit' )
|
632
|
-
opts[:editparams].merge!( :id => page.id, :
|
621
|
+
opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', 'icon' => 'edit-o' )
|
622
|
+
opts[:editparams].merge!( :id => page.id, :t => _origin.site.page_class.underscore, f: opts[:form_name], edit_only: 'body' )
|
633
623
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_content') )
|
634
624
|
|
635
|
-
opts[:editparams].merge!( edit_only: nil, 'icon' => '
|
625
|
+
opts[:editparams].merge!( edit_only: nil, 'icon' => 'edit-o' )
|
636
626
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_advanced') )
|
637
627
|
|
638
628
|
opts[:editparams].merge!( action: 'new', 'icon' => 'plus' )
|
639
629
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_page') )
|
640
630
|
|
641
|
-
opts[:editparams].merge!(ids: page.id, form_name: 'dc_part', 'icon' => 'plus
|
631
|
+
opts[:editparams].merge!(ids: page.id, form_name: 'dc_part', 'icon' => 'plus',
|
642
632
|
table: "#{_origin.site.page_class.underscore};dc_part" )
|
643
633
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_part') )
|
644
634
|
end.html_safe
|
@@ -751,23 +741,6 @@ def dc_choices4_all_collections
|
|
751
741
|
choices.invert.to_a.sort # hash has to be inverted for values to be returned right
|
752
742
|
end
|
753
743
|
|
754
|
-
########################################################################
|
755
|
-
# Merges two forms when current form extends other form. Subroutine of dc_choices4_cmsmenu.
|
756
|
-
# With a little help of https://www.ruby-forum.com/topic/142809
|
757
|
-
########################################################################
|
758
|
-
def forms_merge(hash1, hash2) #:nodoc:
|
759
|
-
target = hash1.dup
|
760
|
-
hash2.keys.each do |key|
|
761
|
-
if hash2[key].is_a? Hash and hash1[key].is_a? Hash
|
762
|
-
target[key] = forms_merge(hash1[key], hash2[key])
|
763
|
-
next
|
764
|
-
end
|
765
|
-
target[key] = hash2[key] == '/' ? nil : hash2[key]
|
766
|
-
end
|
767
|
-
# delete keys with nil value
|
768
|
-
target.delete_if{ |k, v| v.nil? }
|
769
|
-
end
|
770
|
-
|
771
744
|
##########################################################################
|
772
745
|
# Returns choices for creating collection edit select field on CMS top menu.
|
773
746
|
##########################################################################
|
@@ -778,14 +751,14 @@ def dc_choices4_cmsmenu
|
|
778
751
|
next unless File.exist?(filename)
|
779
752
|
menu = YAML.load_file(filename) rescue nil # load menu
|
780
753
|
next if menu.nil? or !menu['menu'] # not menu or error
|
781
|
-
menus = forms_merge(menu['menu'], menus)
|
754
|
+
menus = CmsHelper.forms_merge(menu['menu'], menus) # ignore top level part
|
782
755
|
end
|
783
756
|
|
784
757
|
html = '<ul>'
|
785
758
|
menus.to_a.sort.each do |index, menu| # sort menus, result is array of sorted hashes
|
786
759
|
next unless menu['caption']
|
787
760
|
icon = menu['icon'].match('/') ? image_tag(menu['icon']) : fa_icon(menu['icon']) #external or fa- image
|
788
|
-
html <<
|
761
|
+
html << %(<li class="cmsedit-top-level-menu"><div>#{icon}#{t(menu['caption'])}</div><ul>)
|
789
762
|
menu['items'].to_a.sort.each do |index1, value| # again, sort menu items first
|
790
763
|
html << if value['link']
|
791
764
|
opts = { target: value['target'] || 'iframe_cms' }
|
@@ -1085,9 +1058,9 @@ end
|
|
1085
1058
|
# Html code for edit iframe
|
1086
1059
|
########################################################################
|
1087
1060
|
def dc_iframe_edit(table, opts={})
|
1088
|
-
ret = if params.to_unsafe_h.size > 2
|
1061
|
+
ret = if params.to_unsafe_h.size > 2 && table # controller, action, path is minimal
|
1089
1062
|
params[:controller] = 'cmsedit'
|
1090
|
-
params[:action] = (params[:oper]
|
1063
|
+
params[:action] = (params[:oper] && (params[:oper] == 'edit')) ? 'edit' : 'index'
|
1091
1064
|
params[:action] = opts[:action] unless params[:oper]
|
1092
1065
|
params[:table] ||= table
|
1093
1066
|
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
|
|
@@ -40,7 +40,6 @@ field :css, type: String, default: ''
|
|
40
40
|
field :route_name, type: String, default: ''
|
41
41
|
field :page_title, type: String
|
42
42
|
field :document_extension, type: String
|
43
|
-
field :page_table, type: String
|
44
43
|
field :page_class, type: String, default: 'DcPage'
|
45
44
|
field :site_layout, type: String, default: 'content'
|
46
45
|
field :menu_class, type: String, default: 'DcSimpleMenu'
|
@@ -87,10 +86,17 @@ def params(what=nil)
|
|
87
86
|
end
|
88
87
|
|
89
88
|
########################################################################
|
90
|
-
# Returns class object of collection
|
89
|
+
# Returns class object of page collection
|
91
90
|
########################################################################
|
92
91
|
def page_klass
|
93
|
-
|
92
|
+
page_class.classify.constantize
|
93
|
+
end
|
94
|
+
|
95
|
+
########################################################################
|
96
|
+
# Returns collection name for page collection
|
97
|
+
########################################################################
|
98
|
+
def page_table
|
99
|
+
page_class.underscore
|
94
100
|
end
|
95
101
|
|
96
102
|
########################################################################
|
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_journal.rb
CHANGED
data/app/models/dc_json_ld.rb
CHANGED
@@ -37,21 +37,21 @@
|
|
37
37
|
#
|
38
38
|
########################################################################
|
39
39
|
class DcJsonLd
|
40
|
-
|
41
|
-
|
40
|
+
include Mongoid::Document
|
41
|
+
include Mongoid::Timestamps
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
field :name, type: String
|
44
|
+
field :type, type: String
|
45
|
+
field :data, type: String
|
46
|
+
field :active, type: Boolean, default: true
|
47
47
|
|
48
|
-
|
48
|
+
embeds_many :dc_json_lds, :cyclic => true
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
field :created_by, type: BSON::ObjectId
|
51
|
+
field :updated_by, type: BSON::ObjectId
|
52
|
+
|
53
|
+
validates :name, presence: true
|
54
|
+
validates :type, presence: true
|
55
55
|
|
56
56
|
##########################################################################
|
57
57
|
# Returns JSON LD data as YAML
|
@@ -71,29 +71,6 @@ def get_json_ld(parent_data)
|
|
71
71
|
yaml
|
72
72
|
end
|
73
73
|
|
74
|
-
########################################################################
|
75
|
-
# Searches forms path for file_name and returns full file name or nil if not found.
|
76
|
-
#
|
77
|
-
# @param [String] Form file name. File name can be passed as gem_name.filename. This can
|
78
|
-
# be useful when you are extending form but want to retain same name as original form
|
79
|
-
# For example. You are extending dc_user form from drg_cms gem and want to
|
80
|
-
# retain same dc_user name. This can be done by setting drg_cms.dc_user to extend option.
|
81
|
-
#
|
82
|
-
# @return [String] Form file name including path or nil if not found.
|
83
|
-
########################################################################
|
84
|
-
def self.dc_find_form_file(form_file)
|
85
|
-
form_path=nil
|
86
|
-
if form_file.match(/\.|\//)
|
87
|
-
form_path,form_file=form_file.split(/\.|\//)
|
88
|
-
end
|
89
|
-
DrgCms.paths(:forms).reverse.each do |path|
|
90
|
-
f = "#{path}/#{form_file}.yml"
|
91
|
-
return f if File.exist?(f) and (form_path.nil? or path.to_s.match(/\/#{form_path}\//i))
|
92
|
-
end
|
93
|
-
p "Form file #{form_file} not found!"
|
94
|
-
nil
|
95
|
-
end
|
96
|
-
|
97
74
|
########################################################################
|
98
75
|
# Find document by ids when document are embedded into main d even if embedded
|
99
76
|
#
|
@@ -105,9 +82,9 @@ end
|
|
105
82
|
def self.find_document_by_ids(tables, ids)
|
106
83
|
collection = tables.split(';').first.classify.constantize
|
107
84
|
ar_ids = ids.split(';')
|
108
|
-
# Find top document
|
85
|
+
# Find top document
|
109
86
|
document = collection.find(ar_ids.shift)
|
110
|
-
# Search for embedded document
|
87
|
+
# Search for embedded document
|
111
88
|
ar_ids.each {|id| document = document.dc_json_lds.find(id) }
|
112
89
|
document
|
113
90
|
end
|
@@ -116,7 +93,7 @@ end
|
|
116
93
|
# Returns possible options for type select field on form.
|
117
94
|
#########################################################################
|
118
95
|
def self.choices4_type()
|
119
|
-
yaml = YAML.load_file(
|
96
|
+
yaml = YAML.load_file( CmsHelper.form_file_find('json_ld_schema') )
|
120
97
|
|
121
98
|
yaml.inject([]) {|result, schema_name| result << schema_name.first }
|
122
99
|
end
|
@@ -125,7 +102,7 @@ end
|
|
125
102
|
# Create menu to add schema element. Called from DRGCMS Form action.
|
126
103
|
#########################################################################
|
127
104
|
def self.add_schema_menu(parent)
|
128
|
-
yaml = YAML.load_file(
|
105
|
+
yaml = YAML.load_file( CmsHelper.form_file_find('json_ld_schema') )
|
129
106
|
if (level = parent.params['ids'].split(';').size) == 1
|
130
107
|
# select only top level elements
|
131
108
|
yaml.delete_if { |schema_name, schema_data| schema_data['level'].nil? }
|
@@ -139,14 +116,14 @@ def self.add_schema_menu(parent)
|
|
139
116
|
end
|
140
117
|
yaml = _yaml
|
141
118
|
end
|
142
|
-
# create menu code
|
119
|
+
# create menu code
|
143
120
|
html = '<ul>'
|
144
121
|
yaml.each do |schema_name, schema_data|
|
145
122
|
next if level == 1 and schema_data['level'].nil?
|
146
123
|
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
|
124
|
+
html << %Q[<li class="dc-link-ajax in-menu" data-url="#{url}">#{schema_name}</li>]
|
148
125
|
end
|
149
126
|
html << '</ul>'
|
150
127
|
end
|
151
128
|
|
152
|
-
end
|
129
|
+
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.
|
data/app/models/dc_site.rb
CHANGED
@@ -38,7 +38,6 @@
|
|
38
38
|
# route_name String Default route name for creating page link. ex. page. Leave blank if not used.
|
39
39
|
# page_title String Default page title displayed in browser's top menu when title can not be extracted from document
|
40
40
|
# document_extension String Default document extension eg. html
|
41
|
-
# page_table String Name of table holding data for pages
|
42
41
|
# page_class String Rails model class name which defines table holding pages data usually DcPage
|
43
42
|
# site_layout String Rails layout used to draw response. This is by default content layout.
|
44
43
|
# menu_class String Rails model class name which defines table holding menu data usually DcMenu
|
@@ -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'
|