workarea-legacy_orders 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintrc.json +35 -0
  4. data/.github/workflows/ci.yml +61 -0
  5. data/.gitignore +24 -0
  6. data/.rubocop.yml +2 -0
  7. data/.stylelintrc.json +8 -0
  8. data/.yardopts +1 -0
  9. data/CHANGELOG.md +39 -0
  10. data/Gemfile +7 -0
  11. data/LICENSE +52 -0
  12. data/README.md +188 -0
  13. data/Rakefile +56 -0
  14. data/app/controllers/workarea/admin/legacy_orders_controller.rb +17 -0
  15. data/app/controllers/workarea/api/admin/legacy_orders_controller.rb +44 -0
  16. data/app/controllers/workarea/storefront/orders_controller.decorator +37 -0
  17. data/app/controllers/workarea/storefront/users/orders_controller.decorator +42 -0
  18. data/app/models/workarea/legacy_order/address.rb +28 -0
  19. data/app/models/workarea/legacy_order/item.rb +22 -0
  20. data/app/models/workarea/legacy_order/tender.rb +25 -0
  21. data/app/models/workarea/legacy_order.rb +58 -0
  22. data/app/models/workarea/search/admin/legacy_order.rb +80 -0
  23. data/app/queries/workarea/search/admin_legacy_orders.rb +33 -0
  24. data/app/seeds/workarea/legacy_orders_seeds.rb +112 -0
  25. data/app/view_models/workarea/admin/legacy_order_view_model.rb +12 -0
  26. data/app/view_models/workarea/storefront/legacy_order_item_view_model.rb +38 -0
  27. data/app/view_models/workarea/storefront/legacy_order_view_model.rb +37 -0
  28. data/app/view_models/workarea/storefront/user_view_model.decorator +23 -0
  29. data/app/views/workarea/admin/legacy_orders/_menu.html.haml +1 -0
  30. data/app/views/workarea/admin/legacy_orders/_summary.html.haml +7 -0
  31. data/app/views/workarea/admin/legacy_orders/index.html.haml +119 -0
  32. data/app/views/workarea/admin/legacy_orders/show.html.haml +108 -0
  33. data/app/views/workarea/admin/legacy_orders/tenders/_legacy_tender.html.haml +7 -0
  34. data/app/views/workarea/storefront/legacy_orders/_summary.html.haml +223 -0
  35. data/app/views/workarea/storefront/legacy_orders/show.html.haml +16 -0
  36. data/app/views/workarea/storefront/legacy_orders/tenders/_legacy_tender.html.haml +14 -0
  37. data/app/views/workarea/storefront/users/legacy_orders/show.html.haml +24 -0
  38. data/bin/rails +19 -0
  39. data/config/initializers/appends.rb +4 -0
  40. data/config/initializers/config.rb +4 -0
  41. data/config/locales/en.yml +16 -0
  42. data/config/routes.rb +19 -0
  43. data/doc/index.json +37 -0
  44. data/doc/legacy_orders/creating_a_legacy_order.json +44 -0
  45. data/doc/legacy_orders/listing_legacy_orders.json +56 -0
  46. data/doc/legacy_orders/showing_a_legacy_order.json +42 -0
  47. data/doc/legacy_orders/updating_a_legacy_order.json +40 -0
  48. data/lib/workarea/legacy_orders/engine.rb +17 -0
  49. data/lib/workarea/legacy_orders/version.rb +5 -0
  50. data/lib/workarea/legacy_orders.rb +11 -0
  51. data/package.json +9 -0
  52. data/script/admin_ci +9 -0
  53. data/script/ci +11 -0
  54. data/script/core_ci +9 -0
  55. data/script/plugins_ci +9 -0
  56. data/script/storefront_ci +9 -0
  57. data/test/documentation/workarea/api/legacy_orders_documentation_test.rb +81 -0
  58. data/test/dummy/Rakefile +6 -0
  59. data/test/dummy/app/assets/config/manifest.js +4 -0
  60. data/test/dummy/app/assets/images/.keep +0 -0
  61. data/test/dummy/app/assets/javascripts/application.js +13 -0
  62. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  63. data/test/dummy/app/controllers/application_controller.rb +3 -0
  64. data/test/dummy/app/controllers/concerns/.keep +0 -0
  65. data/test/dummy/app/helpers/application_helper.rb +2 -0
  66. data/test/dummy/app/jobs/application_job.rb +2 -0
  67. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  68. data/test/dummy/app/models/concerns/.keep +0 -0
  69. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  70. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  71. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  72. data/test/dummy/bin/bundle +3 -0
  73. data/test/dummy/bin/rails +4 -0
  74. data/test/dummy/bin/rake +4 -0
  75. data/test/dummy/bin/setup +34 -0
  76. data/test/dummy/bin/update +29 -0
  77. data/test/dummy/config/application.rb +25 -0
  78. data/test/dummy/config/boot.rb +5 -0
  79. data/test/dummy/config/cable.yml +9 -0
  80. data/test/dummy/config/environment.rb +5 -0
  81. data/test/dummy/config/environments/development.rb +54 -0
  82. data/test/dummy/config/environments/production.rb +86 -0
  83. data/test/dummy/config/environments/test.rb +44 -0
  84. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  85. data/test/dummy/config/initializers/assets.rb +11 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  88. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  89. data/test/dummy/config/initializers/inflections.rb +16 -0
  90. data/test/dummy/config/initializers/mime_types.rb +4 -0
  91. data/test/dummy/config/initializers/new_framework_defaults.rb +23 -0
  92. data/test/dummy/config/initializers/session_store.rb +5 -0
  93. data/test/dummy/config/initializers/workarea.rb +5 -0
  94. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/test/dummy/config/locales/en.yml +23 -0
  96. data/test/dummy/config/puma.rb +47 -0
  97. data/test/dummy/config/routes.rb +6 -0
  98. data/test/dummy/config/secrets.yml +22 -0
  99. data/test/dummy/config/spring.rb +6 -0
  100. data/test/dummy/config.ru +5 -0
  101. data/test/dummy/db/seeds.rb +2 -0
  102. data/test/dummy/lib/assets/.keep +0 -0
  103. data/test/dummy/log/.keep +0 -0
  104. data/test/factories/legacy_orders.rb +88 -0
  105. data/test/integration/workarea/api/admin/legacy_orders_integration_test.rb +59 -0
  106. data/test/integration/workarea/storefront/legacy_order_lookup_integration_test.rb +113 -0
  107. data/test/system/workarea/storefront/legacy_order_lookup_system_test.rb +21 -0
  108. data/test/system/workarea/storefront/order_history_system_test.rb +64 -0
  109. data/test/teaspoon_env.rb +6 -0
  110. data/test/test_helper.rb +10 -0
  111. data/workarea-legacy_orders.gemspec +18 -0
  112. metadata +173 -0
@@ -0,0 +1,28 @@
1
+ module Workarea
2
+ class LegacyOrder
3
+ class Address
4
+ include Mongoid::Document
5
+
6
+ field :first_name, type: String
7
+ field :last_name, type: String
8
+ field :street, type: String
9
+ field :street_2, type: String
10
+ field :city, type: String
11
+ field :company, type: String
12
+ field :region, type: String
13
+ field :postal_code, type: String
14
+ field :country, type: Country
15
+ field :phone_number, type: String
16
+ field :phone_extension, type: String
17
+
18
+ embedded_in :order, class_name: "Workarea::LegacyOrder"
19
+
20
+ alias_method :name=, :first_name=
21
+ alias_method :region_name, :region
22
+
23
+ def name
24
+ [first_name, last_name].compact.join(' ')
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ module Workarea
2
+ class LegacyOrder
3
+ class Item
4
+ include Mongoid::Document
5
+
6
+ field :name, type: String
7
+ field :sku, type: String
8
+ field :product_id, type: String
9
+ field :quantity, type: Integer
10
+ field :price, type: Money
11
+ field :details, type: Hash, default: {}
12
+ field :customizations, type: Hash, default: {}
13
+ field :token, type: String
14
+ field :status, type: String
15
+ field :data, type: Hash, default: {}
16
+
17
+ embedded_in :order, class_name: "Workarea::LegacyOrder"
18
+
19
+ validates_presence_of :name, :sku, :quantity, :price
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module Workarea
2
+ class LegacyOrder
3
+ class Tender
4
+ include Mongoid::Document
5
+
6
+ field :type, type: String
7
+ field :number, type: String
8
+ field :amount, type: Money
9
+ field :issuer, type: String
10
+ field :expiration_month, type: String
11
+ field :expiration_year, type: String
12
+ field :data, type: Hash, default: {}
13
+
14
+ validates_presence_of :type, :amount
15
+
16
+ def slug
17
+ "legacy_tender"
18
+ end
19
+
20
+ def issuer
21
+ super.presence || type
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,58 @@
1
+ module Workarea
2
+ class LegacyOrder
3
+ include ApplicationDocument
4
+
5
+ field :_id, type: String, default: -> { SecureRandom.hex(5).upcase }
6
+ field :email, type: String
7
+ field :customer_number, type: String
8
+ field :alternate_number, type: String
9
+ field :placed_at, type: DateTime
10
+ field :status, type: String, default: "Shipped"
11
+ field :shipping_method, type: String
12
+ field :shipping_total, type: Money
13
+ field :tax_total, type: Money
14
+ field :total_price, type: Money
15
+ field :discount_total, type: Money
16
+ field :data, type: Hash, default: {}
17
+
18
+ embeds_many :items, class_name: "Workarea::LegacyOrder::Item"
19
+ embeds_one :billing_address, class_name: "Workarea::LegacyOrder::Address"
20
+ embeds_one :shipping_address, class_name: "Workarea::LegacyOrder::Address"
21
+ embeds_many :tenders, class_name: "Workarea::LegacyOrder::Tender"
22
+
23
+ index(email: 1)
24
+
25
+ validates_presence_of :email, :placed_at, :tax_total, :total_price
26
+
27
+ default_scope -> { order_by(:placed_at.desc) }
28
+
29
+ def self.for_email(email)
30
+ where(email: email)
31
+ end
32
+
33
+ def self.lookup(id, postal_code)
34
+ order = find(id) rescue nil
35
+ order&.billing_address&.postal_code == postal_code ? order : nil
36
+ end
37
+
38
+ def name
39
+ I18n.t('workarea.order.name', id: id)
40
+ end
41
+
42
+ # The number of units in this order.
43
+ #
44
+ # @return [Integer]
45
+ #
46
+ def quantity
47
+ items.sum(&:quantity)
48
+ end
49
+
50
+ def subtotal_price
51
+ items.sum(&:price)
52
+ end
53
+
54
+ def placed?
55
+ placed_at.present?
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,80 @@
1
+ module Workarea
2
+ module Search
3
+ class Admin
4
+ class LegacyOrder < Search::Admin
5
+ def name
6
+ if model.billing_address.present?
7
+ model.billing_address.name
8
+ else
9
+ model.name
10
+ end
11
+ end
12
+
13
+ def search_text
14
+ [
15
+ 'order',
16
+ model.id,
17
+ model.status,
18
+ model.email,
19
+ model.customer_number,
20
+ model.alternate_number,
21
+ model.items.map { |i| "#{i.product_id} #{i.sku}" },
22
+ model.shipping_method,
23
+ addresses_text,
24
+ tenders_text
25
+ ].flatten.join(' ')
26
+ end
27
+
28
+ def keywords
29
+ super + [model.email, model.alternate_number]
30
+ end
31
+
32
+ def jump_to_text
33
+ if model.placed?
34
+ "#{model.id} - Placed @ #{model.placed_at.to_s(:short)}"
35
+ else
36
+ "#{model.id} - #{model.status.to_s.titleize}"
37
+ end
38
+ end
39
+
40
+ def jump_to_position
41
+ 3
42
+ end
43
+
44
+ def facets
45
+ super.merge(order_status: model.status)
46
+ end
47
+
48
+ def as_document
49
+ super.merge(
50
+ total_price: model.total_price.to_f,
51
+ placed_at: model.placed_at
52
+ )
53
+ end
54
+
55
+ def addresses_text
56
+ [model.shipping_address, model.billing_address].map do |address|
57
+ [
58
+ address.first_name,
59
+ address.last_name,
60
+ address.company,
61
+ address.street,
62
+ address.street_2,
63
+ address.city,
64
+ address.region,
65
+ address.postal_code,
66
+ address.country,
67
+ address.phone_number
68
+ ]
69
+ end.flatten
70
+ end
71
+
72
+ def tenders_text
73
+ model.tenders.map do |tender|
74
+ [tender.issuer, tender.type]
75
+ end.flatten
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,33 @@
1
+ module Workarea
2
+ module Search
3
+ class AdminLegacyOrders
4
+ include Query
5
+ include AdminIndexSearch
6
+ include AdminSorting
7
+ include Pagination
8
+
9
+ document Search::Admin
10
+
11
+ def initialize(params = {})
12
+ super(params.merge(type: 'legacy_order'))
13
+ end
14
+
15
+ def facets
16
+ super + [TermsFacet.new(self, 'order_status')]
17
+ end
18
+
19
+ def filters
20
+ [
21
+ DateFilter.new(self, 'placed_at', :gte),
22
+ DateFilter.new(self, 'placed_at', :lte),
23
+ RangeFilter.new(self, 'total_price', :gte),
24
+ RangeFilter.new(self, 'total_price', :lt)
25
+ ]
26
+ end
27
+
28
+ def current_sort
29
+ AdminOrders.available_sorts.find(params[:sort])
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,112 @@
1
+ module Workarea
2
+ class LegacyOrdersSeeds
3
+ def perform
4
+ puts "Adding legacy orders..."
5
+
6
+ users.each do |user|
7
+ rand(1..5).times { Workarea::LegacyOrder.create!(order(user)) }
8
+ end
9
+
10
+ 10.times { Workarea::LegacyOrder.create!(order) }
11
+ end
12
+
13
+ private
14
+
15
+ def users
16
+ (
17
+ Workarea::User.all.sample(4) +
18
+ [Workarea::User.find_by_email("user@workarea.com")]
19
+ ).uniq.compact
20
+ end
21
+
22
+ def order(user = nil)
23
+ email = user&.email || Faker::Internet.email
24
+ items = rand(1..5).times.map { item }
25
+
26
+ shipping = Faker::Commerce.price.to_m
27
+ discount = [0, nil, -1 * Faker::Commerce.price.to_m].sample
28
+ tax = Faker::Commerce.price.to_m
29
+
30
+ total = items.sum { |i| i[:price] } + shipping + tax + discount.to_m
31
+
32
+ {
33
+ email: email,
34
+ customer_number: user&.id,
35
+ alternate_number: SecureRandom.hex(5).upcase,
36
+ placed_at: Faker::Date.between(from: 3.years.ago, to: Date.today),
37
+ status: "Shipped",
38
+ shipping_method: "USPS Ground",
39
+ shipping_total: shipping,
40
+ discount_total: discount,
41
+ tax_total: tax,
42
+ total_price: total,
43
+ items: items,
44
+ tenders: tenders(total),
45
+ billing_address: address,
46
+ shipping_address: address
47
+ }
48
+ end
49
+
50
+ def tenders(total)
51
+ tenders = []
52
+
53
+ if Faker::Boolean.boolean
54
+ tenders << {
55
+ type: "Gift Card",
56
+ number: Faker::Business.credit_card_number,
57
+ amount: Faker::Commerce.price(range: 0..total.to_f).to_m
58
+ }
59
+ end
60
+
61
+ tenders << {
62
+ type: Faker::Business.credit_card_type,
63
+ number: Faker::Business.credit_card_number,
64
+ amount: total - (tenders.sum { |t| t[:amount] } || 0).to_m,
65
+ expiration_month: Faker::Business.credit_card_expiry_date.month,
66
+ expiration_year: Faker::Business.credit_card_expiry_date.year
67
+ }
68
+ end
69
+
70
+ def item
71
+ item = {
72
+ name: Faker::Commerce.product_name,
73
+ sku: Faker::Code.isbn,
74
+ quantity: rand(1..8),
75
+ price: Faker::Commerce.price.to_m,
76
+ status: item_status.sample
77
+ }
78
+ if Faker::Boolean.boolean
79
+ item[:details] = {
80
+ color: Faker::Commerce.color,
81
+ size: "medium"
82
+ }
83
+ end
84
+
85
+ if Faker::Boolean.boolean
86
+ item[:customizations] = {
87
+ line_1: Faker::Hipster.words.join(" "),
88
+ line_2: Faker::Hipster.words.join(" ")
89
+ }
90
+ end
91
+
92
+ item
93
+ end
94
+
95
+ def address
96
+ {
97
+ name: Faker::Name.name,
98
+ street: Faker::Address.street_address,
99
+ street_2: Faker::Address.secondary_address,
100
+ city: Faker::Address.city,
101
+ region: Faker::Address.state_abbr,
102
+ postal_code: Faker::Address.zip,
103
+ country: Faker::Address.country_code,
104
+ phone_number: Faker::PhoneNumber.phone_number
105
+ }
106
+ end
107
+
108
+ def item_status
109
+ @item_status = [*%w(shipping) * 9, nil, 'pending', 'canceled']
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,12 @@
1
+ module Workarea
2
+ module Admin
3
+ class LegacyOrderViewModel < ApplicationViewModel
4
+ delegate_missing_to :storefront_view_model
5
+
6
+ def storefront_view_model
7
+ @storefront_view_model ||=
8
+ Storefront::LegacyOrderViewModel.wrap(model, options)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ module Workarea
2
+ module Storefront
3
+ class LegacyOrderItemViewModel < ApplicationViewModel
4
+ def sku_name
5
+ name
6
+ end
7
+
8
+ def total_price
9
+ price
10
+ end
11
+
12
+ def has_options?
13
+ model.details.present?
14
+ end
15
+
16
+ def product_name
17
+ return sku_name unless product.present?
18
+ product.name
19
+ end
20
+
21
+ def product
22
+ return nil if product_id.blank?
23
+ return @product if defined?(@product)
24
+
25
+ model = Catalog::Product.find(product_id) rescue nil
26
+ @product = model.present? ? ProductViewModel.wrap(model, sku: sku) : nil
27
+ end
28
+
29
+ def image
30
+ if product.present?
31
+ product.primary_image
32
+ else
33
+ Catalog::ProductPlaceholderImage.cached
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ module Workarea
2
+ module Storefront
3
+ class LegacyOrderViewModel < ApplicationViewModel
4
+ def fulfillment_status
5
+ status
6
+ end
7
+
8
+ def requires_shipping?
9
+ shipping_address.present?
10
+ end
11
+
12
+ def items
13
+ @items ||= LegacyOrderItemViewModel.wrap(model.items)
14
+ end
15
+
16
+ def pending_items
17
+ items.select { |i| i.status == 'pending' }
18
+ end
19
+
20
+ def shipped_items
21
+ items.select { |i| i.status == 'shipped' }
22
+ end
23
+
24
+ def canceled_items
25
+ items.select { |i| i.status == 'canceled' }
26
+ end
27
+
28
+ def packages
29
+ []
30
+ end
31
+
32
+ def refunds
33
+ []
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ module Workarea
2
+ decorate Storefront::UserViewModel, with: :legacy_orders do
3
+ def recent_orders
4
+ super + legacy_orders
5
+ end
6
+
7
+ def legacy_orders
8
+ Storefront::LegacyOrderViewModel.wrap(legacy_order_models)
9
+ end
10
+
11
+ def legacy_order_models
12
+ return [] unless legacy_order_limit > 0
13
+
14
+ LegacyOrder
15
+ .for_email(model.email)
16
+ .limit(legacy_order_limit)
17
+ end
18
+
19
+ def legacy_order_limit
20
+ Workarea.config.recent_order_count - recent_order_models.size
21
+ end
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ %li{ class: "primary-nav__item" }= link_to t('workarea.admin.shared.primary_nav.legacy_orders'), legacy_orders_path, class: navigation_link_classes(legacy_orders_path)
@@ -0,0 +1,7 @@
1
+ .summary
2
+ = link_to legacy_order_path(model) do
3
+ %span.summary__name= model.name
4
+ .summary__info-container
5
+ %span.summary__info= local_time_ago(model.updated_at)
6
+ %span.summary__info #{model.email}, #{number_to_currency model.total_price}
7
+ %span.summary__type{ title: t('workarea.admin.orders.summary.order') }= t('workarea.admin.orders.summary.order')
@@ -0,0 +1,119 @@
1
+ - @page_title = t('workarea.admin.legacy_orders.index.title')
2
+
3
+ .view
4
+ .view__header
5
+ .grid.grid--center
6
+ .grid__cell.grid__cell--50
7
+ .view__heading
8
+ = link_to "↑ #{t('workarea.admin.orders.index.dashboard_link')}", orders_dashboards_path, class: 'view__dashboard-button'
9
+ %h1= t('workarea.admin.legacy_orders.index.title')
10
+
11
+ .view__container
12
+ .browsing-controls.browsing-controls--with-divider.browsing-controls--center{ class: ('browsing-controls--filters-displayed' unless @search.toggle_facets?) }
13
+ = form_tag legacy_orders_path, method: 'get', class: 'browsing-controls__form' do
14
+ = facet_hidden_inputs(@search.facets)
15
+ .browsing-controls__sort
16
+ .property.property--inline
17
+ = label_tag 'sort', t('workarea.admin.search.sort_by'), class: 'property__name'
18
+ = select_tag :sort, options_for_select(@search.sorts, selected: @search.sort), data: { form_submitting_control: '' }
19
+
20
+ .browsing-controls__search
21
+ .search-form
22
+ = text_field_tag :q, params[:q], class: 'search-form__input', id: 'search_legacy_orders', title: t('workarea.admin.search.keywords'), placeholder: t('workarea.admin.search.keywords')
23
+ = submit_tag 'search_legacy_orders', class: 'search-form__button'
24
+
25
+ .browsing-controls__filter.browsing-controls__filter--date
26
+ %button.browsing-controls__filter-button{ type: 'button', data: { filter_dropdown: "#filters-dropdown-date-placed" } }
27
+ = t('workarea.admin.orders.index.filters.order_placed')
28
+ = inline_svg('workarea/admin/icons/calendar.svg', class: 'browsing-controls__filter-button-icon svg-icon svg-icon--small')
29
+
30
+ #filters-dropdown-date.browsing-controls__filter-dropdown.tooltip-content
31
+ .grid
32
+ .grid__cell.grid__cell--50
33
+ .property.property--inline
34
+ -# TODO v4 rename to placed_at_starts_at, unify globally with partial
35
+ = label_tag 'placed_at_greater_than', t('workarea.admin.orders.index.filters.placed_date'), class: 'property__name'
36
+ = datetime_picker_tag 'placed_at_greater_than', params[:placed_at_greater_than], class: 'text-box', placeholder: 'Start Date', data: { datepicker_field: { inline: true }, datepicker_field_starts_at: '' }
37
+ .grid__cell.grid__cell--50
38
+ .property.property--inline
39
+ -# TODO v4 rename to placed_at_ends_at
40
+ = datetime_picker_tag 'placed_at_less_than', params[:placed_at_less_than], class: 'text-box', placeholder: 'End Date', data: { datepicker_field: { inline: true }, datepicker_field_ends_at: '' }
41
+ .browsing-controls__filter-dropdown-submit
42
+ .grid.grid--auto.grid--middle.grid--center
43
+ .grid__cell= label_tag 'quick_range', t('workarea.admin.date_selector.or_choose')
44
+ .grid__cell= select_tag 'quick_range', options_for_select(date_selector_quick_range_options)
45
+ .grid__cell= t('workarea.admin.date_selector.and')
46
+ .grid__cell= submit_tag t('workarea.admin.search.submit'), name: 'filter_by_creation_date', class: 'button button--small'
47
+
48
+
49
+ .browsing-controls__filter.browsing-controls__filter--price
50
+ %button.browsing-controls__filter-button{ type: 'button', data: { filter_dropdown: "#filters-dropdown-price" } }
51
+ = t('workarea.admin.orders.index.filters.price_range')
52
+ = inline_svg('workarea/admin/icons/prices.svg', class: 'browsing-controls__filter-button-icon svg-icon svg-icon--small')
53
+
54
+ #filters-dropdown-price.browsing-controls__filter-dropdown
55
+ .grid.grid--auto
56
+ .grid__cell
57
+ .property
58
+ .grid.grid--auto.grid--middle
59
+ .grid__cell= label_tag 'total_price_greater_than', currency_symbol, class: 'property__name'
60
+ .grid__cell= text_field_tag 'total_price_greater_than', params[:total_price_greater_than], class: 'text-box text-box--small', title: 'Total Price Min', placeholder: 'Min', pattern: '\d*\.?\d*'
61
+ .grid__cell
62
+ .property
63
+ .grid.grid--auto.grid--middle
64
+ .grid__cell= label_tag 'total_price_less_than', currency_symbol, class: 'property__name'
65
+ .grid__cell= text_field_tag 'total_price_less_than', params[:total_price_less_than], class: 'text-box text-box--small', title: 'Total Price Max', placeholder: 'Max', pattern: '\d*\.?\d*'
66
+ .grid_cell
67
+ = button_tag t('workarea.admin.search.submit'), value: 'search', class: 'button'
68
+
69
+ - if @search.facets.present?
70
+ - @search.facets.each do |facet|
71
+ = render "workarea/admin/facets/#{facet.type}", facet: facet
72
+
73
+ - if @search.toggle_facets?
74
+ .browsing-controls__toggle-filters
75
+ %button.text-button{ type: 'button', data: { toggle_filters: '' } }= t('workarea.admin.search.show_filters')
76
+
77
+ = render 'workarea/admin/facets/applied', search: @search, reset_path: legacy_orders_path
78
+
79
+ .browsing-controls__count= pluralize(@search.total, t('workarea.admin.orders.index.summary.results'))
80
+
81
+ - if @search.results.any?
82
+ %table.index-table
83
+ %thead
84
+ %tr
85
+ %th.index-table__control-cell
86
+ .checkbox
87
+ = check_box_tag 'select_all', nil, false, id: 'select_all', class: 'checkbox__input', data: { bulk_action_select_all: '' }
88
+ = label_tag 'select_all', t('workarea.admin.bulk_actions.select_all'), class: 'checkbox__label'
89
+ %th= t('workarea.admin.fields.id')
90
+ %th= t('workarea.admin.fields.email')
91
+ %th= t('workarea.admin.fields.total_price')
92
+ %th= t('workarea.admin.fields.status')
93
+ %th.align-right= t('workarea.admin.fields.placed_at')
94
+ %th= t('workarea.admin.fields.updated_at')
95
+ %tbody
96
+ - @search.results.each do |result|
97
+ %tr
98
+ %td.index-table__control-cell
99
+ .checkbox
100
+ = check_box_tag 'global_id', result.to_gid_param, false, class: 'checkbox__input', id: dom_id(result), data: { bulk_action_item: '' }
101
+ = label_tag dom_id(result), '', class: 'checkbox__label', title: t('workarea.admin.bulk_actions.add_summary_button')
102
+ %td= link_to result.id, legacy_order_path(result)
103
+ %td= result.email
104
+ %td= number_to_currency result.total_price
105
+ %td= result.status.to_s.titleize
106
+ %td.align-right
107
+ - if result.placed?
108
+ = local_time_ago(result.placed_at)
109
+ - else
110
+ \-
111
+ %td= local_time_ago(result.updated_at)
112
+
113
+ - if @search.results.total_pages > 1
114
+ = render 'workarea/admin/shared/pagination', collection: @search.results
115
+
116
+ .workflow-bar
117
+ .grid
118
+ .grid__cell
119
+ = render 'workarea/admin/shared/bulk_actions', klass: Workarea::LegacyOrder, search: @search, bulk_delete: false