caboose-cms 0.5.48 → 0.5.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/controllers/caboose/categories_controller.rb +8 -10
- data/app/views/caboose/categories/admin_edit.html.erb +38 -47
- data/app/views/caboose/categories/admin_index.html.erb +24 -1
- data/app/views/caboose/categories/admin_new.html.erb +59 -35
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Zjg2Mjg4ZTQwMDBmNzg1ZGEyOWVjODE3YzY0MzU3NzI1Y2ZkZmI0MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmZlNjVmZTMyZDNiNzNjMzEwZjJkZjhlNTU5ZGY5OGJmNTU0MGQzNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWFiYTYxYmVjNjIwZmE5NzRkN2U1NWI3YmQ2MjMwNWYyYTkxMDI5Y2VmYmI1
|
10
|
+
NmY1YTlkNjk2YjI5YzIzNGViMDNlMmRhN2NjMTczMjMyYzk3YTM1NTExMDNi
|
11
|
+
M2NmNTRiOTNlNDAxYTcyZDhmYjUxMTNhMzYwOTgzNTU1NjU5M2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzAyYTI0ZGZiNGM5ZmZhZjVjNTJiNTAwZjQ0NjUxYjc2YzJiN2JiN2I2YWRk
|
14
|
+
MjUzNjc3MzgwMjM3NWU4ZjVkY2FlOTE1OTI2N2Y4MDA4Y2JhYmQ1ZDEwY2Iw
|
15
|
+
YzIwOWFhNmYyMGQzMDNlZTM5YjI2YTc3MzVlMjIwMDQwMDU1NTc=
|
@@ -114,21 +114,19 @@ module Caboose
|
|
114
114
|
|
115
115
|
# GET /admin/categories/options
|
116
116
|
def admin_options
|
117
|
-
options = []
|
118
|
-
cat = Category.where("site_id = ? and parent_id is null").first
|
117
|
+
@options = []
|
118
|
+
cat = Category.where("site_id = ? and parent_id is null", @site.id).first
|
119
119
|
if cat.nil?
|
120
120
|
cat = Category.create(:site_id => @site.id, :name => 'All Products', :url => '/')
|
121
|
-
end
|
122
|
-
cat
|
123
|
-
|
124
|
-
end
|
125
|
-
render :json => options
|
121
|
+
end
|
122
|
+
admin_options_helper(cat, '')
|
123
|
+
render :json => @options
|
126
124
|
end
|
127
125
|
|
128
|
-
def admin_options_helper(
|
129
|
-
options << { :value => cat.id, :text => "#{prefix}#{cat.name}" }
|
126
|
+
def admin_options_helper(cat, prefix)
|
127
|
+
@options << { :value => cat.id, :text => "#{prefix}#{cat.name}" }
|
130
128
|
cat.children.each do |c|
|
131
|
-
admin_options_helper(
|
129
|
+
admin_options_helper(c, "#{prefix} - ")
|
132
130
|
end
|
133
131
|
end
|
134
132
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<h1>Edit Category</h1>
|
2
2
|
|
3
|
+
<p><div class="push-below" id="category_<%= @category.id %>_parent_id"></div></p>
|
3
4
|
<p><div class="push-below" id="category_<%= @category.id %>_name"></div></p>
|
4
5
|
<p><div class="push-below" id="category_<%= @category.id %>_slug"></div></p>
|
5
6
|
<p><div class="push-below" id="category_<%= @category.id %>_status"></div></p>
|
@@ -28,52 +29,42 @@
|
|
28
29
|
<% end %>
|
29
30
|
|
30
31
|
<% content_for :caboose_js do %>
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
modal.autosize("<p class='loading'>Deleting the category...</p>");
|
68
|
-
|
69
|
-
$.ajax({
|
70
|
-
url: '/admin/categories/' + cat_id,
|
71
|
-
type: 'delete',
|
72
|
-
success: function(resp) {
|
73
|
-
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
74
|
-
if (resp.redirect) window.location = resp.redirect;
|
75
|
-
}
|
76
|
-
});
|
32
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
33
|
+
<script type='text/javascript'>
|
34
|
+
|
35
|
+
$(document).ready(function() {
|
36
|
+
m = new ModelBinder({
|
37
|
+
name: 'Category',
|
38
|
+
id: <%= @category.id %>,
|
39
|
+
update_url: '/admin/categories/<%= @category.id %>',
|
40
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
41
|
+
attributes: [
|
42
|
+
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(@category.name) %> , width: 400 },
|
43
|
+
{ name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@category.slug) %> , width: 400 },
|
44
|
+
{ name: 'status', nice_name: 'Status', type: 'select', value: <%= raw Caboose.json(@category.status) %> , width: 400 , text: <%= raw Caboose.json(@category.status) %>, options_url: '/admin/categories/status-options' },
|
45
|
+
{ name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(@category.image.url(:medium)) %> , width: 200 }
|
46
|
+
]
|
47
|
+
});
|
48
|
+
});
|
49
|
+
|
50
|
+
function delete_category(cat_id, confirm) {
|
51
|
+
if (!confirm) {
|
52
|
+
var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
|
53
|
+
.append("Are you sure you want to delete the category?<br />This can't be undone.<br /><br />")
|
54
|
+
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_category(cat_id, true); })).append(' ')
|
55
|
+
.append($('<input/>').attr('type', 'button').val('No').click(function() { $('#message').empty(); }));
|
56
|
+
$('#message').empty().append(p);
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
$('#message').html("<p class='loading'>Deleting the category...</p>");
|
60
|
+
$.ajax({
|
61
|
+
url: '/admin/categories/' + cat_id,
|
62
|
+
type: 'delete',
|
63
|
+
success: function(resp) {
|
64
|
+
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
65
|
+
if (resp.redirect) window.location = resp.redirect;
|
77
66
|
}
|
78
|
-
|
67
|
+
});
|
68
|
+
}
|
69
|
+
</script>
|
79
70
|
<% end %>
|
@@ -1,6 +1,29 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
top_cat = Caboose::Category.where("site_id = ? and parent_id is null", @site.id).first
|
4
|
+
if top_cat.nil?
|
5
|
+
top_cat = Category.create(:site_id => @site.id, :name => 'All Products', :url => '/')
|
6
|
+
end
|
7
|
+
|
8
|
+
def category_list(cat)
|
9
|
+
str = "<ul>"
|
10
|
+
str << category_list_items(cat)
|
11
|
+
str << "</ul>"
|
12
|
+
return str
|
13
|
+
end
|
14
|
+
|
15
|
+
def category_list_items(cat)
|
16
|
+
str = "<li><a href='/admin/categories/#{cat.id}'>#{cat.name}</a>"
|
17
|
+
cat.children.each{ |kid| str << category_list(kid) } if cat.children && cat.children.count > 0
|
18
|
+
str << "</li>"
|
19
|
+
return str
|
20
|
+
end
|
21
|
+
|
22
|
+
%>
|
23
|
+
|
1
24
|
<h1>Categories</h1>
|
2
25
|
<a href='/admin/categories/new'>New Category</a>
|
3
|
-
<%= category_list %>
|
26
|
+
<%= category_list(top_cat) %>
|
4
27
|
|
5
28
|
<% content_for :caboose_js do %>
|
6
29
|
<script type='text/javascript'>
|
@@ -1,20 +1,13 @@
|
|
1
1
|
<h1>New Category</h1>
|
2
2
|
|
3
3
|
<form action="/admin/categories" method="post" id="new_form">
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<%= category_select('parent_id') %>
|
12
|
-
|
13
|
-
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
14
|
-
<input type="text" name="name" placeholder="Category Name" />
|
15
|
-
|
16
|
-
<div id="message"></div>
|
17
|
-
|
4
|
+
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
5
|
+
<p><select name='parent_id' id='parent_id'></select><%
|
6
|
+
# category_select('parent_id')
|
7
|
+
%></p>
|
8
|
+
<p><input type="text" name="name" id='name' placeholder="Category Name" /></p>
|
9
|
+
<p><input type='checkbox' name='stay' id='stay' value='1' /> Stay here so I can add another category</p>
|
10
|
+
<div id="message"></div>
|
18
11
|
<input type="button" value="< Back" onclick="window.location='/admin/categories';" />
|
19
12
|
<input type="submit" value="Add Category" onclick="add_category(); return false" />
|
20
13
|
</form>
|
@@ -36,27 +29,58 @@
|
|
36
29
|
<% end %>
|
37
30
|
|
38
31
|
<% content_for :caboose_js do %>
|
39
|
-
|
32
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
33
|
+
<script type='text/javascript'>
|
34
|
+
|
35
|
+
$(document).ready(function() {
|
36
|
+
get_category_options();
|
37
|
+
});
|
38
|
+
|
39
|
+
function add_category() {
|
40
|
+
$('#message').html("<p class='loading'>Adding category...</p>");
|
41
|
+
var stay = $('#stay').prop('checked');
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
$.ajax({
|
44
|
+
url: '/admin/categories',
|
45
|
+
type: 'post',
|
46
|
+
data: $('#new_form').serialize(),
|
47
|
+
success: function(resp) {
|
48
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
49
|
+
if (resp.redirect)
|
50
|
+
{
|
51
|
+
if (stay)
|
52
|
+
{
|
53
|
+
$('#name').val('');
|
54
|
+
get_category_options();
|
55
|
+
$('#message').html("<p class='note succes'>The category has been added successfully.</p>");
|
56
|
+
setTimeout(function() { $('#message').empty(); }, 2000);
|
57
|
+
}
|
58
|
+
else if (resp.redirect)
|
59
|
+
window.location = resp.redirect;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
});
|
63
|
+
}
|
64
|
+
|
65
|
+
function get_category_options()
|
66
|
+
{
|
67
|
+
var select = $('#parent_id');
|
68
|
+
var current_value = select.val();
|
69
|
+
|
70
|
+
$.ajax({
|
71
|
+
url: '/admin/categories/options',
|
72
|
+
type: 'get',
|
73
|
+
success: function(options) {
|
74
|
+
select.empty();
|
75
|
+
$.each(options, function(i, option) {
|
76
|
+
var opt = $('<option/>').val(option['value']).html(option['text']);
|
77
|
+
if (option['value'] == current_value)
|
78
|
+
opt.prop('selected', true);
|
79
|
+
select.append(opt);
|
80
|
+
});
|
54
81
|
}
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
modal = new CabooseModal(800);
|
60
|
-
});
|
61
|
-
</script>
|
82
|
+
});
|
83
|
+
}
|
84
|
+
|
85
|
+
</script>
|
62
86
|
<% end %>
|
data/lib/caboose/version.rb
CHANGED