Book Image

Ext JS Application Development Blueprints

Book Image

Ext JS Application Development Blueprints

Overview of this book

Table of Contents (18 chapters)
Ext JS Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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) {
            return get('currentPosition') < get('stepCount') + 1;
        },

        isNextEnabled: function...