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

unnullifyTranslations() assumes translated cannot change #2821

Open
jnm opened this issue Oct 5, 2020 · 1 comment
Open

unnullifyTranslations() assumes translated cannot change #2821

jnm opened this issue Oct 5, 2020 · 1 comment
Labels
bug Things broken and not working as expected UI & UX User interface problems and improvements

Comments

@jnm
Copy link
Member

jnm commented Oct 5, 2020

Consider that we have a form with one named language, French (fr), and only labels—no hints:

{
    "schema": "1",
    "survey": [
        {
            "type": "integer",
            "$kuid": "kv4jl55",
            "label": [
                "Au contraire!"
            ],
            "required": false,
            "$autoname": "Au_contraire"
        }
    ],
    "settings": {
        "default_language": "French (fr)"
    },
    "translated": [
        "label"
    ],
    "translations": [
        "French (fr)"
    ]
}

If we open this in the form builder, add a hint ("My brother"), and save it:

  1. unnullifyTranslations() will see that translated in the asset content contains only label;
  2. It will change label to label::French (fr), but it will not alter hint;
  3. The front end will PATCH the asset with this content:
    {
        "settings": [
            {
                "default_language": "French (fr)"
            }
        ],
        "survey": [
            {
                "$autoname": "Au_contraire",
                "$kuid": "kv4jl55",
                "hint": "My brother",
                "label::French (fr)": "Au contraire!",
                "required": "false",
                "type": "integer"
            }
        ]
    }
  4. The back end (formpack) will now treat the form as having two translations: null (from the bare hint) and French (fr):
    {
        "schema": "1",
        "survey": [
            {
                "hint": [
                    null,
                    "My brother"
                ],
                "type": "integer",
                "$kuid": "kv4jl55",
                "label": [
                    "Au contraire!",
                    null
                ],
                "required": false,
                "$autoname": "Au_contraire"
            }
        ],
        "settings": {
            "default_language": "French (fr)"
        },
        "translated": [
            "hint",
            "label"
        ],
        "translations": [
            "French (fr)",
            null
        ]
    }

What should happen? unnullifyTranslations() must recognize that changes made by the form builder can cause translated to become invalid. We should probably use a constant list of translatable columns when unnullifying a translation.

@jnm jnm added bug Things broken and not working as expected UI & UX User interface problems and improvements labels Oct 5, 2020
@tinok
Copy link
Member

tinok commented Jun 2, 2021

@jnm @magicznyleszek I just ran into this same issue on my end (added a hint to a form that had no previous hints) and noticed that the formbuilder can't be used after refreshing or reopening the form. Is this new or what you had experienced?

Should this be a separate issue?

image

I made a quick video in case it's helpful.
https://user-images.githubusercontent.com/673511/120410565-370f0380-c321-11eb-9865-17667eed820c.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things broken and not working as expected UI & UX User interface problems and improvements
Projects
None yet
Development

No branches or pull requests

2 participants