Skip to content

Add feature to save turnip data from JSON to the manager - #2

Open
patrikhillner wants to merge 6 commits into
Pingviinituutti:mainfrom
patrikhillner:paste-json-to-manager
Open

Add feature to save turnip data from JSON to the manager#2
patrikhillner wants to merge 6 commits into
Pingviinituutti:mainfrom
patrikhillner:paste-json-to-manager

Conversation

@patrikhillner

Copy link
Copy Markdown
Contributor

Also add feature usage instructions to index page

Also add feature usage instructions to index page
@patrikhillner

Copy link
Copy Markdown
Contributor Author

Still needs to update a variable name: checked -> autoUpdateJson

@patrikhillner
patrikhillner marked this pull request as draft July 2, 2021 15:18
* Refactor checked and setChecked to jsonAutoUpdate and setJsonAutoUpdate respectively. This is to improve clarity on what it does.
* Remove redundant semi-colon.
@patrikhillner
patrikhillner marked this pull request as ready for review July 2, 2021 18:52
Also set jsonAutoUpdate state to be tracked in TurnipPriceStore.
@Pingviinituutti

Pingviinituutti commented Jul 5, 2021

Copy link
Copy Markdown
Owner

Updating the JSON does not work? For example, changi the textarea value to [] does nothing.

@patrikhillner

Copy link
Copy Markdown
Contributor Author

This PR adds feature to fill blank spaces with data. Saving does not overwrite all data, so it works as it should.

JSON text area did not update automatically when ticked. This was due to the fact that jsonAutoUpdate variable did not extend the observable property that the similarly named variable in the store did. This commit fixes that by directly using the variable (through reference) of the store and updating only that through the method in the store.
If user had removed a price through the TurnipPriceDialog, and then wanted to add a price through the JSON text area for the same (morning/afternoon) date, then stored price was `NaN`. This caused undefined and null checks to return false, thus not saving the new price.
Since calendar tiles do not directly use the same objects as in turnips list in the turnip store, the calendar tiles did not update when saving JSON text area and null prices were set to a non-null value. Add check to see if the tile needs to update its turnip.
Existing TurnipPriceStore functions refresh turnip objects in TurnipPriceDialog when turnip list in store is updated, causing the object to re-render and do the check.
@patrikhillner

Copy link
Copy Markdown
Contributor Author

Final issues of this PR have been fixed:

  • Issue: JSON text area updating only when ticking checkbox.
  • Add isNaN check for stored price when saving JSON text area content.
  • Issue: Calendar tiles with null values did not update after saving JSON text area containing data for respective tiles.

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