[pve-devel] [PATCH widget-toolkit 1/1] add callback for window.edit

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Apr 25 14:19:32 CEST 2018


On 4/25/18 11:41 AM, Dominik Csapak wrote:
> we sometimes want/need to do something when the api call
> finished and need to know whether it was successful or need the result
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  window/Edit.js | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/window/Edit.js b/window/Edit.js
> index 9548e21..4b9b5bf 100644
> --- a/window/Edit.js
> +++ b/window/Edit.js
> @@ -44,6 +44,10 @@ Ext.define('Proxmox.window.Edit', {
>      // the task finished. function(success)
>      taskDone: Ext.emptyFn,
>  
> +    // gets called when the api call is finished, right at the beginning
> +    // function(success, response, options)
> +    callback: Ext.emptyFn,
> +

callback is to generic for such a complex component,
which bundles quite a few things and configs.

apiCallDone (not ideal but it isn't to long and more expressive)
(other, better, suggestions/ideas are naturally welcome).

We almost always see that this is a function when looking at an user
(it points to an (often anonymous) function), so it's more important
to get the info when this CB gets triggered when reading an edit
window declaration.

looks good besides this name issue.

>      // assign a reference from docs, to add a help button docked to the
>      // bottom of the window. If undefined we magically fall back to the
>      // onlineHelp of our first item, if set.
> @@ -130,6 +134,8 @@ Ext.define('Proxmox.window.Edit', {
>  	    method: me.method || (me.backgroundDelay ? 'POST' : 'PUT'),
>  	    params: values,
>  	    failure: function(response, options) {
> +		me.callback(false, response, options);
> +
>  		if (response.result && response.result.errors) {
>  		    form.markInvalid(response.result.errors);
>  		}
> @@ -139,6 +145,8 @@ Ext.define('Proxmox.window.Edit', {
>  		var hasProgressBar = (me.backgroundDelay || me.showProgress || me.showTaskViewer) &&
>  		    response.result.data ? true : false;
>  
> +		me.callback(true, response, options);
> +
>  		if (hasProgressBar) {
>  		    // stay around so we can trigger our close events
>  		    // when background action is completed
> 





More information about the pve-devel mailing list