drg_cms 0.6.1.4 → 0.6.1.9
Sign up to get free protection for your applications and to get access to all the features.
- 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 +229 -95
- data/app/assets/stylesheets/drg_cms/drg_cms.css +608 -542
- 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 +54 -127
- data/app/controllers/dc_application_controller.rb +17 -2
- data/app/controllers/dc_common_controller.rb +13 -7
- data/app/controls/browse_models_control.rb +15 -26
- data/app/controls/cmsedit_control.rb +125 -0
- data/app/controls/dc_help_control.rb +13 -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/controls/design_element_settings_control.rb +1 -1
- data/app/forms/all_options.yml +23 -7
- data/app/forms/cms_menu.yml +24 -24
- data/app/forms/dc_big_table.yml +0 -2
- data/app/forms/dc_big_table_value.yml +0 -2
- data/app/forms/dc_browse_fields.yml +13 -9
- data/app/forms/dc_design.yml +1 -2
- data/app/forms/dc_folder_permission.yml +0 -2
- data/app/forms/dc_help_1.yml +2 -1
- data/app/forms/dc_json_ld.yml +0 -3
- data/app/forms/dc_menu.yml +6 -12
- data/app/forms/dc_menu_item.yml +1 -3
- data/app/forms/dc_page.yml +1 -2
- data/app/forms/dc_policy.yml +2 -5
- data/app/forms/dc_poll.yml +10 -16
- data/app/forms/dc_poll_result_export.yml +1 -1
- data/app/forms/dc_seo.yml +1 -2
- data/app/forms/dc_simple_menu.yml +1 -2
- data/app/forms/dc_site.yml +5 -7
- data/app/helpers/cms_common_helper.rb +8 -6
- data/app/helpers/cms_edit_helper.rb +61 -53
- data/app/helpers/cms_helper.rb +78 -42
- data/app/helpers/cms_index_helper.rb +198 -137
- data/app/helpers/dc_application_helper.rb +65 -43
- data/app/models/concerns/dc_page_concern.rb +1 -1
- data/app/models/concerns/dc_site_concern.rb +9 -3
- data/app/models/dc_big_table.rb +2 -2
- data/app/models/dc_filter.rb +45 -37
- data/app/models/dc_json_ld.rb +1 -1
- data/app/models/dc_part.rb +19 -9
- data/app/models/dc_site.rb +0 -1
- data/app/models/dc_temp.rb +7 -0
- data/app/models/drgcms_form_fields/comment.rb +11 -2
- 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 +14 -14
- data/app/models/drgcms_form_fields/text_autocomplete.rb +19 -11
- 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 +3 -2
- data/app/views/cmsedit/_result.html.erb +21 -18
- data/app/views/cmsedit/login.html.erb +1 -1
- 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 +5 -3
- data/config/locales/drgcms_sl.yml +5 -3
- data/config/locales/kaminari.yml +1 -1
- data/config/locales/models_sl.yml +1 -0
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +6 -12
- metadata +10 -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'] ? 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|
|
@@ -456,19 +454,43 @@ end
|
|
456
454
|
def dc_error_messages_for(doc)
|
457
455
|
return '' unless doc && doc.errors.any?
|
458
456
|
|
459
|
-
msgs = ''
|
460
|
-
doc.errors.each do |error|
|
457
|
+
msgs = doc.errors.inject('') do |r, error|
|
461
458
|
label = t("helpers.label.#{decamelize_type(doc.class)}.#{error.attribute}", error.attribute)
|
462
|
-
|
459
|
+
r << "<li>#{label} : #{error.message}</li>"
|
463
460
|
end
|
464
|
-
|
465
|
-
|
461
|
+
|
462
|
+
%(
|
466
463
|
<div class="dc-form-error">
|
467
464
|
<h2>#{t('drgcms.errors_no')} #{doc.errors.size}</h2>
|
468
465
|
<ul>#{msgs}</ul>
|
469
|
-
</div>
|
470
|
-
|
471
|
-
|
466
|
+
</div>).html_safe
|
467
|
+
end
|
468
|
+
|
469
|
+
####################################################################
|
470
|
+
# Returns warning messages if any set in a model.
|
471
|
+
#
|
472
|
+
# When warnings array is added to model its content can be written on top of the form.
|
473
|
+
#
|
474
|
+
# Parameters:
|
475
|
+
# [doc] Document. Document record which will be checked for errors.
|
476
|
+
#
|
477
|
+
# Returns:
|
478
|
+
# String. HTML code formatted for display.
|
479
|
+
####################################################################
|
480
|
+
def dc_warning_messages_for(doc)
|
481
|
+
return ''
|
482
|
+
return '' unless doc && doc.respond_to?(:warnings)
|
483
|
+
|
484
|
+
msgs = doc.warnings.inject('') do |r, error|
|
485
|
+
label = t("helpers.label.#{decamelize_type(doc.class)}.#{error.attribute}", error.attribute)
|
486
|
+
msgs << "<li>#{label} : #{error.message}</li>"
|
487
|
+
end
|
488
|
+
|
489
|
+
%(
|
490
|
+
<div class="dc-form-warning">
|
491
|
+
<h2>#{t('drgcms.warnings_no')} #{doc.warnings.size}</h2>
|
492
|
+
<ul>#{msgs}</ul>
|
493
|
+
</div>).html_safe
|
472
494
|
end
|
473
495
|
|
474
496
|
####################################################################
|
@@ -506,8 +528,8 @@ def dc_link_for_create(opts)
|
|
506
528
|
opts['action'] = 'new'
|
507
529
|
opts['controller'] ||= 'cmsedit'
|
508
530
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
509
|
-
dc_link_to(nil, _origin.fa_icon('plus-circle
|
510
|
-
{ 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
|
511
533
|
end
|
512
534
|
|
513
535
|
####################################################################
|
@@ -529,13 +551,13 @@ def dc_link_for_edit(opts)
|
|
529
551
|
title = opts.delete('title') #
|
530
552
|
title = t(title)
|
531
553
|
target = opts.delete('target') || 'iframe_cms'
|
532
|
-
icon = opts.delete('icon') || 'edit
|
554
|
+
icon = opts.delete('icon') || 'edit-o'
|
533
555
|
opts['controller'] ||= 'cmsedit'
|
534
556
|
opts['action'] ||= 'edit'
|
535
557
|
opts['form_name'] ||= opts['table'].to_s.split(';').last
|
536
558
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
537
|
-
dc_link_to(nil, _origin.fa_icon(icon
|
538
|
-
{ 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'})
|
539
561
|
end
|
540
562
|
|
541
563
|
####################################################################
|
@@ -544,8 +566,8 @@ end
|
|
544
566
|
def dc_link_menu_tag(title) #:nodoc:
|
545
567
|
html = %(
|
546
568
|
<dl>
|
547
|
-
<dt><div class='drgcms_popmenu' href="#">
|
548
|
-
#{_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)}
|
549
571
|
</div></dt>
|
550
572
|
<dd>
|
551
573
|
<ul class=' div-hidden drgcms_popmenu_class'>
|
@@ -600,17 +622,17 @@ def dc_page_edit_menu(opts = @opts)
|
|
600
622
|
title = "#{t('drgcms.edit')}: #{page.subject}"
|
601
623
|
opts[:editparams] ||= {}
|
602
624
|
dc_link_menu_tag(title) do |html|
|
603
|
-
opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', 'icon' => 'edit' )
|
604
|
-
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' )
|
605
627
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_content') )
|
606
628
|
|
607
|
-
opts[:editparams].merge!( edit_only: nil, 'icon' => '
|
629
|
+
opts[:editparams].merge!( edit_only: nil, 'icon' => 'edit-o' )
|
608
630
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_advanced') )
|
609
631
|
|
610
632
|
opts[:editparams].merge!( action: 'new', 'icon' => 'plus' )
|
611
633
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_page') )
|
612
634
|
|
613
|
-
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',
|
614
636
|
table: "#{_origin.site.page_class.underscore};dc_part" )
|
615
637
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_part') )
|
616
638
|
end.html_safe
|
@@ -757,7 +779,7 @@ def dc_choices4_cmsmenu
|
|
757
779
|
menus.to_a.sort.each do |index, menu| # sort menus, result is array of sorted hashes
|
758
780
|
next unless menu['caption']
|
759
781
|
icon = menu['icon'].match('/') ? image_tag(menu['icon']) : fa_icon(menu['icon']) #external or fa- image
|
760
|
-
html <<
|
782
|
+
html << %(<li class="cmsedit-top-level-menu"><div>#{icon}#{t(menu['caption'])}</div><ul>)
|
761
783
|
menu['items'].to_a.sort.each do |index1, value| # again, sort menu items first
|
762
784
|
html << if value['link']
|
763
785
|
opts = { target: value['target'] || 'iframe_cms' }
|
@@ -1057,9 +1079,9 @@ end
|
|
1057
1079
|
# Html code for edit iframe
|
1058
1080
|
########################################################################
|
1059
1081
|
def dc_iframe_edit(table, opts={})
|
1060
|
-
ret = if params.to_unsafe_h.size > 2
|
1082
|
+
ret = if params.to_unsafe_h.size > 2 && table # controller, action, path is minimal
|
1061
1083
|
params[:controller] = 'cmsedit'
|
1062
|
-
params[:action] = (params[:oper]
|
1084
|
+
params[:action] = (params[:oper] && (params[:oper] == 'edit')) ? 'edit' : 'index'
|
1063
1085
|
params[:action] = opts[:action] unless params[:oper]
|
1064
1086
|
params[:table] ||= table
|
1065
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
|
|
@@ -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_big_table.rb
CHANGED
@@ -78,10 +78,10 @@ class DcBigTable
|
|
78
78
|
########################################################################
|
79
79
|
# Will return possible choices for specified key prepared for usega in select input field.
|
80
80
|
########################################################################
|
81
|
-
def self.choices4(key, site, locale=nil)
|
81
|
+
def self.choices4(key, site = nil, locale = nil)
|
82
82
|
result = []
|
83
83
|
choices = find_by(key: key, site: site)
|
84
|
-
choices = find_by(key: key, site: nil) if choices.nil?
|
84
|
+
choices = find_by(key: key, site: nil) if site && choices.nil?
|
85
85
|
if choices
|
86
86
|
choices.dc_big_table_values.each do |choice|
|
87
87
|
description = choice.description
|
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
|
@@ -119,7 +119,7 @@ def self.get_filter_field(parent)
|
|
119
119
|
return '' if field.nil? && filter['input'].nil?
|
120
120
|
|
121
121
|
saved_readonly = parent.form['readonly']
|
122
|
-
parent.form['readonly'] =
|
122
|
+
parent.form['readonly'] = false # must be
|
123
123
|
field ||= {}
|
124
124
|
# If field has choices available in labels, use them. This is most likely select input field.
|
125
125
|
if field['name']
|
@@ -133,37 +133,37 @@ 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']
|
148
148
|
# create input field object
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
return '' if klas.nil?
|
153
|
-
|
149
|
+
html = ''
|
150
|
+
klass_string = field['type'].camelize
|
151
|
+
klass = DrgcmsFormFields::const_get(klass_string) rescue nil
|
154
152
|
# return data from object and create html code to display field
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
if klass
|
154
|
+
if drg_field = klass.new(parent, nil, field).render rescue nil
|
155
|
+
js = drg_field.js.blank? ? '' : parent.javascript_tag(drg_field.js)
|
156
|
+
html = %(<li class="no-background">
|
157
|
+
<span class="filter_field" data-url="#{url}">#{drg_field.html}
|
158
|
+
#{parent.fa_icon('search', class: 'record_filter_field_icon')}
|
159
|
+
#{js}</span></li>)
|
160
|
+
else
|
161
|
+
# Error. Forget filter
|
162
|
+
parent.session[ parent.form['table'] ][:filter] = nil
|
163
|
+
end
|
160
164
|
end
|
161
|
-
|
162
|
-
|
163
|
-
<span class="filter_field" data-url="#{url}">#{object.html}
|
164
|
-
#{parent.fa_icon('search lg', class: 'record_filter_field_icon')}
|
165
|
-
#{js}</span>
|
166
|
-
</li>)
|
165
|
+
parent.form['readonly'] = saved_readonly
|
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.
|
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
|
data/app/models/dc_temp.rb
CHANGED
@@ -137,4 +137,11 @@ def self.prepare(key:, clear: nil)
|
|
137
137
|
self.where(key: key)
|
138
138
|
end
|
139
139
|
|
140
|
+
########################################################################
|
141
|
+
# Order data by new key. Will update order field with values from new field
|
142
|
+
########################################################################
|
143
|
+
def self.reorder_by(key, new_order)
|
144
|
+
self.where(key: key).each { |doc| doc.order = data[key]; doc.save }
|
145
|
+
end
|
146
|
+
|
140
147
|
end
|
@@ -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
|
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
|
@@ -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
|
|