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

Handle pasted data types #989

Closed
wants to merge 15 commits into from
Closed

Handle pasted data types #989

wants to merge 15 commits into from

Conversation

AdrianaCeric
Copy link
Contributor

@AdrianaCeric AdrianaCeric commented Oct 5, 2023

Checklist

  • Appropriate branch selected (all PRs must first be merged to dev before they can be merged to master)
  • Any modified or new methods or classes have helpful JSDoc and code is thoroughly commented
  • The description lists all applicable issues this PR seeks to resolve
  • The description lists any configuration setting(s) that differ from the default settings
  • All tests and CI builds passing

Description

  • Enhances data handling when pasting content from the clipboard, such as CSV data, into TEXT type timetable cells (e.g., Trip ID, Trip Headsign). Previously, the data was returned as seconds, which an issue
    image
  • Improves the handling of carriage return characters that may appear when pasting data from Excel so parseCellValue can parse the correct string inTIMETABLE_FORMATS
  • Checks if the parsed value is valid and keeps the original value of the timetable cell instead of returning 00:00:00 for:
    • pasted CSV
    • inputted data in individual cells

Copy link
Contributor

@philip-cline philip-cline left a comment

Choose a reason for hiding this comment

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

Code looks really good, thanks for the update! One thing we could do if you're up for it is to validate the user's input and reject it rather than setting the time to 00:00:00 on invalid input in the time columns.

@AdrianaCeric
Copy link
Contributor Author

AdrianaCeric commented Oct 16, 2023

I need to do $FlowFixMe instead

Copy link
Contributor

@philip-cline philip-cline left a comment

Choose a reason for hiding this comment

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

Couple of small comments and the behaviour saving the current contents when invalid time formats are entered doesn't seem to be working for me.

lib/editor/util/timetable.js Outdated Show resolved Hide resolved
lib/editor/util/timetable.js Outdated Show resolved Hide resolved
lib/editor/components/timetable/TimetableGrid.js Outdated Show resolved Hide resolved
Copy link
Contributor

@philip-cline philip-cline left a comment

Choose a reason for hiding this comment

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

Works well for me! Thanks for the update

Copy link
Contributor

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

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

Great work! Lots of good cleanup! Just a little bit more

beginEditing () {
const {columnIndex, rowIndex, setActiveCell} = this.props
const beginEditing = () => {
const {columnIndex, rowIndex, setActiveCell} = props
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these variables defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The console was mad when I didn't define the variables since I switched everything to a functonal component

lib/editor/components/timetable/EditableCell.js Outdated Show resolved Hide resolved
clearTimeout(alertTimeout)
if (isTimeFormat(col.type)) {
if (!parsedDate.isValid()) {
alertTimeout = setTimeout(() => alert('Please enter a valid time format'), 600)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we wait to alert the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prevented an issue where the alert would show twice, I can make the timeout shorter

Copy link
Contributor

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

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

See my changes for a fix following this PR's approach to solving this problem, but it sounds like @philip-cline might have an alternate solution cooking

daniel-heppner-ibigroup

This comment was marked as resolved.

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.

4 participants