Page MenuHomePhabricator

Support item management for arrays
Closed, ResolvedPublic8 Estimated Story Points

Description

In T360445 a design is proposed to add support for adding and removing elements from arrays. This task is to make an initial implementation of that design and support this feature.

control for collections (2).png (977×984 px, 25 KB)

Design specification for nested fields: Codex constructing forms docs

Acceptance criteria

  • Collection item fields are wrapped in a box, T364846
  • Using multi-column fields to save vertical space and improve the double enumeration.
  • Add a trash button inside each module, clicking on it removes the element
  • Add a button to 'Add another (collection element)', clicking on it adds an empty item

Open questions

  • Should all arrays have management? If not, how should an schema opt-in/opt-out from having management
  • Should we add support json-schema's minItems, maxItems vocabulary and let it configure the bahviour of the management (see docs) as part of this task?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1042329 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/CommunityConfiguration@master] [WIP]: Add array management

https://gerrit.wikimedia.org/r/1042329

Change #1047480 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/GrowthExperiments@master] i18n: Add message for "Add another link" button in the CommConf help panel section

https://gerrit.wikimedia.org/r/1047480

Change #1047480 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] i18n: Add message for "Add another link" button in the CommConf help panel section

https://gerrit.wikimedia.org/r/1047480

Change #1042329 merged by jenkins-bot:

[mediawiki/extensions/CommunityConfiguration@master] Add array management

https://gerrit.wikimedia.org/r/1042329

Can be tested on https://en.wikipedia.beta.wmflabs.org/wiki/Special:CommunityConfiguration/HelpPanel

Once the change Allow no more than 10 specific help-links has been merged, then it can also be tested that no more than 10 links can be added. (though that is not strictly part of this task)

Tested in beta, currently a user can hit the "Add another link" as many times as they want and save empty objects. The "emptiness" of the object seems related to T358659 and not in scope of this task. However, from a UX pov, maybe the array control management should limit the number of "empty fields" to one? Seems also related to T358659 but different in the sense that we need to compute what is an empty/untouched/clean field rather than what is an empty field. Thoughts?

Tested in beta, currently a user can hit the "Add another link" as many times as they want and save empty objects. The "emptiness" of the object seems related to T358659 and not in scope of this task. However, from a UX pov, maybe the array control management should limit the number of "empty fields" to one? Seems also related to T358659 but different in the sense that we need to compute what is an empty/untouched/clean field rather than what is an empty field. Thoughts?

On the one hand, I agree it might be nice to limit that. On the other hand, this creates surprising number of follow-up questions that do not have one single obvious answer: Should we also limit the number of empty fields when the existing empty field is not the last one? That is, what about the circumstance when the second of 5 existing links has its values removed (not deleted!) and then the user wants to click the "add another link" button?
Also, if we disallow it, what exactly are we going to do? Disable the button until the user has entered _something_ in the existing fields? That needs to be a UX decision.
Also, figuring out what exactly constitutes "empty fields" in full generality is not a trivial challenge.

That being said, all of these could be resolved by making the fields required. Then the user cannot submit empty fields, but rather has to either fill in something or delete the unfilled element. Though that then again is T358659.

In conclusion: I'd be happy to improve array management further, but would suggest not doing that in context of this task. For this task, we should stick to the AC as written.

Etonkovidova subscribed.

Checked on testwiki wmf.11 and on arwiki wmf.11 - works as expected. It's possible to save an item with a blank label which would be displayed on Special:Homepage as an empty bullet point, but it should be in the scope of a different task if needed.