comable_frontend 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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +16 -4
  4. data/app/assets/javascripts/comable/frontend/application.coffee +5 -0
  5. data/app/assets/stylesheets/comable/frontend/application.scss +434 -0
  6. data/app/assets/stylesheets/comable/frontend/products.scss +0 -0
  7. data/app/assets/stylesheets/comable/products.scss +0 -0
  8. data/app/controllers/comable/application_controller.rb +2 -0
  9. data/app/controllers/comable/carts_controller.rb +32 -17
  10. data/app/controllers/comable/customers_controller.rb +5 -5
  11. data/app/controllers/comable/orders_controller.rb +31 -71
  12. data/app/controllers/comable/products_controller.rb +15 -1
  13. data/app/controllers/concerns/comable/payment_action.rb +3 -13
  14. data/app/controllers/concerns/comable/shipment_action.rb +2 -12
  15. data/app/controllers/concerns/comable/signin_action.rb +55 -0
  16. data/app/views/comable/carts/show.slim +65 -20
  17. data/app/views/comable/customers/_address.slim +7 -7
  18. data/app/views/comable/customers/addresses.slim +31 -29
  19. data/app/views/comable/customers/show.slim +60 -2
  20. data/app/views/comable/orders/confirm.slim +73 -30
  21. data/app/views/comable/orders/create.slim +6 -4
  22. data/app/views/comable/orders/delivery.slim +23 -14
  23. data/app/views/comable/orders/orderer.slim +38 -20
  24. data/app/views/comable/orders/payment.slim +12 -11
  25. data/app/views/comable/orders/shipment.slim +12 -10
  26. data/app/views/comable/orders/signin.slim +22 -0
  27. data/app/views/comable/products/index.slim +30 -10
  28. data/app/views/comable/products/show.slim +89 -21
  29. data/app/views/comable/shared/_address.slim +13 -20
  30. data/app/views/comable/shared/_address_form.slim +33 -15
  31. data/app/views/comable/shared/_footer.slim +2 -0
  32. data/app/views/comable/shared/_header.slim +74 -0
  33. data/app/views/comable/shared/_header_for_checkout.slim +18 -0
  34. data/app/views/kaminari/comable_frontend/_gap.html.slim +2 -0
  35. data/app/views/kaminari/comable_frontend/_next_page.html.slim +7 -0
  36. data/app/views/kaminari/comable_frontend/_page.html.slim +3 -0
  37. data/app/views/kaminari/comable_frontend/_paginator.html.slim +11 -0
  38. data/app/views/kaminari/comable_frontend/_prev_page.html.slim +7 -0
  39. data/app/views/layouts/comable/application.slim +23 -14
  40. data/config/routes.rb +9 -12
  41. data/lib/comable/frontend/engine.rb +8 -0
  42. metadata +151 -7
  43. data/app/controllers/concerns/comable/permitted_attributes.rb +0 -15
  44. data/app/views/comable/orders/new.slim +0 -4
@@ -1,14 +1,14 @@
1
1
  = render 'comable/shared/address', address: address
2
2
 
3
- .buttons
4
- .use_bill_address
5
- - if address != address.customer.bill_address
3
+ ul.buttons.list-inline
4
+ - if address != address.customer.bill_address
5
+ li.use_bill_address
6
6
  = form_for current_customer, as: :customer, url: comable.addresses_customer_url, method: :put do |f|
7
7
  = f.hidden_field :bill_address_id, value: address.id
8
- = f.submit 'use as billing address'
8
+ = f.submit Comable.t('use_as_billing_address'), class: 'btn btn-default'
9
9
 
10
- .use_ship_address
11
- - if address != address.customer.ship_address
10
+ - if address != address.customer.ship_address
11
+ li.use_ship_address
12
12
  = form_for current_customer, as: :customer, url: comable.addresses_customer_url, method: :put do |f|
13
13
  = f.hidden_field :ship_address_id, value: address.id
14
- = f.submit 'use as shipping address'
14
+ = f.submit Comable.t('use_as_shipping_address'), class: 'btn btn-default'
@@ -1,7 +1,7 @@
1
1
  .customer
2
2
  .addresses
3
3
  h1
4
- | Addresses
4
+ = Comable.t('address_book')
5
5
 
6
6
  - if current_customer.errors.any?
7
7
  .errors
@@ -12,41 +12,43 @@
12
12
  - if current_customer.addresses.empty?
13
13
  .not_found
14
14
  p
15
- | Not found.
15
+ = Comable.t('not_found')
16
16
  - else
17
- .bill_address
18
- h2
19
- | Bill address
20
- - if current_customer.bill_address
21
- = render 'address', address: current_customer.bill_address
22
- - else
23
- .not_found
24
- p
25
- | Not found.
17
+ .row
18
+ .bill_address.col-sm-6
19
+ h2
20
+ = current_customer.class.human_attribute_name(:bill_address)
21
+ - if current_customer.bill_address
22
+ = render 'address', address: current_customer.bill_address
23
+ - else
24
+ .not_found
25
+ p
26
+ = Comable.t('not_found')
26
27
 
27
- .ship_address
28
- h2
29
- | Ship address
30
- - if current_customer.ship_address
31
- = render 'address', address: current_customer.ship_address
32
- - else
33
- .not_found
34
- p
35
- | Not found.
28
+ .ship_address.col-sm-6
29
+ h2
30
+ = current_customer.class.human_attribute_name(:ship_address)
31
+ - if current_customer.ship_address
32
+ = render 'address', address: current_customer.ship_address
33
+ - else
34
+ .not_found
35
+ p
36
+ = Comable.t('not_found')
36
37
 
37
- .other_addresses
38
- h2
39
- | Other addresses
40
- ul
41
- - current_customer.other_addresses.each do |address|
42
- li
43
- = render 'address', address: address
38
+ .row
39
+ .other_addresses
40
+ h2
41
+ = Comable.t('other_addresses')
42
+ ul.list-unstyled
43
+ - current_customer.other_addresses.each do |address|
44
+ li.col-sm-4
45
+ = render 'address', address: address
44
46
 
45
47
  .new_address
46
48
  h2
47
- | New Address
49
+ = Comable.t('new_address')
48
50
  = form_for current_customer, as: :customer, url: comable.addresses_customer_url, method: :put do |f|
49
51
  = f.fields_for :addresses, current_customer.addresses.build do |ff|
50
52
  = render 'comable/shared/address_form', address: ff
51
53
  .submit
52
- = f.submit
54
+ = f.submit Comable.t('actions.create')
@@ -1,2 +1,60 @@
1
- .customer
2
- .name = current_customer.email
1
+ #comable-customer
2
+ h1
3
+ = Comable.t('my_account')
4
+
5
+ .comable-name
6
+ = current_customer.email
7
+
8
+ .comable-member-menu
9
+ ul
10
+ li
11
+ = link_to Comable.t('change_email_or_password'), comable.edit_customer_path
12
+ li
13
+ = link_to Comable.t('edit_your_address_book'), comable.addresses_customer_path
14
+
15
+ .coamble-orders
16
+ h2
17
+ = Comable.t('order_history')
18
+ - @orders.each do |order|
19
+ table
20
+ thead
21
+ tr
22
+ th
23
+ = order.class.human_attribute_name(:completed_at)
24
+ th
25
+ = order.class.human_attribute_name(:total_price)
26
+ th
27
+ = order.class.human_attribute_name(:bill_address)
28
+ th
29
+ = order.class.human_attribute_name(:code)
30
+ tbody
31
+ tr
32
+ td
33
+ = l order.completed_at.to_date, format: :long
34
+ td
35
+ = number_to_currency order.total_price
36
+ td
37
+ = order.bill_address.full_name
38
+ td
39
+ = order.code
40
+ - order.order_details.each do |order_detail|
41
+ tr
42
+ td colspan="4"
43
+ .comable-detail
44
+ .row
45
+ .col-sm-2.comable-image
46
+ = link_to comable.product_path(order_detail.product), class: 'thumbnail' do
47
+ = image_tag order_detail.product.image_url, width: '100%'
48
+ .col-sm-10
49
+ .comable-name
50
+ = link_to order_detail.name_with_sku, comable.product_path(order_detail.product)
51
+ .comable-repeat
52
+ = form_tag comable.add_cart_path do
53
+ - if order_detail.stock.unsold?
54
+ .add_cart.form-inline.form-group
55
+ = hidden_field_tag :stock_id, order_detail.stock_id
56
+ = hidden_field_tag :quantity, order_detail.quantity
57
+ = submit_tag Comable.t('reorder'), class: 'btn btn-default'
58
+
59
+ .text-center
60
+ = paginate @orders, theme: :comable_frontend
@@ -1,35 +1,78 @@
1
- h1 注文情報確認
1
+ #comable-order
2
+ h1
3
+ = @order.class.human_state_name(:confirm)
2
4
 
3
- .order
4
- .bill_address
5
- h2
6
- | Billing address
7
- = render 'comable/shared/address', address: @order.bill_address if @order.bill_address
5
+ section.col-sm-8
6
+ .row
7
+ .col-sm-4.comable-bill_address
8
+ h2
9
+ = @order.class.human_attribute_name(:bill_address)
10
+ .comable-email
11
+ = @order.email
12
+ = render 'comable/shared/address', address: @order.bill_address
8
13
 
9
- .ship_address
10
- h2
11
- | Shipping address
12
- = render 'comable/shared/address', address: @order.ship_address if @order.ship_address
14
+ .col-sm-4.comable-ship_address
15
+ h2
16
+ = @order.class.human_attribute_name(:ship_address)
17
+ = render 'comable/shared/address', address: @order.ship_address
13
18
 
14
- .details
15
- h2
16
- | Order details
17
- - @order.order_deliveries.first.order_details.each do |order_detail|
18
- .name
19
- = order_detail.stock.name
20
- .price
21
- = order_detail.price
22
- .quantity
23
- = order_detail.quantity
19
+ - if @order.payment_method
20
+ .col-sm-4.comable-payment_method
21
+ h2
22
+ = @order.class.human_attribute_name(:payment_method)
23
+ = @order.payment_method.name
24
24
 
25
- .total
26
- h2 お会計
27
- .item_total_price
28
- = number_to_currency @order.current_item_total_price
29
- .shipment_fee
30
- = number_to_currency @order.current_shipment_fee
31
- .total_price
32
- = number_to_currency @order.current_total_price
25
+ - if @order.shipment_method
26
+ .row
27
+ .col-sm-12.comable-shipment_method
28
+ h2
29
+ = @order.class.human_attribute_name(:shipment_method)
30
+ = @order.shipment_method.name
33
31
 
34
- = form_for @order, as: :order, url: comable.order_path, method: :post do |f|
35
- = f.submit
32
+ .row
33
+ .col-sm-12.comable-order_details
34
+ table
35
+ thead
36
+ tr
37
+ th
38
+ th
39
+ = @order.order_details.human_attribute_name(:price)
40
+ th
41
+ = @order.order_details.human_attribute_name(:quantity)
42
+
43
+ tbody
44
+ - @order.order_details.each do |order_detail|
45
+ tr
46
+ td
47
+ .name
48
+ = order_detail.name_with_sku
49
+ .caption
50
+ = order_detail.product.caption
51
+ td.price
52
+ = number_to_currency order_detail.price
53
+ td.quantity
54
+ = number_with_delimiter order_detail.quantity
55
+
56
+ aside.col-sm-4
57
+ table
58
+ thead
59
+ tr
60
+ th colspan="2"
61
+ = form_for @order, as: :order, url: comable.order_path, method: :post do |f|
62
+ = f.submit Comable.t('complete_order')
63
+ tbody
64
+ tr
65
+ th.text-right
66
+ = @order.class.human_attribute_name(:item_total_price)
67
+ td
68
+ = number_to_currency @order.current_item_total_price
69
+ tr
70
+ th.text-right
71
+ = @order.class.human_attribute_name(:shipment_fee)
72
+ td
73
+ = number_to_currency @order.current_shipment_fee
74
+ tr
75
+ th.text-right
76
+ = @order.class.human_attribute_name(:total_price)
77
+ td
78
+ = number_to_currency @order.current_total_price
@@ -1,5 +1,7 @@
1
- h1 注文完了
1
+ #comable-order
2
+ .comable-complete
3
+ h1
4
+ = @order.class.human_state_name(:complete)
2
5
 
3
- .order
4
- .code
5
- = @order.code
6
+ .comable-code
7
+ = @order.code
@@ -1,26 +1,34 @@
1
- .order
2
- .ship_address
1
+ #comable-order
2
+ .comable-ship_address
3
3
  h1
4
- | Shipping address
4
+ = @order.class.human_state_name(:delivery)
5
5
 
6
- - if @order.ship_address
6
+ - if @order.ship_address.try(:persisted?)
7
7
  = render 'comable/shared/address', address: @order.ship_address
8
- = link_to 'Next step', next_order_path
8
+ = link_to Comable.t('next_step'), next_order_path
9
+
10
+ .edit.row
11
+ h2
12
+ = Comable.t('edit_shipping_address')
13
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
14
+ = f.fields_for :ship_address do |ff|
15
+ = render 'comable/shared/address_form', address: ff
16
+ = f.submit Comable.t('next_step')
9
17
 
10
18
  - if current_customer.other_addresses.any?
11
- .other_addresses
19
+ .other_addresses.row
12
20
  h2
13
- | Other addresses
14
- ul
21
+ = Comable.t('other_addresses')
22
+ ul.list-unstyled
15
23
  - current_customer.addresses.each do |address|
16
24
  - next if @order.ship_address.same_as? address
17
- li
25
+ li.col-sm-4
18
26
  = render 'comable/shared/address', address: address
19
- = form_for @order, as: :order, url: comable.delivery_order_path, method: :put do |f|
27
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
20
28
  .hidden
21
29
  = f.fields_for :ship_address, address.clone do |ff|
22
30
  = render 'comable/shared/address_form', address: ff
23
- = f.submit 'Use this'
31
+ = f.submit Comable.t('use_this_address'), class: 'btn btn-default'
24
32
 
25
33
  - else
26
34
  / TODO: Standardize
@@ -32,8 +40,9 @@
32
40
 
33
41
  .new
34
42
  h2
35
- | New shipping address
36
- = form_for @order, as: :order, url: comable.delivery_order_path, method: :put do |f|
43
+ = Comable.t('new_shipping_address')
44
+ - @order.ship_address ||= @order.build_ship_address
45
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
37
46
  = f.fields_for :ship_address do |ff|
38
47
  = render 'comable/shared/address_form', address: ff
39
- = f.submit
48
+ = f.submit Comable.t('next_step')
@@ -1,26 +1,43 @@
1
- .order
2
- .bill_address
1
+ #comable-order
2
+ .comable-bill_address
3
3
  h1
4
- | Billing address
4
+ = @order.class.human_state_name(:orderer)
5
5
 
6
- - if @order.bill_address
6
+ - if @order.bill_address.try(:persisted?)
7
+ .comable-email
8
+ = @order.email
7
9
  = render 'comable/shared/address', address: @order.bill_address
8
- = link_to 'Next step', next_order_path
10
+ = link_to Comable.t('next_step'), next_order_path
11
+
12
+ .edit.row
13
+ h2
14
+ = Comable.t('edit_billing_address')
15
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
16
+ .form-group
17
+ .col-sm-2.control-label
18
+ = f.label :email
19
+ .col-sm-10
20
+ = f.email_field :email, placeholder: @order.class.human_attribute_name(:email)
21
+
22
+ = f.fields_for :bill_address do |ff|
23
+ = render 'comable/shared/address_form', address: ff
24
+
25
+ = f.submit Comable.t('next_step')
9
26
 
10
27
  - if current_customer.other_addresses.any?
11
- .other_addresses
28
+ .other_addresses.row
12
29
  h2
13
- | Other addresses
14
- ul
30
+ = Comable.t('other_addresses')
31
+ ul.list-unstyled
15
32
  - current_customer.addresses.each do |address|
16
33
  - next if @order.bill_address.same_as? address
17
- li
34
+ li.col-sm-4
18
35
  = render 'comable/shared/address', address: address
19
- = form_for @order, as: :order, url: comable.orderer_order_path, method: :put do |f|
36
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
20
37
  .hidden
21
38
  = f.fields_for :bill_address, address.clone do |ff|
22
39
  = render 'comable/shared/address_form', address: ff
23
- = f.submit 'Use this'
40
+ = f.submit Comable.t('use_this_address'), class: 'btn btn-default'
24
41
 
25
42
  - else
26
43
  / TODO: Standardize
@@ -32,15 +49,16 @@
32
49
 
33
50
  .new
34
51
  h2
35
- | New billing address
36
- = form_for @order, as: :order, url: comable.orderer_order_path, method: :put do |f|
37
- = f.email_field :email, placeholder: @order.class.human_attribute_name(:email)
52
+ = Comable.t('new_billing_address')
53
+ - @order.bill_address ||= @order.build_bill_address
54
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
55
+ .form-group
56
+ .col-sm-2.control-label
57
+ = f.label :email
58
+ .col-sm-10
59
+ = f.email_field :email, placeholder: @order.class.human_attribute_name(:email)
60
+
38
61
  = f.fields_for :bill_address do |ff|
39
62
  = render 'comable/shared/address_form', address: ff
40
- = f.submit
41
63
 
42
- / for old spec
43
- / TODO: Remove
44
- .hidden
45
- = f.text_field :family_name, placeholder: '姓'
46
- = f.text_field :first_name, placeholder: '名'
64
+ = f.submit Comable.t('next_step')
@@ -1,12 +1,13 @@
1
- h1 決済方法
1
+ #comable-order
2
+ .comable-pyament
3
+ h1
4
+ = @order.class.human_state_name(:payment)
2
5
 
3
- .order.payment
4
- = form_for @order, as: :order, url: comable.payment_order_path, method: :put do |f|
5
- ul
6
- - Comable::Payment.all.each.with_index do |payment, index|
7
- li
8
- - payment_foreign_key = Comable::Payment.table_name.singularize.foreign_key.to_sym
9
- - checked_flag = @order.payment ? (@order.payment.id == payment.id) : index.zero?
10
- = f.radio_button payment_foreign_key, payment.id, checked: checked_flag
11
- = f.label payment_foreign_key, payment.name, value: payment.id
12
- = f.submit
6
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
7
+ ul
8
+ - Comable::PaymentMethod.all.each.with_index do |payment_method, index|
9
+ li
10
+ - checked_flag = @order.payment_method ? (@order.payment_method.id == payment_method.id) : index.zero?
11
+ = f.radio_button :payment_method_id, payment_method.id, checked: checked_flag
12
+ = f.label :payment_method_id, payment_method.name, value: payment_method.id
13
+ = f.submit Comable.t('next_step')