From 08c752f1b399930144e97ce2fcce92c8294b7706 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 26 Mar 2017 18:10:26 -0300 Subject: [PATCH] Simplify addcost management --- kfet/templates/kfet/kpsul.html | 37 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 75665f95..3a33bb42 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -795,27 +795,26 @@ $(document).ready(function() { } } - var addcostDialog = new UserDialog({ - 'title': 'Majoration', - 'content': '', - 'callback_as_dict': true, - }); function askAddcost(errors = '') { - addcostDialog.open( - function(data) { - api_with_auth({ - url: Urls['kfet.kpsul.update_addcost'](), - data: data, - on_400: function(data) { - askAddcost(getErrorsHtml(data)); - }, - next_focus: kpsul.account_manager, - }); - }, - errors, - kpsul.account_manager - ); + var addcostDialog = new UserDialog({ + 'title': 'Majoration', + 'content': '', + 'callback_as_dict': true, + }); + + function callback(data) { + api_with_auth({ + url: Urls['kfet.kpsul.update_addcost'](), + data: data, + on_400: function(data) { + askAddcost(getErrorsHtml(data)); + }, + next_focus: kpsul.account_manager, + }); + } + + addcostDialog.open(callback, errors, kpsul.account_manager); }