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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b502e1b45d6003b1da74942284939b4e930bb7c
|
4
|
+
data.tar.gz: 845ee2831d322d102bbba5c81728e0022dae83ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa721bb626e09db7b61c6bff893ad3e020e97a1947dcb5b3c1b6e8f217af1c3851dc8dd4267c2bc37db8061cc37d51de6ed19c586c8376862aee959ad4462aa
|
7
|
+
data.tar.gz: cb6ece0fb52a4c83b30af7724d7e86e2c2c420ecbbe6446ebdfe1116ec3bbd988dc6b5391d091cb74d047a3d71fad958469a823b1c2c0b92d209fc065043a3c9
|
data/History.log
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
New features for DRG CMS version 0.5.9
|
3
|
+
|
4
|
+
Main CMS menu was becoming to large and was divided into two menus.
|
5
|
+
Result set browse filter data entry redesigned. Values can now be entered directly on actions area. Value of entered fied is also retained beetwen calls.
|
6
|
+
New DcInternals model introduced. It will be used for accessing internal variables.
|
7
|
+
DRG Forms has new option columns. Option defines number of columns per tab or fields. Field option also got colspan option indicating over how many columns field spans.
|
8
|
+
DRG Forms field size can now also be defined on same level as field type. Before it was defined in html sublevel.
|
9
|
+
|
10
|
+
Bugs resolved for DRG CMS version 0.5.9
|
11
|
+
|
12
|
+
Improved readonly display of select and text_autocomplete DRG Forms fields.
|
13
|
+
Text_autocomplete field is set to nil when content of field is deleted.
|
14
|
+
|
15
|
+
--
|
16
|
+
|
17
|
+
New features for DRG CMS version 0.5.8
|
18
|
+
|
19
|
+
Browsing array of hashes is now possible with DRG Forms
|
20
|
+
Simple browsing of all defined models and field definitions added to CMS System menu
|
21
|
+
new result_set options table_style, table_class, tr_style, tr_class, td_style, td_class. Welcome colors to result_set browser
|
22
|
+
result_set has been renewed for more modern design. Header elements have now sorting icons
|
23
|
+
dblclick and click actions can now be defined on result set and can fire any action when clicked or double clicked on result set row.
|
24
|
+
|
25
|
+
Bugs resolved for DRG CMS version 0.5.8
|
26
|
+
|
27
|
+
associated menu can now be selected on dc_page form also for non dc_simple_menu menus
|
28
|
+
|
29
|
+
--
|
30
|
+
|
31
|
+
New features for DRG CMS version 0.5.7
|
32
|
+
|
33
|
+
single site document. All data for the site can be saved to single dc_site document and processed by dc_single_sitedoc_request
|
34
|
+
site parts can now also be saved and collected from dc_site document
|
35
|
+
CMS menu done right
|
36
|
+
Page title is now set from dc_page_renderer default method
|
37
|
+
|
38
|
+
Bugs resolved for DRG CMS version 0.5.7
|
39
|
+
|
40
|
+
Corrected bug when multitext_autocomplete field was not displaying right values when displayed readonly
|
41
|
+
|
42
|
+
dc_choices4 now checks if model has active field defined and returns only choices of documents that have active field value set to true
|
43
|
+
|
44
|
+
Design and page edit icons are now displayed only when design or page documents are available
|
45
|
+
|
46
|
+
return_to from drgcms_control was not properly handled
|
47
|
+
|
48
|
+
Mouse cursor now changes to pointer when moved over ajax link
|
data/README.md
CHANGED
@@ -4,10 +4,10 @@ DRG CMS is alternative way of programming application for Ruby on Rails. Instead
|
|
4
4
|
|
5
5
|
DRG CMS uses Mongo DB, leading NO-SQL document database, as database back-end with a help of mongoid gem. Mongoid's flexible document model defines all document fields, indexes, dependencies, validations in single model file with no Rails migrations required.
|
6
6
|
|
7
|
-
It has built-in user friendly role based access system and it can be easly extended with help of Ruby on Rails plugin system.
|
8
|
-
|
9
7
|
DRG CMS can be used for rapid development of complex, data-entry intensive web sites as well as building your private, in-house, Intranet applications.
|
10
8
|
|
9
|
+
DRG CMS has built-in user friendly role based access system and it can be easly extended with help of Ruby on Rails plugin system.
|
10
|
+
|
11
11
|
Project Tracking
|
12
12
|
----------------
|
13
13
|
|
@@ -16,7 +16,7 @@ Project Tracking
|
|
16
16
|
Compatibility
|
17
17
|
-------------
|
18
18
|
|
19
|
-
DRG CMS is tested against Ruby 2.0, 2.1 and 2.2, Rails 4.2, Mongoid 4 and 5, MongoDB 2.4
|
19
|
+
DRG CMS is tested against Ruby 2.0, 2.1 and 2.2, Rails 4.2, Mongoid 4 and 5, MongoDB 2.4, 2.6, 3.0
|
20
20
|
|
21
21
|
Documentation
|
22
22
|
-------------
|
@@ -24,8 +24,8 @@ Documentation
|
|
24
24
|
Please see the DRG CMS website for up-to-date documentation:
|
25
25
|
[www.drgcms.org](http://www.drgcms.org)
|
26
26
|
|
27
|
-
License
|
28
|
-
|
27
|
+
License (MIT LICENCE)
|
28
|
+
---------------------
|
29
29
|
|
30
30
|
Copyright (c) 2012-2015 Damjan Rems
|
31
31
|
|
@@ -516,7 +516,7 @@ element = $(this).find(':first').attr('id');
|
|
516
516
|
* This will fire cmsedit index action and pass value enterred into
|
517
517
|
* filter field and thus refresh browsed result set.
|
518
518
|
*******************************************************************/
|
519
|
-
$('#
|
519
|
+
$('#_record__filter_field').keydown( function(e) {
|
520
520
|
if (e.which == '13' || e.which == '9') {
|
521
521
|
url = $(this).parents('span').attr("data-url");
|
522
522
|
url = url + "&filter_value=" + this.value;
|
@@ -530,7 +530,7 @@ element = $(this).find(':first').attr('id');
|
|
530
530
|
* work on all field types.
|
531
531
|
*******************************************************************/
|
532
532
|
$('.record_filter_field_icon').on('click', function(e) {
|
533
|
-
field = $('#
|
533
|
+
field = $('#_record__filter_field');
|
534
534
|
url = $(this).parents('span').attr("data-url");
|
535
535
|
url = url + "&filter_value=" + field.val();
|
536
536
|
location.href = url;
|
@@ -540,7 +540,10 @@ element = $(this).find(':first').attr('id');
|
|
540
540
|
* Click on show filter form
|
541
541
|
*******************************************************************/
|
542
542
|
$('#open_drgcms_filter').on('click', function(e) {
|
543
|
-
$('#drgcms_filter').
|
543
|
+
$('#drgcms_filter').bPopup({
|
544
|
+
speed: 650,
|
545
|
+
transition: 'slideDown'
|
546
|
+
});
|
544
547
|
});
|
545
548
|
|
546
549
|
/*******************************************************************
|
@@ -549,11 +552,15 @@ element = $(this).find(':first').attr('id');
|
|
549
552
|
$('.drgcms_popup_submit').on('click', function(e) {
|
550
553
|
//e.preventDefault();
|
551
554
|
url = $(this).attr( 'data-url' );
|
552
|
-
field = $('select#
|
555
|
+
field = $('select#_filter_field1').val();
|
553
556
|
oper = $('select#_filter_oper').val();
|
554
557
|
location.href = url + '&filter_field=' + field + '&filter_oper=' + oper
|
555
|
-
//
|
556
|
-
|
558
|
+
// Still opening in new window
|
559
|
+
// iframe = parent.document.getElementsByTagName("iframe")[0].getAttribute("id");
|
560
|
+
// loc = url + '&filter_field=' + field + '&filter_oper=' + oper
|
561
|
+
// $('#'+iframe).attr('src', loc);
|
562
|
+
// parent.document.getElementById(iframe).src = loc
|
563
|
+
});
|
557
564
|
|
558
565
|
});
|
559
566
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*================================================================================
|
2
|
+
* @name: bPopup - if you can't get it up, use bPopup
|
3
|
+
* @author: (c)Bjoern Klinggaard (twitter@bklinggaard)
|
4
|
+
* @demo: http://dinbror.dk/bpopup
|
5
|
+
* @version: 0.11.0.min
|
6
|
+
================================================================================*/
|
7
|
+
(function(c){c.fn.bPopup=function(A,E){function L(){a.contentContainer=c(a.contentContainer||b);switch(a.content){case "iframe":var d=c('<iframe class="b-iframe" '+a.iframeAttr+"></iframe>");d.appendTo(a.contentContainer);t=b.outerHeight(!0);u=b.outerWidth(!0);B();d.attr("src",a.loadUrl);l(a.loadCallback);break;case "image":B();c("<img />").load(function(){l(a.loadCallback);F(c(this))}).attr("src",a.loadUrl).hide().appendTo(a.contentContainer);break;default:B(),c('<div class="b-ajax-wrapper"></div>').load(a.loadUrl,a.loadData,function(d,b,e){l(a.loadCallback,b);F(c(this))}).hide().appendTo(a.contentContainer)}}function B(){a.modal&&c('<div class="b-modal '+e+'"></div>').css({backgroundColor:a.modalColor,position:"fixed",top:0,right:0,bottom:0,left:0,opacity:0,zIndex:a.zIndex+v}).appendTo(a.appendTo).fadeTo(a.speed,a.opacity);C();b.data("bPopup",a).data("id",e).css({left:"slideIn"==a.transition||"slideBack"==a.transition?"slideBack"==a.transition?f.scrollLeft()+w:-1*(x+u):m(!(!a.follow[0]&&n||g)),position:a.positionStyle||"absolute",top:"slideDown"==a.transition||"slideUp"==a.transition?"slideUp"==a.transition?f.scrollTop()+y:z+-1*t:p(!(!a.follow[1]&&q||g)),"z-index":a.zIndex+v+1}).each(function(){a.appending&&c(this).appendTo(a.appendTo)});G(!0)}function r(){a.modal&&c(".b-modal."+b.data("id")).fadeTo(a.speed,0,function(){c(this).remove()});a.scrollBar||c("html").css("overflow","auto");c(".b-modal."+e).unbind("click");f.unbind("keydown."+e);k.unbind("."+e).data("bPopup",0<k.data("bPopup")-1?k.data("bPopup")-1:null);b.undelegate(".bClose, ."+a.closeClass,"click."+e,r).data("bPopup",null);clearTimeout(H);G();return!1}function I(d){y=k.height();w=k.width();h=D();if(h.x||h.y)clearTimeout(J),J=setTimeout(function(){C();d=d||a.followSpeed;var e={};h.x&&(e.left=a.follow[0]?m(!0):"auto");h.y&&(e.top=a.follow[1]?p(!0):"auto");b.dequeue().each(function(){g?c(this).css({left:x,top:z}):c(this).animate(e,d,a.followEasing)})},50)}function F(d){var c=d.width(),e=d.height(),f={};a.contentContainer.css({height:e,width:c});e>=b.height()&&(f.height=b.height());c>=b.width()&&(f.width=b.width());t=b.outerHeight(!0);u=b.outerWidth(!0);C();a.contentContainer.css({height:"auto",width:"auto"});f.left=m(!(!a.follow[0]&&n||g));f.top=p(!(!a.follow[1]&&q||g));b.animate(f,250,function(){d.show();h=D()})}function M(){k.data("bPopup",v);b.delegate(".bClose, ."+a.closeClass,"click."+e,r);a.modalClose&&c(".b-modal."+e).css("cursor","pointer").bind("click",r);N||!a.follow[0]&&!a.follow[1]||k.bind("scroll."+e,function(){if(h.x||h.y){var d={};h.x&&(d.left=a.follow[0]?m(!g):"auto");h.y&&(d.top=a.follow[1]?p(!g):"auto");b.dequeue().animate(d,a.followSpeed,a.followEasing)}}).bind("resize."+e,function(){I()});a.escClose&&f.bind("keydown."+e,function(a){27==a.which&&r()})}function G(d){function c(e){b.css({display:"block",opacity:1}).animate(e,a.speed,a.easing,function(){K(d)})}switch(d?a.transition:a.transitionClose||a.transition){case "slideIn":c({left:d?m(!(!a.follow[0]&&n||g)):f.scrollLeft()-(u||b.outerWidth(!0))-200});break;case "slideBack":c({left:d?m(!(!a.follow[0]&&n||g)):f.scrollLeft()+w+200});break;case "slideDown":c({top:d?p(!(!a.follow[1]&&q||g)):f.scrollTop()-(t||b.outerHeight(!0))-200});break;case "slideUp":c({top:d?p(!(!a.follow[1]&&q||g)):f.scrollTop()+y+200});break;default:b.stop().fadeTo(a.speed,d?1:0,function(){K(d)})}}function K(d){d?(M(),l(E),a.autoClose&&(H=setTimeout(r,a.autoClose))):(b.hide(),l(a.onClose),a.loadUrl&&(a.contentContainer.empty(),b.css({height:"auto",width:"auto"})))}function m(a){return a?x+f.scrollLeft():x}function p(a){return a?z+f.scrollTop():z}function l(a,e){c.isFunction(a)&&a.call(b,e)}function C(){z=q?a.position[1]:Math.max(0,(y-b.outerHeight(!0))/2-a.amsl);x=n?a.position[0]:(w-b.outerWidth(!0))/2;h=D()}function D(){return{x:w>b.outerWidth(!0),y:y>b.outerHeight(!0)}}c.isFunction(A)&&(E=A,A=null);var a=c.extend({},c.fn.bPopup.defaults,A);a.scrollBar||c("html").css("overflow","hidden");var b=this,f=c(document),k=c(window),y=k.height(),w=k.width(),N=/OS 6(_\d)+/i.test(navigator.userAgent),v=0,e,h,q,n,g,z,x,t,u,J,H;b.close=function(){r()};b.reposition=function(a){I(a)};return b.each(function(){c(this).data("bPopup")||(l(a.onOpen),v=(k.data("bPopup")||0)+1,e="__b-popup"+v+"__",q="auto"!==a.position[1],n="auto"!==a.position[0],g="fixed"===a.positionStyle,t=b.outerHeight(!0),u=b.outerWidth(!0),a.loadUrl?L():B())})};c.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",autoClose:!1,closeClass:"b-close",content:"ajax",contentContainer:!1,easing:"swing",escClose:!0,follow:[!0,!0],followEasing:"swing",followSpeed:500,iframeAttr:'scrolling="no" frameborder="0"',loadCallback:!1,loadData:!1,loadUrl:!1,modal:!0,modalClose:!0,modalColor:"#000",onClose:!1,onOpen:!1,opacity:.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,speed:250,transition:"fadeIn",transitionClose:!1,zIndex:9997}})(jQuery);
|
@@ -415,16 +415,20 @@ background: transparent linear-gradient(to bottom, #ddd 0%, #FFF 100%) repeat sc
|
|
415
415
|
font-weight: bold;
|
416
416
|
padding: 10px 2px;
|
417
417
|
width: 150px;
|
418
|
-
/*
|
419
|
-
background-color: #f4f4f4;
|
420
|
-
border-bottom: 1px solid #eee;
|
421
|
-
*/
|
422
418
|
}
|
423
419
|
|
424
420
|
.dc-form-label label {
|
425
421
|
padding: 0px 0px 2px 1px;
|
426
422
|
}
|
427
423
|
|
424
|
+
.dc-form-label-top {
|
425
|
+
color: #555;
|
426
|
+
text-align: right;
|
427
|
+
vertical-align: middle;
|
428
|
+
font-weight: bold;
|
429
|
+
padding: 3px 5px;
|
430
|
+
}
|
431
|
+
|
428
432
|
.dc-align-left {
|
429
433
|
text-align: left;
|
430
434
|
}
|
@@ -880,13 +884,14 @@ border-radius: 2px;
|
|
880
884
|
|
881
885
|
/************************** info popup *************************/
|
882
886
|
#drgcms_filter {
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
background: #fff;
|
889
|
-
display: none;
|
890
|
-
padding: 20px;
|
891
|
-
border: 2px solid #222;
|
887
|
+
z-index:100;
|
888
|
+
background: #fff;
|
889
|
+
display: none;
|
890
|
+
padding: 4px;
|
891
|
+
border: 2px solid #222;
|
892
892
|
}
|
893
|
+
#drgcms_filter h1 {
|
894
|
+
background-color: #ccc;
|
895
|
+
font-size: 2em;
|
896
|
+
padding: 5px;
|
897
|
+
}
|
@@ -16,7 +16,7 @@
|
|
16
16
|
*= #require ../javascripts/drg_cms/elfinder/css/elfinder.min.css
|
17
17
|
*= #require ../javascripts/drg_cms/elfinder/css/theme.css
|
18
18
|
*= require font-awesome
|
19
|
-
*= require drg_cms/the-modal.css
|
19
|
+
*= #require drg_cms/the-modal.css
|
20
20
|
*/
|
21
21
|
|
22
22
|
/* Required for link buttons to look alike */
|
@@ -263,6 +263,15 @@ end
|
|
263
263
|
########################################################################
|
264
264
|
def show
|
265
265
|
find_record
|
266
|
+
if (m = callback_method('before_show') )
|
267
|
+
ret = call_callback_method(m)
|
268
|
+
# Don't do anything if return is false
|
269
|
+
if ret.class == FalseClass
|
270
|
+
@form['readonly'] = nil # must be
|
271
|
+
return index
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
266
275
|
render action: 'edit', layout: 'cms'
|
267
276
|
end
|
268
277
|
|
@@ -645,23 +654,6 @@ def update_standards(record = @record)
|
|
645
654
|
end
|
646
655
|
end
|
647
656
|
|
648
|
-
########################################################################
|
649
|
-
# Since tabs have been introduced on form it is a little more complicated
|
650
|
-
# to get all edit fields on form. This method does it. Subroutine of save_data.
|
651
|
-
########################################################################
|
652
|
-
def fields_on_form() #:nodoc:
|
653
|
-
fields = []
|
654
|
-
if @form['form']['fields']
|
655
|
-
# second element of array is hash. Get only hash element
|
656
|
-
@form['form']['fields'].each {|field| fields << field[1]}
|
657
|
-
else
|
658
|
-
@form['form']['tabs'].keys.each do |key|
|
659
|
-
@form['form']['tabs'][key].each {|field| fields << field[1]}
|
660
|
-
end
|
661
|
-
end
|
662
|
-
fields
|
663
|
-
end
|
664
|
-
|
665
657
|
########################################################################
|
666
658
|
# Save document changes to journal table. Saves all parameters to retrieve record if needed.
|
667
659
|
#
|
@@ -748,6 +740,23 @@ def process_return_to(return_to)
|
|
748
740
|
render text: js_tag(script)
|
749
741
|
end
|
750
742
|
|
743
|
+
########################################################################
|
744
|
+
# Since tabs have been introduced on form it is a little more complicated
|
745
|
+
# to get all edit fields on form. This method does it. Subroutine of save_data.
|
746
|
+
########################################################################
|
747
|
+
def fields_on_form() #:nodoc:
|
748
|
+
fields = []
|
749
|
+
if @form['form']['fields']
|
750
|
+
# read only field elements (key is Fixnum)
|
751
|
+
@form['form']['fields'].each {|key,options| fields << options if key.class == Fixnum }
|
752
|
+
else
|
753
|
+
@form['form']['tabs'].keys.each do |tab|
|
754
|
+
@form['form']['tabs'][tab].each {|key,options| fields << options if key.class == Fixnum }
|
755
|
+
end
|
756
|
+
end
|
757
|
+
fields
|
758
|
+
end
|
759
|
+
|
751
760
|
########################################################################
|
752
761
|
# Save edited data. Take care that only fields defined on form are affected.
|
753
762
|
# It also saves journal data and calls before_save and after_save callbacks.
|
@@ -757,6 +766,7 @@ def save_data
|
|
757
766
|
return true unless fields.size > 0
|
758
767
|
#
|
759
768
|
fields.each do |v|
|
769
|
+
next if v['type'].nil?
|
760
770
|
next if v['type'].match('embedded') # don't wipe embedded fields
|
761
771
|
next if params[:edit_only] and params[:edit_only] != v['name'] # otherwise other fields would be wiped
|
762
772
|
next unless @record.respond_to?(v['name']) # there can be temporary fields on the form
|
@@ -45,6 +45,8 @@ end
|
|
45
45
|
|
46
46
|
####################################################################
|
47
47
|
# Return true if CMS is in edit mode
|
48
|
+
#
|
49
|
+
# @return [Boolean] True if user CMS edit mode is selected
|
48
50
|
####################################################################
|
49
51
|
def dc_edit_mode?
|
50
52
|
session[:edit_mode] > 1
|
@@ -54,8 +56,7 @@ end
|
|
54
56
|
# Checks if user has required role.
|
55
57
|
#
|
56
58
|
# @param [DcPolicyRole] role can be passed as DcPolicyRole object or
|
57
|
-
# @param [String] role as role name. If passed as name, dc_policy_roles
|
58
|
-
# is searched for appropriate role.
|
59
|
+
# @param [String] role as role name. If passed as name, dc_policy_roles is searched for appropriate role.
|
59
60
|
#
|
60
61
|
# @return [Boolean] True if user has required role added to his profile.
|
61
62
|
#
|
@@ -112,14 +113,12 @@ end
|
|
112
113
|
########################################################################
|
113
114
|
# Searches forms path for file_name and returns full file name or nil if not found.
|
114
115
|
#
|
115
|
-
# [
|
116
|
-
# [form_file] Form file name. File name can be passed as gem_name.filename. This can
|
116
|
+
# @param [String] Form file name. File name can be passed as gem_name.filename. This can
|
117
117
|
# be useful when you are extending form but want to retain same name as original form
|
118
118
|
# For example. You are extending dc_user form from drg_cms gem and want to
|
119
119
|
# retain same dc_user name. This can be done by setting drg_cms.dc_user to extend option.
|
120
120
|
#
|
121
|
-
# [
|
122
|
-
# String. Full form file name or nil if not found.
|
121
|
+
# @return [String] Form file name including path or nil if not found.
|
123
122
|
########################################################################
|
124
123
|
def dc_find_form_file(form_file)
|
125
124
|
form_path=nil
|
@@ -137,8 +136,11 @@ end
|
|
137
136
|
#######################################################################
|
138
137
|
# Will render public/404.html file with some debug code includded.
|
139
138
|
#
|
140
|
-
# [
|
141
|
-
#
|
139
|
+
# @param [Object] Object where_the_error_is. Additional data can be displayed with error.
|
140
|
+
#
|
141
|
+
# @example Render error
|
142
|
+
# site = dc_get_site()
|
143
|
+
# return dc_render_404('Site') unless site
|
142
144
|
########################################################################
|
143
145
|
def dc_render_404(where_the_error_is=nil)
|
144
146
|
render(file: "#{Rails.root}/public/404", :status => 404, :layout => false, :formats => [:html],
|
@@ -177,15 +179,13 @@ end
|
|
177
179
|
# Checks if user can perform (read, create, edit, delete) document in specified
|
178
180
|
# table (collection).
|
179
181
|
#
|
180
|
-
# [
|
181
|
-
# [
|
182
|
-
# [String table] Name of table(collection) for which permission is required. Defaults to params[table].
|
182
|
+
# @param [Integer] Required permission level
|
183
|
+
# @param [String] Collection (table) name for which permission is queried. Defaults to params[table].
|
183
184
|
#
|
184
|
-
# [
|
185
|
-
# Boolean true if user's role permits operation on a table(collection) with required permission.
|
185
|
+
# @return [Boolean] true if user's role permits (is higher or equal then required) operation on a table (collection).
|
186
186
|
#
|
187
|
-
#
|
188
|
-
#
|
187
|
+
# @Example True when user has view permission on the table
|
188
|
+
# if dc_user_can(DcPermission::CAN_VIEW, params[:table]) then ...
|
189
189
|
############################################################################
|
190
190
|
def dc_user_can(permission, table=params[:table])
|
191
191
|
if @permissions.nil?
|
@@ -220,8 +220,8 @@ end
|
|
220
220
|
|
221
221
|
##########################################################################
|
222
222
|
# Merge values from parameters fields (from site, page ...) into internal @options hash.
|
223
|
-
#
|
224
|
-
# [String
|
223
|
+
#
|
224
|
+
# @param [String] YAML string.
|
225
225
|
##########################################################################
|
226
226
|
def dc_set_options(parameters)
|
227
227
|
@options ||= {}
|
@@ -242,10 +242,13 @@ def dc_set_options(parameters)
|
|
242
242
|
end
|
243
243
|
|
244
244
|
##########################################################################
|
245
|
-
# Check if document(s) has been modified since last visit.
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
245
|
+
# Check if document(s) has been modified since last visit. It turned out that caching
|
246
|
+
# is not that simple and that there are multiple caching scenarios that can be used.
|
247
|
+
# So this code is here just for a example, how documents can be checked for changed status.
|
248
|
+
#
|
249
|
+
# @param [Documents] List of documents which are checked against last visit date
|
250
|
+
#
|
251
|
+
# @return [Boolean] true when none of documents is changed.
|
249
252
|
##########################################################################
|
250
253
|
def dc_not_modified?(*documents)
|
251
254
|
# request.env.each {|k,v| p k,'*',v}
|
@@ -270,15 +273,14 @@ end
|
|
270
273
|
# design documents, collect parameters from different objects, add CMS edit code if allowed
|
271
274
|
# and at the end render design.body or design.rails_view or site.rails_view.
|
272
275
|
#
|
273
|
-
#
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
#
|
278
|
-
#
|
279
|
-
#
|
280
|
-
#
|
281
|
-
#
|
276
|
+
# @example as defined in routes.rb
|
277
|
+
# get '*path' => 'dc_application_controller#dc_process_default_request'
|
278
|
+
# # or
|
279
|
+
# get '*path' => 'my_controller#page'
|
280
|
+
# # then in my_controller.rb
|
281
|
+
# def page
|
282
|
+
# dc_process_default_request
|
283
|
+
# end
|
282
284
|
##########################################################################
|
283
285
|
def dc_process_default_request()
|
284
286
|
session[:edit_mode] ||= 0
|
@@ -383,12 +385,14 @@ def dc_single_sitedoc_request
|
|
383
385
|
end
|
384
386
|
|
385
387
|
########################################################################
|
386
|
-
# Decamelizes string. Does oposite
|
388
|
+
# Decamelizes string. Does oposite of camelize method. It probably doesn't work
|
387
389
|
# very good with non ascii chars. Since this method is used for converting from model
|
388
390
|
# to collection names it is very unwise to use non ascii chars for table (collection) names.
|
389
391
|
#
|
390
|
-
# [
|
391
|
-
#
|
392
|
+
# @param [String] String to be converted
|
393
|
+
#
|
394
|
+
# @example
|
395
|
+
# decamelize_type(ModelName) # 'ModelName' => 'model_name'
|
392
396
|
########################################################################
|
393
397
|
def decamelize_type(string)
|
394
398
|
return nil unless string
|
@@ -406,11 +410,9 @@ end
|
|
406
410
|
####################################################################
|
407
411
|
# Return's error messages for the document formated for display on edit form.
|
408
412
|
#
|
409
|
-
# [
|
410
|
-
# [document] Document which will be examined for errors.
|
413
|
+
# @param [Document] Document object which will be examined for errors.
|
411
414
|
#
|
412
|
-
# [
|
413
|
-
# String. HTML code for displaying error on edit form.
|
415
|
+
# @return [String] HTML code for displaying error on edit form.
|
414
416
|
####################################################################
|
415
417
|
def dc_error_messages_for(document)
|
416
418
|
return '' unless document.errors.any?
|
@@ -435,19 +437,17 @@ end
|
|
435
437
|
# model errors or when saving to multiple collections and where each save must be
|
436
438
|
# checked if succesfull.
|
437
439
|
#
|
438
|
-
# [
|
439
|
-
# [
|
440
|
-
# [Boolean crash] Should crash when errors detected. Default = false.
|
440
|
+
# @param [Document] Document object which will be checked
|
441
|
+
# @param [Boolean] If true method should end in runtime error. Default = false.
|
441
442
|
#
|
442
|
-
# [
|
443
|
-
# String. Documents error message empty string if everything is OK.
|
443
|
+
# @return [String] Error messages or empty string if everything is OK.
|
444
444
|
#
|
445
|
-
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
445
|
+
# @Example Check for error when data is saved.
|
446
|
+
# model.save
|
447
|
+
# if (msg = dc_check_model(model) ).size > 0
|
448
|
+
# p msg
|
449
|
+
# error process ......
|
450
|
+
# end
|
451
451
|
#
|
452
452
|
####################################################################
|
453
453
|
def dc_check_model(document, crash=false)
|
@@ -464,12 +464,11 @@ end
|
|
464
464
|
######################################################################
|
465
465
|
# Call rake task from controller.
|
466
466
|
#
|
467
|
-
# [
|
468
|
-
# [
|
469
|
-
# [Hash options] Options that will be send to task as environment variables
|
467
|
+
# @param [String] Rake task name
|
468
|
+
# @param [Hash] Options that will be send to task as environment variables
|
470
469
|
#
|
471
|
-
#
|
472
|
-
#
|
470
|
+
# @example Call rake task from application
|
471
|
+
# dc_call_rake('clear:all', some_parm: some_id)
|
473
472
|
######################################################################
|
474
473
|
def dc_call_rake(task, options = {})
|
475
474
|
options[:rails_env] ||= Rails.env
|
@@ -482,17 +481,15 @@ end
|
|
482
481
|
# made from DRG CMS form return may be quite complicated. All ajax return combinations
|
483
482
|
# can be found in drg_cms.js file.
|
484
483
|
#
|
485
|
-
# [
|
486
|
-
# [Hash opts] Different options
|
484
|
+
# @param [Hash] Options
|
487
485
|
#
|
488
|
-
# [
|
489
|
-
# String. Formatted to be used on ajax return.
|
486
|
+
# @return [JSON Response] Formatted to be used for ajax return.
|
490
487
|
#
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#
|
495
|
-
#
|
488
|
+
# @example
|
489
|
+
# html_code = '<span>Some text</span>'
|
490
|
+
# dc_render_ajax(div: 'mydiv', prepand: html_code) # Will prepand code to mydiv div
|
491
|
+
# dc_render_ajax(class: 'myclass', append: html_code) # Will append code to all objects with myclass class
|
492
|
+
# dc_render_ajax(operation: 'window', value: "/pdf_file.pdf") # will open pdf file in new window.
|
496
493
|
#
|
497
494
|
######################################################################
|
498
495
|
def dc_render_ajax(opts)
|
@@ -514,19 +511,16 @@ def dc_render_ajax(opts)
|
|
514
511
|
end
|
515
512
|
|
516
513
|
########################################################################
|
517
|
-
# Find document by parameters. This is how cmsedit finds document based
|
518
|
-
# on url parameters.
|
514
|
+
# Find document by parameters. This is how cmsedit finds document based on url parameters.
|
519
515
|
#
|
520
|
-
# [
|
521
|
-
# [String
|
522
|
-
# [String
|
523
|
-
# [String table] Ids of parent documents when document is embedded. Ids are separated by ; char.
|
516
|
+
# @param [String] Table (collection) name. Could be dc_page;dc_part;... when searching for embedded document.
|
517
|
+
# @param [String] Id of the document
|
518
|
+
# @param [String] Ids of parent documents when document is embedded. Ids are separated by ; char.
|
524
519
|
#
|
525
|
-
# [
|
526
|
-
# Document. Required document or nil if not found.
|
520
|
+
# @return [document]. Required document or nil if not found.
|
527
521
|
#
|
528
|
-
#
|
529
|
-
#
|
522
|
+
# @example As used in Cmsedit_controller
|
523
|
+
# dc_find_document(params[:table], params[:id], params[:ids])
|
530
524
|
########################################################################
|
531
525
|
def dc_find_document(table, id, ids)
|
532
526
|
tables = table.split(';')
|
@@ -543,12 +537,12 @@ end
|
|
543
537
|
|
544
538
|
########################################################################
|
545
539
|
# Reload patches in development. Since patching files are not automatically loaded in
|
546
|
-
# development environment
|
540
|
+
# development environment this little method automatically reloads all patch files
|
547
541
|
# found in DrgCms.paths(:patches) path array.
|
548
542
|
########################################################################
|
549
543
|
def dc_reload_patches
|
550
544
|
DrgCms.paths(:patches).each do |patches|
|
551
|
-
Dir["#{patches}/**/*.rb"].each { |
|
545
|
+
Dir["#{patches}/**/*.rb"].each { |file| require_dependency(file) }
|
552
546
|
end
|
553
547
|
end
|
554
548
|
|