drg_cms 0.6.0.1 → 0.6.1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +454 -145
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +635 -244
- data/app/assets/stylesheets/drg_cms/select-multiple.css +18 -12
- data/app/assets/stylesheets/drg_cms_cms.css +1 -1
- data/app/controllers/cmsedit_controller.rb +515 -335
- data/app/controllers/dc_application_controller.rb +378 -111
- data/app/controllers/dc_common_controller.rb +105 -14
- data/app/{controllers → controls}/browse_models_control.rb +0 -0
- data/app/controls/dc_help_control.rb +126 -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 +223 -0
- data/app/{controllers → controls}/design_element_settings_control.rb +0 -0
- data/app/forms/all_options.yml +44 -9
- data/app/forms/cms_menu.yml +28 -18
- 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_category.yml +2 -1
- data/app/forms/dc_design.yml +20 -16
- data/app/forms/dc_filter.yml +3 -6
- data/app/forms/dc_help_1.yml +109 -0
- data/app/forms/dc_journal.yml +3 -1
- data/app/forms/dc_json_ld.yml +59 -0
- data/app/forms/dc_key_value.yml +32 -0
- data/app/forms/dc_link.yml +1 -1
- data/app/forms/dc_menu.yml +2 -0
- data/app/forms/dc_menu_item.yml +2 -0
- data/app/forms/dc_page.yml +3 -5
- data/app/forms/dc_part.yml +1 -0
- data/app/forms/dc_piece.yml +1 -0
- data/app/forms/dc_poll.yml +15 -5
- 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_seo.yml +33 -0
- data/app/forms/dc_simple_menu.yml +2 -0
- data/app/forms/dc_site.yml +4 -12
- data/app/forms/dc_user.yml +27 -11
- data/app/forms/dc_user_role.yml +3 -0
- data/app/forms/json_ld_schema.yml +168 -0
- data/app/helpers/cms_common_helper.rb +375 -0
- data/app/helpers/cms_edit_helper.rb +506 -0
- data/app/helpers/cms_helper.rb +268 -0
- data/app/helpers/cms_index_helper.rb +580 -0
- data/app/helpers/dc_application_helper.rb +218 -306
- data/app/models/concerns/dc_page_concern.rb +40 -6
- data/app/models/concerns/dc_policy_rule_concern.rb +20 -8
- data/app/models/concerns/dc_seo_concern.rb +66 -0
- data/app/models/concerns/dc_site_concern.rb +67 -44
- data/app/models/concerns/dc_user_concern.rb +57 -18
- data/app/models/dc_design.rb +30 -18
- data/app/models/dc_filter.rb +22 -13
- data/app/models/dc_json_ld.rb +152 -0
- data/app/models/dc_key_value.rb +48 -0
- data/app/models/dc_key_value_store.rb +1 -0
- data/app/models/dc_memory.rb +8 -1
- data/app/models/dc_page.rb +0 -1
- data/app/models/dc_permission.rb +49 -9
- data/app/models/dc_policy.rb +25 -14
- data/app/models/dc_policy_role.rb +22 -11
- data/app/models/dc_poll.rb +39 -19
- data/app/models/dc_poll_result.rb +46 -0
- data/app/models/dc_temp.rb +140 -0
- data/app/models/dc_user_role.rb +2 -2
- data/app/models/drgcms_form_fields.rb +12 -1
- data/app/models/drgcms_form_fields/action.rb +61 -0
- data/app/models/drgcms_form_fields/comment.rb +8 -4
- data/app/models/drgcms_form_fields/date_picker.rb +11 -9
- data/app/models/drgcms_form_fields/date_select.rb +1 -1
- data/app/models/drgcms_form_fields/datetime_picker.rb +12 -10
- data/app/models/drgcms_form_fields/datetime_select.rb +1 -1
- data/app/models/drgcms_form_fields/drgcms_field.rb +55 -9
- data/app/models/drgcms_form_fields/embedded.rb +26 -16
- data/app/models/drgcms_form_fields/file_field.rb +52 -0
- data/app/models/drgcms_form_fields/file_select.rb +2 -2
- data/app/models/drgcms_form_fields/hash_field.rb +90 -0
- data/app/models/drgcms_form_fields/hidden_field.rb +1 -1
- data/app/models/drgcms_form_fields/html_field.rb +1 -1
- data/app/models/drgcms_form_fields/link_to.rb +2 -2
- data/app/models/drgcms_form_fields/method.rb +66 -0
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +23 -14
- data/app/models/drgcms_form_fields/number_field.rb +15 -6
- data/app/models/drgcms_form_fields/radio.rb +96 -0
- data/app/models/drgcms_form_fields/readonly.rb +2 -2
- data/app/models/drgcms_form_fields/select.rb +92 -29
- data/app/models/drgcms_form_fields/text_area.rb +1 -1
- data/app/models/drgcms_form_fields/text_autocomplete.rb +31 -17
- data/app/models/drgcms_form_fields/text_field.rb +1 -1
- data/app/models/drgcms_form_fields/text_with_select.rb +6 -3
- data/app/models/drgcms_form_fields/tree_select.rb +15 -4
- 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/{helpers → renderers}/dc_gallery_renderer.rb +1 -0
- data/app/{helpers → renderers}/dc_menu_renderer.rb +11 -4
- data/app/{helpers → renderers}/dc_page_renderer.rb +1 -0
- 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 +91 -64
- 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 +4 -1
- data/app/views/cmsedit/index.html.erb +7 -1
- data/app/views/cmsedit/new.html.erb +3 -1
- data/app/views/dc_common/_help.html.erb +17 -0
- data/app/views/layouts/models.html.erb +2 -1
- data/config/locales/drgcms_en.yml +27 -3
- data/config/locales/drgcms_sl.yml +32 -5
- data/config/locales/models_en.yml +65 -17
- data/config/locales/models_sl.yml +69 -18
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms.rb +61 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +9 -2
- data/lib/tasks/database.rake +6 -56
- metadata +73 -54
- 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 -888
- data/app/models/dc_dummy.rb +0 -102
- data/test/fixtures/drg_cms_test_data.rb +0 -87
@@ -1,339 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* jQuery UI CSS Framework 1.8.23
|
3
|
-
*
|
4
|
-
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
|
5
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6
|
-
* http://jquery.org/license
|
7
|
-
*
|
8
|
-
* http://docs.jquery.com/UI/Theming/API
|
9
|
-
*/
|
10
|
-
|
11
|
-
/* Layout helpers
|
12
|
-
----------------------------------*/
|
13
|
-
.ui-helper-hidden { display: none; }
|
14
|
-
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
15
|
-
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
16
|
-
.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
|
17
|
-
.ui-helper-clearfix:after { clear: both; }
|
18
|
-
.ui-helper-clearfix { zoom: 1; }
|
19
|
-
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
20
|
-
|
21
|
-
|
22
|
-
/* Interaction Cues
|
23
|
-
----------------------------------*/
|
24
|
-
.ui-state-disabled { cursor: default !important; }
|
25
|
-
|
26
|
-
|
27
|
-
/* Icons
|
28
|
-
----------------------------------*/
|
29
|
-
|
30
|
-
/* states and images */
|
31
|
-
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
32
|
-
|
33
|
-
|
34
|
-
/* Misc visuals
|
35
|
-
----------------------------------*/
|
36
|
-
|
37
|
-
/* Overlays */
|
38
|
-
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
39
|
-
|
40
|
-
|
41
|
-
/*!
|
42
|
-
* jQuery UI CSS Framework 1.8.23
|
43
|
-
*
|
44
|
-
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
|
45
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
46
|
-
* http://jquery.org/license
|
47
|
-
*
|
48
|
-
* http://docs.jquery.com/UI/Theming/API
|
49
|
-
*
|
50
|
-
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS,%20Tahoma,%20Verdana,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px
|
51
|
-
*/
|
52
|
-
|
53
|
-
|
54
|
-
/* Component containers
|
55
|
-
----------------------------------*/
|
56
|
-
.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; }
|
57
|
-
.ui-widget .ui-widget { font-size: 1em; }
|
58
|
-
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; }
|
59
|
-
.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; }
|
60
|
-
.ui-widget-content a { color: #333333; }
|
61
|
-
.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
|
62
|
-
.ui-widget-header a { color: #ffffff; }
|
63
|
-
|
64
|
-
/* Interaction states
|
65
|
-
----------------------------------*/
|
66
|
-
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; }
|
67
|
-
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
|
68
|
-
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; }
|
69
|
-
.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; }
|
70
|
-
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; }
|
71
|
-
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; text-decoration: none; }
|
72
|
-
.ui-widget :active { outline: none; }
|
73
|
-
|
74
|
-
/* Interaction Cues
|
75
|
-
----------------------------------*/
|
76
|
-
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; }
|
77
|
-
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
|
78
|
-
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; }
|
79
|
-
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; }
|
80
|
-
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; }
|
81
|
-
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
82
|
-
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
83
|
-
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
84
|
-
|
85
|
-
/* Icons
|
86
|
-
----------------------------------*/
|
87
|
-
|
88
|
-
/* states and images */
|
89
|
-
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
|
90
|
-
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
91
|
-
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
|
92
|
-
.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
93
|
-
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
94
|
-
.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
95
|
-
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); }
|
96
|
-
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); }
|
97
|
-
|
98
|
-
/* positioning */
|
99
|
-
.ui-icon-carat-1-n { background-position: 0 0; }
|
100
|
-
.ui-icon-carat-1-ne { background-position: -16px 0; }
|
101
|
-
.ui-icon-carat-1-e { background-position: -32px 0; }
|
102
|
-
.ui-icon-carat-1-se { background-position: -48px 0; }
|
103
|
-
.ui-icon-carat-1-s { background-position: -64px 0; }
|
104
|
-
.ui-icon-carat-1-sw { background-position: -80px 0; }
|
105
|
-
.ui-icon-carat-1-w { background-position: -96px 0; }
|
106
|
-
.ui-icon-carat-1-nw { background-position: -112px 0; }
|
107
|
-
.ui-icon-carat-2-n-s { background-position: -128px 0; }
|
108
|
-
.ui-icon-carat-2-e-w { background-position: -144px 0; }
|
109
|
-
.ui-icon-triangle-1-n { background-position: 0 -16px; }
|
110
|
-
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
111
|
-
.ui-icon-triangle-1-e { background-position: -32px -16px; }
|
112
|
-
.ui-icon-triangle-1-se { background-position: -48px -16px; }
|
113
|
-
.ui-icon-triangle-1-s { background-position: -64px -16px; }
|
114
|
-
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
115
|
-
.ui-icon-triangle-1-w { background-position: -96px -16px; }
|
116
|
-
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
117
|
-
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
118
|
-
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
119
|
-
.ui-icon-arrow-1-n { background-position: 0 -32px; }
|
120
|
-
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
121
|
-
.ui-icon-arrow-1-e { background-position: -32px -32px; }
|
122
|
-
.ui-icon-arrow-1-se { background-position: -48px -32px; }
|
123
|
-
.ui-icon-arrow-1-s { background-position: -64px -32px; }
|
124
|
-
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
125
|
-
.ui-icon-arrow-1-w { background-position: -96px -32px; }
|
126
|
-
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
127
|
-
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
128
|
-
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
129
|
-
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
130
|
-
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
131
|
-
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
132
|
-
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
133
|
-
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
134
|
-
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
135
|
-
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
136
|
-
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
137
|
-
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
138
|
-
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
139
|
-
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
140
|
-
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
141
|
-
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
142
|
-
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
143
|
-
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
144
|
-
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
145
|
-
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
146
|
-
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
147
|
-
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
148
|
-
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
149
|
-
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
150
|
-
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
151
|
-
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
152
|
-
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
153
|
-
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
154
|
-
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
155
|
-
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
156
|
-
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
157
|
-
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
158
|
-
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
159
|
-
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
160
|
-
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
161
|
-
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
162
|
-
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
163
|
-
.ui-icon-arrow-4 { background-position: 0 -80px; }
|
164
|
-
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
165
|
-
.ui-icon-extlink { background-position: -32px -80px; }
|
166
|
-
.ui-icon-newwin { background-position: -48px -80px; }
|
167
|
-
.ui-icon-refresh { background-position: -64px -80px; }
|
168
|
-
.ui-icon-shuffle { background-position: -80px -80px; }
|
169
|
-
.ui-icon-transfer-e-w { background-position: -96px -80px; }
|
170
|
-
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
171
|
-
.ui-icon-folder-collapsed { background-position: 0 -96px; }
|
172
|
-
.ui-icon-folder-open { background-position: -16px -96px; }
|
173
|
-
.ui-icon-document { background-position: -32px -96px; }
|
174
|
-
.ui-icon-document-b { background-position: -48px -96px; }
|
175
|
-
.ui-icon-note { background-position: -64px -96px; }
|
176
|
-
.ui-icon-mail-closed { background-position: -80px -96px; }
|
177
|
-
.ui-icon-mail-open { background-position: -96px -96px; }
|
178
|
-
.ui-icon-suitcase { background-position: -112px -96px; }
|
179
|
-
.ui-icon-comment { background-position: -128px -96px; }
|
180
|
-
.ui-icon-person { background-position: -144px -96px; }
|
181
|
-
.ui-icon-print { background-position: -160px -96px; }
|
182
|
-
.ui-icon-trash { background-position: -176px -96px; }
|
183
|
-
.ui-icon-locked { background-position: -192px -96px; }
|
184
|
-
.ui-icon-unlocked { background-position: -208px -96px; }
|
185
|
-
.ui-icon-bookmark { background-position: -224px -96px; }
|
186
|
-
.ui-icon-tag { background-position: -240px -96px; }
|
187
|
-
.ui-icon-home { background-position: 0 -112px; }
|
188
|
-
.ui-icon-flag { background-position: -16px -112px; }
|
189
|
-
.ui-icon-calendar { background-position: -32px -112px; }
|
190
|
-
.ui-icon-cart { background-position: -48px -112px; }
|
191
|
-
.ui-icon-pencil { background-position: -64px -112px; }
|
192
|
-
.ui-icon-clock { background-position: -80px -112px; }
|
193
|
-
.ui-icon-disk { background-position: -96px -112px; }
|
194
|
-
.ui-icon-calculator { background-position: -112px -112px; }
|
195
|
-
.ui-icon-zoomin { background-position: -128px -112px; }
|
196
|
-
.ui-icon-zoomout { background-position: -144px -112px; }
|
197
|
-
.ui-icon-search { background-position: -160px -112px; }
|
198
|
-
.ui-icon-wrench { background-position: -176px -112px; }
|
199
|
-
.ui-icon-gear { background-position: -192px -112px; }
|
200
|
-
.ui-icon-heart { background-position: -208px -112px; }
|
201
|
-
.ui-icon-star { background-position: -224px -112px; }
|
202
|
-
.ui-icon-link { background-position: -240px -112px; }
|
203
|
-
.ui-icon-cancel { background-position: 0 -128px; }
|
204
|
-
.ui-icon-plus { background-position: -16px -128px; }
|
205
|
-
.ui-icon-plusthick { background-position: -32px -128px; }
|
206
|
-
.ui-icon-minus { background-position: -48px -128px; }
|
207
|
-
.ui-icon-minusthick { background-position: -64px -128px; }
|
208
|
-
.ui-icon-close { background-position: -80px -128px; }
|
209
|
-
.ui-icon-closethick { background-position: -96px -128px; }
|
210
|
-
.ui-icon-key { background-position: -112px -128px; }
|
211
|
-
.ui-icon-lightbulb { background-position: -128px -128px; }
|
212
|
-
.ui-icon-scissors { background-position: -144px -128px; }
|
213
|
-
.ui-icon-clipboard { background-position: -160px -128px; }
|
214
|
-
.ui-icon-copy { background-position: -176px -128px; }
|
215
|
-
.ui-icon-contact { background-position: -192px -128px; }
|
216
|
-
.ui-icon-image { background-position: -208px -128px; }
|
217
|
-
.ui-icon-video { background-position: -224px -128px; }
|
218
|
-
.ui-icon-script { background-position: -240px -128px; }
|
219
|
-
.ui-icon-alert { background-position: 0 -144px; }
|
220
|
-
.ui-icon-info { background-position: -16px -144px; }
|
221
|
-
.ui-icon-notice { background-position: -32px -144px; }
|
222
|
-
.ui-icon-help { background-position: -48px -144px; }
|
223
|
-
.ui-icon-check { background-position: -64px -144px; }
|
224
|
-
.ui-icon-bullet { background-position: -80px -144px; }
|
225
|
-
.ui-icon-radio-off { background-position: -96px -144px; }
|
226
|
-
.ui-icon-radio-on { background-position: -112px -144px; }
|
227
|
-
.ui-icon-pin-w { background-position: -128px -144px; }
|
228
|
-
.ui-icon-pin-s { background-position: -144px -144px; }
|
229
|
-
.ui-icon-play { background-position: 0 -160px; }
|
230
|
-
.ui-icon-pause { background-position: -16px -160px; }
|
231
|
-
.ui-icon-seek-next { background-position: -32px -160px; }
|
232
|
-
.ui-icon-seek-prev { background-position: -48px -160px; }
|
233
|
-
.ui-icon-seek-end { background-position: -64px -160px; }
|
234
|
-
.ui-icon-seek-start { background-position: -80px -160px; }
|
235
|
-
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
236
|
-
.ui-icon-seek-first { background-position: -80px -160px; }
|
237
|
-
.ui-icon-stop { background-position: -96px -160px; }
|
238
|
-
.ui-icon-eject { background-position: -112px -160px; }
|
239
|
-
.ui-icon-volume-off { background-position: -128px -160px; }
|
240
|
-
.ui-icon-volume-on { background-position: -144px -160px; }
|
241
|
-
.ui-icon-power { background-position: 0 -176px; }
|
242
|
-
.ui-icon-signal-diag { background-position: -16px -176px; }
|
243
|
-
.ui-icon-signal { background-position: -32px -176px; }
|
244
|
-
.ui-icon-battery-0 { background-position: -48px -176px; }
|
245
|
-
.ui-icon-battery-1 { background-position: -64px -176px; }
|
246
|
-
.ui-icon-battery-2 { background-position: -80px -176px; }
|
247
|
-
.ui-icon-battery-3 { background-position: -96px -176px; }
|
248
|
-
.ui-icon-circle-plus { background-position: 0 -192px; }
|
249
|
-
.ui-icon-circle-minus { background-position: -16px -192px; }
|
250
|
-
.ui-icon-circle-close { background-position: -32px -192px; }
|
251
|
-
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
252
|
-
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
253
|
-
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
254
|
-
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
255
|
-
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
256
|
-
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
257
|
-
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
258
|
-
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
259
|
-
.ui-icon-circle-zoomin { background-position: -176px -192px; }
|
260
|
-
.ui-icon-circle-zoomout { background-position: -192px -192px; }
|
261
|
-
.ui-icon-circle-check { background-position: -208px -192px; }
|
262
|
-
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
263
|
-
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
264
|
-
.ui-icon-circlesmall-close { background-position: -32px -208px; }
|
265
|
-
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
266
|
-
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
267
|
-
.ui-icon-squaresmall-close { background-position: -80px -208px; }
|
268
|
-
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
269
|
-
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
270
|
-
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
271
|
-
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
272
|
-
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
273
|
-
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
274
|
-
|
275
|
-
|
276
|
-
/* Misc visuals
|
277
|
-
----------------------------------*/
|
278
|
-
|
279
|
-
/* Corner radius */
|
280
|
-
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
|
281
|
-
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
|
282
|
-
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
|
283
|
-
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
|
284
|
-
|
285
|
-
/* Overlays */
|
286
|
-
.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .50;filter:Alpha(Opacity=50); }
|
287
|
-
.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }/*!
|
288
|
-
* jQuery UI Autocomplete 1.8.23
|
289
|
-
*
|
290
|
-
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
|
291
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
292
|
-
* http://jquery.org/license
|
293
|
-
*
|
294
|
-
* http://docs.jquery.com/UI/Autocomplete#theming
|
295
|
-
*/
|
296
|
-
.ui-autocomplete { position: absolute; cursor: default; }
|
297
|
-
|
298
|
-
/* workarounds */
|
299
|
-
* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
|
300
|
-
|
301
|
-
/*
|
302
|
-
* jQuery UI Menu 1.8.23
|
303
|
-
*
|
304
|
-
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
|
305
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
306
|
-
* http://jquery.org/license
|
307
|
-
*
|
308
|
-
* http://docs.jquery.com/UI/Menu#theming
|
309
|
-
*/
|
310
|
-
.ui-menu {
|
311
|
-
list-style:none;
|
312
|
-
padding: 2px;
|
313
|
-
margin: 0;
|
314
|
-
display:block;
|
315
|
-
float: left;
|
316
|
-
}
|
317
|
-
.ui-menu .ui-menu {
|
318
|
-
margin-top: -3px;
|
319
|
-
}
|
320
|
-
.ui-menu .ui-menu-item {
|
321
|
-
margin:0;
|
322
|
-
padding: 0;
|
323
|
-
zoom: 1;
|
324
|
-
float: left;
|
325
|
-
clear: left;
|
326
|
-
width: 100%;
|
327
|
-
}
|
328
|
-
.ui-menu .ui-menu-item a {
|
329
|
-
text-decoration:none;
|
330
|
-
display:block;
|
331
|
-
padding:.2em .4em;
|
332
|
-
line-height:1.5;
|
333
|
-
zoom:1;
|
334
|
-
}
|
335
|
-
.ui-menu .ui-menu-item a.ui-state-hover,
|
336
|
-
.ui-menu .ui-menu-item a.ui-state-active {
|
337
|
-
font-weight: normal;
|
338
|
-
margin: -1px;
|
339
|
-
}
|
@@ -1,888 +0,0 @@
|
|
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
|
-
#
|
26
|
-
# CmseditHelper module defines helper methods used by cmsedit actions. Output is controlled by
|
27
|
-
# data found in 3 major sections of DRG CMS form: index, result_set and form sections.
|
28
|
-
#
|
29
|
-
###########################################################################
|
30
|
-
module CmseditHelper
|
31
|
-
# javascript part created by form helpers
|
32
|
-
attr_reader :js
|
33
|
-
|
34
|
-
############################################################################
|
35
|
-
# Get standard actions when actions directive contains single line.
|
36
|
-
# Subroutine of dc_actions_for_index
|
37
|
-
#
|
38
|
-
# Allows for actions: new, filter, standard syntax
|
39
|
-
############################################################################
|
40
|
-
def define_standard_actions(actions_params, standard)
|
41
|
-
actions = {}
|
42
|
-
actions_params.split(',').each do |an_action|
|
43
|
-
an_action.strip!
|
44
|
-
if an_action == 'standard'
|
45
|
-
actions.merge!(standard)
|
46
|
-
else
|
47
|
-
standard.each do |index, action|
|
48
|
-
(actions[index] = action; break) if action == an_action
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
actions
|
53
|
-
end
|
54
|
-
|
55
|
-
############################################################################
|
56
|
-
# Creates action div for cmsedit index action.
|
57
|
-
############################################################################
|
58
|
-
def dc_actions_for_index()
|
59
|
-
return '' if @form['index'].nil? or @form['readonly']
|
60
|
-
actions = @form['index']['actions']
|
61
|
-
return '' if actions.nil? or actions.size == 0
|
62
|
-
std_actions = {2 => 'new', 3 => 'sort', 4 => 'filter' }
|
63
|
-
if actions.class == String
|
64
|
-
actions = define_standard_actions(actions, std_actions)
|
65
|
-
elsif actions['standard']
|
66
|
-
actions.merge!(std_actions)
|
67
|
-
actions['standard'] = nil
|
68
|
-
end
|
69
|
-
|
70
|
-
# start div with hidden spinner image
|
71
|
-
html = <<EOT
|
72
|
-
<div id="dc-action-menu">
|
73
|
-
<span class="dc-spinner div-hidden">#{fa_icon('spinner lg spin')}</span>
|
74
|
-
<ul class="dc-action-menu">
|
75
|
-
EOT
|
76
|
-
# Remove actions settings and sort
|
77
|
-
only_actions = []
|
78
|
-
actions.each { |key, value| only_actions << [key, value] if key.class == Integer }
|
79
|
-
only_actions.sort_by!(&:first)
|
80
|
-
only_actions.each do |element|
|
81
|
-
k,v = element
|
82
|
-
session[:form_processing] = "index:actions: #{k}=#{v}"
|
83
|
-
next if v.nil? # must be
|
84
|
-
url = @parms.clone
|
85
|
-
yaml = v.class == String ? {'type' => v} : v # if single definition simulate type parameter
|
86
|
-
action = yaml['type'].to_s.downcase
|
87
|
-
if action == 'url'
|
88
|
-
dc_deprecate "action: url will be deprecated. Use action: link in index: actions"
|
89
|
-
action = 'link'
|
90
|
-
end
|
91
|
-
# if return_to is present link directly to URL
|
92
|
-
if action == 'link' and yaml['url']
|
93
|
-
url = yaml['url']
|
94
|
-
else
|
95
|
-
url['controller'] = yaml['controller'] if yaml['controller']
|
96
|
-
url['action'] = yaml['action'] || action
|
97
|
-
url['table'] = yaml['table'] if yaml['table']
|
98
|
-
url['form_name'] = yaml['form_name'] if yaml['form_name']
|
99
|
-
end
|
100
|
-
# html link options
|
101
|
-
yhtml = yaml['html'] || {}
|
102
|
-
yhtml['title'] = yaml['title'] if yaml['title']
|
103
|
-
code = case
|
104
|
-
# sort
|
105
|
-
when action == 'sort' then
|
106
|
-
choices = [['id','id']]
|
107
|
-
if @form['index']['sort']
|
108
|
-
@form['index']['sort'].split(',').each do |s|
|
109
|
-
s.strip!
|
110
|
-
choices << [ t("helpers.label.#{@form['table']}.#{s}"), s ]
|
111
|
-
end
|
112
|
-
end
|
113
|
-
fa_icon('sort-alpha-asc') + ' ' + t('drgcms.sort') + ' ' +
|
114
|
-
select('sort', 'sort', choices, { include_blank: true },
|
115
|
-
{ class: 'drgcms_sort', 'data-table' => @form['table']} )
|
116
|
-
# filter
|
117
|
-
when action == 'filter' then
|
118
|
-
caption = t('drgcms.filter')
|
119
|
-
caption << ' ' + fa_icon('caret-down lg') + DcFilter.menu_filter(self)
|
120
|
-
# add filter OFF link
|
121
|
-
s = session[@form['table']]
|
122
|
-
if s and s[:filter]
|
123
|
-
caption << ' ' + dc_link_to(nil,'remove lg', {controller: 'cmsedit',
|
124
|
-
filter: 'off', table: @form['table']}, { title: DcFilter.title4_filter_off(s[:filter]) })
|
125
|
-
end
|
126
|
-
caption
|
127
|
-
# new
|
128
|
-
when action == 'new' then
|
129
|
-
caption = yaml['caption'] || 'drgcms.new'
|
130
|
-
dc_link_to(caption,'plus', url, yhtml )
|
131
|
-
# menu
|
132
|
-
when action == 'menu' then
|
133
|
-
caption = t(v['caption'], v['caption']) + ' ' + fa_icon('caret-down lg')
|
134
|
-
caption + eval(v['eval'])
|
135
|
-
=begin
|
136
|
-
# reorder
|
137
|
-
when action == 'reorder' then
|
138
|
-
caption = t('drgcms.reorder')
|
139
|
-
parms = @parms.clone
|
140
|
-
parms['operation'] = v
|
141
|
-
parms['id'] = params[:ids]
|
142
|
-
parms['table'] = @form['table']
|
143
|
-
dc_link_to( caption, 'reorder', parms, method: :delete )
|
144
|
-
=end
|
145
|
-
when action == 'script'
|
146
|
-
html << dc_script_action(v)
|
147
|
-
next
|
148
|
-
else
|
149
|
-
caption = yaml['caption'] || yaml['text']
|
150
|
-
icon = yaml['icon'] ? yaml['icon'] : action
|
151
|
-
dc_link_to(caption, icon, url, yhtml)
|
152
|
-
end
|
153
|
-
html << "<li class=\"dc-animate\">#{code}</li>"
|
154
|
-
end
|
155
|
-
html << '</ul>'
|
156
|
-
html << DcFilter.get_filter_field(self)
|
157
|
-
html << '</div>'
|
158
|
-
html.html_safe
|
159
|
-
end
|
160
|
-
|
161
|
-
############################################################################
|
162
|
-
# Creates filter div for cmsedit index/filter action.
|
163
|
-
############################################################################
|
164
|
-
def dc_div_filter()
|
165
|
-
choices = []
|
166
|
-
filter = (@form['index'] and @form['index']['filter']) ? @form['index']['filter'] + ',' : ''
|
167
|
-
filter << 'id as text_field' # filter id is added by default
|
168
|
-
filter.split(',').each do |f|
|
169
|
-
f.strip!
|
170
|
-
name = f.match(' as ') ? f.split(' ').first : f
|
171
|
-
# like another field on the form
|
172
|
-
if f.match(' like ')
|
173
|
-
a = f.split(' ')
|
174
|
-
name = a.first
|
175
|
-
f = a.last
|
176
|
-
end
|
177
|
-
choices << [ t("helpers.label.#{@form['table']}.#{name}", name), f ]
|
178
|
-
end
|
179
|
-
choices4_operators = t('drgcms.choices4_filter_operators').chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )}
|
180
|
-
# currently selected options
|
181
|
-
if session[@form['table']] and session[@form['table']][:filter]
|
182
|
-
field_name, operators_value, dummy = session[@form['table']][:filter].split("\t")
|
183
|
-
else
|
184
|
-
field_name, operators_value = nil, nil
|
185
|
-
end
|
186
|
-
#{ form_tag :table => @form['table'], filter: :on, filter_input: 1, action: :index, method: :post }
|
187
|
-
url = url_for(table: @form['table'],form_name: params['form_name'], filter: :on, filter_input: 1, action: :index, controller: :cmsedit)
|
188
|
-
html =<<EOT
|
189
|
-
<div id="drgcms_filter" class="div-hidden">
|
190
|
-
<h1>#{t('drgcms.filter_set')}</h1>
|
191
|
-
|
192
|
-
#{ select(nil, 'filter_field1', options_for_select(choices, field_name), { include_blank: true }) }
|
193
|
-
#{ select(nil, 'filter_oper', options_for_select(choices4_operators, operators_value)) }
|
194
|
-
<div class="dc-menu">
|
195
|
-
<div class="dc-link dc-animate drgcms_popup_submit" data-url="#{url}">#{fa_icon('check-square-o')} #{t('drgcms.filter_on')}</div>
|
196
|
-
<div class="dc-link dc-animate">#{dc_link_to('drgcms.filter_off','close', {action: :index, filter: 'off', table: @form['table'], form_name: params['form_name']}) }</div>
|
197
|
-
</div>
|
198
|
-
</div>
|
199
|
-
EOT
|
200
|
-
html.html_safe
|
201
|
-
end
|
202
|
-
|
203
|
-
############################################################################
|
204
|
-
# Creates title div for cmsedit index result set records. Title div also includes paging
|
205
|
-
# options.
|
206
|
-
############################################################################
|
207
|
-
def dc_table_title_for_result(result=nil)
|
208
|
-
title = if @form['title'] # form has title section
|
209
|
-
t(@form['title'],@form['title'])
|
210
|
-
else # get name from translations
|
211
|
-
t('helpers.label.' + @form['table'] + '.tabletitle', @form['table'])
|
212
|
-
end
|
213
|
-
dc_table_title(title, result)
|
214
|
-
end
|
215
|
-
|
216
|
-
############################################################################
|
217
|
-
# Creates code for link or ajax action type. Subroutine of dc_actions_for_result.
|
218
|
-
############################################################################
|
219
|
-
def dc_link_or_ajax_action(yaml, parms) #:nodoc:
|
220
|
-
rest = {}
|
221
|
-
rest['method'] = yaml['method'] || yaml['request'] || 'get'
|
222
|
-
rest['caption'] = yaml['caption'] || yaml['text']
|
223
|
-
rest['class'] = 'dc-animate'
|
224
|
-
rest['title'] = yaml['title']
|
225
|
-
|
226
|
-
if yaml['type'] == 'link'
|
227
|
-
dc_link_to(yaml['caption'], yaml['icon'], parms, rest )
|
228
|
-
else
|
229
|
-
rest['data-url'] = url_for(parms)
|
230
|
-
rest['class'] << " fa fa-#{yaml['icon']}"
|
231
|
-
fa_icon(yaml['icon'], rest )
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
############################################################################
|
236
|
-
# Creates code for script action type.
|
237
|
-
############################################################################
|
238
|
-
def dc_script_action(yaml)
|
239
|
-
data = {'request' => 'script', 'script' => yaml['js']}
|
240
|
-
%Q[<li class="dc-link-ajax dc-animate">#{ dc_link_to(yaml['caption'], yaml['icon'], '#', data: data ) }</li>]
|
241
|
-
end
|
242
|
-
|
243
|
-
############################################################################
|
244
|
-
# Determines actions and width of actions column
|
245
|
-
############################################################################
|
246
|
-
def dc_actions_column()
|
247
|
-
actions = @form['result_set']['actions']
|
248
|
-
# standard actions
|
249
|
-
actions = {'standard' => true} if actions.class == String && actions == 'standard'
|
250
|
-
std_actions = {' 2' => 'edit', ' 3' => 'delete'}
|
251
|
-
actions.merge!(std_actions) if actions['standard']
|
252
|
-
#
|
253
|
-
width = @form['result_set']['actions_width'] || 20*actions.size
|
254
|
-
[ actions, "<div class=\"actions\" style=\"width: #{width}px;\">" ]
|
255
|
-
end
|
256
|
-
|
257
|
-
############################################################################
|
258
|
-
# Creates actions that could be performed on single row of result set.
|
259
|
-
############################################################################
|
260
|
-
def dc_actions_for_result(document)
|
261
|
-
actions = @form['result_set']['actions']
|
262
|
-
return '' if actions.nil? or @form['readonly']
|
263
|
-
#
|
264
|
-
actions, html = dc_actions_column()
|
265
|
-
actions.each do |k,v|
|
266
|
-
session[:form_processing] = "result_set:actions: #{k}=#{v}"
|
267
|
-
next if k == 'standard' # ignore standard definition
|
268
|
-
parms = @parms.clone
|
269
|
-
yaml = v.class == String ? {'type' => v} : v # if single definition simulate type parameter
|
270
|
-
html << case
|
271
|
-
when yaml['type'] == 'edit' then
|
272
|
-
parms['action'] = 'edit'
|
273
|
-
parms['id'] = document.id
|
274
|
-
dc_link_to( nil, 'pencil lg', parms )
|
275
|
-
when yaml['type'] == 'duplicate' then
|
276
|
-
parms['id'] = document.id
|
277
|
-
# duplicate string will be added to these fields.
|
278
|
-
parms['dup_fields'] = yaml['dup_fields']
|
279
|
-
parms['action'] = 'create'
|
280
|
-
dc_link_to( nil, 'copy lg', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post )
|
281
|
-
when yaml['type'] == 'delete' then
|
282
|
-
parms['action'] = 'destroy'
|
283
|
-
parms['id'] = document.id
|
284
|
-
dc_link_to( nil, 'remove lg', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete )
|
285
|
-
# undocumented so far
|
286
|
-
when yaml['type'] == 'edit_embedded'
|
287
|
-
parms['controller'] = 'cmsedit'
|
288
|
-
parms['table'] += ";#{yaml['table']}"
|
289
|
-
parms['ids'] ||= ''
|
290
|
-
parms['ids'] += "#{document.id};"
|
291
|
-
dc_link_to( nil, 'table lg', parms, method: :get )
|
292
|
-
when yaml['type'] == 'link' || yaml['type'] == 'ajax' then
|
293
|
-
if yaml['url']
|
294
|
-
parms['controller'] = yaml['url']
|
295
|
-
parms['idr'] = document.id
|
296
|
-
else
|
297
|
-
parms['id'] = document.id
|
298
|
-
end
|
299
|
-
parms['controller'] = yaml['controller'] if yaml['controller']
|
300
|
-
parms['action'] = yaml['action'] if yaml['action']
|
301
|
-
parms['table'] = yaml['table'] if yaml['table']
|
302
|
-
parms['form_name'] = yaml['form_name'] if yaml['form_name']
|
303
|
-
parms['target'] = yaml['target'] if yaml['target']
|
304
|
-
dc_link_or_ajax_action(yaml, parms)
|
305
|
-
else # error.
|
306
|
-
yaml['type'].to_s
|
307
|
-
end
|
308
|
-
end
|
309
|
-
html << '</div>'
|
310
|
-
html.html_safe
|
311
|
-
end
|
312
|
-
|
313
|
-
############################################################################
|
314
|
-
# Creates header div for result set.
|
315
|
-
############################################################################
|
316
|
-
def dc_header_for_result()
|
317
|
-
html = '<div class="dc-result-header">'
|
318
|
-
if @form['result_set']['actions'] and !@form['readonly']
|
319
|
-
ignore, code = dc_actions_column()
|
320
|
-
html << code + '</div>'
|
321
|
-
end
|
322
|
-
# preparation for sort icon
|
323
|
-
sort_field, sort_direction = nil, nil
|
324
|
-
if session[@form['table']]
|
325
|
-
sort_field, sort_direction = session[@form['table']][:sort].to_s.split(' ')
|
326
|
-
end
|
327
|
-
#
|
328
|
-
if (columns = @form['result_set']['columns'])
|
329
|
-
columns.each do |k,v|
|
330
|
-
session[:form_processing] = "result_set:columns: #{k}=#{v}"
|
331
|
-
#
|
332
|
-
th = %Q[<div class="th" style="width: #{v['width'] || '15%'};text-align: #{v['align'] || 'left'};"]
|
333
|
-
v = {'name' => v} if v.class == String
|
334
|
-
caption = v['caption'] || t("helpers.label.#{@form['table']}.#{v['name']}")
|
335
|
-
# no sorting when embedded documents or custom filter is active
|
336
|
-
sort_ok = @form['result_set'].nil? || (@form['result_set'] && @form['result_set']['filter'].nil?)
|
337
|
-
sort_ok = sort_ok || (@form['index'] && @form['index']['sort'])
|
338
|
-
if @tables.size == 1 and sort_ok
|
339
|
-
icon = 'sort lg'
|
340
|
-
if v['name'] == sort_field
|
341
|
-
icon = sort_direction == '1' ? 'sort-alpha-asc lg' : 'sort-alpha-desc lg'
|
342
|
-
end
|
343
|
-
th << ">#{dc_link_to(caption, icon, sort: v['name'], table: params[:table], form_name: params[:form_name], action: :index, icon_pos: :last )}</div>"
|
344
|
-
else
|
345
|
-
th << ">#{caption}</div>"
|
346
|
-
end
|
347
|
-
html << "<div class=\"spacer\"></div>" + th
|
348
|
-
end
|
349
|
-
end
|
350
|
-
(html << '</div>').html_safe
|
351
|
-
end
|
352
|
-
|
353
|
-
############################################################################
|
354
|
-
# Creates link for single or double click on result column
|
355
|
-
############################################################################
|
356
|
-
def dc_clicks_for_result(document)
|
357
|
-
html = ''
|
358
|
-
if @form['result_set']['dblclick']
|
359
|
-
yaml = @form['result_set']['dblclick']
|
360
|
-
opts = {}
|
361
|
-
opts[:controller] = yaml['controller'] || 'cmsedit'
|
362
|
-
opts[:action] = yaml['action']
|
363
|
-
opts[:table] = yaml['table']
|
364
|
-
opts[:form_name] = yaml['form_name']
|
365
|
-
opts[:method] = yaml['method'] || 'get'
|
366
|
-
opts[:id] = document['id']
|
367
|
-
html << ' data-dblclick=' + url_for(opts)
|
368
|
-
else
|
369
|
-
html << (' data-dblclick=' +
|
370
|
-
url_for(action: 'show', controller: 'cmsedit', id: document.id,
|
371
|
-
readonly: (params[:readonly] ? 2 : 1), table: params[:table],
|
372
|
-
form_name: params[:form_name], ids: params[:ids]) ) if @form['form']
|
373
|
-
end
|
374
|
-
html
|
375
|
-
end
|
376
|
-
|
377
|
-
############################################################################
|
378
|
-
# Formats value according to format supplied or data type. There is lots of things missing here.
|
379
|
-
############################################################################
|
380
|
-
def dc_format_value(value, format=nil)
|
381
|
-
return '' if value.nil?
|
382
|
-
klass = value.class.to_s
|
383
|
-
case when klass.match('Time') then
|
384
|
-
format ||= t('time.formats.default')
|
385
|
-
value.strftime(format)
|
386
|
-
when klass.match('Date') then
|
387
|
-
format ||= t('date.formats.default')
|
388
|
-
value.strftime(format)
|
389
|
-
when format.to_s[0] == 'N' then
|
390
|
-
dec = format[1].blank? ? nil : format[1].to_i
|
391
|
-
sep = format[2].blank? ? nil : format[2]
|
392
|
-
del = format[3].blank? ? nil : format[3]
|
393
|
-
cur = format[4].blank? ? nil : format[4]
|
394
|
-
dc_format_number(value, dec, sep, del, cur)
|
395
|
-
else
|
396
|
-
value.to_s
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
############################################################################
|
401
|
-
# Defines style or class for row (tr) or column (td)
|
402
|
-
############################################################################
|
403
|
-
def dc_style_or_class(selector, yaml, value, record)
|
404
|
-
return '' if yaml.nil?
|
405
|
-
# alias record and value so both names can be used in eval
|
406
|
-
field = value
|
407
|
-
document = record
|
408
|
-
html = selector ? "#{selector}=\"" : ''
|
409
|
-
html << if yaml.class == String
|
410
|
-
yaml
|
411
|
-
else
|
412
|
-
(yaml['eval'] ? eval(yaml['eval']) : '') rescue 'background-color:red;'
|
413
|
-
end
|
414
|
-
html << '"' if selector
|
415
|
-
html
|
416
|
-
end
|
417
|
-
|
418
|
-
############################################################################
|
419
|
-
# Creates tr code for each row of result set.
|
420
|
-
############################################################################
|
421
|
-
def dc_row_for_result(document)
|
422
|
-
clas = "dc-#{cycle('odd','even')} " + dc_style_or_class(nil, @form['result_set']['tr_class'], nil, document)
|
423
|
-
style = dc_style_or_class('style', @form['result_set']['tr_style'], nil, document)
|
424
|
-
"<div class=\"dc-result-data #{clas}\" #{dc_clicks_for_result(document)} #{style}>".html_safe
|
425
|
-
end
|
426
|
-
|
427
|
-
############################################################################
|
428
|
-
# Creates column for each field of result set document.
|
429
|
-
############################################################################
|
430
|
-
def dc_columns_for_result(document)
|
431
|
-
html = ''
|
432
|
-
return html unless @form['result_set']['columns']
|
433
|
-
#
|
434
|
-
@form['result_set']['columns'].each do |k,v|
|
435
|
-
session[:form_processing] = "result_set:columns: #{k}=#{v}"
|
436
|
-
# convert shortcut to hash
|
437
|
-
v = {'name' => v} if v.class == String
|
438
|
-
# eval
|
439
|
-
value = if v['eval']
|
440
|
-
if v['eval'].match('dc_name4_id')
|
441
|
-
a = v['eval'].split(',')
|
442
|
-
if a.size == 3
|
443
|
-
dc_name4_id(a[1], a[2], nil, document[ v['name'] ])
|
444
|
-
else
|
445
|
-
dc_name4_id(a[1], a[2], a[3], document[ v['name'] ])
|
446
|
-
end
|
447
|
-
elsif v['eval'].match('dc_name4_value')
|
448
|
-
dc_name4_value( @form['table'], v['name'], document[ v['name'] ] )
|
449
|
-
elsif v['eval'].match('eval ')
|
450
|
-
# evaluate with specified parameters
|
451
|
-
else
|
452
|
-
if v['params']
|
453
|
-
if v['params'] == 'document' # pass document as parameter when all
|
454
|
-
eval( "#{v['eval']} document")
|
455
|
-
else # list of fields delimeted by ,
|
456
|
-
params = v['params'].chomp.split(',').inject('') do |result,e|
|
457
|
-
result << (e.match(/\.|\:|\(/) ? e : "document['#{e.strip}']") + ','
|
458
|
-
end
|
459
|
-
params.chomp!(',')
|
460
|
-
eval( "#{v['eval']} #{params}")
|
461
|
-
end
|
462
|
-
else
|
463
|
-
eval( "#{v['eval']} '#{document[ v['name'] ]}'")
|
464
|
-
end
|
465
|
-
end
|
466
|
-
# as field
|
467
|
-
elsif document.respond_to?(v['name'])
|
468
|
-
dc_format_value(document.send( v['name'] ), v['format'])
|
469
|
-
# as hash (dc_memory)
|
470
|
-
elsif document.class == Hash
|
471
|
-
dc_format_value(document[ v['name'] ], v['format'])
|
472
|
-
# error
|
473
|
-
else
|
474
|
-
"!!! #{v['name']}"
|
475
|
-
end
|
476
|
-
#
|
477
|
-
td = '<div class="spacer"></div><div class="td" '
|
478
|
-
td << dc_style_or_class('class', v['td_class'], value, document)
|
479
|
-
|
480
|
-
width_align = %Q[width: #{v['width'] || '15%'};text-align: #{v['align'] || 'left'};]
|
481
|
-
style = dc_style_or_class('style', v['td_style'] || v['style'], value, document)
|
482
|
-
style = if style.size > 1
|
483
|
-
# remove trailing " add width and add trailing " back
|
484
|
-
style.delete_suffix('"') + width_align + '"'
|
485
|
-
else
|
486
|
-
# create style string
|
487
|
-
"style=\"#{width_align}\""
|
488
|
-
end
|
489
|
-
html << "#{td} #{style}>#{value}</div>"
|
490
|
-
end
|
491
|
-
html.html_safe
|
492
|
-
end
|
493
|
-
|
494
|
-
############################################################################
|
495
|
-
# Will return value for parameter required on form
|
496
|
-
############################################################################
|
497
|
-
def dc_value_for_parameter(param)
|
498
|
-
if param.class == Hash
|
499
|
-
dc_internal_var(param['object'] || 'record', param['method'])
|
500
|
-
else
|
501
|
-
param
|
502
|
-
end
|
503
|
-
end
|
504
|
-
|
505
|
-
############################################################################
|
506
|
-
# Creates actions div for edit form.
|
507
|
-
#
|
508
|
-
# Displaying readonly form turned out to be challenge. For now when readonly parameter
|
509
|
-
# has value 2, back link will force readonly form. Value 1 or not set will result in
|
510
|
-
# normal link.
|
511
|
-
############################################################################
|
512
|
-
def dc_actions_for_form()
|
513
|
-
# create standard actions
|
514
|
-
std_actions = {' 1' => 'back', ' 2' => {'type' => 'submit', 'caption' => 'drgcms.save'},
|
515
|
-
' 3' => {'type' => 'submit', 'caption' => 'drgcms.save&back'} }
|
516
|
-
# when edit only
|
517
|
-
unless @record.id.nil?
|
518
|
-
std_actions.merge!({' 6' => 'new'} )
|
519
|
-
std_actions.merge!(@record.active ? {' 5' => 'disable'} : {' 5' => 'enable'} ) if @record.respond_to?('active')
|
520
|
-
std_actions.merge!({' 7' => 'refresh'} )
|
521
|
-
end
|
522
|
-
actions = @form['form']['actions']
|
523
|
-
# shortcut for actions: standard
|
524
|
-
actions = nil if actions.class == String && actions == 'standard'
|
525
|
-
# standard actions
|
526
|
-
actions = std_actions if actions.nil?
|
527
|
-
# readonly
|
528
|
-
actions = {' 1' => 'back'} if @form['readonly']
|
529
|
-
# Actions are strictly forbidden
|
530
|
-
if @form['form']['actions'] and dc_dont?(@form['form']['actions'])
|
531
|
-
actions = []
|
532
|
-
elsif actions['standard']
|
533
|
-
actions.merge!(std_actions)
|
534
|
-
actions['standard'] = nil
|
535
|
-
end
|
536
|
-
# Update save and save&back
|
537
|
-
actions.each do |k,v|
|
538
|
-
if v.class == String
|
539
|
-
if v.match(/save\&back/i)
|
540
|
-
actions[k] = {'type' => 'submit', 'caption' => 'drgcms.save&back'}
|
541
|
-
elsif v == 'save'
|
542
|
-
actions[k] = {'type' => 'submit', 'caption' => 'drgcms.save'}
|
543
|
-
end
|
544
|
-
end
|
545
|
-
end
|
546
|
-
# Sort so that standard actions come first
|
547
|
-
actions = actions.to_a.sort {|x,y| x[0].to_s <=> y[0].to_s}
|
548
|
-
# Add spinner to the beginning
|
549
|
-
c = %Q[<span class="dc-spinner div-hidden">#{fa_icon('spinner lg spin')}</span><ul class="dc-menu">]
|
550
|
-
|
551
|
-
actions.each do |element|
|
552
|
-
session[:form_processing] = "form:actions: #{element}"
|
553
|
-
v = element[1]
|
554
|
-
next if v.nil? # yes it happends
|
555
|
-
p "Using text option in actions_for form is replaced with caption. Table #{@form['table']}" if v['text']
|
556
|
-
# on_save_ok should't go inside td tags
|
557
|
-
if (element[0] == 'on_save_ok') then
|
558
|
-
c << hidden_field_tag(:on_save_ok, v)
|
559
|
-
next
|
560
|
-
end
|
561
|
-
#
|
562
|
-
action_active = !(dc_dont?(v['when_new']) and @record.new_record?)
|
563
|
-
# p [v['caption'], action_active]
|
564
|
-
parms = @parms.clone
|
565
|
-
if v.class == String
|
566
|
-
next if params[:readonly] and !(v == 'back')
|
567
|
-
|
568
|
-
c << '<li class="dc-link dc-animate">'
|
569
|
-
c << case
|
570
|
-
when (v == 'back' or v == 'cancle') then
|
571
|
-
# If return_to is present link directly to URL
|
572
|
-
if parms['xreturn_to'] # disabled for now
|
573
|
-
dc_link_to( 'drgcms.back','arrow-left', parms['return_to'] )
|
574
|
-
else
|
575
|
-
parms['action'] = 'index'
|
576
|
-
parms['readonly'] = parms['readonly'].to_s.to_i < 2 ? nil : 1
|
577
|
-
dc_link_to( 'drgcms.back','arrow-left', parms )
|
578
|
-
end
|
579
|
-
when v == 'delete' then
|
580
|
-
parms['operation'] = v
|
581
|
-
parms['id'] = @record.id
|
582
|
-
dc_link_to( 'drgcms.delete','remove', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete )
|
583
|
-
when v == 'new' then
|
584
|
-
parms['action'] = v
|
585
|
-
dc_link_to( 'drgcms.new', 'plus', parms)
|
586
|
-
when (v == 'enable' or v == 'disable') then
|
587
|
-
parms['operation'] = v
|
588
|
-
parms['id'] = @record.id
|
589
|
-
icon = (v == 'enable' ? 'thumbs-o-up' : 'thumbs-o-down')
|
590
|
-
dc_link_to( "drgcms.#{v}",icon, parms, method: :delete )
|
591
|
-
when v == 'edit' then
|
592
|
-
parms['operation'] = v
|
593
|
-
parms['id'] = @record.id
|
594
|
-
dc_link_to( "drgcms.#{v}",v, parms )
|
595
|
-
when v == 'refresh' then
|
596
|
-
"<span onclick='window.location.href=window.location.href;'>#{fa_icon('refresh')} #{t('drgcms.refresh')}</span></li>"
|
597
|
-
else
|
598
|
-
"err1 #{element[0]}=>#{v}"
|
599
|
-
end
|
600
|
-
c << '</td>'
|
601
|
-
# non standard actions
|
602
|
-
else
|
603
|
-
c << case
|
604
|
-
# submit button
|
605
|
-
when v['type'] == 'submit'
|
606
|
-
caption = v['caption'] || 'drgcms.save'
|
607
|
-
icon = v['icon'] || 'save'
|
608
|
-
if action_active
|
609
|
-
'<li class="dc-link-submit dc-animate">' +
|
610
|
-
dc_submit_tag(caption, icon, {:data => v['params'], :title => v['title'] }) +
|
611
|
-
'</li>'
|
612
|
-
else
|
613
|
-
"<li class=\"dc-link-no\">#{fa_icon(icon)} #{caption}</li>"
|
614
|
-
end
|
615
|
-
|
616
|
-
# delete with some sugar added
|
617
|
-
when v['type'] == 'delete'
|
618
|
-
parms['id'] = @record.id
|
619
|
-
parms.merge!(v['params'])
|
620
|
-
caption = v['caption'] || 'drgcms.delete'
|
621
|
-
icon = v['icon'] || 'remove'
|
622
|
-
'<li class="dc-link dc-animate">' +
|
623
|
-
dc_link_to( caption, icon, parms, data: t('drgcms.confirm_delete'), method: :delete ) +
|
624
|
-
'</li>'
|
625
|
-
|
626
|
-
# ajax or link button
|
627
|
-
when v['type'] == 'ajax' || v['type'] == 'link' || v['type'] == 'window'
|
628
|
-
parms = {}
|
629
|
-
# direct url
|
630
|
-
if v['url']
|
631
|
-
parms['controller'] = v['url']
|
632
|
-
parms['idr'] = dc_document_path(@record)
|
633
|
-
# make url from action controller
|
634
|
-
else
|
635
|
-
parms['controller'] = v['controller']
|
636
|
-
parms['action'] = v['action']
|
637
|
-
parms['table'] = v['table']
|
638
|
-
parms['form_name'] = v['form_name']
|
639
|
-
end
|
640
|
-
# add current id to parameters
|
641
|
-
parms['id'] = dc_document_path(@record)
|
642
|
-
# additional parameters
|
643
|
-
v['params'].each { |k,v| parms[k] = dc_value_for_parameter(v) } if v['params']
|
644
|
-
# Error if controller parameter is missing
|
645
|
-
if parms['controller'].nil?
|
646
|
-
"<li>#{t('drgcms.error')}</li>"
|
647
|
-
else
|
648
|
-
v['caption'] ||= v['text']
|
649
|
-
caption = t("#{v['caption'].downcase}", v['caption'])
|
650
|
-
#
|
651
|
-
url = url_for(parms) rescue ''
|
652
|
-
request = v['request'] || v['method'] || 'get'
|
653
|
-
icon = v['icon'] ? "#{fa_icon(v['icon'])} " : ''
|
654
|
-
if v['type'] == 'ajax' # ajax button
|
655
|
-
clas = action_active ? "dc-link-ajax dc-animate" : "dc-link-no"
|
656
|
-
%Q[<li class="#{clas}" data-url="#{action_active ? url : ''}"
|
657
|
-
data-request="#{request}" title="#{v['title']}">#{icon}#{caption}</li>]
|
658
|
-
elsif v['type'] == 'link' # link button
|
659
|
-
clas = action_active ? "dc-link dc-animate" : "dc-link-no"
|
660
|
-
%Q[<li class="#{clas}">#{action_active ? dc_link_to(v['caption'],v['icon'], parms, {target: v['target']} ) : caption}</li>]
|
661
|
-
elsif v['type'] == 'window'
|
662
|
-
clas = action_active ? "dc-link dc-animate dc-window-open" : "dc-link-no"
|
663
|
-
%Q[<li class="#{clas}" data-url="#{action_active ? url : ''}">#{icon}#{caption}</li>]
|
664
|
-
else
|
665
|
-
'Action Type error'
|
666
|
-
end
|
667
|
-
end
|
668
|
-
|
669
|
-
# Javascript action
|
670
|
-
when v['type'] == 'script'
|
671
|
-
dc_script_action(v)
|
672
|
-
else
|
673
|
-
'<li>err2</li>'
|
674
|
-
end
|
675
|
-
end
|
676
|
-
end
|
677
|
-
(c << '</ul>').html_safe
|
678
|
-
end
|
679
|
-
|
680
|
-
############################################################################
|
681
|
-
# Create background div and table definitions for result set.
|
682
|
-
############################################################################
|
683
|
-
def dc_background_for_result(start)
|
684
|
-
if start == :start
|
685
|
-
html = '<div class="dc-result-div" '
|
686
|
-
html << (@form['result_set']['table_style'] ? 'style="overflow-x: scroll;" >' : '>')
|
687
|
-
#
|
688
|
-
html << "\n<div class=\"dc-result #{@form['result_set']['table_class']}\" "
|
689
|
-
html << (@form['result_set']['table_style'] ? "style=\"#{@form['result_set']['table_style']}\" >" : '>')
|
690
|
-
else
|
691
|
-
html = '</div></div>'
|
692
|
-
end
|
693
|
-
html.html_safe
|
694
|
-
end
|
695
|
-
|
696
|
-
############################################################################
|
697
|
-
# Checks if value is defined and sets default. If values are sent it also checks
|
698
|
-
# if value is found in values. If not it will report error and set value to default.
|
699
|
-
# Subroutine of dc_fields_for_tab.
|
700
|
-
############################################################################
|
701
|
-
def dc_check_and_default(value, default, values=nil) #:nodoc:
|
702
|
-
return default if value.nil?
|
703
|
-
# check if value is within allowed values
|
704
|
-
if values
|
705
|
-
if !values.index(value)
|
706
|
-
# parameters should be in downcase. Check downcase version.
|
707
|
-
if n = values.index(value.downcase)
|
708
|
-
return values[n]
|
709
|
-
else
|
710
|
-
logger.error("DRG Forms: Value #{value} not within values [#{values.join(',')}]. Default #{default} used!")
|
711
|
-
return default
|
712
|
-
end
|
713
|
-
end
|
714
|
-
end
|
715
|
-
value
|
716
|
-
end
|
717
|
-
|
718
|
-
############################################################################
|
719
|
-
# Creates top or bottom horizontal line on form.
|
720
|
-
############################################################################
|
721
|
-
def top_bottom_line(yaml, columns=2)
|
722
|
-
'<div class="dc-separator"></div>'
|
723
|
-
end
|
724
|
-
|
725
|
-
############################################################################
|
726
|
-
# Creates input fields for one tab. Subroutine of dc_fields_for_form.
|
727
|
-
############################################################################
|
728
|
-
def dc_fields_for_tab(fields_on_tab) #:nodoc:
|
729
|
-
@js ||= ''
|
730
|
-
html = '<div class="dc-form">'
|
731
|
-
labels_pos = dc_check_and_default(@form['form']['labels_pos'], 'right', ['top','left','right'])
|
732
|
-
hidden_fields = ''
|
733
|
-
odd_even = nil
|
734
|
-
group_option, group_count = 0, 0
|
735
|
-
reset_cycle()
|
736
|
-
# options and fields must be separated before sorting
|
737
|
-
# form_options = fields.select {|field| field.class != Integer }
|
738
|
-
# columns = form_options.try(:[],'columns') || 1
|
739
|
-
# Select form fields and sort them by key
|
740
|
-
form_fields = fields_on_tab.select {|field| field.class == Integer }
|
741
|
-
form_fields.to_a.sort.each do |element|
|
742
|
-
options = element.last
|
743
|
-
session[:form_processing] = "form:fields: #{element.first}=#{options}"
|
744
|
-
# ignore if edit_only singe field is required
|
745
|
-
next if params[:edit_only] and params[:edit_only] != options['name']
|
746
|
-
# hidden_fields. Add them at the end
|
747
|
-
if options['type'] == 'hidden_field'
|
748
|
-
hidden_fields << DrgcmsFormFields::HiddenField.new(self, @record, options).render
|
749
|
-
next
|
750
|
-
end
|
751
|
-
# label
|
752
|
-
text = if options['text']
|
753
|
-
t(options['text'], options['text'])
|
754
|
-
elsif options['name']
|
755
|
-
t_name(options['name'], options['name'].capitalize.gsub('_',' ') )
|
756
|
-
end
|
757
|
-
# help text can be defined in form or in translations starting with helpers. or as helpers.help.collection.field
|
758
|
-
help = if options['help']
|
759
|
-
options['help'].match('helpers.') ? t(options['help']) : options['help']
|
760
|
-
end
|
761
|
-
help ||= t('helpers.help.' + @form['table'] + '.' + options['name'],' ') if options['name']
|
762
|
-
# create field object from class and call its render method
|
763
|
-
klas_string = options['type'].camelize
|
764
|
-
field_html = if DrgcmsFormFields.const_defined?(klas_string) # check if field type is defined
|
765
|
-
klas = DrgcmsFormFields.const_get(klas_string)
|
766
|
-
field = klas.new(self, @record, options).render
|
767
|
-
@js << field.js
|
768
|
-
field.html
|
769
|
-
else # litle error string
|
770
|
-
"Error: Code for field type #{options['type']} not defined!"
|
771
|
-
end
|
772
|
-
# Line separator
|
773
|
-
html << top_bottom_line(options['top-line']) if options['top-line']
|
774
|
-
# Begining of new row
|
775
|
-
if group_count == 0
|
776
|
-
html << '<div class="row-div">'
|
777
|
-
odd_even = cycle('odd','even')
|
778
|
-
group_count = options['group'] || 1
|
779
|
-
group_option = options['group'] || 1
|
780
|
-
end
|
781
|
-
#
|
782
|
-
html << if labels_pos == 'top'
|
783
|
-
%Q[
|
784
|
-
<div class="dc-form-label-top dc-color-#{odd_even} dc-align-left" title="#{help}">
|
785
|
-
<label for="record_#{options['name']}">#{text} </label>
|
786
|
-
<div id="td_record_#{options['name']}">#{field_html}</div>
|
787
|
-
</div> ]
|
788
|
-
else
|
789
|
-
label_width = 14
|
790
|
-
# less place for label when more then 1 field per row
|
791
|
-
label_width = 10 if group_option > 1 and group_option != group_count
|
792
|
-
data_width = (94 - 10*group_option)/group_option
|
793
|
-
%Q[
|
794
|
-
<div class="dc-form-label dc-color-#{odd_even} dc-align-#{labels_pos}" style="width:#{label_width}%;" title="#{help}">
|
795
|
-
<label for="record_#{options['name']}">#{text} </label>
|
796
|
-
</div>
|
797
|
-
<div id="td_record_#{options['name']}" class="dc-form-field dc-color-#{odd_even}" style="width:#{data_width}%;">#{field_html}</div>
|
798
|
-
]
|
799
|
-
end
|
800
|
-
# check if must go to next row
|
801
|
-
group_count -= 1
|
802
|
-
html << '</div>' if group_count == 0
|
803
|
-
html << top_bottom_line(options['bottom-line']) if options['bottom-line']
|
804
|
-
end
|
805
|
-
html << '</div>' << hidden_fields
|
806
|
-
end
|
807
|
-
|
808
|
-
############################################################################
|
809
|
-
# Creates edit form div.
|
810
|
-
############################################################################
|
811
|
-
def dc_fields_for_form()
|
812
|
-
html, tabs, tdata = '',[], ''
|
813
|
-
# Only fields defined
|
814
|
-
if (form_fields = @form['form']['fields'])
|
815
|
-
html << "<div id='data_fields' " + (@form['form']['height'] ? "style=\"height: #{@form['form']['height']}px;\">" : '>')
|
816
|
-
html << dc_fields_for_tab(form_fields) + '</div>'
|
817
|
-
else
|
818
|
-
# there are multiple tabs on form
|
819
|
-
first = true # first tab
|
820
|
-
@form['form']['tabs'].keys.sort.each do |tabname|
|
821
|
-
next if tabname.match('actions')
|
822
|
-
# Tricky. If field name is not on the tab skip to next tab
|
823
|
-
if params[:edit_only]
|
824
|
-
is_on_tab = false
|
825
|
-
@form['form']['tabs'][tabname].each {|k,v| is_on_tab = true if params[:edit_only] == v['name'] }
|
826
|
-
next unless is_on_tab
|
827
|
-
end
|
828
|
-
# first div is displayed all other are hidden
|
829
|
-
tdata << "<div id='data_#{tabname.delete("\s\n")}'"
|
830
|
-
tdata << ' class="div-hidden"' unless first
|
831
|
-
tdata << " style=\"height: #{@form['form']['height']}px;\"" if @form['form']['height']
|
832
|
-
tdata << ">#{dc_fields_for_tab(@form['form']['tabs'][tabname])}</div>"
|
833
|
-
tabs << tabname
|
834
|
-
first = false
|
835
|
-
end
|
836
|
-
# make it all work together
|
837
|
-
html << '<ul class="dc-form-ul" >'
|
838
|
-
first = true # first tab must be selected
|
839
|
-
tabs.each do |tab|
|
840
|
-
html << "<li id='li_#{tab}' data-div='#{tab.delete("\s\n")}' class='dc-form-li #{'dc-form-li-selected' if first }'>#{t_name(tab, tab)}</li>"
|
841
|
-
first = false
|
842
|
-
end
|
843
|
-
html << '</ul>'
|
844
|
-
html << tdata
|
845
|
-
end
|
846
|
-
# add last_updated_at hidden field so controller can check if record was updated in during editing
|
847
|
-
html << hidden_field(nil, :last_updated_at, value: @record.updated_at.to_i) if @record.respond_to?(:updated_at)
|
848
|
-
# add form time stamp to prevent double form submit
|
849
|
-
html << hidden_field(nil, :form_time_stamp, value: Time.now.to_i)
|
850
|
-
html.html_safe
|
851
|
-
end
|
852
|
-
|
853
|
-
############################################################################
|
854
|
-
# Returns username for id. Subroutine of dc_document_statistics
|
855
|
-
############################################################################
|
856
|
-
def _get_user_for(field_name) #:nodoc:
|
857
|
-
if @record[field_name]
|
858
|
-
u = DcUser.find(@record[field_name])
|
859
|
-
return u ? u.name : @record[field_name]
|
860
|
-
end
|
861
|
-
# nil
|
862
|
-
end
|
863
|
-
|
864
|
-
############################################################################
|
865
|
-
# Creates current document statistics div (created_by, created_at, ....) at the bottom of edit form.
|
866
|
-
# + lots of more. At the moment also adds icon for dumping current document as json text.
|
867
|
-
############################################################################
|
868
|
-
def dc_document_statistics
|
869
|
-
return '' if @record.new_record? or dc_dont?(@form['form']['info'])
|
870
|
-
html = %Q[<div id="dc-document-info">#{fa_icon('info-circle lg')}</div> <div id="dc-document-info-popup" class="div-hidden"> ]
|
871
|
-
#
|
872
|
-
u = _get_user_for('created_by')
|
873
|
-
html << %Q[<div><span>#{t('drgcms.created_by', 'Created by')}: </span><span>#{u}</span></div>] if u
|
874
|
-
u = _get_user_for('updated_by')
|
875
|
-
html << %Q[<div><span>#{t('drgcms.updated_by', 'Updated by')}: </span><span>#{u}</span></div>] if u
|
876
|
-
html << %Q[<div><span>#{t('drgcms.created_at', 'Created at')}: </span><span>#{dc_format_value(@record.created_at)}</span></div>] if @record['created_at']
|
877
|
-
html << %Q[<div><span>#{t('drgcms.updated_at', 'Updated at')}: </span><span>#{dc_format_value(@record.updated_at)}</span></div>] if @record['updated_at']
|
878
|
-
# copy to clipboard icon
|
879
|
-
parms = params.clone
|
880
|
-
parms[:controller] = 'dc_common'
|
881
|
-
parms[:action] = 'copy_clipboard'
|
882
|
-
url = url_for(parms.permit!)
|
883
|
-
html << fa_icon('copy 2x', class: 'dc-link-img dc-link-ajax dc-animate',
|
884
|
-
'data-url' => url, 'data-request' => 'get', title: t('drgcms.doc_copy_clipboard') )
|
885
|
-
(html << '</div></div>').html_safe
|
886
|
-
end
|
887
|
-
|
888
|
-
end
|