drg_cms 0.6.1.9 → 0.7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +260 -0
- data/MIT-LICENSE +1 -1
- data/README.md +9 -5
- data/app/assets/javascripts/drg_cms/drg_cms.js +69 -32
- data/app/assets/javascripts/drg_cms_application.js +0 -2
- data/app/assets/javascripts/drg_cms_cms.js +2 -3
- data/app/assets/stylesheets/drg_cms/drg_cms.css +89 -26
- data/app/assets/stylesheets/drg_cms/jstree.css +32 -27
- data/app/assets/stylesheets/drg_cms/select-multiple.css +4 -2
- data/app/controllers/cmsedit_controller.rb +9 -111
- data/app/controllers/dc_application_controller.rb +100 -23
- data/app/controllers/dc_common_controller.rb +10 -24
- data/app/controls/browse_models_control.rb +3 -1
- data/app/controls/cmsedit_control.rb +5 -1
- data/app/controls/dc_category_control.rb +61 -0
- data/app/controls/dc_report.rb +1 -1
- data/app/forms/all_options.yml +2 -0
- data/app/forms/cms_menu.yml +3 -2
- data/app/forms/dc_browse_models.yml +24 -2
- data/app/forms/dc_category.yml +17 -8
- data/app/forms/dc_category_as_tree.yml +31 -0
- data/app/forms/dc_steps_template.yml +51 -0
- data/app/forms/help/dc_category_as_tree.en +4 -0
- data/app/forms/help/dc_category_as_tree.sl +5 -0
- data/app/helpers/cms_common_helper.rb +66 -1
- data/app/helpers/cms_edit_helper.rb +230 -121
- data/app/helpers/cms_helper.rb +74 -17
- data/app/helpers/cms_index_helper.rb +40 -37
- data/app/helpers/dc_application_helper.rb +37 -76
- data/app/helpers/dc_category_helper.rb +129 -0
- data/app/models/dc_category.rb +50 -24
- data/app/models/dc_journal.rb +2 -2
- data/app/models/dc_json_ld.rb +18 -41
- data/app/models/drgcms_form_fields/date_picker.rb +10 -12
- data/app/models/drgcms_form_fields/datetime_picker.rb +10 -11
- data/app/models/drgcms_form_fields/drgcms_field.rb +46 -4
- data/app/models/drgcms_form_fields/readonly.rb +1 -1
- data/app/models/drgcms_form_fields/select.rb +2 -2
- data/app/models/drgcms_form_fields/text_autocomplete.rb +2 -2
- data/app/models/drgcms_form_fields/text_with_select.rb +1 -0
- data/app/models/drgcms_form_fields/tree_select.rb +20 -19
- data/app/renderers/dc_common_renderer.rb +20 -3
- data/app/views/cmsedit/_form.html.erb +19 -12
- data/app/views/cmsedit/edit.html.erb +10 -6
- data/app/views/cmsedit/index.html.erb +5 -3
- data/app/views/cmsedit/new.html.erb +9 -5
- data/app/views/dc_common/_help.html.erb +1 -0
- data/app/views/layouts/content.html.erb +1 -1
- data/config/locales/drgcms_en.yml +7 -0
- data/config/locales/drgcms_sl.yml +7 -0
- data/drg_cms.gemspec +3 -3
- data/lib/drg_cms/version.rb +1 -1
- data/lib/tasks/dc_cleanup.rake +20 -42
- metadata +18 -12
- data/History.log +0 -109
@@ -321,8 +321,9 @@ border-radius: 1px;
|
|
321
321
|
margin: -6px 0 0 16px;
|
322
322
|
}
|
323
323
|
|
324
|
-
.dc-result-submenu ul
|
324
|
+
.dc-result-submenu ul li {
|
325
325
|
text-align: left;
|
326
|
+
padding: 5px;
|
326
327
|
}
|
327
328
|
|
328
329
|
.dc-result-submenu ul li a:link, .dc-result-submenu .dc-link a:link,
|
@@ -330,7 +331,6 @@ border-radius: 1px;
|
|
330
331
|
font-size: 15px;
|
331
332
|
line-height: 18px;
|
332
333
|
font-weight: 500;
|
333
|
-
padding: 5px 10px;
|
334
334
|
color: #666;
|
335
335
|
display: inline-block;
|
336
336
|
width: 100%;
|
@@ -359,9 +359,9 @@ border-radius: 1px;
|
|
359
359
|
|
360
360
|
.dc-link-no i {
|
361
361
|
color: #bbb;
|
362
|
+
vertical-align: top;
|
362
363
|
}
|
363
364
|
|
364
|
-
|
365
365
|
.dc-result-header .dc-check-all {
|
366
366
|
font-size: 18px;
|
367
367
|
padding: 6px 0;
|
@@ -374,6 +374,7 @@ border-radius: 1px;
|
|
374
374
|
.dc-result-data .dc-link, .dc-result-data .dc-link-ajax {
|
375
375
|
background-color: transparent;
|
376
376
|
border: 0;
|
377
|
+
text-align: left;
|
377
378
|
}
|
378
379
|
|
379
380
|
.dc-result-data .dc-link, .dc-result-data .dc-link a, .dc-result-data .dc-link-ajax {
|
@@ -445,6 +446,12 @@ display: inline-table;
|
|
445
446
|
cursor: pointer;
|
446
447
|
filter: none;
|
447
448
|
}
|
449
|
+
.dc-window-open:hover {
|
450
|
+
transition: 0.3s;
|
451
|
+
color: #fff;
|
452
|
+
background: rgba(44, 142, 255, 1);
|
453
|
+
cursor: pointer;
|
454
|
+
}
|
448
455
|
|
449
456
|
.dc-link:hover > i, .dc-link-ajax:hover > i, .dc-submit:hover > i {
|
450
457
|
color: #fff;
|
@@ -622,10 +629,25 @@ display: inline-table;
|
|
622
629
|
|
623
630
|
/***** FORM *****/
|
624
631
|
|
632
|
+
#dc-form-container {
|
633
|
+
display: flex;
|
634
|
+
padding-left: 4px;
|
635
|
+
}
|
636
|
+
|
637
|
+
#dc-form-left {
|
638
|
+
padding: 8px;
|
639
|
+
background-color: rgba(44, 142, 255, 0.15);;
|
640
|
+
display: none;
|
641
|
+
margin-top: 12px;
|
642
|
+
}
|
643
|
+
|
644
|
+
#dc-form-right {
|
645
|
+
flex: 1;
|
646
|
+
}
|
647
|
+
|
625
648
|
.dc-form-frame {
|
626
649
|
margin: 0px;
|
627
650
|
padding: 4px;
|
628
|
-
/*background-color: #f7f7f7;*/
|
629
651
|
}
|
630
652
|
|
631
653
|
.dc-form {
|
@@ -690,11 +712,12 @@ display: inline-table;
|
|
690
712
|
}
|
691
713
|
|
692
714
|
.dc-form-label-top {
|
693
|
-
color: #555;
|
694
715
|
text-align: right;
|
695
716
|
vertical-align: middle;
|
696
|
-
|
697
|
-
|
717
|
+
color: #555;
|
718
|
+
font-weight: 500;
|
719
|
+
line-height: 1.8em;
|
720
|
+
margin-top: 8px;
|
698
721
|
}
|
699
722
|
|
700
723
|
.dc-form-label.dc-color-odd, .dc-form-label.dc-color-even {background-color: transparent;}
|
@@ -816,6 +839,45 @@ display: flex;
|
|
816
839
|
font-weight: normal;
|
817
840
|
}
|
818
841
|
|
842
|
+
#dc-form-left #dc-steps-menu {
|
843
|
+
color: #222;
|
844
|
+
}
|
845
|
+
#dc-form-left #dc-steps-menu h2 {
|
846
|
+
font-size: 1.6em;
|
847
|
+
font-weight: 600;
|
848
|
+
border-bottom: 2px solid #444;
|
849
|
+
margin-bottom: 8px;
|
850
|
+
}
|
851
|
+
|
852
|
+
#dc-form-left #dc-steps-menu li {
|
853
|
+
filter: none;
|
854
|
+
border: none;
|
855
|
+
text-align: left;
|
856
|
+
background-color: transparent;
|
857
|
+
padding: 8px 0;
|
858
|
+
font-size: 1.1em;
|
859
|
+
}
|
860
|
+
|
861
|
+
#dc-form-left #dc-steps-menu li {
|
862
|
+
color: #222;
|
863
|
+
}
|
864
|
+
|
865
|
+
#dc-form-left #dc-steps-menu li.active {
|
866
|
+
color: #000;
|
867
|
+
font-weight: 600;
|
868
|
+
}
|
869
|
+
|
870
|
+
#dc-form-left #dc-steps-menu li.active:before {
|
871
|
+
font-family: MI;
|
872
|
+
content: '\e409';
|
873
|
+
vertical-align: middle;
|
874
|
+
margin-left: -4px;
|
875
|
+
}
|
876
|
+
|
877
|
+
#dc-form-left #dc-steps-menu .dc-link-ajax:hover {
|
878
|
+
color: rgba(44, 142, 255, 1);
|
879
|
+
}
|
880
|
+
|
819
881
|
/*** CMS toggle button */
|
820
882
|
.cms-toggle {
|
821
883
|
z-index: 1000000;
|
@@ -1125,7 +1187,7 @@ color: #000;
|
|
1125
1187
|
}
|
1126
1188
|
.iframe_embedded {
|
1127
1189
|
padding: 4px;
|
1128
|
-
|
1190
|
+
background-color: #fff;
|
1129
1191
|
border-radius: 2px;
|
1130
1192
|
border: 2px solid #666;
|
1131
1193
|
}
|
@@ -1255,8 +1317,9 @@ color: #000;
|
|
1255
1317
|
margin-right: 5px;
|
1256
1318
|
}
|
1257
1319
|
|
1258
|
-
.dc-filter .mi-
|
1320
|
+
.dc-filter .mi-filter_alt_off {
|
1259
1321
|
color: #c43;
|
1322
|
+
font-size: 20px;
|
1260
1323
|
}
|
1261
1324
|
.dc-filter i:hover {
|
1262
1325
|
color: rgba(44, 142, 255, 1);
|
@@ -1266,10 +1329,6 @@ color: #000;
|
|
1266
1329
|
padding-top: 2px;
|
1267
1330
|
}
|
1268
1331
|
|
1269
|
-
.dc-sort:hover > select {
|
1270
|
-
color: rgba(44, 142, 255, 1);
|
1271
|
-
}
|
1272
|
-
|
1273
1332
|
.dc-sort-select {
|
1274
1333
|
width: 18px;
|
1275
1334
|
background: none;
|
@@ -1403,22 +1462,24 @@ color: #000;
|
|
1403
1462
|
|
1404
1463
|
.filter-popup {
|
1405
1464
|
background-color: #fff;
|
1406
|
-
|
1465
|
+
filter: drop-shadow(2px 2px 8px #888);
|
1466
|
+
border-radius: 2px;
|
1407
1467
|
}
|
1408
1468
|
|
1409
1469
|
.filter-popup div {
|
1470
|
+
font-weight: 500;
|
1410
1471
|
padding: 5px 10px;
|
1411
1472
|
text-align: center;
|
1412
|
-
|
1413
|
-
|
1473
|
+
color: rgba(44, 142, 255, 1);
|
1474
|
+
border-bottom: 2px solid rgba(44, 142, 255, 1);
|
1414
1475
|
}
|
1415
1476
|
|
1416
1477
|
.filter-popup li {
|
1417
|
-
padding:
|
1478
|
+
padding: 5px 10px;
|
1418
1479
|
}
|
1419
1480
|
|
1420
1481
|
.filter-popup li:hover {
|
1421
|
-
background-color:
|
1482
|
+
background-color: rgba(44, 142, 255, 1);
|
1422
1483
|
color: #fff;
|
1423
1484
|
cursor: pointer;
|
1424
1485
|
}
|
@@ -1436,14 +1497,15 @@ cursor: pointer;
|
|
1436
1497
|
}
|
1437
1498
|
|
1438
1499
|
#dc-document-info-popup {
|
1439
|
-
text-align: left;
|
1440
|
-
padding: 6px;
|
1441
|
-
font-size: 0.9em;
|
1442
|
-
position:absolute;
|
1443
|
-
background-color: #fff;
|
1444
|
-
border: solid 1px #
|
1445
|
-
border-radius:
|
1446
|
-
z-index: 100;
|
1500
|
+
text-align: left;
|
1501
|
+
padding: 6px;
|
1502
|
+
font-size: 0.9em;
|
1503
|
+
position:absolute;
|
1504
|
+
background-color: #fff;
|
1505
|
+
border: solid 1px #eee;
|
1506
|
+
border-radius: 2px;
|
1507
|
+
z-index: 100;
|
1508
|
+
filter: drop-shadow(0 8px 8px #ccc);
|
1447
1509
|
}
|
1448
1510
|
|
1449
1511
|
#dc-document-info-popup div span:first-child {
|
@@ -1454,6 +1516,7 @@ z-index: 100;
|
|
1454
1516
|
}
|
1455
1517
|
#dc-document-info-popup div span:last-child {font-weight: 600;}
|
1456
1518
|
|
1519
|
+
#dc-document-info-popup i {height: initial;}
|
1457
1520
|
|
1458
1521
|
/************************** filter popup *************************/
|
1459
1522
|
#drgcms_filter {
|
@@ -117,11 +117,9 @@
|
|
117
117
|
.vakata-context,
|
118
118
|
.vakata-context ul {
|
119
119
|
margin: 0;
|
120
|
-
padding: 2px;
|
121
120
|
position: absolute;
|
122
|
-
background: #
|
123
|
-
|
124
|
-
box-shadow: 2px 2px 2px #999999;
|
121
|
+
background: #fff;
|
122
|
+
filter: drop-shadow(1px 1px 6px #ddd);
|
125
123
|
}
|
126
124
|
.vakata-context ul {
|
127
125
|
list-style: none;
|
@@ -140,19 +138,20 @@
|
|
140
138
|
}
|
141
139
|
.vakata-context li > a {
|
142
140
|
display: block;
|
143
|
-
padding:
|
141
|
+
padding: 4px;
|
144
142
|
text-decoration: none;
|
145
143
|
width: auto;
|
146
144
|
color: black;
|
147
145
|
white-space: nowrap;
|
148
|
-
line-height: 2.4em;
|
149
|
-
text-shadow: 1px 1px 0 white;
|
150
146
|
border-radius: 1px;
|
151
147
|
}
|
152
148
|
.vakata-context li > a:hover {
|
153
149
|
position: relative;
|
154
|
-
background-color:
|
155
|
-
|
150
|
+
background-color: rgba(44, 142, 255, 1);
|
151
|
+
color: #fff;
|
152
|
+
}
|
153
|
+
.vakata-context li > a:hover > i {
|
154
|
+
color: #fff;
|
156
155
|
}
|
157
156
|
.vakata-context li > a.vakata-context-parent {
|
158
157
|
background-image: url("data:image/gif;base64,R0lGODlhCwAHAIAAACgoKP///yH5BAEAAAEALAAAAAALAAcAAAIORI4JlrqN1oMSnmmZDQUAOw==");
|
@@ -164,8 +163,6 @@
|
|
164
163
|
}
|
165
164
|
.vakata-context .vakata-context-hover > a {
|
166
165
|
position: relative;
|
167
|
-
background-color: #e8eff7;
|
168
|
-
box-shadow: 0 0 2px #0a6aa1;
|
169
166
|
}
|
170
167
|
.vakata-context .vakata-context-separator > a,
|
171
168
|
.vakata-context .vakata-context-separator > a:hover {
|
@@ -177,7 +174,6 @@
|
|
177
174
|
max-height: 1px;
|
178
175
|
padding: 0;
|
179
176
|
margin: 0 0 0 2.4em;
|
180
|
-
border-left: 1px solid #e0e0e0;
|
181
177
|
text-shadow: 0 0 0 transparent;
|
182
178
|
box-shadow: 0 0 0 transparent;
|
183
179
|
border-radius: 0;
|
@@ -195,25 +191,15 @@
|
|
195
191
|
.vakata-context li > a > i {
|
196
192
|
text-decoration: none;
|
197
193
|
display: inline-block;
|
198
|
-
width: 2.4em;
|
199
|
-
height: 2.4em;
|
200
194
|
background: transparent;
|
201
|
-
|
202
|
-
vertical-align: top;
|
195
|
+
vertical-align: bottom;
|
203
196
|
text-align: center;
|
204
|
-
|
197
|
+
color: rgba(44, 142, 255, 1);
|
205
198
|
}
|
206
199
|
.vakata-context li > a > i:empty {
|
207
|
-
width: 2.4em;
|
208
|
-
line-height: 2.4em;
|
209
200
|
}
|
210
201
|
.vakata-context li > a .vakata-contextmenu-sep {
|
211
202
|
display: inline-block;
|
212
|
-
width: 1px;
|
213
|
-
height: 2.4em;
|
214
|
-
background: white;
|
215
|
-
margin: 0 0.5em 0 0;
|
216
|
-
border-left: 1px solid #e2e3e3;
|
217
203
|
}
|
218
204
|
.vakata-context .vakata-contextmenu-shortcut {
|
219
205
|
font-size: 0.8em;
|
@@ -233,9 +219,7 @@
|
|
233
219
|
background-repeat: no-repeat;
|
234
220
|
}
|
235
221
|
.vakata-context-rtl .vakata-context-separator > a {
|
236
|
-
margin: 0 2.4em 0 0;
|
237
222
|
border-left: 0;
|
238
|
-
border-right: 1px solid #e2e3e3;
|
239
223
|
}
|
240
224
|
.vakata-context-rtl .vakata-context-left ul {
|
241
225
|
right: auto;
|
@@ -954,7 +938,8 @@
|
|
954
938
|
margin-top: -10px;
|
955
939
|
}
|
956
940
|
}
|
957
|
-
|
941
|
+
|
942
|
+
@media (max-width: 600px) {
|
958
943
|
.jstree-default-responsive {
|
959
944
|
/*
|
960
945
|
.jstree-open > .jstree-ocl,
|
@@ -1099,4 +1084,24 @@
|
|
1099
1084
|
margin-left: 0;
|
1100
1085
|
margin-right: 0;
|
1101
1086
|
}
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
/* edit categorise as tree */
|
1090
|
+
#catagories-as-tree {
|
1091
|
+
margin: 8px 4px;
|
1092
|
+
border-top: 2px solid #bbb;
|
1093
|
+
padding: 8px;
|
1094
|
+
background-color: #f8f8f8;
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
#catagories-as-tree .jstree-anchor {
|
1098
|
+
padding: 2px 4px;
|
1099
|
+
font-weight: 400;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
#catagories-as-tree .mi-o {
|
1103
|
+
font-size: 22px;
|
1104
|
+
color: #666;
|
1105
|
+
padding-right: 4px;
|
1106
|
+
vertical-align: top;
|
1102
1107
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
.ms-container{
|
2
|
-
|
2
|
+
width: fit-content;
|
3
|
+
max-width: 600px;
|
3
4
|
}
|
4
5
|
|
5
6
|
.ms-container:after{
|
@@ -62,7 +63,7 @@
|
|
62
63
|
}
|
63
64
|
|
64
65
|
.ms-container .ms-selectable li.ms-elem-selectable{
|
65
|
-
padding:
|
66
|
+
padding: 3px 10px;
|
66
67
|
color: #444;
|
67
68
|
font-size: 14px;
|
68
69
|
}
|
@@ -96,4 +97,5 @@
|
|
96
97
|
.pull-right.ms-elem-selected{
|
97
98
|
float: right;
|
98
99
|
font-size: smaller;
|
100
|
+
padding-left: 4px;
|
99
101
|
}
|
@@ -196,7 +196,7 @@ def new
|
|
196
196
|
end
|
197
197
|
# new_record callback. Set default values for new record
|
198
198
|
if (m = callback_method('new_record') ) then call_callback_method(m) end
|
199
|
-
@
|
199
|
+
@form_params['action'] = 'create'
|
200
200
|
end
|
201
201
|
|
202
202
|
########################################################################
|
@@ -279,8 +279,8 @@ def create
|
|
279
279
|
flash[:info] = t('drgcms.doc_saved')
|
280
280
|
params[:return_to] = 'index' if params[:commit] == t('drgcms.save&back') # save & back
|
281
281
|
return process_return_to(params[:return_to]) if params[:return_to]
|
282
|
-
|
283
|
-
@
|
282
|
+
|
283
|
+
@form_params['id'] = @record.id # must be set, for proper update link
|
284
284
|
params[:id] = @record.id # must be set, for find_record
|
285
285
|
edit
|
286
286
|
else # error
|
@@ -309,7 +309,7 @@ def edit
|
|
309
309
|
# don't do anything if return is false
|
310
310
|
return index if ret.class == FalseClass
|
311
311
|
end
|
312
|
-
@
|
312
|
+
@form_params['action'] = 'update'
|
313
313
|
render action: :edit
|
314
314
|
end
|
315
315
|
|
@@ -331,7 +331,7 @@ def update
|
|
331
331
|
|
332
332
|
if save_data
|
333
333
|
params[:return_to] = 'index' if params[:commit] == t('drgcms.save&back') # save & back
|
334
|
-
@
|
334
|
+
@form_params['action'] = 'update'
|
335
335
|
# Process return_to
|
336
336
|
return process_return_to(params[:return_to]) if params[:return_to]
|
337
337
|
else
|
@@ -422,7 +422,7 @@ def destroy
|
|
422
422
|
|
423
423
|
end
|
424
424
|
|
425
|
-
@
|
425
|
+
@form_params['action'] = 'update'
|
426
426
|
render action: :edit
|
427
427
|
end
|
428
428
|
|
@@ -496,108 +496,6 @@ def user_has_permission?(permission, collection_name)
|
|
496
496
|
true
|
497
497
|
end
|
498
498
|
|
499
|
-
########################################################################
|
500
|
-
# Merges two forms when current form extends other form. Subroutine of read_drg_form.
|
501
|
-
# With a little help of https://www.ruby-forum.com/topic/142809
|
502
|
-
########################################################################
|
503
|
-
def forms_merge(hash1, hash2)
|
504
|
-
target = hash1.dup
|
505
|
-
hash2.keys.each do |key|
|
506
|
-
if hash2[key].is_a? Hash and hash1[key].is_a? Hash
|
507
|
-
target[key] = forms_merge(hash1[key], hash2[key])
|
508
|
-
next
|
509
|
-
end
|
510
|
-
target[key] = hash2[key] == '/' ? nil : hash2[key]
|
511
|
-
end
|
512
|
-
# delete keys with nil value
|
513
|
-
target.delete_if { |k, v| v.nil? }
|
514
|
-
end
|
515
|
-
|
516
|
-
########################################################################
|
517
|
-
# Extends DRGCMS form file. Extended file is processed first and then merged
|
518
|
-
# with code in this form file. Form can extend only single form file.
|
519
|
-
#
|
520
|
-
# [Parameters:]
|
521
|
-
# [extend_option] : Value of @form['extend'] option
|
522
|
-
########################################################################
|
523
|
-
def extend_drg_form(extend_option)
|
524
|
-
form_file_name = dc_find_form_file(extend_option)
|
525
|
-
@form_js << read_js_drg_form(form_file_name)
|
526
|
-
form = YAML.load_file( form_file_name )
|
527
|
-
@form = forms_merge(form, @form)
|
528
|
-
# If combined form contains tabs and fields options, merge fields into tabs
|
529
|
-
if @form['form']['tabs'] && @form['form']['fields']
|
530
|
-
@form['form']['tabs']['fields'] = @form['form']['fields']
|
531
|
-
@form['form']['fields'] = nil
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
########################################################################
|
536
|
-
# Include code from another DRGCMS form file. Included code is merged
|
537
|
-
# with current form file code. Form can include more than one other DRGCMS forms.
|
538
|
-
#
|
539
|
-
# [Parameters:]
|
540
|
-
# [include_option] : Value of @form['include'] option
|
541
|
-
########################################################################
|
542
|
-
def include_drg_form(include_option)
|
543
|
-
includes = include_option.class == Array ? include_option : include_option.split(/\,|\;/)
|
544
|
-
includes.each do |include_file|
|
545
|
-
form_file_name = dc_find_form_file(include_file)
|
546
|
-
@form_js << read_js_drg_form(form_file_name)
|
547
|
-
form = YAML.load_file(form_file_name)
|
548
|
-
@form = forms_merge(@form, form)
|
549
|
-
end
|
550
|
-
end
|
551
|
-
|
552
|
-
########################################################################
|
553
|
-
# Will read data from form_file_name.js if exists.
|
554
|
-
#
|
555
|
-
# [Parameters:]
|
556
|
-
# [form_file_name] : Physical form filename
|
557
|
-
########################################################################
|
558
|
-
def read_js_drg_form(form_file_name)
|
559
|
-
js_form_file_name = form_file_name.sub('.yml','.js')
|
560
|
-
File.read(js_form_file_name) rescue ''
|
561
|
-
end
|
562
|
-
|
563
|
-
########################################################################
|
564
|
-
# Read DRG form into @form object. Subroutine of check_authorization.
|
565
|
-
########################################################################
|
566
|
-
def read_drg_form
|
567
|
-
table_name = decamelize_type(CmsHelper.table_param(params).strip)
|
568
|
-
@tables = table_name.split(';').inject([]) { |r, v| r << [(v.classify.constantize rescue nil), v] }
|
569
|
-
|
570
|
-
# split ids passed when embedded document
|
571
|
-
ids = params[:ids].to_s.strip.downcase
|
572
|
-
@ids = ids.split(';').inject([]) { |r,v| r << v }
|
573
|
-
|
574
|
-
# form_name defaults to last table specified
|
575
|
-
form_name = CmsHelper.form_param(params) || @tables.last[1]
|
576
|
-
@form_js = ''
|
577
|
-
|
578
|
-
# dynamically generated form
|
579
|
-
@form = if CmsHelper.form_param(params) == 'method'
|
580
|
-
dc_eval_class_method(params[:form_method], params)
|
581
|
-
else
|
582
|
-
form_file_name = dc_find_form_file(form_name)
|
583
|
-
@form_js = read_js_drg_form(form_file_name)
|
584
|
-
YAML.load_file(form_file_name)
|
585
|
-
end
|
586
|
-
|
587
|
-
# form includes or extends another form file
|
588
|
-
include_drg_form(@form['include']) if @form['include']
|
589
|
-
extend_drg_form(@form['extend']) if @form['extend']
|
590
|
-
@form['script'] = (@form['script'].blank? ? @form_js : @form['script'] + @form_js)
|
591
|
-
# add readonly key to form if readonly parameter is passed in url
|
592
|
-
@form['readonly'] = 1 if params['readonly'] #and %w(1 yes true).include?(params['readonly'].to_s.downcase.strip)
|
593
|
-
|
594
|
-
# !!!!!! Always use strings for key names since @parms['table'] != @parms[:table]
|
595
|
-
@parms = { 'table' => table_name, 'ids' => params[:ids], 'form_name' => form_name,
|
596
|
-
'return_to' => params['return_to'], 'edit_only' => params['edit_only'],
|
597
|
-
'readonly' => params['readonly']
|
598
|
-
}
|
599
|
-
end
|
600
|
-
|
601
499
|
############################################################################
|
602
500
|
# Load module if available. Try not to mask errors in control module
|
603
501
|
############################################################################
|
@@ -648,8 +546,7 @@ def check_authorization
|
|
648
546
|
(table.size < 3 or !dc_user_can(DcPermission::CAN_VIEW))
|
649
547
|
return render(action: 'error', locals: { error: t('drgcms.not_authorized')} )
|
650
548
|
end
|
651
|
-
|
652
|
-
return render( plain: t('drgcms.form_error') ) if @form.nil?
|
549
|
+
dc_form_read
|
653
550
|
|
654
551
|
# Permissions can be also defined on form
|
655
552
|
#TODO So far only can_view is used. Think about if using other permissions has sense
|
@@ -698,6 +595,7 @@ def update_standards(record = @record)
|
|
698
595
|
# and will be directly visible only to admins
|
699
596
|
record.dc_site_id = dc_get_site.id if record.respond_to?('dc_site_id') && record.dc_site_id.nil?
|
700
597
|
end
|
598
|
+
record.send(:set_history, self) if record.respond_to?(:set_history)
|
701
599
|
end
|
702
600
|
|
703
601
|
########################################################################
|
@@ -739,7 +637,7 @@ def callback_method(key) #:nodoc:
|
|
739
637
|
callback = case
|
740
638
|
when params['data'] && params['data'][data_key] then params['data'][data_key]
|
741
639
|
# dc_ + key method is present then call it automatically
|
742
|
-
when @form
|
640
|
+
when @form.dig('form', key) then @form['form'][key]
|
743
641
|
when respond_to?('dc_' + key) then 'dc_' + key
|
744
642
|
when params[data_key] then params[data_key]
|
745
643
|
else nil
|
@@ -114,27 +114,6 @@ def set_page_title
|
|
114
114
|
dc_add_meta_tag(:name, 'description', @page.meta_description)
|
115
115
|
end
|
116
116
|
|
117
|
-
########################################################################
|
118
|
-
# Searches forms path for file_name and returns full file name or nil if not found.
|
119
|
-
#
|
120
|
-
# @param [String] Form file name. File name can be passed as gem_name.filename. This can
|
121
|
-
# be useful when you are extending form but want to retain same name as original form
|
122
|
-
# For example. You are extending dc_user form from drg_cms gem and want to
|
123
|
-
# retain same dc_user name. This can be done by setting drg_cms.dc_user as extend option.
|
124
|
-
#
|
125
|
-
# @return [String] Form file name including path or nil if not found.
|
126
|
-
########################################################################
|
127
|
-
def dc_find_form_file(form_file)
|
128
|
-
form_path = nil
|
129
|
-
form_path, form_file = form_file.split(/\.|\//) if form_file.match(/\.|\//)
|
130
|
-
|
131
|
-
DrgCms.paths(:forms).reverse.each do |path|
|
132
|
-
f = "#{path}/#{form_file}.yml"
|
133
|
-
return f if File.exist?(f) && (form_path.nil? || path.to_s.match(/\/#{form_path}(-|\/)/i))
|
134
|
-
end
|
135
|
-
raise "Exception: Form file '#{form_file}' not found!"
|
136
|
-
end
|
137
|
-
|
138
117
|
#######################################################################
|
139
118
|
# Will render public/404.html file with some debug code includded.
|
140
119
|
#
|
@@ -445,7 +424,7 @@ end
|
|
445
424
|
# decamelize_type(ModelName) # 'ModelName' => 'model_name'
|
446
425
|
########################################################################
|
447
426
|
def decamelize_type(model_string)
|
448
|
-
model_string ? model_string.underscore : nil
|
427
|
+
model_string ? model_string.to_s.underscore : nil
|
449
428
|
end
|
450
429
|
|
451
430
|
####################################################################
|
@@ -460,7 +439,8 @@ def dc_error_messages_for(document)
|
|
460
439
|
|
461
440
|
msg = ''
|
462
441
|
document.errors.each do |error|
|
463
|
-
label = t("helpers.label.#{decamelize_type(document.class)}.#{error.attribute}"
|
442
|
+
label = t("helpers.label.#{decamelize_type(document.class)}.#{error.attribute}")
|
443
|
+
label = error.attribute if label.match( 'translation missing' )
|
464
444
|
msg << "<li>#{label} : #{error.message}</li>"
|
465
445
|
end
|
466
446
|
|
@@ -833,4 +813,101 @@ def redis
|
|
833
813
|
Rails.cache.redis
|
834
814
|
end
|
835
815
|
|
816
|
+
########################################################################
|
817
|
+
# Extends DRGCMS form file. Extended file is processed first and then merged
|
818
|
+
# with code in this form file. Form can extend only single form file.
|
819
|
+
#
|
820
|
+
# [Parameters:]
|
821
|
+
# [extend_option] : Value of @form['extend'] option
|
822
|
+
########################################################################
|
823
|
+
def dc_form_extend(extend_option)
|
824
|
+
form_file_name = CmsHelper.form_file_find(extend_option)
|
825
|
+
@form_js << read_js_drg_form(form_file_name)
|
826
|
+
form = YAML.load_file( form_file_name )
|
827
|
+
@form = CmsHelper.forms_merge(form, @form)
|
828
|
+
# If combined form contains tabs and fields options, merge fields into tabs
|
829
|
+
if @form['form']['tabs'] && @form['form']['fields']
|
830
|
+
@form['form']['tabs']['fields'] = @form['form']['fields']
|
831
|
+
@form['form']['fields'] = nil
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
########################################################################
|
836
|
+
# Include code from another DRGCMS form file. Included code is merged
|
837
|
+
# with current form file code. Form can include more than one other DRGCMS forms.
|
838
|
+
#
|
839
|
+
# [Parameters:]
|
840
|
+
# [include_option] : Value of @form['include'] option
|
841
|
+
########################################################################
|
842
|
+
def dc_form_include(include_option)
|
843
|
+
includes = include_option.class == Array ? include_option : include_option.split(/\,|\;/)
|
844
|
+
includes.each do |include_file|
|
845
|
+
form_file_name = CmsHelper.form_file_find(include_file)
|
846
|
+
@form_js << read_js_drg_form(form_file_name)
|
847
|
+
form = YAML.load_file(form_file_name)
|
848
|
+
@form = CmsHelper.forms_merge(@form, form)
|
849
|
+
end
|
850
|
+
end
|
851
|
+
|
852
|
+
########################################################################
|
853
|
+
# Will read data from form_file_name.js if exists.
|
854
|
+
#
|
855
|
+
# [Parameters:]
|
856
|
+
# [form_file_name] : Physical form filename
|
857
|
+
########################################################################
|
858
|
+
def read_js_drg_form(form_file_name)
|
859
|
+
js_form_file_name = form_file_name.sub('.yml','.js')
|
860
|
+
File.read(js_form_file_name) rescue ''
|
861
|
+
end
|
862
|
+
|
863
|
+
########################################################################
|
864
|
+
# Read DRG form into @form object. Subroutine of check_authorization.
|
865
|
+
########################################################################
|
866
|
+
def dc_form_read
|
867
|
+
params[:table] ||= params[:t] || CmsHelper.form_param(params)
|
868
|
+
table_name = decamelize_type(CmsHelper.table_param(params).strip)
|
869
|
+
@tables = table_name.split(';').inject([]) { |r, v| r << [(v.classify.constantize rescue nil), v] }
|
870
|
+
|
871
|
+
# split ids passed when embedded document
|
872
|
+
ids = params[:ids].to_s.strip.downcase
|
873
|
+
@ids = ids.split(';').inject([]) { |r,v| r << v }
|
874
|
+
|
875
|
+
# form_name defaults to last table specified
|
876
|
+
form_name = CmsHelper.form_param(params) || @tables.last[1]
|
877
|
+
@form_js = ''
|
878
|
+
|
879
|
+
# dynamically generated form
|
880
|
+
@form = if CmsHelper.form_param(params) == 'method'
|
881
|
+
dc_eval_class_method(params[:form_method], params)
|
882
|
+
else
|
883
|
+
form_file_name = CmsHelper.form_file_find(form_name)
|
884
|
+
@form_js = read_js_drg_form(form_file_name)
|
885
|
+
YAML.load_file(form_file_name)
|
886
|
+
end
|
887
|
+
|
888
|
+
# form includes or extends another form file
|
889
|
+
dc_form_include(@form['include']) if @form['include']
|
890
|
+
dc_form_extend(@form['extend']) if @form['extend']
|
891
|
+
@form['script'] = (@form['script'].blank? ? @form_js : @form['script'] + @form_js)
|
892
|
+
# add readonly key to form if readonly parameter is passed in url
|
893
|
+
@form['readonly'] = 1 if params['readonly'] #and %w(1 yes true).include?(params['readonly'].to_s.downcase.strip)
|
894
|
+
|
895
|
+
# !!!!!! Always use strings for key names since @form_params['table'] != @form_params[:table]
|
896
|
+
@form_params = { 'table' => table_name, 'ids' => params[:ids], 'form_name' => form_name,
|
897
|
+
'return_to' => params['return_to'], 'edit_only' => params['edit_only'],
|
898
|
+
'readonly' => params['readonly'], 'window_close' => params['window_close']}
|
899
|
+
end
|
900
|
+
|
901
|
+
########################################################################
|
902
|
+
# Will search for help file and return it's full path name if found.
|
903
|
+
########################################################################
|
904
|
+
def self.find_help_file(help_file_name)
|
905
|
+
file_name = nil
|
906
|
+
DrgCms.paths(:forms).reverse.each do |path|
|
907
|
+
f = "#{path}/help/#{help_file_name}.#{I18n.locale}"
|
908
|
+
file_name = f and break if File.exist?(f)
|
909
|
+
end
|
910
|
+
file_name
|
911
|
+
end
|
912
|
+
|
836
913
|
end
|