Skip to content
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

FIO-7184 Fixed showing incorrect value for DateTime and Time componen… #5393

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

antonSoftensity
Copy link
Contributor

…ts with multiple value enabled inside of the DataTable

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-7184

Description

Previously, DateTime and Time components didn't have support for multiple values inside of getValueAsString methods, which caused an error when the value was formatted by moment library. Added a case to format each value one by one.

How has this PR been tested?

Tested locally

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

…ts with multiple value enabled inside of the DataTable
@@ -203,6 +203,9 @@ export default class DateTimeComponent extends Input {
format += format.match(/z$/) ? '' : ' z';
const timezone = this.timezone;
if (value && !this.attached && timezone) {
if (Array.isArray(value) && this.component.multiple) {
return value.map((item) => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
}
return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
}
return (value ? _.trim(moment(value).format(format)) : value) || '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if timezone is undefined and component is multiple? The line 207 is skipped and we go to line 211 that does not expect array value.
It also would be nice to separate repeated code in some new method. I mean lines 207 and 209. The same is for Time component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that the repeated code should be separated in that case, because it is specific for that particular function.

@TanyaGashtold TanyaGashtold merged commit 492cdfa into master Nov 23, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants