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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjAzMmQ2OTFiMjYzYWQ1ODU2OWI5NDFiNDZjMDY3MmI3NjM0NzQyZQ==
4
+ Zjg2Mjg4ZTQwMDBmNzg1ZGEyOWVjODE3YzY0MzU3NzI1Y2ZkZmI0MA==
5
5
  data.tar.gz: !binary |-
6
- MDViNjhlM2EwNGI1MGU4MGYzYjAzZDEyYjlhY2VlODYxMTVlZjRiZA==
6
+ YmZlNjVmZTMyZDNiNzNjMzEwZjJkZjhlNTU5ZGY5OGJmNTU0MGQzNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Njg4MzA5Yjc5MWQ2OWI5OTE3MGVkNTFhOGRkOWMxZDYwYzY0ZjhlY2M1Y2Yy
10
- OGNlM2M3MjQ2YmRlMGI2NWYxOWUyZTM5ZjdhNmMwYTE0OGYyN2ZiY2ZmYjk3
11
- ODEzNmMzM2Q4OTU1YzE4ZTk0ZmJmYTdkNjFkZmNlYWUxNDlhMDg=
9
+ ZWFiYTYxYmVjNjIwZmE5NzRkN2U1NWI3YmQ2MjMwNWYyYTkxMDI5Y2VmYmI1
10
+ NmY1YTlkNjk2YjI5YzIzNGViMDNlMmRhN2NjMTczMjMyYzk3YTM1NTExMDNi
11
+ M2NmNTRiOTNlNDAxYTcyZDhmYjUxMTNhMzYwOTgzNTU1NjU5M2Q=
12
12
  data.tar.gz: !binary |-
13
- NGE1YmQ1Y2IzNjVkNzBkMjlkZTA4OGZmMjZjOTMxMTA2N2Y4ZGNiNDE2Yzdl
14
- ODIxOGIwY2M3MWI1YmM3MWU5OGY3M2NjMTAyOWJlYjc4NTIwMDEyYTQwMTI4
15
- OTk1ZjE5Y2U4NDYxYWJjY2MxYTFjODdhODFiMTk5ZDBkM2IzZTY=
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.children.each do |c|
123
- admin_options_helper(options, c, '')
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(options, cat, prefix)
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(options, c, "#{prefix} - ")
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
- <%= javascript_include_tag "caboose/model/all" %>
32
-
33
- <script type='text/javascript'>
34
- var modal = false;
35
-
36
- $(window).load(function() {
37
- modal = new CabooseModal(800);
38
- });
39
-
40
- $(document).ready(function() {
41
- m = new ModelBinder({
42
- name: 'Category',
43
- id: <%= @category.id %>,
44
- update_url: '/admin/categories/<%= @category.id %>',
45
- authenticity_token: '<%= form_authenticity_token %>',
46
- attributes: [
47
- { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(@category.name) %> , width: 400 },
48
- { name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@category.slug) %> , width: 400 },
49
- { 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' },
50
- { name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(@category.image.url(:medium)) %> , width: 200 }
51
- ]
52
- });
53
- });
54
-
55
- function delete_category(cat_id, confirm) {
56
- if (!confirm) {
57
- var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
58
- .append("Are you sure you want to delete the category?<br />This can't be undone.<br /><br />")
59
- .append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_category(cat_id, true); })).append(' ')
60
- .append($('<input/>').attr('type', 'button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
61
-
62
- modal.autosize(p, 'message');
63
-
64
- return;
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
- </script>
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
- <!-- <select name="parent_id">
5
- <option value="">-- Parent Category --</option>
6
- <%=
7
- #raw categories_options(@root_category)
8
- %>
9
- </select> -->
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
- <%= javascript_include_tag "caboose/model/all" %>
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
- <script type='text/javascript'>
42
- function add_category() {
43
- modal.autosize("<p class='loading'>Adding category...</p>");
44
-
45
- $.ajax({
46
- url: '/admin/categories',
47
- type: 'post',
48
- data: $('#new_form').serialize(),
49
- success: function(resp) {
50
- if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
51
- if (resp.redirect) window.location = resp.redirect
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
- var modal = false;
57
-
58
- $(window).load(function() {
59
- modal = new CabooseModal(800);
60
- });
61
- </script>
82
+ });
83
+ }
84
+
85
+ </script>
62
86
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.48'
2
+ VERSION = '0.5.49'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.48
4
+ version: 0.5.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry