drg_cms 0.5.10.10 → 0.5.50.2
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 +2 -1
- data/app/assets/javascripts/drg_cms/drg_cms.js +7 -0
- data/app/assets/javascripts/drg_cms_cms.js +5 -13
- data/app/assets/stylesheets/drg_cms/{jquery-ui.css → __jquery-ui.css} +0 -0
- data/app/assets/stylesheets/drg_cms/drg_cms.css +121 -119
- data/app/assets/stylesheets/drg_cms_cms.css +4 -6
- data/app/controllers/{drgcms_controls/browse_models_control.rb → browse_models_control.rb} +1 -1
- data/app/controllers/cmsedit_controller.rb +6 -1
- data/app/controllers/dc_application_controller.rb +9 -2
- data/app/controllers/{drgcms_controls/dc_page_control.rb → dc_page_control.rb} +1 -1
- data/app/forms/all_options.yml +4 -1
- data/app/forms/dc_category.yml +1 -0
- data/app/forms/dc_design.yml +15 -3
- data/app/forms/dc_journal.yml +1 -1
- data/app/forms/dc_page.yml +0 -0
- data/app/helpers/cmsedit_helper.rb +2 -2
- data/app/helpers/dc_application_helper.rb +27 -14
- data/app/helpers/dc_poll_renderer.rb +12 -5
- data/app/models/dc_big_table.rb +11 -10
- data/app/models/dc_category.rb +17 -0
- data/app/models/dc_design.rb +2 -0
- data/app/models/drgcms_form_fields.rb +5 -3
- data/app/views/cmsedit/_edit_stuff.html.erb +29 -16
- data/config/initializers/kaminari_patch.rb +25 -5
- data/config/locales/models_en.yml +5 -0
- data/config/locales/models_sl.yml +6 -0
- data/config/routes.rb +0 -0
- data/drg_cms.gemspec +7 -5
- data/lib/drg_cms.rb +26 -8
- data/lib/drg_cms/version.rb +1 -1
- metadata +19 -19
@@ -11,13 +11,11 @@
|
|
11
11
|
*= require drg_cms/drg_cms
|
12
12
|
*= require drg_cms/jquery.datetimepicker.css
|
13
13
|
*= require drg_cms/select-multiple
|
14
|
-
|
15
|
-
*= require jquery-ui/
|
16
|
-
|
17
|
-
*= #require ../javascripts/drg_cms/elfinder/css/elfinder.min.css
|
18
|
-
*= #require ../javascripts/drg_cms/elfinder/css/theme.css
|
14
|
+
|
15
|
+
*= require jquery-ui/all
|
16
|
+
|
19
17
|
*= require font-awesome
|
20
18
|
*/
|
21
19
|
|
22
20
|
/* Required for link buttons to look alike */
|
23
|
-
.dc-link a, .dc-link-submit input {font-weight: bold; font-
|
21
|
+
.dc-link a, .dc-link-submit input {font-weight: bold; font-size: 12px; }
|
@@ -25,7 +25,7 @@
|
|
25
25
|
######################################################################
|
26
26
|
#
|
27
27
|
######################################################################
|
28
|
-
module
|
28
|
+
module BrowseModelsControl
|
29
29
|
include DcApplicationHelper
|
30
30
|
|
31
31
|
#########################################################################
|
@@ -77,7 +77,7 @@
|
|
77
77
|
########################################################################
|
78
78
|
class CmseditController < DcApplicationController
|
79
79
|
before_action :check_authorization, :except => [:login, :logout]
|
80
|
-
|
80
|
+
before_action :dc_reload_patches if Rails.env.development?
|
81
81
|
|
82
82
|
layout 'cms'
|
83
83
|
|
@@ -623,6 +623,11 @@ def check_authorization
|
|
623
623
|
# Extend class with methods defined in drgcms_controls module. May include embedded forms therefor ; => _
|
624
624
|
controls_string = (@form['controls'] ? @form['controls'] : params[:table].gsub(';','_')) + '_control'
|
625
625
|
controls = "DrgcmsControls::#{controls_string.classify}".constantize rescue nil
|
626
|
+
# version next
|
627
|
+
if controls.nil?
|
628
|
+
controls_string = "#{@form['controls'] || params[:table].gsub(';','_')}_control"
|
629
|
+
controls = "#{controls_string.classify}".constantize rescue nil
|
630
|
+
end
|
626
631
|
extend controls if controls
|
627
632
|
else
|
628
633
|
render(action: 'error', locals: { error: t('drgcms.not_authorized')} )
|
@@ -29,7 +29,7 @@
|
|
29
29
|
class DcApplicationController < ActionController::Base
|
30
30
|
protect_from_forgery
|
31
31
|
|
32
|
-
|
32
|
+
before_action :dc_reload_patches if Rails.env.development?
|
33
33
|
|
34
34
|
########################################################################
|
35
35
|
# Writes anything passed as parameter to logger file.
|
@@ -207,7 +207,8 @@ end
|
|
207
207
|
# Detects if called from mobile agent according to http://detectmobilebrowsers.com/
|
208
208
|
####################################################################
|
209
209
|
def dc_set_is_mobile
|
210
|
-
is_mobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.match(request.user_agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.match(request.user_agent[0..3])
|
210
|
+
is_mobile = request.user_agent ? /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.match(request.user_agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.match(request.user_agent[0..3])
|
211
|
+
: false
|
211
212
|
session[:is_mobile] = is_mobile ? 1 : 0
|
212
213
|
end
|
213
214
|
|
@@ -273,6 +274,12 @@ def get_design_and_render(design_doc)
|
|
273
274
|
layout = @site.site_layout.blank? ? 'content' : @site.site_layout
|
274
275
|
site_top = '<%= dc_page_top %>'
|
275
276
|
site_bottom = '<%= dc_page_bottom %>'
|
277
|
+
# lets try the rails way
|
278
|
+
if @options[:control] and @options[:action]
|
279
|
+
controller = "#{@options[:control]}_control".classify.constantize rescue nil
|
280
|
+
extend controller if controller
|
281
|
+
return send @options[:action] if respond_to?(@options[:action])
|
282
|
+
end
|
276
283
|
#
|
277
284
|
if design_doc
|
278
285
|
if !design_doc.rails_view.blank?
|
@@ -25,7 +25,7 @@
|
|
25
25
|
######################################################################
|
26
26
|
# DrgcmsControls for DcPage model.
|
27
27
|
######################################################################
|
28
|
-
module
|
28
|
+
module DcPageControl
|
29
29
|
|
30
30
|
######################################################################
|
31
31
|
# Called when new empty record is created
|
data/app/forms/all_options.yml
CHANGED
@@ -40,7 +40,7 @@ index:
|
|
40
40
|
caption: Some caption
|
41
41
|
|
42
42
|
result_set:
|
43
|
-
filter:
|
43
|
+
filter: custom_filter
|
44
44
|
actions_width: 100
|
45
45
|
per_page: 10
|
46
46
|
table_style: 'color: green;'
|
@@ -65,6 +65,7 @@ result_set:
|
|
65
65
|
icon: delete.png
|
66
66
|
4:
|
67
67
|
type: link
|
68
|
+
caption: Caption
|
68
69
|
controller: controller_name
|
69
70
|
action: action_name
|
70
71
|
table: table_name
|
@@ -127,6 +128,8 @@ form:
|
|
127
128
|
type: text_field
|
128
129
|
type: hidden_field
|
129
130
|
type: readonly
|
131
|
+
type: file_select
|
132
|
+
|
130
133
|
colspan: 2
|
131
134
|
size: 50 or
|
132
135
|
html:
|
data/app/forms/dc_category.yml
CHANGED
data/app/forms/dc_design.yml
CHANGED
@@ -41,18 +41,30 @@ form:
|
|
41
41
|
html:
|
42
42
|
include_blank: true
|
43
43
|
30:
|
44
|
-
name:
|
44
|
+
name: control
|
45
45
|
type: text_field
|
46
46
|
html:
|
47
47
|
size: 50
|
48
48
|
|
49
49
|
40:
|
50
|
+
name: control_method
|
51
|
+
type: text_field
|
52
|
+
html:
|
53
|
+
size: 50
|
54
|
+
|
55
|
+
50:
|
56
|
+
name: rails_view
|
57
|
+
type: text_field
|
58
|
+
html:
|
59
|
+
size: 50
|
60
|
+
|
61
|
+
60:
|
50
62
|
name: body
|
51
63
|
type: text_area
|
52
64
|
html:
|
53
|
-
size:
|
65
|
+
size: 120x25
|
54
66
|
|
55
|
-
|
67
|
+
70:
|
56
68
|
name: css
|
57
69
|
type: text_area
|
58
70
|
html:
|
data/app/forms/dc_journal.yml
CHANGED
data/app/forms/dc_page.yml
CHANGED
File without changes
|
@@ -630,7 +630,7 @@ def top_bottom_line(yaml, columns=2)
|
|
630
630
|
style = yaml['style']
|
631
631
|
end
|
632
632
|
clas ||= 'dc-separator'
|
633
|
-
"<tr><td colspan=\"#{columns*2}\" class=\"#{clas}\" style=\"#{style}\"></td></tr>"
|
633
|
+
"<tr><td> </td></tr><tr><td colspan=\"#{columns*2}\" class=\"#{clas}\" style=\"#{style}\"></td></tr><tr><td> </td></tr>"
|
634
634
|
end
|
635
635
|
|
636
636
|
############################################################################
|
@@ -788,7 +788,7 @@ def dc_document_statistics
|
|
788
788
|
parms = params.clone
|
789
789
|
parms[:controller] = 'dc_common'
|
790
790
|
parms[:action] = 'copy_clipboard'
|
791
|
-
url = url_for(parms)
|
791
|
+
url = url_for(parms.permit!)
|
792
792
|
# caption = image_tag('drg_cms/copy.png', title: t('drgcms.doc_copy_clipboard'))
|
793
793
|
# html << %Q[<hr><img class="dc-link-img dc-link-ajax dc-animate" data-url="#{url}" data-request="get" #{caption}]
|
794
794
|
html << fa_icon('copy 2x', class: 'dc-link-img dc-link-ajax dc-animate',
|
@@ -74,6 +74,10 @@ end
|
|
74
74
|
# Parameters:
|
75
75
|
# [renderer] String or Symbol. Class name (in lowercase) that will be used to render final HTML code.
|
76
76
|
# If class name is provided without '_renderer' suffix it will be added automatically.
|
77
|
+
#
|
78
|
+
# When renderer has value :part, it is a shortcut for dc_render_design_part method which
|
79
|
+
# is used to draw parts of layout on design.
|
80
|
+
#
|
77
81
|
# [opts] Hash. Additional options that are passed to method. Options are merged with
|
78
82
|
# options set on site, design, page and passed to renderer object.
|
79
83
|
#
|
@@ -81,6 +85,8 @@ end
|
|
81
85
|
# <%= dc_render(:dc_page, method: 'view', category: 'news') %>
|
82
86
|
############################################################################
|
83
87
|
def dc_render(renderer, opts={})
|
88
|
+
return dc_render_design_part(renderer[:part]) if renderer.class == Hash
|
89
|
+
#
|
84
90
|
opts[:edit_mode] = session[:edit_mode]
|
85
91
|
opts[:editparams] = {}
|
86
92
|
opts = @options.merge(opts) # merge options with parameters passed on site, page, design ...
|
@@ -239,9 +245,11 @@ def dc_edit_title()
|
|
239
245
|
c << (@form['title'] ? t( @form['title'], @form['title'] ) : t_tablename(@form['table'])) + ' : '
|
240
246
|
title = (title and title['field']) ? title['field'] : @form['form']['edit_title']
|
241
247
|
dc_deprecate('form:edit_title will be deprecated. Use form:title:field instead.') if @form['form']['edit_title']
|
248
|
+
#
|
242
249
|
c << "#{@record[ title ]} : " if title and @record.respond_to?(title)
|
243
|
-
c << @record._id
|
250
|
+
c << @record._id if @record
|
244
251
|
end
|
252
|
+
c
|
245
253
|
end
|
246
254
|
|
247
255
|
############################################################################
|
@@ -433,7 +441,9 @@ def dc_link_for_create(opts)
|
|
433
441
|
title = opts.delete('title') #
|
434
442
|
title = t(title, title) if title
|
435
443
|
target = opts.delete('target') || 'iframe_cms'
|
436
|
-
opts['
|
444
|
+
opts['form_name'] ||= opts['table']
|
445
|
+
opts['action'] = 'new'
|
446
|
+
opts['controller'] ||= 'cmsedit'
|
437
447
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
438
448
|
dc_link_to(nil, _origin.fa_icon('plus-circle lg', class: 'dc-inline-link'), '#',
|
439
449
|
{ onclick: js, title: title, alt: 'Create'}).html_safe
|
@@ -456,8 +466,9 @@ def dc_link_for_edit(opts)
|
|
456
466
|
opts.stringify_keys!
|
457
467
|
title = opts.delete('title') #
|
458
468
|
target = opts.delete('target') || 'iframe_cms'
|
459
|
-
opts['action'] = 'edit'
|
460
469
|
opts['controller'] ||= 'cmsedit'
|
470
|
+
opts['action'] = 'edit'
|
471
|
+
opts['form_name'] ||= opts['table']
|
461
472
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
462
473
|
dc_link_to(nil, _origin.fa_icon('edit lg', class: 'dc-inline-link'), '#',
|
463
474
|
{ onclick: js, title: title, alt: 'Edit'})
|
@@ -509,18 +520,19 @@ end
|
|
509
520
|
def dc_page_edit_menu(opts=@opts)
|
510
521
|
return '' if opts[:edit_mode] < 2
|
511
522
|
# save some data to cookie. This can not go to session.
|
523
|
+
page = opts[:page] || @page
|
512
524
|
table = _origin.site.page_table
|
513
|
-
kukis = { "#{table}.dc_design_id" =>
|
514
|
-
"#{table}.menu_id" =>
|
515
|
-
"#{table}.kats" =>
|
516
|
-
"#{table}.page_id" =>
|
525
|
+
kukis = { "#{table}.dc_design_id" => page.dc_design_id,
|
526
|
+
"#{table}.menu_id" => page.menu_id,
|
527
|
+
"#{table}.kats" => page.kats,
|
528
|
+
"#{table}.page_id" => page.id,
|
517
529
|
"#{table}.dc_site_id" => _origin.site.id
|
518
530
|
}
|
519
531
|
_origin.cookies[:record] = Marshal.dump(kukis)
|
520
|
-
title = "#{t('drgcms.edit')}: #{
|
532
|
+
title = "#{t('drgcms.edit')}: #{page.subject}"
|
521
533
|
dc_link_menu_tag(title) do |html|
|
522
534
|
opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', 'icon' => 'edit' )
|
523
|
-
opts[:editparams].merge!( :id =>
|
535
|
+
opts[:editparams].merge!( :id => page.id, :table => _origin.site.page_table, formname: opts[:formname], edit_only: 'body' )
|
524
536
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_content') )
|
525
537
|
|
526
538
|
# opts[:editparams][:edit_only] = nil
|
@@ -531,7 +543,7 @@ def dc_page_edit_menu(opts=@opts)
|
|
531
543
|
opts[:editparams].merge!( action: 'new', 'icon' => 'plus' )
|
532
544
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_page') )
|
533
545
|
|
534
|
-
opts[:editparams].merge!(ids:
|
546
|
+
opts[:editparams].merge!(ids: page.id, formname: 'dc_part', 'icon' => 'plus-square-o',
|
535
547
|
table: "#{_origin.site.page_table};dc_part" )
|
536
548
|
html << dc_link_for_edit1( opts[:editparams], t('drgcms.edit_new_part') )
|
537
549
|
end
|
@@ -687,8 +699,8 @@ end
|
|
687
699
|
def dc_name4_id(model, field, field_name, id=nil)
|
688
700
|
return '' if id.nil?
|
689
701
|
field_name = 'id' if field_name.nil?
|
690
|
-
model = model.classify.constantize if model.class == String
|
691
|
-
rec = Mongoid::QueryCache.cache { model.find_by(field_name.to_sym => id) }
|
702
|
+
model = model.strip.classify.constantize if model.class == String
|
703
|
+
rec = Mongoid::QueryCache.cache { model.find_by(field_name.strip.to_sym => id) }
|
692
704
|
rec.nil? ? '' : rec[field]
|
693
705
|
end
|
694
706
|
|
@@ -842,11 +854,11 @@ def dc_choices4_cmsmenu()
|
|
842
854
|
menus = forms_merge(menu['menu'], menus) # ignore top level part
|
843
855
|
end
|
844
856
|
#
|
845
|
-
html = ''
|
857
|
+
html = '<ul>'
|
846
858
|
menus.to_a.sort.each do |one_menu| # sort menus, result is array of sorted hashes
|
847
859
|
menu = one_menu[1] # value is the second (1) element of array
|
848
860
|
next unless menu['caption']
|
849
|
-
html << "<li>#{fa_icon(menu['icon'])}#{t(menu['caption'])}<ul>"
|
861
|
+
html << "<li class=\"cmsedit-top-level-menu\">#{fa_icon(menu['icon'])}#{t(menu['caption'])}<ul>"
|
850
862
|
menu['items'].to_a.sort.each do |item| # as above. sort items first
|
851
863
|
value = item[1]
|
852
864
|
opts = { controller: value['controller'],
|
@@ -1145,6 +1157,7 @@ def dc_iframe_edit(table, opts={})
|
|
1145
1157
|
params[:id] ||= params[:idp] || opts[:id]
|
1146
1158
|
params[:readonly] ||= opts[:readonly]
|
1147
1159
|
params[:path] = nil
|
1160
|
+
params.permit! # rails 5 request
|
1148
1161
|
"<iframe id='iframe_edit' name='iframe_edit' src='#{url_for params}'></iframe>"
|
1149
1162
|
else
|
1150
1163
|
"<iframe id='iframe_edit' name='iframe_edit'></iframe>"
|
@@ -58,7 +58,12 @@ def do_one_item(poll, yaml)
|
|
58
58
|
yaml['text'] ||= ''
|
59
59
|
#
|
60
60
|
text = yaml['text'].match(/\./) ? t(yaml['text']) : yaml['text']
|
61
|
-
|
61
|
+
if yaml['mandatory']
|
62
|
+
text << '<font color="red"> *</font>'
|
63
|
+
yaml['html'] ||= {}
|
64
|
+
yaml['html']['required'] = true
|
65
|
+
end
|
66
|
+
|
62
67
|
# Just add text if comment and go to next one
|
63
68
|
if yaml['type'] == 'comment'
|
64
69
|
html << if poll.display == 'lr'
|
@@ -112,9 +117,9 @@ def do_one_item(poll, yaml)
|
|
112
117
|
# other elements
|
113
118
|
else
|
114
119
|
html << if poll.display == 'lr'
|
115
|
-
"<tr><td class='poll-data-text'>#{text}</td><td class='poll-data-field'>#{field_html}</td></tr>\n"
|
120
|
+
"<tr><td class='poll-data-text'>#{text}</td><td class='poll-data-field #{yaml['class']}'>#{field_html}</td></tr>\n"
|
116
121
|
else
|
117
|
-
"<div class='poll-data-text'>#{text}</div><div class='poll-data-field'>#{field_html}#{yaml['separator']}</div>\n"
|
122
|
+
"<div class='poll-data-text'>#{text}</div><div class='poll-data-field #{yaml['class']}'>#{field_html}#{yaml['separator']}</div>\n"
|
118
123
|
end
|
119
124
|
end
|
120
125
|
end
|
@@ -130,7 +135,8 @@ def default
|
|
130
135
|
poll = DcPoll.find(poll_id)
|
131
136
|
poll = DcPoll.find_by(name: poll_id) if poll.nil? # name instead of id
|
132
137
|
return "<div class=\"dc-form-error\">Invalid Poll id #{poll_id}</div>" if poll.nil?
|
133
|
-
html =
|
138
|
+
html = @opts[:div] ? "<div id='#{@opts[:div]}'>" : ''
|
139
|
+
html << '<a name="poll-top"></a>'
|
134
140
|
|
135
141
|
# Operation called before poll is displayed. Usefull for filling predefined values into flash[:record][value]
|
136
142
|
# Called method must return at least one result if process can continue.
|
@@ -156,7 +162,7 @@ def default
|
|
156
162
|
html << "<div class=\"poll-div\">\n"
|
157
163
|
# edit link
|
158
164
|
if @opts[:edit_mode] > 1
|
159
|
-
@opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', id: poll._id, table: 'dc_poll' )
|
165
|
+
@opts[:editparams].merge!( controller: 'cmsedit', action: 'edit', id: poll._id, table: 'dc_poll', formname: 'dc_poll' )
|
160
166
|
@opts[:editparams].merge!(title: "#{t('drgcms.edit')}: #{poll.name}")
|
161
167
|
@opts[:editparams].delete(:ids) # this is from page, but it gets in a way
|
162
168
|
html << dc_link_for_edit( @opts[:editparams] )
|
@@ -207,6 +213,7 @@ def default
|
|
207
213
|
html << @parent.hidden_field_tag('poll_id', poll_id )
|
208
214
|
html << @parent.hidden_field_tag('page_id', @parent.page.id )
|
209
215
|
html << "</form></div>"
|
216
|
+
html << '</div>' if @opts[:div]
|
210
217
|
|
211
218
|
@part_css = poll.css
|
212
219
|
html
|
data/app/models/dc_big_table.rb
CHANGED
@@ -79,21 +79,22 @@ class DcBigTable
|
|
79
79
|
# Will return possible choices for specified key prepared for usega in select input field.
|
80
80
|
########################################################################
|
81
81
|
def self.choices4(key, site, locale=nil)
|
82
|
-
|
83
|
-
|
84
|
-
if
|
85
|
-
|
86
|
-
|
82
|
+
result = []
|
83
|
+
choices = find_by(key: key, site: site)
|
84
|
+
choices = find_by(key: key, site: nil) if choices.nil?
|
85
|
+
if choices
|
86
|
+
choices.dc_big_table_values.each do |choice|
|
87
|
+
description = choice.description
|
87
88
|
if locale
|
88
|
-
|
89
|
-
|
89
|
+
desc = choice.find_by('dc_big_table_values.locale' => locale)
|
90
|
+
description = desc.value if desc
|
90
91
|
end
|
91
|
-
|
92
|
+
result << [description, choice.value]
|
92
93
|
end
|
93
94
|
end
|
94
95
|
# Error if empty
|
95
|
-
|
96
|
-
|
96
|
+
result = [[I18n.t('drgcms.error'),I18n.t('drgcms.error')]] if result.size == 0
|
97
|
+
result
|
97
98
|
end
|
98
99
|
|
99
100
|
end
|
data/app/models/dc_category.rb
CHANGED
@@ -68,4 +68,21 @@ def self.values_for_parent #:nodoc:
|
|
68
68
|
where(parent: nil).sort(name: 1).inject([]) {|r,v| r << [v.name, v._id]}
|
69
69
|
end
|
70
70
|
|
71
|
+
#########################################################################
|
72
|
+
# Returns values for category type. Values should be defined in BigTable
|
73
|
+
# on the site level all owerall.
|
74
|
+
#########################################################################
|
75
|
+
def self.choices4_ctype(site_id=nil)
|
76
|
+
site_id = site_id.id if site_id
|
77
|
+
if DcBigTable.find_by(key: 'dc_category_type', :site.in => [site_id, nil])
|
78
|
+
DcBigTable.choices4('dc_category_type', site_id)
|
79
|
+
else
|
80
|
+
opts = I18n.t('helpers.label.dc_category.choices4_ctype')
|
81
|
+
# not defined
|
82
|
+
return [] if opts.blank?
|
83
|
+
opts.split(',').inject([]) {|result, e| result << e.split(':')}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
71
88
|
end
|
data/app/models/dc_design.rb
CHANGED
@@ -93,6 +93,8 @@ class DcDesign
|
|
93
93
|
field :body, type: String, default: ''
|
94
94
|
field :css, type: String, default: ''
|
95
95
|
field :rails_view, type: String, default: ''
|
96
|
+
field :control, type: String, default: ''
|
97
|
+
field :control_method, type: String, default: ''
|
96
98
|
field :author, type: String
|
97
99
|
field :active, type: Boolean, default: true
|
98
100
|
field :created_by, type: BSON::ObjectId
|
@@ -355,9 +355,11 @@ def render
|
|
355
355
|
@yaml['name'] = 'old' if @record[@yaml['name']].nil?
|
356
356
|
@html << '<table width="99%">'
|
357
357
|
JSON.parse(@record[@yaml['name']]).each do |k,v|
|
358
|
+
old_value = v.class == Array ? v[0] : v
|
359
|
+
new_value = v.class == Array ? v[1] : v
|
358
360
|
@html << "<tr><td style='background-color: #654ddd;'>#{@parent.check_box('select', k)} #{k}:</td></tr>
|
359
|
-
<tr><td style='background-color: #ffe;'
|
360
|
-
<tr><td style='background-color: #eff;'
|
361
|
+
<tr><td style='background-color: #ffe;'>- #{old_value}</td></tr>
|
362
|
+
<tr><td style='background-color: #eff;'>+ #{new_value}</td></tr>"
|
361
363
|
end
|
362
364
|
@html << '</table>'
|
363
365
|
self
|
@@ -596,7 +598,7 @@ def get_choices
|
|
596
598
|
choices.chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )} :
|
597
599
|
choices
|
598
600
|
rescue Exception => e
|
599
|
-
|
601
|
+
Rails.logger.debug "Error in select eval. #{e.message}\n"
|
600
602
|
['error'] # return empty array when error occures
|
601
603
|
end
|
602
604
|
end
|