Fix for cards losing their values when in "dirty" state & adding back highlight #10581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
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
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
andthis.url_label
are used in the front end HTM for the datatype, but the variable changed when entering data isthis.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()
inselect2-query
is not retained unlike the other select widgets (concept, resource-instance etc). Similarly, theinitSelection
function withinselect2config
id value was reset each time the node was navigated away from. Assigning theself.value()
to the id allows data to be retained.