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,52 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2020+ 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 file_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: file_field
|
37
|
+
# size: 30
|
38
|
+
###########################################################################
|
39
|
+
class FileField < DrgcmsField
|
40
|
+
|
41
|
+
###########################################################################
|
42
|
+
# Render text_field field html code
|
43
|
+
###########################################################################
|
44
|
+
def render
|
45
|
+
return self if @readonly
|
46
|
+
#record = record_text_for(@yaml['name'])
|
47
|
+
@html << @parent.file_field(nil,@yaml['name'], @yaml['html'])
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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 file_select DRG CMS form field.
|
27
|
+
#
|
28
|
+
# FileSelect like HtmlField implements redirection for calling document manager edit field code.
|
29
|
+
# This can be drg_default_html_editor's elfinder or any other code defined
|
30
|
+
# by dc_site.settings file_select setting.
|
31
|
+
#
|
32
|
+
# Example of dc_site.setting used for drg_default_html_editor gem.
|
33
|
+
# html_editor: ckeditor
|
34
|
+
# ck_editor:
|
35
|
+
# config_file: /files/ck_config.js
|
36
|
+
# css_file: /files/ck_css.css
|
37
|
+
# file_select: elfinder
|
38
|
+
#
|
39
|
+
# Form example:
|
40
|
+
# 60:
|
41
|
+
# name: picture
|
42
|
+
# type: file_select
|
43
|
+
# html:
|
44
|
+
# size: 50
|
45
|
+
###########################################################################
|
46
|
+
class FileSelect < DrgcmsField
|
47
|
+
|
48
|
+
###########################################################################
|
49
|
+
# Render file_select field html code
|
50
|
+
###########################################################################
|
51
|
+
def render
|
52
|
+
return ro_standard if @readonly
|
53
|
+
# retrieve html editor from page settings
|
54
|
+
selector_string = @parent.dc_get_site.params['file_select'] if @parent.dc_get_site
|
55
|
+
selector_string ||= 'elfinder'
|
56
|
+
#
|
57
|
+
klas_string = selector_string.camelize
|
58
|
+
if DrgcmsFormFields.const_defined?(klas_string)
|
59
|
+
klas = DrgcmsFormFields::const_get(klas_string)
|
60
|
+
o = klas.new(@parent, @record, @yaml).render
|
61
|
+
@js << o.js
|
62
|
+
@html << o.html
|
63
|
+
else
|
64
|
+
@html << "File select component not defined. Check site.settings or include drgcms_default_html_editor gem."
|
65
|
+
end
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2019+ 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 HashField < DrgcmsField
|
42
|
+
|
43
|
+
###########################################################################
|
44
|
+
# Returns value for readonly field
|
45
|
+
###########################################################################
|
46
|
+
def ro_standard()
|
47
|
+
return self if @record[@yaml['name']].nil?
|
48
|
+
html = ''
|
49
|
+
@record[@yaml['name']].each do |key, value|
|
50
|
+
html << "#{key}:#{value}<br>"
|
51
|
+
end
|
52
|
+
super(html)
|
53
|
+
end
|
54
|
+
|
55
|
+
###########################################################################
|
56
|
+
# Render text_field field html code
|
57
|
+
###########################################################################
|
58
|
+
def render
|
59
|
+
return ro_standard if @readonly
|
60
|
+
set_initial_value
|
61
|
+
#
|
62
|
+
record = record_text_for(@yaml['name'])
|
63
|
+
# Convert Hash to values separated by colon
|
64
|
+
if @record[@yaml['name']]
|
65
|
+
@yaml['html']['value'] = @record[@yaml['name']].to_a.inject('') {|r, e| r << "#{e.first}:#{e.last}\n"}
|
66
|
+
end
|
67
|
+
@html << @parent.text_area( record, @yaml['name'], @yaml['html'])
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
###########################################################################
|
72
|
+
# Return value. Return nil if input field is empty
|
73
|
+
###########################################################################
|
74
|
+
def self.get_data(params, name)
|
75
|
+
return nil if params['record'][name].blank?
|
76
|
+
#
|
77
|
+
result = params['record'][name].split("\n").select {|e| !e.blank? }
|
78
|
+
return nil if result.size == 0
|
79
|
+
# convert to Hash
|
80
|
+
ret = {}
|
81
|
+
result.map { |e| key,value = e.chomp.split(':'); ret[key.strip] = value.strip unless value.blank? }
|
82
|
+
ret
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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 hidden DRG CMS form field.
|
27
|
+
#
|
28
|
+
# Will create hidden_field on form.
|
29
|
+
#
|
30
|
+
# ===Form options:
|
31
|
+
# * +name:+ field name
|
32
|
+
# * +type:+ hidden_field
|
33
|
+
#
|
34
|
+
# Form example:
|
35
|
+
# 10:
|
36
|
+
# name: im_hidden
|
37
|
+
# type: hidden_field
|
38
|
+
###########################################################################
|
39
|
+
class HiddenField < DrgcmsField
|
40
|
+
###########################################################################
|
41
|
+
# Render hidden_field field html code
|
42
|
+
###########################################################################
|
43
|
+
def render
|
44
|
+
set_initial_value
|
45
|
+
value = @yaml['html']['value'] ? @yaml['html']['value'] : @record.send(@yaml['name'])
|
46
|
+
record = record_text_for(@yaml['name'])
|
47
|
+
@parent.hidden_field(record, @yaml['name'], value: value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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 html_field DRG CMS form field.
|
27
|
+
#
|
28
|
+
# HtmlField class only implements code for calling actual html edit field code.
|
29
|
+
# This is by default drg_default_html_editor gem which uses CK editor javascript plugin
|
30
|
+
# or any other plugin. Which plugin will be used as html editor is defined by
|
31
|
+
# dc_site.settings html_editor setting.
|
32
|
+
#
|
33
|
+
# Example of dc_site.setting used for drg_default_html_editor gem.
|
34
|
+
# html_editor: ckeditor
|
35
|
+
# ck_editor:
|
36
|
+
# config_file: /files/ck_config.js
|
37
|
+
# css_file: /files/ck_css.css
|
38
|
+
# file_select: elfinder
|
39
|
+
#
|
40
|
+
# Form example:
|
41
|
+
# 10:
|
42
|
+
# name: body
|
43
|
+
# type: html_field
|
44
|
+
# options: "height: 500, width: 550, toolbar: 'basic'"
|
45
|
+
###########################################################################
|
46
|
+
class HtmlField < DrgcmsField
|
47
|
+
|
48
|
+
###########################################################################
|
49
|
+
# Render html_field field html code
|
50
|
+
###########################################################################
|
51
|
+
def render
|
52
|
+
#return ro_standard if @readonly
|
53
|
+
# retrieve html editor from page settings
|
54
|
+
editor_string = @parent.dc_get_site.params['html_editor'] if @parent.dc_get_site
|
55
|
+
editor_string ||= 'ckeditor'
|
56
|
+
#
|
57
|
+
klas_string = editor_string.camelize
|
58
|
+
if DrgcmsFormFields.const_defined?(klas_string)
|
59
|
+
klas = DrgcmsFormFields::const_get(klas_string)
|
60
|
+
o = klas.new(@parent, @record, @yaml).render
|
61
|
+
@js << o.js
|
62
|
+
@html << o.html
|
63
|
+
else
|
64
|
+
@html << "HTML editor not defined. Check site.settings or include drgcms_default_html_editor gem."
|
65
|
+
end
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 journal_diff DRG CMS form field. journal_diff field is used to
|
27
|
+
# show differences between two fields in DcJournal collection.
|
28
|
+
#
|
29
|
+
# ===Form options:
|
30
|
+
# * +name:+ field name (required)
|
31
|
+
# * +type:+ journal_diff (required)
|
32
|
+
#
|
33
|
+
# Form example:
|
34
|
+
# 10:
|
35
|
+
# name: diff
|
36
|
+
# type: journal_diff
|
37
|
+
# html:
|
38
|
+
# size: 100x25
|
39
|
+
###########################################################################
|
40
|
+
class JournalDiff < DrgcmsField
|
41
|
+
|
42
|
+
###########################################################################
|
43
|
+
# Render journal_diff field html code
|
44
|
+
###########################################################################
|
45
|
+
def render
|
46
|
+
@yaml['name'] = 'old' if @record[@yaml['name']].nil?
|
47
|
+
@html << '<div class="dc-journal">'
|
48
|
+
JSON.parse(@record[@yaml['name']]).each do |k,v|
|
49
|
+
old_value = v.class == Array ? v[0] : v
|
50
|
+
new_value = v.class == Array ? v[1] : v
|
51
|
+
@html << "<div style='background-color: #eee;'>#{@parent.check_box('select', k)} #{k}</div>
|
52
|
+
<div style='background-color: #fcc;'>-<br>#{old_value}</div>
|
53
|
+
<div style='background-color: #cfc;'>+<br>#{new_value}</div><br>"
|
54
|
+
end
|
55
|
+
@html << '</div>'
|
56
|
+
self
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,69 @@
|
|
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 link_to DRG CMS form field. link_to form field is mostly used by polls but can
|
27
|
+
# be also incorporated anywhere on the form.
|
28
|
+
#
|
29
|
+
# ===Form options:
|
30
|
+
# * +type:+ link_to (required)
|
31
|
+
# * +caption:+ Link caption
|
32
|
+
# * +icon:+ Link icon
|
33
|
+
# * +url:+ direct url link
|
34
|
+
# * +controller:+ controller name
|
35
|
+
# * +action:+ action name
|
36
|
+
# * +html:+ html options which apply to link_to (optional)
|
37
|
+
#
|
38
|
+
# Form example:
|
39
|
+
# 30:
|
40
|
+
# type: link_to
|
41
|
+
# caption: Some action
|
42
|
+
# icon: cogs
|
43
|
+
# controller: my_controller
|
44
|
+
# action: my_action
|
45
|
+
# id: id # will be replaced by record._id
|
46
|
+
###########################################################################
|
47
|
+
class LinkTo < DrgcmsField
|
48
|
+
|
49
|
+
###########################################################################
|
50
|
+
# Render link_to field html code
|
51
|
+
###########################################################################
|
52
|
+
def render
|
53
|
+
@yaml['html'] ||= {}
|
54
|
+
@yaml['html']['class'] ||= 'dc-link dc-animate'
|
55
|
+
@yaml['html'].symbolize_keys!
|
56
|
+
#
|
57
|
+
@yaml[:id] = record._id if @yaml[:id] == 'id'
|
58
|
+
url = @yaml['url'] || "#{@yaml[:controller]}/#{@yaml[:action]}/#{@yaml[:id]}"
|
59
|
+
url.gsub!('//','/') # no action and id
|
60
|
+
url = '/' + @yaml['url'] unless url[0,1] == '/' # no leading /
|
61
|
+
url.chop if url[0,-1] == '/' # remove trailing /
|
62
|
+
#
|
63
|
+
caption = @yaml['caption'] || @yaml['text']
|
64
|
+
@html << @parent.dc_link_to(caption, @yaml['icon'], url, @yaml['html'])
|
65
|
+
self
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|