import * as ko from "knockout"; import * as ViewModels from "../../Contracts/ViewModels"; import { ContextualPaneBase } from "./ContextualPaneBase"; import { KeyCodes } from "../../Common/Constants"; import Explorer from "../Explorer"; export default class NewVertexPane extends ContextualPaneBase { public container: Explorer; public visible: ko.Observable; public formErrors: ko.Observable; public formErrorsDetails: ko.Observable; // Graph style stuff public tempVertexData: ko.Observable; // vertex data being edited private onSubmitCreateCallback: (newVertexData: ViewModels.NewVertexData) => void; private partitionKeyProperty: ko.Observable; constructor(options: ViewModels.PaneOptions) { super(options); this.tempVertexData = ko.observable(null); this.partitionKeyProperty = ko.observable(null); this.resetData(); } public submit() { // Commit edited changes if (this.onSubmitCreateCallback != null) { this.onSubmitCreateCallback(this.tempVertexData()); } // this.close(); } public resetData() { super.resetData(); this.onSubmitCreateCallback = null; this.tempVertexData({ label: "", properties: [] }); this.partitionKeyProperty(null); } public subscribeOnSubmitCreate(callback: (newVertexData: ViewModels.NewVertexData) => void): void { this.onSubmitCreateCallback = callback; } public setPartitionKeyProperty(pKeyProp: string): void { this.partitionKeyProperty(pKeyProp); } public onMoreDetailsKeyPress = (source: any, event: KeyboardEvent): boolean => { if (event.keyCode === KeyCodes.Space || event.keyCode === KeyCodes.Enter) { this.showErrorDetails(); return false; } return true; }; public buildString = (prefix: string, index: number): string => { return `${prefix}${index}`; }; }