tienda 2.0.1 → 2.0.2
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 +4 -4
- data/app/assets/javascripts/tienda/application.coffee +1 -57
- data/app/controllers/tienda/dashboard_controller.rb +2 -2
- data/app/controllers/tienda/product_categories_controller.rb +4 -2
- data/app/helpers/tienda/product_categories_helper.rb +56 -0
- data/app/models/tienda/product.rb +18 -4
- data/app/models/tienda/product_category.rb +8 -5
- data/app/views/layouts/tienda/application.html.haml +7 -7
- data/app/views/tienda/product_categories/_form.html.haml +6 -2
- data/app/views/tienda/product_categories/index.html.haml +2 -1
- data/config/initializers/assets.rb +2 -2
- data/db/migrate/20150605232554_add_parent_id_to_categories.rb +5 -0
- data/lib/tienda/version.rb +1 -1
- metadata +4 -9
- data/app/assets/javascripts/tienda/chosen.jquery.js +0 -1166
- data/app/assets/javascripts/tienda/custom-scripts.js +0 -182
- data/app/assets/javascripts/tienda/custom.js +0 -200
- data/app/assets/javascripts/tienda/morris.js +0 -1913
- data/app/assets/javascripts/tienda/mousetrap.js +0 -9
- data/app/assets/javascripts/tienda/raphael-2.1.0.min.js +0 -10
- data/app/assets/stylesheets/tienda/morris-0.4.3.min.css +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f31e72ee89918573cb2806723fc533734645a9
|
4
|
+
data.tar.gz: 76d33082565183722512ea4cbfdac5d63243410e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e37424a4dbce21b3484ebaf1899d709ff4f14b3c9bd8e4444a2b9a3fb0fb47243a77eb8bbd2eb553936e4d0c9696939fba981eef11ba17190fd8ce65bb4185a
|
7
|
+
data.tar.gz: 04c0e881b1f0e3a417a0d56433802dd51af397f4b5253de5131579962768816ac5bf0a9a13a9c2606d42191a1d859f4ca622cc6588e070d57dcba564045610c1
|
@@ -12,7 +12,7 @@ $ ->
|
|
12
12
|
$('.tienda_products_index, .tienda_variants_index').on('ajax:success', '#new_stock_level_adjustment', (e, data, status, xhr) ->
|
13
13
|
quantity = parseInt($(this).find('#stock_level_adjustment_adjustment').val())
|
14
14
|
product = $(this).find('#item_id').val()
|
15
|
-
stock_label = $('a.btn-sm[href*=' + product + ']').closest('td').find('b')
|
15
|
+
stock_label = $('a.btn-sm[href*=' + product + ']').closest('td').find('b')
|
16
16
|
old_quantity = parseInt(stock_label.text())
|
17
17
|
$('#stockModal').modal('hide')
|
18
18
|
if isNaN(old_quantity)
|
@@ -80,21 +80,6 @@ $ ->
|
|
80
80
|
# window.open($(this).attr('href'), 'despatchnote', 'width=700,height=800')
|
81
81
|
# false
|
82
82
|
#
|
83
|
-
# # Close dialog
|
84
|
-
# $('body').on 'click', 'a[rel=closeDialog]', Nifty.Dialog.closeTopDialog
|
85
|
-
#
|
86
|
-
# # Open AJAX dialogs
|
87
|
-
# $('a[rel=dialog]').on 'click', ->
|
88
|
-
# element = $(this)
|
89
|
-
# options = {}
|
90
|
-
# options.width = element.data('dialog-width') if element.data('dialog-width')
|
91
|
-
# options.offset = element.data('dialog-offset') if element.data('dialog-offset')
|
92
|
-
# options.behavior = element.data('dialog-behavior') if element.data('dialog-behavior')
|
93
|
-
# options.id = 'ajax'
|
94
|
-
# options.url = element.attr('href')
|
95
|
-
# Nifty.Dialog.open(options)
|
96
|
-
# false
|
97
|
-
#
|
98
83
|
# # Format money values to 2 decimal places
|
99
84
|
# $('div.moneyInput input').each formatMoneyField
|
100
85
|
# $('body').on('blur', 'div.moneyInput input', formatMoneyField)
|
@@ -106,44 +91,3 @@ $ ->
|
|
106
91
|
# value = $(this).val().replace /,/, ""
|
107
92
|
# $(this).val(parseFloat(value).toFixed(2)) if value.length
|
108
93
|
#
|
109
|
-
# #
|
110
|
-
# # Stock Level Adjustment dialog beavior
|
111
|
-
# #
|
112
|
-
# Nifty.Dialog.addBehavior
|
113
|
-
# name: 'stockLevelAdjustments'
|
114
|
-
# onLoad: (dialog,options)->
|
115
|
-
# $('input[type=text]:first', dialog).focus()
|
116
|
-
# $(dialog).on 'submit', 'form', ->
|
117
|
-
# form = $(this)
|
118
|
-
# $.ajax
|
119
|
-
# url: form.attr('action')
|
120
|
-
# method: 'POST'
|
121
|
-
# data: form.serialize()
|
122
|
-
# dataType: 'text'
|
123
|
-
# success: (data)->
|
124
|
-
# $('div.table', dialog).replaceWith(data)
|
125
|
-
# $('input[type=text]:first', dialog).focus()
|
126
|
-
# error: (xhr)->
|
127
|
-
# if xhr.status == 422
|
128
|
-
# alert xhr.responseText
|
129
|
-
# else
|
130
|
-
# alert 'An error occurred while saving the stock level.'
|
131
|
-
# false
|
132
|
-
# $(dialog).on 'click', 'nav.pagination a', ->
|
133
|
-
# $.ajax
|
134
|
-
# url: $(this).attr('href')
|
135
|
-
# success: (data)->
|
136
|
-
# $('div.table', dialog).replaceWith(data)
|
137
|
-
# false
|
138
|
-
#
|
139
|
-
# #
|
140
|
-
# # Always fire keyboard shortcuts when focused on fields
|
141
|
-
# #
|
142
|
-
# Mousetrap.stopCallback = -> false
|
143
|
-
#
|
144
|
-
# #
|
145
|
-
# # Close dialogs on escape
|
146
|
-
# #
|
147
|
-
# Mousetrap.bind 'escape', ->
|
148
|
-
# Nifty.Dialog.closeTopDialog()
|
149
|
-
# false
|
@@ -7,11 +7,11 @@ module Tienda
|
|
7
7
|
@last_30_days_orders = {}
|
8
8
|
end_date = Date.today
|
9
9
|
start_date = end_date - 30.days
|
10
|
-
last_30_days_orders = Tienda::Order.group('DATE(created_at)').where(created_at: start_date..end_date).count
|
10
|
+
last_30_days_orders = Tienda::Order.received.group('DATE(created_at)').where(created_at: start_date..end_date).count
|
11
11
|
(start_date..end_date).each do |day|
|
12
12
|
@last_30_days_orders[day] = last_30_days_orders[day] || 0
|
13
13
|
end
|
14
|
-
@sales_by_category = Tienda::Order.joins(products: [:product_category]).where(created_at: start_date..end_date).group('tienda_product_categories.name').count
|
14
|
+
@sales_by_category = Tienda::Order.received.joins(products: [:product_category]).where(created_at: start_date..end_date).group('tienda_product_categories.name').count
|
15
15
|
@users_count = Tienda::User.count
|
16
16
|
end
|
17
17
|
|
@@ -5,10 +5,11 @@ module Tienda
|
|
5
5
|
before_filter { params[:id] && @product_category = Tienda::ProductCategory.find(params[:id]) }
|
6
6
|
|
7
7
|
def index
|
8
|
-
@product_categories = Tienda::ProductCategory.ordered.
|
8
|
+
@product_categories = Tienda::ProductCategory.root.ordered.includes(:children)
|
9
9
|
end
|
10
10
|
|
11
11
|
def new
|
12
|
+
@parents = Tienda::ProductCategory.all
|
12
13
|
@product_category = Tienda::ProductCategory.new
|
13
14
|
end
|
14
15
|
|
@@ -22,6 +23,7 @@ module Tienda
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def edit
|
26
|
+
@parents = Tienda::ProductCategory.all
|
25
27
|
end
|
26
28
|
|
27
29
|
def update
|
@@ -40,7 +42,7 @@ module Tienda
|
|
40
42
|
private
|
41
43
|
|
42
44
|
def safe_params
|
43
|
-
params[:product_category].permit(:name, :permalink, :description, :image_file)
|
45
|
+
params[:product_category].permit(:name, :permalink, :description, :image_file, :parent_id)
|
44
46
|
end
|
45
47
|
|
46
48
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Tienda
|
2
|
+
module ProductCategoriesHelper
|
3
|
+
|
4
|
+
def product_category_spacing(category, relative_depth)
|
5
|
+
("<span style='display:inline-block;width:#{relative_depth}em;'></span>").html_safe
|
6
|
+
end
|
7
|
+
|
8
|
+
def product_category_rows(category, current_category = nil, link_to_current = true, relative_depth = 0)
|
9
|
+
if category.present? && category.children.any?
|
10
|
+
relative_depth += 1
|
11
|
+
String.new.tap do |s|
|
12
|
+
category.children.ordered.each do |child|
|
13
|
+
s << '<tr><td>'
|
14
|
+
if child == current_category
|
15
|
+
if link_to_current == false
|
16
|
+
s << "#{product_category_spacing child, relative_depth} ↳ #{child.name} (#{t('shoppe.product_category.nesting.current_category')})"
|
17
|
+
else
|
18
|
+
s << "#{product_category_spacing child, relative_depth} ↳ #{link_to(child.name, [:edit, child]).html_safe} (#{t('shoppe.product_category.nesting.current_category')})"
|
19
|
+
end
|
20
|
+
else
|
21
|
+
s << "#{product_category_spacing child, relative_depth} ↳ #{link_to(child.name, [:edit, child]).html_safe}"
|
22
|
+
end
|
23
|
+
s << '</td></tr>'
|
24
|
+
s << product_category_rows(child, current_category, link_to_current, relative_depth)
|
25
|
+
end
|
26
|
+
end.html_safe
|
27
|
+
else
|
28
|
+
''
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def product_categories_options_for_select(selected = nil, disable = nil)
|
33
|
+
String.new.tap do |s|
|
34
|
+
Tienda::ProductCategory.root.ordered.includes(:children).each do |category|
|
35
|
+
s << product_categories_options_for_select_recursive(category, 0, selected, disable)
|
36
|
+
end
|
37
|
+
end.html_safe
|
38
|
+
end
|
39
|
+
|
40
|
+
def product_categories_options_for_select_recursive(category, depth, selected, disable)
|
41
|
+
if category.present?
|
42
|
+
String.new.tap do |s|
|
43
|
+
s << "<option value='#{category.id}'#{' selected' if selected == category.id}#{' disabled' if disable == category.id}>#{' ↳ ' * depth}#{category.name}</option>"
|
44
|
+
if category.children.any?
|
45
|
+
depth += 1
|
46
|
+
category.children.ordered.each do |child|
|
47
|
+
s << product_categories_options_for_select_recursive(child, depth, selected, disable)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end.html_safe
|
51
|
+
else
|
52
|
+
''
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -21,18 +21,18 @@ module Tienda
|
|
21
21
|
# The product's category
|
22
22
|
#
|
23
23
|
# @return [Tienda::ProductCategory]
|
24
|
-
belongs_to :product_category
|
24
|
+
belongs_to :product_category
|
25
25
|
|
26
26
|
# The product's tax rate
|
27
27
|
#
|
28
28
|
# @return [Tienda::TaxRate]
|
29
|
-
belongs_to :tax_rate
|
29
|
+
belongs_to :tax_rate
|
30
30
|
|
31
31
|
# Ordered items which are associated with this product
|
32
|
-
has_many :order_items, dependent: :restrict_with_exception,
|
32
|
+
has_many :order_items, dependent: :restrict_with_exception, as: :ordered_item
|
33
33
|
|
34
34
|
# Orders which have ordered this product
|
35
|
-
has_many :orders, through: :order_items
|
35
|
+
has_many :orders, through: :order_items
|
36
36
|
|
37
37
|
# Stock level adjustments for this product
|
38
38
|
has_many :stock_level_adjustments, dependent: :destroy
|
@@ -108,6 +108,20 @@ module Tienda
|
|
108
108
|
nifty_attachments.select { |attachment| attachment.role != "data_sheet" }
|
109
109
|
end
|
110
110
|
|
111
|
+
# Return all product categories
|
112
|
+
#
|
113
|
+
# @return [Array]
|
114
|
+
def categories
|
115
|
+
parent_category_id = product_category.id
|
116
|
+
cats = []
|
117
|
+
while parent_category_id != nil
|
118
|
+
c = Tienda::ProductCategory.find(parent_category_id)
|
119
|
+
cats << c
|
120
|
+
parent_category_id = c.parent_id
|
121
|
+
end
|
122
|
+
cats
|
123
|
+
end
|
124
|
+
|
111
125
|
# Search for products which include the given attributes and return an active record
|
112
126
|
# scope of these products. Chainable with other scopes and with_attributes methods.
|
113
127
|
# For example:
|
@@ -1,20 +1,23 @@
|
|
1
1
|
module Tienda
|
2
2
|
class ProductCategory < ActiveRecord::Base
|
3
3
|
|
4
|
-
self.table_name = 'tienda_product_categories'
|
5
|
-
|
6
4
|
# Categories have an image attachment
|
7
5
|
attachment :image
|
8
6
|
|
9
7
|
# All products within this category
|
10
|
-
has_many :products, :
|
8
|
+
has_many :products, dependent: :restrict_with_exception
|
9
|
+
# Sub Categories relationships
|
10
|
+
has_many :children, class_name: 'Tienda::ProductCategory', foreign_key: :parent_id
|
11
|
+
belongs_to :parent, class_name: 'Tienda::ProductCategory'
|
11
12
|
|
12
13
|
# Validations
|
13
|
-
validates :name, :
|
14
|
-
validates :permalink, :
|
14
|
+
validates :name, presence: true
|
15
|
+
validates :permalink, presence: true, uniqueness: true, permalink: true
|
15
16
|
|
16
17
|
# All categories ordered by their name ascending
|
17
18
|
scope :ordered, -> { order(:name) }
|
19
|
+
scope :root, -> { where(parent_id: nil) }
|
20
|
+
scope :sub_categories, -> { where.not(parent_id: nil) }
|
18
21
|
|
19
22
|
# Set the permalink on callback
|
20
23
|
before_validation { self.permalink = self.name.parameterize if self.permalink.blank? && self.name.is_a?(String) }
|
@@ -7,14 +7,12 @@
|
|
7
7
|
%title #{@page_title} - Tienda
|
8
8
|
%meta{content: "http://gonzalo.robaina.me", name: "author"}/
|
9
9
|
=# stylesheet_link_tag 'tienda/application'
|
10
|
-
/ Bootstrap Styles
|
11
10
|
%link{href: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css', rel: 'stylesheet'}
|
12
|
-
/ FontAwesome Styles
|
13
11
|
%link{href: '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', rel: 'stylesheet'}
|
14
|
-
|
15
|
-
|
16
|
-
/
|
17
|
-
%link{:
|
12
|
+
= stylesheet_link_tag 'tienda/custom-styles'
|
13
|
+
|
14
|
+
%link{href: '//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css', rel: 'stylesheet'}
|
15
|
+
%link{href: 'http://fonts.googleapis.com/css?family=Open+Sans', rel: 'stylesheet', type: 'text/css'}/
|
18
16
|
= javascript_include_tag 'tienda/application'
|
19
17
|
= csrf_meta_tags
|
20
18
|
:javascript
|
@@ -38,4 +36,6 @@
|
|
38
36
|
%a{:href => "http://webthemez.com"} WebThemez
|
39
37
|
|
40
38
|
%script{src: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"}
|
41
|
-
|
39
|
+
%script{src: "//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"}
|
40
|
+
%script{src: "//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"}
|
41
|
+
= javascript_include_tag 'tienda/jquery.metisMenu'
|
@@ -5,11 +5,15 @@
|
|
5
5
|
= t('tienda.product_category.category_details')
|
6
6
|
.panel-body
|
7
7
|
.row
|
8
|
-
.col-md-
|
8
|
+
.col-md-4
|
9
|
+
.form-group
|
10
|
+
= f.label :name, t('tienda.product_category.parent')
|
11
|
+
= f.select :parent_id, product_categories_options_for_select(@product_category.parent_id, @product_category.id), {prompt: true}, {class: 'form-control'}
|
12
|
+
.col-md-4
|
9
13
|
.form-group
|
10
14
|
= f.label :name, t('tienda.product_category.name')
|
11
15
|
= f.text_field :name, class: 'focus form-control'
|
12
|
-
.col-md-
|
16
|
+
.col-md-4
|
13
17
|
.form-group
|
14
18
|
= f.label :permalink, t('tienda.product_category.permalink')
|
15
19
|
= f.text_field :permalink, class: 'form-control'
|
@@ -5,5 +5,5 @@ Rails.application.config.assets.version = '1.0'
|
|
5
5
|
|
6
6
|
# Precompile additional assets.
|
7
7
|
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
8
|
-
Rails.application.config.assets.precompile += %w( tienda/
|
9
|
-
Rails.application.config.assets.precompile += %w( tienda/jquery.metisMenu.js
|
8
|
+
Rails.application.config.assets.precompile += %w( tienda/custom-styles.css )
|
9
|
+
Rails.application.config.assets.precompile += %w( tienda/jquery.metisMenu.js )
|
data/lib/tienda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tienda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Robaina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -400,21 +400,14 @@ files:
|
|
400
400
|
- app/assets/images/tienda/statuses/shipped.svg
|
401
401
|
- app/assets/images/tienda/table-tear-off.png
|
402
402
|
- app/assets/javascripts/tienda/application.coffee
|
403
|
-
- app/assets/javascripts/tienda/chosen.jquery.js
|
404
|
-
- app/assets/javascripts/tienda/custom-scripts.js
|
405
|
-
- app/assets/javascripts/tienda/custom.js
|
406
403
|
- app/assets/javascripts/tienda/jquery.metisMenu.js
|
407
404
|
- app/assets/javascripts/tienda/jquery_ui.js
|
408
|
-
- app/assets/javascripts/tienda/morris.js
|
409
|
-
- app/assets/javascripts/tienda/mousetrap.js
|
410
405
|
- app/assets/javascripts/tienda/order_form.coffee
|
411
|
-
- app/assets/javascripts/tienda/raphael-2.1.0.min.js
|
412
406
|
- app/assets/stylesheets/tienda/application.scss
|
413
407
|
- app/assets/stylesheets/tienda/chosen.scss
|
414
408
|
- app/assets/stylesheets/tienda/custom-styles.scss
|
415
409
|
- app/assets/stylesheets/tienda/dialog.scss
|
416
410
|
- app/assets/stylesheets/tienda/elements.scss
|
417
|
-
- app/assets/stylesheets/tienda/morris-0.4.3.min.css
|
418
411
|
- app/assets/stylesheets/tienda/printable.scss
|
419
412
|
- app/assets/stylesheets/tienda/reset.scss
|
420
413
|
- app/assets/stylesheets/tienda/sub.scss
|
@@ -436,6 +429,7 @@ files:
|
|
436
429
|
- app/controllers/tienda/users_controller.rb
|
437
430
|
- app/controllers/tienda/variants_controller.rb
|
438
431
|
- app/helpers/tienda/application_helper.rb
|
432
|
+
- app/helpers/tienda/product_categories_helper.rb
|
439
433
|
- app/mailers/tienda/order_mailer.rb
|
440
434
|
- app/mailers/tienda/user_mailer.rb
|
441
435
|
- app/models/tienda/country.rb
|
@@ -530,6 +524,7 @@ files:
|
|
530
524
|
- db/migrate/20150517195800_remove_stock_level_item_polymorphism.rb
|
531
525
|
- db/migrate/20150517212100_update_stock_counter_cache.rb
|
532
526
|
- db/migrate/20150603235417_add_document_to_orders.rb
|
527
|
+
- db/migrate/20150605232554_add_parent_id_to_categories.rb
|
533
528
|
- db/seeds.rb
|
534
529
|
- db/seeds_data/poe400.jpg
|
535
530
|
- db/seeds_data/snom-870-blk.jpg
|