@paperbits/core
Version:
Paperbits core components.
44 lines (36 loc) • 1 kB
text/typescript
import * as ko from "knockout";
import template from "./confirmation.html";
import { Component, Event, Param, OnMounted } from "@paperbits/common/ko/decorators";
({
selector: "confirmation",
template: template
})
export class Confirmation {
public readonly message: ko.Observable<string>;
()
public getMessage: () => Promise<string>;
()
public onConfirm: () => void;
()
public onDecline: () => void;
constructor() {
this.message = ko.observable("Are you sure?");
}
()
public async onMounted(): Promise<void> {
if (this.getMessage) {
const message = await this.getMessage();
this.message(message);
}
}
public confirm(): void {
if (this.onConfirm) {
this.onConfirm();
}
}
public decline(): void {
if (this.onDecline) {
this.onDecline();
}
}
}