From: Raxel Gutierrez Date: Thu, 19 Aug 2021 04:20:23 +0000 (+0000) Subject: static: add rest.js to handle PATCH requests & respective responses X-Git-Tag: v3.1.0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a6304b51879115d15bff9723e59ba6a51958151;p=thirdparty%2Fpatchwork.git static: add rest.js to handle PATCH requests & respective responses Add `rest.js` file to have a utilities JavaScript module that can be reused by any Patchwork JS files that make requests to the REST API. The comments for each function follow the Google JS Style guide [1] which is something that would be nice to have for better documented frontend code, especially for JS modules that export functions like rest.js. In particular, this patch provides the following function: - `updateProperty`: make PATCH requests that partially update the fields of an object given it's REST API endpoint specified by the caller. Also, the caller can specify the field(s) to modify and the associated content for update messages in the case of both failed successful requests that render to the current webpage. The caller receives whether the request was successful or not. The `rest.js` module can be further expanded to support and provide functions that allow for other requests (e.g. GET, POST, PUT) to the REST API. Also, add functions that handle update & error messages for these PATCH requests that match the Django messages framework format and form error styling. These functions are internal to the module and aren't exposed outside of the `rest.js` file. Error and accompanying failed update messages are replaced by successful update messages and vice versa. Consecutive successful update messages add to a counter of updated objects. Consecutive error messages stack up. Signed-off-by: Raxel Gutierrez Reviewed-by: Daniel Axtens Reviewed-by: Stephen Finucane --- diff --git a/htdocs/README.rst b/htdocs/README.rst index 679bfcd9..d53619ad 100644 --- a/htdocs/README.rst +++ b/htdocs/README.rst @@ -122,6 +122,11 @@ js :GitHub: https://github.com/js-cookie/js-cookie/ :Version: 3.0.0 +``rest.js.`` + Utility module for REST API requests to be used by other Patchwork JS files. + + Part of Patchwork. + ``selectize.min.js`` Selectize is the hybrid of a ``textbox`` and ``