Commit Graph

35253 Commits

Author SHA1 Message Date
David Cook
2004934399 Register only necessary elements
This should be more efficient.

Best viewed with whitespace ignored.
2026-03-18 14:30:23 +11:00
David Cook
827ba1990d Ensure changes are tracked on newly added variant
I considered a few ways to do this. Cloned products are done with MutationObserver but it doesn't quite sit right with me. A dedicated controller for newly added rows would provide a good general solution. But do we want yet another controller? I'm not sure. This works and is pretty simple (although it requires a quick loop over _every_ form element.. let's see if we can avoid that.)
2026-03-18 14:03:11 +11:00
David Cook
18fb1cfa74 Rename variant 'owner' to 'hub'
As discussed by team, and using same nomenclature as VariantOverride.
2026-03-11 11:09:13 +11:00
David Cook
e9ce2df5a9 Rename 'source variant' to linked variant (in most places)
There are two types of linked variant associations: source and target, so we need to keep the name there.
But when cloning a variant and retaining a link as source,  we will prefer the general term 'linked variant'. Hopefully this name works well.
2026-03-11 11:09:13 +11:00
David Cook
c165ade4ba Avoid unnecessary save
Actually, the variant factory is still adding an extra save. We should refactor Variant to avoid that.. but the afternoon slump has got me.
2026-03-11 11:09:12 +11:00
David Cook
7e8b3694be Move class instance variable to helper 2026-03-11 11:09:12 +11:00
David Cook
6ee715419a ORder by ID to ensure deterministic results 2026-03-11 11:09:12 +11:00
David Cook
7da6adfe4f Use reference command
For uniformity

Co-authored-by: Maikel <maikel@email.org.au>
2026-03-11 11:09:12 +11:00
David Cook
05c31db46a Remove touch
I think I was just following convention from existing relationships. Perhaps you could argue that a variant is affected by the links added/removed.. but we never look at updated_at so really there's no point at all.
2026-03-11 11:09:12 +11:00
David Cook
666e872ac8 Revert uninentional schema change
I guess my local db is slightly out of sync.
2026-03-11 11:09:12 +11:00
David Cook
de6eb9e281 Avoid useless updated_at column
These records won't be updatable, but it might still be worth tracking when they were created.
2026-03-11 11:09:12 +11:00
David Cook
299ada1220 Refactor: move variant duplication to model
I tried to avoid it but rubocop made me move it. I think maybe it will need to go into a concern or service class later, but hopefully it's ok here for now.
2026-03-11 11:09:12 +11:00
David Cook
5757f086ec Set owner enterprise when creating source variant 2026-03-11 11:09:12 +11:00
David Cook
8955ffe126 AddOwnerToSpreeVariants [migration]
Should existing variants be migrated to have an owner (copied from supplier)? No, because you can change supplier. This concept needs work.
2026-03-11 11:09:09 +11:00
David Cook
b26152cf0e Only show option when you have permission
Preload the allow list once in the controller. This controller was initially set up to avoid instance variables, and pass variables explicitly to the template. That's a good principle, but in practice we have a growing list of variables passed down the chain to multiple partials which is getting cumbersome. I think instance variables have their place after all.
2026-03-11 11:08:50 +11:00
David Cook
78db179ff3 haml-lint:disable ViewLength
TIL we have linting on haml.

I couldn't think of a better way to handle this but would be glad to receive feedback.
2026-03-11 11:08:50 +11:00
David Cook
5fc6d25a69 Display presence of variant link in UI
It's quite ugly. But we will be iterating on this later.
2026-03-11 11:08:50 +11:00
David Cook
b877540f5f Create sourced variant link on clone 2026-03-11 11:08:50 +11:00
copilot-swe-agent[bot]
04c0adf960 Fix source_variants and target_variants associations in Variant model
Co-authored-by: dacook <4188088+dacook@users.noreply.github.com>

Thanks co-pilot for sending me in the right direction.
Would this be neater as a has_and_belongs_to_many? Maybe but I will try to keep moving.
2026-03-11 11:08:50 +11:00
David Cook
1c89e9979e CreateVariantLinks [migration]
Tried using the rails generator, but as usual it was a waste of time becuase it doesn't handle unusual cases.

I found more good guidance from that stackoverflow post:
> why are you worrying about your indexes? Build your app!

Something's not right in the model, see next commit.
2026-03-11 11:08:47 +11:00
David Cook
eba2fbcc30 Create source variants 2026-03-11 11:07:08 +11:00
David Cook
940aa57daf Set up permissions for creating source variants 2026-03-11 11:07:08 +11:00
David Cook
766bedb773 Label this feature as 'beta'
The permission is effectively the feature toggle. Users can choose to use it, but shouldn't expect it all to work perfectly yet.
When it's considered full featured, we just need to update the translation. Hm... I hope that's not too painful.🤞
2026-03-11 11:07:08 +11:00
David Cook
6fe2357ca0 Add enterprise permission create_sourced_variants 2026-03-11 11:07:08 +11:00
David Cook
bd01b5f113 Add 'create sourced variant' option in variant actions menu
For now, we will only be able to create sourced variant from variants that are visible to us (variants that we manage)

    In a later commit I will hide the option if you can't use it
2026-03-11 11:07:08 +11:00
David Cook
e565243ce4 Remove unnecessary before action
Each context has different setup and needs to load the page after setup.
2026-03-11 11:07:08 +11:00
David Cook
0f3b299544 Clean up spec
There's no "COPY OF" product in the spec setup, so we don't need to check that it's not there. (unless maybe we added that to the product factory, but it seems unlikely).

Also we can use helper method.
2026-03-11 11:07:08 +11:00
David Cook
1332051a6e Move specs to relevant file
These tests are about browsing products, not performing actions.

Well, ok there's one about updating, which should probably go in the update file. But hey this is better than before.
And admittedly the "Actions" file covers three different things, not just the actions menu. shrug.
2026-03-11 11:07:07 +11:00
Gaetan Craig-Riou
dff9d7ede6 Merge pull request #14009 from openfoodfoundation/dependabot/npm_and_yarn/postcss-8.5.8
Bump postcss from 8.5.6 to 8.5.8
2026-03-11 10:32:14 +11:00
Gaetan Craig-Riou
210303de90 Merge pull request #14011 from openfoodfoundation/dependabot/bundler/flipper-ui-1.4.0
Bump flipper-ui from 1.3.6 to 1.4.0
2026-03-11 10:30:56 +11:00
Gaetan Craig-Riou
7a0eee121d Merge pull request #14010 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.7.6
Bump @floating-ui/dom from 1.7.5 to 1.7.6
2026-03-11 10:24:43 +11:00
Gaetan Craig-Riou
9816332601 Update all locales with the latest Transifex translations v5.4.5 2026-03-10 22:15:29 +11:00
Gaetan Craig-Riou
4810b02233 Merge pull request #13702 from marincarroll/improve-accessibility-of-admin-pagination
Improve accessibility of admin pagination
2026-03-10 22:12:57 +11:00
Gaetan Craig-Riou
f8716f8005 Merge pull request #13963 from rioug/13855-payment-with-credit
Payment with credit
2026-03-10 22:11:40 +11:00
dependabot[bot]
8064154a86 Bump flipper-ui from 1.3.6 to 1.4.0
Bumps [flipper-ui](https://github.com/flippercloud/flipper) from 1.3.6 to 1.4.0.
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v1.3.6...v1.4.0)

---
updated-dependencies:
- dependency-name: flipper-ui
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 09:34:57 +00:00
dependabot[bot]
c3051ea351 Bump @floating-ui/dom from 1.7.5 to 1.7.6
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.7.5 to 1.7.6.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Changelog](https://github.com/floating-ui/floating-ui/blob/master/packages/dom/CHANGELOG.md)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.7.6/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-version: 1.7.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 09:33:40 +00:00
dependabot[bot]
c850feeab8 Bump postcss from 8.5.6 to 8.5.8
Bumps [postcss](https://github.com/postcss/postcss) from 8.5.6 to 8.5.8.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.5.6...8.5.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 09:33:21 +00:00
Gaetan Craig-Riou
5cf213f22a Fix failing spec 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
251a1acffc Clean up enterprise controller 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
d5dec05ab1 Remove payment method ApiCustomerCredit 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
7790259c27 Add transaction origin for internal credit payments 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
6a99d2a3c8 Add transaction origin in descriptiopn 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
e7a2b7ea48 Remove payment method from customer account transaction 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
bd0dcd99f3 Fix failing spec
I wrongly fixed it due to my local database having rogue data
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
bc23423521 Remove the link between enterprise and internal payment method
Enterprise have access to the internal payment method by default.
The access is handled at the application level so we don't have to
manage database links.
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
a4ca56c7a5 Refactored internal payment method
We now check on known payment method type, instead of using the internal
collumn.
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
9f7655852d Provide helper method to get internal payment method 2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
ec106a8f83 Add new payment method ApiCustomerCredit
It was previously modelled by a "Check" payment method
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
2e7237197a Refactor customer credit payment method
Set fixed name and description
2026-03-10 16:07:43 +11:00
Gaetan Craig-Riou
25c579c478 Per review, small code fixes 2026-03-10 16:07:43 +11:00