stable
Clone or download
When we create a new section, we create it before another one, or at the end of the document. When we create it before another one, because of concurrent edition, the section may not exist anymore (the artifact may have been deleted, or the section may have been removed − not implemented yet). In that case we don't know what to do with the new section. First naive implementation was to put the new section at the beginning of the document. Pros: * The section is saved Cons: * There is no feedback to the user about the current situation * The section is marked as succesfully saved in the current position whereas it is not the right position * The user continue to work on a document that does not reflect its current state. This contribution changes the strategy by rejecting the save of the new section if the sibling section does not exist. The section is marked as error with an (hopefully) explicit message. It is up to the user to fix the situation. In the future we might improve a little bit the situation with the following algorithm: 1. get the next sibling 2. save the section before the sibling (or at the end if no sibling) 3. backend reject because sibling does not exist 4. front end detect this specific case (how?) 5. automatic removal of already deleted section in the current document 6. Go to 1. until success We would need to find a way to warn user about removed sections, and manage the fact that some of these sections was being edited by current user. 🤯 To test current contribution: Load a document with at least one section. In a new tab, go to the artifact of the section, copy its id, and delete it in the tracker administration. In the document that still contain the deleted section, create a new section just above it. The save should fail with an error message. Part of story #38288: add a new section Change-Id: Ib88bba7ad4527a20191d21348b1e4b7c3549ebce
Modified Files
Name | ||||
---|---|---|---|---|
M | plugins/artidoc/include/Artidoc/Document/ArtidocDao.php | +6 | −1 | Go to diff View file |
M | plugins/artidoc/include/Artidoc/Document/SaveOneSection.php | +2 | −0 | Go to diff View file |
A | plugins/artidoc/include/Artidoc/Document/Section/UnableToFindSiblingSectionException.php | +27 | −0 | Go to diff View file |
M | plugins/artidoc/include/Artidoc/REST/v1/ArtidocResource.php | +4 | −0 | Go to diff View file |
M | plugins/artidoc/include/Artidoc/REST/v1/POSTSectionHandler.php | +3 | −0 | Go to diff View file |
A | plugins/artidoc/include/Artidoc/REST/v1/UnableToFindSiblingSectionFault.php | +36 | −0 | Go to diff View file |
M | plugins/artidoc/scripts/artidoc/src/components/SectionFooter.vue | +1 | −2 | Go to diff View file |
M | plugins/artidoc/scripts/artidoc/src/composables/useEditorErrors.test.ts | +2 | −2 | Go to diff View file |
M | plugins/artidoc/scripts/artidoc/src/composables/useEditorErrors.ts | +5 | −5 | Go to diff View file |
M | plugins/artidoc/scripts/artidoc/src/helpers/stubs/SectionEditorStub.ts | +1 | −1 | Go to diff View file |
M | plugins/artidoc/site-content/fr_FR/LC_MESSAGES/tuleap-artidoc.po | +9 | −0 | Go to diff View file |
M | plugins/artidoc/tests/integration/Artidoc/Document/ArtidocDaoTest.php | +5 | −5 | Go to diff View file |
M | plugins/artidoc/tests/unit/Artidoc/REST/v1/POSTSectionHandlerTest.php | +43 | −0 | Go to diff View file |
M | plugins/artidoc/tests/unit/Artidoc/Stubs/Document/SaveOneSectionStub.php | +29 | −8 | Go to diff View file |