drg_cms 0.7.0.2 → 0.7.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +63 -18
- data/app/assets/javascripts/drg_cms/jquery.bpopup.js +372 -0
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/javascripts/drg_cms_cms.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +37 -5
- data/app/assets/stylesheets/drg_cms/select-multiple.css +2 -2
- data/app/controllers/cmsedit_controller.rb +22 -24
- data/app/controllers/dc_application_controller.rb +8 -8
- data/app/controllers/dc_common_controller.rb +9 -6
- data/app/controllers/dc_main_controller.rb +0 -1
- data/app/controls/{dc_category_control.rb → dc_gallery_control.rb} +15 -30
- data/app/controls/dc_image_control.rb +180 -0
- data/app/controls/dc_page_control.rb +3 -3
- data/app/controls/dc_poll_result_control.rb +7 -8
- data/app/controls/dc_report.rb +9 -4
- data/app/controls/design_element_settings_control.rb +88 -37
- data/app/forms/all_options.yml +18 -7
- data/app/forms/cms_menu.yml +7 -2
- data/app/forms/dc_gallery.yml +1 -1
- data/app/forms/dc_image.yml +122 -0
- data/app/forms/dc_image_search.yml +72 -0
- data/app/forms/dc_page.yml +11 -8
- data/app/forms/dc_steps_template.yml +2 -1
- data/app/helpers/cms_common_helper.rb +24 -16
- data/app/helpers/cms_edit_helper.rb +26 -33
- data/app/helpers/cms_helper.rb +21 -5
- data/app/helpers/cms_index_helper.rb +53 -38
- data/app/helpers/dc_application_helper.rb +64 -72
- data/app/helpers/dc_image_helper.rb +127 -0
- data/app/models/concerns/dc_policy_rule_concern.rb +1 -1
- data/app/models/concerns/dc_user_concern.rb +12 -4
- data/app/models/dc_category.rb +12 -0
- data/app/models/dc_design.rb +5 -4
- data/app/models/dc_filter.rb +19 -18
- data/app/models/dc_image.rb +237 -0
- data/app/models/dc_internals.rb +5 -9
- data/app/models/dc_policy_role.rb +8 -8
- data/app/models/drgcms_form_fields/drgcms_field.rb +9 -26
- data/app/models/drgcms_form_fields/embedded.rb +11 -8
- data/app/models/drgcms_form_fields/journal_diff.rb +2 -2
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +51 -47
- data/app/models/drgcms_form_fields/select.rb +20 -14
- data/app/models/drgcms_form_fields/text_with_select.rb +5 -9
- data/app/renderers/dc_gallery_renderer.rb +10 -4
- data/app/renderers/dc_page_renderer.rb +7 -7
- data/app/renderers/dc_poll_renderer.rb +13 -12
- data/app/views/cmsedit/_edit_stuff.html.erb +1 -1
- data/app/views/cmsedit/edit.html.erb +1 -1
- data/app/views/cmsedit/index.html.erb +1 -1
- data/app/views/cmsedit/new.html.erb +1 -0
- data/config/locales/drgcms_en.yml +14 -2
- data/config/locales/drgcms_sl.yml +13 -2
- data/config/locales/models_en.yml +33 -0
- data/config/locales/models_sl.yml +44 -1
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +19 -5
- data/lib/generators/convert_to_ar/USAGE +8 -0
- data/lib/generators/convert_to_ar/convert_to_ar_generator.rb +158 -0
- metadata +16 -10
- data/app/assets/javascripts/drg_cms/jquery.bpopup.min.js +0 -7
- data/app/views/layouts/__cmsedit.html.erb +0 -16
@@ -78,15 +78,18 @@ def render
|
|
78
78
|
@html << "<iframe class='iframe_embedded' id='if_#{@yaml['name']}' name='if_#{@yaml['name']}' #{html}></iframe>"
|
79
79
|
unless @record.new_record?
|
80
80
|
url = @parent.url_for(opts)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
attributes = case
|
82
|
+
when @yaml['load'].nil? || @yaml['load'].match('default')
|
83
|
+
"'src', '#{url}'"
|
84
|
+
when @yaml['load'].match('delay')
|
85
|
+
"'data-src-#{@yaml['load']}', '#{url}'"
|
86
|
+
when @yaml['load'].match('always')
|
87
|
+
"{'data-src-#{@yaml['load']}': '#{url}', src: '#{url}'}"
|
88
|
+
end
|
89
|
+
@js << %(
|
87
90
|
$(document).ready( function() {
|
88
|
-
$('#if_#{@yaml['name']}').attr(
|
89
|
-
});
|
91
|
+
$('#if_#{@yaml['name']}').attr(#{attributes});
|
92
|
+
});)
|
90
93
|
end
|
91
94
|
self
|
92
95
|
end
|
@@ -49,8 +49,8 @@ def render
|
|
49
49
|
old_value = v.class == Array ? v[0] : v
|
50
50
|
new_value = v.class == Array ? v[1] : v
|
51
51
|
@html << "<div style='background-color: #eee;'>#{@parent.check_box('select', k)} #{k}</div>
|
52
|
-
<div style='background-color: #fcc;'>-<br>#{old_value}</div>
|
53
|
-
<div style='background-color: #cfc;'>+<br>#{new_value}</div><br>"
|
52
|
+
<div style='background-color: #fcc;'>-<br>#{old_value.to_s.gsub("\n", '<br>')}</div>
|
53
|
+
<div style='background-color: #cfc;'>+<br>#{new_value.to_s.gsub("\n", '<br>')}</div><br>"
|
54
54
|
end
|
55
55
|
@html << '</div>'
|
56
56
|
self
|
@@ -24,12 +24,12 @@ module DrgcmsFormFields
|
|
24
24
|
|
25
25
|
###########################################################################
|
26
26
|
# Implementation of multitext_autocomplete DRG Form field.
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# multitext_autocomplete field is complex data entry field which uses autocomplete
|
29
29
|
# function when selecting multiple values for MongoDB Array field. Array typically holds
|
30
|
-
# id's of selected documents and control typically displays value of the field name
|
30
|
+
# id's of selected documents and control typically displays value of the field name
|
31
31
|
# defined by search options.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# ===Form options:
|
34
34
|
# * +name:+ field name (required)
|
35
35
|
# * +type:+ multitext_autocomplete (required)
|
@@ -40,12 +40,12 @@ module DrgcmsFormFields
|
|
40
40
|
# * collection_name.search_field_name.method_name; When searching is more complex custom search
|
41
41
|
# method may be defined in CollectionName model which will provide result set for search.
|
42
42
|
# * +with_new+ Will add an icon for shortcut to add new document to collection
|
43
|
-
#
|
43
|
+
#
|
44
44
|
# Form example:
|
45
45
|
# 90:
|
46
46
|
# name: kats
|
47
47
|
# type: multitext_autocomplete
|
48
|
-
# search: dc_category.name
|
48
|
+
# search: dc_category.name
|
49
49
|
# with_new: model_name
|
50
50
|
# size: 30
|
51
51
|
###########################################################################
|
@@ -55,10 +55,11 @@ class MultitextAutocomplete < DrgcmsField
|
|
55
55
|
# Returns value for readonly field
|
56
56
|
###########################################################################
|
57
57
|
def ro_standard(table, search)
|
58
|
-
result = ''
|
59
|
-
table = table.classify.constantize
|
60
58
|
return self if @record[@yaml['name']].nil?
|
61
|
-
|
59
|
+
|
60
|
+
result = ''
|
61
|
+
table = table.classify.constantize
|
62
|
+
# when field name and method are defined together
|
62
63
|
search = search.split('.').first if search.match('.')
|
63
64
|
@record[@yaml['name']].each do |element|
|
64
65
|
result << table.find(element)[search] + '<br>'
|
@@ -69,8 +70,8 @@ end
|
|
69
70
|
###########################################################################
|
70
71
|
# Render multitext_autocomplete field html code
|
71
72
|
###########################################################################
|
72
|
-
def render
|
73
|
-
#
|
73
|
+
def render
|
74
|
+
# get field name
|
74
75
|
if @yaml['search'].class == Hash
|
75
76
|
table = @yaml['search']['table']
|
76
77
|
field_name = @yaml['search']['field']
|
@@ -82,27 +83,28 @@ def render
|
|
82
83
|
else # search and table name are separated
|
83
84
|
search = field_name = @yaml['search']
|
84
85
|
end
|
85
|
-
#
|
86
|
+
# get table name
|
86
87
|
if @yaml['table']
|
87
88
|
table = if @yaml['table'].class == String
|
88
|
-
|
89
|
-
# eval(how_to_get_my_table_name)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
@yaml['table']
|
90
|
+
# eval(how_to_get_my_table_name)
|
91
|
+
elsif @yaml['table']['eval']
|
92
|
+
eval @yaml['table']['eval']
|
93
|
+
else
|
94
|
+
Rails.logger.error "Field #{@yaml['name']}: Invalid table parameter!"
|
95
|
+
nil
|
96
|
+
end
|
96
97
|
end
|
97
|
-
|
98
|
-
|
98
|
+
|
99
|
+
if table.blank? || search.blank?
|
100
|
+
@html << 'Table or search field not defined!'
|
99
101
|
return self
|
100
102
|
end
|
101
|
-
|
102
|
-
# TODO check if table exists
|
103
|
+
|
104
|
+
# TODO check if table exists
|
103
105
|
collection = table.classify.constantize
|
104
106
|
unless @record.respond_to?(@yaml['name'])
|
105
|
-
@html << "Invalid field name: #{@yaml['name']}"
|
107
|
+
@html << "Invalid field name: #{@yaml['name']}"
|
106
108
|
return self
|
107
109
|
end
|
108
110
|
# put field to enter search data on form
|
@@ -117,44 +119,44 @@ def render
|
|
117
119
|
# text field for autocomplete
|
118
120
|
@html << '<span class="dc-text-autocomplete">' << @parent.text_field(record, _name, @yaml['html']) << '<span></span></span>'
|
119
121
|
# direct link for adding new documents to collection
|
120
|
-
if @yaml['with_new']
|
121
|
-
@html << ' ' +
|
122
|
+
if @yaml['with_new'] && !@readonly
|
123
|
+
@html << ' ' +
|
122
124
|
@parent.fa_icon('plus-square-o', class: 'in-edit-add', title: t('drgcms.new'),
|
123
|
-
style: "vertical-align: top;", 'data-table' => @yaml['with_new'] )
|
125
|
+
style: "vertical-align: top;", 'data-table' => @yaml['with_new'] )
|
124
126
|
end
|
125
127
|
# div to list active selections
|
126
128
|
@html << "<div id =\"#{record}#{@yaml['name']}\">"
|
127
|
-
# find value for each field inside categories
|
129
|
+
# find value for each field inside categories
|
128
130
|
unless @record[@yaml['name']].nil?
|
129
131
|
@record[@yaml['name']].each do |element|
|
130
|
-
# this is quick and dirty trick. We have model dc_big_table which can be used for retrive
|
131
|
-
# more complicated options
|
132
|
+
# this is quick and dirty trick. We have model dc_big_table which can be used for retrive
|
133
|
+
# more complicated options
|
132
134
|
# TODO retrieve choices from big_table
|
133
135
|
rec = if table == 'dc_big_table'
|
134
136
|
collection.find(@yaml['name'], @parent.session)
|
135
137
|
else
|
136
138
|
collection.find(element)
|
137
139
|
end
|
138
|
-
# Related data is missing. It happends.
|
140
|
+
# Related data is missing. It happends.
|
139
141
|
@html << if rec
|
140
142
|
link = @parent.link_to(@parent.fa_icon('remove_circle', class: 'dc-red'), '#',
|
141
|
-
onclick:
|
143
|
+
onclick: %($('##{rec.id}').hide(); var v = $('##{record}_#{@yaml['name']}_#{rec.id}'); v.val("-" + v.val());return false;))
|
142
144
|
link = @parent.fa_icon('check', class: 'dc-green') if @readonly
|
143
145
|
field = @parent.hidden_field(record, "#{@yaml['name']}_#{rec.id}", value: element)
|
144
|
-
|
146
|
+
%(<div id="#{rec.id}" style="padding:4px;">#{link} #{rec.send(field_name)}<br>#{field}</div>)
|
145
147
|
else
|
146
148
|
'** error **'
|
147
149
|
end
|
148
150
|
end
|
149
151
|
end
|
150
152
|
@html << "</div></div>"
|
151
|
-
# Create text for div to be added when new category is selected
|
153
|
+
# Create text for div to be added when new category is selected
|
152
154
|
link = @parent.link_to(@parent.fa_icon('remove_circle', class: 'dc-red'), '#',
|
153
155
|
onclick: "$('#rec_id').hide(); var v = $('##{record}_#{@yaml['name']}_rec_id'); v.val(\"-\" + v.val());return false;")
|
154
156
|
field = @parent.hidden_field(record, "#{@yaml['name']}_rec_id", value: 'rec_id')
|
155
157
|
one_div = "<div id=\"rec_id\" style=\"padding:4px;\">#{link} rec_search<br>#{field}</div>"
|
156
|
-
|
157
|
-
# JS stuff
|
158
|
+
|
159
|
+
# JS stuff
|
158
160
|
@js << <<EOJS
|
159
161
|
$(document).ready(function() {
|
160
162
|
$("##{record}_#{_name}").autocomplete( {
|
@@ -173,10 +175,12 @@ $(document).ready(function() {
|
|
173
175
|
},
|
174
176
|
change: function (event, ui) {
|
175
177
|
var div = '#{one_div}';
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
178
|
+
if (ui.item != null) {
|
179
|
+
div = div.replace(/rec_id/g, ui.item.id)
|
180
|
+
div = div.replace('rec_search', ui.item.value)
|
181
|
+
$("##{record}#{@yaml['name']}").append(div);
|
182
|
+
$("##{record}_#{_name}").val('');
|
183
|
+
}
|
180
184
|
$("##{record}_#{_name}").focus();
|
181
185
|
},
|
182
186
|
minLength: 2
|
@@ -184,20 +188,20 @@ $(document).ready(function() {
|
|
184
188
|
});
|
185
189
|
EOJS
|
186
190
|
|
187
|
-
self
|
191
|
+
self
|
188
192
|
end
|
189
193
|
|
190
194
|
###########################################################################
|
191
|
-
# Class method for retrieving data from multitext_autocomplete form field.
|
195
|
+
# Class method for retrieving data from multitext_autocomplete form field. Values are sabed
|
196
|
+
# in parameters as name_id => id
|
192
197
|
###########################################################################
|
193
198
|
def self.get_data(params, name)
|
194
199
|
r = []
|
195
|
-
params['record'].each do |k,v|
|
196
|
-
# if it starts with - then it was removed
|
197
|
-
r << BSON::ObjectId.from_string(v) if k.
|
200
|
+
params['record'].each do |k, v|
|
201
|
+
# if it starts with - then it was removed
|
202
|
+
r << BSON::ObjectId.from_string(v) if k.starts_with?("#{name}_") && v[0] != '-'
|
198
203
|
end
|
199
|
-
r.uniq
|
200
|
-
r
|
204
|
+
r.uniq
|
201
205
|
end
|
202
206
|
|
203
207
|
end
|
@@ -80,9 +80,9 @@ class Select < DrgcmsField
|
|
80
80
|
def choices_in_helper(helper = nil)
|
81
81
|
helper ||= "helpers.label.#{@form['table']}.choices4_#{@yaml['name']}"
|
82
82
|
c = t(helper)
|
83
|
-
if c.match(
|
83
|
+
if c.match(/translation missing/i)
|
84
84
|
helper = "choices_for_#{@form['table']}_#{@yaml['name']}"
|
85
|
-
return "Error. #{helper} not defined" if c.match(
|
85
|
+
return "Error. #{helper} not defined" if c.match(/translation missing/i)
|
86
86
|
end
|
87
87
|
c
|
88
88
|
end
|
@@ -95,21 +95,27 @@ def choices_in_eval(e)
|
|
95
95
|
e.strip!
|
96
96
|
if @yaml['depend'].nil?
|
97
97
|
method = e.split(/\ |\(/).first
|
98
|
-
return eval(e) if respond_to?(method) #
|
99
|
-
return eval('@parent.' + e) if @parent.respond_to?(method) # is method defined in
|
98
|
+
return eval(e) if respond_to?(method) # is method defined here
|
99
|
+
return eval('@parent.' + e) if @parent.respond_to?(method) # is method defined in helper methods
|
100
100
|
# eval whatever it is there
|
101
101
|
eval e
|
102
102
|
else
|
103
|
-
# add event listener to depend field
|
104
|
-
|
105
|
-
$(document).ready(function() {
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
# add event listener to depend field(s)
|
104
|
+
depend_value = ''
|
105
|
+
@js << "\n$(document).ready(function() {\n"
|
106
|
+
@yaml['depend'].split(',') do |depend|
|
107
|
+
depend.strip!
|
108
|
+
depend_value << ',' if depend_value.present?
|
109
|
+
# depend field might be virtual field. It's value should be set in params
|
110
|
+
depend_value << (depend[0] == '_' ? @parent.params["p_#{depend}"] : @record[depend]).to_s
|
111
|
+
next if depend == @yaml['name'] # self may be sent, but don't listen to change event
|
112
|
+
|
113
|
+
@js << %(
|
114
|
+
$('#record_#{depend}').change( function(e) { update_select_depend('record_#{@yaml['name']}', '#{@yaml['depend']}', '#{e}');});
|
115
|
+
$('#_record_#{depend}').change( function(e) { update_select_depend('record_#{@yaml['name']}', '#{@yaml['depend']}', '#{e}');});
|
109
116
|
)
|
110
|
-
|
111
|
-
|
112
|
-
|
117
|
+
end
|
118
|
+
@js << + "});\n"
|
113
119
|
e << " '#{depend_value}'"
|
114
120
|
eval e
|
115
121
|
end
|
@@ -132,7 +138,7 @@ def get_choices
|
|
132
138
|
|
133
139
|
choices.chomp.split(',').map { |e| e.match(':') ? e.split(':') : e }
|
134
140
|
rescue Exception => e
|
135
|
-
Rails.logger.
|
141
|
+
Rails.logger.error "\nError in select eval. #{e.message}\n"
|
136
142
|
Rails.logger.debug(e.backtrace.join($/)) if Rails.env.development?
|
137
143
|
['error'] # return empty array when error occures
|
138
144
|
end
|
@@ -65,9 +65,7 @@ class TextWithSelect < Select
|
|
65
65
|
# Render text_with_select field html code
|
66
66
|
###########################################################################
|
67
67
|
def render
|
68
|
-
|
69
|
-
set_initial_value('html','value')
|
70
|
-
|
68
|
+
set_initial_value
|
71
69
|
record = record_text_for(@yaml['name'])
|
72
70
|
@html << @parent.text_field( record, @yaml['name'], @yaml['html'])
|
73
71
|
@yaml['html']['class'] ||= ''
|
@@ -80,13 +78,11 @@ def render
|
|
80
78
|
# javascript to update text field if new value is selected in select field
|
81
79
|
@js =<<EOJS
|
82
80
|
$(document).ready(function() {
|
83
|
-
|
84
|
-
|
85
|
-
$('##{record}_#{@yaml['name']}').val( $(this).val() );
|
81
|
+
$('##{@yaml['name']}_').on("click", function() {
|
82
|
+
$('##{record}_#{@yaml['name']}').val( $(this).val().toString() );
|
86
83
|
$('##{record}_#{@yaml['name']}').trigger("change");
|
87
|
-
|
88
|
-
|
89
|
-
});
|
84
|
+
$('##{record}_#{@yaml['name']}').focus();
|
85
|
+
});
|
90
86
|
});
|
91
87
|
EOJS
|
92
88
|
self
|
@@ -52,14 +52,20 @@ end
|
|
52
52
|
def default
|
53
53
|
can_view, msg = dc_user_can_view(@parent, @page)
|
54
54
|
return msg unless can_view
|
55
|
-
|
55
|
+
|
56
56
|
html = '<div class="picture-gallery"><ul>'
|
57
57
|
DcGallery.where(doc_id: @opts[:doc_id], active: true).order_by(order: 1).each do |picture|
|
58
58
|
html << '<li>'
|
59
|
-
|
59
|
+
if @opts[:edit_mode] > 1
|
60
|
+
html << edit_menu(picture)
|
61
|
+
html << %(
|
62
|
+
<span class="dc-inline-link dc-link-ajax" data-url="/cmsedit/run?control=DcGalleryControl.picture_remove;id=#{picture.id};table=DcGallery"
|
63
|
+
data-confirm="#{t('drgcms.confirm_delete')}" title="#{t('drgcms.delete')}">
|
64
|
+
<i class="mi-o mi-delete"></i>
|
65
|
+
</span>)
|
66
|
+
end
|
60
67
|
html << "#{@parent.link_to(i@parent.mage_tag(picture.thumbnail, title: picture.title), picture.picture)}<li>"
|
61
68
|
end
|
62
|
-
#
|
63
69
|
html << '</ul></div>'
|
64
70
|
end
|
65
71
|
|
@@ -88,7 +94,7 @@ def edit_menu(picture)
|
|
88
94
|
opts[:id] = picture.id
|
89
95
|
opts[:table] = 'dc_gallery'
|
90
96
|
|
91
|
-
'<li>'+dc_link_for_edit(opts)+'</li>'
|
97
|
+
'<li>' + dc_link_for_edit(opts) + '</li>'
|
92
98
|
end
|
93
99
|
|
94
100
|
|
@@ -41,7 +41,7 @@ include CmsCommonHelper
|
|
41
41
|
########################################################################
|
42
42
|
# Object initialization.
|
43
43
|
########################################################################
|
44
|
-
def initialize( parent, opts={} ) #:nodoc:
|
44
|
+
def initialize( parent, opts = {} ) #:nodoc:
|
45
45
|
@parent = parent
|
46
46
|
@opts = opts
|
47
47
|
@page = @parent.page
|
@@ -74,11 +74,11 @@ def iframe
|
|
74
74
|
return '' if @page.if_url.blank?
|
75
75
|
|
76
76
|
html = "\n<iframe"
|
77
|
-
html << " id=\"#{@page.if_id}\""
|
78
|
-
html << " class=\"#{@page.if_class}\""
|
77
|
+
html << " id=\"#{@page.if_id}\"" if @page.if_id.present?
|
78
|
+
html << " class=\"#{@page.if_class}\"" if @page.if_class.present?
|
79
79
|
html << " border=\"#{@page.if_border}\""
|
80
|
-
html << " height=\"#{@page.if_height}\""
|
81
|
-
html << " width=\"#{@page.if_width}\""
|
80
|
+
html << " height=\"#{@page.if_height}\"" if @page.if_height.present?
|
81
|
+
html << " width=\"#{@page.if_width}\"" if @page.if_width.blank?
|
82
82
|
html << " scrolling=\"#{@page.if_scroll}\""
|
83
83
|
# Parameters
|
84
84
|
parameters = @page.if_url.match(/\?/) ? '' : '?'
|
@@ -88,7 +88,7 @@ def iframe
|
|
88
88
|
val = @parent.dc_internal_var(value['object'], value['method'])
|
89
89
|
parameters << "&#{key}=#{val}" if val # only when not nil
|
90
90
|
end
|
91
|
-
url = @page.if_url + (parameters.
|
91
|
+
url = @page.if_url + (parameters.blank? ? '' : parameters)
|
92
92
|
html << "src=\"#{url}\" ></iframe>\n"
|
93
93
|
html
|
94
94
|
end
|
@@ -106,7 +106,7 @@ def default
|
|
106
106
|
html << @page.body
|
107
107
|
# render poll if defined
|
108
108
|
if @page.dc_poll_id
|
109
|
-
@opts.merge!(:
|
109
|
+
@opts.merge!(poll_id: @page.dc_poll_id, return_to: @parent.request.url, method: nil)
|
110
110
|
comment = DcPollRenderer.new(@parent, @opts)
|
111
111
|
html << "<div class='wrap row'>#{comment.render_html}</div>"
|
112
112
|
@css << "\n#{comment.render_css}"
|
@@ -110,7 +110,7 @@ def do_one_item(poll, yaml)
|
|
110
110
|
if !@end_of_data
|
111
111
|
html << (poll.display == 'lr' ? "</div><br>\n" : "</div>\n")
|
112
112
|
# captcha
|
113
|
-
if poll.captcha_type.
|
113
|
+
if poll.captcha_type.present?
|
114
114
|
@opts.merge!(:captcha_type => poll.captcha_type)
|
115
115
|
captcha = DcCaptchaRenderer.new(@parent, @opts)
|
116
116
|
html << captcha.render_html
|
@@ -157,7 +157,7 @@ end
|
|
157
157
|
########################################################################
|
158
158
|
def default
|
159
159
|
# poll_id may be defined in params or opts
|
160
|
-
poll_id = @opts[:poll_id] || @parent.params[:poll_id]
|
160
|
+
poll_id = @opts[:id] || @opts[:poll_id] || @parent.params[:poll_id]
|
161
161
|
return '<br>Poll id is not defined?<br>' if poll_id.nil?
|
162
162
|
|
163
163
|
poll = DcPoll.find(poll_id)
|
@@ -191,18 +191,19 @@ def default
|
|
191
191
|
html << %(<div class="poll-div">\n)
|
192
192
|
# edit link
|
193
193
|
if @opts[:edit_mode] > 1
|
194
|
-
@opts[:editparams].merge!( controller:
|
194
|
+
@opts[:editparams].merge!( controller: :cmsedit, action: :edit, id: poll._id, table: :dc_poll, form_name: :dc_poll )
|
195
195
|
@opts[:editparams].merge!(title: "#{t('drgcms.edit')}: #{poll.name}")
|
196
196
|
@opts[:editparams].delete(:ids) # this is from page, but it gets in a way
|
197
197
|
html << dc_link_for_edit( @opts[:editparams] )
|
198
198
|
end
|
199
199
|
|
200
200
|
html << case
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
201
|
+
when poll.operation == 'poll_submit'
|
202
|
+
@parent.form_tag(action: poll.operation, method: :put, return_to: params[:return_to])
|
203
|
+
when poll.operation == 'link'
|
204
|
+
poll.parameters << "?return_to=#{params[:return_to]}" if params[:return_to]
|
205
|
+
@parent.form_tag( poll.parameters, method: :put)
|
206
|
+
end
|
206
207
|
# header, - on first position will not display title
|
207
208
|
html << %(<div class="poll-title">#{poll.title}</div>) unless poll.title[0] == '-'
|
208
209
|
html << %(<div class="poll-text">#{poll.sub_text}</div>)
|
@@ -212,10 +213,10 @@ def default
|
|
212
213
|
%(<div class="poll-data-div">\n)
|
213
214
|
end
|
214
215
|
# items. Convert each item to yaml
|
215
|
-
@
|
216
|
+
@end_of_data = false
|
216
217
|
if poll.form.to_s.size < 10
|
217
218
|
items = poll.dc_poll_items
|
218
|
-
items.sort! { |a,b| a.order <=> b.order }
|
219
|
+
items.sort! { |a, b| a.order <=> b.order }
|
219
220
|
items.each do |item|
|
220
221
|
next unless item.active # disabled items
|
221
222
|
# convert options to yaml
|
@@ -232,12 +233,12 @@ def default
|
|
232
233
|
html << do_one_item(poll, yaml)
|
233
234
|
end
|
234
235
|
else
|
235
|
-
yaml = YAML.load(poll.form.gsub(' ',' ')) # very annoying. They come with copy&paste ;-)
|
236
|
+
yaml = YAML.load(poll.form.gsub(' ', ' ')) # very annoying. They come with copy&paste ;-)
|
236
237
|
# if entered without numbering yaml is returned as Hash otherwise as Array
|
237
238
|
yaml.each { |i| html << do_one_item(poll, (i.class == Hash ? i : i.last)) } #
|
238
239
|
end
|
239
240
|
# hide some fields usefull as parameters
|
240
|
-
html << @parent.hidden_field_tag('return_to', @opts[:return_to] || @parent.params[:return_to]
|
241
|
+
html << @parent.hidden_field_tag('return_to', @opts[:return_to] || @parent.params[:return_to])
|
241
242
|
html << @parent.hidden_field_tag('return_to_error', @parent.request.url )
|
242
243
|
html << @parent.hidden_field_tag('poll_id', poll_id )
|
243
244
|
html << @parent.hidden_field_tag('page_id', @parent.page.id )
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2012
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -65,7 +65,8 @@ en:
|
|
65
65
|
no_class: Class [%{class}] not defined!
|
66
66
|
no_method: Method (helper) [%{method}] not defined!
|
67
67
|
img_alt_not_present: All images in body must have alternative text entered
|
68
|
-
|
68
|
+
not_valid: Value is not valid!
|
69
|
+
|
69
70
|
toggle_cms: Toggle CMS edit/view mode
|
70
71
|
edit: Edit
|
71
72
|
show: Show
|
@@ -87,6 +88,7 @@ en:
|
|
87
88
|
save: Save
|
88
89
|
save&back: Save & back
|
89
90
|
save&close: Save & close
|
91
|
+
search: Search
|
90
92
|
filter_on: Filter ON
|
91
93
|
filter_off: Filter OFF
|
92
94
|
filter_set: Set filter
|
@@ -141,3 +143,13 @@ en:
|
|
141
143
|
1basic: Basic
|
142
144
|
2index: Index
|
143
145
|
3form: Form
|
146
|
+
|
147
|
+
dc_image:
|
148
|
+
wrong_type: Image type not allowed! Types allowed are (jpg jpeg png gif svg webp).
|
149
|
+
no_file: Original image file not present. Try to upload image file again.
|
150
|
+
invoke: Invoke images manager.
|
151
|
+
search: Search and select image
|
152
|
+
select: Click to select
|
153
|
+
preview: Click to view image
|
154
|
+
available: Available image sizes
|
155
|
+
offset_error: Enter either X or Y offset.
|
@@ -64,7 +64,8 @@ sl:
|
|
64
64
|
img_large: Klik za večjo sliko
|
65
65
|
no_class: Razred (class) [%{class}] ni definiran!
|
66
66
|
no_method: Metoda (helper) [%{method}] ne obstaja!
|
67
|
-
img_alt_not_present: Vse slike v vsebini morajo imeti vpisano nadomestno besedilo
|
67
|
+
img_alt_not_present: Vse slike v vsebini morajo imeti vpisano nadomestno besedilo
|
68
|
+
not_valid: Nedovoljena vrednost!
|
68
69
|
|
69
70
|
toggle_cms: Preklopi med CMS urejanjem in prikazom
|
70
71
|
edit: Urejanje
|
@@ -87,6 +88,7 @@ sl:
|
|
87
88
|
save: Shrani
|
88
89
|
save&back: Shrani in nazaj
|
89
90
|
save&close: Shrani in zapri
|
91
|
+
search: Išči
|
90
92
|
filter_on: Vklopi filter
|
91
93
|
filter_off: Izklopi filter
|
92
94
|
filter_set: Nastavi filter
|
@@ -139,4 +141,13 @@ sl:
|
|
139
141
|
2index: Index
|
140
142
|
3form: Forma
|
141
143
|
|
142
|
-
|
144
|
+
dc_image:
|
145
|
+
wrong_type: Nedovoljena vrsta slike. Dovoljene so vrste (jpg jpeg png gif svg webp).
|
146
|
+
no_file: Nisem našel originalne slike. Predlagam, da sliko ponovno naložite.
|
147
|
+
invoke: Zagon iskalnika slik.
|
148
|
+
search: Poiščite in izberite sliko
|
149
|
+
select: Kliknite za izbiro
|
150
|
+
preview: Kliknite za ogled slike
|
151
|
+
image: Slika
|
152
|
+
available: Velikosti na voljo
|
153
|
+
offset_error: Vpišite samo X ali Y zamik.
|
@@ -570,6 +570,26 @@ en:
|
|
570
570
|
dc_json_lds: Schema sub element
|
571
571
|
active: Active
|
572
572
|
|
573
|
+
dc_image:
|
574
|
+
tabletitle: Images manager
|
575
|
+
|
576
|
+
upload_file: Upload
|
577
|
+
name: File name
|
578
|
+
short: Short description
|
579
|
+
text: Description text
|
580
|
+
keep_original: Keep original
|
581
|
+
size_o: Original dimension
|
582
|
+
size_l: Large dimension
|
583
|
+
size_m: Medium dimension
|
584
|
+
size_s: Small dimension
|
585
|
+
size_ls: Large dimension
|
586
|
+
size_ms: Medium dimension
|
587
|
+
size_ss: Small dimension
|
588
|
+
categories: Categories
|
589
|
+
cats_input: Categories
|
590
|
+
categories_line: Categories
|
591
|
+
created_by: Uploaded by
|
592
|
+
|
573
593
|
# help for forms #####################################################
|
574
594
|
|
575
595
|
help:
|
@@ -973,3 +993,16 @@ en:
|
|
973
993
|
active: Document is active
|
974
994
|
add_schema: Add new schema
|
975
995
|
add_error: Schema element %{schema} already exists!
|
996
|
+
|
997
|
+
dc_image:
|
998
|
+
upload_file: Select file to upload
|
999
|
+
name: Original file name
|
1000
|
+
short: Short image description
|
1001
|
+
text: Longer image description text
|
1002
|
+
keep_original: Keep original image
|
1003
|
+
size_o: Dimension of original image
|
1004
|
+
size_l: Dimension for large image
|
1005
|
+
size_m: Dimension form medium size image
|
1006
|
+
size_s: Dimension for small size image
|
1007
|
+
categories: Categories for later searching of image
|
1008
|
+
created_by: Image was uploaded by
|