Compare commits

..

116 Commits

Author SHA1 Message Date
Andy Brett
5e658eb9dd Update all locales with the latest Transifex translations 2021-09-28 09:21:09 -07:00
Maikel
c9d36e6f5c Merge pull request #8204 from meronokbay/6942-fix-payment-method-fee-bug-all
Fix payment method fee bug for all calculator types
2021-09-28 08:39:05 +10:00
Matt-Yorkley
0f4c8d8ecc Merge pull request #8251 from openfoodfoundation/dependabot/bundler/nokogiri-1.12.5
Bump nokogiri from 1.12.4 to 1.12.5
2021-09-27 23:13:06 +02:00
dependabot[bot]
6553136d2d Bump nokogiri from 1.12.4 to 1.12.5
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.12.4 to 1.12.5.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.12.4...v1.12.5)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 20:40:40 +00:00
Matt-Yorkley
9cbdc8293d Merge pull request #8244 from openfoodfoundation/dependabot/npm_and_yarn/jest-27.2.2
Bump jest from 27.2.1 to 27.2.2
2021-09-27 21:36:15 +02:00
Matt-Yorkley
6d1d688b1d Merge pull request #8215 from openfoodfoundation/transifex
Transifex
2021-09-27 15:04:24 +02:00
dependabot[bot]
af1e26e9e1 Bump jest from 27.2.1 to 27.2.2
Bumps [jest](https://github.com/facebook/jest) from 27.2.1 to 27.2.2.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/compare/v27.2.1...v27.2.2)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 09:07:54 +00:00
Andy Brett
6a50f68b52 Merge pull request #8217 from filipefurtad0/orders_spec_update
Orders page spec update
2021-09-24 13:41:06 -07:00
Andy Brett
a137bdd00e Merge pull request #8220 from openfoodfoundation/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-09-24 13:24:31 -07:00
Andy Brett
b593ef78ea Merge pull request #8226 from openfoodfoundation/dependabot/npm_and_yarn/hotwired/turbo-7.0.0-rc.5
Bump @hotwired/turbo from 7.0.0-rc.4 to 7.0.0-rc.5
2021-09-24 13:23:00 -07:00
Andy Brett
9e5bc9ba0c Merge pull request #8222 from jibees/8221-show-order-with-line-items-and-finalized-ones
Show orders with line items + finalized orders
2021-09-24 13:21:09 -07:00
dependabot[bot]
1953d2164b Bump @hotwired/turbo from 7.0.0-rc.4 to 7.0.0-rc.5
Bumps [@hotwired/turbo](https://github.com/hotwired/turbo) from 7.0.0-rc.4 to 7.0.0-rc.5.
- [Release notes](https://github.com/hotwired/turbo/releases)
- [Commits](https://github.com/hotwired/turbo/compare/v7.0.0-rc.4...v7.0.0-rc.5)

---
updated-dependencies:
- dependency-name: "@hotwired/turbo"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-24 09:09:18 +00:00
Jean-Baptiste Bellet
e82e93e1cc Update test to add more case with finalized order with no line items
Those empty order but finalized must be returned by the API
2021-09-23 11:06:58 +02:00
Jean-Baptiste Bellet
78bbee49e9 Search for orders that are finalized
Thus, we display the orders that contains at least one line item (whatever its state) + the finalized orders

NB // Finalized state : complete canceled resumed awaiting_return returned
2021-09-23 11:06:15 +02:00
Maikel
5b5693dc26 Merge pull request #8180 from jibees/7504-resolve-rounded-errors
Avoid rounded with float numbers errors with javascript
2021-09-23 09:56:03 +10:00
Nihal M. Kelanthodika
f170b4241d Merge pull request #8168 from apricot12/7799-Enterprise-Fee-Report 2021-09-22 20:39:06 +05:30
Maikel
bdc7444422 Merge pull request #8213 from openfoodfoundation/dependabot/npm_and_yarn/jest-27.2.1
Bump jest from 27.2.0 to 27.2.1
2021-09-22 18:13:42 +10:00
Maikel
53ffdaf6de Merge pull request #8212 from openfoodfoundation/dependabot/bundler/bootsnap-1.9.1
Bump bootsnap from 1.9.0 to 1.9.1
2021-09-22 18:13:00 +10:00
dependabot[bot]
37c6f11e05 Bump bootsnap from 1.9.0 to 1.9.1
Bumps [bootsnap](https://github.com/Shopify/bootsnap) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/Shopify/bootsnap/releases)
- [Changelog](https://github.com/Shopify/bootsnap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Shopify/bootsnap/compare/v1.9.0...v1.9.1)

---
updated-dependencies:
- dependency-name: bootsnap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-22 08:10:45 +00:00
Maikel
45fad30f7b Merge pull request #8211 from openfoodfoundation/dependabot/bundler/bugsnag-6.23.0
Bump bugsnag from 6.22.1 to 6.23.0
2021-09-22 18:09:24 +10:00
Maikel
3e689b46d0 Merge pull request #8209 from openfoodfoundation/dependabot/bundler/puma-5.5.0
Bump puma from 5.4.0 to 5.5.0
2021-09-22 17:10:42 +10:00
Maikel
98db38b0cc Merge pull request #8190 from openfoodfoundation/dependabot/npm_and_yarn/rails/webpacker-5.4.3
Bump @rails/webpacker from 5.4.2 to 5.4.3
2021-09-22 17:04:58 +10:00
Maikel
7348ceca64 Merge pull request #8189 from openfoodfoundation/dependabot/bundler/webpacker-5.4.3
Bump webpacker from 5.4.2 to 5.4.3
2021-09-22 17:04:02 +10:00
dependabot[bot]
ea21469ff6 Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-22 06:34:42 +00:00
filipefurtad0
6000d4c985 Declares variables with let! avoiding repedition (DRY) 2021-09-21 16:33:17 +01:00
filipefurtad0
f2bd45162b Updates base_spec_helper.rb to make system specs work 2021-09-21 16:00:41 +01:00
filipefurtad0
536d4b9894 Updates orders_spec.rb into system spec 2021-09-21 15:58:45 +01:00
Transifex-Openfoodnetwork
17d7270a32 Updating translations for config/locales/nb.yml 2021-09-21 21:31:51 +10:00
dependabot[bot]
a259444129 Bump jest from 27.2.0 to 27.2.1
Bumps [jest](https://github.com/facebook/jest) from 27.2.0 to 27.2.1.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/compare/v27.2.0...v27.2.1)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 09:06:34 +00:00
dependabot[bot]
5c3e03b86b Bump bugsnag from 6.22.1 to 6.23.0
Bumps [bugsnag](https://github.com/bugsnag/bugsnag-ruby) from 6.22.1 to 6.23.0.
- [Release notes](https://github.com/bugsnag/bugsnag-ruby/releases)
- [Changelog](https://github.com/bugsnag/bugsnag-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bugsnag/bugsnag-ruby/compare/v6.22.1...v6.23.0)

---
updated-dependencies:
- dependency-name: bugsnag
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 09:03:35 +00:00
dependabot[bot]
62fd374262 Bump puma from 5.4.0 to 5.5.0
Bumps [puma](https://github.com/puma/puma) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v5.4.0...v5.5.0)

---
updated-dependencies:
- dependency-name: puma
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-20 09:02:31 +00:00
Maikel
02a10ede15 Merge pull request #7938 from dacook/product-image-import
Add script to import product images from URL
2021-09-20 16:57:23 +10:00
Maikel
58c0d30af3 Merge pull request #8207 from openfoodfoundation/revert-8064-Kill_stripe_connect
Revert "Kill stripe connect"
2021-09-20 08:59:16 +10:00
Maikel Linke
4336350140 Updates from Transifex 2021-09-20 08:54:17 +10:00
Maikel
a3c31f7d86 Revert "Kill stripe connect" 2021-09-20 08:39:34 +10:00
Meron Ogbai
cd992ee866 Validate preferred values all calculators 2021-09-17 18:50:29 +03:00
Andy Brett
6ee9daf768 Merge pull request #8198 from openfoodfoundation/dependabot/bundler/bootsnap-1.9.0
Bump bootsnap from 1.8.1 to 1.9.0
2021-09-17 08:50:08 -07:00
Meron Ogbai
957f834694 Rename preferred amount to preferred value 2021-09-17 18:49:57 +03:00
Meron Ogbai
d73df78f43 Extract gateway_params to a private method 2021-09-17 16:48:53 +03:00
dependabot[bot]
d086f7694a Bump bootsnap from 1.8.1 to 1.9.0
Bumps [bootsnap](https://github.com/Shopify/bootsnap) from 1.8.1 to 1.9.0.
- [Release notes](https://github.com/Shopify/bootsnap/releases)
- [Changelog](https://github.com/Shopify/bootsnap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Shopify/bootsnap/compare/v1.8.1...v1.9.0)

---
updated-dependencies:
- dependency-name: bootsnap
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-17 09:02:52 +00:00
dependabot[bot]
b2fb0366f7 Bump @rails/webpacker from 5.4.2 to 5.4.3
Bumps [@rails/webpacker](https://github.com/rails/webpacker) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/rails/webpacker/releases)
- [Changelog](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/webpacker/compare/v5.4.2...v5.4.3)

---
updated-dependencies:
- dependency-name: "@rails/webpacker"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-17 08:53:44 +00:00
Matt-Yorkley
f4c86a1b51 Merge pull request #8061 from Matt-Yorkley/turbo-checkout
Split Checkout new toys
2021-09-17 10:48:59 +02:00
Matt-Yorkley
02bcb7bcc7 Merge pull request #8192 from Matt-Yorkley/orders-path-issue
Fix order_path issue in cart page
2021-09-16 16:16:36 +02:00
Matt-Yorkley
d55a3f3340 Bump Turbo 2021-09-16 14:12:31 +01:00
Matt-Yorkley
47346e9f2c Uncomment ActionCable in application.rb
We're not directly utilising it yet, but CableReady expects it to be loaded.
2021-09-15 18:52:24 +01:00
Andy Brett
f28200164b Merge pull request #8154 from meronokbay/8098-custom-modal-order-deletion
Replaced the default alert and confirm modals in the order page by custom modals
2021-09-15 09:22:58 -07:00
Andy Brett
6e674b47ac Merge pull request #8153 from sinansonmez/6140-change-profile-link-based-on-enterprise-profile
update profile link based on enterprise profile
2021-09-15 09:22:03 -07:00
Matt-Yorkley
0c879dc4c9 Fix order_path issue in cart page
The order_path route wasn't being inferred correctly from this Spree controller, causing errors to be thrown in the cart page if the number of editable orders was precisely one:

ActionView::Template::Error: undefined method `order_path'
2021-09-15 10:54:59 +01:00
dependabot[bot]
a1f7d8753b Bump webpacker from 5.4.2 to 5.4.3
Bumps [webpacker](https://github.com/rails/webpacker) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/rails/webpacker/releases)
- [Changelog](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/webpacker/compare/v5.4.2...v5.4.3)

---
updated-dependencies:
- dependency-name: webpacker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-15 09:03:58 +00:00
Nihal M. Kelanthodika
9d216f0cea Merge pull request #8160 from apricot12/8019-Delivery_report
Show order total in Delivery/Payment Method reports instead of first …
2021-09-15 13:11:43 +05:30
Maikel
16aeb16519 Merge pull request #8172 from openfoodfoundation/dependabot/bundler/activemerchant-1.123.0
Bump activemerchant from 1.121.0 to 1.123.0
2021-09-15 17:14:29 +10:00
Andy Brett
2f5f2a03dd Merge pull request #8182 from openfoodfoundation/dependabot/bundler/test-unit-3.4.7
Bump test-unit from 3.4.6 to 3.4.7
2021-09-14 11:02:48 -07:00
Andy Brett
8c78316718 Merge pull request #8181 from openfoodfoundation/dependabot/bundler/rubocop-1.21.0
Bump rubocop from 1.20.0 to 1.21.0
2021-09-14 11:02:19 -07:00
dependabot[bot]
841a7a31fa Bump test-unit from 3.4.6 to 3.4.7
Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.4.6 to 3.4.7.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](https://github.com/test-unit/test-unit/compare/3.4.6...3.4.7)

---
updated-dependencies:
- dependency-name: test-unit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-14 09:03:26 +00:00
dependabot[bot]
6d9173deba Bump rubocop from 1.20.0 to 1.21.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.20.0 to 1.21.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.20.0...v1.21.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-14 09:02:19 +00:00
Jean-Baptiste Bellet
ba09618374 Avoid rounded with float numbers errors with javascript
0.7/0.001 = 699.9999999999999

Use Math.round() to avoid this.
2021-09-14 10:45:31 +02:00
Andy Brett
82a8eed652 Merge pull request #8165 from openfoodfoundation/dependabot/bundler/view_component-2.40.0
Bump view_component from 2.39.0 to 2.40.0
2021-09-13 15:26:55 -07:00
Andy Brett
77ca05ebe5 Merge pull request #8175 from openfoodfoundation/dependabot/npm_and_yarn/jest-27.2.0
Bump jest from 27.1.1 to 27.2.0
2021-09-13 15:26:31 -07:00
Andy Brett
da912d2fdf Merge pull request #8173 from openfoodfoundation/dependabot/bundler/test-unit-3.4.6
Bump test-unit from 3.4.5 to 3.4.6
2021-09-13 15:26:08 -07:00
Andy Brett
297dc56fe5 Merge pull request #8174 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.12.2
Bump rubocop-rails from 2.12.0 to 2.12.2
2021-09-13 15:25:45 -07:00
dependabot[bot]
b0b91c959e Bump jest from 27.1.1 to 27.2.0
Bumps [jest](https://github.com/facebook/jest) from 27.1.1 to 27.2.0.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/compare/v27.1.1...v27.2.0)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 09:09:54 +00:00
dependabot[bot]
a7e9acd435 Bump rubocop-rails from 2.12.0 to 2.12.2
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.12.0 to 2.12.2.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.12.0...v2.12.2)

---
updated-dependencies:
- dependency-name: rubocop-rails
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 09:05:04 +00:00
dependabot[bot]
d75b03debd Bump test-unit from 3.4.5 to 3.4.6
Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.4.5 to 3.4.6.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](https://github.com/test-unit/test-unit/compare/3.4.5...3.4.6)

---
updated-dependencies:
- dependency-name: test-unit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 09:04:26 +00:00
dependabot[bot]
685a3eb14f Bump activemerchant from 1.121.0 to 1.123.0
Bumps [activemerchant](https://github.com/activemerchant/active_merchant) from 1.121.0 to 1.123.0.
- [Release notes](https://github.com/activemerchant/active_merchant/releases)
- [Changelog](https://github.com/activemerchant/active_merchant/blob/master/CHANGELOG)
- [Commits](https://github.com/activemerchant/active_merchant/compare/v1.121.0...v1.123.0)

---
updated-dependencies:
- dependency-name: activemerchant
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 09:02:43 +00:00
Nihal
757b7513ef Migrate Pin gateway peyments to check 2021-09-11 16:52:32 +05:30
Meron Ogbai
94ff59ebab Make order spec click clearer 2021-09-11 13:37:14 +03:00
Meron Ogbai
a065a92616 Reorganize alert and confirm code 2021-09-11 13:36:28 +03:00
Meron Ogbai
aed84912a3 Use selector to get del element 2021-09-11 13:10:33 +03:00
Andy Brett
1ec9cce439 Merge pull request #8163 from mkllnk/migration-specs
Remove problematic migration spec
2021-09-10 10:32:29 -07:00
Nihal M. Kelanthodika
5811b6e3d1 Merge pull request #8064 from apricot12/Kill_stripe_connect
Kill stripe connect
2021-09-10 22:57:00 +05:30
Nihal
98a879a0e9 Restore removed spec to profile_storer_spec 2021-09-10 14:43:34 +05:30
Nihal Mohammed
98ff3980f8 Migration of StripeConnect to StripeSCA 2021-09-10 14:43:34 +05:30
Nihal Mohammed
eb17c208f9 Update stripe_stubs to handle stripeSCA 2021-09-10 14:43:34 +05:30
Nihal Mohammed
fa9f6432c3 Fix profile_storer.rb and profile_storer_spec 2021-09-10 14:43:34 +05:30
Nihal Mohammed
6ac835de2e Fix response for payment_profile_id in profile_storer.rb 2021-09-10 14:43:34 +05:30
Nihal Mohammed
696d434979 Removed stripe connect example and fixed JSON generation in profile_storer spec 2021-09-10 14:43:34 +05:30
Nihal Mohammed
48c1312cea Remove expectation to generate clean name for StripeConnect from payment_method_spec 2021-09-10 14:43:34 +05:30
Luis Ramos
0c240cee9a A few more removals of stripe connect related code 2021-09-10 14:43:34 +05:30
Luis Ramos
f90e34bb47 Adapt specs to use stripe_sca_payment_method factory and delete stripe_connect_payment_method 2021-09-10 14:43:34 +05:30
Luis Ramos
9de9b41575 Remove stripe connect spec, there's a similar spec for stripesca below 2021-09-10 14:43:34 +05:30
Luis Ramos
60a8ae6675 Remove Stripe Connect gateway and related code 2021-09-10 14:43:24 +05:30
Luis Ramos
5434b51f75 Switch filter to StripeSCA, this must have been an error, must be tested (manually or automatically) 2021-09-10 14:41:06 +05:30
dependabot[bot]
93118f9c32 Bump view_component from 2.39.0 to 2.40.0
Bumps [view_component](https://github.com/github/view_component) from 2.39.0 to 2.40.0.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.39.0...v2.40.0)

---
updated-dependencies:
- dependency-name: view_component
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-10 09:02:41 +00:00
Nihal
43e6d1b933 Show order total in Delivery/Payment Method reports instead of first payment 2021-09-10 13:08:00 +05:30
Maikel Linke
10c2a1c55c Remove problematic migration spec
Unfortunately, loading the migration code also reloads some Spree models
which causes errors later on. Another spec was failing with:

  1) full-page cart viewing the cart when a product is soft-deleted shows the cart without errors
     Failure/Error: variant.instance_variable_set :@hub, @hub

     FrozenError:
       can't modify frozen NilClass: nil
     # ./lib/open_food_network/scope_variant_to_hub.rb:12:in `instance_variable_set'

The command to reproduce was:

rspec ./spec/features/consumer/shopping/cart_spec.rb[1:1:3:1]\
 ./spec/migrations/migrate_enterprise_fee_tax_amounts_spec.rb[1:1:1:1] --seed 0

I couldn't find a quick solution to make the migration not use app code.
Since the migration is a historical record now, it doesn't need repeated
testing.
2021-09-10 16:19:40 +10:00
Maikel
9affc6a945 Merge pull request #8108 from Matt-Yorkley/andand
Remove `andand` gem
2021-09-10 15:06:00 +10:00
Maikel Linke
e013d81e3d Simplify safe navigation operator use < and [] 2021-09-10 14:40:46 +10:00
Sinan Chaush
868187aaaf create helper to select correct url 2021-09-09 22:22:25 +02:00
Sinan Sonmez (Chaush)
12c154934d Update app/views/spree/admin/overview/single_enterprise_dashboard.html.haml
Co-authored-by: Maikel <maikel@email.org.au>
2021-09-09 16:29:28 +02:00
Matt-Yorkley
b352476301 Update app/models/proxy_order.rb
Co-authored-by: Maikel <maikel@email.org.au>
2021-09-09 13:39:08 +02:00
Meron Ogbai
4eda15fb71 Expect custom modal instead of alert in order spec 2021-09-09 11:57:56 +03:00
Meron Ogbai
95e294c9ec Use custom modals for deleting orders 2021-09-09 06:25:03 +03:00
Meron Ogbai
4806ba540f Add modals in orders page 2021-09-09 06:23:39 +03:00
Meron Ogbai
2de75ef7f4 Remove default rails confirm behavior 2021-09-09 06:22:55 +03:00
Meron Ogbai
d4f7b318e7 Add haml and css for custom modals 2021-09-09 06:21:14 +03:00
Sinan Chaush
f883e66c96 update profile link based on enterprise profile 2021-09-08 21:10:12 +02:00
Matt-Yorkley
44b870d248 Bump MRUJS and update syntax for new plugin architecture 2021-09-08 19:39:52 +01:00
Matt-Yorkley
1d5077061e Remove andand
This old gem implemented some functionality for handling nils which is no longer needed, as it's provided natively by Ruby with the &. operator.
2021-09-08 14:28:31 +01:00
Matt-Yorkley
086c5ab264 Replace directive with data-confirm 2021-09-08 10:34:34 +01:00
Matt-Yorkley
8bf3f72ad3 Extract CableCar responses code to a concern 2021-09-08 10:34:34 +01:00
Matt-Yorkley
5ef34347a3 Implement optional non-Angular flash messages 2021-09-08 10:34:34 +01:00
Matt-Yorkley
e48b9d84e5 Extract boilerplate code 2021-09-08 10:34:34 +01:00
Matt-Yorkley
03abc395f2 Update responses to use cable_ready 2021-09-08 10:34:34 +01:00
Matt-Yorkley
7fa9457550 Add cable_ready 2021-09-08 10:34:34 +01:00
Matt-Yorkley
edb599b426 Disable Turbo page caching 2021-09-08 10:34:34 +01:00
Matt-Yorkley
062a3abc2d Enable Turbo in the new checkout 2021-09-08 10:34:34 +01:00
Matt-Yorkley
6b028ba849 Disable Turbo site-wide 2021-09-08 10:34:34 +01:00
Matt-Yorkley
23779fd5e4 Include progressbar for mrujs form submissions 2021-09-08 10:34:34 +01:00
Matt-Yorkley
20ff594014 Set data-remote on checkout form 2021-09-08 10:34:34 +01:00
Matt-Yorkley
9be73a8ff1 Respond with HTTP error code on update failure 2021-09-08 10:34:34 +01:00
Matt-Yorkley
10f6368524 Add Angular teardown 2021-09-08 10:34:34 +01:00
Matt-Yorkley
a23171ea51 Compile Webpacker assets only once in test environment 2021-09-08 10:34:34 +01:00
Matt-Yorkley
658f0eccbb Replace ng-app with explicit Angular bootstrapping and move scripts to head 2021-09-08 10:34:34 +01:00
Matt-Yorkley
b29d88be25 Add progress bar styling 2021-09-08 00:05:04 +01:00
Matt-Yorkley
79efa50a34 Add Turbo and MRUJS 2021-09-08 00:05:04 +01:00
David Cook
c156d0c2e6 Add script to import product images from URL
With new ImageImporter.

Co-authored-by: Maikel <maikel@email.org.au>
2021-07-16 11:36:49 +10:00
142 changed files with 1085 additions and 809 deletions

View File

@@ -57,7 +57,6 @@ gem 'oauth2', '~> 1.4.7' # Used for Stripe Connect
gem 'pagy', '~> 4.11'
gem 'andand'
gem 'angularjs-rails', '1.8.0'
gem 'aws-sdk', '1.67.0'
gem 'bugsnag'
@@ -90,6 +89,8 @@ gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'sidekiq'
gem 'sidekiq-scheduler'
gem "cable_ready", "5.0.0.pre2"
gem 'combine_pdf'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

View File

@@ -102,7 +102,7 @@ GEM
activejob (6.1.4.1)
activesupport (= 6.1.4.1)
globalid (>= 0.3.6)
activemerchant (1.121.0)
activemerchant (1.123.0)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
@@ -142,7 +142,6 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
afm (0.2.2)
andand (1.3.3)
angular-rails-templates (1.1.0)
railties (>= 4.2, < 7)
sprockets (>= 3.0, < 5)
@@ -163,15 +162,18 @@ GEM
bcrypt (3.1.16)
bigdecimal (3.0.2)
bindex (0.8.1)
bootsnap (1.8.1)
bootsnap (1.9.1)
msgpack (~> 1.0)
bugsnag (6.22.1)
bugsnag (6.23.0)
concurrent-ruby (~> 1.0)
builder (3.2.4)
bullet (6.1.5)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
cable_ready (5.0.0.pre2)
rails (>= 5.2)
thread-local (>= 1.1.0)
cancancan (1.15.0)
capybara (3.35.3)
addressable
@@ -388,7 +390,7 @@ GEM
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.5.8)
nokogiri (1.12.3)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
oauth2 (1.4.7)
@@ -408,7 +410,7 @@ GEM
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
mime-types
parallel (1.20.1)
parallel (1.21.0)
paranoia (2.4.3)
activerecord (>= 4.0, < 6.2)
parser (3.0.2.0)
@@ -433,7 +435,7 @@ GEM
byebug (~> 11.0)
pry (~> 0.13.0)
public_suffix (4.0.6)
puma (5.4.0)
puma (5.5.0)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.5.2)
@@ -472,7 +474,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.1)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
@@ -547,7 +549,7 @@ GEM
rswag-ui (2.4.0)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (1.20.0)
rubocop (1.21.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
@@ -558,7 +560,7 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.11.0)
parser (>= 3.0.1.1)
rubocop-rails (2.12.0)
rubocop-rails (2.12.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
@@ -620,9 +622,10 @@ GEM
stripe (5.38.0)
temple (0.8.2)
test-prof (1.0.7)
test-unit (3.4.5)
test-unit (3.4.7)
power_assert
thor (1.1.0)
thread-local (1.1.0)
thwait (0.2.0)
e2mmap
tilt (2.0.10)
@@ -637,7 +640,7 @@ GEM
valid_email2 (4.0.0)
activemodel (>= 3.2)
mail (~> 2.5)
view_component (2.39.0)
view_component (2.40.0)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
view_component_storybook (0.10.1)
@@ -657,7 +660,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpacker (5.4.2)
webpacker (5.4.3)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
@@ -687,7 +690,6 @@ DEPENDENCIES
activerecord-session_store
acts-as-taggable-on (~> 8.1)
acts_as_list (= 1.0.4)
andand
angular-rails-templates (>= 0.3.0)
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
@@ -700,6 +702,7 @@ DEPENDENCIES
bugsnag
bullet
byebug
cable_ready (= 5.0.0.pre2)
cancancan (~> 1.15.0)
capybara
catalog!

View File

@@ -48,7 +48,7 @@ angular.module("admin.products").factory "OptionValueNamer", (VariantUnitManager
option_value_value_unit_scaled: ->
[unit_scale, unit_name] = @scale_for_unit_value()
value = @variant.unit_value / unit_scale
value = Math.round((@variant.unit_value / unit_scale) * 100) / 100
[value, unit_name]

View File

@@ -2,6 +2,9 @@
$(document).ready(function() {
initAlert()
initConfirm()
if ($('#variant_autocomplete_template').length > 0) {
window.variantTemplate = Handlebars.compile($('#variant_autocomplete_template').text());
window.variantStockTemplate = Handlebars.compile($('#variant_autocomplete_stock_template').text());
@@ -45,7 +48,7 @@ $(document).ready(function() {
if (quantity > maxQuantity) {
quantity = maxQuantity;
save.parents('tr').find('input.line_item_quantity').val(maxQuantity);
alert(t("js.admin.orders.quantity_adjusted"));
ofnAlert(t("js.admin.orders.quantity_adjusted"));
}
toggleItemEdit();
@@ -54,18 +57,23 @@ $(document).ready(function() {
}
$('a.save-item').click(handle_save_click);
handle_delete_click = function(e, confirmed){
if (confirmed) {
var del = $(this);
var shipment_number = del.data('shipment-number');
var variant_id = del.data('variant-id');
handle_delete_click = function(elementSelector){
var del = $(elementSelector);
del.hide()
var shipment_number = del.data('shipment-number');
var variant_id = del.data('variant-id');
toggleItemEdit();
toggleItemEdit();
adjustItems(shipment_number, variant_id, 0);
}
adjustItems(shipment_number, variant_id, 0);
}
$('a.delete-item').on('confirm:complete', handle_delete_click);
$('a.delete-item').click((event) => {
ofnConfirm(() => {
handle_delete_click('#custom-confirm');
});
});
}
});
@@ -74,7 +82,7 @@ adjustItems = function(shipment_number, variant_id, quantity){
var inventory_units = _.where(shipment.inventory_units, {variant_id: variant_id});
if (quantity == 0 && inventory_units.length == shipment.inventory_units.length) {
alert(t("js.admin.orders.cannot_remove_last_item"));
ofnAlert(t("js.admin.orders.cannot_remove_last_item"));
return;
}
@@ -91,7 +99,7 @@ adjustItems = function(shipment_number, variant_id, quantity){
url += '.json';
if (new_quantity == 0) {
alert(t("js.admin.orders.quantity_unchanged"));
ofnAlert(t("js.admin.orders.quantity_unchanged"));
} else {
$.ajax({
type: "PUT",
@@ -154,3 +162,27 @@ addVariantFromStockLocation = function() {
}
return 1
}
initAlert = function() {
$('#custom-alert .confirm').click(function(e) {
$('#custom-alert').hide();
})
}
initConfirm = function() {
$('#custom-confirm button.cancel').click(function(e) {
$('#custom-confirm').hide();
});
}
ofnAlert = function(message) {
$('#custom-alert .message').text(message);
$('#custom-alert').show();
}
ofnConfirm = function(callback) {
$('#custom-confirm').data($(event.target).data());
$('#custom-confirm button.confirm').click(callback);
$('#custom-confirm').show();
}

View File

@@ -54,3 +54,23 @@
#= require_tree ./mixins
#= require_tree ./directives
#= require_tree .
document.addEventListener "turbo:load", ->
window.injector = angular.bootstrap document.body, ["Darkswarm"]
true
document.addEventListener "turbo:before-render", ->
if window.injector
rootscope = window.injector.get("$rootScope")
rootscope?.$destroy()
rootscope = null
window.injector = null
true
document.addEventListener "ajax:beforeSend", (event) =>
window.Turbo.navigator.adapter.progressBar.setValue(0)
window.Turbo.navigator.adapter.progressBar.show()
document.addEventListener "ajax:complete", (event) =>
window.Turbo.navigator.adapter.progressBar.setValue(100)
window.Turbo.navigator.adapter.progressBar.hide()

View File

@@ -1,9 +0,0 @@
angular.module('Darkswarm').directive "confirmLinkClick", ($window) ->
restrict: 'A'
scope:
confirmMsg: '@confirmLinkClick'
link: (scope, elem, attr) ->
elem.bind 'click', (event) ->
unless confirm(scope.confirmMsg)
event.preventDefault()
event.stopPropagation()

View File

@@ -134,3 +134,33 @@ table.index td.actions {
color: $warning-red;
}
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
text-align: center;
.modal-content {
background-color: $color-1;
margin: 15% auto;
padding: 1.2em;
width: 30%;
border-radius: 1em;
border: 1px solid $color-border;
}
.modal-title {
font-size: $h4-size;
}
.message {
font-size: $h5-size;
padding: 1.2em 0;
}
}

View File

@@ -1,7 +1,21 @@
@import "mixins";
.turbo-progress-bar {
background-color: $teal-400;
}
// ANIMATION FUNCTIONS
@keyframes fade-out-hide {
0% {opacity: 1; visibility: visible;}
99% {opacity: 0; visibility: visible;}
100% {opacity: 0; visibility: hidden;}
}
.animate-hide-500 {
animation: fade-out-hide 0.5s;
}
//
@-webkit-keyframes slideInDown {
0% {

View File

@@ -6,7 +6,7 @@ module Admin
# GET /admin/bulk_line_items.json
#
def index
order_params = params[:q].andand.delete :order
order_params = params[:q]&.delete :order
orders = order_permissions.editable_orders.ransack(order_params).result
@line_items = order_permissions.

View File

@@ -50,7 +50,7 @@ module Admin
end
def load_object_data
@owner_email = @enterprise_group.andand.owner.andand.email || ""
@owner_email = @enterprise_group&.owner&.email || ""
end
def collection

View File

@@ -73,7 +73,7 @@ module Admin
end
def bulk_update
if order_cycle_set.andand.save
if order_cycle_set&.save
render_as_json @order_cycles,
ams_prefix: 'index',
current_user: spree_current_user,
@@ -155,7 +155,7 @@ module Admin
if json_request?
# Split ransack params into all those that currently exist and new ones
# to limit returned ocs to recent or undated
orders_close_at_gt = raw_params[:q].andand.delete(:orders_close_at_gt) || 31.days.ago
orders_close_at_gt = raw_params[:q]&.delete(:orders_close_at_gt) || 31.days.ago
raw_params[:q] = {
g: [raw_params.delete(:q) || {}, { m: 'or',
orders_close_at_gt: orders_close_at_gt,
@@ -217,7 +217,7 @@ module Admin
(order_cycle_bulk_params[:collection_attributes] || []).keep_if do |_index, hash|
order_cycle = OrderCycle.find(hash[:id])
managed_ids.include?(order_cycle.andand.coordinator_id)
managed_ids.include?(order_cycle&.coordinator_id)
end
end

View File

@@ -28,7 +28,7 @@ module Admin
def load_build_context
@shop = Enterprise.managed_by(spree_current_user).find_by(id: params[:shop_id])
@schedule = permissions.editable_schedules.find_by(id: params[:schedule_id])
@order_cycle = @schedule.andand.current_or_next_order_cycle
@order_cycle = @schedule&.current_or_next_order_cycle
@variant = variant_if_eligible(subscription_line_item_params[:variant_id]) if @shop.present?
end

View File

@@ -94,7 +94,7 @@ module Api
end
def customer
@current_api_user.andand.customer_of(distributor) || nil
@current_api_user&.customer_of(distributor) || nil
end
def distributed_products

View File

@@ -152,7 +152,7 @@ class ApplicationController < ActionController::Base
end
def check_order_cycle_expiry
if current_order_cycle.andand.closed?
if current_order_cycle&.closed?
current_order.empty!
current_order.set_order_cycle! nil
flash[:info] = I18n.t('order_cycle_closed')

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
module CablecarResponses
extend ActiveSupport::Concern
included do
include CableReady::Broadcaster
end
private
def partial(path, options = {})
{ html: render_to_string(partial: path, **options) }
end
end

View File

@@ -31,7 +31,7 @@ class EnterprisesController < BaseController
respond_to do |format|
format.json do
enterprises = @enterprise.andand.relatives.andand.activated
enterprises = @enterprise&.relatives&.activated
render(json: enterprises,
each_serializer: Api::EnterpriseSerializer,
data: OpenFoodNetwork::EnterpriseInjectionData.new)

View File

@@ -8,6 +8,7 @@ class SplitCheckoutController < ::BaseController
include OrderStockCheck
include Spree::BaseHelper
include CheckoutCallbacks
include CablecarResponses
helper 'terms_and_conditions'
helper 'checkout'
@@ -25,7 +26,11 @@ class SplitCheckoutController < ::BaseController
redirect_to_step
else
flash.now[:error] = I18n.t('split_checkout.errors.global')
render :edit
render operations: cable_car.
replace("#checkout", partial("split_checkout/checkout")).
replace("#flashes", partial("shared/flashes", locals: { flashes: flash })),
status: :unprocessable_entity
end
end

View File

@@ -106,7 +106,7 @@ module Spree
raise "Suffix '#{ams_prefix}' not found in ams_prefix_whitelist for #{self.class.name}."
end
prefix = ams_prefix.andand.classify || ""
prefix = ams_prefix&.classify || ""
name = controller_name.classify
"::Api::Admin::#{prefix}#{name}Serializer".constantize
end

View File

@@ -7,7 +7,7 @@ module Spree
before_action :load_data
before_action :validate_payment_method_provider, only: [:create]
before_action :load_hubs, only: [:new, :edit, :update]
before_action :validate_calculator_preferred_amount, only: [:update]
before_action :validate_calculator_preferred_value, only: [:update]
respond_to :html
@@ -136,7 +136,7 @@ module Spree
def restrict_stripe_account_change
return unless @payment_method
return unless stripe_payment_method?
return unless @payment_method.preferred_enterprise_id.andand > 0
return unless @payment_method.preferred_enterprise_id&.positive?
@stripe_account_holder = Enterprise.find(@payment_method.preferred_enterprise_id)
return if spree_current_user.enterprises.include? @stripe_account_holder
@@ -158,11 +158,14 @@ module Spree
call.to_h.with_indifferent_access
end
def gateway_params
raw_params[ActiveModel::Naming.param_key(@payment_method)] || {}
end
# Merge payment method params with gateway params like :gateway_stripe_connect
# Also, remove password if present and blank
def update_params
@update_params ||= begin
gateway_params = raw_params[ActiveModel::Naming.param_key(@payment_method)] || {}
params_for_update = base_params.merge(gateway_params)
params_for_update.each do |key, value|
@@ -175,15 +178,30 @@ module Spree
end
end
def validate_calculator_preferred_amount
preferred_amount = params.dig(:payment_method_check, :calculator_attributes,
:preferred_amount)
return if preferred_amount.nil? || Float(preferred_amount,
exception: false)
def validate_calculator_preferred_value
return if calculator_preferred_values.all? do |value|
preferred_value_from_params = gateway_params.dig(:calculator_attributes, value)
preferred_value_from_params.nil? || Float(preferred_value_from_params,
exception: false)
end
flash[:error] = I18n.t(:calculator_preferred_amount_error)
flash[:error] = I18n.t(:calculator_preferred_value_error)
redirect_to spree.edit_admin_payment_method_path(@payment_method)
end
def calculator_preferred_values
[
:preferred_amount,
:preferred_flat_percent,
:preferred_flat_percent,
:preferred_first_item,
:preferred_additional_item,
:preferred_max_items,
:preferred_normal_amount,
:preferred_discount_amount,
:preferred_minimal_amount
]
end
end
end
end

View File

@@ -82,7 +82,7 @@ module Spree
def create_before
option_values = params[:new_variant]
option_values.andand.each_value { |id| @object.option_values << OptionValue.find(id) }
option_values&.each_value { |id| @object.option_values << OptionValue.find(id) }
@object.save
end

View File

@@ -171,16 +171,16 @@ module Spree
# changes are allowed and the user has access. Return nil if not.
def changeable_order_from_number
order = Spree::Order.complete.find_by(number: params[:id])
return nil unless order.andand.changes_allowed? && can?(:update, order)
return nil unless order&.changes_allowed? && can?(:update, order)
order
end
def check_at_least_one_line_item
return unless order_to_update.andand.complete?
return unless order_to_update&.complete?
items = params[:order][:line_items_attributes]
.andand.select{ |_k, attrs| attrs["quantity"].to_i > 0 }
&.select{ |_k, attrs| attrs["quantity"].to_i > 0 }
if items.empty?
flash[:error] = I18n.t(:orders_cannot_remove_the_final_item)

View File

@@ -4,7 +4,7 @@ require 'open_food_network/available_payment_method_filter'
module EnterprisesHelper
def current_distributor
@current_distributor ||= current_order(false).andand.distributor
@current_distributor ||= current_order(false)&.distributor
end
def current_customer
@@ -19,7 +19,7 @@ module EnterprisesHelper
shipping_methods = current_distributor.shipping_methods.display_on_checkout.to_a
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
"FilterShippingMethods", current_customer.andand.tag_list)
"FilterShippingMethods", current_customer&.tag_list)
applicator.filter!(shipping_methods)
shipping_methods.uniq
@@ -34,7 +34,7 @@ module EnterprisesHelper
filter.filter!(payment_methods)
applicator = OpenFoodNetwork::TagRuleApplicator.new(current_distributor,
"FilterPaymentMethods", current_customer.andand.tag_list)
"FilterPaymentMethods", current_customer&.tag_list)
applicator.filter!(payment_methods)
payment_methods
@@ -90,7 +90,7 @@ module EnterprisesHelper
end
def order_changes_allowed?
current_order.andand.distributor.andand.allow_order_changes?
current_order&.distributor&.allow_order_changes?
end
def show_bought_items?
@@ -100,4 +100,12 @@ module EnterprisesHelper
def subscriptions_enabled?
spree_current_user.admin? || spree_current_user.enterprises.where(enable_subscriptions: true).any?
end
def enterprise_url_selector(enterprise)
if enterprise.is_distributor
main_app.enterprise_shop_url(enterprise)
else
main_app.producers_url
end
end
end

View File

@@ -17,6 +17,6 @@ module GroupsHelper
end
def strip_url(url)
url.andand.sub(%r{^https?://}i, '')
url&.sub(%r{^https?://}i, '')
end
end

View File

@@ -4,7 +4,7 @@ require 'open_food_network/permissions'
module OrderCyclesHelper
def current_order_cycle
@current_order_cycle ||= current_order(false).andand.order_cycle
@current_order_cycle ||= current_order(false)&.order_cycle
end
def permitted_enterprises_for(order_cycle)

View File

@@ -12,11 +12,11 @@ module SharedHelper
end
def enterprise_user?
spree_current_user.andand.enterprises.andand.count.to_i > 0
spree_current_user&.enterprises&.count.to_i > 0
end
def admin_user?
spree_current_user.andand.has_spree_role? 'admin'
spree_current_user&.has_spree_role? 'admin'
end
def current_shop_products_path

View File

@@ -12,7 +12,7 @@ module Spree
end
def cart_count
current_order.andand.line_items.andand.count || 0
current_order&.line_items&.count || 0
end
def changeable_orders
@@ -30,7 +30,7 @@ module Spree
end
def changeable_orders_link_path
changeable_orders.one? ? order_path(changeable_orders.first) : spree.account_path
changeable_orders.one? ? main_app.order_path(changeable_orders.first) : spree.account_path
end
def shop_changeable_orders_alert_html

View File

@@ -6,15 +6,15 @@ module Spree
module ReportsHelper
def report_order_cycle_options(order_cycles)
order_cycles.map do |oc|
orders_open_at = oc.orders_open_at.andand.to_s(:short) || 'NA'
orders_close_at = oc.orders_close_at.andand.to_s(:short) || 'NA'
orders_open_at = oc.orders_open_at&.to_s(:short) || 'NA'
orders_close_at = oc.orders_close_at&.to_s(:short) || 'NA'
["#{oc.name} &nbsp; (#{orders_open_at} - #{orders_close_at})".html_safe, oc.id]
end
end
def report_payment_method_options(orders)
orders.map do |order|
payment_method = order.payments.first.andand.payment_method
payment_method = order.payments.first&.payment_method
next unless payment_method
@@ -25,7 +25,7 @@ module Spree
def report_shipping_method_options(orders)
orders.map do |o|
sm = o.shipping_method
[sm.andand.name, sm.andand.id]
[sm&.name, sm&.id]
end.uniq
end

View File

@@ -50,9 +50,9 @@ module Calculator
def weight_per_variant(line_item)
if variant_unit(line_item) == 'weight'
# Convert unit_value to the preferred unit
convert_weight(line_item.variant.andand.unit_value)
convert_weight(line_item.variant&.unit_value)
else
line_item.variant.andand.weight || 0
line_item.variant&.weight || 0
end
end
@@ -79,7 +79,7 @@ module Calculator
end
def variant_unit(line_item)
line_item.variant.product.andand.variant_unit
line_item.variant.product&.variant_unit
end
def convert_weight(value)

View File

@@ -35,7 +35,7 @@ class Customer < ApplicationRecord
private
def downcase_email
email.andand.downcase!
email&.downcase!
end
def empty_code

View File

@@ -410,7 +410,7 @@ class Enterprise < ApplicationRecord
end
def strip_url(url)
url.andand.sub(%r{(https?://)?}, '')
url&.sub(%r{(https?://)?}, '')
end
def set_unused_address_fields

View File

@@ -231,15 +231,15 @@ class OrderCycle < ApplicationRecord
end
def receival_instructions_for(supplier)
exchange_for_supplier(supplier).andand.receival_instructions
exchange_for_supplier(supplier)&.receival_instructions
end
def pickup_time_for(distributor)
exchange_for_distributor(distributor).andand.pickup_time || distributor.next_collection_at
exchange_for_distributor(distributor)&.pickup_time || distributor.next_collection_at
end
def pickup_instructions_for(distributor)
exchange_for_distributor(distributor).andand.pickup_instructions
exchange_for_distributor(distributor)&.pickup_instructions
end
def exchanges_carrying(variant, distributor)

View File

@@ -424,7 +424,7 @@ module ProductImport
end
def import_into_inventory?
@import_settings[:settings].andand['import_into'] == 'inventories'
@import_settings.dig(:settings, 'import_into') == 'inventories'
end
def validate_inventory_item(entry, variant_override)

View File

@@ -86,7 +86,7 @@ module ProductImport
end
def enterprise_products
@processor.andand.enterprise_products
@processor&.enterprise_products
end
def total_enterprise_products

View File

@@ -37,7 +37,7 @@ module ProductImport
private
def import_into_inventory?
@import_settings[:settings].andand['import_into'] == 'inventories'
@import_settings.dig(:settings, 'import_into') == 'inventories'
end
def create_enterprises_index

View File

@@ -33,7 +33,7 @@ class ProxyOrder < ApplicationRecord
end
def cancel
return false unless order_cycle.orders_close_at.andand > Time.zone.now
return false unless order_cycle.orders_close_at&.>(Time.zone.now)
transaction do
update_column(:canceled_at, Time.zone.now)
@@ -43,7 +43,7 @@ class ProxyOrder < ApplicationRecord
end
def resume
return false unless order_cycle.orders_close_at.andand > Time.zone.now
return false unless order_cycle.orders_close_at&.>(Time.zone.now)
transaction do
update_column(:canceled_at, nil)
@@ -72,7 +72,7 @@ class ProxyOrder < ApplicationRecord
end
def cart?
order.andand.state == 'complete' &&
order&.state == 'complete' &&
order_cycle.orders_close_at > Time.zone.now
end

View File

@@ -197,7 +197,7 @@ module Spree
end
can [:admin, :index, :read, :update, :bulk_update, :bulk_reset], VariantOverride do |vo|
next false unless vo.hub.present? && vo.variant.andand.product.andand.supplier.present?
next false unless vo.hub.present? && vo.variant&.product&.supplier.present?
hub_auth = OpenFoodNetwork::Permissions.new(user).
variant_override_hubs.
@@ -212,7 +212,7 @@ module Spree
can [:admin, :create, :update], InventoryItem do |ii|
next false unless ii.enterprise.present? &&
ii.variant.andand.product.andand.supplier.present?
ii.variant&.product&.supplier.present?
hub_auth = OpenFoodNetwork::Permissions.new(user).
variant_override_hubs.
@@ -267,7 +267,7 @@ module Spree
# Enterprise User can access orders that they are a distributor for
user.enterprises.include?(order.distributor) ||
# Enterprise User can access orders that are placed inside a OC they coordinate
order.order_cycle.andand.coordinated_by?(user)
order.order_cycle&.coordinated_by?(user)
end
can [:admin, :bulk_management, :managed], Spree::Order do
user.admin? || user.enterprises.any?(&:is_distributor)
@@ -280,7 +280,7 @@ module Spree
order = item.order
user.admin? ||
user.enterprises.include?(order.distributor) ||
order.order_cycle.andand.coordinated_by?(user)
order.order_cycle&.coordinated_by?(user)
end
can [:admin, :index, :read, :create, :edit, :update, :fire], Spree::Payment
@@ -293,7 +293,7 @@ module Spree
else
order = adjustment.order
user.enterprises.include?(order.distributor) ||
order.order_cycle.andand.coordinated_by?(user)
order.order_cycle&.coordinated_by?(user)
end
end

View File

@@ -90,7 +90,7 @@ module Spree
end
def full_address
render_address([address1, address2, city, zipcode, state.andand.name])
render_address([address1, address2, city, zipcode, state&.name])
end
def address_part1
@@ -98,7 +98,7 @@ module Spree
end
def address_part2
render_address([city, zipcode, state.andand.name])
render_address([city, zipcode, state&.name])
end
private

View File

@@ -22,7 +22,7 @@ module Spree
end
def stripe_account_id
StripeAccount.find_by(enterprise_id: preferred_enterprise_id).andand.stripe_user_id
StripeAccount.find_by(enterprise_id: preferred_enterprise_id)&.stripe_user_id
end
# NOTE: the name of this method is determined by Spree::Payment::Processing
@@ -100,7 +100,7 @@ module Spree
end
def ensure_enterprise_selected
return if preferred_enterprise_id.andand > 0
return if preferred_enterprise_id&.positive?
errors.add(:stripe_account_owner, I18n.t(:error_required))
end

View File

@@ -33,7 +33,7 @@ module Spree
end
def stripe_account_id
StripeAccount.find_by(enterprise_id: preferred_enterprise_id).andand.stripe_user_id
StripeAccount.find_by(enterprise_id: preferred_enterprise_id)&.stripe_user_id
end
# NOTE: the name of this method is determined by Spree::Payment::Processing
@@ -169,7 +169,7 @@ module Spree
end
def ensure_enterprise_selected
return if preferred_enterprise_id.andand.positive?
return if preferred_enterprise_id&.positive?
errors.add(:stripe_account_owner, I18n.t(:error_required))
end

View File

@@ -172,7 +172,7 @@ module Spree
end
def tax_rates
product.tax_category.andand.tax_rates || []
product.tax_category&.tax_rates || []
end
def price_with_adjustments
@@ -251,8 +251,8 @@ module Spree
def calculate_final_weight_volume
if final_weight_volume.present? && quantity_was > 0
self.final_weight_volume = final_weight_volume * quantity / quantity_was
elsif variant.andand.unit_value.present?
self.final_weight_volume = variant.andand.unit_value * quantity
elsif variant&.unit_value.present?
self.final_weight_volume = variant&.unit_value * quantity
end
end
end

View File

@@ -192,7 +192,7 @@ module Spree
end
def changes_allowed?
complete? && distributor.andand.allow_order_changes? && order_cycle.andand.open?
complete? && distributor&.allow_order_changes? && order_cycle&.open?
end
# Is this a free order in which case the payment step should be skipped
@@ -569,7 +569,7 @@ module Spree
def set_distributor!(distributor)
self.distributor = distributor
self.order_cycle = nil unless order_cycle.andand.has_distributor? distributor
self.order_cycle = nil unless order_cycle&.has_distributor? distributor
save!
end
@@ -677,7 +677,7 @@ module Spree
end
def using_guest_checkout?
require_email && !user.andand.id
require_email && !user&.id
end
def registered_email?
@@ -689,7 +689,7 @@ module Spree
end
def skip_payment_for_subscription?
subscription.present? && order_cycle.orders_close_at.andand > Time.zone.now
subscription.present? && order_cycle.orders_close_at&.>(Time.zone.now)
end
def require_customer?
@@ -705,7 +705,7 @@ module Spree
end
def email_for_customer
(user.andand.email || email).andand.downcase
(user&.email || email)&.downcase
end
def associate_customer
@@ -721,9 +721,9 @@ module Spree
enterprise: distributor,
email: email_for_customer,
user: user,
name: bill_address.andand.full_name,
bill_address: bill_address.andand.clone,
ship_address: ship_address.andand.clone
name: bill_address&.full_name,
bill_address: bill_address&.clone,
ship_address: ship_address&.clone
)
customer.save

View File

@@ -110,7 +110,7 @@ module Spree
def build_source
return if source_attributes.nil?
return unless payment_method.andand.payment_source_class
return unless payment_method&.payment_source_class
self.source = payment_method.payment_source_class.new(source_attributes)
source.payment_method_id = payment_method.id

View File

@@ -28,7 +28,7 @@ module Spree
def line_item_shipment(line_item)
return line_item.target_shipment if line_item.target_shipment
return line_item.order.shipments.first if line_item.order.andand.shipments.any?
return line_item.order.shipments.first if line_item.order&.shipments.any?
end
# Overrides Spree v2.0.4 validate method version to:

View File

@@ -60,13 +60,13 @@ module Spree
if: proc { Spree::Config[:require_master_price] }
validates :unit_value, presence: true, if: ->(variant) {
%w(weight volume).include?(variant.product.andand.variant_unit)
%w(weight volume).include?(variant.product&.variant_unit)
}
validates :unit_value, numericality: { greater_than: 0 }
validates :unit_description, presence: true, if: ->(variant) {
variant.product.andand.variant_unit.present? && variant.unit_value.nil?
variant.product&.variant_unit.present? && variant.unit_value.nil?
}
before_validation :set_cost_currency

View File

@@ -5,7 +5,7 @@ class TagRule::FilterOrderCycles < TagRule
preference :exchange_tags, :string, default: ""
def tags_match?(order_cycle)
exchange_tags = exchange_for(order_cycle).andand.tag_list || []
exchange_tags = exchange_for(order_cycle)&.tag_list || []
preferred_tags = preferred_exchange_tags.split(",")
( exchange_tags & preferred_tags ).any?
end

View File

@@ -5,7 +5,7 @@ class TagRule::FilterPaymentMethods < TagRule
preference :payment_method_tags, :string, default: ""
def tags_match?(payment_method)
payment_method_tags = payment_method.andand.tag_list || []
payment_method_tags = payment_method&.tag_list || []
preferred_tags = preferred_payment_method_tags.split(",")
( payment_method_tags & preferred_tags ).any?
end

View File

@@ -10,7 +10,7 @@ class TagRule
end
def tags_match?(variant)
variant_tags = variant.andand["tag_list"] || []
variant_tags = variant&.[]("tag_list") || []
preferred_tags = preferred_variant_tags.split(",")
(variant_tags & preferred_tags).any?
end

View File

@@ -9,7 +9,7 @@ class TagRule::FilterShippingMethods < TagRule
end
def tags_match?(shipping_method)
shipping_method_tags = shipping_method.andand.tag_list || []
shipping_method_tags = shipping_method&.tag_list || []
preferred_tags = preferred_shipping_method_tags.split(",")
( shipping_method_tags & preferred_tags ).any?
end

View File

@@ -9,10 +9,10 @@ class Api::AddressSerializer < ActiveModel::Serializer
:zipcode, :country_name
def country_name
object.country.andand.name
object.country&.name
end
def state_name
object.state.andand.abbr
object.state&.abbr
end
end

View File

@@ -15,11 +15,11 @@ module Api
end
def orders_open_at
object.orders_open_at.andand.strftime("%F %T %z")
object.orders_open_at&.strftime("%F %T %z")
end
def orders_close_at
object.orders_close_at.andand.strftime("%F %T %z")
object.orders_close_at&.strftime("%F %T %z")
end
end
end

View File

@@ -10,7 +10,7 @@ module Api
has_one :bill_address, serializer: Api::AddressSerializer
def name
object.name.presence || object.bill_address.andand.full_name
object.name.presence || object.bill_address&.full_name
end
def tag_list
@@ -19,7 +19,7 @@ module Api
def tags
customer_tag_list.map do |tag|
tag_rule_map = options[:tag_rule_mapping].andand[tag]
tag_rule_map = options.dig(:tag_rule_mapping, tag)
tag_rule_map || { text: tag, rules: nil }
end
end
@@ -35,7 +35,7 @@ module Api
def customer_tag_list
return object.tag_list unless options[:customer_tags]
options[:customer_tags].andand[object.id] || []
options.dig(:customer_tags, object.id) || []
end
end
end

View File

@@ -7,11 +7,11 @@ module Api
:calculator_type, :enterprise_name, :calculator_description, :calculator_settings
def enterprise_name
object.enterprise.andand.name
object.enterprise&.name
end
def calculator_description
object.calculator.andand.description
object.calculator&.description
end
def calculator_settings

View File

@@ -7,7 +7,7 @@ module Api
attributes :name, :supplier_name, :image_url, :master_id, :variants
def supplier_name
object.supplier.andand.name
object.supplier&.name
end
def image_url

View File

@@ -17,7 +17,7 @@ module Api
end
def distributor_name
object.distributor.andand.name
object.distributor&.name
end
def display_outstanding_balance

View File

@@ -13,7 +13,7 @@ module Api
end
def update_issues
options[:order_update_issues].andand[object.order_id] || []
options[:order_update_issues]&.[](object.order_id) || []
end
def completed_at

View File

@@ -11,7 +11,7 @@ module Api
end
def price_estimate
object.price_estimate.andand.to_f || "?"
object.price_estimate&.to_f || "?"
end
def in_open_and_upcoming_order_cycles
@@ -23,11 +23,11 @@ module Api
private
def option_or_assigned_shop
@options[:shop] || object.subscription.andand.shop
@options[:shop] || object.subscription&.shop
end
def option_or_assigned_schedule
@options[:schedule] || object.subscription.andand.schedule
@options[:schedule] || object.subscription&.schedule
end
end
end

View File

@@ -15,31 +15,31 @@ module Api
has_one :ship_address, serializer: Api::AddressSerializer
def begins_at
object.begins_at.andand.strftime('%F')
object.begins_at&.strftime('%F')
end
def ends_at
object.ends_at.andand.strftime('%F')
object.ends_at&.strftime('%F')
end
def paused_at
object.paused_at.andand.strftime('%F')
object.paused_at&.strftime('%F')
end
def canceled_at
object.canceled_at.andand.strftime('%F')
object.canceled_at&.strftime('%F')
end
def customer_email
object.customer.andand.email
object.customer&.email
end
def customer_name
object.customer.andand.name
object.customer&.name
end
def schedule_name
object.schedule.andand.name
object.schedule&.name
end
def edit_path

View File

@@ -9,7 +9,7 @@ module Api
cached
def cache_key
enterprise.andand.cache_key
enterprise&.cache_key
end
attributes :name, :id, :description, :latitude, :longitude,
@@ -119,7 +119,7 @@ module Api
end
def active
@active ||= data.active_distributor_ids.andand.include? enterprise.id
@active ||= data.active_distributor_ids&.include? enterprise.id
end
# Map svg icons.

View File

@@ -11,11 +11,11 @@ class Api::CurrentOrderSerializer < ActiveModel::Serializer
has_many :finalised_line_items, serializer: Api::LineItemSerializer
def payment_method_id
object.payments.first.andand.payment_method_id
object.payments.first&.payment_method_id
end
def shipping_method_id
object.shipping_method.andand.id
object.shipping_method&.id
end
def display_total

View File

@@ -16,7 +16,7 @@ module Api
has_many :distributed_properties, serializer: Api::PropertySerializer
def orders_close_at
OrderCycle.with_distributor(enterprise).soonest_closing.first.andand.orders_close_at
OrderCycle.with_distributor(enterprise).soonest_closing.first&.orders_close_at
end
def active

View File

@@ -34,7 +34,7 @@ module Api
def changes_allowed_until
return I18n.t(:not_allowed) unless object.changes_allowed?
I18n.l(object.order_cycle.andand.orders_close_at, format: "%b %d, %Y %H:%M")
I18n.l(object.order_cycle&.orders_close_at, format: "%b %d, %Y %H:%M")
end
def shipment_state

View File

@@ -11,7 +11,7 @@ module Api
end
def active
options[:data].active_distributor_ids.andand.include? object.id
options[:data].active_distributor_ids&.include? object.id
end
end
end

View File

@@ -11,7 +11,7 @@ class Api::VariantSerializer < ActiveModel::Serializer
delegate :price, to: :object
def fees
options[:enterprise_fee_calculator].andand.indexed_fees_by_type_for(object) ||
options[:enterprise_fee_calculator]&.indexed_fees_by_type_for(object) ||
object.fees_by_type_for(options[:current_distributor], options[:current_order_cycle])
end

View File

@@ -0,0 +1,22 @@
class ImageImporter
def import(url, product)
attach(download(url), product)
end
private
def download(url)
local_file = Tempfile.new
remote_file = open(url)
IO.copy_stream(remote_file, local_file)
local_file
end
def attach(file, product)
Spree::Image.create(
attachment: file,
viewable_id: product.master.id,
viewable_type: Spree::Variant,
)
end
end

View File

@@ -13,7 +13,7 @@ class OrderSyncer
def sync!
orders_in_order_cycles_not_closed.all? do |order|
order.assign_attributes(customer_id: customer_id, email: customer.andand.email,
order.assign_attributes(customer_id: customer_id, email: customer&.email,
distributor_id: shop_id)
update_associations_for(order)
line_item_syncer.sync!(order)
@@ -59,7 +59,7 @@ class OrderSyncer
payment = order.payments.
with_state('checkout').where(payment_method_id: payment_method_id_was).last
if payment
payment.andand.void_transaction!
payment&.void_transaction!
order.payments.create(payment_method_id: payment_method_id, amount: order.reload.total)
else
unless order.payments.with_state('checkout').where(payment_method_id: payment_method_id).any?

View File

@@ -110,6 +110,6 @@ class ProductTagRulesFilterer
end
def customer_tag_list
customer.andand.tag_list || []
customer&.tag_list || []
end
end

View File

@@ -24,6 +24,7 @@ class SearchOrders
def search_query
base_query = ::Permissions::Order.new(current_user).editable_orders.not_empty
.or(::Permissions::Order.new(current_user).editable_orders.finalized)
return base_query unless params[:shipping_method_id]

View File

@@ -28,7 +28,7 @@ module Sets
end
if found_element.nil?
@collection << @klass.new(attributes) unless @reject_if.andand.call(attributes)
@collection << @klass.new(attributes) unless @reject_if&.call(attributes)
else
process(found_element, attributes)
end
@@ -64,12 +64,12 @@ module Sets
# Allows us to render @model_set.collection without deleted elements
deleted = []
@collection = collection.to_a
collection.delete_if { |e| deleted << e if @delete_if.andand.call(e.attributes) }
collection.delete_if { |e| deleted << e if @delete_if&.call(e.attributes) }
deleted
end
def collection_to_keep
collection.reject { |e| @delete_if.andand.call(e.attributes) }
collection.reject { |e| @delete_if&.call(e.attributes) }
end
def persisted?

View File

@@ -22,7 +22,7 @@ module Shop
def apply_tag_rules!(order_cycles)
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor,
"FilterOrderCycles",
@customer.andand.tag_list)
@customer&.tag_list)
applicator.filter!(order_cycles)
order_cycles

View File

@@ -27,13 +27,13 @@ class UserDefaultAddressSetter
def set_bill_address_attributes(object, new_address)
object.update(
bill_address_attributes: new_address.merge('id' => object.bill_address.andand.id)
bill_address_attributes: new_address.merge('id' => object.bill_address&.id)
)
end
def set_ship_address_attributes(object, new_address)
object.update(
ship_address_attributes: new_address.merge('id' => object.ship_address.andand.id)
ship_address_attributes: new_address.merge('id' => object.ship_address&.id)
)
end
end

View File

@@ -10,6 +10,6 @@
- if spree_current_user.admin?
= f.hidden_field :owner_id,
class: "select2 fullwidth",
'user-select' => "{id:'#{@enterprise_group.owner.andand.id}', email:'#{@enterprise_group.owner.andand.email}'}"
'user-select' => "{id:'#{@enterprise_group.owner&.id}', email:'#{@enterprise_group.owner&.email}'}"
- else
= @enterprise_group.owner.andand.email
= @enterprise_group.owner&.email

View File

@@ -24,7 +24,7 @@
%tr
%td.name= enterprise_group.name
- if spree_current_user.admin?
%td= enterprise_group.owner.andand.email || ""
%td= enterprise_group.owner&.email || ""
%td= enterprise_group.on_front_page ? 'Y' : 'N'
%td= enterprise_group.enterprises.map(&:name).join ', '
%td.actions

View File

@@ -13,7 +13,7 @@
%div{'ofn-with-tip' => t('.owner_tip')}
%a= t('admin.whats_this')
.nine.columns.omega
- owner_email = @enterprise.andand.owner.andand.email || ""
- owner_email = @enterprise&.owner&.email || ""
= f.hidden_field :owner_id, class: "select2 fullwidth", 'user-select' => 'Enterprise.owner'
.row
.three.columns.alpha

View File

@@ -1,5 +1,5 @@
- owner_email = @enterprise.andand.owner.andand.email || ""
- full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise.andand.owner)
- owner_email = @enterprise&.owner&.email || ""
- full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise&.owner)
.row
.three.columns.alpha

View File

@@ -15,17 +15,27 @@
%link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"}
%link{href: font_path("OFN-v2.woff"), rel: "preload", as: "font", crossorigin: "anonymous"}
= stylesheet_link_tag "darkswarm/all"
= javascript_pack_tag "application"
= csrf_meta_tags
= stylesheet_link_tag "darkswarm/all", "data-turbo-track": "reload"
= javascript_pack_tag "application", "data-turbo-track": "reload"
%body{ class: body_classes, "body-scroll" => true , ng: { app: 'Darkswarm' }}
= render "layouts/shopfront_script" if @shopfront_layout
= render "layouts/bugsnag_js"
- if Spree::Config.stripe_connect_enabled
= render "shared/stripe_js"
= javascript_include_tag "darkswarm/all", "data-turbo-track": "reload"
= javascript_include_tag "web/all", "data-turbo-track": "reload"
= render "layouts/i18n_script"
= csrf_meta_tags
%meta{name: "turbo-cache-control", content: "no-cache"}
%body{ class: body_classes, "body-scroll": "true", "data-turbo": "false" }
/ [if lte IE 8]
= render partial: "shared/ie_warning"
= javascript_include_tag "iehack"
= render "layouts/shopfront_script" if @shopfront_layout
.off-canvas-wrap{ offcanvas: true }
.fixed.off-canvas-fixed
= render "shared/menu/menu" unless @hide_menu
@@ -38,16 +48,7 @@
#footer
%loading
= render "layouts/bugsnag_js"
- if Spree::Config.stripe_connect_enabled
= render "shared/stripe_js"
= javascript_include_tag "darkswarm/all"
= javascript_include_tag "web/all"
= render "layouts/i18n_script"
= yield :scripts
= inject_current_hub
= inject_current_user
= inject_rails_flash

View File

@@ -11,9 +11,12 @@
%link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"}
= stylesheet_link_tag "darkswarm/all"
= javascript_include_tag "darkswarm/all"
= javascript_pack_tag "application"
= csrf_meta_tags
%body.off-canvas{"ng-app" => "Darkswarm", style: "background-image: url(#{image_path('tile-wide.png')})" }
%body.off-canvas{ style: "background-image: url(#{image_path('tile-wide.png')})", "data-turbo": "false" }
/ [if lte IE 8]
= render partial: "shared/ie_warning"
= javascript_include_tag "iehack"
@@ -27,10 +30,7 @@
#footer
%loading
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''}"}
= javascript_include_tag "darkswarm/all"
= yield :scripts
= inject_current_user
= yield :injection_data

View File

@@ -0,0 +1,7 @@
#flashes
- if defined? flashes
- flashes.each do |type, msg|
%alert.animate-show{"data-controller": "flash"}
%div{type: "#{type}", class: "alert-box #{type == 'error' ? 'alert' : type}"}
%span= msg
%a.small.close{"data-action": "click->flash#close"} ×

View File

@@ -1,6 +1,9 @@
%div{'ng-controller' => 'CartDropdownCtrl'}
= render "shared/menu/large_menu"
%ofn-flash
= render partial: "shared/flashes"
= render "shared/menu/mobile_menu"
= render "shared/menu/offcanvas_menu"
= render "shared/menu/cart_sidebar"

View File

@@ -1,4 +1,4 @@
- distributor = @order.andand.distributor || current_distributor
- distributor = @order&.distributor || current_distributor
%navigation
%distributor.details.row

View File

@@ -1,4 +1,4 @@
- if (@order.andand.distributor || current_distributor) == current_distributor
- if (@order&.distributor || current_distributor) == current_distributor
- shop_tabs.each do |tab|
= render "shopping_shared/tabs/#{tab[:name]}"

View File

@@ -0,0 +1,4 @@
%checkout.row#checkout
.small-12.medium-12.columns
= render partial: "split_checkout/tabs"
= render partial: "split_checkout/form"

View File

@@ -2,5 +2,7 @@
= inject_saved_credit_cards
%div.checkout-step
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put do |f|
= render "split_checkout/#{checkout_step}", f: f
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put,
data: { remote: "true" } do |form|
= render "split_checkout/#{checkout_step}", f: form

View File

@@ -1,7 +1,7 @@
- content_for(:title) do
= t :checkout_title
.darkswarm.footer-pad
.darkswarm.footer-pad{"data-turbo": "true"}
- content_for :order_cycle_form do
%closing
= t :checkout_now
@@ -19,10 +19,6 @@
.sub-header.show-for-medium-down
= render partial: "shopping_shared/order_cycles"
%checkout.row
.small-12.medium-12.columns
= render partial: "split_checkout/tabs"
= render partial: "split_checkout/form"
= render partial: "checkout"
= render partial: "shared/footer"

View File

@@ -5,13 +5,13 @@
.alpha.six.columns
%p
%b= t('.distributor')
= @order.distributor.andand.name || t(:none)
%input{type: "hidden", id: "order_distributor_id", value: @order.distributor.andand.id}
= @order.distributor&.name || t(:none)
%input{type: "hidden", id: "order_distributor_id", value: @order.distributor&.id}
.omega.six.columns
%p
%b= t('.order_cycle')
= @order.order_cycle.andand.name || t(:none)
%input{type: "hidden", id: "order_order_cycle_id", value: @order.order_cycle.andand.id}
= @order.order_cycle&.name || t(:none)
%input{type: "hidden", id: "order_order_cycle_id", value: @order.order_cycle&.id}
- else
.alpha.six.columns
.field

View File

@@ -22,4 +22,7 @@
= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('actions.save'), :style => 'display: none'
= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('actions.cancel'), :style => 'display: none'
= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('actions.edit')
= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => t(:are_you_sure)}, :title => t('actions.delete')
= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => t('actions.delete')
= render 'spree/admin/shared/custom-alert'
= render 'spree/admin/shared/custom-confirm'

View File

@@ -15,7 +15,7 @@
%td{width: "10%" }
&nbsp;
%td{ :align => "right" }
%h4= @order.order_cycle.andand.name
%h4= @order.order_cycle&.name
%tr{ valign: "top" }
%td{ align: "left", colspan: 3 }
%strong= "#{t('.from')}: #{@order.distributor.name}"
@@ -35,14 +35,14 @@
%br
- if @order.bill_address
= @order.bill_address.full_name
- if @order.andand.customer.andand.code.present?
- if @order&.customer&.code.present?
%br
= "#{t('.code')}: #{@order.customer.code}"
%br
- if @order.bill_address
= @order.bill_address.full_address
%br
- if @order.andand.customer.andand.email.present?
- if @order&.customer&.email.present?
= "#{@order.customer.email},"
- if @order.bill_address
= "#{@order.bill_address.phone}"

View File

@@ -46,7 +46,7 @@
%br
- if @order.bill_address
%strong= @order.bill_address.full_name
- if @order.andand.customer.andand.code.present?
- if @order&.customer&.code.present?
%br
= "Code: #{@order.customer.code}"
%br

View File

@@ -40,7 +40,7 @@
%span.icon-user
= t "your_profil_live"
.list
%a.button.bottom{href: main_app.enterprise_shop_url(@enterprise), target: '_blank'}
%a.button.bottom{href: enterprise_url_selector(@enterprise), target: '_blank'}
= t "see"
= @enterprise.name
= t "live"

View File

@@ -13,7 +13,7 @@
placeholder: t(".enterprise_select_placeholder"),
data: 'shops', ng: { model: 'paymentMethod.preferred_enterprise_id' } }
- else
%strong= Enterprise.find_by(id: @payment_method).andand.name
%strong= Enterprise.find_by(id: @payment_method)&.name
#stripe-account-status{ ng: { show: "paymentMethod.preferred_enterprise_id" } }
.alert-box.warning{ ng: { hide: "stripe_account.status" } }

View File

@@ -1,11 +1,11 @@
= form_tag spree.users_and_enterprises_admin_reports_url do |f|
.row
.alpha.two.columns= label_tag nil, t(:report_enterprises)
.omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in].andand.split(",")), {class: "select2 fullwidth", multiple: true})
.omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in]&.split(",")), {class: "select2 fullwidth", multiple: true})
.row
.alpha.two.columns= label_tag nil, t(:report_users)
.omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in].andand.split(",")), {class: "select2 fullwidth", multiple: true})
.omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in]&.split(",")), {class: "select2 fullwidth", multiple: true})
-# Might need this later if we add different kinds of reports
-# .row

View File

@@ -0,0 +1,8 @@
#custom-alert.modal
.modal-content
.modal-title
%i.icon-warning-sign
.message
.action-buttons
%button.confirm
= t(:ok)

View File

@@ -0,0 +1,11 @@
#custom-confirm.modal
.modal-content
.modal-title
%i.icon-question-sign
.message
= t(:are_you_sure)
.action-buttons
%button.cancel
= t(:cancel)
%button.confirm.red
= t(:ok)

View File

@@ -1,17 +1,17 @@
- if @order.shipping_method.andand.delivery?
- if @order.shipping_method&.delivery?
/ Delivery details
%p.callout
%strong
- if @order.shipping_method.andand.name
- if @order.shipping_method&.name
#{@order.shipping_method.name.html_safe}
- else
= t :email_shipping_delivery_details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor)
- if @order.order_cycle&.pickup_time_for(@order.distributor)
%h4
= t :email_shipping_delivery_time
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description
- if @order.shipping_method&.description
%p
%em #{@order.shipping_method.description.html_safe}
%br &nbsp;
@@ -32,22 +32,22 @@
/ Collection details
%p.callout
%strong
- if @order.shipping_method.andand.name
- if @order.shipping_method&.name
#{@order.shipping_method.name.html_safe}
- else
= t :email_shipping_collection_details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor).present?
- if @order.order_cycle&.pickup_time_for(@order.distributor).present?
%h4
= t :email_shipping_collection_time
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description.present?
- if @order.shipping_method&.description.present?
%p
%em #{@order.shipping_method.description.html_safe}
%br &nbsp;
- if @order.order_cycle.andand.pickup_instructions_for(@order.distributor).present?
- if @order.order_cycle&.pickup_instructions_for(@order.distributor).present?
%p
%strong
= t :email_shipping_collection_instructions

View File

@@ -8,12 +8,12 @@
= render 'spree/shared/line_item_name', line_item: line_item
- if @insufficient_stock_lines.andand.include? line_item
- if @insufficient_stock_lines&.include? line_item
%span.out-of-stock
= variant.in_stock? ? t(".insufficient_stock", :on_hand => variant.on_hand) : t(".out_of_stock")
%br/
- if @unavailable_order_variants.andand.include? line_item.variant
- if @unavailable_order_variants&.include? line_item.variant
%span.out-of-stock
= t(".unavailable_item")
%br/

View File

@@ -12,7 +12,7 @@
- if order.changes_allowed?
.columns.show-for-medium-up.medium-3 &nbsp;
.columns.small-12.medium-3
= link_to main_app.cancel_order_path(@order), method: :put, :class => "button secondary expand", "confirm-link-click" => t('orders_confirm_cancel') do
= link_to main_app.cancel_order_path(@order), method: :put, class: "button secondary expand", "data-confirm": t('orders_confirm_cancel') do
%i.ofn-i_009-close
= t(:cancel_order)
.columns.small-12.medium-3

View File

@@ -29,7 +29,7 @@
= order.bill_address.phone
.columns.large-6
- if order.shipping_method.andand.require_ship_address
- if order.shipping_method&.require_ship_address
= render 'spree/shared/shipment_delivery_details', order: order
- else
= render 'spree/shared/shipment_pickup_details', order: order

View File

@@ -5,7 +5,7 @@
= t :order_delivery_time
%strong #{order.order_cycle.pickup_time_for(order.distributor)}
%p.text-small.text-skinny.pre-line
%em= order.shipping_method.description.andand.html_safe || ""
%em= order.shipping_method.description&.html_safe || ""
.order-summary.text-small
%strong
= t :order_delivery_address

View File

@@ -5,7 +5,7 @@
= t :order_pickup_time
%strong #{order.order_cycle.pickup_time_for(order.distributor)}
%p.text-small.text-skinny.pre-line
%em= order.shipping_method.description.andand.html_safe || ""
%em= order.shipping_method.description&.html_safe || ""
- if order.order_cycle.pickup_instructions_for(order.distributor).present?
%br

View File

@@ -21,4 +21,4 @@
%td.order6.text-right.brick
%a{"ng-href" => "{{::order.path}}" }= t('.edit')
%td.order7.show-for-large-up.text-right
= link_to t('.cancel'), "", method: :put, "ng-href" => "{{::order.cancel_path}}", "confirm-link-click" => t('orders_confirm_cancel')
= link_to t('.cancel'), "", method: :put, "ng-href": "{{::order.cancel_path}}", "data-confirm": t('orders_confirm_cancel')

View File

@@ -0,0 +1,20 @@
import { Controller } from "stimulus"
document.addEventListener('turbolinks:before-cache', () =>
document.getElementById('flash').remove()
)
export default class extends Controller {
connect() {
setTimeout(this.fadeout.bind(this), 3000)
}
fadeout() {
this.element.classList.add("animate-hide-500")
setTimeout(this.close.bind(this), 500)
}
close() {
this.element.remove()
}
}

Some files were not shown because too many files have changed in this diff Show More