Commit 0212491c authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add protection when the wizard is closing.

parent a52c0420
......@@ -32,7 +32,7 @@ from regex import (REG_COLLABORATION,
plugins = PluginManager()
plugins.dbui.app_css = 'static/my.css'
plugins.dbui.app_debug = None
plugins.dbui.app_lg = 'static/track_publications/locale'
plugins.dbui.app_lg = 'static/track_publications/locale/trp-lang-fr.js'
plugins.dbui.app_libmin = 'static/track_publications-min.js'
plugins.dbui.app_script = 'static/app.js'
# plugins.dbui.app_script_dir = None
......
......@@ -3,13 +3,6 @@
*
*/
Ext.define('Trp.wizard.Base', {
override: 'Trp.wizard.Base',
textFinish: 'Fin',
textNext: 'Suivant',
textPrevious: 'Précédent'
});
Ext.define('Trp.wizard.Harvester', {
override: 'Trp.wizard.Harvester',
textCategory: [
......@@ -68,3 +61,17 @@ Ext.define('Trp.wizard.Harvester', {
"Cliquer sur le boutton <i>suivant</i> pour continuer.</p>"
]
});
Ext.define('Trp.wizard.Wizard', {
override: 'Trp.wizard.Wizard',
textAttention: "Attention",
textClose: [
"<p>L'assistant va être fermé.<br>",
"Toutes les données vont être perdues.</p><br>",
"Voulez-vous continuer ?"
],
textFinish: 'Fin',
textNext: 'Suivant',
textPrevious: 'Précédent'
});
......@@ -2,10 +2,18 @@
* The base class to create Wizard.
*
* The wizard is organised in pages.
* Buttons allow to move from one page to the next and vice-versa.
* Each page contains text and fields to collect data.
* The data are transfered to a the server as a JSON dictionary when the
* button finish is clicked.
*
* Buttons allow to move from one page to the next one and vice-versa.
* At the end, when all fields are field, the button Finish trigger the
* data transfer to the server.
*
* The action executes on the server side is defined by an hyperlinks.
* The data are transfered as a JSON dictionary.
*
* The base class only contains the logic to navigate between pages and to
* send the data to the server. The pages and their configurations has to be
* created for the inherited classes and added via the add method.
*
* @since 0.9.3
*
......@@ -18,12 +26,6 @@ Ext.define('Trp.wizard.Wizard', {
'Ext.layout.container.Card',
'Ext.layout.container.Form'
],
uses: [
'App.form.field.ComboBox',
'Ext.form.field.ComboBox',
'Ext.form.RadioGroup',
'Ext.form.field.Text'
],
/**
* @cfg {String}
......@@ -60,7 +62,7 @@ Ext.define('Trp.wizard.Wizard', {
/**
* @property {Number}
* The number of the current page, startin at 0.
* The number of the current page, starting at 0.
*/
currentPage: 0,
......@@ -71,13 +73,19 @@ Ext.define('Trp.wizard.Wizard', {
lastPage: 0,
// private properties for internationalisation
textAttention: "Attention",
textClose: [
"<p>The wizard is closing.<br>",
"All data will be lost.</p><br>",
"Would you like to continue?"
],
textFinish: 'Finish',
textNext: 'Next',
textPrevious: 'Previous',
// jshint strict: false
// private method requires by the Ext JS component model
// private methods requires by the Ext JS component model
initComponent: function () {
var me = this,
......@@ -114,6 +122,21 @@ Ext.define('Trp.wizard.Wizard', {
me.buttonFinish.setHandler(me.onFinish, me);
},
// insert the protection mechanism when the parent window is closed.
onRender: function () {
var me = this,
window;
me.callParent(arguments);
window = me.up("window");
if (window !== undefined) {
window.on('beforeclose', me.onClose, me);
}
},
// jshint strict: true
// private
......@@ -137,6 +160,30 @@ Ext.define('Trp.wizard.Wizard', {
me.buttonPrev.setDisabled(me.currentPage === 0);
},
/**
* Handler calls when the parent window is closed.
* It requests a confirmation to avoid data lost.
*
* @param {Ext.window.window}
*
*/
onClose: function (window) {
"use strict";
var me = this,
msg = me.textClose.join(" ");
// continue the closing sequence
Ext.Msg.confirm(me.textAttention, msg, function (btn) {
if (btn === "yes") {
window.doClose();
}
});
// pause the event propagation waiting user answer
return false;
},
/**
* Handler call when the transaction with the server failed
* Inform the user and give him/her a change to modify the value
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment