drg_cms 0.5.52.12 → 0.5.52.16
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 +5 -5
- data/app/assets/javascripts/drg_cms/drg_cms.js +17 -2
- data/app/assets/stylesheets/drg_cms/drg_cms.css +16 -3
- data/app/assets/stylesheets/drg_cms/select-multiple.css +1 -1
- data/app/controllers/cmsedit_controller.rb +56 -16
- data/app/controllers/dc_application_controller.rb +83 -1
- data/app/controllers/dc_common_controller.rb +2 -52
- data/app/forms/all_options.yml +27 -4
- data/app/forms/cms_menu.yml +5 -0
- data/app/forms/dc_gallery.yml +53 -0
- data/app/forms/dc_link.yml +16 -10
- data/app/forms/dc_menu_item.yml +5 -0
- data/app/forms/dc_page.yml +1 -2
- data/app/forms/dc_removed_url.yml +42 -0
- data/app/helpers/cmsedit_helper.rb +63 -22
- data/app/helpers/dc_application_helper.rb +35 -11
- data/app/helpers/dc_gallery_renderer.rb +94 -0
- data/app/helpers/dc_page_renderer.rb +20 -3
- data/app/helpers/dc_poll_renderer.rb +6 -7
- data/app/models/concerns/dc_page_concern.rb +1 -1
- data/app/models/dc_filter.rb +15 -7
- data/app/models/dc_gallery.rb +64 -0
- data/app/models/dc_link.rb +1 -0
- data/app/models/dc_memory.rb +19 -4
- data/app/models/dc_page.rb +1 -1
- data/app/models/dc_removed_url.rb +54 -0
- data/app/models/drgcms_form_fields.rb +5 -1649
- data/app/models/drgcms_form_fields/check_box.rb +69 -0
- data/app/models/drgcms_form_fields/comment.rb +49 -0
- data/app/models/drgcms_form_fields/date_picker.rb +102 -0
- data/app/models/drgcms_form_fields/date_select.rb +68 -0
- data/app/models/drgcms_form_fields/date_time_picker.rb +87 -0
- data/app/models/drgcms_form_fields/datetime_select.rb +73 -0
- data/app/models/drgcms_form_fields/drgcms_field.rb +241 -0
- data/app/models/drgcms_form_fields/drgcms_form_fields.rb +25 -0
- data/app/models/drgcms_form_fields/embedded.rb +84 -0
- data/app/models/drgcms_form_fields/file_select.rb +70 -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/multitext_autocomplete.rb +195 -0
- data/app/models/drgcms_form_fields/number_field.rb +83 -0
- data/app/models/drgcms_form_fields/password_field.rb +62 -0
- data/app/models/drgcms_form_fields/readonly.rb +79 -0
- data/app/models/drgcms_form_fields/select.rb +164 -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 +143 -0
- data/app/models/drgcms_form_fields/text_field.rb +56 -0
- data/app/models/drgcms_form_fields/text_with_select.rb +92 -0
- data/app/models/drgcms_form_fields/tree_select.rb +150 -0
- data/config/locales/drgcms_en.yml +1 -0
- data/config/locales/drgcms_sl.yml +2 -1
- data/config/locales/models_en.yml +42 -6
- data/config/locales/models_sl.yml +38 -3
- data/lib/drg_cms.rb +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/tasks/dc_cleanup.rake +1 -1
- metadata +33 -4
@@ -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 check_box DRG CMS form field.
|
27
|
+
#
|
28
|
+
# ===Form options:
|
29
|
+
# * +name:+ field name (required)
|
30
|
+
# * +type:+ check_box (required)
|
31
|
+
# * +choices:+ Values check_box separated by comma (1,0) (yes,no)
|
32
|
+
# * +checked_value:+ 1 or yes or approved
|
33
|
+
# * +unchecked_value:+ 0 or no or not approved
|
34
|
+
# * +html:+ html options which apply to check_box field (optional)
|
35
|
+
#
|
36
|
+
# Form example:
|
37
|
+
# 30:
|
38
|
+
# name: active
|
39
|
+
# type: check_box
|
40
|
+
# 40:
|
41
|
+
# name: status
|
42
|
+
# type: check_box
|
43
|
+
# choices: yes,no
|
44
|
+
###########################################################################
|
45
|
+
class CheckBox < DrgcmsField
|
46
|
+
|
47
|
+
###########################################################################
|
48
|
+
# Render check_box field html code
|
49
|
+
###########################################################################
|
50
|
+
def render
|
51
|
+
set_initial_value('html','default')
|
52
|
+
# checked flag must be set
|
53
|
+
@yaml['html']['checked'] = !@parent.dc_dont?(@yaml['html']['default']) if @yaml['html']['default']
|
54
|
+
# disable it if readonly
|
55
|
+
@yaml['html']['disabled'] = @readonly ? true : nil
|
56
|
+
# If choices are present split them to set checked and unchecked value
|
57
|
+
@yaml['checked_value'], @yaml['unchecked_value'] = @yaml['choices'].split(',') if @yaml['choices']
|
58
|
+
@yaml['html'].symbolize_keys!
|
59
|
+
record = record_text_for(@yaml['name'])
|
60
|
+
@html << if @yaml['checked_value']
|
61
|
+
@parent.check_box(record, @yaml['name'], @yaml['html'], @yaml['checked_value'], @yaml['unchecked_value'] || '0')
|
62
|
+
else
|
63
|
+
@parent.check_box(record, @yaml['name'], @yaml['html'])
|
64
|
+
end
|
65
|
+
self
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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 comment DRG CMS form field. Comments may also be written
|
27
|
+
# on the place of form field.
|
28
|
+
#
|
29
|
+
# ===Form options:
|
30
|
+
# * +text:+ any text. Text will be translated if key is found in translations. (required)
|
31
|
+
# * +type:+ comment (required)
|
32
|
+
#
|
33
|
+
# Form example:
|
34
|
+
# 30:
|
35
|
+
# name: active
|
36
|
+
# type: check_box
|
37
|
+
###########################################################################
|
38
|
+
class Comment < DrgcmsField
|
39
|
+
|
40
|
+
###########################################################################
|
41
|
+
# Render comment field html code
|
42
|
+
###########################################################################
|
43
|
+
def render
|
44
|
+
@html << t(@yaml['comment'], @yaml['comment'])
|
45
|
+
self
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,102 @@
|
|
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 date_picker DRG CMS form field with help of jQuery DateTimePicker plugin.
|
27
|
+
#
|
28
|
+
# Since javascript date(time) format differs from ruby date(time) format localization
|
29
|
+
# must be provided in order for date_picker object works as expected. For example:
|
30
|
+
#
|
31
|
+
# en:
|
32
|
+
# datetimepicker:
|
33
|
+
# formats:
|
34
|
+
# date: 'Y/m/d'
|
35
|
+
# datetime: 'Y/m/d H:i'
|
36
|
+
#
|
37
|
+
# sl:
|
38
|
+
# datetimepicker:
|
39
|
+
# formats:
|
40
|
+
# date: 'd.m.Y'
|
41
|
+
# datetime: 'd.m.Y H:i'
|
42
|
+
#
|
43
|
+
# ===Form options:
|
44
|
+
# * +type:+ date_picker (required)
|
45
|
+
# * +name:+ Field name (required)
|
46
|
+
# * +options:+ options which apply to date_picker field. All options can be found here http://xdsoft.net/jqplugins/datetimepicker/ .
|
47
|
+
# Options can be defined in single line like:
|
48
|
+
# * options: 'inline: true,lang: "sl"' or
|
49
|
+
#
|
50
|
+
# * options:
|
51
|
+
# * inline: true
|
52
|
+
# * lang: '"sl"'
|
53
|
+
#
|
54
|
+
# * +html:+ html options which apply to date_picker field (optional)
|
55
|
+
#
|
56
|
+
# Form example:
|
57
|
+
# 10:
|
58
|
+
# name: created
|
59
|
+
# type: date_picker
|
60
|
+
# options: 'inline: true,lang: "sl"'
|
61
|
+
###########################################################################
|
62
|
+
class DatePicker < DrgcmsField
|
63
|
+
|
64
|
+
###########################################################################
|
65
|
+
# Render date_picker field html code
|
66
|
+
###########################################################################
|
67
|
+
def render
|
68
|
+
value = (@record and @record[@yaml['name']]) ? I18n.localize(@record[@yaml['name']].to_date) : nil
|
69
|
+
return ro_standard( @parent.dc_format_value(value)) if @readonly
|
70
|
+
#
|
71
|
+
@yaml['options'] ||= {}
|
72
|
+
set_initial_value
|
73
|
+
@yaml['html']['size'] ||= 10
|
74
|
+
@yaml['html']['value'] = value
|
75
|
+
#
|
76
|
+
@yaml['options']['lang'] ||= "'#{I18n.locale}'"
|
77
|
+
@yaml['options']['format'] ||= "'#{t('datetimepicker.formats.date')}'"
|
78
|
+
@yaml['options']['timepicker'] = false
|
79
|
+
#
|
80
|
+
record = record_text_for(@yaml['name'])
|
81
|
+
@html << @parent.text_field(record, @yaml['name'], @yaml['html'])
|
82
|
+
@js << <<EOJS
|
83
|
+
$(document).ready(function() {
|
84
|
+
$("##{record}_#{@yaml['name']}").datetimepicker( {
|
85
|
+
#{hash_to_options(@yaml['options'])}
|
86
|
+
});
|
87
|
+
});
|
88
|
+
EOJS
|
89
|
+
|
90
|
+
self
|
91
|
+
end
|
92
|
+
|
93
|
+
###########################################################################
|
94
|
+
# DatePicker get_data method.
|
95
|
+
###########################################################################
|
96
|
+
def self.get_data(params, name)
|
97
|
+
t = params['record'][name] ? params['record'][name].to_datetime : nil
|
98
|
+
t ? Time.zone.local(t.year, t.month, t.day) : nil
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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 date_select DRG CMS form field.
|
27
|
+
#
|
28
|
+
# ===Form options:
|
29
|
+
# * +type:+ date_select (required)
|
30
|
+
# * +name:+ Field name (required)
|
31
|
+
# * +options:+ options which apply to date_select field (optional)
|
32
|
+
# * +html:+ html options which apply to password field (optional)
|
33
|
+
#
|
34
|
+
# Form example:
|
35
|
+
# 50:
|
36
|
+
# name: valid_from
|
37
|
+
# type: date_select
|
38
|
+
# options:
|
39
|
+
# include_blank: true
|
40
|
+
# html:
|
41
|
+
# class: my-date-class
|
42
|
+
###########################################################################
|
43
|
+
class DateSelect < DrgcmsField
|
44
|
+
|
45
|
+
###########################################################################
|
46
|
+
# Render date_select field html code
|
47
|
+
###########################################################################
|
48
|
+
def render
|
49
|
+
return ro_standard( @parent.dc_format_value(@record[@yaml['name']])) if @readonly
|
50
|
+
#
|
51
|
+
@yaml['options'] ||= {}
|
52
|
+
set_initial_value('options','default')
|
53
|
+
@yaml['options'].symbolize_keys!
|
54
|
+
@yaml['html'].symbolize_keys!
|
55
|
+
record = record_text_for(@yaml['name'])
|
56
|
+
@html << @parent.date_select(record, @yaml['name'], @yaml['options'], @yaml['html'])
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
###########################################################################
|
61
|
+
# DatetimeSelect get_data method.
|
62
|
+
###########################################################################
|
63
|
+
def self.get_data(params, name)
|
64
|
+
DatetimeSelect.get_data(params, name).to_date rescue nil
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,87 @@
|
|
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 date_time_picker DRG CMS form field with help of jQuery DateTimePicker plugin
|
27
|
+
#
|
28
|
+
# ===Form options:
|
29
|
+
# * +type:+ datetime_picker (required)
|
30
|
+
# * +name:+ Field name (required)
|
31
|
+
# * +options:+ options which apply to date_picker field. All options can be found here http://xdsoft.net/jqplugins/datetimepicker/ .
|
32
|
+
# Options can be defined in single line like:
|
33
|
+
# * options: 'step: 15,inline: true,lang: "sl"' or
|
34
|
+
#
|
35
|
+
# * options:
|
36
|
+
# * step: 15
|
37
|
+
# * inline: true
|
38
|
+
# * lang: '"sl"'
|
39
|
+
#
|
40
|
+
# * +html:+ html options which apply to date_time_picker field (optional)
|
41
|
+
#
|
42
|
+
# Form example:
|
43
|
+
# 10:
|
44
|
+
# name: valid_to
|
45
|
+
# type: datetime_picker
|
46
|
+
# options: 'step: 60'
|
47
|
+
###########################################################################
|
48
|
+
class DatetimePicker < DrgcmsField
|
49
|
+
|
50
|
+
###########################################################################
|
51
|
+
# Render date_time_picker field html code
|
52
|
+
###########################################################################
|
53
|
+
def render
|
54
|
+
value = (@record and @record[@yaml['name']]) ? I18n.localize(@record[@yaml['name']].localtime) : nil
|
55
|
+
return ro_standard( @parent.dc_format_value(value)) if @readonly
|
56
|
+
#
|
57
|
+
@yaml['options'] ||= {}
|
58
|
+
set_initial_value
|
59
|
+
@yaml['html']['size'] ||= 14
|
60
|
+
@yaml['html']['value'] = value if @record[@yaml['name']]
|
61
|
+
#
|
62
|
+
@yaml['options']['lang'] ||= "'#{I18n.locale}'"
|
63
|
+
@yaml['options']['format'] ||= "'#{t('datetimepicker.formats.datetime')}'"
|
64
|
+
#
|
65
|
+
record = record_text_for(@yaml['name'])
|
66
|
+
@html << @parent.text_field(record, @yaml['name'], @yaml['html'])
|
67
|
+
@js << <<EOJS
|
68
|
+
$(document).ready(function() {
|
69
|
+
$("##{record}_#{@yaml['name']}").datetimepicker( {
|
70
|
+
#{hash_to_options(@yaml['options'])}
|
71
|
+
});
|
72
|
+
});
|
73
|
+
EOJS
|
74
|
+
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
78
|
+
###########################################################################
|
79
|
+
# DateTimePicker get_data method.
|
80
|
+
###########################################################################
|
81
|
+
def self.get_data(params, name)
|
82
|
+
t = params['record'][name] ? params['record'][name].to_datetime : nil
|
83
|
+
t ? Time.zone.local(t.year, t.month, t.day, t.hour, t.min) : nil
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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
|
+
###########################################################################
|
27
|
+
# Create datetime_select form field
|
28
|
+
#
|
29
|
+
# ===Form options:
|
30
|
+
# * +type:+ datetime_select (required)
|
31
|
+
# * +name:+ Field name (required)
|
32
|
+
# * +options:+ options which apply to date_select field (optional)
|
33
|
+
# * +html:+ html options which apply to password field (optional)
|
34
|
+
#
|
35
|
+
# Form example:
|
36
|
+
# 60:
|
37
|
+
# name: end_time
|
38
|
+
# type: datetime_select
|
39
|
+
# options:
|
40
|
+
# include_blank: true
|
41
|
+
###########################################################################
|
42
|
+
class DatetimeSelect < DrgcmsField
|
43
|
+
|
44
|
+
###########################################################################
|
45
|
+
# Render datetime_select field html code
|
46
|
+
###########################################################################
|
47
|
+
def render
|
48
|
+
return ro_standard( @parent.dc_format_value(@record[@yaml['name']])) if @readonly
|
49
|
+
#
|
50
|
+
@yaml['options'] ||= {}
|
51
|
+
set_initial_value('options','default')
|
52
|
+
@yaml['options'].symbolize_keys!
|
53
|
+
@yaml['html'].symbolize_keys!
|
54
|
+
#
|
55
|
+
record = record_text_for(@yaml['name'])
|
56
|
+
@html << @parent.datetime_select(record, @yaml['name'], @yaml['options'], @yaml['html'])
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
####################################################################
|
61
|
+
# DatetimeSelect get_data method.
|
62
|
+
####################################################################
|
63
|
+
def self.get_data(params, name)
|
64
|
+
begin
|
65
|
+
attrs = (1..5).map { |i| params['record']["#{name}(#{i}i)"]}
|
66
|
+
Time.zone.local(*attrs)
|
67
|
+
rescue
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|