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

Fix for cards losing their values when in "dirty" state & adding back highlight #10581

Conversation

SDScandrettKint
Copy link
Member

@SDScandrettKint SDScandrettKint commented Feb 5, 2024

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description of Change

The main bug linked shows that some datatypes do not persist card data that is entered but not saved, a feature that almost all datatypes have. This bug is present for three datatypes: String, URL and Node Value.
This PR fixes all three (details on each fix below).

Issues Solved

Main issue: #10027
Datatype Issues: #10592 & #8451

Checklist

  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Ticket Background

Further comments

String dtype:
This bug was caused by the defaultValue of the string datatype being set to the i18n dictionary of language and value, causing the data entered in the string card to be reset by the empty default value dictionary. The change in this PR checks whether the active language value is an empty string, and if so then sets the default value as an empty string, allowing the data to persist once again.

URL dtype:
The values this.url and this.url_label are used in the front end HTM for the datatype, but the variable changed when entering data is this.value().url & url_label. The two were not visually synced, as navigating back and forth from the card would reset the UI (this.url & this.url_label) data but not the 'this.value().X' data. This fix updates the visual variables with what has been entered.
This PR also includes a fix for #10592 by raising an error if the URL label has been inputted without the URL itself.
It also includes a fix for #8451 by adding the url_label to the object with the value of an empty string.

Node Value dtype:
When a node value is selected and navigated from and to, the $(el).val() in select2-query is not retained unlike the other select widgets (concept, resource-instance etc). Similarly, the initSelection function within select2config id value was reset each time the node was navigated away from. Assigning the self.value() to the id allows data to be retained.

@SDScandrettKint SDScandrettKint changed the title Fix for i18n string cards losing their values when in "dirty" state & adding back highlight Fix for cards losing their values when in "dirty" state & adding back highlight Feb 8, 2024
@SDScandrettKint SDScandrettKint marked this pull request as ready for review February 27, 2024 23:35
@chiatt chiatt self-requested a review February 29, 2024 21:59
Copy link
Member

@chiatt chiatt left a comment

Choose a reason for hiding this comment

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

Because this PR addresses bugs, it needs to be made against 7.5 rather than 7.6. Ideally the fixes that resolve #8451 should go into a second PR to be merged into 6.2.x.

@SDScandrettKint
Copy link
Member Author

Replaced by #10642 for 7.5.x and #10643 for cherry picked commits into 6.2.x

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