diff --git a/src/sunstone/public/app/tabs/templates-tab/actions.js b/src/sunstone/public/app/tabs/templates-tab/actions.js
index 449b7f8b42..28f4b2625d 100644
--- a/src/sunstone/public/app/tabs/templates-tab/actions.js
+++ b/src/sunstone/public/app/tabs/templates-tab/actions.js
@@ -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. 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",
diff --git a/src/sunstone/public/app/tabs/templates-tab/buttons.js b/src/sunstone/public/app/tabs/templates-tab/buttons.js
index fcb62facaf..116a62b6b3 100644
--- a/src/sunstone/public/app/tabs/templates-tab/buttons.js
+++ b/src/sunstone/public/app/tabs/templates-tab/buttons.js
@@ -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 recursive'),
- 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")
}
};
diff --git a/src/sunstone/public/app/utils/dialogs/generic-confirm.js b/src/sunstone/public/app/utils/dialogs/generic-confirm.js
index 35a749b4bb..9edd8919c0 100644
--- a/src/sunstone/public/app/utils/dialogs/generic-confirm.js
+++ b/src/sunstone/public/app/utils/dialogs/generic-confirm.js
@@ -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 += '';
+ });
+
+ $(".form_buttons", context).html(html);
+ }
+
return false;
}
});