Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
On 07/10/2014 12:31 PM, Hongliang Wang wrote:
Mock model will return a task with "finished" state
immediately when the user
generates a report, though the generate window will disappear only when there
is a task with "running" returned so it will never disappear.
Fixed it in this patch.
Signed-off-by: Hongliang Wang <hlwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.report_add_main.js | 39 ++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/ui/js/src/kimchi.report_add_main.js b/ui/js/src/kimchi.report_add_main.js
index f64b879..0388041 100644
--- a/ui/js/src/kimchi.report_add_main.js
+++ b/ui/js/src/kimchi.report_add_main.js
@@ -48,11 +48,31 @@ kimchi.report_add_main = function() {
}
var formData = addReportForm.serializeObject();
var taskAccepted = false;
+ var onTaskAccepted = function() {
+ if(taskAccepted) {
+ return;
+ }
+ taskAccepted = true;
+ kimchi.window.close();
+ var reportName = nameTextbox.val() || i18n['KCHDR6012M'];
+ $('.grid-body-view table tbody', '#' +
reportGridID).prepend(
+ '<tr>' +
+ '<td>' +
+ '<div class="cell-text-wrapper">' +
reportName + '</div>' +
+ '</td>' +
+ '<td id ="id-debug-img">' +
+ '<div class="cell-text-wrapper">' +
i18n['KCHDR6007M'] + '</div>' +
+ '</td>' +
+ '</tr>'
+ );
+ };
+
disableToolbarButtons();
submitButton.prop('disabled', true);
$('.grid-body table tr', '#' + reportGridID)
.on('click', disableToolbarButtons);
kimchi.createReport(formData, function(result) {
+ onTaskAccepted();
$('.grid-body-view table tr:first-child', '#' +
reportGridID).remove();
$('.grid-body table tr', '#' + reportGridID)
.off('click', disableToolbarButtons);
@@ -78,24 +98,7 @@ kimchi.report_add_main = function() {
generateButton.prop('disabled', false);
submitButton.prop('disabled', false);
nameTextbox.select();
- }, function(result) {
- if(taskAccepted) {
- return;
- }
- taskAccepted = true;
- kimchi.window.close();
- var reportName = nameTextbox.val() || i18n['KCHDR6012M'];
- $('.grid-body-view table tbody', '#' +
reportGridID).prepend(
- '<tr>' +
- '<td>' +
- '<div class="cell-text-wrapper">' +
reportName + '</div>' +
- '</td>' +
- '<td id ="id-debug-img">' +
- '<div class="cell-text-wrapper">' +
i18n['KCHDR6007M'] + '</div>' +
- '</td>' +
- '</tr>'
- );
- });
+ }, onTaskAccepted);
event.preventDefault();
};