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

Polish the class Wizard.

parent a82a0481
......@@ -5,8 +5,7 @@
* Each page contains text and fields to collect data.
*
* 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.
* At the end, the button Finish triggers 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.
......@@ -15,6 +14,15 @@
* 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.
*
* 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
*
*/
......@@ -52,12 +60,6 @@ Ext.define('Trp.wizard.Wizard', {
*/
burronPrev: null,
/**
* @property {Number}
* The number of the current page, starting at 0.
*/
currentPage: 0,
/**
* @property {Number}
* The number of pages.
......@@ -67,6 +69,7 @@ Ext.define('Trp.wizard.Wizard', {
// shortcuts
cardLayout: null,
mask: null,
window: null,
// private properties for internationalisation
textAttention: "Attention",
......@@ -137,18 +140,18 @@ Ext.define('Trp.wizard.Wizard', {
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 () {
var me = this,
window;
var me = this;
me.callParent(arguments);
window = me.up("window");
me.window = me.up('window');
if (window !== undefined) {
window.on('beforeclose', me.onClose, me);
if (me.window) {
me.window.on('beforeclose', me.onClose, me);
}
},
......@@ -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;
},
......@@ -196,14 +199,15 @@ Ext.define('Trp.wizard.Wizard', {
if (explain !== "") {
msg += "<br>" + explain;
}
Ext.Msg.alert(me.textError, msg);
me.mask.hide();
},
/**
* Handler call when the data collection is finished.
* It mainly send the collect data to the server for the final processing.
* The data are encapsulated in a JSON string
* It sends the collect data to the server for the final processing.
* The data are encapsulated in a JSON string.
*
*/
onFinish: function () {
......@@ -241,7 +245,7 @@ Ext.define('Trp.wizard.Wizard', {
card = me.cardLayout.next();
if (card.isDisabled()) {
if (card && card.isDisabled()) {
me.onNext();
return;
}
......@@ -261,7 +265,7 @@ Ext.define('Trp.wizard.Wizard', {
card = me.cardLayout.prev();
if (card.isDisabled()) {
if (card && card.isDisabled()) {
me.onPrevious();
return;
}
......@@ -284,7 +288,9 @@ Ext.define('Trp.wizard.Wizard', {
// use the private method doclose instead of close
// to avoid the protection
me.up("window").doClose();
if (me.window) {
me.window.doClose();
}
},
// private
......@@ -293,12 +299,13 @@ Ext.define('Trp.wizard.Wizard', {
"use strict";
var me = this,
cards = me.cardLayout.getLayoutItems(),
currentPage = Ext.Array.indexOf(cards, me.cardLayout.getActiveItem());
layout = me.cardLayout,
cards = layout.getLayoutItems(),
currentPage = Ext.Array.indexOf(cards, layout.getActiveItem());
// compute the number of pages once
if (me.lastPage === 0) {
me.lastPage = me.items.length - 1;
me.lastPage = cards.length - 1;
}
// 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