-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: date field to format date before displaying, org unit filters #456
Conversation
✅ Deploy Preview for dhis2-maintenance-app-beta ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
017a11b
to
66383ef
Compare
69364f2
to
c521cad
Compare
c521cad
to
d1be798
Compare
<IdentifiableFilter /> | ||
<div className={css.filterWrapper}> | ||
<IdentifiableFilter /> | ||
<DynamicFilters /> |
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.
Do we actually want additional filters for orgunits? It does make it a bit weird. eg. if we had a filter to filter on a certain level - how do we display the tree?
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.
ah that's a good point. Probably not right? prob best to remove filters from public view all together?
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.
ok @Birkbjo i just removed the filter tabs all together
@@ -10,7 +10,8 @@ export function OrganisationUnitSelector() { | |||
const fieldName = 'parent' | |||
const { input, meta } = useField(fieldName, { format: (value) => value }) | |||
const userRootOrgUnits = useCurrentUserRootOrgUnits() | |||
const userRootOrgUnitsIds = userRootOrgUnits.map((unit) => `/${unit.id}`) | |||
const userRootOrgUnitsIds = userRootOrgUnits.map((unit) => `${unit.id}`) | |||
const userRootOrgUnitsPaths = userRootOrgUnits.map((unit) => `/${unit.id}`) |
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.
This only works if the root is on level one. We need the path. But if this is just for initiallyExpanded
, I think we can just use the first lowest level root. If you had multiple roots on level 1 - you probably dont want to expand both?
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.
you need for expanded right. The main point of this change was to send ids without /
in front to OrganisationUnitTree roots. But for expanded, i am actually not sure what we should use if there is nothing selected. What do you think? we can also decide to leave everything collapsed?
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.
fixed the paths
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 in general we just want to expand the first root?
}) | ||
|
||
const { input, meta } = useField<string | undefined>(name) | ||
|
||
useEffect(() => { | ||
if (input.value) { | ||
const dateWithNoTimestamp = input.value.substring(0, 10) |
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.
Why is this an useEffect
and not done in handleChange
below? Is it because we just want this on the initial value when editing?
Eg. the server will give us date with timestamp, but the Calendar-component does not?
I think we also could use format
and/or parse
in useField
.
const { input, meta } = useField<string | undefined>(name, {
format: (value) => value && value.substring(0,10),
})
This would strip the timezone from "input.value", but wouldn't touch whats in the formState
. But I think that should be fine, if the calendar-component gives us the right string?
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.
yes it is because we only want it to work for the initial value (not only, it's ok if we rerun it every time, but handleChange does not run without an event occurring). Tried with format before, but the calendar library gives a validation error because of the format on the value, so users would need to touch the field before pressing save. Not sure if you have other ideas on how to achieve this? (i'm removing the onblur, i don't think that's needed )
df1beda
to
8e49e88
Compare
@@ -47,7 +54,7 @@ export function DateField({ | |||
validationText: i18n.t('Required'), | |||
}) | |||
} else { | |||
setValidation(payload?.validation || { error: false }) | |||
setValidation(payload?.validation || { error: false, valid: true }) | |||
} | |||
input.onChange(payload?.calendarDateString || '') | |||
input.onBlur() |
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.
Cant select the line below, but I think this:
valid={validation?.valid && input?.value !== ''}
should also check for undefined? Right now you will get a "Check" next to the field if it's undefined. Or is this intentional?
We could also format undefined to ''
though.
eg:
format: (value) =>
value ? value.substring(0, 10) : '',
d822c50
to
4b334da
Compare
src/lib/form/modelFormSchemas.ts
Outdated
@@ -37,12 +37,15 @@ const style = z.object({ | |||
icon: z.string().optional(), | |||
}) | |||
|
|||
const dateWithoutTimestampSchema = z.coerce.date() |
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.
To be pedantic, this is now just a date schema, right? It doesn't actually do what the variable name says. In that case we would want something like:
const dateWithoutTimestampSchema = z
.string()
.transform((v) => v.substring(0, 10))
.pipe(z.string().date()),
4b334da
to
75d59ad
Compare
75d59ad
to
cee7f4a
Compare
src/pages/organisationUnits/Edit.tsx
Outdated
@@ -67,7 +71,7 @@ export const Component = () => { | |||
})} | |||
section={section} | |||
initialValues={orgUnit.data} | |||
validate={validate} | |||
schema={organisationUnitSchema} |
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.
Guess this is a remnant from trying the FormBase2
?
cee7f4a
to
c76fde1
Compare
c76fde1
to
d11d229
Compare
## [0.19.2](v0.19.1...v0.19.2) (2024-12-05) ### Bug Fixes * date field to format date before displaying, org unit filters ([#456](#456)) ([8537bce](8537bce)) * refresh list view on close of dialog ([#461](#461)) ([c10d79f](c10d79f)) * **categoryCombo:** validation and load optionSize on initial load [skip release] ([#457](#457)) ([a1a6110](a1a6110)) * **categoryOption:** load formName [skip release] ([#458](#458)) ([bb3baee](bb3baee)) * **categoryOptionGroups:** add custom attributesection to group/groupset [skip release] ([#459](#459)) ([5c853bc](5c853bc))
🎉 This PR is included in version 0.19.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.