drg_cms 0.4.61 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +10 -14
- data/app/assets/stylesheets/drg_cms/drg_cms.css +19 -17
- data/app/controllers/cmsedit_controller.rb +7 -13
- data/app/controllers/dc_application_controller.rb +48 -0
- data/app/controllers/dc_common_controller.rb +1 -1
- data/app/forms/all_options.yml +5 -1
- data/app/forms/dc_category.yml +0 -2
- data/app/forms/dc_design.yml +3 -3
- data/app/helpers/cmsedit_helper.rb +10 -42
- data/app/helpers/dc_application_helper.rb +100 -57
- data/app/models/drgcms_form_fields.rb +385 -49
- data/config/locales/drgcms_en.yml +1 -0
- data/config/locales/drgcms_sl.yml +1 -0
- data/drg_cms.gemspec +2 -3
- data/lib/drg_cms/version.rb +1 -1
- metadata +5 -5
- data/app/models/drgcms_form_field.rb +0 -1027
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0544d2cf8584b8b6081d9303dc5eafed7c61f2
|
4
|
+
data.tar.gz: 03ff0ee749f6ec797edd6b185fc7775fe56df7e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f38a5123df485097ea0838d1d8c44fe22ead095961b6d5ee6f8f5d0f0a41ab42c6bc9227cd620231a77a454b1c895b71ff38df0a8cb204b4d252b81e5ae358
|
7
|
+
data.tar.gz: 4d4a60ea1524ed9feecfe25f1c1fc86dee7c8a43c077ad9846de6143355a763351c2f6ca156b6c8551725166867f66bfb3e03af8a42305b916878f8b5314c738
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# DrgCms
|
2
2
|
|
3
|
-
DRG CMS is content management system build on strong foundations of Ruby on Rails and Mongo DB. It uses single (cmsedit) controller
|
3
|
+
DRG CMS is content management system build on strong foundations of Ruby on Rails and Mongo DB. It uses single (cmsedit) controller together with specialy crafted forms system for data entry. It has built-in user friendly role based access system and it can be easly extended with help of Ruby on Rails plugin system.
|
4
4
|
|
5
|
-
DRG CMS can be used for rapid building of complex, data-entry intensive web sites
|
5
|
+
DRG CMS can be used for rapid building of complex, data-entry intensive web sites as well as building your private Intranet applications.
|
6
6
|
|
7
7
|
Project Tracking
|
8
8
|
----------------
|
@@ -12,7 +12,7 @@ Project Tracking
|
|
12
12
|
Compatibility
|
13
13
|
-------------
|
14
14
|
|
15
|
-
DRG CMS is tested against Ruby 1.9.3, 2.0, 2.1 and 2.2, MongoDB 2.4
|
15
|
+
DRG CMS is tested against Ruby 1.9.3, 2.0, 2.1 and 2.2, MongoDB 2.4 and 2.6
|
16
16
|
|
17
17
|
Documentation
|
18
18
|
-------------
|
@@ -47,4 +47,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
47
47
|
Credits
|
48
48
|
-------
|
49
49
|
|
50
|
-
Damjan Rems: damjan dot rems at gmail dot com
|
50
|
+
Damjan Rems: damjan dot rems at gmail dot com
|
@@ -80,7 +80,7 @@ $(function() {
|
|
80
80
|
*
|
81
81
|
* #div_divname : will replace divname with value
|
82
82
|
* #div+_divname : will append value to divname
|
83
|
-
* #+div_divname : will prepend value to divname
|
83
|
+
* #+div_divname : will prepend value to divname
|
84
84
|
* .div_classname : will replace all accurencess of classname with value
|
85
85
|
* .+div_classname : will prepend value to all accurencess of classname
|
86
86
|
* .div+_classname : will append value to all accurencess of classname
|
@@ -419,8 +419,7 @@ element = $(this).find(':first').attr('id');
|
|
419
419
|
* Popup or hide document information
|
420
420
|
*******************************************************************/
|
421
421
|
$('#dc-document-info').on('click',function(e) {
|
422
|
-
|
423
|
-
popup = $(e.target).next();
|
422
|
+
popup = $('#dc-document-info-popup');
|
424
423
|
popup.toggleClass('div-hidden');
|
425
424
|
if (!popup.hasClass('div-hidden')) {
|
426
425
|
var o = {
|
@@ -434,13 +433,7 @@ element = $(this).find(':first').attr('id');
|
|
434
433
|
* Just hide document information on click.
|
435
434
|
*******************************************************************/
|
436
435
|
$('#dc-document-info-popup').on('click',function(e) {
|
437
|
-
|
438
|
-
if (e.target.id == 'dc-document-info-popup') {
|
439
|
-
$(e.target).toggleClass('div-hidden');
|
440
|
-
// click on text or picture. Hence hide parent
|
441
|
-
} else {
|
442
|
-
$(e.target).parent().toggleClass('div-hidden');
|
443
|
-
}
|
436
|
+
$('#dc-document-info-popup').toggleClass('div-hidden');
|
444
437
|
});
|
445
438
|
|
446
439
|
/*******************************************************************
|
@@ -452,11 +445,13 @@ element = $(this).find(':first').attr('id');
|
|
452
445
|
});
|
453
446
|
|
454
447
|
/*******************************************************************
|
455
|
-
* Force reload of parent page if this div appears
|
448
|
+
* Force reload of parent page if this div appears.
|
449
|
+
*
|
450
|
+
* Just an Idea. Not needed yet.
|
456
451
|
*******************************************************************/
|
457
452
|
$('#div-reload').load( function() {
|
458
|
-
|
459
|
-
location.href = location.href;
|
453
|
+
alert('div-reload 1');
|
454
|
+
// location.href = location.href;
|
460
455
|
});
|
461
456
|
|
462
457
|
$('#div-reload-parent').on('DOMNodeInserted DOMNodeRemoved', function() {
|
@@ -471,7 +466,8 @@ element = $(this).find(':first').attr('id');
|
|
471
466
|
*******************************************************************/
|
472
467
|
$('.dc-result tr').on('dblclick', function(e) {
|
473
468
|
e.preventDefault();
|
474
|
-
|
469
|
+
url = this.getAttribute("data");
|
470
|
+
if (url !== null) { location.href = url; }
|
475
471
|
});
|
476
472
|
|
477
473
|
});
|
@@ -134,52 +134,39 @@ padding: 0px;
|
|
134
134
|
.dc-link {
|
135
135
|
padding: 4px 8px;
|
136
136
|
text-align: center;
|
137
|
-
/* border: 1px solid #eee;*/
|
138
137
|
border-radius: 5px;
|
139
138
|
background-color: #eee;
|
140
|
-
/* background: linear-gradient(#eee 5%, #fff 100%); */
|
141
139
|
}
|
142
140
|
|
143
141
|
.dc-link:hover {
|
144
|
-
/* background: linear-gradient(#fff 5%, #eee 100%); */
|
145
142
|
background-color: #888;
|
146
143
|
}
|
147
144
|
|
148
|
-
.dc-link:hover a {
|
149
|
-
color: #fff;
|
150
|
-
}
|
145
|
+
.dc-link:hover a { color: #fff; }
|
151
146
|
|
152
147
|
.dc-link-ajax {
|
153
148
|
text-align: left;
|
154
149
|
font-weight: bold;
|
155
|
-
/* border:1px solid #eee; */
|
156
150
|
padding: 5px 8px;
|
157
151
|
border-radius: 5px;
|
158
152
|
color: #888;
|
159
153
|
background-color: #eee;
|
160
|
-
/*
|
161
|
-
background: linear-gradient(#eee 5%, #fff 100%); */
|
162
154
|
}
|
163
155
|
|
164
156
|
.dc-link-ajax:hover {
|
165
|
-
/* background: linear-gradient(#fff 5%, #eee 100%); */
|
166
|
-
cursor: pointer;
|
167
157
|
color: #fff;
|
168
158
|
background-color: #888;
|
169
159
|
}
|
170
160
|
|
161
|
+
.dc-link-ajax:hover a { color: #fff; }
|
162
|
+
|
171
163
|
.dc-link-img {
|
172
164
|
padding: 3px;
|
173
165
|
text-align: center;
|
174
166
|
margin: 0px;
|
175
|
-
/*
|
176
|
-
border:1px solid #eee;
|
177
|
-
border-radius: 2px;
|
178
|
-
background: linear-gradient(#eee 5%, #fff 100%); */
|
179
167
|
}
|
180
168
|
|
181
169
|
.dc-link-img:hover {
|
182
|
-
/* background: linear-gradient(#fff 5%, #eee 100%); */
|
183
170
|
background-color: #eee;
|
184
171
|
}
|
185
172
|
|
@@ -195,6 +182,20 @@ background-color: #eee;
|
|
195
182
|
border:1px solid #eee;
|
196
183
|
}
|
197
184
|
|
185
|
+
.dc-inline-link {
|
186
|
+
cursor: pointer;
|
187
|
+
color: #222;
|
188
|
+
padding: 4px;
|
189
|
+
background: #fff;
|
190
|
+
border: 2px solid #222;
|
191
|
+
border-radius: 5px;
|
192
|
+
}
|
193
|
+
|
194
|
+
.dc-inline-link:hover {
|
195
|
+
color: #c43;
|
196
|
+
border: 2px solid #c43;
|
197
|
+
}
|
198
|
+
|
198
199
|
.skip-next {
|
199
200
|
text-align: center;
|
200
201
|
border:1px solid #888;
|
@@ -489,7 +490,7 @@ height: 26px;
|
|
489
490
|
|
490
491
|
.ui-autocomplete-table {
|
491
492
|
padding: 3px;
|
492
|
-
border: solid 1px #
|
493
|
+
border: solid 1px #aaa;
|
493
494
|
border-radius: 2px;
|
494
495
|
background: #fff;
|
495
496
|
/*
|
@@ -524,6 +525,7 @@ position:absolute;
|
|
524
525
|
background-color: #eee;
|
525
526
|
border: 1px solid #ddd;
|
526
527
|
border-radius: 4px;
|
528
|
+
z-index: 100;
|
527
529
|
}
|
528
530
|
|
529
531
|
.drgcms_popmenu_class a:hover {
|
@@ -77,7 +77,7 @@
|
|
77
77
|
########################################################################
|
78
78
|
class CmseditController < DcApplicationController
|
79
79
|
before_action :check_authorization, :except => [:login]
|
80
|
-
before_filter :
|
80
|
+
before_filter :dc_reload_patches if Rails.env.development?
|
81
81
|
|
82
82
|
layout 'cms'
|
83
83
|
|
@@ -127,7 +127,7 @@ def user_filter_options(model) #:nodoc:
|
|
127
127
|
field = '_id' if field == 'id' # must be
|
128
128
|
value = /#{value}/ if oper == 'like' # do regex if operation is like
|
129
129
|
# when field type is ObjectId transform value
|
130
|
-
if model.fields[field].type == BSON::ObjectId
|
130
|
+
if model.fields[field] and model.fields[field].type == BSON::ObjectId
|
131
131
|
value = BSON::ObjectId.from_string(value) rescue nil
|
132
132
|
flash[:error] = t('drgcms.not_id') if value.nil?
|
133
133
|
end
|
@@ -166,7 +166,7 @@ def check_filter_options() #:nodoc:
|
|
166
166
|
field = '_id' if field == 'id' # must be
|
167
167
|
value = /#{value}/ if oper == 'like' # do regex if operation is like
|
168
168
|
# when field type is ObjectId transform value
|
169
|
-
if model.fields[field].type == BSON::ObjectId
|
169
|
+
if model.fields[field] and model.fields[field].type == BSON::ObjectId
|
170
170
|
value = BSON::ObjectId.from_string(value) rescue nil
|
171
171
|
flash[:error] = t('drgcms.not_id') if value.nil?
|
172
172
|
end
|
@@ -202,7 +202,10 @@ def index
|
|
202
202
|
if respond_to?(@form['result_set']['filter'])
|
203
203
|
@records = send @form['result_set']['filter']
|
204
204
|
# something iz wrong. flash[] should have explanation.
|
205
|
-
|
205
|
+
if @records.class == FalseClass
|
206
|
+
@records = []
|
207
|
+
return render(action: :index)
|
208
|
+
end
|
206
209
|
# pagination
|
207
210
|
per_page = (@form['result_set']['per_page'] || 30).to_i
|
208
211
|
@records = @records.page(params[:page]).per(per_page) if per_page > 0
|
@@ -762,13 +765,4 @@ def save_data
|
|
762
765
|
saved
|
763
766
|
end
|
764
767
|
|
765
|
-
########################################################################
|
766
|
-
# Reload patches in development.
|
767
|
-
########################################################################
|
768
|
-
def reload_patches
|
769
|
-
DrgCms.paths(:patches).each do |patches|
|
770
|
-
Dir["#{patches}/**/*.rb"].each { |path| require_dependency path }
|
771
|
-
end
|
772
|
-
end
|
773
|
-
|
774
768
|
end
|
@@ -439,6 +439,42 @@ def dc_render_ajax(opts)
|
|
439
439
|
render inline: result.to_json, formats: 'js'
|
440
440
|
end
|
441
441
|
|
442
|
+
######################################################################
|
443
|
+
# Small helper for rendering ajax return code from controller. When ajax call is
|
444
|
+
# made from DRG CMS form return may be quite complicated. All ajax return combinations
|
445
|
+
# can be found in drg_cms.js file.
|
446
|
+
#
|
447
|
+
# [Parameters:]
|
448
|
+
# [Hash opts] Different options
|
449
|
+
#
|
450
|
+
# [Return:]
|
451
|
+
# String. Formatted to be used on ajax return.
|
452
|
+
#
|
453
|
+
# [Example:]
|
454
|
+
# html_code = '<span>Some text</span>'
|
455
|
+
# dc_render_ajax(div: 'mydiv', prepand: html_code) # Will prepand code to mydiv div
|
456
|
+
# dc_render_ajax(class: 'myclass', append: html_code) # Will append code to all objects with myclass class
|
457
|
+
# dc_render_ajax(operation: 'window', value: "/pdf_file.pdf") # will open pdf file in new window.
|
458
|
+
#
|
459
|
+
######################################################################
|
460
|
+
def dc_render_ajax(opts)
|
461
|
+
result = {}
|
462
|
+
if opts[:div] or opts[:class]
|
463
|
+
selector = opts[:div] ? '#' : '.' # for div . for class
|
464
|
+
key = case
|
465
|
+
when opts[:prepend] then "#{selector}+div"
|
466
|
+
when opts[:append] then "#{selector}div+"
|
467
|
+
else "#{selector}div"
|
468
|
+
end
|
469
|
+
key << "_#{opts[:div]}#{opts[:class]}"
|
470
|
+
else
|
471
|
+
p 'Error: dc_render_ajax. Operation is not set!' if opts[:operation].nil?
|
472
|
+
key = "#{opts[:operation]}_"
|
473
|
+
end
|
474
|
+
result[key] = opts[:value] || opts[:url] || ''
|
475
|
+
render inline: result.to_json, formats: 'js'
|
476
|
+
end
|
477
|
+
|
442
478
|
########################################################################
|
443
479
|
# Find document by parameters. This is how cmsedit finds document based
|
444
480
|
# on url parameters.
|
@@ -467,5 +503,17 @@ def dc_find_document(table, id, ids)
|
|
467
503
|
doc
|
468
504
|
end
|
469
505
|
|
506
|
+
########################################################################
|
507
|
+
# Reload patches in development. Since patching files are not automatically loaded in
|
508
|
+
# development environment thiws litle method automatically reloads all patch files
|
509
|
+
# found in DrgCms.paths(:patches) path array.
|
510
|
+
########################################################################
|
511
|
+
def dc_reload_patches
|
512
|
+
DrgCms.paths(:patches).each do |patches|
|
513
|
+
Dir["#{patches}/**/*.rb"].each { |path| require_dependency path }
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
|
470
518
|
|
471
519
|
end
|
data/app/forms/all_options.yml
CHANGED
@@ -10,7 +10,6 @@ permissions:
|
|
10
10
|
|
11
11
|
index:
|
12
12
|
filter: name, id as text_field
|
13
|
-
|
14
13
|
actions: standard
|
15
14
|
|
16
15
|
actions:
|
@@ -82,7 +81,12 @@ result_set:
|
|
82
81
|
form:
|
83
82
|
edit_title: description
|
84
83
|
height: 600
|
84
|
+
title:
|
85
|
+
edit: Title for edit
|
86
|
+
show: Title for show
|
87
|
+
|
85
88
|
actions: standard
|
89
|
+
actions: none
|
86
90
|
|
87
91
|
actions:
|
88
92
|
5:
|
data/app/forms/dc_category.yml
CHANGED
data/app/forms/dc_design.yml
CHANGED
@@ -48,11 +48,9 @@ def dc_actions_for_index()
|
|
48
48
|
# start div with hidden spinner image
|
49
49
|
html = <<EOT
|
50
50
|
<div id="dc-action-menu">
|
51
|
-
<span id="dc-spinner" class="div-hidden">#{fa_icon('spinner lg spin')}
|
51
|
+
<span id="dc-spinner" class="div-hidden">#{fa_icon('spinner lg spin')}</span>
|
52
52
|
<ul class="dc-action-menu">
|
53
53
|
EOT
|
54
|
-
# #{fa_icon('spinner lg spin', id: 'dc-spinner', class: 'div-hidden')}
|
55
|
-
|
56
54
|
#
|
57
55
|
actions.each do |k,v|
|
58
56
|
session[:form_processing] = "index:actions: #{k}=#{v}"
|
@@ -99,7 +97,8 @@ EOT
|
|
99
97
|
# link_to(caption.html_safe, '#', yhtml )
|
100
98
|
dc_link_to('drgcms.filter','filter', '#', yhtml )
|
101
99
|
when action == 'new' then # new
|
102
|
-
|
100
|
+
caption = yaml['caption'] || 'drgcms.new'
|
101
|
+
dc_link_to(caption,'plus', url, yhtml )
|
103
102
|
when action == 'menu' then # menu
|
104
103
|
caption = t(v['caption'], v['caption'])
|
105
104
|
caption + eval(v['eval'])
|
@@ -218,41 +217,6 @@ def dc_table_title_for_result(result=nil)
|
|
218
217
|
dc_table_title(title, result)
|
219
218
|
end
|
220
219
|
|
221
|
-
############################################################################
|
222
|
-
# Similar to rails submit_tag, but also takes care of link icon, translation, ...
|
223
|
-
############################################################################
|
224
|
-
def dc_submit_tag(caption, icon, parms, rest={})
|
225
|
-
parms['class'] ||= 'dc-submit'
|
226
|
-
if icon
|
227
|
-
icon_image = if icon.match(/\./)
|
228
|
-
image_tag(icon, class: 'dc-animate')
|
229
|
-
else
|
230
|
-
fa_icon(icon)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
html = icon_image || ''
|
234
|
-
html << submit_tag(t(caption, caption), parms)
|
235
|
-
end
|
236
|
-
############################################################################
|
237
|
-
# Similar to rails link_to, but also takes care of link icon, translation, ...
|
238
|
-
############################################################################
|
239
|
-
def dc_link_to(caption, icon, parms, rest={})
|
240
|
-
rest['class'] = rest['class'].to_s + ' dc-animate'
|
241
|
-
if icon
|
242
|
-
icon_image = if icon.match(/\./)
|
243
|
-
image_tag(icon, class: 'dc-link-img dc-animate')
|
244
|
-
else
|
245
|
-
fa_icon(icon)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
#
|
249
|
-
if caption
|
250
|
-
caption = t(caption, caption)
|
251
|
-
icon_image << ' ' if icon_image
|
252
|
-
end
|
253
|
-
link_to("#{icon_image}#{caption}".html_safe, parms, rest)
|
254
|
-
end
|
255
|
-
|
256
220
|
############################################################################
|
257
221
|
# Creates code for link or ajax action type. Subroutine of dc_actions_for_result.
|
258
222
|
############################################################################
|
@@ -336,6 +300,7 @@ def dc_actions_for_result(record)
|
|
336
300
|
parms['id'] = record.id
|
337
301
|
# duplicate string will be added to these fields.
|
338
302
|
parms['dup_fields'] = yaml['dup_fields']
|
303
|
+
parms['action'] = 'create'
|
339
304
|
dc_link_to( nil, 'copy lg', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post )
|
340
305
|
when yaml['type'] == 'delete' then
|
341
306
|
parms['action'] = 'destroy'
|
@@ -485,8 +450,10 @@ def dc_actions_for_form()
|
|
485
450
|
actions = std_actions if actions.nil?
|
486
451
|
# readonly
|
487
452
|
actions = {' 1' => 'back'} if @form['readonly']
|
488
|
-
|
489
|
-
if actions['
|
453
|
+
# Actions are strictly forbidden
|
454
|
+
if @form['form']['actions'] and dc_dont?(@form['form']['actions'])
|
455
|
+
actions = []
|
456
|
+
elsif actions['standard']
|
490
457
|
actions.merge!(std_actions)
|
491
458
|
actions['standard'] = nil
|
492
459
|
end
|
@@ -763,8 +730,9 @@ def dc_document_statistics
|
|
763
730
|
return '' if @record.new_record? or dc_dont?(@form['form']['info'])
|
764
731
|
html = "<div id='dc-document-info'>#{t('drgcms.doc_info')}</div>"
|
765
732
|
# html = "<div id='dc-document-info'>#{fa_icon 'info-circle 2x'}</div>"
|
766
|
-
html
|
733
|
+
html = '<div id="dc-document-info">' + fa_icon('info-circle lg') + '</div>'
|
767
734
|
#
|
735
|
+
html << "<div id='dc-document-info-popup' class='div-hidden'><table>"
|
768
736
|
u = _get_user_for('created_by')
|
769
737
|
html << "<tr><td>#{t('drgcms.created_by', 'Created by')}: </td><td><b>#{u}</td></tr>" if u
|
770
738
|
u = _get_user_for('updated_by')
|