-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: [DHIS2-17970] Auto-select orgUnit if there is only one available #3798
feat: [DHIS2-17970] Auto-select orgUnit if there is only one available #3798
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @henrikmv!
Some quick comments that you could look into, but you're on the right track 🏁
src/core_modules/capture-core/components/WidgetRelatedStages/WidgetRelatedStages.component.js
Outdated
Show resolved
Hide resolved
orgUnits: { | ||
resource: 'me', | ||
params: { | ||
fields: ['organisationUnits[id,path,displayName,children::isNotEmpty]'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might have misunderstood each other here - fetching orgunits through the /me
-endpoint does not necessarily filter the children array for whether you have access or not. Let's say a user only has access to the Bo
-orgunit. With this API-call, children would be present (true) as Bo does have a child. However, the user does not have access to this orgUnit.
When fetching through the /api/organisationUnits
-endpoint, there are filters to make sure you are searching for all orgunits withinUserScope
or withinUserSearchScope
. If this array is bigger than two, that means the user has more than two orgunits assigned.
params: { | ||
fields: 'id,path,displayName', | ||
withinUserSearchHierarchy: true, | ||
page: 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henrikmv what is the reason for adding page: 2
? I am not able to get the only available orgUnit with these parameters combination. It works if I remove it or use page:1
instead. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, it should have been pageSize
. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🚀 Deployed on https://deploy-preview-3798.capture.netlify.dhis2.org |
…/fix/DHIS2-17970_AutoSelectOrgunitWhenOnlyOneAvailable
import { useApiMetadataQuery } from '../../../utils/reactQueryHelpers'; | ||
|
||
export const useOrgUnitAutoSelect = (setRelatedStageDataValues: any) => { | ||
const queryKey = ['organisationUnits']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this hook is basically the same as the on in MetadataAutoSelectInitializer
. Could we perhaps combine them and reuse it? I feel pretty certain that this will be used in multiple places. Make a new hook called useOrgUnitsForAutoSelect
which returns isLoading
and an array of max 2 orgunits called orgUnits
.
Keep the useEffect outside of the hook, so that the behavior can be customized for whichever use-case needed. (In this case, move the useEffect into the WidgetRelatedStages.component.js
-file). Put the hook in the src/core_modules/capture-core/dataQueries
folder.
This reverts commit 9b97d2e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested successfully on 2.42,2.41.2,2.40.6,2.39.8 versions
# [101.11.0](v101.10.2...v101.11.0) (2024-10-14) ### Features * [DHIS2-17970] Auto-select orgUnit if there is only one available ([#3798](#3798)) ([de06f8b](de06f8b))
🎉 This PR is included in version 101.11.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
… WL (#3821) chore(release): cut 101.9.0 [skip release] * [DHIS2-15238] show and filter on assigned user in program stage WL ([#3821](#3821)) ([e032d50](e032d50)) fix(translations): sync translations from transifex (master) Automatically merged. chore(release): cut 101.9.1 [skip release] * **translations:** sync translations from transifex (master) ([2603f34](2603f34)) feat: [DHIS2-17771] Org unit context in tables and lists (#3813) * feat: update client to list converter * feat: changes in tooltip component * feat: add orgunit context stages and events widget * feat: use cache for subvalues * feat: orgunit context event workspace * fix: renaming of return statement chore(release): cut 101.10.0 [skip release] * [DHIS2-17771] Org unit context in tables and lists ([#3813](#3813)) ([b1a720a](b1a720a)) fix: [DHIS2-18028] User is able to add invalid related stages event (#3795) * fix: change logic for linkable events * fix: split up all and linkable events * chore: remove redundant filter chore(release): cut 101.10.1 [skip release] * [DHIS2-18028] User is able to add invalid related stages event ([#3795](#3795)) ([301585e](301585e)) test: cleanup after running NewPage tests (#3843) fix: cleanup after tests are run chore: [DHIS2-17915] remove opt-in functionality (#3796) fix: [DHIS2-18215] selected working list not persisted on navigate (#3838) * fix: persist working list on navigate * fix: allow navigate back despite displayFrontPageList * chore: review chore(release): cut 101.10.2 [skip release] * [DHIS2-18215] selected working list not persisted on navigate ([#3838](#3838)) ([599b2c1](599b2c1)) feat: [DHIS2-17970] Auto-select orgUnit if there is only one available (#3798) * feat: pre select * feat: review changes * fix: remove children check * fix: review change * feat: merge hooks for auto select * Revert "feat: merge hooks for auto select" This reverts commit 9b97d2e. * fix: review changes chore(release): cut 101.11.0 [skip release] * [DHIS2-17970] Auto-select orgUnit if there is only one available ([#3798](#3798)) ([de06f8b](de06f8b)) fix: [DHIS2-16993] Text and long text DEs are missing arrows in changelog when deleted (#3827) * fix: make arrow size static * fix: revert changes to text chore(release): cut 101.11.1 [skip release] * [DHIS2-16993] Text and long text DEs are missing arrows in changelog when deleted ([#3827](#3827)) ([5e6dfa6](5e6dfa6)) fix: [DHIS2-18056] use linkedEntityFormFoundation instead of the searchFormFoundation (#3835) chore(release): cut 101.11.2 [skip release] * [DHIS2-18056] use linkedEntityFormFoundation instead of the searchFormFoundation ([#3835](#3835)) ([cbfe70b](cbfe70b)) feat: [DHIS2-17956] Display name for org unit in changelog (#3826) * feat: update client to list converter * feat: changes in tooltip component * feat: add orgunit context stages and events widget * feat: use cache for subvalues * feat: orgunit context event workspace * fix: renaming of return statement * feat: display name for orgunit * fix: merge conflict * fix: improve flow type chore(release): cut 101.12.0 [skip release] * [DHIS2-17956] Display name for org unit in changelog ([#3826](#3826)) ([5299f37](5299f37)) fix: [DHIS2-17978] use title instead of alt on missing icons (#3847) * fix: use title instead of alt on missing icons * chore: fix failing tests chore(release): cut 101.12.1 [skip release] * [DHIS2-17978] use title instead of alt on missing icons ([#3847](#3847)) ([b5940f2](b5940f2)) fix(translations): sync translations from transifex (master) Automatically merged. chore(release): cut 101.12.2 [skip release] * **translations:** sync translations from transifex (master) ([9bf7696](9bf7696)) feat: [DHIS2-17991] Show orgUnit selector in Enter details now (#3824) * feat: add org unit selector * feat: select org unit for linked event * feat: add validation feat: [DHIS2-16992] Fixed size for changelog modal and columns (#3834) * feat: temp * feat: fixed size table and columns * fix: remove console log * fix: fixed size improvement chore(release): cut 101.13.0 [skip release] * [DHIS2-16992] Fixed size for changelog modal and columns ([#3834](#3834)) ([3b021cf](3b021cf)) * [DHIS2-17991] Show orgUnit selector in Enter details now ([#3824](#3824)) ([bf2f1ca](bf2f1ca)) feat: [DHIS2-17792] Org unit context in forms (#3828) * feat: update client to list converter * feat: changes in tooltip component * feat: add orgunit context stages and events widget * feat: use cache for subvalues * feat: orgunit context event workspace * fix: renaming of return statement * feat: add org unit context to forms * fix: translation * fix: cy tests breakes after translation fix * fix: cy tests chore(release): cut 101.14.0 [skip release] * [DHIS2-17792] Org unit context in forms ([#3828](#3828)) ([c8ccf63](c8ccf63)) fix: [DHIS2-16010] app crashes on invalid programid (#3765) * fix: app crash on invalid programid * fix: app stuck in loading state when url has invalid enrollmentId or teiId * fix: useProgramInfo hook breaks the app chore(release): cut 101.14.1 [skip release] * [DHIS2-16010] app crashes on invalid programid ([#3765](#3765)) ([9133a63](9133a63)) fix(translations): sync translations from transifex (master) Automatically merged. chore(release): cut 101.14.2 [skip release] * **translations:** sync translations from transifex (master) ([57a7b83](57a7b83)) docs: improve docs (#3865) fix: [DHIS2-17843] Disable delete enrollment button when user does not have authority (#3859) * fix: string adjustment * fix: disable button and add tooltip * fix: revert wrong commit * fix: create generic authorities hook chore(release): cut 101.14.3 [skip release] * [DHIS2-17843] Disable delete enrollment button when user does not have authority ([#3859](#3859)) ([edee6d3](edee6d3)) fix: [DHIS2-18228] Image Deleted on Update (#3857) * fix: image deleted on update * fix: remove call to fileresources chore(release): cut 101.14.4 [skip release] * [DHIS2-18228] Image Deleted on Update ([#3857](#3857)) ([4656864](4656864)) fix: [DHIS2-18248] pass on createdAt to rules engine when editing (#3848)
… WL (#3821) chore(release): cut 101.9.0 [skip release] * [DHIS2-15238] show and filter on assigned user in program stage WL ([#3821](#3821)) ([e032d50](e032d50)) fix(translations): sync translations from transifex (master) Automatically merged. chore(release): cut 101.9.1 [skip release] * **translations:** sync translations from transifex (master) ([2603f34](2603f34)) feat: [DHIS2-17771] Org unit context in tables and lists (#3813) * feat: update client to list converter * feat: changes in tooltip component * feat: add orgunit context stages and events widget * feat: use cache for subvalues * feat: orgunit context event workspace * fix: renaming of return statement chore(release): cut 101.10.0 [skip release] * [DHIS2-17771] Org unit context in tables and lists ([#3813](#3813)) ([b1a720a](b1a720a)) fix: [DHIS2-18028] User is able to add invalid related stages event (#3795) * fix: change logic for linkable events * fix: split up all and linkable events * chore: remove redundant filter chore(release): cut 101.10.1 [skip release] * [DHIS2-18028] User is able to add invalid related stages event ([#3795](#3795)) ([301585e](301585e)) test: cleanup after running NewPage tests (#3843) fix: cleanup after tests are run chore: [DHIS2-17915] remove opt-in functionality (#3796) fix: [DHIS2-18215] selected working list not persisted on navigate (#3838) * fix: persist working list on navigate * fix: allow navigate back despite displayFrontPageList * chore: review chore(release): cut 101.10.2 [skip release] * [DHIS2-18215] selected working list not persisted on navigate ([#3838](#3838)) ([599b2c1](599b2c1)) feat: [DHIS2-17970] Auto-select orgUnit if there is only one available (#3798) * feat: pre select * feat: review changes * fix: remove children check * fix: review change * feat: merge hooks for auto select * Revert "feat: merge hooks for auto select" This reverts commit 9b97d2e. * fix: review changes chore(release): cut 101.11.0 [skip release] * [DHIS2-17970] Auto-select orgUnit if there is only one available ([#3798](#3798)) ([de06f8b](de06f8b)) fix: [DHIS2-16993] Text and long text DEs are missing arrows in changelog when deleted (#3827) * fix: make arrow size static * fix: revert changes to text chore(release): cut 101.11.1 [skip release] * [DHIS2-16993] Text and long text DEs are missing arrows in changelog when deleted ([#3827](#3827)) ([5e6dfa6](5e6dfa6)) fix: [DHIS2-18056] use linkedEntityFormFoundation instead of the searchFormFoundation (#3835) chore(release): cut 101.11.2 [skip release] * [DHIS2-18056] use linkedEntityFormFoundation instead of the searchFormFoundation ([#3835](#3835)) ([cbfe70b](cbfe70b)) feat: [DHIS2-17956] Display name for org unit in changelog (#3826) * feat: update client to list converter * feat: changes in tooltip component * feat: add orgunit context stages and events widget * feat: use cache for subvalues * feat: orgunit context event workspace * fix: renaming of return statement * feat: display name for orgunit * fix: merge conflict * fix: improve flow type chore(release): cut 101.12.0 [skip release] * [DHIS2-17956] Display name for org unit in changelog ([#3826](#3826)) ([5299f37](5299f37)) fix: [DHIS2-17978] use title instead of alt on missing icons (#3847) * fix: use title instead of alt on missing icons * chore: fix failing tests chore(release): cut 101.12.1 [skip release] * [DHIS2-17978] use title instead of alt on missing icons ([#3847](#3847)) ([b5940f2](b5940f2)) fix(translations): sync translations from transifex (master) Automatically merged. chore(release): cut 101.12.2 [skip release] * **translations:** sync translations from transifex (master) ([9bf7696](9bf7696)) feat: [DHIS2-17991] Show orgUnit selector in Enter details now (#3824) * feat: add org unit selector * feat: select org unit for linked event * feat: add validation feat: [DHIS2-16992] Fixed size for changelog modal and columns (#3834) * feat: temp * feat: fixed size table and columns * fix: remove console log * fix: fixed size improvement chore(release): cut 101.13.0 [skip release] * [DHIS2-16992] Fixed size for changelog modal and columns ([#3834](#3834)) ([3b021cf](3b021cf)) * [DHIS2-17991] Show orgUnit selector in Enter details now ([#3824](#3824)) ([bf2f1ca](bf2f1ca)) feat: [DHIS2-17792] Org unit context in forms (#3828) * feat: update client to list converter * feat: changes in tooltip component * feat: add orgunit context stages and events widget * feat: use cache for subvalues * feat: orgunit context event workspace * fix: renaming of return statement * feat: add org unit context to forms * fix: translation * fix: cy tests breakes after translation fix * fix: cy tests chore(release): cut 101.14.0 [skip release] * [DHIS2-17792] Org unit context in forms ([#3828](#3828)) ([c8ccf63](c8ccf63)) fix: [DHIS2-16010] app crashes on invalid programid (#3765) * fix: app crash on invalid programid * fix: app stuck in loading state when url has invalid enrollmentId or teiId * fix: useProgramInfo hook breaks the app chore(release): cut 101.14.1 [skip release] * [DHIS2-16010] app crashes on invalid programid ([#3765](#3765)) ([9133a63](9133a63)) fix(translations): sync translations from transifex (master) Automatically merged. chore(release): cut 101.14.2 [skip release] * **translations:** sync translations from transifex (master) ([57a7b83](57a7b83)) docs: improve docs (#3865) fix: [DHIS2-17843] Disable delete enrollment button when user does not have authority (#3859) * fix: string adjustment * fix: disable button and add tooltip * fix: revert wrong commit * fix: create generic authorities hook chore(release): cut 101.14.3 [skip release] * [DHIS2-17843] Disable delete enrollment button when user does not have authority ([#3859](#3859)) ([edee6d3](edee6d3)) fix: [DHIS2-18228] Image Deleted on Update (#3857) * fix: image deleted on update * fix: remove call to fileresources chore(release): cut 101.14.4 [skip release] * [DHIS2-18228] Image Deleted on Update ([#3857](#3857)) ([4656864](4656864)) fix: [DHIS2-18248] pass on createdAt to rules engine when editing (#3848)
DHIS2-17970
organisationUnits
resource