comable_backend 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +16 -4
  4. data/app/assets/javascripts/comable/admin/application.coffee +88 -0
  5. data/app/assets/stylesheets/comable/admin/application.scss +590 -0
  6. data/app/controllers/comable/admin/application_controller.rb +28 -0
  7. data/app/controllers/comable/admin/categories_controller.rb +14 -0
  8. data/app/controllers/comable/admin/customers_controller.rb +36 -0
  9. data/app/controllers/comable/admin/dashboard_controller.rb +20 -0
  10. data/app/controllers/comable/admin/orders_controller.rb +14 -0
  11. data/app/controllers/comable/admin/payment_methods_controller.rb +52 -0
  12. data/app/controllers/comable/admin/products_controller.rb +50 -1
  13. data/app/controllers/comable/admin/shipment_methods_controller.rb +11 -27
  14. data/app/controllers/comable/admin/stocks_controller.rb +69 -0
  15. data/app/controllers/comable/admin/store_controller.rb +12 -29
  16. data/app/views/comable/admin/categories/index.slim +94 -0
  17. data/app/views/comable/admin/customers/edit.slim +94 -0
  18. data/app/views/comable/admin/customers/index.slim +68 -0
  19. data/app/views/comable/admin/customers/show.slim +93 -0
  20. data/app/views/comable/admin/dashboard/_widget.slim +13 -0
  21. data/app/views/comable/admin/dashboard/show.slim +63 -0
  22. data/app/views/comable/admin/orders/index.slim +79 -0
  23. data/app/views/comable/admin/orders/show.slim +116 -0
  24. data/app/views/comable/admin/payment_methods/_form.slim +46 -0
  25. data/app/views/comable/admin/payment_methods/edit.slim +28 -0
  26. data/app/views/comable/admin/payment_methods/index.slim +53 -0
  27. data/app/views/comable/admin/payment_methods/new.slim +17 -0
  28. data/app/views/comable/admin/products/_form.slim +130 -0
  29. data/app/views/comable/admin/products/edit.slim +40 -0
  30. data/app/views/comable/admin/products/index.slim +75 -5
  31. data/app/views/comable/admin/products/new.slim +17 -0
  32. data/app/views/comable/admin/shipment_methods/_form.slim +35 -19
  33. data/app/views/comable/admin/shipment_methods/edit.slim +26 -5
  34. data/app/views/comable/admin/shipment_methods/index.slim +46 -13
  35. data/app/views/comable/admin/shipment_methods/new.slim +15 -3
  36. data/app/views/comable/admin/stocks/_form.slim +40 -0
  37. data/app/views/comable/admin/stocks/edit.slim +46 -0
  38. data/app/views/comable/admin/stocks/index.slim +81 -0
  39. data/app/views/comable/admin/stocks/new.slim +17 -0
  40. data/app/views/comable/admin/store/_form.slim +43 -31
  41. data/app/views/comable/admin/store/edit.slim +11 -3
  42. data/app/views/kaminari/comable_backend/_first_page.html.slim +2 -0
  43. data/app/views/kaminari/comable_backend/_gap.html.slim +2 -0
  44. data/app/views/kaminari/comable_backend/_last_page.html.slim +2 -0
  45. data/app/views/kaminari/comable_backend/_next_page.html.slim +2 -0
  46. data/app/views/kaminari/comable_backend/_page.html.slim +3 -0
  47. data/app/views/kaminari/comable_backend/_paginator.html.slim +15 -0
  48. data/app/views/kaminari/comable_backend/_prev_page.html.slim +2 -0
  49. data/app/views/layouts/comable/admin/application.slim +103 -2
  50. data/config/routes.rb +14 -2
  51. data/lib/comable/backend/engine.rb +22 -0
  52. metadata +240 -9
  53. data/app/assets/javascripts/comable/admin/application.js +0 -13
  54. data/app/assets/stylesheets/comable/admin/application.css +0 -15
  55. data/app/views/comable/admin/shipment_methods/show.slim +0 -22
  56. data/app/views/comable/admin/store/new.slim +0 -3
  57. data/app/views/comable/admin/store/show.slim +0 -24
@@ -0,0 +1,46 @@
1
+ = form_for [comable, :admin, @payment_method] do |f|
2
+ / TODO: Standardize
3
+ - if @payment_method.errors.any?
4
+ #error_explanation
5
+ h2
6
+ = pluralize(@payment_method.errors.count, 'error')
7
+ | prohibited this payment_method from being saved:
8
+
9
+ ul
10
+ - @payment_method.errors.full_messages.each do |message|
11
+ li = message
12
+
13
+ .panel.panel-inverse
14
+ .panel-heading
15
+ .panel-title
16
+ = Comable.t('admin.nav.payment_methods.edit')
17
+
18
+ .panel-body
19
+ .form-horizontal
20
+ fieldset
21
+ .form-group
22
+ .col-sm-3.control-label
23
+ = f.label :name
24
+ .col-sm-6
25
+ = f.text_field :name
26
+
27
+ .form-group
28
+ .col-sm-3.control-label
29
+ = f.label :payment_provider
30
+ .col-sm-3
31
+ = f.select :payment_provider_type, Comable::PaymentProvider.all.map { |provider_class| [provider_class.display_name, provider_class.name] }
32
+ .col-sm-3
33
+ = f.select :payment_provider_kind, Comable::PaymentProvider::General.kind.map.with_index { |(_, value), index| [value, index] }
34
+
35
+ .form-group
36
+ .col-sm-3.control-label
37
+ = f.label :enable_price
38
+ .col-sm-3
39
+ = f.text_field :enable_price_from
40
+ .col-sm-3
41
+ = f.text_field :enable_price_to
42
+
43
+ .panel-footer
44
+ = link_to Comable.t('admin.actions.cancel'), comable.admin_payment_methods_path, class: 'btn btn-default'
45
+ .pull-right
46
+ = f.submit
@@ -0,0 +1,28 @@
1
+ #comable-payment-method
2
+ ol.breadcrumb
3
+ li
4
+ = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
+ li
6
+ = link_to Comable.t('admin.nav.payment_method'), comable.admin_payment_methods_path
7
+ li.active
8
+ = @payment_method.name
9
+
10
+ h1.page-header
11
+ = @payment_method.name
12
+
13
+ .row
14
+ section.col-sm-8
15
+ = render 'form'
16
+ hr
17
+ .panel.panel-danger
18
+ .panel-heading type="button" data-toggle="collapse" data-target="#comable-danger" aria-expanded="false" aria-controls="comable-danger"
19
+ strong
20
+ span.fa.fa-angle-down>
21
+ = Comable.t('admin.actions.destroy')
22
+ #comable-danger.collapse
23
+ .panel-body
24
+ p
25
+ = Comable.t('admin.confirmation_to_remove_product')
26
+ = link_to Comable.t('admin.actions.destroy'), comable.admin_payment_method_path(@payment_method), method: :delete, class: 'btn btn-danger'
27
+
28
+ nav.col-sm-4
@@ -0,0 +1,53 @@
1
+ #comable-payment-method
2
+ ol.breadcrumb
3
+ li
4
+ = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
+ li.active
6
+ = Comable.t('admin.nav.payment_method')
7
+
8
+ h1.page-header
9
+ = Comable.t('admin.nav.payment_method')
10
+ small<
11
+ = @payment_methods.total_count
12
+ = Comable.t('admin.results')
13
+
14
+ .row
15
+ section.col-sm-8
16
+ - if @payment_methods.empty?
17
+ = Comable.t('admin.not_found')
18
+ - else
19
+ .panel.panel-inverse
20
+ .panel-heading
21
+ .panel-title
22
+ = Comable.t('admin.index')
23
+ table.table.table-striped
24
+ thead
25
+ th
26
+ = @payment_methods.klass.human_attribute_name(:name)
27
+ th
28
+ = @payment_methods.klass.human_attribute_name(:payment_provider)
29
+ th
30
+ = @payment_methods.klass.human_attribute_name(:enable_price)
31
+ tbody
32
+ - @payment_methods.each do |payment_method|
33
+ tr
34
+ td
35
+ = link_to payment_method.name, comable.admin_payment_method_path(payment_method)
36
+ /- unless payment_method.activate_flag
37
+ / span.fa.fa-eye-slash.text-muted<
38
+ td
39
+ = payment_method.payment_provider.display_name
40
+ td
41
+ - if payment_method.enable_price_from || payment_method.enable_price_to
42
+ span = number_to_currency payment_method.enable_price_from
43
+ span>< ~
44
+ span = number_to_currency payment_method.enable_price_to
45
+
46
+ .text-center
47
+ = paginate @payment_methods, theme: :comable_backend
48
+
49
+ nav.col-sm-4
50
+ #comable-affix
51
+ .panel
52
+ .list-group
53
+ = link_to Comable.t('admin.actions.new'), comable.new_admin_payment_method_path, class: 'list-group-item'
@@ -0,0 +1,17 @@
1
+ #comable-payment-method
2
+ ol.breadcrumb
3
+ li
4
+ = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
+ li
6
+ = link_to Comable.t('admin.nav.payment_method'), comable.admin_payment_methods_path
7
+ li.active
8
+ = Comable.t('admin.actions.new')
9
+
10
+ h1.page-header
11
+ = Comable.t('admin.actions.new')
12
+
13
+ .row
14
+ section.col-sm-8
15
+ = render 'form'
16
+
17
+ nav.col-sm-4
@@ -0,0 +1,130 @@
1
+ - url = comable.admin_products_path if @product.new_record?
2
+ - url ||= comable.admin_product_path(@product)
3
+ = form_for @product, url: url, html: { multipart: true } do |f|
4
+ .panel.panel-inverse
5
+ .panel-heading
6
+ .panel-title
7
+ = Comable.t('admin.general')
8
+ .panel-body
9
+ .form-horizontal
10
+ .form-group
11
+ .col-sm-3.control-label
12
+ = f.label :code
13
+ .col-sm-6
14
+ = f.text_field :code
15
+
16
+ .form-group
17
+ .col-sm-3.control-label
18
+ = f.label :name
19
+ .col-sm-6
20
+ = f.text_field :name
21
+
22
+ .form-group
23
+ .col-sm-3.control-label
24
+ = f.label :caption
25
+ .col-sm-6
26
+ = f.text_field :caption
27
+
28
+ .form-group
29
+ .col-sm-3.control-label
30
+ = f.label :price
31
+ .col-sm-6
32
+ = f.text_field :price
33
+
34
+ = stylesheet_link_tag 'http://rawgithub.com/aehlke/tag-it/master/css/jquery.tagit.css', media: 'all'
35
+ = stylesheet_link_tag 'http://rawgithub.com/aehlke/tag-it/master/css/tagit.ui-zendesk.css', media: 'all'
36
+ = javascript_include_tag 'http://rawgithub.com/aehlke/tag-it/master/js/tag-it.min.js'
37
+
38
+ / TODO: Refactoring
39
+ javascript:
40
+ comable_tagit_available_tags = #{raw Comable::Category.all.map(&:path).map { |path| path.map(&:name).join(' > ') }.sort.to_json};
41
+ coffee:
42
+ $(document).ready(->
43
+ $("#comable-tagit").tagit({
44
+ fieldName: 'product[category_path_names][]',
45
+ availableTags: comable_tagit_available_tags,
46
+ autocomplete: { delay: 0, minLength: 0 },
47
+ showAutocompleteOnFocus: true,
48
+ removeConfirmation: true,
49
+ # Only allow available tags
50
+ beforeTagAdded: (event, ui) -> (comable_tagit_available_tags.indexOf(ui.tagLabel) != -1)
51
+ })
52
+ )
53
+
54
+ .form-group
55
+ .col-sm-3.control-label
56
+ = f.label :categories
57
+ .col-sm-6
58
+ ul#comable-tagit
59
+ - @product.categories.each do |category|
60
+ li
61
+ = category.path.map(&:name).join(' > ')
62
+
63
+ fieldset
64
+ legend.text-center.text-muted
65
+ | SKU
66
+
67
+ .form-group
68
+ .col-sm-3.control-label
69
+ = f.label :sku_h_item_name
70
+ .col-sm-6
71
+ = f.text_field :sku_h_item_name
72
+ span.help-block
73
+ = Comable.t('admin.please_fill_when_using_sku')
74
+
75
+ .form-group
76
+ .col-sm-3.control-label
77
+ = f.label :sku_v_item_name
78
+ .col-sm-6
79
+ = f.text_field :sku_v_item_name
80
+
81
+ .panel-footer
82
+ = link_to Comable.t('admin.actions.cancel'), comable.admin_products_path, class: 'btn btn-default'
83
+ .pull-right
84
+ = f.submit
85
+
86
+ .panel.panel-inverse
87
+ .panel-heading
88
+ .panel-title
89
+ = Comable.t('admin.images')
90
+ .panel-body
91
+ - images = @product.images + [@product.images.build]
92
+ - main_image = images.first
93
+ - sub_images = images - [main_image]
94
+
95
+ .row
96
+ .col-sm-6
97
+ = f.fields_for :images, main_image do |ff|
98
+ label
99
+ = Comable.t('admin.main_image')
100
+ p
101
+ = ff.file_field :file
102
+ - if ff.object.url
103
+ .thumbnail
104
+ = image_tag ff.object.url
105
+ - if ff.object.persisted?
106
+ label.remove
107
+ span> = ff.check_box :_destroy
108
+ span> = Comable.t('admin.actions.destroy')
109
+
110
+ .col-sm-6
111
+ .row
112
+ - sub_images.each.with_index(1) do |image, index|
113
+ = f.fields_for :images, image do |ff|
114
+ .col-sm-6
115
+ label
116
+ | #{Comable.t('admin.sub_image')} ##{index}
117
+ p
118
+ = ff.file_field :file
119
+ - if ff.object.url
120
+ .thumbnail
121
+ = image_tag ff.object.url
122
+ - if ff.object.persisted?
123
+ label.remove
124
+ span> = ff.check_box :_destroy
125
+ span> = Comable.t('admin.actions.destroy')
126
+
127
+ .panel-footer
128
+ = link_to Comable.t('admin.actions.cancel'), comable.admin_products_path, class: 'btn btn-default'
129
+ .pull-right
130
+ = f.submit
@@ -0,0 +1,40 @@
1
+ #comable-product
2
+ ol.breadcrumb
3
+ li
4
+ = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
+ li
6
+ = link_to Comable.t('admin.nav.product'), comable.admin_products_path
7
+ li.active
8
+ = @product.name
9
+
10
+ h1.page-header
11
+ = @product.name
12
+ small< = @product.code
13
+
14
+ .row
15
+ section.col-sm-8
16
+ = render 'form'
17
+ hr
18
+ .panel.panel-danger
19
+ .panel-heading type="button" data-toggle="collapse" data-target="#comable-danger" aria-expanded="false" aria-controls="comable-danger"
20
+ strong
21
+ span.fa.fa-angle-down>
22
+ = Comable.t('admin.actions.destroy')
23
+ #comable-danger.collapse
24
+ .panel-body
25
+ p
26
+ = Comable.t('admin.confirmation_to_remove_product')
27
+ = link_to Comable.t('admin.actions.destroy'), comable.admin_product_path(@product), method: :delete, class: 'btn btn-danger'
28
+
29
+ nav.col-sm-4
30
+ #comable-affix data-spy="affix"
31
+ .panel
32
+ .list-group
33
+ = link_to Comable.t('admin.nav.products.detail'), comable.admin_product_path(@product), class: 'list-group-item disabled'
34
+ = link_to Comable.t('admin.nav.products.stock'), comable.admin_product_stocks_path(@product), class: 'list-group-item'
35
+
36
+ .panel
37
+ .list-group
38
+ = link_to comable.product_path(@product), class: 'list-group-item' do
39
+ span.fa.fa-external-link>
40
+ = Comable.t('admin.check_this_product_in_frontend')
@@ -1,6 +1,76 @@
1
- h1 Admin::Products#index
1
+ #comable-product
2
+ ol.breadcrumb
3
+ li
4
+ = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
+ li.active
6
+ = Comable.t('admin.nav.product')
2
7
 
3
- - if @products.any?
4
- ul
5
- - @products.each do |product|
6
- li = product.name
8
+ h1.page-header
9
+ = Comable.t('admin.nav.product')
10
+ small<
11
+ = @products.total_count
12
+ = Comable.t('admin.results')
13
+
14
+ .row
15
+ section.col-sm-8
16
+ .panel.panel-inverse
17
+ .panel-heading
18
+ .panel-title
19
+ = Comable.t('admin.index')
20
+ - if @products.empty?
21
+ .panel-body
22
+ = Comable.t('admin.not_found')
23
+ - else
24
+ table.table.table-striped
25
+ thead
26
+ th
27
+ th
28
+ = sort_link [:comable, @q], :code
29
+ th
30
+ = sort_link [:comable, @q], :name
31
+ th
32
+ = sort_link [:comable, @q], :price
33
+ th
34
+ = sort_link [:comable, @q], :stocks_quantity
35
+ tbody
36
+ - @products.each do |product|
37
+ - quantity = product.stocks.to_a.sum(&:quantity)
38
+ tr
39
+ td.comable-image
40
+ = link_to comable.admin_product_path(product), class: 'thumbnail' do
41
+ = image_tag product.image_url
42
+ td
43
+ = link_to product.code, comable.admin_product_path(product)
44
+ td
45
+ = product.name
46
+ td
47
+ = number_to_currency product.price
48
+ td
49
+ strong class="#{(quantity <= 0) ? 'text-danger' : (quantity <= 10) ? 'text-warning' : 'text-success'}"
50
+ = number_with_delimiter product.stocks.to_a.sum(&:quantity)
51
+
52
+ .text-center
53
+ = paginate @products, theme: :comable_backend
54
+
55
+ nav.col-sm-4
56
+ #comable-affix
57
+ .panel
58
+ .list-group
59
+ = link_to Comable.t('admin.actions.new'), comable.new_admin_product_path, class: 'list-group-item'
60
+
61
+ .panel
62
+ .panel-body
63
+ = search_form_for @q, url: comable.admin_products_path do |f|
64
+ .form-horizontal
65
+ .form-group
66
+ .col-sm-3.control-label
67
+ = f.label :code
68
+ .col-sm-9
69
+ = f.text_field :code_cont
70
+ .form-group
71
+ .col-sm-3.control-label
72
+ = f.label :name
73
+ .col-sm-9
74
+ = f.text_field :name_cont
75
+ .text-right
76
+ = f.submit Comable.t('admin.search'), class: 'btn btn-default'
@@ -0,0 +1,17 @@
1
+ #comable-product
2
+ ol.breadcrumb
3
+ li
4
+ = link_to Comable.t('admin.nav.dashboard'), comable.admin_root_path
5
+ li.active
6
+ = link_to Comable.t('admin.nav.product'), comable.admin_products_path
7
+ li.active
8
+ = Comable.t('admin.actions.new')
9
+
10
+ h1.page-header
11
+ = Comable.t('admin.actions.new')
12
+
13
+ .row
14
+ section.col-sm-8
15
+ = render 'form'
16
+
17
+ nav.col-sm-4
@@ -1,4 +1,5 @@
1
- = form_for([comable, :admin, @shipment_method]) do |f|
1
+ = form_for [comable, :admin, @shipment_method] do |f|
2
+ / TODO: Standardize
2
3
  - if @shipment_method.errors.any?
3
4
  #error_explanation
4
5
  h2
@@ -9,25 +10,40 @@
9
10
  - @shipment_method.errors.full_messages.each do |message|
10
11
  li = message
11
12
 
12
- .activate_flag
13
- = f.label :activate_flag do
14
- span = f.check_box :activate_flag
15
- span = @shipment_method.class.human_attribute_name(:activate_flag)
13
+ .panel.panel-inverse
14
+ .panel-heading
15
+ .panel-title
16
+ = Comable.t('admin.nav.shipment_methods.edit')
16
17
 
17
- .name
18
- = f.label :name do
19
- span = @shipment_method.class.human_attribute_name(:name)
20
- span = f.text_field :name
18
+ .panel-body
19
+ .form-horizontal
20
+ fieldset
21
+ .form-group
22
+ .col-sm-3.control-label
23
+ = f.label :name
24
+ .col-sm-6
25
+ = f.text_field :name
21
26
 
22
- .fee
23
- = f.label :fee do
24
- span = @shipment_method.class.human_attribute_name(:fee)
25
- span = f.text_field :fee
27
+ .form-group
28
+ .col-sm-3.control-label
29
+ = f.label :fee
30
+ .col-sm-6
31
+ = f.text_field :fee
26
32
 
27
- .traking_url
28
- = f.label :traking_url do
29
- span = @shipment_method.class.human_attribute_name(:traking_url)
30
- span = f.text_field :traking_url
33
+ .form-group
34
+ .col-sm-3.control-label
35
+ = f.label :traking_url
36
+ .col-sm-6
37
+ = f.text_field :traking_url, placeholder: 'http://'
31
38
 
32
- .actions
33
- = f.submit
39
+ .form-group
40
+ .col-sm-offset-3.col-sm-6
41
+ .checkbox
42
+ = f.label :activate_flag do
43
+ = f.check_box :activate_flag
44
+ = f.object.class.human_attribute_name(:activate_flag)
45
+
46
+ .panel-footer
47
+ = link_to Comable.t('admin.actions.cancel'), comable.admin_shipment_methods_path, class: 'btn btn-default'
48
+ .pull-right
49
+ = f.submit