caboose-cms 0.5.47 → 0.5.48

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
- NzBjMTkxZTAwZThkY2FjNDA1YTcxZWFjOWIyYWE1MWUzZTM0YjdiMg==
4
+ YjAzMmQ2OTFiMjYzYWQ1ODU2OWI5NDFiNDZjMDY3MmI3NjM0NzQyZQ==
5
5
  data.tar.gz: !binary |-
6
- NGNiMzEwYWJhZWZjZWVkNjg2MTY3YWFmNTg4ZTA0OWY0ZWZhZGEwZQ==
6
+ MDViNjhlM2EwNGI1MGU4MGYzYjAzZDEyYjlhY2VlODYxMTVlZjRiZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGRiZTFkYjgwZjRkYTI1YzRlNDE1MzAwOTA5MzM1YTIwN2VmZDFhMzQxYzI1
10
- YWM3YjU3ZWNiNjNkYTBmZjNlNjRiODc0NjcwMGM4MmVhMTU4YWY5ZDkxMWZm
11
- YjE4MTdhYzViZTY3OWU4OTQ3MWRiOTM0N2E4M2JkMWYzM2ExNWQ=
9
+ Njg4MzA5Yjc5MWQ2OWI5OTE3MGVkNTFhOGRkOWMxZDYwYzY0ZjhlY2M1Y2Yy
10
+ OGNlM2M3MjQ2YmRlMGI2NWYxOWUyZTM5ZjdhNmMwYTE0OGYyN2ZiY2ZmYjk3
11
+ ODEzNmMzM2Q4OTU1YzE4ZTk0ZmJmYTdkNjFkZmNlYWUxNDlhMDg=
12
12
  data.tar.gz: !binary |-
13
- YjUzZjU4ZDgzMGI5NzEzYTJjYTk0ODE0YmY0ODYxYTJlYWJiNzc4ZTljMWEx
14
- N2Q3MmM2MTlhNjMzNGViM2VkOGNmNmFjMmMwYzAzYzU0MzcwYTg0ZTNlYjVl
15
- MWQ0MmZjMmE2NzFmOGY5ZjAyMDU5M2JiOGFhODU3NjNjNjc5ODk=
13
+ NGE1YmQ1Y2IzNjVkNzBkMjlkZTA4OGZmMjZjOTMxMTA2N2Y4ZGNiNDE2Yzdl
14
+ ODIxOGIwY2M3MWI1YmM3MWU5OGY3M2NjMTAyOWJlYjc4NTIwMDEyYTQwMTI4
15
+ OTk1ZjE5Y2U4NDYxYWJjY2MxYTFjODdhODFiMTk5ZDBkM2IzZTY=
@@ -34,7 +34,7 @@ module Caboose
34
34
  :site_id => @site.id,
35
35
  :parent_id => p.id,
36
36
  :name => params[:name],
37
- :status => 'Inactive'
37
+ :status => 'Active'
38
38
  )
39
39
  cat.slug = cat.generate_slug
40
40
  cat.url = "#{p.url}/#{cat.slug}"
@@ -53,11 +53,23 @@ module Caboose
53
53
  vendor = Vendor.new(
54
54
  :site_id => @site.id,
55
55
  :name => params[:name],
56
- :status => 'Inactive'
56
+ :status => 'Active'
57
57
  )
58
58
  render :json => { :success => vendor.save, :redirect => "/admin/vendors/#{vendor.id}" }
59
59
  end
60
60
 
61
+ # DELETE /admin/vendors/:id
62
+ def admin_delete
63
+ return if !user_is_allowed('vendors', 'delete')
64
+ v = Vendor.find(params[:id])
65
+ v.destroy
66
+
67
+ resp = StdClass.new({
68
+ 'redirect' => '/admin/vendors'
69
+ })
70
+ render :json => resp
71
+ end
72
+
61
73
  # GET /admin/vendors/status-options
62
74
  def status_options
63
75
  render :json => [
@@ -15,7 +15,7 @@ module Caboose
15
15
  def category_list_items(category)
16
16
 
17
17
  # Link to category
18
- link = link_to(category.name, "/admin/categories/#{category.id}/edit")
18
+ link = link_to(category.name, "/admin/categories/#{category.id}")
19
19
 
20
20
  # Recursively find category children
21
21
  children = content_tag :ul, category.children.collect { |child| category_list_items(child) }.join.to_s.html_safe if category.children.any?
@@ -18,7 +18,7 @@
18
18
  <% end %>
19
19
 
20
20
  <div id="message"></div>
21
- <input type="button" value="< Back" onclick="window.location='/admin/categories'" />
21
+ <input type="button" value="< Back" onclick="window.location='/admin/categories';" />
22
22
  <input type="button" value="Delete Category" onclick="delete_category(<%= @category.id %>)" />
23
23
 
24
24
  <% content_for :caboose_css do %>
@@ -1,24 +1,47 @@
1
1
  <h1>Edit Vendor</h1>
2
2
  <p><div id="vendor_<%= @vendor.id %>_name"></div></p>
3
3
  <p><div id="vendor_<%= @vendor.id %>_status"></div></p>
4
- <input type="button" value="< Back" onclick="window.location=/admin/vendors" />
5
- <input type="button" value="Delete" onclick="window.location=/admin/vendors/<%= @vendor.id %>/delete" />
4
+ <div id='message'></div>
5
+ <input type="button" value="< Back" onclick="window.location='/admin/vendors';" />
6
+ <input type="button" value="Delete" onclick="delete_vendor(<%= @vendor.id %>);" />
6
7
 
7
8
  <% content_for :caboose_js do %>
8
- <%= javascript_include_tag "caboose/model/all" %>
9
-
10
- <script>
11
- $(document).ready(function() {
12
- m = new ModelBinder({
13
- id: <%= @vendor.id %>,
14
- name: 'Vendor',
15
- update_url: '/admin/vendors/<%= @vendor.id %>/update',
16
- authenticity_token: '<%= form_authenticity_token %>',
17
- attributes: [
18
- { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= Caboose.json(@vendor.name).html_safe %>, width: 500 },
19
- { name: 'status' , nice_name: 'Status' , type: 'select' , text: <%= raw Caboose.json(@vendor.status).html_safe %>, value: <%= Caboose.json(@vendor.status).html_safe %>, width: 500, options_url: '/admin/vendors/status-options' }
20
- ]
21
- })
22
- });
23
- </script>
9
+ <%= javascript_include_tag "caboose/model/all" %>
10
+ <script>
11
+ $(document).ready(function() {
12
+ m = new ModelBinder({
13
+ id: <%= @vendor.id %>,
14
+ name: 'Vendor',
15
+ update_url: '/admin/vendors/<%= @vendor.id %>/update',
16
+ authenticity_token: '<%= form_authenticity_token %>',
17
+ attributes: [
18
+ { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= Caboose.json(@vendor.name).html_safe %>, width: 500 },
19
+ { name: 'status' , nice_name: 'Status' , type: 'select' , text: <%= raw Caboose.json(@vendor.status).html_safe %>, value: <%= Caboose.json(@vendor.status).html_safe %>, width: 500, options_url: '/admin/vendors/status-options' }
20
+ ]
21
+ })
22
+ });
23
+
24
+ function delete_vendor(vendor_id, confirm)
25
+ {
26
+ if (!confirm)
27
+ {
28
+ var p = $('<p/>').addClass('note confirm')
29
+ .append('Are you sure you want to delete the vendor? ')
30
+ .append($('<input/>').attr('type','button').val('Yes').click(function() { delete_vendor(vendor_id, true); })).append(' ')
31
+ .append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); }));
32
+ $('#message').empty().append(p);
33
+ return;
34
+ }
35
+ $('#message').html("<p class='loading'>Deleting vendor...</p>");
36
+ $.ajax({
37
+ url: '/admin/vendors/' + vendor_id,
38
+ type: 'delete',
39
+ success: function(resp) {
40
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
41
+ if (resp.redirect) window.location = resp.redirect;
42
+ }
43
+ });
44
+ }
45
+
46
+ </script>
24
47
  <% end %>
@@ -12,14 +12,16 @@
12
12
  <tr>
13
13
  <%= raw @pager.sortable_table_headings({
14
14
  'id' => 'ID',
15
- 'name' => 'Name'
15
+ 'name' => 'Name',
16
+ 'status' => 'Status'
16
17
  }) %>
17
18
  </tr>
18
19
 
19
20
  <% @vendors.each do |vendor| %>
20
- <tr onclick="window.location='/admin/vendors/<%= vendor.id %>/edit';">
21
+ <tr onclick="window.location='/admin/vendors/<%= vendor.id %>';">
21
22
  <td style="text-align: center"><%= raw vendor.id %></td>
22
23
  <td><%= raw vendor.name %></td>
24
+ <td><%= raw vendor.status %></td>
23
25
  </tr>
24
26
  <% end %>
25
27
  </table>
@@ -2,11 +2,12 @@
2
2
 
3
3
  <form id="new-vendor" action="/admin/vendors" method="post">
4
4
  <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
5
- <input id="name" name="name" type="text" placeholder="Vendor Name" style="width: 400px" />
6
- <div id='message'></div>
5
+ <p><input id="name" name="name" id='name' type="text" placeholder="Vendor Name" style="width: 400px" /></p>
6
+ <p><input type='checkbox' name='stay' id='stay' value='1' /> Stay here so I can add another vendor</p>
7
+ <div id='message'></div>
7
8
  <p>
8
- <input type="button" value="< Back" onclick="window.location='/admin/products'" />
9
- <input type="submit" value="Add Vendor" />
9
+ <input type="button" value="< Back" onclick="window.location='/admin/vendors';" />
10
+ <input type="submit" value="Add Vendor" />
10
11
  </p>
11
12
  </form>
12
13
 
@@ -14,9 +15,10 @@
14
15
  <script>
15
16
  $(document).ready(function() {
16
17
  $('#new-vendor').on('submit', function(event) {
17
- $('#message').html("<p class='loading'>Adding vendor...</p>");
18
18
  event.preventDefault();
19
+ var stay = $('#stay').prop('checked');
19
20
 
21
+ $('#message').html("<p class='loading'>Adding vendor...</p>");
20
22
  $.ajax({
21
23
  url: '/admin/vendors',
22
24
  type: 'post',
@@ -24,8 +26,17 @@ $(document).ready(function() {
24
26
  success: function(resp) {
25
27
  if (resp.error)
26
28
  $('#message').html("<p class='note error'>" + resp.error + "</p>");
27
- else if (resp.redirect)
28
- window.location = resp.redirect;
29
+ else
30
+ {
31
+ if (stay)
32
+ {
33
+ $('#name').val('');
34
+ $('#message').html("<p class='note succes'>The vendor has been added successfully.</p>");
35
+ setTimeout(function() { $('#message').empty(); }, 2000);
36
+ }
37
+ else if (resp.redirect)
38
+ window.location = resp.redirect;
39
+ }
29
40
  }
30
41
  });
31
42
  });
data/config/routes.rb CHANGED
@@ -289,13 +289,14 @@ Caboose::Engine.routes.draw do
289
289
 
290
290
  get '/admin/products/add-upcs' => 'products#admin_add_upcs'
291
291
 
292
- get '/admin/vendors/status-options' => 'vendors#status_options'
293
- get '/admin/vendors/new' => 'vendors#admin_new'
294
- get '/admin/vendors/:id' => 'vendors#admin_edit'
295
- put '/admin/vendors/:id' => 'vendors#admin_update'
296
- post '/admin/vendors' => 'vendors#admin_add'
297
- get '/admin/vendors' => 'vendors#admin_index'
298
-
292
+ get '/admin/vendors/status-options' => 'vendors#status_options'
293
+ get '/admin/vendors/new' => 'vendors#admin_new'
294
+ get '/admin/vendors/:id' => 'vendors#admin_edit'
295
+ get '/admin/vendors' => 'vendors#admin_index'
296
+ put '/admin/vendors/:id' => 'vendors#admin_update'
297
+ post '/admin/vendors' => 'vendors#admin_add'
298
+ delete '/admin/vendors/:id' => 'vendors#admin_delete'
299
+
299
300
  # Orders
300
301
 
301
302
  get '/admin/orders/:id/void' => 'orders#admin_void'
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.47'
2
+ VERSION = '0.5.48'
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.47
4
+ version: 0.5.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry