mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #3748: New generic confirm dialog
This commit is contained in:
parent
3a12e9a3df
commit
7cd3378864
@ -47,7 +47,8 @@ define(function(require) {
|
||||
|
||||
var _commonDialogs = [
|
||||
require('utils/dialogs/confirm'),
|
||||
require('utils/dialogs/confirm-with-select')
|
||||
require('utils/dialogs/confirm-with-select'),
|
||||
require('utils/dialogs/generic-confirm')
|
||||
]
|
||||
|
||||
Sunstone.addDialogs(_commonDialogs);
|
||||
|
86
src/sunstone/public/app/utils/dialogs/generic-confirm.js
Normal file
86
src/sunstone/public/app/utils/dialogs/generic-confirm.js
Normal file
@ -0,0 +1,86 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./generic-confirm/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var Locale = require('utils/locale');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./generic-confirm/dialogId');
|
||||
|
||||
/*
|
||||
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;
|
||||
Dialog.prototype.setParams = _setParams;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({dialogId: this.dialogId});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} params.
|
||||
* - params.header : Optional, html string
|
||||
* - params.body : Optional, html string
|
||||
* - params.question : Optional, html string
|
||||
* - params.submit : Mandatory, function to call if user confirms
|
||||
*/
|
||||
function _setParams(params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
$('#' + DIALOG_ID + 'Form', context).submit(function() {
|
||||
Sunstone.getDialog(DIALOG_ID).hide();
|
||||
|
||||
if (that.params.submit){
|
||||
that.params.submit(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
if (this.params.header){
|
||||
$("#header", context).html(this.params.header);
|
||||
}
|
||||
|
||||
if (this.params.body){
|
||||
$("#body", context).html(this.params.body);
|
||||
}
|
||||
|
||||
if (this.params.question){
|
||||
$("#question", context).html(this.params.question);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
define(function(require){
|
||||
return 'genericConfirmDialog';
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
<div id="{{dialogId}}" class="reveal-modal" data-reveal>
|
||||
<div class="row">
|
||||
<h3 class="subheader">
|
||||
<span id="header">{{tr "Confirm"}}</span>
|
||||
<br>
|
||||
</h3>
|
||||
</div>
|
||||
<form id="{{dialogId}}Form">
|
||||
<div id="body">{{tr "You have to confirm this action."}}</div>
|
||||
<br/>
|
||||
<div id="question">{{tr "Do you want to proceed?"}}</div>
|
||||
<br/>
|
||||
<div class="form_buttons">
|
||||
<button id="generic_confirm_proceed" class="radius button right" value="">{{tr "OK"}}</button>
|
||||
</div>
|
||||
<a class="close-reveal-modal">×</a>
|
||||
</form>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user