caboose-cms 0.5.116 → 0.5.117

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
- YzE5ZTQzY2FhZGM1NjEzMjZlZDRmNGYxZmE0YTY3YmI3NTI4MmQwNA==
4
+ NDk4YzUwNzc5OGRjMzEzYTkzYmNmY2Q1M2FlNTkwMzkzMzJmMTZiZA==
5
5
  data.tar.gz: !binary |-
6
- Mzk4N2RkMjRkYTVmMDczNjcxNDZkNjFiY2NhMjJmZGJiNTM5ZDI0NQ==
6
+ ZGNhNmZhMjI4YzcwN2Q2MjUzMTVlOTNiZTVkNzNjZGMyNDdiYzM3YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjdlOTRhNWQxNTczMTk5OGEyMjk5MDY5MTc1MWE3MTk5MDZhZWI3MzllNmQ2
10
- MDFhZGE0M2YyOTRhNDA5NWVlZTY2NWI1NmE0NWVjNzE4YWM5ZjdmZDRmNWQ5
11
- NGZjNDI3ZDEyOTQyNTg1ODE2Y2I0NTg0Y2RhMmYzODE4YTE3YTM=
9
+ MDQ2Mzk3MTQ3NTBkZWNlMTY1YzZlNGJlZjM4NTJhMjk5MTcwYjI5MTU2OGE1
10
+ NzU4Y2ZlNzk5MDQ5NzY2NzQ0Yjg1MTcyNGM2MjE1MmE1MDk1Yzc0NDQ3OGFk
11
+ ZjUzMjkxZTQ1NDMyMzI2MDQ4NTg2MzFlN2JlODc2NjQ4MmU3ZWM=
12
12
  data.tar.gz: !binary |-
13
- ZTI3YjA0M2Y4Mzc0NDBiODU2NWVmN2Y5YjgyMGQwMjI5N2RiM2MwNjQ2ODhl
14
- OGI2NzAwNmZhMzdhZjIyZTAwZjJjMzFjNTdhNTU5NmFlNWQzNzI5NGNkM2Q4
15
- Zjg0ZTU2NzE4NjEzYTBhN2FiNzgzMjI1MjMzZjZmYzBhMzEzNzA=
13
+ YzkxOGFjZDc3ZDUyZjVjMWZkOTdkMGZhMTRiMDQwOGM3MzI0Nzc0NWRiMmI4
14
+ NjA0NGJkNmMzYTE2M2ZlZGQ0ZjgxZDA0ZmI3MWU2Y2UzZmJiMTlkY2Q2NjE1
15
+ NGE1ZDBhOGFlZDI2ZDBjYTQ5YmUwMzI4ZTYyYzU0YjU2ZjZkNWY=
@@ -0,0 +1,114 @@
1
+ module Caboose
2
+ class VendorsController < Caboose::ApplicationController
3
+
4
+ # GET /admin/vendors
5
+ def admin_index
6
+ return if !user_is_allowed('vendors', 'view')
7
+
8
+ @pager = Caboose::Pager.new(params, {
9
+ 'site_id' => @site.id,
10
+ 'name_like' => ''
11
+ }, {
12
+ 'model' => 'Caboose::Vendor',
13
+ 'sort' => 'name',
14
+ 'desc' => false,
15
+ 'base_url' => '/admin/vendors',
16
+ 'items_per_page' => 25,
17
+ 'use_url_params' => false
18
+ });
19
+
20
+ @vendors = @pager.items
21
+
22
+ render :layout => 'caboose/admin'
23
+ end
24
+
25
+ # GET /admin/vendors/:id
26
+ def admin_edit
27
+ return if !user_is_allowed('vendors', 'edit')
28
+ @vendor = Vendor.find(params[:id])
29
+ render :layout => 'caboose/admin'
30
+ end
31
+
32
+ # PUT /admin/vendors/:id/update
33
+ def admin_update
34
+ return if !user_is_allowed('vendors', 'edit')
35
+ vendor = Vendor.find(params[:id])
36
+
37
+ params.each do |name, value|
38
+ case name
39
+ when 'site_id' then vendor.site_id = value
40
+ when 'name' then vendor.name = value
41
+ when 'status' then vendor.status = value
42
+ when 'featured' then vendor.featured = value
43
+ end
44
+ end
45
+
46
+ render :json => { :success => vendor.save }
47
+ end
48
+
49
+ # POST /admin/vendors/:id/update/image
50
+ def admin_update_image
51
+ return if !user_is_allowed('vendors', 'edit')
52
+
53
+ vendor = Vendor.find(params[:id])
54
+ vendor.image = params[:image]
55
+ vendor.save
56
+
57
+ resp = StdClass.new
58
+ resp.attributes = { :image => { :value => vendor.image.url(:thumb) }}
59
+ resp.success = vendor.save
60
+ end
61
+
62
+ # GET /admin/vendors/new
63
+ def admin_new
64
+ return if !user_is_allowed('vendors', 'add')
65
+ render :layout => 'caboose/admin'
66
+ end
67
+
68
+ # POST /admin/vendors
69
+ def admin_add
70
+ return if !user_is_allowed('vendors', 'add')
71
+
72
+ render :json => { :success => false, :message => 'Must define a name' } and return if params[:name].nil? || params[:name].empty?
73
+
74
+ vendor = Vendor.new(
75
+ :site_id => @site.id,
76
+ :name => params[:name],
77
+ :status => 'Active'
78
+ )
79
+ render :json => { :success => vendor.save, :redirect => "/admin/vendors/#{vendor.id}" }
80
+ end
81
+
82
+ # DELETE /admin/vendors/:id
83
+ def admin_delete
84
+ return if !user_is_allowed('vendors', 'delete')
85
+ v = Vendor.find(params[:id])
86
+ v.destroy
87
+
88
+ resp = StdClass.new({
89
+ 'redirect' => '/admin/vendors'
90
+ })
91
+ render :json => resp
92
+ end
93
+
94
+ # GET /admin/vendors/options
95
+ def options
96
+ render :json => Vendor.where(:site_id => @site.id).reorder(:name).all.collect
97
+ { :text => 'Active' , :value => 'Active' },
98
+ { :text => 'Inactive' , :value => 'Inactive' },
99
+ { :text => 'Deleted' , :value => 'Deleted' }
100
+ ]
101
+ end
102
+
103
+ # GET /admin/vendors/status-options
104
+ def status_options
105
+ render :json => [
106
+ { :text => 'Active' , :value => 'Active' },
107
+ { :text => 'Inactive' , :value => 'Inactive' },
108
+ { :text => 'Deleted' , :value => 'Deleted' }
109
+ ]
110
+ end
111
+
112
+ end
113
+ end
114
+
@@ -3,30 +3,7 @@ p = @product
3
3
  %>
4
4
  <%= render :partial => 'caboose/products/admin_header' %>
5
5
 
6
- <p>
7
- <strong>Vendor:</strong>
8
-
9
- <select id="vendor" data-product-id="<%= @product.id %>">
10
- <option>-- Select a Vendor --</option>
11
-
12
- <% Caboose::Vendor.where(:site_id => @site.id).reorder(:name).all.each do |vendor| %>
13
- <option value="<%= vendor.id %>" <%= 'selected' if p.vendor_id && p.vendor_id == vendor.id %>><%= vendor.name %></option>
14
- <% end %>
15
- </select>
16
- </p>
17
-
18
-
19
- <% if p.vendor %>
20
- <p>
21
- <strong>Vendor Status (<%= p.vendor.name %>):</strong>
22
- <select id="vendor-status" data-vendor-id="<%= p.vendor.id %>">
23
- <% ['Active', 'Inactive'].each do |status| %>
24
- <option value="<%= status %>" <%= 'selected' if p.vendor.status == status %>><%= status %></option>
25
- <% end %>
26
- </select>
27
- </p>
28
- <% end %>
29
-
6
+ <p><div id='product_<%= p.id %>_vendor_id'></div></p>
30
7
  <p><div id='product_<%= p.id %>_title'></div></p>
31
8
  <p><div id='product_<%= p.id %>_caption'></div></p>
32
9
  <p><div id='product_<%= p.id %>_handle'></div></p>
@@ -47,34 +24,6 @@ p = @product
47
24
  date_available = p.date_available ? p.date_available.strftime('%F') : ''
48
25
  %>
49
26
  $(document).ready(function() {
50
- $('#vendor').on('change', function(event) {
51
- event.preventDefault();
52
-
53
- var $target = $(event.target)
54
- , vendor_id = $target.val()
55
- , product_id = $target.data('product-id');
56
-
57
- console.log(vendor_id, product_id);
58
-
59
- $.ajax({
60
- type: 'put',
61
- url: '/admin/products/' + product_id + '/update-vendor',
62
- data: { vendor_id: vendor_id },
63
- success: function(response) {
64
- console.log(response);
65
- }
66
- })
67
- });
68
-
69
- $('#vendor-status').on('change', function(e) {
70
- $select = $(e.target)
71
-
72
- $.ajax({
73
- type: 'put',
74
- url: '/admin/products/update-vendor-status/' + $select.data('vendor-id'),
75
- data: { status: $select.val() }
76
- });
77
- });
78
27
 
79
28
  m = new ModelBinder({
80
29
  name: 'Product',
@@ -82,9 +31,10 @@ $(document).ready(function() {
82
31
  update_url: '/admin/products/<%= p.id %>',
83
32
  authenticity_token: '<%= form_authenticity_token %>',
84
33
  attributes: [
34
+ { name: 'vendor_id' , nice_name: 'Vendor' , type: 'text' , value: <%= raw Caboose.json(p.vendor_id ) %>, width: 500, options_url: '/admin/vendors/options' },
85
35
  { name: 'title' , nice_name: 'Title' , type: 'text' , value: <%= raw Caboose.json(p.title ) %>, width: 500 },
86
36
  { name: 'caption' , nice_name: 'Caption' , type: 'text' , value: <%= raw Caboose.json(p.caption ) %>, width: 500 },
87
- { name: 'status' , nice_name: 'Status' , type: 'select' , value: <%= raw Caboose.json(p.status ) %>, width: 500, text: <%= raw Caboose.json(p.status) %>, options_url: '/admin/products/status-options' },
37
+ { name: 'status' , nice_name: 'Status' , type: 'select' , value: <%= raw Caboose.json(p.status ) %>, width: 500, options_url: '/admin/products/status-options' },
88
38
  { name: 'handle' , nice_name: 'URL Handle' , type: 'text' , value: <%= raw Caboose.json(p.handle ) %>, width: 500 },
89
39
  { name: 'seo_title' , nice_name: 'SEO Page Title' , type: 'text' , value: <%= raw Caboose.json(p.seo_title ) %>, width: 500 },
90
40
  { name: 'seo_description' , nice_name: 'SEO Meta Description' , type: 'textarea' , value: <%= raw Caboose.json(p.seo_description ) %>, width: 500, height: 150 },
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.116'
2
+ VERSION = '0.5.117'
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.116
4
+ version: 0.5.117
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
@@ -489,6 +489,7 @@ files:
489
489
  - app/assets/templates/caboose/product/images.jst.ejs
490
490
  - app/assets/templates/caboose/product/images_old.jst.ejs
491
491
  - app/assets/templates/caboose/product/options.jst.ejs
492
+ - app/controllers/caboose/#vendors_controller.rb#
492
493
  - app/controllers/caboose/ab_options_controller.rb
493
494
  - app/controllers/caboose/ab_variants_controller.rb
494
495
  - app/controllers/caboose/admin_controller.rb