As a follow-up from T401405, we should use the wbparsevalue API before sending the value to wbeditentity. This way, the API can already normalize the value (specifically: trim whitespace); this, in turn, lets us detect if the value was actually changed or not. (TODO: Task needs polishing.)
Specifically:
- the “statement being edited” store (T405723) should primarily contain the values in a form that can be directly bound to the text inputs, i.e. not yet in parsed data value form
- separately, there should be a store (cache?) of parsed data values (property ID → string input → Promise for parsed response); when the user types into the input, we send out the wbparsevalue request and put it in this store
- the publish button should be enabled if the parsed data value store contains resolved responses for all the currently used text inputs (and at that point we can then also check if it’s actually different from the currently saved value in the statementsStore, and disable the button if the user’s input results in no change to the saved value, e.g. only adding surrounding whitespace)
- publishing the edit pulls the corresponding parsed data values out of that cache (for the main value, qualifiers, and references) and then assembles the entity in the format we send to wbeditentity
A WIP patch for this has some more useful comments.
Question for UX: How should the user interface behave while it’s waiting for the wbparsevalue API request to respond? And also, what should happen if the value wasn’t actually changed (e.g. the user just added a space at the end)? The desktop UI always disables the “publish” button until the value has finished parsing and is known to be different from the previous value. (There have been occasional complaints about this slowing down editors. I suspect a lot of editors, yours truly included, at this point have some deeply ingrained muscle memory for waiting a moment between entering a value and pressing Enter to save it.)
Answer: The publish button will remain greyed out until it has been parsed by the server
This is blocked by: T405723
Acceptance Criteria
- The publish button will remain greyed out until it has been parsed by the server
- When adding spaces to an existing value the publish button will remain greyed out