Commit 8daf3716 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Polish the class Wizard.

parent a82a0481
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
* Each page contains text and fields to collect data. * Each page contains text and fields to collect data.
* *
* Buttons allow to move from one page to the next one and vice-versa. * 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 * At the end, the button Finish triggers the data transfer to the server.
* data transfer to the server.
* *
* The action executes on the server side is defined by an hyperlinks. * The action executes on the server side is defined by an hyperlinks.
* The data are transfered as a JSON dictionary. * The data are transfered as a JSON dictionary.
...@@ -15,6 +14,15 @@ ...@@ -15,6 +14,15 @@
* send the data to the server. The pages and their configurations has to be * 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. * created for the inherited classes and added via the add method.
* *
* Two mechanism are in placed to ease the navigation logic. They are base on
* the field property allowBlank and on the panel property disabled.
* The first one allow to enable/disable the button finish while the second
* allow to skip page.
*
* The button Finish is linked to the fields via the allowBlank and
* formBind properties. The button Finish is enabled when all the field, with
* property allowBlank equal to false, are filled.
*
* @since 0.9.3 * @since 0.9.3
* *
*/ */
...@@ -52,12 +60,6 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -52,12 +60,6 @@ Ext.define('Trp.wizard.Wizard', {
*/ */
burronPrev: null, burronPrev: null,
/**
* @property {Number}
* The number of the current page, starting at 0.
*/
currentPage: 0,
/** /**
* @property {Number} * @property {Number}
* The number of pages. * The number of pages.
...@@ -67,6 +69,7 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -67,6 +69,7 @@ Ext.define('Trp.wizard.Wizard', {
// shortcuts // shortcuts
cardLayout: null, cardLayout: null,
mask: null, mask: null,
window: null,
// private properties for internationalisation // private properties for internationalisation
textAttention: "Attention", textAttention: "Attention",
...@@ -137,18 +140,18 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -137,18 +140,18 @@ Ext.define('Trp.wizard.Wizard', {
me.cardLayout = me.getLayout(); me.cardLayout = me.getLayout();
}, },
// insert the protection mechanism when the parent window is closed. // private methods of the Ext JS component model.
// Insert the protection mechanism when the parent window is closed.
onRender: function () { onRender: function () {
var me = this, var me = this;
window;
me.callParent(arguments); me.callParent(arguments);
window = me.up("window"); me.window = me.up('window');
if (window !== undefined) { if (me.window) {
window.on('beforeclose', me.onClose, me); me.window.on('beforeclose', me.onClose, me);
} }
}, },
...@@ -174,7 +177,7 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -174,7 +177,7 @@ Ext.define('Trp.wizard.Wizard', {
} }
}); });
// pause the event propagation waiting user answer // stop the event propagation waiting user answer
return false; return false;
}, },
...@@ -196,14 +199,15 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -196,14 +199,15 @@ Ext.define('Trp.wizard.Wizard', {
if (explain !== "") { if (explain !== "") {
msg += "<br>" + explain; msg += "<br>" + explain;
} }
Ext.Msg.alert(me.textError, msg); Ext.Msg.alert(me.textError, msg);
me.mask.hide(); me.mask.hide();
}, },
/** /**
* Handler call when the data collection is finished. * Handler call when the data collection is finished.
* It mainly send the collect data to the server for the final processing. * It sends the collect data to the server for the final processing.
* The data are encapsulated in a JSON string * The data are encapsulated in a JSON string.
* *
*/ */
onFinish: function () { onFinish: function () {
...@@ -241,7 +245,7 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -241,7 +245,7 @@ Ext.define('Trp.wizard.Wizard', {
card = me.cardLayout.next(); card = me.cardLayout.next();
if (card.isDisabled()) { if (card && card.isDisabled()) {
me.onNext(); me.onNext();
return; return;
} }
...@@ -261,7 +265,7 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -261,7 +265,7 @@ Ext.define('Trp.wizard.Wizard', {
card = me.cardLayout.prev(); card = me.cardLayout.prev();
if (card.isDisabled()) { if (card && card.isDisabled()) {
me.onPrevious(); me.onPrevious();
return; return;
} }
...@@ -284,7 +288,9 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -284,7 +288,9 @@ Ext.define('Trp.wizard.Wizard', {
// use the private method doclose instead of close // use the private method doclose instead of close
// to avoid the protection // to avoid the protection
me.up("window").doClose(); if (me.window) {
me.window.doClose();
}
}, },
// private // private
...@@ -293,12 +299,13 @@ Ext.define('Trp.wizard.Wizard', { ...@@ -293,12 +299,13 @@ Ext.define('Trp.wizard.Wizard', {
"use strict"; "use strict";
var me = this, var me = this,
cards = me.cardLayout.getLayoutItems(), layout = me.cardLayout,
currentPage = Ext.Array.indexOf(cards, me.cardLayout.getActiveItem()); cards = layout.getLayoutItems(),
currentPage = Ext.Array.indexOf(cards, layout.getActiveItem());
// compute the number of pages once // compute the number of pages once
if (me.lastPage === 0) { if (me.lastPage === 0) {
me.lastPage = me.items.length - 1; me.lastPage = cards.length - 1;
} }
// inhibit buttons // inhibit buttons
......
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