1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Feature #4317: Delete recursive is now a confirm dialog with 2 options

This commit is contained in:
Carlos Martín 2016-03-01 16:52:42 +01:00
parent 5e31b9b73a
commit ba0156af1c
3 changed files with 77 additions and 14 deletions

View File

@ -27,6 +27,7 @@ define(function(require) {
var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId');
var INSTANTIATE_DIALOG_ID = require('./form-panels/instantiate/formPanelId');
var IMPORT_DIALOG_ID = require('./form-panels/import/formPanelId');
var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId');
var XML_ROOT = "VMTEMPLATE"
var RESOURCE = "Template"
@ -39,6 +40,35 @@ define(function(require) {
"Template.refresh" : _commonActions.refresh(),
"Template.delete" : _commonActions.del(),
"Template.delete_dialog":
{
type: "custom",
call: function() {
Sunstone.getDialog(CONFIRM_DIALOG_ID).setParams({
//header :
body : Locale.tr("This will delete the Template.<br/>You can also delete any Image referenced inside this Template"),
//question :
buttons : [
Locale.tr("Delete all images"),
Locale.tr("Delete"),
],
submit : [
function(){
Sunstone.runAction('Template.delete_recursive', Sunstone.getDataTable(TAB_ID).elements());
return false;
},
function(){
Sunstone.runAction('Template.delete', Sunstone.getDataTable(TAB_ID).elements());
return false;
}
]
});
Sunstone.getDialog(CONFIRM_DIALOG_ID).reset();
Sunstone.getDialog(CONFIRM_DIALOG_ID).show();
}
},
"Template.delete_recursive":
{
type: "multiple",

View File

@ -67,24 +67,18 @@ define(function(require) {
type: "confirm",
layout: "main",
text: Locale.tr("Share"),
tip: Locale.tr("The template, along with any image defined in DISK/IMAGE_ID, will be shared with the group's users. Images defined by name are not affected. Permission changed: GROUP USE"),
tip: Locale.tr("The template, along with any image referenced by it, will be shared with the group's users. Permission changed: GROUP USE"),
},
"Template.unshare" : {
type: "confirm",
layout: "main",
text: Locale.tr("Unshare"),
tip: Locale.tr("The template, along with any image defined in DISK/IMAGE_ID, will be unshared with the group's users. Images defined by name are not affected. Permission changed: GROUP USE"),
tip: Locale.tr("The template, along with any image referenced by it, will be unshared with the group's users. Permission changed: GROUP USE"),
},
"Template.delete" : {
type: "confirm",
text: Locale.tr("Delete"),
layout: "vmsdelete_buttons"
},
"Template.delete_recursive" : {
type: "confirm",
text: Locale.tr('Delete <span class="label secondary radius">recursive</span>'),
tip: Locale.tr("The template will be deleted, along with any image defined in DISK/IMAGE_ID. Images defined by name are not affected"),
layout: "vmsdelete_buttons"
"Template.delete_dialog" : {
type: "action",
layout: "del",
text: Locale.tr("Delete")
}
};

View File

@ -62,25 +62,54 @@ define(function(require) {
* - params.header : Optional, html string
* - params.body : Optional, html string
* - params.question : Optional, html string
* - params.buttons : Optional, html string for the button.
* Can be an array for multiple options
* - params.submit : Mandatory, function to call if user confirms
* If buttons is an array, it must be an array
* of the same size
*/
function _setParams(params) {
this.params = params;
if (this.params.buttons != undefined){
if (!$.isArray(this.params.buttons)){
this.params.buttons = [this.params.buttons];
}
if (this.params.submit != undefined){
if (!$.isArray(this.params.submit)){
this.params.submit = [this.params.submit];
}
}
}
}
function _setup(context) {
var that = this;
$('#' + DIALOG_ID + 'Form', context).submit(function() {
$('#' + DIALOG_ID + 'Form', context).submit(function(e) {
if (that.params.buttons != undefined){
e.preventDefault();
return false;
}
Sunstone.getDialog(DIALOG_ID).hide();
if (that.params.submit){
if (that.params.submit != undefined){
that.params.submit(this);
}
return false;
});
$(context).on("click", ".custom_submit", function(){
var index = $(this).attr("submit");
that.params.submit[index]();
Sunstone.getDialog(DIALOG_ID).hide();
return false;
});
return false;
}
@ -97,6 +126,16 @@ define(function(require) {
$("#question", context).html(this.params.question);
}
if (this.params.buttons != undefined){
var html = "";
$.each(this.params.buttons, function(i, text){
html += '<button class="custom_submit radius button right" submit="'+i+'">'+text+'</button>';
});
$(".form_buttons", context).html(html);
}
return false;
}
});