/** Angular2 */ import * as ng from "@angular/core"; /** Core */ import { HostElementComponent, HostViewComponent } from "cmf.core/src/core"; import Cmf from "cmf.lbos"; /** Nested Dependencies */ import { Transaction } from "../transaction/transaction"; import { TreatTransactionOutput } from "../transaction/transactionDef"; import { TransactionWizardDef } from "./transactionWizardDef"; import { WizardEventArgs } from "cmf.core.controls/src/components/wizard/wizardDef"; import * as BaseWizardPackage from "cmf.core.controls/src/components/wizard/wizard"; /** * Business wizard directive. * This is an intermediate wizard (between base wizard and the functionality wizard) * that will handle all business logic related with usual business transactions. * * * Examples: * Handle input object comments; * Handle output errors and feedback messages; * Results Step * * * @class TransactionWizard */ export declare class TransactionWizard extends Transaction implements BaseWizardPackage.WizardInterface, ng.OnChanges { private _instance; private _instanceInfoExpanded; private _instanceInfoSubTitle; private _instanceInfoTitle; private _instanceInfoProperties; protected handleDataOutput: string; protected baseComponent: any; /** * @method constructor */ constructor(viewContainerRef: ng.ViewContainerRef, wizard: HostElementComponent, transactionWizardComponent: HostViewComponent, compiler: ng.Compiler); /** * Treats the output received from the server inspecting for errors and feedback messages */ treatOutput(output: Cmf.Foundation.BusinessOrchestration.BaseOutput, exceptionScheme?: { exception: Error; isRecuperableError?: boolean; }): TreatTransactionOutput; /** * When the base wizard is initiated. This is where we should load all input data required by the wizard. */ onWizardInit(args: WizardEventArgs): Promise; /** * When the base wizard is finished. This is where we should call the final service for the wizard and collect its results. */ onWizardFinish(args: WizardEventArgs): Promise; /** * When a specific step in the wizard is activated. This allows delegating to the wizard client prepare what can be shown or not later on in the wizard. */ onWizardStepActivate(args: WizardEventArgs): void; ngOnChanges(changes: any): void; } /** * The interface to implement for Transaction Wizards * * @whatItDoes * The Transaction Wizard Interface allows for the implementation of transaction wizards. * It provides several methods that can be implemented to access and influence the lifecycle of the wizard. * * * @howToUse * ## Transaction Wizards * Transaction wizards are used to perform specific operations in the system, such as doing a Material Track-in * or requesting a Maintenance Activity Order. * They provide a sense of logical incremental steps to the operation, in that way guaranteeing that dependent fields * are filled in the correct order. It also provides an atomic operation, so only when the wizard * is completed is the transaction registered in the system, along with the ability to cancel it at any time. * * ## Page Bag * Must like Pages, Wizards also receive a Page Bag. This allows them to receive context from the outside. * These page bags can be filled directly from the navigation or from the page that invokes the wizard. * Their context object is untyped, which means you need to know what the wizard accepts to invoke it. * * ## Methods * The transaction wizard interface provides several methods that you can use in your wizards, * similarly to how you can use e.g. ngOnInit when you implement its interface (ng.OnInit) * Available methods include: * ``` * prepareDataInput(): Promise>; * ``` * The ```prepareDataInput``` is invoked when the wizard opens initially. * It should return Promise which resolves to an array of LBO input objects which will be invoked to load wizard data. * A common example is calling GetDataForTrackIn when opening a Material track-in wizard. * * * ``` * handleDataOutput(outputs: Array, wizardArgs?: WizardEventArgs): Promise; * ``` * This method is invoked with the result of all the calls made from the inputs provided in ```prepareDataInput```. * You can then proceed to use the loaded data in your wizard. * The passed ```WizardEventArgs``` allows you to directly invoke the callback for this event, and is rarely used here. * This method should return a promise that resolves to *null* * * * ``` * prepareTransactionInput(args: TransactionEventArgs): Promise; * ``` * Similar to ```prepareDataInput```, this method is invoked when the wizard's Finish button is clicked. * It should return a promise that resolves to a single input object that will be sent to the server. * In case it explicity returns a promise that resolves to *undefined* the wizard will not make any call to the server. * The ```TransactionEventArgs``` object contains a ```comments``` properties which contains * the text in the transaction wizard comments box,to be passed to the transaction. * * * ``` * handleTransactionOutput(output: Cmf.Foundation.BusinessOrchestration.BaseOutput): Promise; * ``` * This method is invoked when the call to the input object returned from ```prepareTransactionInput``` * completes and has the corresponding output object as argument. This allows for error handling and wizard cleanup before it is closed. * This method should return a promise that resolves to *null*. * * * ``` * activateStep?: (wizardArgs: WizardEventArgs) => Promise; * ``` * ```activateStep``` is invoked then the wizard moves to a new step. The ```WizardEventArgs``` * contain the current step, as well as a full list of the wizard steps. This allows for logic for distinct wizard steps to be implemented. * * * ## Example * ``` * import {TransactionWizardModule, TransactionWizardInterface, TransactionWizardArgs} from * "cmf.core.business.controls/src/directives/transactionWizard/transactionWizard"; * import {PageBag} from "cmf.core.controls/src/components/page/pageBag"; * * export class MyWizard extends CoreComponent implements TransactionWizardInterface { * constructor(element: ng.ElementRef, private _pageBag: PageBag) { * super([element]); * * this._someVar = this._pageBag.context.someVar; * } * * public prepareTransactionInput(args: TransactionWizardPackage.TransactionWizardArgs): * Promise { * let input = new Cmf.Foundation.BusinessOrchestration.GenericServiceManagement.InputObjects.FullUpdateObjectInput(); * input.Object = this.bag.selectedEntity; * * return Promise.resolve(input); * } * } * ``` */ export declare type TransactionWizardInterface = TransactionWizardDef; export declare type TransactionWizardArgs = WizardEventArgs; export { ResultMessageBag, ResultMessageType } from "cmf.core.controls/src/components/wizard/wizard"; export declare class TransactionWizardModule { }