feature #3748: Use dialog instance for zone creation

This commit is contained in:
Daniel Molina committed 2015-05-08 18:20:33 +02:00
1 parent 85a49578b3
commit 0cc683ea7a
2 files changed
+40 -15

No files matched your search

@@ -13,8 +13,8 @@ define(function(require) {
type: "create",
call: OpenNebulaZone.create,
callback: function(request, response) {
Sunstone.hideDialog(CREATE_DIALOG_ID);
Sunstone.resetDialog(CREATE_DIALOG_ID);
Sunstone.getDialog(CREATE_DIALOG_ID).hide();
Sunstone.getDialog(CREATE_DIALOG_ID).reset();
DataTable.addElement(request, response);
},
error: Notifier.onError,
@@ -24,7 +24,7 @@ define(function(require) {
"Zone.create_dialog" : {
type: "custom",
call: function() {
Sunstone.showDialog(CREATE_DIALOG_ID);
Sunstone.getDialog(CREATE_DIALOG_ID).show();
}
},
@@ -1,18 +1,50 @@
define(function(require) {
/*
DEPENDENCIES
*/
var BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./create/html');
var Sunstone = require('sunstone');
/*
CONSTANTS
*/
var DIALOG_ID = require('./create/dialogId');
var _html = function() {
return TemplateHTML({dialogId: DIALOG_ID});
/*
CONSTRUCTOR
*/
function Dialog() {
this.dialogId = DIALOG_ID;
BaseDialog.call(this);
};
Dialog.DIALOG_ID = DIALOG_ID;
Dialog.prototype = Object.create(BaseDialog.prototype);
Dialog.prototype.constructor = Dialog;
Dialog.prototype.html = _html;
Dialog.prototype.onShow = _onShow;
Dialog.prototype.setup = _setup;
return Dialog;
/*
FUNCTION DEFINITIONS
*/
function _html() {
return TemplateHTML({dialogId: this.dialogId});
}
var _setup = function(dialog) {
function _setup(dialog) {
$('#'+DIALOG_ID+'Form', dialog).submit(_submit);
return false;
}
var _submit = function() {
function _submit() {
var name = $('#zonename', this).val();
var endpoint = $("#endpoint", this).val();
var zoneJSON = {"zone" : {"name" : name, "endpoint" : endpoint}};
@@ -20,15 +52,8 @@ define(function(require) {
return false;
}
var _onShow = function(dialog) {
function _onShow(dialog) {
$("#zonename", dialog).focus();
return false;
}
return {
'dialogId': DIALOG_ID,
'html': _html,
'setup': _setup,
'onShow': _onShow
}
});