comable_backend 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/comable/admin/application.coffee +4 -0
  3. data/app/assets/stylesheets/comable/admin/_common.scss +23 -0
  4. data/app/assets/stylesheets/comable/admin/_flow.scss +149 -0
  5. data/app/assets/stylesheets/comable/admin/application.scss +1 -0
  6. data/app/assets/stylesheets/comable/admin/overrides/bootstrap.scss +1 -0
  7. data/app/controllers/comable/admin/application_controller.rb +24 -4
  8. data/app/controllers/comable/admin/dashboard_controller.rb +4 -4
  9. data/app/controllers/comable/admin/orders_controller.rb +82 -1
  10. data/app/controllers/comable/admin/payment_methods_controller.rb +1 -0
  11. data/app/controllers/comable/admin/products_controller.rb +16 -0
  12. data/app/controllers/comable/admin/stocks_controller.rb +16 -0
  13. data/app/controllers/comable/admin/trackers_controller.rb +58 -0
  14. data/app/controllers/comable/admin/{customers_controller.rb → users_controller.rb} +8 -8
  15. data/app/helpers/comable/admin/orders_helper.rb +30 -0
  16. data/app/views/comable/admin/categories/index.slim +2 -2
  17. data/app/views/comable/admin/dashboard/show.slim +9 -10
  18. data/app/views/comable/admin/orders/_payment_state.slim +40 -0
  19. data/app/views/comable/admin/orders/_shipment_state.slim +44 -0
  20. data/app/views/comable/admin/orders/edit.slim +112 -0
  21. data/app/views/comable/admin/orders/index.slim +22 -6
  22. data/app/views/comable/admin/orders/show.slim +141 -110
  23. data/app/views/comable/admin/payment_methods/_form.slim +6 -2
  24. data/app/views/comable/admin/products/_form.slim +9 -9
  25. data/app/views/comable/admin/products/index.slim +16 -0
  26. data/app/views/comable/admin/shared/_header.slim +3 -3
  27. data/app/views/comable/admin/shared/_sidebar.slim +5 -3
  28. data/app/views/comable/admin/shared/export.xlsx.axlsx +17 -0
  29. data/app/views/comable/admin/shipment_methods/_form.slim +2 -2
  30. data/app/views/comable/admin/stocks/_form.slim +2 -2
  31. data/app/views/comable/admin/stocks/index.slim +16 -0
  32. data/app/views/comable/admin/store/_form.slim +2 -2
  33. data/app/views/comable/admin/trackers/_form.slim +109 -0
  34. data/app/views/comable/admin/trackers/edit.slim +27 -0
  35. data/app/views/comable/admin/trackers/index.slim +37 -0
  36. data/app/views/comable/admin/trackers/new.slim +16 -0
  37. data/app/views/comable/admin/{customers → users}/edit.slim +10 -10
  38. data/app/views/comable/admin/{customers → users}/index.slim +20 -20
  39. data/app/views/comable/admin/users/show.slim +88 -0
  40. data/app/views/layouts/comable/admin/application.slim +1 -1
  41. data/config/routes.rb +31 -4
  42. metadata +19 -8
  43. data/app/views/comable/admin/customers/show.slim +0 -88
@@ -1,6 +1,26 @@
1
1
  .comable-page
2
2
  .comable-page-heading
3
3
  ul.pull-right.list-inline
4
+ li
5
+ - if !@order.shipped?
6
+ = link_to comable.ship_admin_order_path(@order), class: 'btn btn-primary', method: :post, disabled: !@order.can_ship? do
7
+ i.fa.fa-truck>
8
+ = Comable.t('admin.ship')
9
+ - if @order.completed?
10
+ li
11
+ = link_to comable.cancel_admin_order_path(@order), class: 'btn btn-default', method: :post do
12
+ = @order.class.human_state_event_name(:cancel)
13
+ - if @order.canceled?
14
+ li
15
+ = button_to comable.resume_admin_order_path(@order), class: 'btn btn-default', method: :post do
16
+ = @order.class.human_state_event_name(:resume)
17
+
18
+ ul.pull-right.list-inline
19
+ li
20
+ = link_to comable.edit_admin_order_path(@order), class: 'btn btn-default' do
21
+ span.fa.fa-edit>
22
+ = Comable.t('admin.actions.edit')
23
+
4
24
  li.btn-group
5
25
  / TODO: Comment out after implemented.
6
26
  / = link_to Comable.t('admin.nav.orders.cart'), '#', class: 'btn btn-default'
@@ -16,131 +36,142 @@
16
36
  small< data-toggle="tooltip" data-placement="right" title="#{l @order.completed_at}"
17
37
  = time_ago_in_words @order.completed_at
18
38
 
19
- .comable-page-body.row
20
- section.col-sm-8
21
- .panel.panel-default
22
- table.table
23
- thead
24
- tr
25
- th colspan="2"
26
- = @order.order_details.klass.human_attribute_name(:product)
27
- th
28
- = @order.order_details.klass.human_attribute_name(:price)
29
- th
30
- = @order.order_details.klass.human_attribute_name(:quantity)
31
- th
32
- = @order.order_details.klass.human_attribute_name(:subtotal_price)
33
- tbody
34
- - @order.order_details.each do |order_detail|
39
+ .comable-page-body
40
+ - if @order.payment
41
+ = render 'payment_state', payment: @order.payment
42
+ - if @order.shipment
43
+ = render 'shipment_state', shipment: @order.shipment
44
+
45
+ section.row
46
+ .col-lg-8
47
+ .panel.panel-default
48
+ table.table
49
+ thead
50
+ tr
51
+ th colspan="2"
52
+ = @order.order_items.klass.human_attribute_name(:product)
53
+ th
54
+ = @order.order_items.klass.human_attribute_name(:price)
55
+ th
56
+ = @order.order_items.klass.human_attribute_name(:quantity)
57
+ th
58
+ = @order.order_items.klass.human_attribute_name(:subtotal_price)
59
+ tbody
60
+ - @order.order_items.each do |order_item|
61
+ tr
62
+ td width="180"
63
+ = image_tag order_item.image_url, width: '100%'
64
+ td
65
+ = order_item.name_with_sku
66
+ .text-muted
67
+ small = order_item.code
68
+ td
69
+ = number_to_currency order_item.price
70
+ td
71
+ = number_with_delimiter order_item.quantity
72
+ td
73
+ = number_to_currency order_item.subtotal_price
35
74
  tr
36
- td width="180"
37
- = image_tag order_detail.image_url, width: '100%'
75
+ th.text-right colspan="4"
76
+ = @order.class.human_attribute_name(:item_total_price)
38
77
  td
39
- = order_detail.name_with_sku
40
- .text-muted
41
- small = order_detail.code
78
+ = number_to_currency @order.item_total_price
79
+ tr
80
+ th.text-right colspan="4"
81
+ = @order.class.human_attribute_name(:payment_fee)
42
82
  td
43
- = number_to_currency order_detail.price
83
+ = number_to_currency @order.payment_fee
84
+ tr
85
+ th.text-right colspan="4"
86
+ = @order.class.human_attribute_name(:shipment_fee)
44
87
  td
45
- = number_with_delimiter order_detail.quantity
88
+ = number_to_currency @order.shipment_fee
89
+ tr
90
+ th.text-right colspan="4"
91
+ = @order.class.human_attribute_name(:total_price)
46
92
  td
47
- = number_to_currency order_detail.subtotal_price
48
- tr
49
- th.text-right colspan="4"
50
- = @order.class.human_attribute_name(:item_total_price)
51
- td
52
- = number_to_currency @order.item_total_price
53
- tr
54
- th.text-right colspan="4"
55
- = @order.class.human_attribute_name(:shipment_fee)
56
- td
57
- = number_to_currency @order.shipment_fee
58
- tr
59
- th.text-right colspan="4"
93
+ = number_to_currency @order.total_price
94
+
95
+ nav.col-lg-4
96
+ .panel.panel-default.visible-lg-block
97
+ .panel-body
98
+ h3.text-center
99
+ small>
60
100
  = @order.class.human_attribute_name(:total_price)
61
- td
62
- = number_to_currency @order.total_price
63
-
64
- nav.col-sm-4
65
- .panel.panel-default
66
- .panel-body
67
- h3.text-center
68
- small>
69
- = @order.class.human_attribute_name(:total_price)
70
- = number_to_currency @order.total_price
71
-
72
- .panel.panel-default
73
- .panel-heading
74
- .panel-title
75
- = Comable.t('admin.bill')
76
- .panel-body
77
- .pull-right
78
- .comable-avatar
79
- = gravatar_tag @order.email, class: 'thumbnail'
80
-
81
- dl.dl-horizontal.comable-address-with-icon
82
- dt
83
- i.fa.fa-map-marker.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:bill_address)}"
84
- dd
85
- ul.list-unstyled
86
- li = @order.bill_address.zip_code
87
- li = @order.bill_address.state_name
88
- li = @order.bill_address.city
89
- li = @order.bill_address.detail
90
-
91
- - if @order.bill_address.phone_number.present?
101
+ = number_to_currency @order.total_price
102
+
103
+ .panel.panel-default
104
+ .panel-heading
105
+ .panel-title
106
+ = Comable.t('admin.bill')
107
+ .panel-body
108
+ .pull-right
109
+ .comable-avatar
110
+ = gravatar_tag @order.email, class: 'thumbnail'
111
+
112
+ dl.dl-horizontal.comable-address-with-icon
92
113
  dt
93
- i.fa.fa-phone.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.bill_address.class.human_attribute_name(:phone_number)}"
114
+ i.fa.fa-map-marker.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:bill_address)}"
94
115
  dd
95
- = @order.bill_address.phone_number
96
-
97
- dt
98
- i.fa.fa-user.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:customer)}"
99
- dd
100
- = link_to_if @order.customer, @order.bill_address.full_name, [comable, :admin, @order.customer]
101
-
102
- dt
103
- i.fa.fa-envelope.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:email)}"
104
- dd
105
- = mail_to @order.email
106
-
107
- .panel.panel-default
108
- .panel-heading
109
- .panel-title
110
- = Comable.t('admin.ship')
111
- .panel-body
112
- dl.dl-horizontal.comable-address-with-icon
113
- dt
114
- i.fa.fa-map-marker.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:ship_address)}"
115
- dd
116
- ul.list-unstyled
117
- li = @order.ship_address.zip_code
118
- li = @order.ship_address.state_name
119
- li = @order.ship_address.city
120
- li = @order.ship_address.detail
121
-
122
- - if @order.ship_address.phone_number.present?
116
+ ul.list-unstyled
117
+ li = @order.bill_address.zip_code
118
+ li = @order.bill_address.state_name
119
+ li = @order.bill_address.city
120
+ li = @order.bill_address.detail
121
+
122
+ - if @order.bill_address.phone_number.present?
123
+ dt
124
+ i.fa.fa-phone.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.bill_address.class.human_attribute_name(:phone_number)}"
125
+ dd
126
+ = @order.bill_address.phone_number
127
+
123
128
  dt
124
- i.fa.fa-phone.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.ship_address.class.human_attribute_name(:phone_number)}"
129
+ i.fa.fa-user.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:user)}"
125
130
  dd
126
- = @order.ship_address.phone_number
131
+ = link_to_if @order.user, @order.bill_address.full_name, [comable, :admin, @order.user]
127
132
 
128
- dt
129
- i.fa.fa-user.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:customer)}"
130
- dd
131
- = @order.bill_address.full_name
133
+ dt
134
+ i.fa.fa-envelope.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:email)}"
135
+ dd
136
+ = mail_to @order.email
132
137
 
133
- - if @order.shipment_method
138
+ .panel.panel-default
139
+ .panel-heading
140
+ .panel-title
141
+ = Comable.t('admin.ship')
142
+ .panel-body
143
+ dl.dl-horizontal.comable-address-with-icon
134
144
  dt
135
- i.fa.fa-truck.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:shipment_method)}"
145
+ i.fa.fa-map-marker.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:ship_address)}"
136
146
  dd
137
- = @order.shipment_method.name
147
+ ul.list-unstyled
148
+ li = @order.ship_address.zip_code
149
+ li = @order.ship_address.state_name
150
+ li = @order.ship_address.city
151
+ li = @order.ship_address.detail
152
+
153
+ - if @order.ship_address.phone_number.present?
154
+ dt
155
+ i.fa.fa-phone.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.ship_address.class.human_attribute_name(:phone_number)}"
156
+ dd
157
+ = @order.ship_address.phone_number
138
158
 
139
- - if @order.payment_method
140
159
  dt
141
- i.fa.fa-money.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:payment_method)}"
160
+ i.fa.fa-user.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:user)}"
142
161
  dd
143
- = @order.payment_method.name
162
+ = @order.bill_address.full_name
163
+
164
+ - if @order.shipment
165
+ dt
166
+ i.fa.fa-truck.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:shipment_method)}"
167
+ dd
168
+ = @order.shipment.name
169
+
170
+ - if @order.payment
171
+ dt
172
+ i.fa.fa-money.fa-lg data-toggle="tooltip" data-placement="left" title="#{@order.class.human_attribute_name(:payment_method)}"
173
+ dd
174
+ = @order.payment.name
144
175
 
145
- .panel-footer
146
- = render 'google_map', id: 'comable-google-map-for-ship-address', address: @order.ship_address
176
+ .panel-footer
177
+ = render 'google_map', id: 'comable-google-map-for-ship-address', address: @order.ship_address
@@ -5,11 +5,11 @@
5
5
  = f.submit
6
6
 
7
7
  fieldset
8
- .col-sm-3
8
+ .col-md-3
9
9
  legend
10
10
  = Comable.t('admin.general')
11
11
 
12
- .col-sm-9
12
+ .col-md-9
13
13
  .form-group
14
14
  = f.label :name
15
15
  = f.text_field :name
@@ -22,6 +22,10 @@
22
22
  .col-sm-6
23
23
  = f.select :payment_provider_kind, Comable::PaymentProvider::General.kind.map.with_index { |(_, value), index| [value, index] }
24
24
 
25
+ .form-group
26
+ = f.label :fee
27
+ = f.text_field :fee
28
+
25
29
  .form-group
26
30
  = f.label :enable_price
27
31
  .row
@@ -8,12 +8,12 @@
8
8
  = f.submit
9
9
 
10
10
  fieldset
11
- .col-sm-3
11
+ .col-md-3
12
12
  legend
13
13
  = Comable.t('admin.general')
14
14
  .help-block
15
15
 
16
- .col-sm-9
16
+ .col-md-9
17
17
  .form-group
18
18
  = f.label :code
19
19
  = f.text_field :code
@@ -60,7 +60,7 @@
60
60
  hr
61
61
 
62
62
  fieldset
63
- .col-sm-3
63
+ .col-md-3
64
64
  legend
65
65
  = Comable.t('admin.stocks')
66
66
  .help-block
@@ -68,7 +68,7 @@
68
68
  = Comable.t('admin.link_to_add_new_stock')
69
69
  = link_to Comable.t('admin.actions.new'), comable.new_admin_product_stock_path(@product)
70
70
 
71
- .col-sm-9
71
+ .col-md-9
72
72
  - if @product.stocks.any?
73
73
  table.table.table-striped
74
74
  thead
@@ -118,18 +118,18 @@
118
118
  hr
119
119
 
120
120
  fieldset
121
- .col-sm-3
121
+ .col-md-3
122
122
  legend
123
123
  = Comable.t('admin.images')
124
124
  .help-block
125
125
 
126
- .col-sm-9
126
+ .col-md-9
127
127
  - images = @product.images
128
128
  - main_image = images.first || @product.images.build
129
129
  - sub_images = images - [main_image]
130
130
 
131
131
  .row
132
- .col-sm-6
132
+ .col-md-6
133
133
  = f.fields_for :images, main_image do |ff|
134
134
  label
135
135
  = Comable.t('admin.main_image')
@@ -143,11 +143,11 @@
143
143
  span> = ff.check_box :_destroy
144
144
  span> = Comable.t('admin.actions.destroy')
145
145
 
146
- .col-sm-6
146
+ .col-md-6
147
147
  .row
148
148
  - sub_images.each.with_index(1) do |image, index|
149
149
  = f.fields_for :images, image do |ff|
150
150
  = render 'comable/admin/shared/image_fields', ff: ff, index: index
151
151
 
152
- .col-sm-6
152
+ .col-md-6
153
153
  = link_to_add_fields Comable.t('admin.add_sub_image'), f, :images
@@ -12,6 +12,22 @@
12
12
  li
13
13
  = link_to comable.root_path do
14
14
  = link_to Comable.t('admin.actions.new'), comable.new_admin_product_path, class: 'btn btn-default'
15
+ li.dropdown
16
+ = link_to '#', class: 'btn btn-default', 'data-toggle' => 'dropdown' do
17
+ = Comable.t('admin.more')
18
+ i.fa.fa-angle-down<
19
+ ul.dropdown-menu.dropdown-menu-right
20
+ li
21
+ = link_to Comable.t('admin.export_to_csv'), comable.export_admin_products_path(format: :csv, q: params[:q])
22
+ li
23
+ = link_to Comable.t('admin.export_to_excel'), comable.export_admin_products_path(format: :xlsx, q: params[:q])
24
+ li.divider
25
+ li
26
+ a.btn-file
27
+ span>
28
+ = Comable.t('admin.import')
29
+ = form_tag comable.import_admin_products_path, multipart: true do
30
+ = file_field_tag :file
15
31
 
16
32
  h1.page-header
17
33
  = Comable.t('admin.nav.product')
@@ -16,16 +16,16 @@ header.navbar.navbar-default.navbar-fixed-top
16
16
  li.dropdown.navbar-user
17
17
  a href="#" class="dropdown-toggle" data-toggle="dropdown"
18
18
  span.hidden-xs
19
- = current_customer.email
19
+ = current_comable_user.email
20
20
  span.caret<
21
21
  ul.dropdown-menu.animated.fadeInLeft
22
22
  li.arrow
23
23
  li
24
- = link_to comable.edit_admin_customer_path(current_customer) do
24
+ = link_to comable.edit_admin_user_path(current_comable_user) do
25
25
  span.fa.fa-edit>
26
26
  = Comable.t('admin.edit_profile')
27
27
  li.divider
28
28
  li
29
- = link_to comable.destroy_customer_session_path, method: :delete do
29
+ = link_to comable.destroy_user_session_path, method: :delete do
30
30
  span.fa.fa-sign-in>
31
31
  = Comable.t('admin.sign_out')
@@ -35,10 +35,10 @@
35
35
  = Comable.t('admin.nav.static_page')
36
36
  li
37
37
  = Comable.t('admin.nav.static_content')
38
- li class="#{'active' if controller_name == 'customers'}"
39
- = link_to comable.admin_customers_path do
38
+ li class="#{'active' if controller_name == 'users'}"
39
+ = link_to comable.admin_users_path do
40
40
  i.fa.fa-user
41
- = Comable.t('admin.nav.customer')
41
+ = Comable.t('admin.nav.user')
42
42
  li class="#{'active' if controller_name.in? %w( store shipment_methods payment_methods )}"
43
43
  = link_to '#' do
44
44
  i.fa.fa-cog
@@ -50,3 +50,5 @@
50
50
  = link_to Comable.t('admin.nav.shipment_method'), comable.admin_shipment_methods_path
51
51
  li class="#{'active' if controller_name == 'payment_methods'}"
52
52
  = link_to Comable.t('admin.nav.payment_method'), comable.admin_payment_methods_path
53
+ li class="#{'active' if controller_name == 'trackers'}"
54
+ = link_to Comable.t('admin.nav.tracker'), comable.admin_trackers_path
@@ -0,0 +1,17 @@
1
+ wb = xlsx_package.workbook
2
+
3
+ header_style = Comable::Config.export_xlsx_header_style
4
+ header_style_handle = wb.styles.add_style(header_style) if header_style
5
+
6
+ style = Comable::Config.export_xlsx_style
7
+ style_handle = wb.styles.add_style(style) if style
8
+
9
+ wb.add_worksheet(name: records.klass.model_name.human) do |sheet|
10
+ sheet.add_row records.klass.new.to_comma_headers
11
+ sheet.row_style 0, header_style_handle if header_style_handle
12
+
13
+ records.each do |record|
14
+ sheet.add_row record.to_comma
15
+ end
16
+ sheet.row_style (1..-1), style_handle if style_handle
17
+ end