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

Language Change makes Conditional Panels Ineffective on Form #6039

Open
bronwyncombs opened this issue Jan 6, 2025 · 4 comments
Open

Language Change makes Conditional Panels Ineffective on Form #6039

bronwyncombs opened this issue Jan 6, 2025 · 4 comments
Labels
1 - Bug Incorrect behavior of the product 2 - Forms Issues that are related to the form system 2 - Preferences Issues that are related to preferences

Comments

@bronwyncombs
Copy link

Describe the bug
From Marion at MFN Berlin:

I noticed a problem with the form conditions, I think I found the cause of the problem but I can't be sure. When Specify 7 changes language, the form conditions are no longer recognized. For example, I created a form that displays certain fields depending on the agent type. This works very well when Specicfy 7 is in English but when used in German or French, the condition no longer works and therefore no longer displays the fields. Same problem for YesNo fields. If a condition is on a YesNo field, I suppose it is transformed into Ja Nein (in German) or Oui Non (in French) and therefore the condition is no longer recognized.
image
image
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://naturkundemuseum01062025-v7.test.specifysystems.org/specify in the Hymenoptera (recent) Collection
  2. View Agent and Preparation forms conditional behavior in English
  3. Change language at the top of Preferences
  4. See error

Expected behavior
changing language shouldn't cause conflict with form definition. Using new default XML strings instead of localized strings would allow the text to be written in English and function in all languages.

Screenshots
If applicable, add screenshots to help explain your problem.
Conditional Agent form in English:
Screenshot 2025-01-06 at 12 50 50 PM
Screenshot 2025-01-06 at 12 54 01 PM

Conditional Agent form in German:
Screenshot 2025-01-06 at 12 53 48 PM

"Person" is spelled the same and works in both languages, but the different spellings of other pick list items ("Group" and "Gruppe") cause conflict and don't render on the form.

Please fill out the following information manually:

Reported By
Marion at MFNB

@bronwyncombs bronwyncombs added 1 - Bug Incorrect behavior of the product 2 - Forms Issues that are related to the form system 2 - Preferences Issues that are related to preferences labels Jan 6, 2025
@maxpatiiuk
Copy link
Member

Ah! An oversight

Agent type, and a few other pick lists are defined on the front-end, rather than coming from the database - and the titles for such pick list items are coming from the localization, rather than database.

const agentTypes = [
formsText.organization(),
formsText.person(),
formsText.other(),
formsText.group(),
] as const;
const pickListTypes = [
formsText.userDefinedItems(),
formsText.entireTable(),
formsText.fieldFromTable(),
] as const;
const auditLogActions = [
commonText.create(),
commonText.update(),
commonText.delete(),
queryText.treeMerge(),
queryText.treeMove(),
queryText.treeSynonymize(),
queryText.treeDesynonymize(),
queryText.treeBulkMove(),
] as const;
const pickListSortTypes = f.store(() => [
commonText.none(),
getField(tables.PickListItem, 'title').label,
commonText.ordinal(),
]);

In conditional forms, the matching happens based on formatted values (title) rather than raw values (what's stored in the database - name or value), so it can depend on the language.

Possible solutions:

  • Allow defining conditional forms based on unformatted value (thus unlocalized). In practice, that means using agent type like 0 or 1 instead of Person/Organization
    • This would be more user friendly once we have full visual form editor
  • Don't localize front-end pick lists (not ideal)
  • Allow defining OR conditions, and then the conditional form can be displayed if the formatted value matched any language (simple solution, and gives us a new feature, but a bit ugly)

@Marion-MfN
Copy link

Thank you for your prompt response. Unfortunately I've been trying to apply the first and third solutions for the last hour without success. Can you show me an example of code to apply these multiple conditions? I have tried
<rows condition="agentType=Other or agentType=Andere or agentType=Autre">, <rows condition="agentType=Other" or condition="agentType=Andere" or condition="agentType=Autre"> and also <rows condition="agentType=0"> but then the script doesn't work at all.
I suppose I can also use AND or AND/OR at the same time but I can't find any examples of scripts on the Specify forum... Thank you in advance for your help.

@maxpatiiuk
Copy link
Member

maxpatiiuk commented Jan 10, 2025

I am sorry, I should have been more clear.
By possible solutions, I meant how Specify can fix this issue so that it doesn't happen for our users.
Until it is fixed, the closest you have to workaround is to duplicate the form definition for each translation:

<rows condition="agentType=Other"> ... </rows>
<rows condition="agentType=Andere"> ... </rows>
<rows condition="agentType= Autre"> ... </rows>

I know it is not ideal that you would have to duplicate the same form 2-3 times. I do not think an easier workaround is available for you until it is fixed on our side

@Marion-MfN
Copy link

Thank you for your time.
It's indeed not a very elegant solution, but it works. It's still not ideal for two reasons:

  1. if I have to change the code there's an increased risk of forgetting,
  2. it makes the word appear in English and not in the language the user is using and adds a message saying that the word (English) is an "invalid current value". It's a problem because most users will think it's a mistake when it's not, and I'll have to answer dozens of emails explaining that it's not a real problem.
    image
    Please let me know when the Specify team has corrected this oversight ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Bug Incorrect behavior of the product 2 - Forms Issues that are related to the form system 2 - Preferences Issues that are related to preferences
Projects
None yet
Development

No branches or pull requests

3 participants