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

feat(form): add (auto)save and local schema repo #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miguelgrc
Copy link
Collaborator

@miguelgrc miguelgrc commented Sep 25, 2024

Closes #84
Related cernanalysispreservation/analysispreservation.cern.ch#2897

  • Adds an autosave feature (into localStorage as formuleCurrent). When reloading the page or closing and opening the browser the last state will be loaded automatically
  • Adds the following features in a floating menu in formule-demo:
    • Manual save: with a ctrl+s shortcut as well (into localStorage as formuleForm_<formid>). It shows a badge when there are unsaved changes
    • Load schemas: new drawer listing all the schemas currently stored in localStorage, lets you delete, download and upload schemas
    • Revert: reverts unsaved changes
    • New schema: starts a new schema from scratch
    • View schema: the existing schema viewer has been moved into here
  • Although this menu is exclusive for the demo, the logic of the saving/loading features mentioned above has been implemented and exported from formule as functions so they can be used in any project.
  • The form key is now displayed in the SchemaPreview. It can be disabled with hideSchemaKey.
  • The process of initializing the form has been simplified, now it's not needed to call initFormuleSchema() in a useEffect on first render anymore (you can still do it on demand or if you want to load an existing form).

Note: When loading a schema which contains an object field the demo can crash, requiring a reload. This will be worked on in #88

@@ -73,7 +74,9 @@ const ObjectFieldTemplate = ({
card.prop = properties[index];
});
}
setCards(newCards);
if (!isEqual(newCards, cards)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets not change for now, since it is breaking some things

Copy link
Collaborator Author

@miguelgrc miguelgrc Nov 18, 2024

Choose a reason for hiding this comment

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

I have reverted this change. The consequence is that now when loading an existing schema which contains an object field it will error out and you will need to refresh to get the schema loaded. Better to have it run like this for now instead of breaking the sorting and cause the issues mentioned in #88

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.

add (auto)save
2 participants