caboose-cms 0.2.31 → 0.2.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/modal.js +14 -9
- data/app/assets/javascripts/caboose/model/all.js +2 -0
- data/app/assets/javascripts/caboose/model/attribute.js +3 -1
- data/app/assets/javascripts/caboose/model/bound_checkbox.js +22 -11
- data/app/assets/javascripts/caboose/model/bound_checkbox_multiple.js +9 -7
- data/app/assets/javascripts/caboose/model/bound_richtext.js +137 -0
- data/app/assets/javascripts/caboose/model/bound_text.js +16 -6
- data/app/assets/javascripts/caboose/model/bound_textarea.js +2 -1
- data/app/assets/javascripts/caboose/model/model_binder.js +8 -6
- data/app/controllers/caboose/pages_controller.rb +5 -41
- data/app/controllers/caboose/roles_controller.rb +4 -4
- data/app/models/caboose/page.rb +15 -0
- data/app/models/caboose/role_plugin.rb +2 -1
- data/app/views/caboose/pages/edit.html.erb +2 -2
- data/app/views/caboose/pages/edit_content.html.erb +0 -1
- data/app/views/caboose/pages/index.html.erb +1 -2
- data/app/views/caboose/pages/show.html.erb +2 -2
- data/app/views/caboose/roles/edit.html.erb +24 -6
- data/lib/caboose/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWE5MzA0NDI3YzU4NTk3ZjIyMGFmYWU1MzNjMDBhMGFkNzhiMmE3NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWU5YWUyN2YyZjE1ZWU1MzUyOWFmZGRkMGYxZWZlZGE5ZDAwOWJhZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjcxOGJkOWI1ZDY3YjQ5MWQ2YTE3YTNmOGMzYTJjNmViMzQ3MzcwYjQwNjBi
|
10
|
+
ZDQ3OWVjNTliZGNlM2IxOWZkYzU3MTg2ZTAwMDIyNDRkOTk2YjExOGE2ZTBi
|
11
|
+
OWZlY2Q3NDA3MTUwNjY0YjFmOGIxOTk1YjliODBmYTQ4ZTEzMmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWRiMzQxYjE5OTIzYzg4ZjZjZTQ3ODE1OGEzNTJjYzUyZmJmZDdjMGJmZTlm
|
14
|
+
MGEyNjJiOGRiNWZiZDBhMDBjMzJmYWQ1YzZjMzI3YzVlMTIzNzFlODliZGMx
|
15
|
+
YmM0NGM5Njc3Mzg4YTU3N2MyYWU0NzdmOWFiYTU3NDliYTk1NGY=
|
@@ -12,6 +12,7 @@
|
|
12
12
|
//
|
13
13
|
//= require jquery
|
14
14
|
//= require jquery_ujs
|
15
|
+
//= require colorbox-rails
|
15
16
|
|
16
17
|
var CabooseModal = function(w, h) {
|
17
18
|
if (!h)
|
@@ -32,21 +33,25 @@ CabooseModal.prototype = {
|
|
32
33
|
resize: function(w, h) { this.width = w; this.height = h; this.colorbox(); },
|
33
34
|
|
34
35
|
// Resizes the height of the modal based on the content height
|
35
|
-
autosize: function(msg) {
|
36
|
-
if (msg)
|
37
|
-
$('#message').
|
36
|
+
autosize: function(msg, msg_container) {
|
37
|
+
if (msg)
|
38
|
+
$('#' + (msg_container ? msg_container : 'message')).empty().append(msg);
|
38
39
|
this.height = $('#modal_content').outerHeight(true);
|
39
40
|
this.colorbox();
|
40
41
|
},
|
41
42
|
|
42
|
-
colorbox: function() {
|
43
|
-
parent.$.fn.colorbox
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
colorbox: function() {
|
44
|
+
if (parent && parent.$.fn.colorbox)
|
45
|
+
{
|
46
|
+
parent.$.fn.colorbox.resize({
|
47
|
+
innerWidth: '' + this.width + 'px',
|
48
|
+
innerHeight: '' + this.height + 'px'
|
49
|
+
});
|
50
|
+
}
|
47
51
|
},
|
48
52
|
|
49
53
|
close: function() {
|
50
|
-
parent.$.fn.colorbox
|
54
|
+
if (parent && parent.$.fn.colorbox)
|
55
|
+
parent.$.fn.colorbox.close();
|
51
56
|
}
|
52
57
|
};
|
@@ -4,7 +4,9 @@
|
|
4
4
|
//= require caboose/model/model_binder
|
5
5
|
//= require caboose/model/bound_control
|
6
6
|
//= require caboose/model/bound_checkbox
|
7
|
+
//= require caboose/model/bound_checkbox_multiple
|
7
8
|
//= require caboose/model/bound_image
|
8
9
|
//= require caboose/model/bound_select
|
9
10
|
//= require caboose/model/bound_text
|
10
11
|
//= require caboose/model/bound_textarea
|
12
|
+
//= require caboose/model/bound_richtext
|
@@ -13,6 +13,8 @@ Attribute.prototype = {
|
|
13
13
|
value_clean: false,
|
14
14
|
text: false,
|
15
15
|
empty_text: 'empty',
|
16
|
+
fixed_placeholder: true,
|
17
|
+
align: 'left',
|
16
18
|
|
17
19
|
update_url: false,
|
18
20
|
options_url: false,
|
@@ -23,7 +25,7 @@ Attribute.prototype = {
|
|
23
25
|
$.ajax({
|
24
26
|
url: this.update_url,
|
25
27
|
type: 'put',
|
26
|
-
data: this.name + '=' + this.value,
|
28
|
+
data: this.name + '=' + encodeURIComponent(this.value),
|
27
29
|
success: function(resp) {
|
28
30
|
if (resp.success)
|
29
31
|
{
|
@@ -24,24 +24,35 @@ BoundCheckbox = BoundControl.extend({
|
|
24
24
|
.css('position', 'relative')
|
25
25
|
);
|
26
26
|
$('#'+this.el+'_container').empty();
|
27
|
-
|
28
|
-
|
29
|
-
.
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
if (this.attribute.fixed_placeholder)
|
28
|
+
{
|
29
|
+
$('#'+this.el+'_container').append($('<div/>')
|
30
|
+
.attr('id', this.placeholder)
|
31
|
+
.addClass('placeholder')
|
32
|
+
.append($('<span/>').html(this.attribute.nice_name + ': '))
|
33
|
+
);
|
34
|
+
}
|
35
|
+
var cb = $('<input/>')
|
33
36
|
.attr('id', this.el)
|
34
|
-
.attr('type', 'checkbox')
|
35
|
-
.css('left', $('#'+this.placeholder).outerWidth() + 10)
|
37
|
+
.attr('type', 'checkbox')
|
36
38
|
.attr('checked', this.attribute.value)
|
37
39
|
.on('change', function() {
|
38
40
|
this2.save();
|
39
|
-
})
|
40
|
-
)
|
41
|
+
});
|
42
|
+
if (this.attribute.align == 'right')
|
43
|
+
cb.css('left', this.attribute.width - 10)
|
44
|
+
else if (this.attribute.align == 'center')
|
45
|
+
cb.css('left', Math.floor($('#'+this.el+'_container').outerWidth()/2))
|
46
|
+
else // left
|
47
|
+
cb.css('left', $('#'+this.placeholder).outerWidth() + 10)
|
48
|
+
$('#'+this.el+'_container').append(cb);
|
49
|
+
|
41
50
|
$('#'+this.el+'_container').append($('<input/>')
|
51
|
+
.attr('type', 'text')
|
42
52
|
.attr('id', this.el + '_background')
|
43
53
|
.attr('disabled', true)
|
44
|
-
|
54
|
+
//.css('background', '#fff')
|
55
|
+
.addClass('checkbox_background')
|
45
56
|
);
|
46
57
|
if (this.attribute.width)
|
47
58
|
$('#'+this.el+'_background').css('width' , this.attribute.width);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
BoundCheckboxMultiple = BoundControl.extend({
|
3
3
|
|
4
4
|
//el: false,
|
5
5
|
//model: false,
|
@@ -40,17 +40,19 @@ BoundCheckbox = BoundControl.extend({
|
|
40
40
|
|
41
41
|
var this2 = this;
|
42
42
|
this.attribute.populate_options(function() {
|
43
|
+
|
43
44
|
var tbody = $('<tbody/>');
|
44
|
-
$.each(this2.options, function(i, option) {
|
45
|
+
$.each(this2.attribute.options, function(i, option) {
|
46
|
+
|
45
47
|
tbody.append($('<tr/>')
|
46
48
|
.append($('<td/>')
|
47
49
|
.attr('id', this2.el + '_' + i)
|
48
50
|
.attr('type', 'checkbox')
|
49
|
-
.attr('checked', this2.attribute.value)
|
51
|
+
.attr('checked', this2.attribute.value[option.value])
|
50
52
|
.on('change', function() {
|
51
|
-
//this2.binder.cancel_active();
|
52
|
-
//this2.binder.active_control = this;
|
53
|
-
//this2.save();
|
53
|
+
// this2.binder.cancel_active();
|
54
|
+
// this2.binder.active_control = this;
|
55
|
+
// this2.save();
|
54
56
|
})
|
55
57
|
)
|
56
58
|
.append($('<label/>')
|
@@ -62,7 +64,7 @@ BoundCheckbox = BoundControl.extend({
|
|
62
64
|
$('#'+this.el+'_container').append(
|
63
65
|
$('<table/>').append(tbody)
|
64
66
|
);
|
65
|
-
);
|
67
|
+
});
|
66
68
|
},
|
67
69
|
|
68
70
|
view: function() {
|
@@ -0,0 +1,137 @@
|
|
1
|
+
|
2
|
+
BoundRichText = BoundControl.extend({
|
3
|
+
|
4
|
+
//el: false,
|
5
|
+
//model: false,
|
6
|
+
//attribute: false,
|
7
|
+
//binder: false,
|
8
|
+
|
9
|
+
width: false,
|
10
|
+
|
11
|
+
init: function(params) {
|
12
|
+
for (var thing in params)
|
13
|
+
this[thing] = params[thing];
|
14
|
+
|
15
|
+
this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
|
16
|
+
|
17
|
+
$('#'+this.el).wrap($('<div/>').attr('id', this.el + '_container').css('position', 'relative'));
|
18
|
+
$('#'+this.el+'_container').empty();
|
19
|
+
$('#'+this.el+'_container').append($('<textarea/>').attr('id', this.el).attr('class', 'tinymce').attr('placeholder', 'empty').val(this.attribute.value));
|
20
|
+
//$('#'+this.el+'_container').append($('<div/>').attr('id', this.el + '_placeholder').addClass('placeholder').append($('<span/>').html(this.attribute.nice_name + ': ')));
|
21
|
+
if (this.attribute.width) $('#'+this.el).css('width' , this.attribute.width);
|
22
|
+
if (this.attribute.height) $('#'+this.el).css('height' , this.attribute.height);
|
23
|
+
var h = $('#'+this.el+'_placeholder').outerHeight();
|
24
|
+
$('#'+this.el).attr('placeholder', 'empty').css('padding-top', '+=' + h).css('height', '-=' + h);
|
25
|
+
|
26
|
+
var this2 = this;
|
27
|
+
$('#'+this.el).on('keyup', function(e) {
|
28
|
+
if (e.keyCode == 27) this2.cancel(); // Escape
|
29
|
+
//if (e.keyCode == 13) this2.save(); // Enter
|
30
|
+
|
31
|
+
if ($('#'+this2.el).val() != this2.attribute.value_clean)
|
32
|
+
{
|
33
|
+
this2.show_controls();
|
34
|
+
$('#'+this2.el).addClass('dirty');
|
35
|
+
}
|
36
|
+
else
|
37
|
+
$('#'+this2.el).removeClass('dirty');
|
38
|
+
});
|
39
|
+
$('#'+this.el).on('blur', function() { this2.save(); });
|
40
|
+
},
|
41
|
+
|
42
|
+
show_controls: function() {
|
43
|
+
if ($('#'+this.el+'_controls').length)
|
44
|
+
return;
|
45
|
+
var w = $('#'+this.el).outerWidth();
|
46
|
+
var this2 = this;
|
47
|
+
$('#'+this.el+'_container').prepend($('<div/>')
|
48
|
+
.attr('id', this.el + '_controls')
|
49
|
+
.addClass('bound_textarea_controls')
|
50
|
+
.css('position', 'absolute')
|
51
|
+
.css('top', 0)
|
52
|
+
.css('left', w - 148)
|
53
|
+
.css('width', 148)
|
54
|
+
.css('overflow', 'hidden')
|
55
|
+
.append($('<div/>')
|
56
|
+
.css('width', 148)
|
57
|
+
.css('margin-left', 148)
|
58
|
+
.append($('<a/>').html('Save' ).addClass('save' ).css('width', 60).attr('href', '#').click(function(event) { event.preventDefault(); this2.save(); }))
|
59
|
+
.append($('<a/>').html('Discard').addClass('discard').css('width', 80).attr('href', '#').click(function(event) { event.preventDefault(); this2.cancel(); }))
|
60
|
+
)
|
61
|
+
);
|
62
|
+
$('#'+this.el+'_controls div').animate({ 'margin-left': 0 }, 300);
|
63
|
+
},
|
64
|
+
|
65
|
+
hide_controls: function() {
|
66
|
+
if (!$('#'+this.el+'_controls').length)
|
67
|
+
return;
|
68
|
+
var this2 = this;
|
69
|
+
$('#'+this.el+'_controls div').animate({ 'margin-left': 100 }, 300, function() {
|
70
|
+
$('#'+this2.el+'_controls').remove();
|
71
|
+
});
|
72
|
+
},
|
73
|
+
|
74
|
+
save: function() {
|
75
|
+
|
76
|
+
tinymce.triggerSave();
|
77
|
+
|
78
|
+
this.attribute.value = $('#'+this.el).val();
|
79
|
+
if (this.attribute.value == this.attribute.value_clean)
|
80
|
+
return;
|
81
|
+
|
82
|
+
this.hide_controls();
|
83
|
+
this.show_loader();
|
84
|
+
var this2 = this;
|
85
|
+
this.model.save(this.attribute, function(resp) {
|
86
|
+
if (resp.error)
|
87
|
+
{
|
88
|
+
this2.hide_loader();
|
89
|
+
this2.error(resp.error);
|
90
|
+
}
|
91
|
+
else
|
92
|
+
{
|
93
|
+
this2.show_check(500);
|
94
|
+
$('#'+this2.el).val(this2.attribute.value);
|
95
|
+
$('#'+this2.el).removeClass('dirty');
|
96
|
+
|
97
|
+
if (this2.binder.success)
|
98
|
+
this2.binder.success(this2);
|
99
|
+
}
|
100
|
+
});
|
101
|
+
},
|
102
|
+
|
103
|
+
cancel: function() {
|
104
|
+
|
105
|
+
if ($('#'+this.el).val() != this.attribute.value_clean)
|
106
|
+
{
|
107
|
+
if (confirm('This box has unsaved changes. Hit OK to save changes, Cancel to discard.'))
|
108
|
+
{
|
109
|
+
this.attribute.value = $('#'+this.el).val();
|
110
|
+
this.attribute.value_clean = $('#'+this.el).val();
|
111
|
+
this.save();
|
112
|
+
}
|
113
|
+
}
|
114
|
+
this.attribute.value = this.attribute.value_clean;
|
115
|
+
$('#'+this.el).val(this.attribute.value);
|
116
|
+
$('#'+this.el).removeClass('dirty');
|
117
|
+
|
118
|
+
if ($('#'+this.el+'_check').length)
|
119
|
+
this.hide_check();
|
120
|
+
},
|
121
|
+
|
122
|
+
error: function(str) {
|
123
|
+
if (!$('#'+this.el+'_message').length)
|
124
|
+
{
|
125
|
+
$('#'+this.el+'_container').append($('<div/>')
|
126
|
+
.attr('id', this.el + '_message')
|
127
|
+
.css('width', $('#'+this.el).outerWidth())
|
128
|
+
);
|
129
|
+
}
|
130
|
+
$('#'+this.el+'_message').hide();
|
131
|
+
$('#'+this.el+'_message').html("<p class='note error'>" + str + "</p>");
|
132
|
+
$('#'+this.el+'_message').slideDown();
|
133
|
+
var this2 = this;
|
134
|
+
setTimeout(function() { $('#'+this2.el+'_message').slideUp(function() { $(this).empty(); }); }, 3000);
|
135
|
+
}
|
136
|
+
|
137
|
+
});
|
@@ -13,15 +13,25 @@ BoundText = BoundControl.extend({
|
|
13
13
|
for (var thing in params)
|
14
14
|
this[thing] = params[thing];
|
15
15
|
|
16
|
-
this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
|
17
|
-
|
16
|
+
this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
|
18
17
|
$('#'+this.el).wrap($('<div/>').attr('id', this.el + '_container').css('position', 'relative'));
|
19
18
|
$('#'+this.el+'_container').empty();
|
20
|
-
$('#'+this.el+'_container').append($('<input/>')
|
21
|
-
|
19
|
+
$('#'+this.el+'_container').append($('<input/>')
|
20
|
+
.attr('id', this.el)
|
21
|
+
.attr('type', 'text')
|
22
|
+
.attr('placeholder', this.attribute.fixed_placeholder ? 'empty' : this.attribute.nice_name)
|
23
|
+
.css('text-align', this.attribute.align)
|
24
|
+
.val(this.attribute.value)
|
25
|
+
);
|
26
|
+
|
27
|
+
if (this.attribute.fixed_placeholder)
|
28
|
+
$('#'+this.el+'_container').append($('<div/>').attr('id', this.el + '_placeholder').addClass('placeholder').append($('<span/>').html(this.attribute.nice_name + ': ')));
|
22
29
|
if (this.attribute.width) $('#'+this.el).css('width' , this.attribute.width);
|
23
|
-
|
24
|
-
|
30
|
+
if (this.attribute.fixed_placeholder)
|
31
|
+
{
|
32
|
+
var w = $('#'+this.el+'_placeholder').outerWidth();
|
33
|
+
$('#'+this.el).attr('placeholder', 'empty').css('padding-left', '+=' + w).css('width', '-=' + w);
|
34
|
+
}
|
25
35
|
|
26
36
|
var this2 = this;
|
27
37
|
$('#'+this.el).on('keyup', function(e) {
|
@@ -72,10 +72,11 @@ BoundTextarea = BoundControl.extend({
|
|
72
72
|
},
|
73
73
|
|
74
74
|
save: function() {
|
75
|
+
|
75
76
|
this.attribute.value = $('#'+this.el).val();
|
76
77
|
if (this.attribute.value == this.attribute.value_clean)
|
77
78
|
return;
|
78
|
-
|
79
|
+
|
79
80
|
this.hide_controls();
|
80
81
|
this.show_loader();
|
81
82
|
var this2 = this;
|
@@ -31,13 +31,15 @@ ModelBinder.prototype = {
|
|
31
31
|
model: this2.model,
|
32
32
|
attribute: attrib,
|
33
33
|
binder: this2
|
34
|
-
};
|
34
|
+
};
|
35
35
|
var control = false;
|
36
|
-
if (attrib.type == 'text')
|
37
|
-
else if (attrib.type == 'select')
|
38
|
-
else if (attrib.type == 'checkbox')
|
39
|
-
else if (attrib.type == '
|
40
|
-
else if (attrib.type == '
|
36
|
+
if (attrib.type == 'text') control = new BoundText(opts);
|
37
|
+
else if (attrib.type == 'select') control = new BoundSelect(opts);
|
38
|
+
else if (attrib.type == 'checkbox') control = new BoundCheckbox(opts);
|
39
|
+
else if (attrib.type == 'checkbox-multiple') control = new BoundCheckboxMultiple(opts);
|
40
|
+
else if (attrib.type == 'textarea') control = new BoundTextarea(opts);
|
41
|
+
else if (attrib.type == 'richtext') control = new BoundRichText(opts);
|
42
|
+
else if (attrib.type == 'image') control = new BoundImage(opts);
|
41
43
|
|
42
44
|
this2.controls.push();
|
43
45
|
});
|
@@ -9,21 +9,6 @@ module Caboose
|
|
9
9
|
# GET /pages
|
10
10
|
def index
|
11
11
|
end
|
12
|
-
|
13
|
-
def view_formatted_resources(page)
|
14
|
-
resources = { js: [], css: [] }
|
15
|
-
return resources if page.linked_resources.nil?
|
16
|
-
page.linked_resources.each_line do |r|
|
17
|
-
r.chomp!
|
18
|
-
case r
|
19
|
-
when /\.js$/
|
20
|
-
resources[:js] += [r]
|
21
|
-
when /\.css$/
|
22
|
-
resources[:css] += [r]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
return resources
|
26
|
-
end
|
27
12
|
|
28
13
|
# GET /pages/:id
|
29
14
|
def show
|
@@ -60,8 +45,6 @@ module Caboose
|
|
60
45
|
@subnav = Caboose::Page.subnav(@page, session['use_redirect_urls'], @user)
|
61
46
|
|
62
47
|
#@subnav.links = @tasks.collect {|href, task| {'href' => href, 'text' => task, 'is_current' => uri == href}}
|
63
|
-
|
64
|
-
@resources = view_formatted_resources(@page)
|
65
48
|
|
66
49
|
end
|
67
50
|
|
@@ -125,7 +108,6 @@ module Caboose
|
|
125
108
|
def edit
|
126
109
|
return unless user_is_allowed('pages', 'edit')
|
127
110
|
@page = Page.find(params[:id])
|
128
|
-
@resources = view_formatted_resources(@page)
|
129
111
|
end
|
130
112
|
|
131
113
|
# GET /pages/1/edit-title
|
@@ -268,38 +250,20 @@ module Caboose
|
|
268
250
|
page[name.to_sym] = value
|
269
251
|
|
270
252
|
when 'linked_resources'
|
271
|
-
result =
|
253
|
+
result = []
|
272
254
|
value.each_line do |line|
|
273
|
-
|
255
|
+
line.chomp!
|
274
256
|
line.strip!
|
275
257
|
next if line.empty?
|
276
258
|
|
277
|
-
|
278
|
-
if comps.length < 2
|
279
|
-
resp.error = "Resource '#{line}' has an unspecified file type. (e.g. given 'myScript.js', '.js' would specify a javascript file type.)"
|
280
|
-
save = false
|
281
|
-
next
|
282
|
-
end
|
283
|
-
|
284
|
-
case comps.last
|
285
|
-
when 'js', 'css'
|
286
|
-
if value =~ URI::regexp()
|
287
|
-
uri = URI.parse(value)
|
288
|
-
if !(uri =~ URI::HTTP || uri =~ URI::HTTPS)
|
289
|
-
resp.error = "Resource '#{line}' is an unrecognized URI format."
|
290
|
-
save = false
|
291
|
-
end
|
292
|
-
end
|
293
|
-
else
|
259
|
+
if !(line.ends_with('.js') || line.ends_with('.css'))
|
294
260
|
resp.error = "Resource '#{line}' has an unsupported file type ('#{comps.last}')."
|
295
261
|
save = false
|
296
|
-
next
|
297
262
|
end
|
298
263
|
|
299
|
-
result
|
300
|
-
result += line
|
264
|
+
result << line
|
301
265
|
end
|
302
|
-
page.linked_resources = result
|
266
|
+
page.linked_resources = result.join("\n")
|
303
267
|
|
304
268
|
when 'content_format'
|
305
269
|
page.content_format = value
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Caboose
|
2
2
|
class RolesController < ApplicationController
|
3
|
-
layout 'caboose/
|
3
|
+
layout 'caboose/modal'
|
4
4
|
|
5
5
|
def before_action
|
6
6
|
@page = Page.page_with_uri('/admin')
|
@@ -61,15 +61,15 @@ module Caboose
|
|
61
61
|
role.description = value
|
62
62
|
when "parent_id"
|
63
63
|
value = value.to_i
|
64
|
-
if
|
64
|
+
if role.id == value
|
65
65
|
resp.error = "You can't set the parent to be this role."
|
66
66
|
save = false
|
67
|
-
elsif
|
67
|
+
elsif role.is_ancestor_of?(value)
|
68
68
|
resp.error = "You can't set the parent to be one of the child roles."
|
69
69
|
save = false
|
70
70
|
else
|
71
71
|
role.parent_id = value
|
72
|
-
if
|
72
|
+
if value == -1
|
73
73
|
resp.attributes = { 'parent_id' => { 'text' => '[No parent]' }}
|
74
74
|
else
|
75
75
|
p = Role.find(value)
|
data/app/models/caboose/page.rb
CHANGED
@@ -327,4 +327,19 @@ class Caboose::Page < ActiveRecord::Base
|
|
327
327
|
return self.is_child(parent_id, pid)
|
328
328
|
end
|
329
329
|
|
330
|
+
def linked_resources_map
|
331
|
+
resources = { js: [], css: [] }
|
332
|
+
return resources if self.linked_resources.nil?
|
333
|
+
self.linked_resources.each_line do |r|
|
334
|
+
r.chomp!
|
335
|
+
case r
|
336
|
+
when /\.js$/
|
337
|
+
resources[:js] << r
|
338
|
+
when /\.css$/
|
339
|
+
resources[:css] << r
|
340
|
+
end
|
341
|
+
end
|
342
|
+
return resources
|
343
|
+
end
|
344
|
+
|
330
345
|
end
|
@@ -11,7 +11,8 @@ class Caboose::RolePlugin < Caboose::CaboosePlugin
|
|
11
11
|
if (user.is_allowed('roles', 'view'))
|
12
12
|
item['children'] << {
|
13
13
|
'href' => '/admin/roles',
|
14
|
-
'text' => 'View All Roles'
|
14
|
+
'text' => 'View All Roles',
|
15
|
+
'modal' => true
|
15
16
|
}
|
16
17
|
end
|
17
18
|
if (user.is_allowed('roles', 'add'))
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div id='editmode_content_container' ><%= @page.content == nil || @page.content.length == 0 ? 'No content.' : (raw @page.content) %></div>
|
3
3
|
|
4
4
|
<% content_for :caboose_css do %>
|
5
|
-
<% @
|
5
|
+
<% @page.linked_resources_map[:css].each do |r| %>
|
6
6
|
<!--link type='text/css' rel='stylesheet' href="<%= r %>" /-->
|
7
7
|
<%= stylesheet_link_tag r %>
|
8
8
|
<% end %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<% content_for :caboose_js do %>
|
14
14
|
|
15
|
-
<% @
|
15
|
+
<% @page.linked_resources_map[:js].each do |r| %>
|
16
16
|
<!--script type='text/javascript' src="<%= r %>" ></script-->
|
17
17
|
<%= javascript_include_tag r %>
|
18
18
|
<% end %>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
2
|
<% content_for :caboose_css do %>
|
3
|
-
<% @
|
3
|
+
<% @page.linked_resources_map[:css].each do |r| %>
|
4
4
|
<!--link type='text/css' rel='stylesheet' href="<%= r %>" /-->
|
5
5
|
<%= stylesheet_link_tag r %>
|
6
6
|
<% end %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<% content_for :caboose_js do %>
|
10
|
-
<% @
|
10
|
+
<% @page.linked_resources_map[:js].each do |r| %>
|
11
11
|
<!--script type='text/javascript' src="<%= r %>" ></script-->
|
12
12
|
<%= javascript_include_tag r %>
|
13
13
|
<% end %>
|
@@ -1,11 +1,21 @@
|
|
1
1
|
|
2
|
-
<h1>
|
3
|
-
<div id=
|
2
|
+
<h1>Editing Role</h1>
|
3
|
+
<div id="role_<%= @role.id %>_name"></div>
|
4
|
+
<div id="role_<%= @role.id %>_parent_id"></div>
|
5
|
+
<div id="role_<%= @role.id %>_description"></div>
|
6
|
+
<div id="role_<%= @role.id %>_members"></div>
|
7
|
+
<div id="role_<%= @role.id %>_permissions"></div>
|
8
|
+
<div id="message"></div>
|
4
9
|
|
5
10
|
<% content_for :caboose_js do %>
|
6
11
|
<%= javascript_include_tag "caboose/model/all" %>
|
7
12
|
<script type="text/javascript">
|
8
13
|
|
14
|
+
var modal = false;
|
15
|
+
$(window).load(function() {
|
16
|
+
modal = new CabooseModal(600, 600);
|
17
|
+
});
|
18
|
+
|
9
19
|
$(document).ready(function() {
|
10
20
|
new ModelBinder({
|
11
21
|
name: 'Role',
|
@@ -23,29 +33,37 @@ $(document).ready(function() {
|
|
23
33
|
text: "<%= @role.parent.nil? ? '[No parent]' : @role.parent.name %>",
|
24
34
|
show_controls: true,
|
25
35
|
loading_message: 'Getting roles...',
|
26
|
-
options_url: '/admin/roles/options'
|
36
|
+
options_url: '/admin/roles/options',
|
37
|
+
width: 590,
|
38
|
+
message: 'message'
|
27
39
|
},
|
28
|
-
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: "<%= @role.name %>" },
|
29
|
-
{ name: 'description' , nice_name: 'Description' , type: 'text' , value: "<%= @role.description %>" },
|
40
|
+
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: "<%= @role.name %>" , width: 590 , message: 'message' },
|
41
|
+
{ name: 'description' , nice_name: 'Description' , type: 'text' , value: "<%= @role.description %>" , width: 590 , message: 'message' },
|
30
42
|
{
|
31
43
|
name: 'members',
|
44
|
+
nice_name: 'Members',
|
32
45
|
type: 'checkbox-multiple',
|
33
46
|
value: <%= @role.users.collect{|u| u.id}.to_json %>,
|
34
47
|
text: "<%= raw @role.users.order('last_name, first_name').collect{|u| "#{u.first_name} #{u.last_name}"}.join('<br />') %>",
|
35
48
|
loading_message: 'Getting users...',
|
36
49
|
options_url: '/admin/users/options',
|
50
|
+
width: 590,
|
51
|
+
message: 'message'
|
37
52
|
},
|
38
53
|
{
|
39
54
|
name: 'permissions',
|
55
|
+
nice_name: 'Permissions',
|
40
56
|
type: 'checkbox-multiple',
|
41
57
|
value: <%= @role.permissions.collect{|p| p.id}.to_json %>,
|
42
58
|
text: "<%= raw @role.permissions.order('resource, action').collect{|p| "#{p.resource}_#{p.action}"}.join('<br />') %>",
|
43
59
|
loading_message: 'Getting permissions...',
|
44
60
|
options_url: '/admin/permissions/options',
|
61
|
+
width: 590,
|
62
|
+
message: 'message'
|
45
63
|
}
|
46
64
|
],
|
47
65
|
on_load: function() { modal.autosize(); }
|
48
|
-
});
|
66
|
+
});
|
49
67
|
|
50
68
|
/*var user = new Model({
|
51
69
|
name: 'Role',
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- app/assets/javascripts/caboose/model/bound_checkbox_multiple.js
|
149
149
|
- app/assets/javascripts/caboose/model/bound_control.js
|
150
150
|
- app/assets/javascripts/caboose/model/bound_image.js
|
151
|
+
- app/assets/javascripts/caboose/model/bound_richtext.js
|
151
152
|
- app/assets/javascripts/caboose/model/bound_select.js
|
152
153
|
- app/assets/javascripts/caboose/model/bound_text.js
|
153
154
|
- app/assets/javascripts/caboose/model/bound_textarea.js
|