comable-frontend 0.6.0

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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +97 -0
  4. data/app/assets/images/comable/frontend/home-one.jpg +0 -0
  5. data/app/assets/images/comable/frontend/home-top.jpg +0 -0
  6. data/app/assets/javascripts/comable/frontend/application.coffee +5 -0
  7. data/app/assets/stylesheets/comable/frontend/application.scss +527 -0
  8. data/app/assets/stylesheets/comable/frontend/products.scss +0 -0
  9. data/app/assets/stylesheets/comable/products.scss +0 -0
  10. data/app/controllers/comable/application_controller.rb +12 -0
  11. data/app/controllers/comable/carts_controller.rb +66 -0
  12. data/app/controllers/comable/home_controller.rb +14 -0
  13. data/app/controllers/comable/orders_controller.rb +97 -0
  14. data/app/controllers/comable/pages_controller.rb +19 -0
  15. data/app/controllers/comable/products_controller.rb +25 -0
  16. data/app/controllers/comable/users_controller.rb +29 -0
  17. data/app/controllers/concerns/comable/payment_action.rb +17 -0
  18. data/app/controllers/concerns/comable/shipment_action.rb +17 -0
  19. data/app/controllers/concerns/comable/signin_action.rb +55 -0
  20. data/app/views/comable/carts/show.slim +67 -0
  21. data/app/views/comable/home/show.slim +24 -0
  22. data/app/views/comable/orders/confirm.slim +83 -0
  23. data/app/views/comable/orders/create.slim +7 -0
  24. data/app/views/comable/orders/delivery.slim +48 -0
  25. data/app/views/comable/orders/orderer.slim +64 -0
  26. data/app/views/comable/orders/payment.slim +15 -0
  27. data/app/views/comable/orders/shipment.slim +15 -0
  28. data/app/views/comable/orders/signin.slim +22 -0
  29. data/app/views/comable/pages/show.slim +7 -0
  30. data/app/views/comable/products/index.slim +20 -0
  31. data/app/views/comable/products/show.slim +89 -0
  32. data/app/views/comable/shared/_address.slim +13 -0
  33. data/app/views/comable/shared/_address_form.slim +39 -0
  34. data/app/views/comable/shared/_footer.slim +39 -0
  35. data/app/views/comable/shared/_header.slim +74 -0
  36. data/app/views/comable/shared/_header_for_checkout.slim +18 -0
  37. data/app/views/comable/shared/_products.slim +23 -0
  38. data/app/views/comable/shared/_tracker.slim +2 -0
  39. data/app/views/comable/users/_address.slim +14 -0
  40. data/app/views/comable/users/addresses.slim +54 -0
  41. data/app/views/comable/users/show.slim +60 -0
  42. data/app/views/kaminari/comable_frontend/_gap.html.slim +2 -0
  43. data/app/views/kaminari/comable_frontend/_next_page.html.slim +7 -0
  44. data/app/views/kaminari/comable_frontend/_page.html.slim +3 -0
  45. data/app/views/kaminari/comable_frontend/_paginator.html.slim +11 -0
  46. data/app/views/kaminari/comable_frontend/_prev_page.html.slim +7 -0
  47. data/app/views/layouts/comable/application.slim +35 -0
  48. data/config/routes.rb +34 -0
  49. data/lib/comable/frontend/engine.rb +29 -0
  50. data/lib/comable/frontend.rb +1 -0
  51. data/lib/tasks/comable_backend_tasks.rake +4 -0
  52. metadata +295 -0
@@ -0,0 +1,66 @@
1
+ module Comable
2
+ class CartsController < Comable::ApplicationController
3
+ before_filter :set_cart_item, only: [:add, :update]
4
+ before_filter :ensure_found_cart_item, only: [:add, :update]
5
+
6
+ def add
7
+ if current_comable_user.add_cart_item(@cart_item, cart_item_options)
8
+ redirect_to comable.cart_path, notice: Comable.t('carts.added')
9
+ else
10
+ flash.now[:alert] = Comable.t('carts.invalid')
11
+ render :show
12
+ end
13
+ end
14
+
15
+ def update
16
+ if current_comable_user.reset_cart_item(@cart_item, cart_item_options)
17
+ redirect_to comable.cart_path, notice: Comable.t('carts.updated')
18
+ else
19
+ flash.now[:alert] = Comable.t('carts.invalid')
20
+ render :show
21
+ end
22
+ end
23
+
24
+ def destroy
25
+ cart_item = find_cart_item
26
+ return redirect_by_product_not_found unless cart_item
27
+
28
+ if current_comable_user.reset_cart_item(cart_item)
29
+ redirect_to comable.cart_path, notice: Comable.t('carts.updated')
30
+ else
31
+ flash.now[:alert] = Comable.t('carts.invalid')
32
+ render :show
33
+ end
34
+ end
35
+
36
+ def checkout
37
+ current_order.next_state if current_order.state?(:cart)
38
+ redirect_to comable.next_order_path(state: :confirm)
39
+ end
40
+
41
+ private
42
+
43
+ def set_cart_item
44
+ @cart_item = find_cart_item
45
+ end
46
+
47
+ def ensure_found_cart_item
48
+ return if @cart_item
49
+ redirect_to :back, alert: Comable.t('errors.messages.products_not_found')
50
+ end
51
+
52
+ def find_cart_item
53
+ cart_item = Comable::Stock.where(id: params[:stock_id]).first
54
+ cart_item ||= Comable::Product.where(id: params[:product_id]).first
55
+ return unless cart_item
56
+ return if cart_item.is_a?(Comable::Product) && cart_item.sku?
57
+ cart_item
58
+ end
59
+
60
+ def cart_item_options
61
+ options = {}
62
+ options.update(quantity: params[:quantity].to_i) if params[:quantity]
63
+ options
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,14 @@
1
+ module Comable
2
+ class HomeController < Comable::ApplicationController
3
+ before_filter :load_products, only: :show
4
+
5
+ def show
6
+ end
7
+
8
+ private
9
+
10
+ def load_products
11
+ @products = Comable::Product.limit(5)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,97 @@
1
+ module Comable
2
+ class OrdersController < Comable::ApplicationController
3
+ # TODO: Change the method name to load_order_with_params
4
+ before_filter :load_order
5
+ before_filter :ensure_cart_not_empty
6
+ before_filter :ensure_saleable_stocks
7
+ before_filter :ensure_correct_flow, only: :create
8
+
9
+ prepend Comable::SigninAction
10
+ prepend Comable::ShipmentAction
11
+ prepend Comable::PaymentAction
12
+ include Comable::PermittedAttributes
13
+
14
+ def edit
15
+ if @order.state?(params[:state]) || @order.stated?(params[:state])
16
+ render params[:state]
17
+ else
18
+ redirect_to next_order_path
19
+ end
20
+ end
21
+
22
+ def update
23
+ if @order.stated?(params[:state]) ? @order.save : @order.next_state
24
+ redirect_to next_order_path
25
+ else
26
+ render @order.state
27
+ end
28
+ end
29
+
30
+ def create
31
+ @order.next_state!
32
+
33
+ flash.now[:notice] = Comable.t('orders.success')
34
+ send_order_complete_mail
35
+ rescue ActiveRecord::RecordInvalid
36
+ flash[:alert] = @order.errors.full_messages.join
37
+ redirect_to next_order_path
38
+ end
39
+
40
+ private
41
+
42
+ def send_order_complete_mail
43
+ return unless current_store.can_send_mail?
44
+ if Rails.version =~ /^4.2./
45
+ Comable::OrderMailer.complete(@order).deliver_now
46
+ else
47
+ Comable::OrderMailer.complete(@order).deliver
48
+ end
49
+ end
50
+
51
+ def ensure_cart_not_empty
52
+ return if current_comable_user.cart.any?
53
+ flash[:alert] = Comable.t('carts.empty')
54
+ redirect_to comable.cart_path
55
+ end
56
+
57
+ def ensure_saleable_stocks
58
+ return if current_order.stocked_items.empty?
59
+ flash[:alert] = Comable.t('errors.messages.out_of_stocks')
60
+ redirect_to comable.cart_path
61
+ end
62
+
63
+ def ensure_correct_flow
64
+ return if @order.state?(:confirm)
65
+ redirect_to next_order_path
66
+ end
67
+
68
+ def load_order
69
+ @order = current_order
70
+ @order.attributes = order_params if order_params
71
+ end
72
+
73
+ def order_params
74
+ return unless params[:order]
75
+ return unless params[:state]
76
+ case params[:state].to_sym
77
+ when :orderer
78
+ order_params_for_orderer
79
+ when :delivery
80
+ order_params_for_delivery
81
+ end
82
+ end
83
+
84
+ def order_params_for_orderer
85
+ params.require(:order).permit(
86
+ :email,
87
+ bill_address_attributes: permitted_address_attributes
88
+ )
89
+ end
90
+
91
+ def order_params_for_delivery
92
+ params.require(:order).permit(
93
+ ship_address_attributes: permitted_address_attributes
94
+ )
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,19 @@
1
+ module Comable
2
+ class PagesController < Comable::ApplicationController
3
+ def show
4
+ if Rails::VERSION::MAJOR == 3
5
+ @page = Comable::Page.find(params[:id])
6
+ else
7
+ @page = Comable::Page.friendly.find(params[:id])
8
+ end
9
+ fail ActiveRecord::RecordNotFound unless @page && (@page.published? || preview?)
10
+ end
11
+
12
+ private
13
+
14
+ def preview?
15
+ session[Comable::Page::PREVIEW_SESSION_KEY] ||= {}
16
+ session[Comable::Page::PREVIEW_SESSION_KEY][@page.slug]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ module Comable
2
+ class ProductsController < Comable::ApplicationController
3
+ before_filter :load_category_and_products, only: :index
4
+
5
+ def index
6
+ @products = @products.page(params[:page]).per(Comable::Config.products_per_page)
7
+ end
8
+
9
+ def show
10
+ @product = Comable::Product.find(params[:id])
11
+ end
12
+
13
+ private
14
+
15
+ def load_category_and_products
16
+ @category = Comable::Category.where(id: params[:category_id]).first
17
+ if @category
18
+ subtree_of_category = Comable::Category.subtree_of(@category)
19
+ @products = Comable::Product.eager_load(:categories).merge(subtree_of_category)
20
+ else
21
+ @products = Comable::Product.search(params[:q])
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module Comable
2
+ class UsersController < Comable::ApplicationController
3
+ include Comable::PermittedAttributes
4
+
5
+ before_filter :authenticate_user!
6
+
7
+ def show
8
+ @orders = current_comable_user.orders.page(params[:page]).per(Comable::Config.orders_per_page)
9
+ end
10
+
11
+ def update_addresses
12
+ current_comable_user.attributes = user_params
13
+ if current_comable_user.save
14
+ flash.now[:notice] = Comable.t('successful')
15
+ else
16
+ flash.now[:alert] = Comable.t('failure')
17
+ end
18
+ render :addresses
19
+ end
20
+
21
+ def user_params
22
+ params.require(:user).permit(
23
+ :bill_address_id,
24
+ :ship_address_id,
25
+ addresses_attributes: permitted_address_attributes
26
+ )
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module Comable
2
+ module PaymentAction
3
+ private
4
+
5
+ # orderride OrdersController#order_params
6
+ def order_params
7
+ return super unless params[:state] == 'payment'
8
+ order_params_for_payment
9
+ end
10
+
11
+ def order_params_for_payment
12
+ params.fetch(:order, {}).permit(
13
+ payment_attributes: [:payment_method_id]
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Comable
2
+ module ShipmentAction
3
+ private
4
+
5
+ # orderride OrdersController#order_params
6
+ def order_params
7
+ return super unless params[:state] == 'shipment'
8
+ order_params_for_shipment
9
+ end
10
+
11
+ def order_params_for_shipment
12
+ params.fetch(:order, {}).permit(
13
+ shipment_attributes: [:shipment_method_id]
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ module Comable
2
+ module SigninAction
3
+ class << self
4
+ def prepended(base)
5
+ base.instance_eval do
6
+ before_filter :ensure_signed_in_or_guest, except: [:signin, :guest]
7
+
8
+ helper_method :resource
9
+ helper_method :resource_name
10
+ helper_method :devise_mapping
11
+ end
12
+ end
13
+ end
14
+
15
+ def guest
16
+ if @order.state?(:cart) ? @order.next_state : @order.save
17
+ redirect_to next_order_path
18
+ else
19
+ render :signin
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def ensure_signed_in_or_guest
26
+ return if @order.email
27
+ store_location
28
+ redirect_to comable.signin_order_path
29
+ end
30
+
31
+ def resource
32
+ current_comable_user
33
+ end
34
+
35
+ def resource_name
36
+ :user
37
+ end
38
+
39
+ def devise_mapping
40
+ Devise.mappings[resource_name]
41
+ end
42
+
43
+ # orderride OrdersController#order_params
44
+ def order_params
45
+ return super unless action_name.in? %w( signin guest )
46
+ order_params_for_signin
47
+ end
48
+
49
+ def order_params_for_signin
50
+ params.fetch(:order, {}).permit(
51
+ :email
52
+ )
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,67 @@
1
+ #carts
2
+ section.cart.col-sm-8
3
+ h1
4
+ = Comable.t('shopping_cart')
5
+
6
+ - if current_comable_user.cart.errors.any?
7
+ .errors
8
+ ul
9
+ - current_comable_user.cart.errors.full_messages.each do |message|
10
+ li = message
11
+
12
+ - if current_comable_user.cart.empty?
13
+ = Comable.t('carts.empty')
14
+ - else
15
+ table
16
+ thead
17
+ tr
18
+ th
19
+ th
20
+ = Comable.t('price')
21
+ th
22
+ = Comable.t('quantity')
23
+ th
24
+
25
+ tbody
26
+ - current_comable_user.cart.each do |cart_item|
27
+ - stock = cart_item.stock
28
+ - product = stock.product
29
+ tr
30
+ td
31
+ .name
32
+ = link_to stock.name_with_sku, comable.product_path(product)
33
+ .caption
34
+ = product.caption
35
+ - if cart_item.unstocked?
36
+ .error.soldout = Comable.t('soldout')
37
+ td.price
38
+ = number_to_currency product.price
39
+ td.quantity
40
+ = form_tag comable.cart_path, method: :put do
41
+ .form-inline.form-group
42
+ - selected = cart_item.quantity
43
+ = select_tag :quantity, options_for_select(1.upto([10, selected].max).to_a, selected)
44
+ = hidden_field_tag :stock_id, stock.id
45
+ = submit_tag Comable.t('actions.update'), class: 'btn-default'
46
+ td
47
+ = link_to Comable.t('actions.destroy'), comable.cart_path(stock_id: stock.id), method: :delete
48
+
49
+ - if current_comable_user.cart.any?
50
+ section.order.col-sm-4
51
+ table
52
+ thead
53
+ tr
54
+ th colspan="2"
55
+ = form_for current_order, as: :order, url: comable.checkout_cart_path, method: :put do |f|
56
+ = f.submit Comable.t('checkout'), class: 'btn btn-primary btn-lg btn-block'
57
+ tbody
58
+ tr.price
59
+ th.text-right
60
+ = Comable.t('item_total_price')
61
+ td
62
+ = number_to_currency current_comable_user.cart.price
63
+ tr.count
64
+ th.text-right
65
+ = Comable.t('item_total_quantity')
66
+ td
67
+ = number_with_delimiter current_comable_user.cart.count
@@ -0,0 +1,24 @@
1
+ #comable-home
2
+ section.comable-home-top
3
+ = image_tag 'comable/frontend/home-top.jpg'
4
+
5
+ section#comable-product
6
+ .container
7
+ .products
8
+ = render 'comable/shared/products'
9
+
10
+ section.comable-home-one
11
+ h2
12
+ = Comable.t('sample_header')
13
+ h3
14
+ = Comable.t('sample_subheader')
15
+ p
16
+ = Comable.t('sample_text')
17
+
18
+ section.comable-home-two
19
+ h2
20
+ = Comable.t('sample_header')
21
+ h3
22
+ = Comable.t('sample_subheader')
23
+ p
24
+ = Comable.t('sample_text')
@@ -0,0 +1,83 @@
1
+ #comable-order
2
+ h1
3
+ = @order.class.human_state_name(:confirm)
4
+
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
13
+
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
18
+
19
+ - if @order.payment
20
+ .col-sm-4.comable-payment_method
21
+ h2
22
+ = @order.class.human_attribute_name(:payment_method)
23
+ = @order.payment.name
24
+
25
+ - if @order.shipment
26
+ .row
27
+ .col-sm-12.comable-shipment
28
+ h2
29
+ = @order.class.human_attribute_name(:shipment_method)
30
+ = @order.shipment.name
31
+
32
+ .row
33
+ .col-sm-12.comable-order_items
34
+ table
35
+ thead
36
+ tr
37
+ th
38
+ th
39
+ = @order.order_items.human_attribute_name(:price)
40
+ th
41
+ = @order.order_items.human_attribute_name(:quantity)
42
+
43
+ tbody
44
+ - @order.order_items.each do |order_item|
45
+ tr
46
+ td
47
+ .name
48
+ = order_item.name_with_sku
49
+ .caption
50
+ = order_item.product.caption
51
+ td.price
52
+ = number_to_currency order_item.price
53
+ td.quantity
54
+ = number_with_delimiter order_item.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(:payment_fee)
72
+ td
73
+ = number_to_currency @order.current_payment_fee
74
+ tr
75
+ th.text-right
76
+ = @order.class.human_attribute_name(:shipment_fee)
77
+ td
78
+ = number_to_currency @order.current_shipment_fee
79
+ tr
80
+ th.text-right
81
+ = @order.class.human_attribute_name(:total_price)
82
+ td
83
+ = number_to_currency @order.current_total_price
@@ -0,0 +1,7 @@
1
+ #comable-order
2
+ .comable-completed
3
+ h1
4
+ = @order.class.human_state_name(:completed)
5
+
6
+ .comable-code
7
+ = @order.code
@@ -0,0 +1,48 @@
1
+ #comable-order
2
+ .comable-ship_address
3
+ h1
4
+ = @order.class.human_state_name(:delivery)
5
+
6
+ - if @order.ship_address.try(:persisted?)
7
+ = render 'comable/shared/address', address: @order.ship_address
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')
17
+
18
+ - if current_comable_user.other_addresses.any?
19
+ .other_addresses.row
20
+ h2
21
+ = Comable.t('other_addresses')
22
+ ul.list-unstyled
23
+ - current_comable_user.addresses.each do |address|
24
+ - next if @order.ship_address.same_as? address
25
+ li.col-sm-4
26
+ = render 'comable/shared/address', address: address
27
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
28
+ .hidden
29
+ = f.fields_for :ship_address, address.clone do |ff|
30
+ = render 'comable/shared/address_form', address: ff
31
+ = f.submit Comable.t('use_this_address'), class: 'btn btn-default'
32
+
33
+ - else
34
+ / TODO: Standardize
35
+ - if @order.errors.any?
36
+ .error_messages
37
+ ul
38
+ - @order.errors.full_messages.each do |full_message|
39
+ li = full_message
40
+
41
+ .new
42
+ h2
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|
46
+ = f.fields_for :ship_address do |ff|
47
+ = render 'comable/shared/address_form', address: ff
48
+ = f.submit Comable.t('next_step')
@@ -0,0 +1,64 @@
1
+ #comable-order
2
+ .comable-bill_address
3
+ h1
4
+ = @order.class.human_state_name(:orderer)
5
+
6
+ - if @order.bill_address.try(:persisted?)
7
+ .comable-email
8
+ = @order.email
9
+ = render 'comable/shared/address', address: @order.bill_address
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')
26
+
27
+ - if current_comable_user.other_addresses.any?
28
+ .other_addresses.row
29
+ h2
30
+ = Comable.t('other_addresses')
31
+ ul.list-unstyled
32
+ - current_comable_user.addresses.each do |address|
33
+ - next if @order.bill_address.same_as? address
34
+ li.col-sm-4
35
+ = render 'comable/shared/address', address: address
36
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
37
+ .hidden
38
+ = f.fields_for :bill_address, address.clone do |ff|
39
+ = render 'comable/shared/address_form', address: ff
40
+ = f.submit Comable.t('use_this_address'), class: 'btn btn-default'
41
+
42
+ - else
43
+ / TODO: Standardize
44
+ - if @order.errors.any?
45
+ .error_messages
46
+ ul
47
+ - @order.errors.full_messages.each do |full_message|
48
+ li = full_message
49
+
50
+ .new
51
+ h2
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
+
61
+ = f.fields_for :bill_address do |ff|
62
+ = render 'comable/shared/address_form', address: ff
63
+
64
+ = f.submit Comable.t('next_step')
@@ -0,0 +1,15 @@
1
+ #comable-order
2
+ .comable-payment
3
+ h1
4
+ = @order.class.human_state_name(:payment)
5
+
6
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
7
+ - payment = @order.payment || @order.build_payment
8
+ = f.fields_for :payment, payment do |ff|
9
+ ul
10
+ - Comable::PaymentMethod.all.each.with_index do |payment_method, index|
11
+ li
12
+ - checked_flag = payment.payment_method ? (payment.payment_method == payment_method) : index.zero?
13
+ = ff.radio_button :payment_method_id, payment_method.id, checked: checked_flag
14
+ = ff.label :payment_method_id, payment_method.name, value: payment_method.id
15
+ = f.submit Comable.t('next_step')
@@ -0,0 +1,15 @@
1
+ #comable-order
2
+ .comable-shipment
3
+ h1
4
+ = @order.class.human_state_name(:shipment)
5
+
6
+ = form_for @order, as: :order, url: update_order_path, method: :put do |f|
7
+ - shipment = @order.shipment || @order.build_shipment
8
+ = f.fields_for :shipment, shipment do |ff|
9
+ ul
10
+ - Comable::ShipmentMethod.activated.each.with_index do |shipment_method, index|
11
+ li
12
+ - checked_flag = shipment.shipment_method ? (shipment.shipment_method == shipment_method) : index.zero?
13
+ = ff.radio_button :shipment_method_id, shipment_method.id, checked: checked_flag
14
+ = ff.label :shipment_method_id, shipment_method.name, value: shipment_method.id
15
+ = f.submit Comable.t('next_step')