== Use cases ==
* [add] When I am adding a new statement, it should be possible to add an arbitrary number of new references by clicking the "add reference" button. Newly added references get saved when the "save" button for the statement is clicked.
* [edit] When I am editing an existing statement, I want to be able to edit all related references as well. All changes made to the references will be saved when the "save" button for the statement is clicked.
* [remove] When I am editing an existing statement that has references I want to be able to remove an arbitrary number of existing references from this statement by clicking an "remove" button which is placed in the heading of each reference. Removing individual reference snaks from a particular reference is done by clicking the "remove" button just beside the snak as it is working right now. All changes made to the references will only be saved once the "save" button for the statement is clicked.
* [error handling] Changes to the statement will only be saved successful when all data including the references is valid. Otherwise an error is shown just as it works right now for invalid qualifiers or main snaks.
{F1910542}
{F1910539}
{F1910537}
== Tasks ==
Possible as non-breaking changes:
* [x] [Task] When adding/editing a statement the reference section (with the expander and the "wikibase-addreference" button) should be there
* [x] [Task] When adding a statement the reference section should be expanded by default
* ~~[ ] [RFC] The expander should not be there when editing a statement and it's references. Just remove it. The reference section should not be collapsible.~~
* [ ] [Task] The referenceview must work (everything except saving) with no statement GUID T115972
* [ ] [Task] Add new bool parameter "editReferencesAlongWithStatement" to referenceview to disable save+cancel
* [ ] [Task] Referenceview must *not* trigger any API request when clicking [remove]
* [ ] [Task] When editReferencesAlongWithStatementis set, the referenceview should display a [remove] button when creating a new reference, not [cancel]
* [ ] [Task] The referenceview must bubble up "change" events to the statementview
All these need to be deployed together, otherwise the UI will be broken:
* [ ] [Task] When checking if a statement is edited (a.k.a. not "equal"), it must consider the references
* [x] [Task] The statementview must trigger saving edited references, when editReferencesAlongWithStatement is set
* [ ] [Task] Reference section must switch to edit mode when statement switches to edit mode
* [ ] [RFC] Possibly, from here it does not make sense to have editReferencesAlongWithStatement for backwards-compatibility
* [x] [Task] Statementview can save all references in it's own wbsetclaim API request instead of triggering wbsetreference
* [x] [Task] Reference views must switch back to non-edit mode when statementview's saving is done