Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Add edit form functionality #1333
Calling the operation "create" when it's "create or update" is smelly, as is the use of a boolean flag. How about using the "update" operation to change the form fields?
When the form fields are updated, the code should first check that the form is not in use and raise an error if it is. Similar to the check when archiving a form.
Good comments. I added another endpoint, /:form-id/edit for editing existing forms.
Using the existing "update" operation to change the form fields would have been problematic, as an identically-named operation is also in use for catalogue items, licenses, and resources, and they share the common parts. It seems therefore better to have a separate, form-specific edit operation.
I also marked as a TODO to change "update" to "update-state" in the future to avoid confusion with "edit".
I opted to just show the error if the user attemps to edit a form that is in use, and let the user explicitly press "Copy as new" (located next to "Edit" button, after all) if that is what the user wants. I think that doing that automatically risks guessing incorrectly what the user wants to do -- for example, it could be that the user is not expecting the form to be in use and after noticing that that is the case, decides to do something else.
But this can be discussed or changed further -- I believe that having it work analogously to "Archive" button, i.e., just showing the error if the operation is non-permitted, is a decent first step.
Thanks for the good comments, I think the patch is already a lot better now after this first review round.