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

Datetime formats - app ui #1607

Merged
merged 19 commits into from
Oct 22, 2024
Merged

Datetime formats - app ui #1607

merged 19 commits into from
Oct 22, 2024

Conversation

XingY
Copy link
Contributor

@XingY XingY commented Oct 15, 2024

Rationale

Support choosing from a set of standard date/time formats for Application Setting and domain fields.

Related Pull Requests

Changes

  • Add utils for handling standard date/time formats
  • Move getFolderDateTimeHelpBody from ContainerLookAndFeelForm to shared util
  • Check blank initial value for SelectInput
  • Modified DateTimeFieldOptions to use standard formats and new UI

# Conflicts:
#	packages/components/package-lock.json
#	packages/components/package.json
# Conflicts:
#	packages/components/package.json
@XingY XingY requested a review from cnathe October 15, 2024 14:38
@XingY XingY changed the title Fb datetime formats Datetime formats - app ui Oct 15, 2024
### version 5.X
*Released*: X October 2024
- Date/Time formatting simplifications - Settings UI Changes
- TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

reminder to add this info before merging

const { onChange } = this.props;

let value = evt.target.value;
export const getInitDateTimeSetting = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I only see one usage of this function in this file. Does it need to be exported?

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 was planning to add jest test for it

Comment on lines 38 to 39
isDate: boolean,
isTime: boolean,
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like the usages for this is using the type: 'dateTime' | 'date' | 'time' type to determine these booleans. Could that type just be passed through instead and used directly?

case DateFormatType.DateTime:
settingName = 'Date Times';
parentFormat = formats.dateTimeFormat;
currentFormat = inherited ? parentFormat : fieldFormat;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: it looks like all three of the cases set this the same. it could be moved to a const above the switch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because each depend on the actual value of parentFormat , they cannot be moved out of the switch.

inherited: checked,
};
if (checked) {
const parentFormat = prevSetting.parentFormat;
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this behavior in the app where you see the parent format when you check to use default. This is different then the LKS behavior that just disables the inputs but keeps their current value (which may or may not match the parent format).

(name: string, selectedValue: string, selectedOption: SelectInputOption): void => {
onFormatChange(selectedOption?.value, true);
},
[domainFieldId, onChange]
Copy link
Contributor

Choose a reason for hiding this comment

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

same question here about the domainFieldId usage in the dependency array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<div className="col-xs-9">
<input
checked={setting.inherited}
onChange={onToggleInherited}
Copy link
Contributor

Choose a reason for hiding this comment

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

in quick testing locally, it looks like changing the use default checkbox state isn't enough to put the page into a dirty state. maybe that is intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}

export function splitDateTimeFormat(dateTimeFormat: string): string[] {
if (dateTimeFormat.indexOf(' h') > -0 || dateTimeFormat.indexOf(' H') > -0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why the negative 0 in the check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wow that must been added by lint


export function isStandardDateTimeDisplayFormat(dateTimeFormat: string): boolean {
if (!dateTimeFormat) return false;
const parts = splitDateTimeFormat(dateTimeFormat.trim());
Copy link
Contributor

Choose a reason for hiding this comment

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

should the trim() here just move into the splitDateTimeFormat?

Comment on lines 241 to 242
To control how a {contentLabel} value is displayed, provide a string format compatible with the Java{' '}
<JavaDocsLink urlSuffix="java/text/SimpleDateFormat.html">SimpleDateFormat</JavaDocsLink> class.
Copy link
Contributor

Choose a reason for hiding this comment

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

as mentioned in chat, we should update this as the user isn't "providing" a string (more like "selecting"). Also, no need to refer to the JavaDocs anymore so can probably drop that part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

# Conflicts:
#	packages/components/package-lock.json
#	packages/components/package.json
#	packages/components/releaseNotes/components.md
# Conflicts:
#	biologics/package-lock.json
#	biologics/package.json
#	inventory/package-lock.json
#	inventory/package.json
#	sampleManagement/package-lock.json
#	sampleManagement/package.json
# Conflicts:
#	packages/components/package-lock.json
#	packages/components/package.json
#	packages/components/releaseNotes/components.md
# Conflicts:
#	packages/components/package-lock.json
#	packages/components/package.json
#	packages/components/releaseNotes/components.md
#	packages/components/src/index.ts
@XingY XingY merged commit f2ec5f2 into develop Oct 22, 2024
1 check passed
@XingY XingY deleted the fb_datetime_formats branch October 22, 2024 19:37
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