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/models/dc_filter.rb
CHANGED
@@ -68,7 +68,6 @@ def self.get_filter(filter)
|
|
68
68
|
value = BSON::ObjectId.from_string(value) rescue nil
|
69
69
|
end
|
70
70
|
#
|
71
|
-
p yaml,'***************'
|
72
71
|
if ['eq','like'].include?(yaml['operation'])
|
73
72
|
model.where(field => value)
|
74
73
|
# TODO in operator
|
@@ -84,13 +83,13 @@ end
|
|
84
83
|
def self.get_field_form_definition(name, parent) #:nodoc:
|
85
84
|
form = parent.form
|
86
85
|
form['form']['tabs'].each do |tab|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
86
|
+
# Array with 2 elements. First is tabname, second is data
|
87
|
+
fields = tab.last
|
88
|
+
fields.each {|k,v| return v if (k.class == Fixnum and v['name'] == name) }
|
91
89
|
end if form['form']['tabs'] # I know. But nice.
|
92
90
|
#
|
93
91
|
form['form']['fields'].each do |field|
|
92
|
+
next unless field.first.class == Fixnum # options
|
94
93
|
return field.last if field.last['name'] == name
|
95
94
|
end if form['form']['fields']
|
96
95
|
nil
|
@@ -106,33 +105,40 @@ def self.get_filter_field(parent)
|
|
106
105
|
#
|
107
106
|
filter = YAML.load(filter) rescue nil
|
108
107
|
return '' if filter.nil?
|
109
|
-
# return '' if filter['input'].nil?
|
110
108
|
#
|
111
|
-
p filter
|
112
109
|
field = get_field_form_definition(filter['field'], parent)
|
113
110
|
return '' if field.nil? and filter['input'].nil?
|
114
111
|
field = {} if field.nil?
|
115
|
-
# field
|
116
|
-
field['name']
|
117
|
-
|
118
|
-
|
112
|
+
# If field has choices available in labels, use them. This is most likely select input field.
|
113
|
+
if field['name']
|
114
|
+
choices = parent.t('helpers.label.' + parent.form['table'] + '.choices4_' + field['name'] )
|
115
|
+
unless choices.match( 'translation missing' ) or choices.match('helpers.label')
|
116
|
+
field['choices'] = choices
|
117
|
+
end
|
118
|
+
end
|
119
|
+
# field redefined with input keyword. Name must start with _
|
120
|
+
field['name'] = '_filter_field'
|
121
|
+
field['type'] = filter['input'] if filter['input'].to_s.size > 5
|
122
|
+
field['type'] ||= 'text_field'
|
123
|
+
field['html'] ||= {}
|
119
124
|
field['html']['size'] = 20
|
125
|
+
# Start with last entered value
|
120
126
|
field['html']['value'] = filter['value'] unless filter['value'] == '#NIL'
|
121
|
-
|
127
|
+
field['html']['selected'] = field['html']['value'] # for select field
|
128
|
+
# url for filter ON action
|
122
129
|
field['html']['data-url'] = parent.url_for(
|
123
130
|
controller: 'cmsedit',action: :index, filter: 'on',
|
124
131
|
table: parent.form['table'], formname: parent.form['formname'])
|
125
132
|
url = field['html']['data-url']
|
126
|
-
#
|
127
|
-
|
128
|
-
klas_string = field_type.camelize
|
133
|
+
# create input field object
|
134
|
+
klas_string = field['type'].camelize
|
129
135
|
klas = DrgcmsFormFields::const_get(klas_string) rescue nil
|
130
136
|
return '' if klas.nil?
|
131
|
-
#
|
137
|
+
# return data from object and create html code to display field
|
132
138
|
object = klas.new(parent, nil, field).render
|
133
139
|
js = object.js
|
134
140
|
"<span class=\"filter_field\" data-url=\"#{url}\">#{object.html} " <<
|
135
|
-
parent.fa_icon('filter lg dc-green', class: 'record_filter_field_icon') <<
|
141
|
+
parent.fa_icon('filter lg dc-green', class: 'record_filter_field_icon dc-link dc-animate') <<
|
136
142
|
(js.size > 2 ? parent.javascript_tag(js) : '') << '</span>'
|
137
143
|
end
|
138
144
|
|
@@ -80,6 +80,10 @@ def initialize( parent, record, yaml )
|
|
80
80
|
@yaml = yaml
|
81
81
|
@form = parent.form
|
82
82
|
@readonly = (@yaml and @yaml['readonly']) || (@form and @form['readonly'])
|
83
|
+
if @yaml['size'] # move size to html element if not already there
|
84
|
+
@yaml['html'] ||= {}
|
85
|
+
@yaml['html']['size'] ||= @yaml['size']
|
86
|
+
end
|
83
87
|
@html = ''
|
84
88
|
@js = ''
|
85
89
|
self
|
@@ -123,11 +127,21 @@ end
|
|
123
127
|
#
|
124
128
|
# Example: Form has field named picture. Field can be initialized by
|
125
129
|
# setting value of param p_picture.
|
130
|
+
# params['p_picture'] = '/path/to_picture'
|
131
|
+
#
|
132
|
+
# When multiple initial values are assigned it is more convinient to assign them
|
133
|
+
# through flash method.
|
134
|
+
# flash[:record] = {}
|
135
|
+
# flash[:record]['picture'] = '/path/to_picture'
|
126
136
|
####################################################################
|
127
137
|
def set_initial_value(opt1='html', opt2='value')
|
128
138
|
@yaml['html'] ||= {}
|
129
139
|
value_send_as = 'p_' + @yaml['name']
|
130
|
-
|
140
|
+
if @parent.params[value_send_as]
|
141
|
+
@yaml[opt1][opt2] = @parent.params[value_send_as]
|
142
|
+
elsif @parent.flash[:record] and @parent.flash[:record][@yaml['name']]
|
143
|
+
@yaml[opt1][opt2] = @parent.flash[:record][@yaml['name']]
|
144
|
+
end
|
131
145
|
end
|
132
146
|
|
133
147
|
####################################################################
|
@@ -1187,10 +1201,11 @@ end
|
|
1187
1201
|
###########################################################################
|
1188
1202
|
def render
|
1189
1203
|
return ro_standard if @readonly
|
1204
|
+
set_initial_value
|
1190
1205
|
#
|
1191
|
-
@yaml['html'] ||= {}
|
1192
|
-
value_send_as = 'p_' + @yaml['name']
|
1193
|
-
@yaml['html']['value'] = @parent.params[value_send_as] if @parent.params[value_send_as]
|
1206
|
+
# @yaml['html'] ||= {}
|
1207
|
+
# value_send_as = 'p_' + @yaml['name']
|
1208
|
+
# @yaml['html']['value'] = @parent.params[value_send_as] if @parent.params[value_send_as]
|
1194
1209
|
|
1195
1210
|
record = record_text_for(@yaml['name'])
|
1196
1211
|
@html << @parent.text_area(record, @yaml['name'], @yaml['html'])
|
data/drg_cms.gemspec
CHANGED
@@ -10,10 +10,10 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ["Damjan Rems"]
|
11
11
|
s.email = ["damjan.rems@gmail.com"]
|
12
12
|
s.homepage = "http://www.drgcms.org"
|
13
|
-
s.summary = "DRG CMS:
|
14
|
-
s.description = "DRG CMS can be used for rapid building of complex, data-entry intensive web sites as well as building your private
|
13
|
+
s.summary = "DRG CMS: Rapid web application development tool for Ruby, Rails and MongoDB"
|
14
|
+
s.description = "DRG CMS can be used for rapid building of complex, data-entry intensive web sites as well as building your in-house private cloud applications."
|
15
15
|
s.license = "MIT-LICENSE"
|
16
|
-
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md", "drg_cms.gemspec"]
|
16
|
+
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md", "History.log", "drg_cms.gemspec"]
|
17
17
|
s.test_files = Dir["test/**/*"]
|
18
18
|
|
19
19
|
s.add_dependency 'rails' #, '~> 3.2.16'
|
data/lib/drg_cms/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drg_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damjan Rems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -123,13 +123,14 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: DRG CMS can be used for rapid building of complex, data-entry intensive
|
126
|
-
web sites as well as building your private
|
126
|
+
web sites as well as building your in-house private cloud applications.
|
127
127
|
email:
|
128
128
|
- damjan.rems@gmail.com
|
129
129
|
executables: []
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
+
- History.log
|
133
134
|
- MIT-LICENSE
|
134
135
|
- README.md
|
135
136
|
- Rakefile
|
@@ -155,8 +156,8 @@ files:
|
|
155
156
|
- app/assets/images/drg_cms/x.png
|
156
157
|
- app/assets/javascripts/drg_cms/drg_cms.js
|
157
158
|
- app/assets/javascripts/drg_cms/jquery-migrate.js
|
159
|
+
- app/assets/javascripts/drg_cms/jquery.bpopup.min.js
|
158
160
|
- app/assets/javascripts/drg_cms/jquery.datetimepicker.js
|
159
|
-
- app/assets/javascripts/drg_cms/jquery.the-modal.js
|
160
161
|
- app/assets/javascripts/drg_cms/some_scripts.js
|
161
162
|
- app/assets/javascripts/drg_cms_application.js
|
162
163
|
- app/assets/javascripts/drg_cms_cms.js
|
@@ -164,7 +165,6 @@ files:
|
|
164
165
|
- app/assets/stylesheets/drg_cms/jquery-ui.css
|
165
166
|
- app/assets/stylesheets/drg_cms/jquery.datetimepicker.css
|
166
167
|
- app/assets/stylesheets/drg_cms/th-bg.png
|
167
|
-
- app/assets/stylesheets/drg_cms/the-modal.css
|
168
168
|
- app/assets/stylesheets/drg_cms/theme.css
|
169
169
|
- app/assets/stylesheets/drg_cms_application.css
|
170
170
|
- app/assets/stylesheets/drg_cms_cms.css
|
@@ -354,7 +354,7 @@ rubyforge_project:
|
|
354
354
|
rubygems_version: 2.2.5
|
355
355
|
signing_key:
|
356
356
|
specification_version: 4
|
357
|
-
summary: 'DRG CMS:
|
357
|
+
summary: 'DRG CMS: Rapid web application development tool for Ruby, Rails and MongoDB'
|
358
358
|
test_files:
|
359
359
|
- test/test_helper.rb
|
360
360
|
- test/lib/generators/new_drg_form_generator_test.rb
|
@@ -1,260 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* The Modal jQuery plugin
|
3
|
-
*
|
4
|
-
* @author Alexander Makarov <sam@rmcreative.ru>
|
5
|
-
* @link https://github.com/samdark/the-modal
|
6
|
-
* @version 0.0.14
|
7
|
-
*/
|
8
|
-
;(function($, window, document, undefined) {
|
9
|
-
"use strict";
|
10
|
-
/*jshint smarttabs:true*/
|
11
|
-
|
12
|
-
// :focusable expression, needed for tabindexes in modal
|
13
|
-
$.extend($.expr[':'],{
|
14
|
-
focusable: function(element){
|
15
|
-
var map, mapName, img,
|
16
|
-
nodeName = element.nodeName.toLowerCase(),
|
17
|
-
isTabIndexNotNaN = !isNaN($.attr(element,'tabindex'));
|
18
|
-
if ('area' === nodeName) {
|
19
|
-
map = element.parentNode;
|
20
|
-
mapName = map.name;
|
21
|
-
if (!element.href || !mapName || map.nodeName.toLowerCase() !== 'map') {
|
22
|
-
return false;
|
23
|
-
}
|
24
|
-
img = $('img[usemap=#' + mapName + ']')[0];
|
25
|
-
return !!img && visible(img);
|
26
|
-
}
|
27
|
-
|
28
|
-
var result = isTabIndexNotNaN;
|
29
|
-
if (/input|select|textarea|button|object/.test(nodeName)) {
|
30
|
-
result = !element.disabled;
|
31
|
-
} else if ('a' === nodeName) {
|
32
|
-
result = element.href || isTabIndexNotNaN;
|
33
|
-
}
|
34
|
-
|
35
|
-
return result && visible(element);
|
36
|
-
|
37
|
-
function visible(element) {
|
38
|
-
return $.expr.filters.visible(element) &&
|
39
|
-
!$(element).parents().addBack().filter(function() {
|
40
|
-
return $.css(this,'visibility') === 'hidden';
|
41
|
-
}).length;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
});
|
45
|
-
|
46
|
-
var pluginNamespace = 'the-modal',
|
47
|
-
// global defaults
|
48
|
-
defaults = {
|
49
|
-
lockClass: 'themodal-lock',
|
50
|
-
overlayClass: 'themodal-overlay',
|
51
|
-
|
52
|
-
closeOnEsc: true,
|
53
|
-
closeOnOverlayClick: true,
|
54
|
-
|
55
|
-
onBeforeClose: null,
|
56
|
-
onClose: null,
|
57
|
-
onOpen: null,
|
58
|
-
|
59
|
-
cloning: true
|
60
|
-
};
|
61
|
-
var oMargin = {};
|
62
|
-
var ieBodyTopMargin = 0;
|
63
|
-
|
64
|
-
function isIE() {
|
65
|
-
return ((navigator.appName == 'Microsoft Internet Explorer') ||
|
66
|
-
(navigator.userAgent.match(/MSIE\s+\d+\.\d+/)) ||
|
67
|
-
(navigator.userAgent.match(/Trident\/\d+\.\d+/)));
|
68
|
-
}
|
69
|
-
|
70
|
-
function lockContainer(options, overlay) {
|
71
|
-
var body = $('body');
|
72
|
-
var oWidth = body.outerWidth(true);
|
73
|
-
body.addClass(options.lockClass);
|
74
|
-
var sbWidth = body.outerWidth(true) - oWidth;
|
75
|
-
if (isIE()) {
|
76
|
-
ieBodyTopMargin = body.css('margin-top');
|
77
|
-
body.css('margin-top', 0);
|
78
|
-
}
|
79
|
-
|
80
|
-
if (sbWidth != 0) {
|
81
|
-
var tags = $('html, body');
|
82
|
-
tags.each(function () {
|
83
|
-
var $this = $(this);
|
84
|
-
oMargin[$this.prop('tagName').toLowerCase()] = parseInt($this.css('margin-right'));
|
85
|
-
});
|
86
|
-
$('html').css('margin-right', oMargin['html'] + sbWidth);
|
87
|
-
overlay.css('left', 0 - sbWidth);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
|
-
function unlockContainer(options) {
|
92
|
-
if (isIE()) {
|
93
|
-
$('body').css('margin-top', ieBodyTopMargin);
|
94
|
-
}
|
95
|
-
|
96
|
-
var body = $('body');
|
97
|
-
var oWidth = body.outerWidth(true);
|
98
|
-
body.removeClass(options.lockClass);
|
99
|
-
var sbWidth = body.outerWidth(true) - oWidth;
|
100
|
-
|
101
|
-
if (sbWidth != 0) {
|
102
|
-
$('html, body').each(function () {
|
103
|
-
var $this = $(this);
|
104
|
-
$this.css('margin-right', oMargin[$this.prop('tagName').toLowerCase()])
|
105
|
-
});
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
function init(els, options) {
|
110
|
-
var modalOptions = options;
|
111
|
-
|
112
|
-
if(els.length) {
|
113
|
-
els.each(function(){
|
114
|
-
$(this).data(pluginNamespace+'.options', modalOptions);
|
115
|
-
});
|
116
|
-
} else {
|
117
|
-
$.extend(defaults, modalOptions);
|
118
|
-
}
|
119
|
-
|
120
|
-
// on Ctrl+A click fire `onSelectAll` event
|
121
|
-
$(window).bind('keydown',function(e){
|
122
|
-
if (!(e.ctrlKey && e.keyCode == 65)) {
|
123
|
-
return true;
|
124
|
-
}
|
125
|
-
|
126
|
-
if ( $('input:focus, textarea:focus').length > 0 ) {
|
127
|
-
return true;
|
128
|
-
}
|
129
|
-
|
130
|
-
var selectAllEvent = new $.Event('onSelectAll');
|
131
|
-
selectAllEvent.parentEvent = e;
|
132
|
-
$(window).trigger(selectAllEvent);
|
133
|
-
return true;
|
134
|
-
});
|
135
|
-
|
136
|
-
els.bind('keydown',function(e){
|
137
|
-
var modalFocusableElements = $(':focusable',$(this));
|
138
|
-
if(modalFocusableElements.filter(':last').is(':focus') && (e.which || e.keyCode) == 9){
|
139
|
-
e.preventDefault();
|
140
|
-
modalFocusableElements.filter(':first').focus();
|
141
|
-
}
|
142
|
-
});
|
143
|
-
|
144
|
-
return {
|
145
|
-
open: function(options) {
|
146
|
-
var el = els.get(0),
|
147
|
-
localOptions = $.extend({}, defaults, $(el).data(pluginNamespace+'.options'), options);
|
148
|
-
|
149
|
-
// close modal if opened
|
150
|
-
if($('.'+localOptions.overlayClass).length) {
|
151
|
-
$.modal().close();
|
152
|
-
}
|
153
|
-
|
154
|
-
var overlay = $('<div/>').addClass(localOptions.overlayClass).prependTo('body');
|
155
|
-
overlay.data(pluginNamespace+'.options', localOptions);
|
156
|
-
|
157
|
-
lockContainer(localOptions, overlay);
|
158
|
-
|
159
|
-
if(el) {
|
160
|
-
var openedModalElement = null;
|
161
|
-
if (!localOptions.cloning) {
|
162
|
-
overlay.data(pluginNamespace+'.el', el);
|
163
|
-
$(el).data(pluginNamespace+'.parent', $(el).parent());
|
164
|
-
openedModalElement = $(el).appendTo(overlay).show();
|
165
|
-
} else {
|
166
|
-
openedModalElement = $(el).clone(true).appendTo(overlay).show();
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
|
-
if(localOptions.closeOnEsc) {
|
171
|
-
$(document).bind('keyup.'+pluginNamespace, function(e){
|
172
|
-
if(e.keyCode === 27) {
|
173
|
-
$.modal().close(localOptions);
|
174
|
-
}
|
175
|
-
});
|
176
|
-
}
|
177
|
-
|
178
|
-
if(localOptions.closeOnOverlayClick) {
|
179
|
-
overlay.children().on('click.' + pluginNamespace, function(e){
|
180
|
-
e.stopPropagation();
|
181
|
-
});
|
182
|
-
$('.' + localOptions.overlayClass).on('click.' + pluginNamespace, function(e){
|
183
|
-
$.modal().close(localOptions);
|
184
|
-
});
|
185
|
-
}
|
186
|
-
|
187
|
-
$(document).bind('touchmove.'+pluginNamespace,function(e){
|
188
|
-
if(!$(e).parents('.' + localOptions.overlayClass)) {
|
189
|
-
e.preventDefault();
|
190
|
-
}
|
191
|
-
});
|
192
|
-
|
193
|
-
if(el) {
|
194
|
-
$(window).bind('onSelectAll',function(e){
|
195
|
-
e.parentEvent.preventDefault();
|
196
|
-
|
197
|
-
var range = null,
|
198
|
-
selection = null,
|
199
|
-
selectionElement = openedModalElement.get(0);
|
200
|
-
if (document.body.createTextRange) { //ms
|
201
|
-
range = document.body.createTextRange();
|
202
|
-
range.moveToElementText(selectionElement);
|
203
|
-
range.select();
|
204
|
-
} else if (window.getSelection) { //all others
|
205
|
-
selection = window.getSelection();
|
206
|
-
range = document.createRange();
|
207
|
-
range.selectNodeContents(selectionElement);
|
208
|
-
selection.removeAllRanges();
|
209
|
-
selection.addRange(range);
|
210
|
-
}
|
211
|
-
});
|
212
|
-
}
|
213
|
-
|
214
|
-
if(localOptions.onOpen) {
|
215
|
-
localOptions.onOpen(overlay, localOptions);
|
216
|
-
}
|
217
|
-
},
|
218
|
-
close: function(options) {
|
219
|
-
var el = els.get(0),
|
220
|
-
localOptions = $.extend({}, defaults, $(el).data(pluginNamespace+'.options'), options);
|
221
|
-
var overlay = $('.' + localOptions.overlayClass);
|
222
|
-
|
223
|
-
if ($.isFunction(localOptions.onBeforeClose)) {
|
224
|
-
if (localOptions.onBeforeClose(overlay, localOptions) === false) {
|
225
|
-
return;
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
if (!localOptions.cloning) {
|
230
|
-
if (!el) {
|
231
|
-
el = overlay.data(pluginNamespace+'.el');
|
232
|
-
}
|
233
|
-
$(el).hide().appendTo($(el).data(pluginNamespace+'.parent'));
|
234
|
-
}
|
235
|
-
|
236
|
-
overlay.remove();
|
237
|
-
unlockContainer(localOptions);
|
238
|
-
|
239
|
-
if(localOptions.closeOnEsc) {
|
240
|
-
$(document).unbind('keyup.'+pluginNamespace);
|
241
|
-
}
|
242
|
-
|
243
|
-
$(window).unbind('onSelectAll');
|
244
|
-
|
245
|
-
if(localOptions.onClose) {
|
246
|
-
localOptions.onClose(overlay, localOptions);
|
247
|
-
}
|
248
|
-
}
|
249
|
-
};
|
250
|
-
}
|
251
|
-
|
252
|
-
$.modal = function(options){
|
253
|
-
return init($(), options);
|
254
|
-
};
|
255
|
-
|
256
|
-
$.fn.modal = function(options) {
|
257
|
-
return init(this, options);
|
258
|
-
};
|
259
|
-
|
260
|
-
})(jQuery, window, document);
|