- Created an HTML form,
- Create Typescript module
- extended PreCustomerSetTrigger
- updated manifest file
import { ClientEntities } from "PosApi/Entities";
import DialogSampleModule from "Create/Dialogs/EnterCustomerContactDialogs/EnterCustomerContactModule"
export default class AfterAddingCustomerToCart extends PreCustomerSetTrigger {
public execute(options: IPreCustomerSetTriggerOptions): Promise<ClientEntities.ICancelable> {
return new Promise((resolve, reject) => {
let dialogSampleModule: DialogSampleModule = new DialogSampleModule();
dialogSampleModule.open();
//const result = "Operation completed successfully";
//alert(result);
const cancelableResult: ClientEntities.ICancelable = {
canceled: false
};
resolve(cancelableResult);
});
}
}
import { ObjectExtensions } from "PosApi/TypeExtensions";
import { ISampleDialogResult } from "Create/Dialogs/EnterCustomerContactDialogs/IDialogSampleResult";
import ko from "knockout";
type DialogResolve = (value: ISampleDialogResult) => void;
type DialogReject = (reason: any) => void;
export default class DialogSampleModule extends Dialogs.ExtensionTemplatedDialogBase {
public userEnteredValue: ko.Observable<string>;
private _resolve: DialogResolve;
constructor() {
super();
this.userEnteredValue = ko.observable("");
}
public onReady(element: HTMLElement): void {
ko.applyBindings(this, element);
}
this._resolve = resolve;
let option: Dialogs.ITemplatedDialogOptions = {
title: "Create Customer Contact",
button1: {
id: "btnCreate",
label: "Create Customer Contact",
isPrimary: true,
onClick: this.btnUpdateClickHandler.bind(this)
},
button2: {
id: "btnCancel",
label: "Create Customer Contact",
onClick: this.btnCancelClickHandler.bind(this)
},
onCloseX: () => this.btnCancelClickHandler()
};
});
return promise;
}
this.resolvePromise("Success");
return true;
}
this.resolvePromise(null);
return true;
}
if (ObjectExtensions.isFunction(this._resolve)) {
this._resolve(<ISampleDialogResult>{
selectedValue: result
});
}
}
}