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,94 @@
1
+ #comable-customer
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.customer'), comable.admin_customers_path
7
+ li
8
+ = link_to @customer.human_id, comable.admin_customer_path(@customer)
9
+ li.active
10
+ = Comable.t('admin.nav.customers.edit')
11
+
12
+ h1.page-header
13
+ = @customer.human_id
14
+ small<
15
+ = Comable.t('honorific', name: @customer.bill_full_name)
16
+
17
+ .row
18
+ section.col-sm-8
19
+ = form_for @customer, url: comable.admin_customer_path(@customer) do |f|
20
+ .panel.panel-inverse
21
+ .panel-heading
22
+ .panel-title
23
+ = Comable.t('admin.nav.customers.edit')
24
+ .panel-body
25
+ .form-horizontal
26
+ fieldset
27
+ .form-group
28
+ .col-sm-3.control-label
29
+ = f.label :role
30
+ .col-sm-6
31
+ = f.select :role, @customer.class.role.options, {}, disabled: (@customer == current_customer)
32
+
33
+ fieldset
34
+ .form-group
35
+ .col-sm-3.control-label
36
+ = f.label :email
37
+ .col-sm-6
38
+ = f.text_field :email
39
+
40
+ .form-group
41
+ .col-sm-3.control-label
42
+ = f.label :password
43
+ .col-sm-6
44
+ = f.password_field :password
45
+
46
+ fieldset
47
+ legend.text-center.text-muted
48
+ = f.object.class.human_attribute_name(:bill_address)
49
+
50
+ = f.fields_for :bill_address do |ff|
51
+ .form-group
52
+ .col-sm-3.control-label
53
+ = ff.label :full_name
54
+ .col-sm-3
55
+ = ff.text_field :family_name, placeholder: ff.object.class.human_attribute_name(:family_name)
56
+ .col-sm-3
57
+ = ff.text_field :first_name, placeholder: ff.object.class.human_attribute_name(:first_name)
58
+
59
+ .form-group
60
+ .col-sm-3.control-label
61
+ = ff.label :zip_code
62
+ .col-sm-6
63
+ = ff.text_field :zip_code, max_length: 8
64
+
65
+ .form-group
66
+ .col-sm-3.control-label
67
+ = ff.label :state_name
68
+ .col-sm-6
69
+ = ff.text_field :state_name
70
+
71
+ .form-group
72
+ .col-sm-3.control-label
73
+ = ff.label :city
74
+ .col-sm-6
75
+ = ff.text_field :city
76
+
77
+ .form-group
78
+ .col-sm-3.control-label
79
+ = ff.label :detail
80
+ .col-sm-6
81
+ = ff.text_field :detail
82
+
83
+ .form-group
84
+ .col-sm-3.control-label
85
+ = ff.label :phone_number
86
+ .col-sm-6
87
+ = ff.text_field :phone_number, max_length: 18
88
+
89
+ .panel-footer
90
+ = link_to Comable.t('admin.actions.cancel'), comable.admin_customer_path(@customer), class: 'btn btn-default'
91
+ .pull-right
92
+ = f.submit
93
+
94
+ nav.col-sm-4
@@ -0,0 +1,68 @@
1
+ #comable-customer
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.customer')
7
+
8
+ h1.page-header
9
+ = Comable.t('admin.nav.customer')
10
+ small<
11
+ = @customers.total_count
12
+ = Comable.t('admin.results')
13
+
14
+ .row
15
+ section.col-sm-8
16
+ - if @customers.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
+ = sort_link [:comable, @q], :id
27
+ th
28
+ = sort_link [:comable, @q], :email
29
+ th
30
+ = @customers.klass.human_attribute_name(:bill_full_name)
31
+ th
32
+ = @customers.klass.human_attribute_name(:bill_address)
33
+ th
34
+ = @customers.klass.human_attribute_name(:orders)
35
+ tbody
36
+ - @customers.each do |customer|
37
+ tr
38
+ td
39
+ = link_to customer.human_id, comable.admin_customer_path(customer)
40
+ td
41
+ = customer.email
42
+ td
43
+ = customer.bill_full_name
44
+ td
45
+ - if customer.bill_address
46
+ span> = customer.bill_address.state_name
47
+ span> = customer.bill_address.city
48
+ span> = customer.bill_address.detail
49
+ td
50
+ = customer.orders.count
51
+ = Comable.t('admin.times')
52
+
53
+ .text-center
54
+ = paginate @customers, theme: :comable_backend
55
+
56
+ nav.col-sm-4
57
+ #comable-affix
58
+ .panel
59
+ .panel-body
60
+ = search_form_for @q, url: comable.admin_customers_path do |f|
61
+ .form-horizontal
62
+ .form-group
63
+ .col-sm-3.control-label
64
+ = f.label :email
65
+ .col-sm-9
66
+ = f.text_field :email_cont
67
+ .text-right
68
+ = f.submit Comable.t('admin.search'), class: 'btn btn-default'
@@ -0,0 +1,93 @@
1
+ #comable-customer
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.customer'), comable.admin_customers_path
7
+ li.active
8
+ = @customer.human_id
9
+
10
+ h1.page-header
11
+ = @customer.human_id
12
+ small<
13
+ = Comable.t('honorific', name: @customer.bill_full_name)
14
+
15
+ .row
16
+ section.col-sm-8
17
+ .panel.panel-inverse
18
+ .panel-heading
19
+ .panel-title
20
+ = Comable.t('admin.nav.customers.detail')
21
+ .panel-body
22
+ dl.dl-horizontal
23
+ dt
24
+ = @customer.class.human_attribute_name(:role)
25
+ dd
26
+ = @customer.role.text
27
+ dt
28
+ = @customer.class.human_attribute_name(:email)
29
+ dd
30
+ = @customer.email
31
+ dt
32
+ = @customer.class.human_attribute_name(:bill_address)
33
+ dd
34
+ - if @customer.bill_address
35
+ ul.list-unstyled
36
+ li = @customer.bill_address.zip_code
37
+ li = @customer.bill_address.full_name
38
+ li = @customer.bill_address.state_name
39
+ li = @customer.bill_address.city
40
+ li = @customer.bill_address.detail
41
+ li = "#{@customer.bill_address.class.human_attribute_name(:phone_number)}: #{@customer.bill_address.phone_number}"
42
+ .panel-footer.text-right
43
+ = link_to comable.edit_admin_customer_path(@customer), class: 'btn btn-default' do
44
+ span.fa.fa-edit>
45
+ = Comable.t('admin.actions.edit')
46
+
47
+ .panel.panel-inverse
48
+ .panel-heading
49
+ .panel-title
50
+ = Comable.t('admin.nav.customers.new_orders', count: 5)
51
+ table.table
52
+ thead
53
+ tr
54
+ th
55
+ = @customer.orders.klass.human_attribute_name(:code)
56
+ th
57
+ = @customer.orders.klass.human_attribute_name(:state)
58
+ th
59
+ = @customer.orders.klass.human_attribute_name(:bill_full_name)
60
+ th
61
+ = @customer.orders.klass.human_attribute_name(:order_details)
62
+ th
63
+ = @customer.orders.klass.human_attribute_name(:total_price)
64
+ th
65
+ = @customer.orders.klass.human_attribute_name(:completed_at)
66
+ tbody
67
+ - @customer.orders.limit(5).each do |order|
68
+ tr
69
+ td
70
+ = link_to order.code, comable.admin_order_path(order)
71
+ td
72
+ = order.human_state_name
73
+ td
74
+ = order.bill_full_name
75
+ td
76
+ ul.list-unstyled
77
+ - order.order_details.each do |order_detail|
78
+ li
79
+ | #{order_detail.name_with_sku} x #{order_detail.quantity}
80
+ td
81
+ = number_to_currency order.total_price
82
+ td
83
+ = l order.completed_at
84
+ .panel-footer.text-right
85
+ = link_to Comable.t('admin.more'), comable.admin_orders_path(search_customer_id: @customer.id), class: 'btn btn-default'
86
+
87
+ nav.col-sm-4
88
+ #comable-affix data-spy="affix"
89
+ .panel
90
+ .list-group
91
+ = link_to Comable.t('admin.nav.order'), comable.admin_orders_path(q: { customer_id_eq: @customer.id }), class: 'list-group-item'
92
+ / TODO: Comment out after implemented.
93
+ / = link_to Comable.t('admin.nav.orders.cart'), '#', class: 'list-group-item'
@@ -0,0 +1,13 @@
1
+ - progress = '-' if progress.nan? || progress.infinite?
2
+
3
+ .widget.widget-stats class="widget-bg-#{color}"
4
+ .stats-icon.stats-icon-lg
5
+ i.fa class="fa-#{fa}"
6
+ .stats-title
7
+ = title
8
+ .stats-number
9
+ = number
10
+ .stats-progress.progress
11
+ .progress-bar style="width: #{progress}%;"
12
+ .stats-desc
13
+ = Comable.t('admin.better_than_last_week', percentage: progress)
@@ -0,0 +1,63 @@
1
+ #comable-dashboard
2
+ h1.page-header
3
+ = Comable.t('admin.nav.dashboard')
4
+
5
+ section.row
6
+ .col-sm-4
7
+ - number = @this_week_orders.count
8
+ = render 'widget',
9
+ title: Comable.t('admin.new_orders'),
10
+ number: number_with_delimiter(number),
11
+ progress: (number.to_f / @last_week_orders.count) * 100,
12
+ color: 'green',
13
+ fa: 'shopping-cart'
14
+
15
+ .col-sm-4
16
+ - number = @this_week_orders.sum(:total_price)
17
+ = render 'widget',
18
+ title: Comable.t('admin.sales'),
19
+ number: number_to_currency(number),
20
+ progress: (number.to_f / @last_week_orders.sum(:total_price)) * 100,
21
+ color: 'blue',
22
+ fa: 'dollar'
23
+
24
+ / TODO: Comment out after adding timestamp columns
25
+ .col-sm-4
26
+ - number = @this_week_customers.count
27
+ = render 'widget',
28
+ title: Comable.t('admin.new_users'),
29
+ number: number_with_delimiter(number),
30
+ progress: (number.to_f / @last_week_customers.count) * 100,
31
+ color: 'black',
32
+ fa: 'user'
33
+
34
+ section.row
35
+ .col-sm-12
36
+ .panel
37
+ .panel-body
38
+ #comable-morris.morris style="height: 300px;"
39
+
40
+ javascript:
41
+ morris_data = #{raw @this_month_orders.to_morris};
42
+ morris_keys = #{raw Comable::Order.morris_keys};
43
+ morris_labels = ['#{Comable.t('admin.order_count')}', '#{Comable.t('admin.sales')}'];
44
+
45
+ coffee:
46
+ new Morris.Line({
47
+ # ID of the element in which to draw the chart.
48
+ element: 'comable-morris',
49
+ # Chart data records -- each entry in this array corresponds to a point on
50
+ # the chart.
51
+ data: morris_data,
52
+ # The name of the data record attribute that contains x-values.
53
+ xkey: 'date',
54
+ # A list of names of data record attributes that contain y-values.
55
+ ykeys: morris_keys,
56
+ # Labels for the ykeys -- will be displayed when you hover over the
57
+ # chart.
58
+ labels: morris_labels,
59
+ xLabelAngle: 45,
60
+ xLabels: ['day'],
61
+ lineColors: ['#00acac', '#348fe2'],
62
+ hideHover: 'auto'
63
+ })
@@ -0,0 +1,79 @@
1
+ #comable-order
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.order')
7
+
8
+ h1.page-header
9
+ = Comable.t('admin.nav.order')
10
+ small<
11
+ = @orders.total_count
12
+ = Comable.t('admin.results')
13
+
14
+ .row
15
+ section.col-sm-8
16
+ - if @orders.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
+ = sort_link [:comable, @q], :code
27
+ th
28
+ / TODO: Change to shipment_state and payment_state
29
+ = sort_link [:comable, @q], :state
30
+ th
31
+ = @orders.klass.human_attribute_name(:bill_full_name)
32
+ th
33
+ = @orders.klass.human_attribute_name(:order_details)
34
+ th
35
+ = sort_link [:comable, @q], :total_price
36
+ th
37
+ = sort_link [:comable, @q], :completed_at
38
+ tbody
39
+ - @orders.each do |order|
40
+ tr
41
+ td
42
+ = link_to order.code, comable.admin_order_path(order)
43
+ td
44
+ = order.human_state_name
45
+ td
46
+ = order.bill_full_name
47
+ td
48
+ ul.list-unstyled
49
+ - order.order_details.each do |order_detail|
50
+ li
51
+ | #{order_detail.name_with_sku} x #{order_detail.quantity}
52
+ td
53
+ = number_to_currency order.total_price
54
+ td
55
+ = l order.completed_at
56
+
57
+ .text-center
58
+ = paginate @orders, theme: :comable_backend
59
+
60
+ nav.col-sm-4
61
+ #comable-affix
62
+ .panel
63
+ .panel-body
64
+ = search_form_for @q, url: comable.admin_orders_path do |f|
65
+ .form-horizontal
66
+ .form-group
67
+ .col-sm-3.control-label
68
+ = f.label :code
69
+ .col-sm-9
70
+ = f.text_field :code_cont
71
+
72
+ .form-group
73
+ .col-sm-3.control-label
74
+ = f.label :customer_id
75
+ .col-sm-9
76
+ = f.text_field :customer_id_eq
77
+
78
+ .text-right
79
+ = f.submit Comable.t('admin.search'), class: 'btn btn-default'
@@ -0,0 +1,116 @@
1
+ #comable-order
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.order'), comable.admin_orders_path
7
+ li.active
8
+ = @order.code
9
+
10
+ h1.page-header
11
+ = @order.code
12
+ small<
13
+ = Comable.t('honorific', name: @order.bill_full_name)
14
+
15
+ .row
16
+ section.col-sm-8
17
+ .panel.panel-inverse
18
+ .panel-heading
19
+ .panel-title
20
+ = Comable.t('admin.nav.orders.detail')
21
+ .panel-body
22
+ dl.dl-horizontal
23
+ dt
24
+ = @order.class.human_attribute_name(:code)
25
+ dd
26
+ = @order.code
27
+ dt
28
+ = @order.class.human_attribute_name(:completed_at)
29
+ dd
30
+ = l @order.completed_at
31
+ dt
32
+ = @order.class.human_attribute_name(:bill_address)
33
+ dd
34
+ ul.list-unstyled
35
+ li = @order.bill_address.zip_code
36
+ li = @order.bill_address.full_name
37
+ li = @order.bill_address.state_name
38
+ li = @order.bill_address.city
39
+ li = @order.bill_address.detail
40
+ li = "#{@order.bill_address.class.human_attribute_name(:phone_number)}: #{@order.bill_address.phone_number}"
41
+ dt
42
+ = @order.class.human_attribute_name(:email)
43
+ dd
44
+ = @order.email
45
+ dt
46
+ = @order.class.human_attribute_name(:shipment_method)
47
+ dd
48
+ = @order.shipment_method.name
49
+ dt
50
+ = @order.class.human_attribute_name(:payment_method)
51
+ dd
52
+ = @order.payment_method.name
53
+
54
+ .panel.panel-inverse
55
+ table.table
56
+ thead
57
+ tr
58
+ th colspan="2"
59
+ = @order.order_details.klass.human_attribute_name(:product)
60
+ th
61
+ = @order.order_details.klass.human_attribute_name(:price)
62
+ th
63
+ = @order.order_details.klass.human_attribute_name(:quantity)
64
+ th
65
+ = @order.order_details.klass.human_attribute_name(:subtotal_price)
66
+ tbody
67
+ - @order.order_details.each do |order_detail|
68
+ tr
69
+ td width="180"
70
+ = image_tag order_detail.image_url, width: '100%'
71
+ td
72
+ = order_detail.name_with_sku
73
+ .text-muted
74
+ small = order_detail.code
75
+ td
76
+ = number_to_currency order_detail.price
77
+ td
78
+ = number_with_delimiter order_detail.quantity
79
+ td
80
+ = number_to_currency order_detail.subtotal_price
81
+ tr
82
+ th.text-right colspan="4"
83
+ = @order.class.human_attribute_name(:item_total_price)
84
+ td
85
+ = number_to_currency @order.item_total_price
86
+ tr
87
+ th.text-right colspan="4"
88
+ = @order.class.human_attribute_name(:shipment_fee)
89
+ td
90
+ = number_to_currency @order.shipment_fee
91
+ tr
92
+ th.text-right colspan="4"
93
+ = @order.class.human_attribute_name(:total_price)
94
+ td
95
+ = number_to_currency @order.total_price
96
+
97
+ nav.col-sm-4
98
+ #comable-affix data-spy="affix"
99
+ .panel
100
+ .panel-body
101
+ h3.text-center
102
+ small>
103
+ = @order.class.human_attribute_name(:total_price)
104
+ = number_to_currency @order.total_price
105
+
106
+ .panel
107
+ .list-group
108
+ - if @order.customer
109
+ = link_to Comable.t('admin.nav.orders.customer'), comable.admin_customer_path(@order.customer), class: 'list-group-item'
110
+ - else
111
+ = link_to Comable.t('admin.nav.orders.customer'), '#', class: 'list-group-item disabled'
112
+
113
+ / TODO: Comment out after implemented.
114
+ / = link_to Comable.t('admin.nav.orders.cart'), '#', class: 'list-group-item'
115
+ / = link_to Comable.t('admin.nav.orders.shipment'), '#', class: 'list-group-item'
116
+ / = link_to Comable.t('admin.nav.orders.payment'), '#', class: 'list-group-item'