drg_cms 0.5.52.3 → 0.5.52.5
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 +20 -13
- data/app/assets/stylesheets/drg_cms/drg_cms.css +37 -7
- data/app/controllers/cmsedit_controller.rb +8 -4
- data/app/controllers/dc_application_controller.rb +10 -8
- data/app/controllers/dc_page_control.rb +3 -3
- data/app/forms/all_options.yml +4 -3
- data/app/forms/dc_journal.yml +13 -10
- data/app/helpers/cmsedit_helper.rb +36 -37
- data/app/helpers/dc_application_helper.rb +4 -4
- data/app/helpers/dc_part_renderer.rb +2 -2
- data/app/models/drgcms_form_fields.rb +13 -13
- data/config/locales/drgcms_en.yml +2 -1
- data/config/locales/drgcms_sl.yml +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea79cbbc378571608364226320f13d300e1b0f8c
|
4
|
+
data.tar.gz: 77fd5dfe3c330b3d0ae59bc3895bd4cc3283090a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b5519ba85b2a272f51324c4ea23125dbc9efe69065798e853b4a01966c8851b63fd89eea06dc273c11876722fdc04c94202e41146884d6d0032501fc299e36
|
7
|
+
data.tar.gz: 2e9692ebed9d93f8dcebeaeeed060a0bd404b129e08f34e3ba759c32196e103b532e563a6951f8b2c03560f398dc2d5effe870f5075132d2c6defa7570df50fd
|
@@ -170,6 +170,17 @@ function dc_reload_window() {
|
|
170
170
|
location.reload();
|
171
171
|
}
|
172
172
|
|
173
|
+
/*******************************************************************
|
174
|
+
* Will select first editable input field on form. Works only when tab
|
175
|
+
* is selected. Still have to find out, what to do on initial display.
|
176
|
+
*******************************************************************/
|
177
|
+
function select_first_input_field(div_name) {
|
178
|
+
$(div_name + " :input:first").each( function() {
|
179
|
+
this.focus();
|
180
|
+
return true;
|
181
|
+
});
|
182
|
+
}
|
183
|
+
|
173
184
|
/*******************************************************************
|
174
185
|
* Will scroll to position on the screen. This is replacement for
|
175
186
|
* location.hash, which doesn't work in Chrome.
|
@@ -188,6 +199,7 @@ $.fn.dc_scroll_view = function () {
|
|
188
199
|
*
|
189
200
|
*******************************************************************/
|
190
201
|
$(document).ready( function() {
|
202
|
+
|
191
203
|
/*******************************************************************
|
192
204
|
* Register ad clicks
|
193
205
|
*******************************************************************/
|
@@ -246,16 +258,16 @@ $(document).ready( function() {
|
|
246
258
|
if (old_tab_id !== null) {
|
247
259
|
$('#data_' + old_tab_id).toggleClass('div-hidden');
|
248
260
|
$('#data_' + e.target.getAttribute("data-div")).toggleClass('div-hidden');
|
249
|
-
// resize parent iframe
|
250
|
-
var div_height = document.getElementById('data_' + e.target.getAttribute("data-div")).clientHeight +
|
251
|
-
// if (window.frameElement.clientHeight < div_height) {
|
261
|
+
// resize parent iframe to fit selected tab size
|
262
|
+
var div_height = document.getElementById('data_' + e.target.getAttribute("data-div")).clientHeight + 130;
|
252
263
|
window.frameElement.style.height = div_height.toString() + 'px';
|
253
|
-
//
|
264
|
+
// it would be too easy $('#cmsform :input:enabled:visible:first').focus();
|
265
|
+
select_first_input_field('#data_' + e.target.getAttribute("data-div"));
|
254
266
|
}
|
255
267
|
});
|
256
268
|
|
257
269
|
/*******************************************************************
|
258
|
-
* Resize iframe_cms to the size of its contents. Make at least 500 px
|
270
|
+
* Resize iframe_cms to the size of its contents. Make at least 500 px high
|
259
271
|
* unless on initial display.
|
260
272
|
*******************************************************************/
|
261
273
|
$('#iframe_cms').load( function() {
|
@@ -263,7 +275,7 @@ $(document).ready( function() {
|
|
263
275
|
new_height = this.contentWindow.document.body.offsetHeight + 50;
|
264
276
|
if (new_height < 500 & new_height > 60) new_height = 500;
|
265
277
|
this.style.height = new_height + 'px';
|
266
|
-
//
|
278
|
+
// scroll to top
|
267
279
|
$('#iframe_cms').dc_scroll_view();
|
268
280
|
});
|
269
281
|
|
@@ -275,10 +287,9 @@ $(document).ready( function() {
|
|
275
287
|
// console.log(this.contentWindow.document.body.offsetHeight);
|
276
288
|
if (this.contentWindow.document.body.offsetHeight > 10) {
|
277
289
|
this.style.height = (this.contentWindow.document.body.offsetHeight + 30) + 'px';
|
278
|
-
// scroll to
|
290
|
+
// scroll to top
|
279
291
|
$('#iframe_edit').dc_scroll_view();
|
280
292
|
}
|
281
|
-
// remove_background_from_iframe(this.contentWindow.document);
|
282
293
|
});
|
283
294
|
|
284
295
|
/*******************************************************************
|
@@ -286,11 +297,7 @@ $(document).ready( function() {
|
|
286
297
|
*******************************************************************/
|
287
298
|
$('.dc-link-ajax').on('click', function(e) {
|
288
299
|
var target = e.target;
|
289
|
-
|
290
|
-
// target = e.target.parent(); // picture
|
291
|
-
// };
|
292
|
-
// dumpAttributes(target);
|
293
|
-
req = target.getAttribute("data-request");
|
300
|
+
var req = target.getAttribute("data-request");
|
294
301
|
/* Get some values from elements on the page: */
|
295
302
|
if (req == "script") {
|
296
303
|
eval (target.getAttribute("data-script"));
|
@@ -145,6 +145,7 @@ color: #666;
|
|
145
145
|
font-weight: bold;
|
146
146
|
text-decoration: none;
|
147
147
|
background: transparent;
|
148
|
+
padding: 8px 0;
|
148
149
|
}
|
149
150
|
|
150
151
|
.dc-link a:hover, .dc-animate a:hover, .dc-result a:hover {
|
@@ -404,8 +405,8 @@ background: transparent linear-gradient(to bottom, #eee 0%, #eee 100%) repeat sc
|
|
404
405
|
border-bottom:1px solid #ccc;*/
|
405
406
|
}
|
406
407
|
|
407
|
-
.dc-form
|
408
|
-
width:
|
408
|
+
.dc-form {
|
409
|
+
width: 99.8%;
|
409
410
|
padding: 0px;
|
410
411
|
padding-top: 4px;
|
411
412
|
border: 1px solid #ddd;
|
@@ -413,6 +414,11 @@ background: transparent linear-gradient(to bottom, #eee 0%, #eee 100%) repeat sc
|
|
413
414
|
background-color: #fcfcfc;
|
414
415
|
}
|
415
416
|
|
417
|
+
.dc-form .row-div {
|
418
|
+
display: flex;
|
419
|
+
align-items: center;
|
420
|
+
}
|
421
|
+
|
416
422
|
.dc-form-info {
|
417
423
|
padding: 8px;
|
418
424
|
background-image: linear-gradient(to bottom, #dff0d8 0px, #c8e5bc 100%);
|
@@ -479,6 +485,7 @@ background: transparent linear-gradient(to bottom, #eee 0%, #eee 100%) repeat sc
|
|
479
485
|
.dc-form-field {
|
480
486
|
text-align: left;
|
481
487
|
padding: 3px 2px;
|
488
|
+
z-index: 10;
|
482
489
|
/*
|
483
490
|
background-color: #f4f4f4;
|
484
491
|
border-bottom: 1px solid #eee;
|
@@ -486,13 +493,14 @@ background: transparent linear-gradient(to bottom, #eee 0%, #eee 100%) repeat sc
|
|
486
493
|
}
|
487
494
|
|
488
495
|
.dc-readonly {
|
496
|
+
display: inline-block;
|
497
|
+
font-size: 14px;
|
489
498
|
font-weight: normal;
|
499
|
+
color: #222;
|
490
500
|
padding: 6px 3px;
|
491
501
|
border: 2px solid #ddd;
|
492
502
|
background-color: #eee;
|
493
503
|
border-radius: 2px;
|
494
|
-
color: #222;
|
495
|
-
font-size: 14px;
|
496
504
|
}
|
497
505
|
|
498
506
|
.dc-color-odd {
|
@@ -544,7 +552,7 @@ border-bottom: 1px solid #eee;
|
|
544
552
|
}
|
545
553
|
|
546
554
|
.dc-separator {
|
547
|
-
padding:
|
555
|
+
padding: 5px 0;
|
548
556
|
border-top: 2px solid #ddd;
|
549
557
|
}
|
550
558
|
|
@@ -568,7 +576,7 @@ border-radius: 2px;
|
|
568
576
|
font-size: 1.2em;
|
569
577
|
}
|
570
578
|
|
571
|
-
/*******
|
579
|
+
/******* TOP MENU *********/
|
572
580
|
.cmsedit-top {
|
573
581
|
width: 100%;
|
574
582
|
background-color: #fff;
|
@@ -665,6 +673,10 @@ display: none;
|
|
665
673
|
text-align: left;
|
666
674
|
}
|
667
675
|
|
676
|
+
/*** JOURNAL **/
|
677
|
+
.dc-journal {width: 99%; }
|
678
|
+
.dc-journal div { padding: 4px;}
|
679
|
+
|
668
680
|
/****** jquery ui-autocomplete widget ***************/
|
669
681
|
.ui-autocomplete-input {
|
670
682
|
font-style: italic;
|
@@ -691,6 +703,7 @@ color: #000;
|
|
691
703
|
}
|
692
704
|
|
693
705
|
.ui-autocomplete-border {
|
706
|
+
display: inline-block;
|
694
707
|
border-radius: 2px;
|
695
708
|
border: solid 2px #ddd;
|
696
709
|
padding: 8px;
|
@@ -915,6 +928,7 @@ position:absolute;
|
|
915
928
|
background-color: #f8f8f8;
|
916
929
|
border: 1px solid #ddd;
|
917
930
|
border-radius: 2px;
|
931
|
+
z-index: 100;
|
918
932
|
}
|
919
933
|
|
920
934
|
/************************** info popup *************************/
|
@@ -937,4 +951,20 @@ padding: 5px;
|
|
937
951
|
background-color: #fff;
|
938
952
|
padding: 10px;
|
939
953
|
border: 2px solid #ddd;
|
940
|
-
}
|
954
|
+
}
|
955
|
+
|
956
|
+
/****** MOBILE DEVICE *****/
|
957
|
+
@media only screen and (max-width: 600px) {
|
958
|
+
.dc-form .row-div {
|
959
|
+
display: block;
|
960
|
+
}
|
961
|
+
.dc-form-field {
|
962
|
+
width: 100%;
|
963
|
+
}
|
964
|
+
.dc-form-label {
|
965
|
+
text-align: left;
|
966
|
+
width: 100%;
|
967
|
+
padding-bottom: 2px;
|
968
|
+
white-space: nowrap;
|
969
|
+
}
|
970
|
+
}
|
@@ -585,8 +585,9 @@ def read_drg_cms_form
|
|
585
585
|
@ids = ids.split(';').inject([]) { |r,v| r << v }
|
586
586
|
# formname defaults to last table specified
|
587
587
|
dc_deprecate("Parameter :formname will be deprecated in future. Use :form_name instead") if params[:formname]
|
588
|
-
form_name = params[:
|
589
|
-
@form = YAML.load_file( dc_find_form_file(form_name) )
|
588
|
+
form_name = params[:form_name] || @tables.last[1]
|
589
|
+
@form = YAML.load_file( dc_find_form_file(form_name) ) rescue nil
|
590
|
+
return unless @form
|
590
591
|
# when form extends another form file.
|
591
592
|
if @form['extend']
|
592
593
|
form = YAML.load_file( dc_find_form_file(@form['extend']) )
|
@@ -611,7 +612,7 @@ end
|
|
611
612
|
# load DRG form.
|
612
613
|
############################################################################
|
613
614
|
def check_authorization
|
614
|
-
params[:table] ||= params[:
|
615
|
+
params[:table] ||= params[:form_name]
|
615
616
|
# Just show menu
|
616
617
|
# return show if params[:action] == 'show'
|
617
618
|
return login if params[:id].in?(%w(login logout))
|
@@ -622,9 +623,12 @@ def check_authorization
|
|
622
623
|
end
|
623
624
|
|
624
625
|
read_drg_cms_form
|
626
|
+
|
625
627
|
# Permissions can be also defined on form
|
628
|
+
if @form.nil?
|
629
|
+
render plain: t('drgcms.form_error')
|
626
630
|
#TODO So far only can_view is used. Think about if using other permissions has sense
|
627
|
-
|
631
|
+
elsif @form['permissions'].nil? or @form['permissions']['can_view'].nil? or
|
628
632
|
dc_user_has_role(@form['permissions']['can_view'])
|
629
633
|
# Extend class with methods defined in drgcms_controls module. May include embedded forms therefor ; => _
|
630
634
|
controls_string = (@form['controls'] ? @form['controls'] : params[:table].gsub(';','_')) + '_control'
|
@@ -103,12 +103,14 @@ def dc_get_site()
|
|
103
103
|
@site
|
104
104
|
end
|
105
105
|
|
106
|
-
|
107
|
-
#
|
108
|
-
|
109
|
-
#
|
110
|
-
|
111
|
-
|
106
|
+
##########################################################################
|
107
|
+
# Will set page title according to data on dc_page or dc_site
|
108
|
+
#
|
109
|
+
# Sets internal @page_title variable.
|
110
|
+
##########################################################################
|
111
|
+
def set_page_title()
|
112
|
+
@page_title = @page.title.blank? ? "#{@page.subject} - #{@site.page_title}" : @page.title
|
113
|
+
end
|
112
114
|
|
113
115
|
########################################################################
|
114
116
|
# Searches forms path for file_name and returns full file name or nil if not found.
|
@@ -326,7 +328,7 @@ def dc_process_default_request()
|
|
326
328
|
# HOMEPAGE. When no parameters is set
|
327
329
|
params[:path] = @site.homepage_link if params[:id].nil? and params[:path].nil?
|
328
330
|
# some other process request. It shoud fail if not defined
|
329
|
-
return
|
331
|
+
return send(@site.request_processor) unless @site.request_processor.blank?
|
330
332
|
|
331
333
|
# Search for page
|
332
334
|
pageclass = @site.page_table.classify.constantize
|
@@ -365,7 +367,7 @@ def dc_process_default_request()
|
|
365
367
|
# Log only visits from non-editors
|
366
368
|
dc_log_visit()
|
367
369
|
end
|
368
|
-
|
370
|
+
set_page_title()
|
369
371
|
get_design_and_render @design
|
370
372
|
end
|
371
373
|
|
@@ -44,9 +44,9 @@ end
|
|
44
44
|
# Called just after record is saved to DB.
|
45
45
|
######################################################################
|
46
46
|
def dc_after_save()
|
47
|
-
if params[:_record][:_update_menu] == '1'
|
48
|
-
menu_class = dc_get_site.menu_class.classify.constantize
|
49
|
-
|
47
|
+
if params[:_record] and params[:_record][:_update_menu] == '1'
|
48
|
+
# menu_class = dc_get_site.menu_class.classify.constantize
|
49
|
+
dc_get_site.menu_klass.update_menu_item_link(@record)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
data/app/forms/all_options.yml
CHANGED
@@ -121,25 +121,26 @@ form:
|
|
121
121
|
|
122
122
|
tabs:
|
123
123
|
tab1:
|
124
|
-
columns: 3
|
125
124
|
|
126
125
|
10:
|
127
126
|
name: name
|
128
127
|
type: text_field
|
128
|
+
type: text_with_select
|
129
129
|
type: hidden_field
|
130
130
|
type: readonly
|
131
131
|
type: file_select
|
132
|
-
|
133
|
-
colspan: 2
|
132
|
+
|
134
133
|
size: 50 or
|
135
134
|
html:
|
136
135
|
size: 50
|
136
|
+
group: 3
|
137
137
|
40:
|
138
138
|
name: dc_site_id
|
139
139
|
type: select
|
140
140
|
multiple: true || 1
|
141
141
|
eval: "dc_choices4('model','description_field_name','_id',site: :with_nil)"
|
142
142
|
eval: ModelName.choices4_site
|
143
|
+
eval: dc_big_table 'key-name'
|
143
144
|
html:
|
144
145
|
include_blank: true
|
145
146
|
|
data/app/forms/dc_journal.yml
CHANGED
@@ -47,39 +47,42 @@ form:
|
|
47
47
|
5:
|
48
48
|
name: operation
|
49
49
|
type: text_field
|
50
|
+
readonly: yes
|
50
51
|
html:
|
51
52
|
size: 10
|
52
53
|
10:
|
53
54
|
name: time
|
54
55
|
type: datetime_select
|
56
|
+
readonly: yes
|
55
57
|
20:
|
56
58
|
name: site_id
|
57
59
|
type: select
|
58
60
|
eval: DcSite.choices4_site
|
61
|
+
readonly: yes
|
59
62
|
30:
|
60
63
|
name: user_id
|
61
64
|
type: text_autocomplete
|
62
65
|
search: dc_user.name
|
63
|
-
|
64
|
-
|
66
|
+
readonly: yes
|
67
|
+
size: 30
|
65
68
|
40:
|
66
69
|
name: tables
|
67
70
|
type: text_field
|
68
|
-
|
69
|
-
|
71
|
+
readonly: yes
|
72
|
+
size: 50
|
70
73
|
50:
|
71
74
|
name: doc_id
|
72
75
|
type: text_field
|
73
|
-
|
74
|
-
|
76
|
+
readonly: yes
|
77
|
+
size: 25
|
75
78
|
60:
|
76
79
|
name: ids
|
77
80
|
type: text_field
|
78
|
-
|
79
|
-
|
81
|
+
readonly: yes
|
82
|
+
size: 70
|
80
83
|
|
81
84
|
70:
|
82
85
|
name: ip
|
83
86
|
type: text_field
|
84
|
-
|
85
|
-
|
87
|
+
readonly: yes
|
88
|
+
size: 15
|
@@ -74,7 +74,6 @@ EOT
|
|
74
74
|
url['action'] = yaml['action'] || action
|
75
75
|
url['table'] = yaml['table'] if yaml['table']
|
76
76
|
url['form_name'] = yaml['form_name'] if yaml['form_name']
|
77
|
-
url['form_name'] = yaml['formname'] if yaml['formname']
|
78
77
|
end
|
79
78
|
# html link options
|
80
79
|
yhtml = yaml['html'] || {}
|
@@ -254,7 +253,6 @@ def dc_actions_for_result(document)
|
|
254
253
|
parms['action'] = yaml['action'] if yaml['action']
|
255
254
|
parms['table'] = yaml['table'] if yaml['table']
|
256
255
|
parms['form_name'] = yaml['form_name'] if yaml['form_name']
|
257
|
-
parms['form_name'] = yaml['formname'] if yaml['formname']
|
258
256
|
parms['target'] = yaml['target'] if yaml['target']
|
259
257
|
dc_link_or_ajax(yaml, parms)
|
260
258
|
else # error.
|
@@ -313,7 +311,7 @@ def dc_clicks_for_result(document)
|
|
313
311
|
opts[:controller] = yaml['controller'] || 'cmsedit'
|
314
312
|
opts[:action] = yaml['action']
|
315
313
|
opts[:table] = yaml['table']
|
316
|
-
opts[:form_name] = yaml['form_name']
|
314
|
+
opts[:form_name] = yaml['form_name']
|
317
315
|
opts[:method] = yaml['method'] || 'get'
|
318
316
|
opts[:id] = document['id']
|
319
317
|
html << ' data-dblclick=' + url_for(opts)
|
@@ -551,7 +549,7 @@ def dc_actions_for_form()
|
|
551
549
|
parms['controller'] = v['controller']
|
552
550
|
parms['action'] = v['action']
|
553
551
|
parms['table'] = v['table']
|
554
|
-
parms['form_name'] = v['form_name']
|
552
|
+
parms['form_name'] = v['form_name']
|
555
553
|
parms['id'] = @record.id
|
556
554
|
# additional parameters
|
557
555
|
v['params'].each { |k,v| parms[k] = v } if v['params']
|
@@ -630,12 +628,7 @@ end
|
|
630
628
|
# Creates top or bottom horizontal line on form.
|
631
629
|
############################################################################
|
632
630
|
def top_bottom_line(yaml, columns=2)
|
633
|
-
|
634
|
-
clas = yaml['class']
|
635
|
-
style = yaml['style']
|
636
|
-
end
|
637
|
-
clas ||= 'dc-separator'
|
638
|
-
"<tr><td> </td></tr><tr><td colspan=\"#{columns*2}\" class=\"#{clas}\" style=\"#{style}\"></td></tr><tr><td> </td></tr>"
|
631
|
+
'<div class="dc-separator"></div>'
|
639
632
|
end
|
640
633
|
|
641
634
|
############################################################################
|
@@ -643,15 +636,15 @@ end
|
|
643
636
|
############################################################################
|
644
637
|
def dc_fields_for_tab(fields) #:nodoc:
|
645
638
|
@js ||= ''
|
646
|
-
html = '<
|
639
|
+
html = '<div class="dc-form">'
|
647
640
|
labels_pos = dc_check_and_default(@form['form']['labels_pos'], 'right', ['top','left','right'])
|
648
|
-
current_column = 0
|
649
641
|
hidden_fields = ''
|
650
642
|
odd_even = nil
|
643
|
+
group_option, group_count = 0, 0
|
651
644
|
reset_cycle()
|
652
645
|
# options and fields must be separated before sorting
|
653
|
-
form_options = fields.select {|field| field.class != Integer }
|
654
|
-
columns = form_options.try(:[],'columns') || 1
|
646
|
+
# form_options = fields.select {|field| field.class != Integer }
|
647
|
+
# columns = form_options.try(:[],'columns') || 1
|
655
648
|
# Select form fields and sort them by key
|
656
649
|
form_fields = fields.select {|field| field.class == Integer }
|
657
650
|
form_fields.to_a.sort.each do |element|
|
@@ -664,11 +657,6 @@ def dc_fields_for_tab(fields) #:nodoc:
|
|
664
657
|
hidden_fields << DrgcmsFormFields::HiddenField.new(self, @record, options).render
|
665
658
|
next
|
666
659
|
end
|
667
|
-
# initialize when column is 0
|
668
|
-
if current_column == 0
|
669
|
-
odd_even = cycle('odd','even')
|
670
|
-
current_column = columns
|
671
|
-
end
|
672
660
|
# label
|
673
661
|
text = if options['text']
|
674
662
|
t(options['text'], options['text'])
|
@@ -691,28 +679,39 @@ def dc_fields_for_tab(fields) #:nodoc:
|
|
691
679
|
"Error: Code for field type #{options['type']} not defined!"
|
692
680
|
end
|
693
681
|
# Line separator
|
694
|
-
html << top_bottom_line(options['top-line']
|
695
|
-
|
696
|
-
|
682
|
+
html << top_bottom_line(options['top-line']) if options['top-line']
|
683
|
+
# Begining of new row
|
684
|
+
if group_count == 0
|
685
|
+
html << '<div class="row-div">'
|
686
|
+
odd_even = cycle('odd','even')
|
687
|
+
group_count = options['group'] || 1
|
688
|
+
group_option = options['group'] || 1
|
689
|
+
end
|
697
690
|
#
|
698
691
|
html << if labels_pos == 'top'
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
692
|
+
%Q[
|
693
|
+
<div class="dc-form-label-top dc-color-#{odd_even} dc-align-left" title="#{help}">
|
694
|
+
<label for="record_#{options['name']}">#{text} </label>
|
695
|
+
<div id="td_record_#{options['name']}">#{field_html}</div>
|
696
|
+
</div> ]
|
697
|
+
else
|
698
|
+
label_width = 14
|
699
|
+
# less place for label when more then 1 field per row
|
700
|
+
label_width = 10 if group_option > 1 and group_option != group_count
|
701
|
+
data_width = (94 - 10*group_option)/group_option
|
702
|
+
%Q[
|
703
|
+
<div class="dc-form-label dc-color-#{odd_even} dc-align-#{labels_pos}" style="width:#{label_width}%;" title="#{help}">
|
704
|
+
<label for="record_#{options['name']}">#{text} </label>
|
705
|
+
</div>
|
706
|
+
<div id="td_record_#{options['name']}" class="dc-form-field dc-color-#{odd_even}" style="width:#{data_width}%;">#{field_html}</div>
|
707
|
+
]
|
709
708
|
end
|
710
|
-
# check if
|
711
|
-
|
712
|
-
html << '</
|
713
|
-
html << top_bottom_line(options['bottom-line']
|
709
|
+
# check if must go to next row
|
710
|
+
group_count -= 1
|
711
|
+
html << '</div>' if group_count == 0
|
712
|
+
html << top_bottom_line(options['bottom-line']) if options['bottom-line']
|
714
713
|
end
|
715
|
-
html << '</
|
714
|
+
html << '</div>' << hidden_fields
|
716
715
|
end
|
717
716
|
|
718
717
|
############################################################################
|
@@ -481,7 +481,7 @@ def dc_link_for_create(opts)
|
|
481
481
|
title = opts.delete('title') #
|
482
482
|
title = t(title, title) if title
|
483
483
|
target = opts.delete('target') || 'iframe_cms'
|
484
|
-
opts['form_name'] ||= opts['
|
484
|
+
opts['form_name'] ||= opts['table'].to_s.split(';').last
|
485
485
|
opts['action'] = 'new'
|
486
486
|
opts['controller'] ||= 'cmsedit'
|
487
487
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
@@ -511,7 +511,7 @@ def dc_link_for_edit(opts)
|
|
511
511
|
icon = opts.delete('icon') || 'edit lg'
|
512
512
|
opts['controller'] ||= 'cmsedit'
|
513
513
|
opts['action'] ||= 'edit'
|
514
|
-
opts['form_name'] ||= opts['
|
514
|
+
opts['form_name'] ||= opts['table'].to_s.split(';').last
|
515
515
|
js = "$('##{target}').attr('src', '#{_origin.url_for(opts)}'); return false;"
|
516
516
|
dc_link_to(nil, _origin.fa_icon(icon, class: 'dc-inline-link'), '#',
|
517
517
|
{ onclick: js, title: title, alt: 'Edit'})
|
@@ -931,7 +931,7 @@ def dc_choices4_cmsmenu()
|
|
931
931
|
{ controller: value['controller'],
|
932
932
|
action: value['action'],
|
933
933
|
table: value['table'],
|
934
|
-
form_name: value['form_name'] || value['
|
934
|
+
form_name: value['form_name'] || value['table'],
|
935
935
|
target: value['target'] || 'iframe_cms',
|
936
936
|
}
|
937
937
|
"<li>#{dc_link_to(t(value['caption']), value['icon'] || '', opts)}</li>"
|
@@ -1225,7 +1225,7 @@ def dc_iframe_edit(table, opts={})
|
|
1225
1225
|
params[:action] = (params[:oper] and (params[:oper] == 'edit')) ? 'edit' : 'index'
|
1226
1226
|
params[:action] = opts[:action] unless params[:oper]
|
1227
1227
|
params[:table] ||= table
|
1228
|
-
params[:form_name] ||= opts[:form_name] ||
|
1228
|
+
params[:form_name] ||= opts[:form_name] || table
|
1229
1229
|
params[:id] ||= params[:idp] || opts[:id]
|
1230
1230
|
params[:readonly] ||= opts[:readonly]
|
1231
1231
|
params[:path] = nil
|
@@ -126,7 +126,7 @@ end
|
|
126
126
|
# </div>
|
127
127
|
########################################################################
|
128
128
|
def default
|
129
|
-
html =
|
129
|
+
html = "<div class=\"#{@opts[:div_class]}\">"
|
130
130
|
# Load all parts only once per call
|
131
131
|
load_parts if @parent.parts.nil?
|
132
132
|
dc_deprecate 'DcPart: Parameter location will be deprecated! Please use position keyword.' if @opts['location']
|
@@ -145,7 +145,7 @@ def default
|
|
145
145
|
html << render_particle(part[0], @opts)
|
146
146
|
end
|
147
147
|
end
|
148
|
-
html
|
148
|
+
html << "</div>"
|
149
149
|
end
|
150
150
|
|
151
151
|
########################################################################
|
@@ -118,7 +118,7 @@ end
|
|
118
118
|
####################################################################
|
119
119
|
def ro_standard(value=nil)
|
120
120
|
value = @record[@yaml['name']] if value.nil? and @record.respond_to?(@yaml['name'])
|
121
|
-
@html << (value.blank? ? '' : "<
|
121
|
+
@html << (value.blank? ? '' : "<div class='dc-readonly'>#{value}</div>")
|
122
122
|
self
|
123
123
|
end
|
124
124
|
|
@@ -261,7 +261,7 @@ class Readonly < DrgcmsField
|
|
261
261
|
###########################################################################
|
262
262
|
def render
|
263
263
|
@html << @parent.hidden_field('record', @yaml['name']) # retain field as hidden field
|
264
|
-
@html << '<
|
264
|
+
@html << '<div class="dc-readonly">'
|
265
265
|
|
266
266
|
@html << if @yaml['eval']
|
267
267
|
if @yaml['eval'].match('dc_name4_id')
|
@@ -279,7 +279,7 @@ def render
|
|
279
279
|
else
|
280
280
|
@parent.dc_format_value(@record[@yaml['name']],@yaml['format'])
|
281
281
|
end
|
282
|
-
@html << '</
|
282
|
+
@html << '</div>'
|
283
283
|
self
|
284
284
|
end
|
285
285
|
end
|
@@ -384,15 +384,15 @@ class JournalDiff < DrgcmsField
|
|
384
384
|
###########################################################################
|
385
385
|
def render
|
386
386
|
@yaml['name'] = 'old' if @record[@yaml['name']].nil?
|
387
|
-
@html << '<
|
387
|
+
@html << '<div class="dc-journal">'
|
388
388
|
JSON.parse(@record[@yaml['name']]).each do |k,v|
|
389
389
|
old_value = v.class == Array ? v[0] : v
|
390
390
|
new_value = v.class == Array ? v[1] : v
|
391
|
-
@html << "<
|
392
|
-
|
393
|
-
|
391
|
+
@html << "<div style='background-color: #eee;'>#{@parent.check_box('select', k)} #{k}</div>
|
392
|
+
<div style='background-color: #fcc;'>-<br>#{old_value}</div>
|
393
|
+
<div style='background-color: #cfc;'>+<br>#{new_value}</div><br>"
|
394
394
|
end
|
395
|
-
@html << '</
|
395
|
+
@html << '</div>'
|
396
396
|
self
|
397
397
|
end
|
398
398
|
end
|
@@ -485,7 +485,7 @@ def render
|
|
485
485
|
@yaml['html']['value'] = '' # must be. Otherwise it will look into record and return error
|
486
486
|
@yaml['html']['placeholder'] = t('drgcms.search_placeholder')
|
487
487
|
_name = '_' + @yaml['name']
|
488
|
-
@html << '<
|
488
|
+
@html << '<div class="ui-autocomplete-border">'
|
489
489
|
@html << @parent.link_to(@parent.fa_icon('plus-square lg', class: 'dc-animate dc-green'), '#',onclick: 'return false;') # dummy add. But it is usefull.
|
490
490
|
|
491
491
|
record = record_text_for(@yaml['name'])
|
@@ -513,7 +513,7 @@ def render
|
|
513
513
|
end
|
514
514
|
end
|
515
515
|
end
|
516
|
-
@html << "</div></div
|
516
|
+
@html << "</div></div>"
|
517
517
|
# Create text for div to be added when new category is selected
|
518
518
|
link = @parent.link_to(@parent.fa_icon('remove lg', class: 'dc-animate dc-red'), '#',
|
519
519
|
onclick: "$('#rec_id').hide(); var v = $('##{record}_#{@yaml['name']}_rec_id'); v.val(\"-\" + v.val());return false;")
|
@@ -1184,10 +1184,10 @@ def render
|
|
1184
1184
|
elsif @record and @record[@yaml['name']]
|
1185
1185
|
@record[@yaml['name']]
|
1186
1186
|
end
|
1187
|
-
# Found value to be written in field
|
1187
|
+
# Found value to be written in field. If field is not found write out value.
|
1188
1188
|
if value
|
1189
1189
|
record = t.find(value)
|
1190
|
-
value_displayed = record.send(ret_name)
|
1190
|
+
value_displayed = record ? record.send(ret_name) : value
|
1191
1191
|
end
|
1192
1192
|
# return if readonly
|
1193
1193
|
return ro_standard(value_displayed) if @readonly
|
@@ -1264,7 +1264,7 @@ class TextArea < DrgcmsField
|
|
1264
1264
|
###########################################################################
|
1265
1265
|
def ro_standard
|
1266
1266
|
value = @record[@yaml['name']]
|
1267
|
-
@html << "<
|
1267
|
+
@html << "<div class='dc-readonly'>#{value.gsub("\n",'<br>')}</div>" unless value.blank?
|
1268
1268
|
self
|
1269
1269
|
end
|
1270
1270
|
|
data/lib/drg_cms/version.rb
CHANGED
@@ -2,7 +2,7 @@ class NewDrgFormGenerator < Rails::Generators::NamedBase
|
|
2
2
|
|
3
3
|
source_root File.expand_path('../templates', __FILE__)
|
4
4
|
#desc "This generator creates form for model at app/forms"
|
5
|
-
#argument :
|
5
|
+
#argument :form_name, :type => :string, :default => ''
|
6
6
|
class_option :tabs, :type => :boolean, :default => false, :description => "Create form with tabulators"
|
7
7
|
|
8
8
|
###########################################################################
|
@@ -11,12 +11,12 @@ class_option :tabs, :type => :boolean, :default => false, :description => "Creat
|
|
11
11
|
def create_form_file
|
12
12
|
#:TODO: find out how to prevent error when model class is not defined
|
13
13
|
@file_name = file_name
|
14
|
-
|
14
|
+
form_name = file_name #if formname.size == 0
|
15
15
|
@model = file_name.classify.constantize rescue nil
|
16
16
|
return (p "Model #{file_name.classify} not found! Aborting.") if @model.nil?
|
17
17
|
#
|
18
18
|
yml = top_level_options + index_options + result_set_options + form_top_options + form_fields_options + localize_options
|
19
|
-
create_file "app/forms/#{
|
19
|
+
create_file "app/forms/#{form_name}.yml", yml
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -52,7 +52,7 @@ index:
|
|
52
52
|
# controller: controller_name
|
53
53
|
# action: action_name
|
54
54
|
# table: table_name
|
55
|
-
#
|
55
|
+
# form_name: form_name
|
56
56
|
|
57
57
|
EOT
|
58
58
|
end
|
@@ -75,7 +75,7 @@ result_set:
|
|
75
75
|
# controller: controller_name
|
76
76
|
# action: action_name
|
77
77
|
# table: table_name
|
78
|
-
#
|
78
|
+
# form_name: form_name
|
79
79
|
# target: target
|
80
80
|
# method: (get),put,post
|
81
81
|
#
|
@@ -172,7 +172,7 @@ def embedded_form_field(offset)
|
|
172
172
|
yml << ' '*offset + "#{field_index}:\n"
|
173
173
|
yml << ' '*(offset+2) + "name: #{embedded_name}\n"
|
174
174
|
yml << ' '*(offset+2) + "type: embedded\n"
|
175
|
-
yml << ' '*(offset+2) + "
|
175
|
+
yml << ' '*(offset+2) + "form_name: #{embedded_name[0,embedded_name.size - 1]}\n"
|
176
176
|
yml << '#' + ' '*(offset+2) + "html:\n"
|
177
177
|
yml << '#' + ' '*(offset+4) + "height: 500\n"
|
178
178
|
field_index += 10
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drg_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.52.
|
4
|
+
version: 0.5.52.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damjan Rems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|