Add confirm dialog remove item VC

This commit is contained in:
Daniel Barbero 2020-01-22 13:00:19 +01:00
parent 69e750da13
commit f3dbf6391f
1 changed files with 39 additions and 33 deletions

View File

@ -1,5 +1,5 @@
// TODO: Add Artica ST header.
/* globals jQuery, VisualConsole, AsyncTaskManager, tinymce */
/* globals jQuery, VisualConsole, AsyncTaskManager, confirmDialog */
/*
* *********************
@ -460,43 +460,49 @@ function createVisualConsole(
var aux = item;
var id = item.props.id;
item.remove();
confirmDialog({
title: "Delete",
message: "Are you sure?",
onAccept: function() {
item.remove();
var taskId = "visual-console-item-update-" + id;
var taskId = "visual-console-item-update-" + id;
asyncTaskManager
.add(taskId, function(done) {
var abortable = removeVisualConsoleItem(
baseUrl,
visualConsole.props.id,
id,
function(error, data) {
if (error || !data) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
asyncTaskManager
.add(taskId, function(done) {
var abortable = removeVisualConsoleItem(
baseUrl,
visualConsole.props.id,
id,
function(error, data) {
if (error || !data) {
console.log(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",
"[API]",
error ? error.message : "Invalid response"
);
// Add the item to the list.
var itemRetrieved = aux.props;
itemRetrieved["receivedAt"] = new Date();
var newItem = visualConsole.addElement(itemRetrieved);
newItem.setMeta({ editMode: true });
}
// Add the item to the list.
var itemRetrieved = aux.props;
itemRetrieved["receivedAt"] = new Date();
var newItem = visualConsole.addElement(itemRetrieved);
newItem.setMeta({ editMode: true });
}
done();
}
);
done();
}
);
return {
cancel: function() {
abortable.abort();
}
};
})
.init();
return {
cancel: function() {
abortable.abort();
}
};
})
.init();
}
});
},
copyItem: function(item) {
var id = item.props.id;