Page Life Cycle: Adding Custom Steps - akumina/AkuminaTraining GitHub Wiki

Applies to

Akumina Foundation 3.4.0.0

Adding Custom Steps

We can add custom steps by returning steps within the Init function of the AdditionalSteps.MoreSteps object.

We define additional steps as shown below

var steps = [];
steps.push({ stepName: "<CoreStepName>", additionalSteps: [{ name: "<NewStepName>", callback: <NewStepFunction> }] });
return steps;
CoreStepName

Replace this with the name of the Core Step you are adding after, ie “Auto Clear Local Cache”. They are listed under the Core Steps section.

NewStepName

Replace this with the name of your new step

NewStepFunction

Replace this with the name of the function that executes your step code.

Chaining Steps

var steps = [];
steps.push({ stepName: "Auto Clear Local Cache", additionalSteps: [{ name: "My First Step", callback: MyFirstStep }] });
steps.push({ stepName: "Auto Clear Local Cache", additionalSteps: [{ name: "My Second Step", callback: MySecondStep }] });
return steps;

The situation above where we add two new steps after the same step will not work. When this happens the second step added will overwrite the first. The correct way to handle this situation is to “chain” these steps, by adding the second step after the newly added first step, as shown below.

var steps = [];
steps.push({ stepName: "Auto Clear Local Cache", additionalSteps: [{ name: "My First Step", callback: MyFirstStep }] });
steps.push({ stepName: "My First Step", additionalSteps: [{ name: "My Second Step", callback: MySecondStep }] });
return steps;

Note: If you are doing customizations on an Akumina Foundation Site you must take note of the Shipped Site Steps when adding new custom step. These steps are incorporated by pushing returning an array of step objects.

AdditionalSteps Object

In our digitalworkplace.custom.js we will need to create an AdditionalSteps object that will initialize our custom steps in the Page Life Cycle.

var AdditionalSteps = AdditionalSteps || {}

if ((typeof AdditionalSteps.MoreSteps) === 'undefined') {

    AdditionalSteps.MoreSteps = {

        Init: function () {
            	console.log('AdditionalSteps.MoreSteps.Init');    
	//Add Custom Steps Here
        }        
    }
}

var AdditionalSteps = AditionalSteps || {}

This line calls the Init function of all objects grouped under AdditionalSteps

if ((typeof AdditionalSteps.MoreSteps) === ‘undefined’)

This defines the AdditionalSteps.MoreSteps object. We can create additional objects under AdditionalSteps called whatever we want, ie AdditionalSteps.MyAdvancedSteps, AdditionalSteps.HelloWorld, AdditionalSteps.ProgrammingIsFun, and their Init functions will all be called

Init: function ()

This is Init function for the AdditionalSteps.MoreSteps object. Here is where we want to add our custom steps.

References

To learn how to customize the Page Life Cycle using the Akumina Framework see the following articles: