import * as Constants from "../../../Common/Constants"; import * as ViewModels from "../../../Contracts/ViewModels"; import { WaitsForTemplateViewModel } from "../../WaitsForTemplateViewModel"; /** * Parameters for this component */ export interface GraphStyleParams { config: ViewModels.GraphConfigUiData; firstFieldHasFocus?: ko.Observable; /** * Callback triggered when the template is bound to the component (for testing purposes) */ onTemplateReady?: () => void; } class GraphStyleViewModel extends WaitsForTemplateViewModel { private params: GraphStyleParams; public constructor(params: GraphStyleParams) { super(); super.onTemplateReady((isTemplateReady: boolean) => { if (isTemplateReady && params.onTemplateReady) { params.onTemplateReady(); } }); this.params = params; } public onAllNeighborsKeyPress = (source: any, event: KeyboardEvent): boolean => { if (event.keyCode === Constants.KeyCodes.Space || event.keyCode === Constants.KeyCodes.Enter) { this.params.config.showNeighborType(ViewModels.NeighborType.BOTH); event.stopPropagation(); return false; } return true; }; public onSourcesKeyPress = (source: any, event: KeyboardEvent): boolean => { if (event.keyCode === Constants.KeyCodes.Space || event.keyCode === Constants.KeyCodes.Enter) { this.params.config.showNeighborType(ViewModels.NeighborType.SOURCES_ONLY); event.stopPropagation(); return false; } return true; }; public onTargetsKeyPress = (source: any, event: KeyboardEvent): boolean => { if (event.keyCode === Constants.KeyCodes.Space || event.keyCode === Constants.KeyCodes.Enter) { this.params.config.showNeighborType(ViewModels.NeighborType.TARGETS_ONLY); event.stopPropagation(); return false; } return true; }; } const template = `

Show vertex (node) as

Map this property to node color

Map this property to node icon

Show

`; export const GraphStyleComponent = { viewModel: GraphStyleViewModel, template };