Overview
For this hypothesis we will build a copy-paste feature so that, when editing an object in the Wikifunctions Default UI (particularly when creating or editing composition implementations or tests), a user should be able to copy a block so that they can reuse it in other parts of the object.
Main use cases
use case 1: wrap an existing function call with another one
In order to debug my composition, I would like to use the "Add debug to function call/Z854" function wrapping an existing complex composition.
To do this without discarding the existing composition, I would like to do:
- select the function call that I want to wrap and choose "copy"
- now edit the function call and select "Add debug..." function
- for the first argument of the "Add debug..." function, select "paste" option
- navigate the clipboard and choose the block I copied before
- copy the block and publish it safely, knowing that I've not altered it in any way
use case 2: reuse an existing implementation to build another one
I want to build a new declension table following the same construction as the "build whole table" implementation for "German noun declension table": https://www.wikifunctions.org/view/en/Z28604
To do this successfully without having to replicate one by one every single function call, I would like to do:
- in the original composition (edit), click on the menu beside "composition" and click "copy"
- in a new tab (or the same one) create a new implementation for my function, and select composition
- click on the menu beside "composition" and click "paste"
- navigate the clipboard and choose the block I copied before
- make any changes needed to adapt this composition to my use case
- publish it safely
Additional information
Decisions and Assumptions
These are some assumptions and decisions made while building the initial POC. As such, they can be either sustained or challenged.
- The copy/paste feature will be displayed in the options menu (marked with an ellipsis icon) on the right side of every key. This menu contains options to modify the shape of its value, and to perform other contextual actions such as moving the item up/down a list or deleting the item from it. This menu appears only in "edit" mode, which means that it will not be possible to "copy" the blocks in "read" mode.
- The block is displayed in the clipboard using the ZObjectToString component, which renders an inline view of the value.
- The blocks are either valid or not valid for copying into the selected key. This depends on whether the type of the block matches the expected type for the key. This is signaled inside the clipboard with a disabled (grey background) state and a disabled action (it cannot be selected).
| only the first block is enabled for pasting | the first and third block are enabled, the second is disabled |
- The copied blocks are stored along with the name of the key they originally belonged to. In case the value for the key is copied twice (or two keys have identical label), an index number is added to the name.
- Additionally to the block "name" and the block value, we also display the type of the value (top right corner of each clipboard block), to enrich the information available to the user.
Challenges
challenge 1: The copied block can be extremely complex and large
In situations like the one described for use case 2, the block copied to the clipboard is very complex. This makes it difficult to navigate through all items stored in the clipboard, identify them and select them successfully.
Acceptance criteria
Create a viable design proposal for the clipboard dialog so that editors can navigate, understand and successfully choose the block they want to paste in a given slot
Completion checklist
Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Design_task_completion_checklist



