drg_cms 0.5.8.2 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.log +48 -0
- data/README.md +5 -5
- data/app/assets/javascripts/drg_cms/drg_cms.js +13 -6
- data/app/assets/javascripts/drg_cms/jquery.bpopup.min.js +7 -0
- data/app/assets/javascripts/drg_cms_cms.js +2 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +18 -13
- data/app/assets/stylesheets/drg_cms_cms.css +1 -1
- data/app/controllers/cmsedit_controller.rb +27 -17
- data/app/controllers/dc_application_controller.rb +68 -74
- data/app/forms/all_options.yml +17 -0
- data/app/forms/dc_category.yml +5 -5
- data/app/forms/dc_site.yml +21 -43
- data/app/helpers/cmsedit_helper.rb +45 -35
- data/app/helpers/dc_application_helper.rb +0 -50
- data/app/models/dc_dummy.rb +1 -4
- data/app/models/dc_filter.rb +23 -17
- data/app/models/drgcms_form_fields.rb +19 -4
- data/drg_cms.gemspec +3 -3
- data/lib/drg_cms/version.rb +1 -1
- metadata +6 -6
- data/app/assets/javascripts/drg_cms/jquery.the-modal.js +0 -260
- data/app/assets/stylesheets/drg_cms/the-modal.css +0 -33
data/app/forms/all_options.yml
CHANGED
@@ -93,6 +93,8 @@ form:
|
|
93
93
|
title:
|
94
94
|
edit: Title for edit
|
95
95
|
show: Title for show
|
96
|
+
labels_pos: top
|
97
|
+
|
96
98
|
|
97
99
|
actions: standard
|
98
100
|
actions: none
|
@@ -117,11 +119,15 @@ form:
|
|
117
119
|
|
118
120
|
tabs:
|
119
121
|
tab1:
|
122
|
+
columns: 3
|
123
|
+
|
120
124
|
10:
|
121
125
|
name: name
|
122
126
|
type: text_field
|
123
127
|
type: hidden_field
|
124
128
|
type: readonly
|
129
|
+
colspan: 2
|
130
|
+
size: 50 or
|
125
131
|
html:
|
126
132
|
size: 50
|
127
133
|
40:
|
@@ -135,6 +141,8 @@ form:
|
|
135
141
|
40:
|
136
142
|
name: operation
|
137
143
|
type: select
|
144
|
+
bottom-line: 1
|
145
|
+
top-line: 1
|
138
146
|
|
139
147
|
30:
|
140
148
|
name: sub_text
|
@@ -181,3 +189,12 @@ form:
|
|
181
189
|
20:
|
182
190
|
name: odhod
|
183
191
|
type: datetime_picker
|
192
|
+
40:
|
193
|
+
name: customer_id
|
194
|
+
type: text_autocomplete
|
195
|
+
search:
|
196
|
+
table: customer
|
197
|
+
field: custumer_name
|
198
|
+
method: search
|
199
|
+
with_new: customer
|
200
|
+
size: 50
|
data/app/forms/dc_category.yml
CHANGED
@@ -29,26 +29,26 @@ form:
|
|
29
29
|
|
30
30
|
fields:
|
31
31
|
|
32
|
-
|
32
|
+
10:
|
33
33
|
name: name
|
34
34
|
type: text_field
|
35
35
|
html:
|
36
36
|
size: 30
|
37
|
-
|
37
|
+
20:
|
38
38
|
name: description
|
39
39
|
type: text_field
|
40
40
|
html:
|
41
41
|
size: 100
|
42
|
-
|
42
|
+
30:
|
43
43
|
name: ctype
|
44
44
|
type: select
|
45
45
|
|
46
|
-
|
46
|
+
40:
|
47
47
|
name: order
|
48
48
|
type: text_field
|
49
49
|
html:
|
50
50
|
size: 5
|
51
|
-
|
51
|
+
50:
|
52
52
|
name: parent
|
53
53
|
type: select
|
54
54
|
eval: DcCategory.values_for_parent
|
data/app/forms/dc_site.yml
CHANGED
@@ -13,7 +13,6 @@ result_set:
|
|
13
13
|
10:
|
14
14
|
type: duplicate
|
15
15
|
dup_fields: name
|
16
|
-
|
17
16
|
|
18
17
|
columns:
|
19
18
|
1:
|
@@ -32,121 +31,100 @@ form:
|
|
32
31
|
10:
|
33
32
|
name: name
|
34
33
|
type: text_field
|
35
|
-
|
36
|
-
size: 50
|
34
|
+
size: 50
|
37
35
|
|
38
36
|
20:
|
39
37
|
name: description
|
40
38
|
type: text_field
|
41
|
-
|
42
|
-
size: 50
|
39
|
+
size: 50
|
43
40
|
|
44
41
|
30:
|
45
42
|
name: alias_for
|
46
43
|
type: text_field
|
47
|
-
|
48
|
-
size: 50
|
44
|
+
size: 50
|
49
45
|
|
50
46
|
40:
|
51
47
|
name: page_title
|
52
48
|
type: text_field
|
53
|
-
|
54
|
-
size: 50
|
49
|
+
size: 50
|
55
50
|
|
56
51
|
50:
|
57
52
|
name: homepage_link
|
58
53
|
type: text_field
|
59
|
-
|
60
|
-
size: 50
|
54
|
+
size: 50
|
61
55
|
60:
|
62
56
|
name: error_link
|
63
57
|
type: text_field
|
64
|
-
|
65
|
-
size: 50
|
58
|
+
size: 50
|
66
59
|
70:
|
67
60
|
name: files_directory
|
68
61
|
type: text_field
|
69
|
-
|
70
|
-
size: 50
|
62
|
+
size: 50
|
71
63
|
80:
|
72
64
|
name: logo
|
73
65
|
type: file_select
|
74
|
-
|
75
|
-
size: 50
|
66
|
+
size: 50
|
76
67
|
90:
|
77
68
|
name: active
|
78
69
|
type: check_box
|
79
|
-
|
80
|
-
size: 50
|
70
|
+
size: 50
|
81
71
|
|
82
72
|
2parameters:
|
83
73
|
10:
|
84
74
|
name: route_name
|
85
75
|
type: text_field
|
86
|
-
|
87
|
-
size: 20
|
76
|
+
size: 20
|
88
77
|
20:
|
89
78
|
name: document_extension
|
90
79
|
type: text_field
|
91
|
-
|
92
|
-
size: 10
|
80
|
+
size: 10
|
93
81
|
25:
|
94
82
|
name: site_layout
|
95
83
|
type: text_field
|
96
|
-
|
97
|
-
size: 20
|
84
|
+
size: 20
|
98
85
|
30:
|
99
86
|
name: page_table
|
100
87
|
type: text_field
|
101
|
-
|
102
|
-
size: 20
|
88
|
+
size: 20
|
103
89
|
40:
|
104
90
|
name: page_class
|
105
91
|
type: text_field
|
106
|
-
|
107
|
-
size: 20
|
92
|
+
size: 20
|
108
93
|
50:
|
109
94
|
name: menu_class
|
110
95
|
type: text_field
|
111
|
-
|
112
|
-
size: 20
|
96
|
+
size: 20
|
113
97
|
60:
|
114
98
|
name: menu_name
|
115
99
|
type: text_with_select
|
116
100
|
eval: dc_choices4(@record.menu_class,'description','name')
|
117
|
-
|
118
|
-
size: 30
|
101
|
+
size: 30
|
119
102
|
90:
|
120
103
|
name: settings
|
121
104
|
type: text_area
|
122
|
-
|
123
|
-
size: 100x20
|
105
|
+
size: 100x20
|
124
106
|
|
125
107
|
3advanced:
|
126
108
|
10:
|
127
109
|
name: header
|
128
110
|
type: text_area
|
129
|
-
|
130
|
-
size: 100x10
|
111
|
+
size: 100x10
|
131
112
|
|
132
113
|
20:
|
133
114
|
name: css
|
134
115
|
type: text_area
|
135
|
-
|
136
|
-
size: 100x40
|
116
|
+
size: 100x40
|
137
117
|
|
138
118
|
4design:
|
139
119
|
10:
|
140
120
|
name: rails_view
|
141
121
|
type: text_field
|
142
|
-
|
143
|
-
size: 50
|
122
|
+
size: 50
|
144
123
|
|
145
124
|
20:
|
146
125
|
name: design
|
147
126
|
type: text_area
|
148
|
-
|
149
|
-
size: 130x40
|
127
|
+
size: 130x40
|
150
128
|
|
151
129
|
5permissions:
|
152
130
|
|
@@ -93,9 +93,12 @@ EOT
|
|
93
93
|
when action == 'filter' then
|
94
94
|
caption = t('drgcms.filter')
|
95
95
|
caption << ' ' + fa_icon('caret-down lg') + DcFilter.menu_filter(self)
|
96
|
-
# add
|
96
|
+
# add filter OFF link
|
97
97
|
s = session[@form['table']]
|
98
|
-
|
98
|
+
if s and s[:filter]
|
99
|
+
caption << ' ' + dc_link_to(nil,'remove lg', controller: 'cmsedit',
|
100
|
+
filter: 'off', table: @form['table'], title: 'drgcms.filter_off')
|
101
|
+
end
|
99
102
|
caption
|
100
103
|
# new
|
101
104
|
when action == 'new' then
|
@@ -141,8 +144,9 @@ def dc_div_filter()
|
|
141
144
|
url = url_for(:table => @form['table'], filter: :on, filter_input: 1, action: :index, controller: :cmsedit)
|
142
145
|
html =<<EOT
|
143
146
|
<div id="drgcms_filter" class="div-hidden">
|
147
|
+
<h1>#{t('drgcms.filter_set')}</h1>
|
144
148
|
<table class="dc-menu"><td>
|
145
|
-
#{ select(nil, '
|
149
|
+
#{ select(nil, 'filter_field1', options_for_select(choices, field_name), { include_blank: true }) }
|
146
150
|
#{ select(nil, 'filter_oper', options_for_select(choices4_operators, operators_value)) }
|
147
151
|
|
148
152
|
</td>
|
@@ -592,50 +596,57 @@ end
|
|
592
596
|
############################################################################
|
593
597
|
# Creates top or bottom horizontal line on form.
|
594
598
|
############################################################################
|
595
|
-
def top_bottom_line(yaml)
|
599
|
+
def top_bottom_line(yaml, columns=2)
|
596
600
|
if yaml.class == Hash
|
597
601
|
clas = yaml['class']
|
598
602
|
style = yaml['style']
|
599
603
|
end
|
600
604
|
clas ||= 'dc-separator'
|
601
|
-
"<tr><td colspan=\"
|
605
|
+
"<tr><td colspan=\"#{columns*2}\" class=\"#{clas}\" style=\"#{style}\"></td></tr>"
|
602
606
|
end
|
603
607
|
|
604
608
|
############################################################################
|
605
|
-
# Creates input
|
609
|
+
# Creates input fields for one tab. Subroutine of dc_fields_for_form.
|
606
610
|
############################################################################
|
607
611
|
def dc_fields_for_tab(fields) #:nodoc:
|
608
|
-
@js
|
609
|
-
|
610
|
-
html = '<table class="dc-form-table">'
|
612
|
+
@js ||= ''
|
613
|
+
html = '<table class="dc-form-table">'
|
611
614
|
labels_pos = dc_check_and_default(@form['form']['labels_pos'], 'right', ['top','left','right'])
|
615
|
+
current_column = 0
|
616
|
+
hidden_fields = ''
|
617
|
+
odd_even = nil
|
612
618
|
reset_cycle()
|
613
|
-
#
|
614
|
-
fields.
|
619
|
+
# options and fields must be separated before sorting
|
620
|
+
form_options = fields.select {|field| field.class != Fixnum }
|
621
|
+
columns = form_options.try(:[],'columns') || 1
|
622
|
+
# Select form fields and sort them by key
|
623
|
+
form_fields = fields.select {|field| field.class == Fixnum }
|
624
|
+
form_fields.to_a.sort.each do |element|
|
615
625
|
options = element.last
|
616
626
|
session[:form_processing] = "form:fields: #{element.first}=#{options}"
|
617
627
|
# ignore if edit_only singe field is required
|
618
628
|
next if params[:edit_only] and params[:edit_only] != options['name']
|
619
|
-
# hidden_fields.
|
629
|
+
# hidden_fields. Add them at the end
|
620
630
|
if options['type'] == 'hidden_field'
|
621
|
-
|
631
|
+
hidden_fields << DrgcmsFormFields::HiddenField.new(self, @record, options).render
|
622
632
|
next
|
623
633
|
end
|
634
|
+
# initialize when column is 0
|
635
|
+
if current_column == 0
|
636
|
+
odd_even = cycle('odd','even')
|
637
|
+
current_column = columns
|
638
|
+
end
|
624
639
|
# label
|
625
640
|
text = if options['text']
|
626
641
|
t(options['text'], options['text'])
|
627
|
-
else
|
642
|
+
else
|
628
643
|
t_name(options['name'], options['name'].capitalize.gsub('_',' ') )
|
629
644
|
end
|
630
|
-
# options['text'] ||= options['name'].capitalize.gsub('_',' ')
|
631
|
-
# text = options['text'].match('helpers.') ? t(options['text']) : t_name(options['name'], options['text'])
|
632
645
|
# help text can be defined in form or in translations starting with helpers. or as helpers.help.collection.field
|
633
646
|
help = if options['help']
|
634
647
|
options['help'].match('helpers.') ? t(options['help']) : options['help']
|
635
648
|
end
|
636
649
|
help ||= t('helpers.help.' + @form['table'] + '.' + options['name'],' ')
|
637
|
-
odd_even = cycle('odd','even')
|
638
|
-
odd_even = cycle('odd','even') if double_field == 2 # it should be same style as first
|
639
650
|
# create field object from class and call its render method
|
640
651
|
klas_string = options['type'].camelize
|
641
652
|
field_html = if DrgcmsFormFields.const_defined?(klas_string) # check if field type is defined
|
@@ -646,30 +657,29 @@ def dc_fields_for_tab(fields) #:nodoc:
|
|
646
657
|
else # litle error string
|
647
658
|
"Error: Code for field type #{options['type']} not defined!"
|
648
659
|
end
|
649
|
-
#
|
650
|
-
html << top_bottom_line(options['top-line']) if options['top-line']
|
651
|
-
|
652
|
-
|
653
|
-
html << '<tr>' if double_field < 2
|
660
|
+
# Line separator
|
661
|
+
html << top_bottom_line(options['top-line'], columns) if options['top-line']
|
662
|
+
html << '<tr>' if current_column == columns
|
663
|
+
colspan = options['colspan'] || 1
|
654
664
|
#
|
655
|
-
html << if labels_pos == 'top'
|
656
|
-
%Q[<td class="dc-form-label dc-color-#{odd_even} dc-align-left"
|
657
|
-
#{
|
665
|
+
html << if labels_pos == 'top'
|
666
|
+
%Q[<td class="dc-form-label-top dc-color-#{odd_even} dc-align-left"
|
667
|
+
title="#{help}" colspan="#{colspan*2}">
|
658
668
|
<div><label for="record_#{options['name']}">#{text} </label></div>
|
659
|
-
<div id="td_record_#{options['name']}">#{field_html}</div></td>]
|
669
|
+
<div id="td_record_#{options['name']}">#{field_html}</div></td> ]
|
660
670
|
else
|
661
671
|
%Q[<td class="dc-form-label dc-color-#{odd_even} dc-align-#{labels_pos}" title="#{help}">
|
662
672
|
<label for="record_#{options['name']}">#{text} </label></td>
|
663
|
-
<td id
|
664
|
-
|
665
|
-
]
|
673
|
+
<td id="td_record_#{options['name']}" class="dc-form-field dc-color-#{odd_even}"
|
674
|
+
colspan="#{colspan*2 - 1}">#{field_html}
|
675
|
+
</td> ]
|
666
676
|
end
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
html << top_bottom_line(options['bottom-line']) if options['bottom-line']
|
677
|
+
# check if must go to next line
|
678
|
+
current_column -= colspan
|
679
|
+
html << '</tr>' if current_column == 0
|
680
|
+
html << top_bottom_line(options['bottom-line'], columns) if options['bottom-line']
|
671
681
|
end
|
672
|
-
html << '</table
|
682
|
+
html << '</table>' << hidden_fields
|
673
683
|
end
|
674
684
|
|
675
685
|
############################################################################
|
@@ -745,34 +745,6 @@ def forms_merge(hash1, hash2) #:nodoc:
|
|
745
745
|
target.delete_if{ |k,v| v.nil? }
|
746
746
|
end
|
747
747
|
|
748
|
-
##########################################################################
|
749
|
-
# Returns choices for creating collection edit select field on CMS top menu.
|
750
|
-
##########################################################################
|
751
|
-
def dc_choices4_cmsmenu()
|
752
|
-
menus = {}
|
753
|
-
DrgCms.paths(:forms).reverse.each do |path|
|
754
|
-
filename = "#{path}/cms_menu.yml"
|
755
|
-
next unless File.exist?(filename)
|
756
|
-
menu = YAML.load_file(filename) rescue nil # load menu
|
757
|
-
next if menu.nil? or !menu['menu'] # not menu or error
|
758
|
-
menus = forms_merge(menu['menu'], menus) # ignore top level part
|
759
|
-
end
|
760
|
-
#
|
761
|
-
choices = []
|
762
|
-
menus.to_a.sort.each do |one_menu| # sort menus, result is array of sorted hashes
|
763
|
-
menu = one_menu[1] # value is the second (1) element of array
|
764
|
-
next unless menu['caption']
|
765
|
-
choices << ["--- #{ t(menu['caption'], menu['caption']) } ---",'#']
|
766
|
-
menu['items'].to_a.sort.each do |item| # as above. sort items first
|
767
|
-
key, value = item[0], item[1]
|
768
|
-
opts = { controller: value['controller'], action: value['action'] }
|
769
|
-
value['params'].each {|k,v| opts.merge!(k => v) } # add parameters to options
|
770
|
-
choices << [ t(value['caption'], value['caption']), url_for( opts ) ]
|
771
|
-
end
|
772
|
-
end
|
773
|
-
choices
|
774
|
-
end
|
775
|
-
|
776
748
|
##########################################################################
|
777
749
|
# Returns choices for creating collection edit select field on CMS top menu.
|
778
750
|
##########################################################################
|
@@ -1057,28 +1029,6 @@ def dc_big_table(key)
|
|
1057
1029
|
ret
|
1058
1030
|
end
|
1059
1031
|
|
1060
|
-
########################################################################
|
1061
|
-
########################################################################
|
1062
|
-
def iframe_edit1() #:nodoc
|
1063
|
-
# default_table = params[:table] if default_table.nil?
|
1064
|
-
# p params
|
1065
|
-
parms = {}
|
1066
|
-
ret = if params.size > 2 #and default_table # controller, action, path is minimum
|
1067
|
-
parms[:controller] = 'cmsedit'
|
1068
|
-
parms[:action] = params[:oper] ? params[:oper] : 'index'
|
1069
|
-
parms[:table] = params[:table]
|
1070
|
-
parms[:formname] = params[:formname] || params[:table]
|
1071
|
-
parms[:id] = params[:idp]
|
1072
|
-
p '**************', url_for(parms)
|
1073
|
-
"<iframe id='iframe_edit' name='iframe_edit' src='#{url_for parms}'></iframe>"
|
1074
|
-
else
|
1075
|
-
"<iframe id='iframe_edit' name='iframe_edit'></iframe>"
|
1076
|
-
end
|
1077
|
-
#bla
|
1078
|
-
p ret
|
1079
|
-
ret.html_safe
|
1080
|
-
end
|
1081
|
-
|
1082
1032
|
########################################################################
|
1083
1033
|
# Will return html code required for load DRG form into iframe. If parameters
|
1084
1034
|
# are passed to method iframe url will have initial value and thus enabling automatic form
|
data/app/models/dc_dummy.rb
CHANGED
@@ -69,15 +69,13 @@ class DcDummy
|
|
69
69
|
# Respond_to should always return true.
|
70
70
|
########################################################################
|
71
71
|
def respond_to?(m)
|
72
|
-
# p "respond_to #{m}"
|
73
72
|
true
|
74
73
|
end
|
75
74
|
|
76
75
|
########################################################################
|
77
76
|
# Redefine send method. Send is used to assign value by cmsedit controller.
|
78
77
|
########################################################################
|
79
|
-
def send(field,value)
|
80
|
-
# p "send #{field} #{value}"
|
78
|
+
def send(field,value=nil)
|
81
79
|
if field.to_s.match('=')
|
82
80
|
field.chomp!('=')
|
83
81
|
@internals ||= {}
|
@@ -90,7 +88,6 @@ end
|
|
90
88
|
# @internals array or will assign new value to @internals hash if m matches '='.
|
91
89
|
########################################################################
|
92
90
|
def method_missing(m, *args, &block) #:nodoc:
|
93
|
-
# p "#{m},#{args},#{block}"
|
94
91
|
@internals ||= {}
|
95
92
|
m = m.to_s
|
96
93
|
if m.match('=')
|