-
Notifications
You must be signed in to change notification settings - Fork 43
fix: [DHIS2-21708] Org unit selector is expanded when form open if no org unit in top bar #4629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
henrikmv
wants to merge
23
commits into
master
Choose a base branch
from
hv/fix/DHIS2-21708_expanded-org-unit-selector
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
786eaf9
fix: add collapsed org unit selection components
henrikmv 33fc96e
fix: remove CollapsedOrgUnitSelectField component
henrikmv 0cffa0d
fix: (review) devin comment
henrikmv eaabf13
fix: (review) add collapsed property to organisation unit settings in…
henrikmv 739fa65
fix: remove collapsed property from organisation unit settings in var…
henrikmv 18cec80
fix: enhance SingleOrgUnitSelectField with debounced search input and…
henrikmv e4ce807
fix: update keyboard event handling to close menu only when open
henrikmv 3a8162f
fix: sonar qube
henrikmv ac8918c
fix: sonar qube final
henrikmv 06a03e9
fix: remove aria expanded attribute from organisation unit selector
henrikmv 1711476
fix: update click handling to open menu on trigger click
henrikmv 42b7747
fix: clean up styles
henrikmv 02d0b42
fix: update cypress organisation unit filter interaction in event and…
henrikmv a5d1eab
fix: update cypress organisation unit selection process in scheduling…
henrikmv 4b81008
Merge branch 'master' into hv/fix/DHIS2-21708_expanded-org-unit-selector
henrikmv b4e734c
Merge branch 'master' into hv/fix/DHIS2-21708_expanded-org-unit-selector
henrikmv 5376619
feat: add auto select functionality for single organization unit fields
henrikmv 18990d2
feat: add auto select option for single organisation unit fields
henrikmv 6887c72
feat: add fieldOptions prop and handle preselection in OrgUnitFilterM…
henrikmv aedde44
feat: enhance organization unit selection logic and state management
henrikmv 378e6b0
fix: revert pot
henrikmv ae103c3
fix. clean up
henrikmv 618a740
Merge branch 'master' into hv/fix/DHIS2-21708_expanded-org-unit-selector
henrikmv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
57 changes: 26 additions & 31 deletions
57
...odules/capture-core/components/FiltersForTypes/OrgUnit/OrgUnitFilterManager.component.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,35 @@ | ||
| import * as React from 'react'; | ||
| import React, { useState } from 'react'; | ||
| import { OrgUnitFilter as OrgUnitFilterInput } from './OrgUnitFilter.component'; | ||
| import { getEmptyValueFilterValue, isEmptyFilterData } from '../EmptyValue'; | ||
| import type { OrgUnitFilter, OrgUnitFilterManagerProps, Value } from './orgUnit.types'; | ||
|
|
||
| type State = { | ||
| value: Value; | ||
| }; | ||
|
|
||
| export class OrgUnitFilterManager extends React.Component<OrgUnitFilterManagerProps, State> { | ||
| static calculateDefaultState(filter: OrgUnitFilter | null | undefined): State { | ||
| if (!filter) return { value: undefined }; | ||
| if (isEmptyFilterData(filter)) return { value: getEmptyValueFilterValue(filter) }; | ||
| const calculateInitialValue = (filter: OrgUnitFilter | null | undefined): Value => { | ||
| if (!filter) return undefined; | ||
| if (isEmptyFilterData(filter)) return getEmptyValueFilterValue(filter); | ||
|
|
||
| const { value, name } = filter; | ||
| return { value: { id: value, name: name ?? value, path: '' } }; | ||
| } | ||
| const { value, name } = filter; | ||
| return { id: value, name: name ?? value, path: '' }; | ||
| }; | ||
|
|
||
| constructor(props: OrgUnitFilterManagerProps) { | ||
| super(props); | ||
| this.state = OrgUnitFilterManager.calculateDefaultState(this.props.filter); | ||
| } | ||
| export const OrgUnitFilterManager = ({ | ||
| filter, | ||
| filterTypeRef, | ||
| handleCommitValue, | ||
| ...passOnProps | ||
| }: OrgUnitFilterManagerProps) => { | ||
| const [value, setValue] = useState<Value>(() => calculateInitialValue(filter)); | ||
|
|
||
| handleCommitValue = (value: Value) => { | ||
| this.setState({ value }); | ||
| this.props.handleCommitValue?.(); | ||
| const onCommitValue = (newValue: Value) => { | ||
| setValue(newValue); | ||
| handleCommitValue?.(); | ||
| }; | ||
|
|
||
| render() { | ||
| const { filter, filterTypeRef, ...passOnProps } = this.props; | ||
| return ( | ||
| <OrgUnitFilterInput | ||
| value={this.state.value} | ||
| ref={filterTypeRef} | ||
| onCommitValue={this.handleCommitValue} | ||
| {...passOnProps} | ||
| /> | ||
| ); | ||
| } | ||
| } | ||
| return ( | ||
| <OrgUnitFilterInput | ||
| value={value} | ||
| ref={filterTypeRef} | ||
| onCommitValue={onCommitValue} | ||
| {...passOnProps} | ||
| /> | ||
| ); | ||
| }; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.