drg_cms 0.5.52.12 → 0.6.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/assets/javascripts/drg_cms/drg_cms.js +395 -120
- data/app/assets/javascripts/drg_cms/jstree.min.js +6 -6
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +476 -215
- data/app/assets/stylesheets/drg_cms/jstree.css +6 -12
- data/app/assets/stylesheets/drg_cms/select-multiple.css +19 -13
- data/app/assets/stylesheets/drg_cms_cms.css +1 -1
- data/app/controllers/cmsedit_controller.rb +474 -233
- data/app/controllers/dc_application_controller.rb +264 -41
- data/app/controllers/dc_common_controller.rb +75 -63
- data/app/{controllers → controls}/browse_models_control.rb +0 -0
- data/app/{controllers → controls}/dc_page_control.rb +24 -8
- data/app/controls/dc_poll_result_control.rb +88 -0
- data/app/controls/dc_report.rb +227 -0
- data/app/{controllers → controls}/design_element_settings_control.rb +0 -0
- data/app/forms/all_options.yml +70 -12
- data/app/forms/cms_menu.yml +26 -17
- data/app/forms/dc_ad.yml +11 -22
- data/app/forms/dc_big_table.yml +1 -0
- data/app/forms/dc_big_table_value.yml +1 -0
- data/app/forms/dc_design.yml +19 -16
- data/app/forms/dc_filter.yml +3 -6
- data/app/forms/dc_gallery.yml +53 -0
- data/app/forms/dc_json_ld.yml +59 -0
- data/app/forms/dc_key_value.yml +32 -0
- data/app/forms/dc_link.yml +16 -10
- data/app/forms/dc_menu_item.yml +6 -0
- data/app/forms/dc_page.yml +2 -7
- data/app/forms/dc_poll.yml +16 -9
- data/app/forms/dc_poll_item.yml +2 -1
- data/app/forms/dc_poll_result.yml +83 -0
- data/app/forms/dc_poll_result_export.yml +35 -0
- data/app/forms/dc_removed_url.yml +42 -0
- data/app/forms/dc_seo.yml +33 -0
- data/app/forms/dc_site.yml +2 -6
- data/app/forms/json_ld_schema.yml +168 -0
- data/app/helpers/cms_common_helper.rb +311 -0
- data/app/helpers/cms_edit_helper.rb +498 -0
- data/app/helpers/cms_helper.rb +230 -0
- data/app/helpers/cms_index_helper.rb +564 -0
- data/app/helpers/dc_application_helper.rb +195 -268
- data/app/models/{dc_dummy.rb → __dc_dummy.rb} +0 -0
- data/app/models/concerns/dc_page_concern.rb +31 -6
- data/app/models/concerns/dc_seo_concern.rb +66 -0
- data/app/models/concerns/dc_site_concern.rb +12 -1
- data/app/models/concerns/dc_user_concern.rb +5 -3
- data/app/models/dc_design.rb +2 -0
- data/app/models/dc_filter.rb +37 -20
- data/app/models/dc_gallery.rb +64 -0
- data/app/models/dc_json_ld.rb +152 -0
- data/app/models/dc_key_value.rb +48 -0
- data/app/models/dc_link.rb +1 -0
- data/app/models/dc_memory.rb +26 -4
- data/app/models/dc_page.rb +1 -2
- data/app/models/dc_permission.rb +30 -0
- data/app/models/dc_poll.rb +39 -19
- data/app/models/dc_poll_result.rb +46 -0
- data/app/models/dc_removed_url.rb +54 -0
- data/app/models/dc_temp.rb +140 -0
- data/app/models/drgcms_form_fields.rb +6 -1642
- data/app/models/drgcms_form_fields/action.rb +61 -0
- data/app/models/drgcms_form_fields/check_box.rb +72 -0
- data/app/models/drgcms_form_fields/comment.rb +53 -0
- data/app/models/drgcms_form_fields/date_picker.rb +104 -0
- data/app/models/drgcms_form_fields/date_select.rb +68 -0
- data/app/models/drgcms_form_fields/datetime_picker.rb +89 -0
- data/app/models/drgcms_form_fields/datetime_select.rb +73 -0
- data/app/models/drgcms_form_fields/drgcms_field.rb +287 -0
- data/app/models/drgcms_form_fields/embedded.rb +97 -0
- data/app/models/drgcms_form_fields/file_field.rb +52 -0
- data/app/models/drgcms_form_fields/file_select.rb +70 -0
- data/app/models/drgcms_form_fields/hash_field.rb +86 -0
- data/app/models/drgcms_form_fields/hidden_field.rb +52 -0
- data/app/models/drgcms_form_fields/html_field.rb +70 -0
- data/app/models/drgcms_form_fields/journal_diff.rb +60 -0
- data/app/models/drgcms_form_fields/link_to.rb +69 -0
- data/app/models/drgcms_form_fields/method.rb +65 -0
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +204 -0
- data/app/models/drgcms_form_fields/number_field.rb +92 -0
- data/app/models/drgcms_form_fields/password_field.rb +62 -0
- data/app/models/drgcms_form_fields/radio.rb +96 -0
- data/app/models/drgcms_form_fields/readonly.rb +79 -0
- data/app/models/drgcms_form_fields/select.rb +226 -0
- data/app/models/drgcms_form_fields/submit_tag.rb +58 -0
- data/app/models/drgcms_form_fields/text_area.rb +68 -0
- data/app/models/drgcms_form_fields/text_autocomplete.rb +155 -0
- data/app/models/drgcms_form_fields/text_field.rb +56 -0
- data/app/models/drgcms_form_fields/text_with_select.rb +95 -0
- data/app/models/drgcms_form_fields/tree_select.rb +169 -0
- data/app/{helpers → renderers}/dc_ad_renderer.rb +0 -0
- data/app/{helpers → renderers}/dc_big_menu_renderer.rb +1 -0
- data/app/{helpers → renderers}/dc_captcha_renderer.rb +0 -0
- data/app/{helpers → renderers}/dc_common_renderer.rb +0 -0
- data/app/renderers/dc_gallery_renderer.rb +95 -0
- data/app/{helpers → renderers}/dc_menu_renderer.rb +11 -4
- data/app/{helpers → renderers}/dc_page_renderer.rb +21 -3
- data/app/{helpers → renderers}/dc_part_renderer.rb +5 -4
- data/app/{helpers → renderers}/dc_piece_renderer.rb +1 -1
- data/app/{helpers → renderers}/dc_poll_renderer.rb +86 -51
- data/app/{helpers → renderers}/dc_renderer.rb +1 -0
- data/app/{helpers → renderers}/dc_simple_menu_renderer.rb +1 -0
- data/app/views/cmsedit/{remove_edit_stuff.js.erb → __remove_edit_stuff.js.erb} +0 -0
- data/app/views/cmsedit/{show.html.erb → __show.html.erb} +0 -0
- data/app/views/cmsedit/_edit_stuff.html.erb +4 -25
- data/app/views/cmsedit/_form.html.erb +4 -3
- data/app/views/cmsedit/_result.html.erb +2 -3
- data/app/views/cmsedit/edit.html.erb +2 -1
- data/app/views/cmsedit/index.html.erb +6 -1
- data/app/views/cmsedit/new.html.erb +1 -1
- data/config/locales/drgcms_en.yml +15 -3
- data/config/locales/drgcms_sl.yml +18 -6
- data/config/locales/models_en.yml +103 -19
- data/config/locales/models_sl.yml +102 -17
- data/drg_cms.gemspec +3 -3
- data/lib/drg_cms.rb +6 -2
- data/lib/drg_cms/version.rb +2 -2
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +9 -2
- data/lib/tasks/database.rake +6 -56
- data/lib/tasks/dc_cleanup.rake +1 -1
- metadata +106 -61
- data/app/assets/stylesheets/drg_cms/__jquery-ui.css +0 -339
- data/app/helpers/application_helper.rb +0 -2
- data/app/helpers/cmsedit_helper.rb +0 -844
- data/test/fixtures/drg_cms_test_data.rb +0 -87
@@ -0,0 +1,56 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module DrgcmsFormFields
|
24
|
+
|
25
|
+
###########################################################################
|
26
|
+
# Implementation of text_field DRG CMS form field.
|
27
|
+
#
|
28
|
+
# ===Form options:
|
29
|
+
# * +type:+ text_field (required)
|
30
|
+
# * +name:+ Field name (required)
|
31
|
+
# * +html:+ html options which apply to text_field field (optional)
|
32
|
+
#
|
33
|
+
# Form example:
|
34
|
+
# 10:
|
35
|
+
# name: title
|
36
|
+
# type: text_field
|
37
|
+
# size: 30
|
38
|
+
# html:
|
39
|
+
# required: yes
|
40
|
+
###########################################################################
|
41
|
+
class TextField < DrgcmsField
|
42
|
+
|
43
|
+
###########################################################################
|
44
|
+
# Render text_field field html code
|
45
|
+
###########################################################################
|
46
|
+
def render
|
47
|
+
#return ro_standard if @readonly
|
48
|
+
set_initial_value
|
49
|
+
#
|
50
|
+
record = record_text_for(@yaml['name'])
|
51
|
+
@html << @parent.text_field( record, @yaml['name'], @yaml['html'])
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module DrgcmsFormFields
|
24
|
+
|
25
|
+
###########################################################################
|
26
|
+
# Implementation of text_with_select DRG CMS form field. Field will provide
|
27
|
+
# text_field entry field with select dropdown box with optional values for the field.
|
28
|
+
# Form options are mostly same as in select field.
|
29
|
+
#
|
30
|
+
# ===Form options:
|
31
|
+
# * +name:+ field name (required)
|
32
|
+
# * +type:+ text_with_select (required)
|
33
|
+
# * +choices:+ Values for choices separated by comma. Values can also be specified like description:value.
|
34
|
+
# In this case description will be shown to user, but value will be saved to document.
|
35
|
+
# choices: 'OK:0,Ready:1,Error:2'
|
36
|
+
# choices: Ruby,Pyton,PHP
|
37
|
+
# * +eval:+ Choices will be provided by evaluating expression
|
38
|
+
# eval: dc_choices4('model_name','description_field_name','_id'); dc_choices4 helper will provide data for select field.
|
39
|
+
# eval: ModelName.choices4_field; ModelName class will define method choices4_field which
|
40
|
+
# will provide data for select field. Since expression is evaluated in the context of Form Field object
|
41
|
+
# Even session session variables can be accessed.
|
42
|
+
# eval: 'MyClass.method(@parent.session[:user_id])'
|
43
|
+
# When searching is more complex custom search method may be defined in CollectionName
|
44
|
+
# model which will provide result set for search.
|
45
|
+
# eval: collection_name.search_field_name.method_name;
|
46
|
+
# If choices or eval is not defined choices will be provided from translation helpers. For example:
|
47
|
+
# Collection has field status. Choices for field will be provided by en.helpers.model_name.choices4_status
|
48
|
+
# entry of english translation. English is of course default translation. If you provide translations in
|
49
|
+
# your local language then select choices will be localized.
|
50
|
+
# en.helpers.model_name.choices4_status: 'OK:0,Ready:1,Error:2'
|
51
|
+
# sl.helpers.model_name.choices4_status: 'V redu:0,Pripravljen:1,Napaka:2'
|
52
|
+
# * +html:+ html options which apply to select and text_field fields (optional)
|
53
|
+
#
|
54
|
+
# Form example:
|
55
|
+
# 10:
|
56
|
+
# name: link
|
57
|
+
# type: text_with_select
|
58
|
+
# eval: '@parent.dc_page_class.all_pages_for_site(@parent.dc_get_site)'
|
59
|
+
# html:
|
60
|
+
# size: 50
|
61
|
+
###########################################################################
|
62
|
+
class TextWithSelect < Select
|
63
|
+
|
64
|
+
###########################################################################
|
65
|
+
# Render text_with_select field html code
|
66
|
+
###########################################################################
|
67
|
+
def render
|
68
|
+
#return ro_standard if @readonly
|
69
|
+
set_initial_value('html','value')
|
70
|
+
|
71
|
+
record = record_text_for(@yaml['name'])
|
72
|
+
@html << @parent.text_field( record, @yaml['name'], @yaml['html'])
|
73
|
+
@yaml['html']['class'] ||= ''
|
74
|
+
@yaml['html']['class'] << ' text-with-select'
|
75
|
+
@yaml['html'].symbolize_keys!
|
76
|
+
unless @readonly
|
77
|
+
@html << @parent.select( @yaml['name'] + '_', nil, get_choices, { include_blank: true }, { class: 'text-with-select' })
|
78
|
+
end
|
79
|
+
|
80
|
+
# javascript to update text field if new value is selected in select field
|
81
|
+
@js =<<EOJS
|
82
|
+
$(document).ready(function() {
|
83
|
+
$('##{@yaml['name']}_').change( function() {
|
84
|
+
if ($(this).val().toString().length > 0) {
|
85
|
+
$('##{record}_#{@yaml['name']}').val( $(this).val() );
|
86
|
+
}
|
87
|
+
$('##{record}_#{@yaml['name']}').focus();
|
88
|
+
});
|
89
|
+
});
|
90
|
+
EOJS
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module DrgcmsFormFields
|
24
|
+
|
25
|
+
###########################################################################
|
26
|
+
# Implementation of tree_select DRG CMS form field. Field will provides
|
27
|
+
# multiple select functionality displayed as a tree. Might be used for selecting
|
28
|
+
# multiple categories in a parent-child tree view.#
|
29
|
+
#
|
30
|
+
# ===Form options:
|
31
|
+
# * +name:+ field name (required)
|
32
|
+
# * +type:+ tree_select (required)
|
33
|
+
# * +choices:+ Values for choices separated by comma. Values can also be specified like description:value.
|
34
|
+
# In this case description will be shown to user, but value will be saved to document.
|
35
|
+
# choices: 'OK:0,Ready:1,Error:2'
|
36
|
+
# choices: Ruby,Pyton,PHP
|
37
|
+
# * +eval:+ Choices will be provided by evaluating expression
|
38
|
+
# eval: ModelName.choices4_field; Model class should define method which will provide data for field.
|
39
|
+
# Data returned must be of type Array and have 3 elements.
|
40
|
+
# 1 - description text
|
41
|
+
# 2 - id value
|
42
|
+
# 3 - parent id
|
43
|
+
# * +html:+ html options which apply to select and text_field fields (optional)
|
44
|
+
#
|
45
|
+
# Form example:
|
46
|
+
# 10:
|
47
|
+
# name: categories
|
48
|
+
# type: tree_select
|
49
|
+
# eval: 'Categories.all_categories'
|
50
|
+
# multiple: true
|
51
|
+
# select_parent: false
|
52
|
+
# html:
|
53
|
+
# size: 50x10
|
54
|
+
###########################################################################
|
55
|
+
class TreeSelect < Select
|
56
|
+
|
57
|
+
###########################################################################
|
58
|
+
# Prepare choices for tree data rendering.
|
59
|
+
###########################################################################
|
60
|
+
def make_tree(parent)
|
61
|
+
return '' unless @choices[parent.to_s]
|
62
|
+
@html << '<ul>'
|
63
|
+
choices = if @choices[parent.to_s].first[3] != 0
|
64
|
+
@choices[parent.to_s].sort_by {|e| e[3].to_i } # sort by order if first is not 0
|
65
|
+
else
|
66
|
+
@choices[parent.to_s].sort_alphabetical_by(&:first) # use UTF-8 sort
|
67
|
+
end
|
68
|
+
choices.each do |choice|
|
69
|
+
data = [ %Q["selected" : #{choice.last ? 'true' : 'false'} ] ]
|
70
|
+
# only for parent objects
|
71
|
+
if @choices[ choice[1].to_s ]
|
72
|
+
# parent is not selectable
|
73
|
+
data << '"disabled" : true' unless @parent.dc_dont?(@yaml['parent_disabled'], true)
|
74
|
+
# parents are opened on start
|
75
|
+
data << '"opened" : true' unless @parent.dc_dont?(@yaml['parent_opened'], true)
|
76
|
+
end
|
77
|
+
# data-jstree must be singe quoted
|
78
|
+
@html << %Q[<li data-id="#{choice[1]}" data-jstree='{#{data.join(' , ')}}'>#{choice.first}\n]
|
79
|
+
# call recursively for children
|
80
|
+
make_tree(choice[1]) if @choices[ choice[1].to_s ]
|
81
|
+
@html << "</li>"
|
82
|
+
end
|
83
|
+
@html << '</ul>'
|
84
|
+
end
|
85
|
+
|
86
|
+
###########################################################################
|
87
|
+
# Render tree_select field html code
|
88
|
+
###########################################################################
|
89
|
+
def render
|
90
|
+
#return ro_standard if @readonly
|
91
|
+
set_initial_value('html','value')
|
92
|
+
require 'sort_alphabetical'
|
93
|
+
|
94
|
+
record = record_text_for(@yaml['name'])
|
95
|
+
clas = 'tree-select' + (@readonly ? ' dc-readonly' : '')
|
96
|
+
@html << "<div id=\"#{@yaml['name']}\" class=\"#{clas}\" #{set_style()} >"
|
97
|
+
# Fill @choices hash. The key is parent object id
|
98
|
+
@choices = {}
|
99
|
+
choices_in_eval(@yaml['eval']).each do |data|
|
100
|
+
@choices[ data[2].to_s ] ||= []
|
101
|
+
@choices[ data[2].to_s ] << (data << false)
|
102
|
+
end
|
103
|
+
# put current values hash with. To speed up selection when there is a lot of categories
|
104
|
+
current_values = {}
|
105
|
+
current = @record[@yaml['name']] || []
|
106
|
+
current = [current] unless current.class == Array # non array fields
|
107
|
+
current.each {|e| current_values[e.to_s] = true}
|
108
|
+
# set third element of @choices when selected
|
109
|
+
@choices.keys.each do |key|
|
110
|
+
0.upto( @choices[key].size - 1 ) do |i|
|
111
|
+
choice = @choices[key][i]
|
112
|
+
choice[choice.size - 1] = true if current_values[ choice[1].to_s ]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
make_tree(nil)
|
116
|
+
@html << '</div>'
|
117
|
+
# add hidden communication field
|
118
|
+
@html << @parent.hidden_field(record, @yaml['name'], value: current.join(','))
|
119
|
+
# save multiple indicator for data processing on return
|
120
|
+
@html << @parent.hidden_field(record, "#{@yaml['name']}_multiple", value: 1) if @yaml['multiple']
|
121
|
+
# javascript to update hidden record field when tree looses focus
|
122
|
+
readonly_code = %Q[
|
123
|
+
,
|
124
|
+
"conditionalselect" : function (node) {
|
125
|
+
return false; }
|
126
|
+
]
|
127
|
+
|
128
|
+
@js =<<EOJS
|
129
|
+
$(function(){
|
130
|
+
$("##{@yaml['name']}").jstree( {
|
131
|
+
"checkbox" : {"three_state" : false},
|
132
|
+
"core" : { "themes" : { "icons": false },
|
133
|
+
"multiple" : #{@yaml['multiple'] ? 'true' : 'false'} },
|
134
|
+
"plugins" : ["checkbox","conditionalselect"]
|
135
|
+
#{@readonly ? readonly_code : ''}
|
136
|
+
});
|
137
|
+
});
|
138
|
+
|
139
|
+
$(document).ready(function() {
|
140
|
+
$('##{@yaml['name']}').on('focusout', function(e) {
|
141
|
+
var checked_ids = [];
|
142
|
+
var checked = $('##{@yaml['name']}').jstree("get_checked", true);
|
143
|
+
$.each(checked, function() {
|
144
|
+
checked_ids.push( this.data.id );
|
145
|
+
});
|
146
|
+
$('#record_#{@yaml['name']}').val( checked_ids.join(",") );
|
147
|
+
});
|
148
|
+
});
|
149
|
+
EOJS
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
###########################################################################
|
154
|
+
# Return value. Return nil if input field is empty
|
155
|
+
###########################################################################
|
156
|
+
def self.get_data(params, name)
|
157
|
+
return nil if params['record'][name].blank?
|
158
|
+
#
|
159
|
+
result = params['record'][name].split(',')
|
160
|
+
result.delete_if {|e| e.blank? }
|
161
|
+
return nil if result.size == 0
|
162
|
+
# convert to BSON objects if is BSON object ID
|
163
|
+
result = result.map{ |e| BSON::ObjectId.from_string(e) } if BSON::ObjectId.legal?(result.first)
|
164
|
+
# return only first element if multiple values select was not alowed
|
165
|
+
params['record']["#{name}_multiple"] == '1' ? result : result.first
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
File without changes
|
@@ -32,6 +32,7 @@
|
|
32
32
|
class DcBigMenuRenderer
|
33
33
|
|
34
34
|
include DcApplicationHelper
|
35
|
+
include CmsCommonHelper
|
35
36
|
########################################################################
|
36
37
|
# Object initialization.
|
37
38
|
########################################################################
|
File without changes
|
File without changes
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
# DcGalleryRenderer renders data for displaying picture galary under the document.
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
# <div id="page">
|
29
|
+
# <%= dc_render(:dc_gallery) if document.gallery %>
|
30
|
+
# </div>
|
31
|
+
#
|
32
|
+
########################################################################
|
33
|
+
class DcGalleryRenderer
|
34
|
+
|
35
|
+
include DcApplicationHelper
|
36
|
+
include CmsCommonHelper
|
37
|
+
|
38
|
+
########################################################################
|
39
|
+
# Object initialization.
|
40
|
+
########################################################################
|
41
|
+
def initialize( parent, opts={} ) #:nodoc:
|
42
|
+
@parent = parent
|
43
|
+
@opts = opts
|
44
|
+
@page = @parent.page
|
45
|
+
@css = ''
|
46
|
+
end
|
47
|
+
|
48
|
+
#########################################################################
|
49
|
+
# Default DcGallery render method. It will simply put thumbnail pictures side by side and
|
50
|
+
# open big picture when clicked on thumbnail.
|
51
|
+
#########################################################################
|
52
|
+
def default
|
53
|
+
can_view, msg = dc_user_can_view(@parent, @page)
|
54
|
+
return msg unless can_view
|
55
|
+
#
|
56
|
+
html = '<div class="picture-gallery"><ul>'
|
57
|
+
DcGallery.where(doc_id: @opts[:doc_id], active: true).order_by(order: 1).each do |picture|
|
58
|
+
html << '<li>'
|
59
|
+
html << edit_menu(picture) if @opts[:edit_mode] > 1
|
60
|
+
html << "#{@parent.link_to(i@parent.mage_tag(picture.thumbnail, title: picture.title), picture.picture)}<li>"
|
61
|
+
end
|
62
|
+
#
|
63
|
+
html << '</ul></div>'
|
64
|
+
end
|
65
|
+
|
66
|
+
#########################################################################
|
67
|
+
# Renderer dispatcher. Method returns HTML part of code.
|
68
|
+
########################################################################
|
69
|
+
def render_html
|
70
|
+
method = @opts[:method] || 'default'
|
71
|
+
respond_to?(method) ? send(method) : "Error DcPage: Method #{method} doesn't exist!"
|
72
|
+
end
|
73
|
+
|
74
|
+
########################################################################
|
75
|
+
# Return CSS part of code.
|
76
|
+
########################################################################
|
77
|
+
def render_css
|
78
|
+
@css
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
########################################################################
|
83
|
+
#
|
84
|
+
########################################################################
|
85
|
+
def edit_menu(picture)
|
86
|
+
opts = { controller: 'cmsedit', action: 'edit' }
|
87
|
+
opts[:title] = "#{t('drgcms.edit')}: #{picture.title}"
|
88
|
+
opts[:id] = picture.id
|
89
|
+
opts[:table] = 'dc_gallery'
|
90
|
+
|
91
|
+
'<li>'+dc_link_for_edit(opts)+'</li>'
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
end
|
@@ -35,6 +35,7 @@
|
|
35
35
|
class DcMenuRenderer
|
36
36
|
|
37
37
|
include DcApplicationHelper
|
38
|
+
include CmsCommonHelper
|
38
39
|
########################################################################
|
39
40
|
# Object initialization. Will also prepare DcMenu document.
|
40
41
|
########################################################################
|
@@ -97,10 +98,16 @@ def link_4menu(item)
|
|
97
98
|
caption = item.caption[0] == '-' ? '' : item.caption.to_s
|
98
99
|
img_title = item.caption.to_s.sub('-','')
|
99
100
|
# add picture if picture is not blank
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
html = ''
|
102
|
+
if !item.picture.blank?
|
103
|
+
if item.picture[0,3] == 'fa-'
|
104
|
+
caption << @parent.fa_icon(item.picture[3,20])
|
105
|
+
else
|
106
|
+
html = @parent.link_to( @parent.image_tag(item.picture), link, {title: img_title, target: target} ) rescue ''
|
107
|
+
end
|
108
|
+
end
|
109
|
+
html << @parent.link_to(caption.html_safe, link, {target: target}) unless caption.blank?
|
110
|
+
html
|
104
111
|
end
|
105
112
|
|
106
113
|
########################################################################
|