fix(growers): resolve org not set filter not applying in grower module - #1229
Open
yasiru98 wants to merge 1 commit into
Open
fix(growers): resolve org not set filter not applying in grower module#1229yasiru98 wants to merge 1 commit into
yasiru98 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SelectOrg.js,handleChangeonly searchedorgListwhich only includes real orgs loaded from the API when looking up the selected org object. "Not set" is a hardcoded option indefaultOrgList, not a real org, so it was never found. This causedhandleSelectionto be called with the raw string'ORGANIZATION_NOT_SET'instead of the object. The filter callback inFilterTopGrower.jstried to read.idoff that string, gotundefined, and the filter was lost before it reached the API.defaultOrgListandorgListinSelectOrg.jsso "Not set" is correctly resolved to its object and passed through the filter chain, resulting inorganizationId: nullin the API call.EditGrower.jsto explicitly convertORGANIZATION_NOT_SETtonullwhen saving, preserving the correct behaviour of unsetting a grower's organization via the edit.Issue(s) addressed
What kind of change(s) does this PR introduce?
Please check if the PR fulfils these requirements
Issue
What is the current behavior?
Selecting "Not set" in the Organization filter on the Growers page sends an API call identical to "All".
organizationIdis absent from the where clause, so all growers are returned regardless of whether they have an org assigned.Editing a grower and setting their organization to "Not set" incorrectly sent the string
'ORGANIZATION_NOT_SET'to the API instead ofnull, which would fail to unset the org.What is the new behavior?
Selecting "Not set" in the filter sends
"organizationId": nullin the API where clause, returning only growers with no organization assigned.Editing a grower and setting their organization to "Not set" now correctly sends
organizationId: nullto the API, unsetting the org as expected.Breaking change
Does this PR introduce a breaking change?
No.
Other useful information
Root cause:
SelectOrg.jssearched onlyorgList(API-loaded orgs) inhandleChange, missing the hardcoded "Not set" entry indefaultOrgList. When not found, the fallback passed the raw string'ORGANIZATION_NOT_SET'to the callback. Callers expecting an object called.idon a string gotundefined, which is dropped byJSON.stringify, leaving no org filter in the API call.The
EditGrower.jsfix is required because that component needsnullsent directly to the API to unset an org, whereas filter components use'ORGANIZATION_NOT_SET'as a sentinel for the filter model.