[PATCH v3 1/1] static: add rest.js to handle PATCH requests & respective responses

Stephen Finucane stephen at that.guru
Fri Aug 20 03:52:57 AEST 2021


On Thu, 2021-08-19 at 04:20 +0000, Raxel Gutierrez wrote:
> 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 <raxel at google.com>
> Reviewed-by: Daniel Axtens <dja at axtens.net>

All my issues are resolved and Daniel's happy

Reviewed-by: Stephen Finucane <stephen at that.guru>

and applied.

Thanks!



More information about the Patchwork mailing list