The wizard model

The final, and in my opinion most important, part of the puzzle is the top-level view model. This is the one that the wizard panel uses directly and is available to all child components of the panel thanks to the view model inheritance. Here's the code:

// packages/wizard/src/view/WizardModel.js Ext.define('Wizard.view.wizard.WizardModel', { extend: 'Ext.app.ViewModel', alias: 'viewmodel.wizard', data: { currentPosition: 0 }, formulas: { currentStep: function(get) { var pos = get('currentPosition') – 1; return get('questionnaire').steps().getAt(pos); }, stepCount: function(get) { return get('questionnaire').steps().count(); }, isIntroduction: function(get) { return get('currentPosition') === 0; }, isNotLastStep: function(get) { ...

Get Ext JS Application Development Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.