jpf 4.2.15 → 4.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.d.ts +2 -1
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js +4 -0
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js.map +1 -1
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.d.ts +2 -1
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js +4 -0
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js.map +1 -1
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +2 -1
- package/dist/controls/custom/FileSelector/FileSelector.js +4 -0
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +2 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.js +4 -0
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -1
- package/dist/controls/custom/ListItem/ListItem.d.ts +4 -2
- package/dist/controls/custom/ListItem/ListItem.js +8 -0
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -1
- package/dist/controls/html/Button/Button.d.ts +2 -1
- package/dist/controls/html/Button/Button.js +4 -0
- package/dist/controls/html/Button/Button.js.map +1 -1
- package/dist/controls/html/Div/Div.d.ts +2 -1
- package/dist/controls/html/Div/Div.js +4 -0
- package/dist/controls/html/Div/Div.js.map +1 -1
- package/dist/controls/html/Image/Image.d.ts +2 -1
- package/dist/controls/html/Image/Image.js +4 -0
- package/dist/controls/html/Image/Image.js.map +1 -1
- package/dist/controls/html/Input/Input.d.ts +2 -1
- package/dist/controls/html/Input/Input.js +4 -0
- package/dist/controls/html/Input/Input.js.map +1 -1
- package/dist/controls/html/Select/Select.d.ts +2 -1
- package/dist/controls/html/Select/Select.js +4 -0
- package/dist/controls/html/Select/Select.js.map +1 -1
- package/dist/controls/html/Span/Span.d.ts +2 -1
- package/dist/controls/html/Span/Span.js +4 -0
- package/dist/controls/html/Span/Span.js.map +1 -1
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.d.ts +2 -1
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js +4 -0
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js.map +1 -1
- package/dist/controls/kendo/Editor/Editor.d.ts +2 -1
- package/dist/controls/kendo/Editor/Editor.js +4 -0
- package/dist/controls/kendo/Editor/Editor.js.map +1 -1
- package/dist/controls/kendo/Grid/Grid.d.ts +2 -1
- package/dist/controls/kendo/Grid/Grid.js +4 -0
- package/dist/controls/kendo/Grid/Grid.js.map +1 -1
- package/dist/controls/kendo/Menu/Menu.js.map +1 -1
- package/dist/controls/leaflet/Map/Map.d.ts +2 -1
- package/dist/controls/leaflet/Map/Map.js +4 -0
- package/dist/controls/leaflet/Map/Map.js.map +1 -1
- package/dist/framework/ViewModel.d.ts +2 -2
- package/dist/framework/ViewModel.js +2 -2
- package/dist/framework/ViewModel.js.map +1 -1
- package/package.json +3 -2
- package/src/controls/codeMirror/HtmlEditor/HtmlEditor.ts +153 -0
- package/src/controls/codeMirror/JsonEditor/JsonEditor.ts +136 -0
- package/src/controls/codeMirror/index.ts +2 -0
- package/src/controls/custom/FileSelector/FileSelector.ts +74 -0
- package/src/controls/custom/LabeledControl/LabeledControl.ts +58 -0
- package/src/controls/custom/ListItem/ListItem.ts +99 -0
- package/src/controls/custom/index.ts +3 -0
- package/src/controls/html/Button/Button.ts +70 -0
- package/src/controls/html/Div/Div.ts +41 -0
- package/src/controls/html/Image/Image.ts +46 -0
- package/src/controls/html/Input/Input.ts +228 -0
- package/src/controls/html/Select/Select.ts +146 -0
- package/src/controls/html/Span/Span.ts +38 -0
- package/src/controls/html/index.ts +6 -0
- package/src/controls/index.ts +15 -0
- package/src/controls/jsonViewAwesome/index.ts +1 -0
- package/src/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.ts +91 -0
- package/src/controls/kendo/Chart/Chart.ts +97 -0
- package/src/controls/kendo/Culture/Culture.ts +32 -0
- package/src/controls/kendo/DataSource/DataSource.ts +4 -0
- package/src/controls/kendo/Dialog/Dialog.ts +64 -0
- package/src/controls/kendo/Editor/Editor.ts +142 -0
- package/src/controls/kendo/Grid/Grid.ts +291 -0
- package/src/controls/kendo/Menu/Menu.ts +125 -0
- package/src/controls/kendo/ObservableObject/ObservableObject.ts +45 -0
- package/src/controls/kendo/Tree/Tree.ts +147 -0
- package/src/controls/kendo/index.ts +9 -0
- package/src/controls/leaflet/LabelControl/LabelControl.ts +42 -0
- package/src/controls/leaflet/Map/Map.ts +180 -0
- package/src/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.ts +19 -0
- package/src/controls/leaflet/PointerEvent/PointerEvent.ts +9 -0
- package/src/controls/leaflet/index.ts +4 -0
- package/src/controls/svg/Circle/Circle.ts +34 -0
- package/src/controls/svg/Ellipse/Ellipse.ts +36 -0
- package/src/controls/svg/ForeignObject/ForeignObject.ts +38 -0
- package/src/controls/svg/Group/Group.ts +38 -0
- package/src/controls/svg/Line/Line.ts +36 -0
- package/src/controls/svg/Pattern/Pattern.ts +49 -0
- package/src/controls/svg/Polygon/Polygon.ts +31 -0
- package/src/controls/svg/Polyline/Polyline.ts +31 -0
- package/src/controls/svg/Rectangle/Rectangle.ts +36 -0
- package/src/controls/svg/Svg/Svg.ts +43 -0
- package/src/controls/svg/Text/Text.ts +38 -0
- package/src/controls/svg/Title/Title.ts +28 -0
- package/src/controls/svg/index.ts +13 -0
- package/src/controls/svg/svg.ts +20 -0
- package/src/framework/View.ts +213 -0
- package/src/framework/ViewModel.ts +525 -0
- package/src/framework/attributes.ts +92 -0
- package/src/framework/event.ts +98 -0
- package/src/framework/observable.ts +80 -0
- package/src/framework/style.ts +3271 -0
- package/src/framework/types.ts +277 -0
- package/src/framework/userAgent.ts +51 -0
- package/src/index.ts +14 -0
- package/src/utilities/blob/blob.ts +19 -0
- package/src/utilities/cookie/cookie.ts +28 -0
- package/src/utilities/dataReaderTable/dataReaderTable.ts +34 -0
- package/src/utilities/fetch/fetch.ts +179 -0
- package/src/utilities/float/float.ts +3 -0
- package/src/utilities/formData/formData.ts +12 -0
- package/src/utilities/html/html.ts +8 -0
- package/src/utilities/htmlElement/htmlElement.ts +15 -0
- package/src/utilities/image/image.ts +1 -0
- package/src/utilities/index.ts +37 -0
- package/src/utilities/integer/integer.ts +31 -0
- package/src/utilities/key/key.ts +7 -0
- package/src/utilities/navigator/navigator.ts +7 -0
- package/src/utilities/notification/notification.ts +88 -0
- package/src/utilities/querystring/querystring.ts +61 -0
- package/src/utilities/router/router.ts +124 -0
- package/src/utilities/stylesheet/stylesheet.ts +58 -0
- package/src/utilities/uniqueId/uniqueId.ts +5 -0
- package/src/utilities/webSocket/webSocket.ts +72 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as kendo from "@progress/kendo-ui/js/kendo.menu.js";
|
|
2
|
+
import { isObservable, unwrap, Subscribable } from "knockout";
|
|
3
|
+
import { View, render } from "../../../framework/View";
|
|
4
|
+
import { ViewModel, Properties, applyBindings as applyViewModelToElement, extendProperties } from "../../../framework/ViewModel";
|
|
5
|
+
import { HierarchicalListItemProperties , HierarchicalListItemViewModel} from "../../custom/ListItem/ListItem";
|
|
6
|
+
const getContent = "getContent";
|
|
7
|
+
|
|
8
|
+
export interface MenuProperties extends Properties {
|
|
9
|
+
items?: Array<HierarchicalListItemProperties| HierarchicalListItemViewModel > | Subscribable<Array<HierarchicalListItemProperties| HierarchicalListItemViewModel>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class MenuView extends View<MenuProperties> {
|
|
13
|
+
constructor(properties: MenuProperties) {
|
|
14
|
+
super(
|
|
15
|
+
{
|
|
16
|
+
tagName: "div",
|
|
17
|
+
properties: extendProperties(
|
|
18
|
+
{
|
|
19
|
+
classNames: ["Menu"],
|
|
20
|
+
viewType: "KendoMenu"
|
|
21
|
+
},
|
|
22
|
+
properties
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private menu: kendo.ui.Menu;
|
|
29
|
+
private dataSource: kendo.data.HierarchicalDataSource;
|
|
30
|
+
|
|
31
|
+
build(): void {
|
|
32
|
+
super.build();
|
|
33
|
+
|
|
34
|
+
const viewModel = this.properties;
|
|
35
|
+
|
|
36
|
+
this.dataSource = new kendo.data.HierarchicalDataSource({});
|
|
37
|
+
this.menu = new kendo.ui.Menu(this.element, {
|
|
38
|
+
dataTextField: "text",
|
|
39
|
+
dataSource: this.dataSource
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
this.menu.bind(
|
|
43
|
+
"dataBound",
|
|
44
|
+
(event) => {
|
|
45
|
+
//Find all menuitems that needs to be post rendered.
|
|
46
|
+
event.sender.wrapper.find(".k-menu-item[postrender]").each((index, element: HTMLElement) => {
|
|
47
|
+
const uid = element.getAttribute("data-uid");
|
|
48
|
+
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as any as HierarchicalListItemProperties;
|
|
49
|
+
if (hierarchicalListItemViewModel) {
|
|
50
|
+
applyViewModelToElement(hierarchicalListItemViewModel, element, this.subscriptions);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if (hierarchicalListItemViewModel[getContent]) {
|
|
54
|
+
const content = hierarchicalListItemViewModel[getContent]();
|
|
55
|
+
if (content instanceof ViewModel) {
|
|
56
|
+
const firstChild = element.firstElementChild as HTMLElement;
|
|
57
|
+
firstChild.style.padding = "0";
|
|
58
|
+
firstChild.innerHTML = "";
|
|
59
|
+
firstChild.appendChild(render(content));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
element.removeAttribute("postrender");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
this.buildItems(unwrap(viewModel.items));
|
|
69
|
+
if (isObservable(viewModel.items)) {
|
|
70
|
+
this.subscriptions.push(
|
|
71
|
+
viewModel.items.subscribe((items) => {
|
|
72
|
+
this.buildItems(items);
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private buildItems(listItems: Array<HierarchicalListItemProperties| HierarchicalListItemViewModel>) {
|
|
79
|
+
const itemDictionary: { [id: string]: HierarchicalListItemProperties } = {};
|
|
80
|
+
const topLevelItems = new Array<HierarchicalListItemProperties>();
|
|
81
|
+
|
|
82
|
+
if (listItems) {
|
|
83
|
+
//Add all visible menuItems to a dictionary
|
|
84
|
+
listItems.forEach((listItem) => {
|
|
85
|
+
if (listItem as any instanceof ViewModel) {
|
|
86
|
+
listItem["attr"] = { postrender: true };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (typeof listItem.text !== "string") {
|
|
90
|
+
var content = listItem.text;
|
|
91
|
+
listItem[getContent] = () => { return content };
|
|
92
|
+
listItem.text = "<post>";
|
|
93
|
+
}
|
|
94
|
+
if (unwrap(listItem.visible) !== false) {
|
|
95
|
+
itemDictionary[listItem.id] = listItem;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
//Add all the children to their parent
|
|
100
|
+
Object.keys(itemDictionary).forEach((key) => {
|
|
101
|
+
const menuItem = itemDictionary[key];
|
|
102
|
+
|
|
103
|
+
if (menuItem.parentId) {
|
|
104
|
+
//Add the menuItem to its parent
|
|
105
|
+
const parent = itemDictionary[menuItem.parentId];
|
|
106
|
+
if (parent) {
|
|
107
|
+
if (!parent.items) {
|
|
108
|
+
parent.items = [];
|
|
109
|
+
}
|
|
110
|
+
parent.items.push(itemDictionary[menuItem.id]);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
//Add the menuItem to the top level items
|
|
114
|
+
topLevelItems.push(itemDictionary[menuItem.id]);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.dataSource.data(topLevelItems);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function menuView(properties: MenuProperties) {
|
|
124
|
+
return new MenuView(properties);
|
|
125
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Subscribable, isObservable, unwrap } from "knockout";
|
|
2
|
+
import * as kendo from "@progress/kendo-ui/js/kendo.data.js";
|
|
3
|
+
|
|
4
|
+
var getUnderlyingObjectFunctionName = "getUnderlyingObject";
|
|
5
|
+
|
|
6
|
+
export function knockoutObservableToKendoObservable(object: object): kendo.data.ObservableObject {
|
|
7
|
+
var observableObject = new kendo.data.ObservableObject();
|
|
8
|
+
observableObject[getUnderlyingObjectFunctionName] = () => {
|
|
9
|
+
return object;
|
|
10
|
+
}
|
|
11
|
+
Object.keys(object).forEach((key: string) => {
|
|
12
|
+
var value = object[key];
|
|
13
|
+
|
|
14
|
+
observableObject[key] = unwrap(value);
|
|
15
|
+
|
|
16
|
+
if (isObservable(value)) {
|
|
17
|
+
value.subscribe(
|
|
18
|
+
(newValue) => {
|
|
19
|
+
observableObject.set(key, newValue);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return observableObject;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getUnderlyingObject(observableObject: kendo.data.ObservableObject): object {
|
|
29
|
+
if (observableObject[getUnderlyingObjectFunctionName]) {
|
|
30
|
+
return observableObject[getUnderlyingObjectFunctionName]();
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function knockoutObservableToKendoObservableArray(array: Array<any> | Subscribable<Array<any>>): Array<kendo.data.ObservableObject> {
|
|
36
|
+
|
|
37
|
+
var observableObjects = new Array<kendo.data.ObservableObject>();
|
|
38
|
+
if (array) {
|
|
39
|
+
unwrap(array).forEach((object) => {
|
|
40
|
+
observableObjects.push(knockoutObservableToKendoObservable(object));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return observableObjects;
|
|
45
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import * as kendo from "@progress/kendo-ui/js/kendo.treeview.js";
|
|
2
|
+
import { isObservable, unwrap, Subscribable } from "knockout";
|
|
3
|
+
import { View, render } from "../../../framework/View";
|
|
4
|
+
import { ViewModel, Properties, applyBindings as applyViewModelToElement, extendProperties } from "../../../framework/ViewModel";
|
|
5
|
+
import { HierarchicalListItemProperties } from "../../custom/ListItem/ListItem";
|
|
6
|
+
const getContent = "getContent";
|
|
7
|
+
|
|
8
|
+
export interface TreeProperties extends Properties {
|
|
9
|
+
items?: Array<HierarchicalListItemProperties> | Subscribable<Array<HierarchicalListItemProperties>>;
|
|
10
|
+
selectedItem?: HierarchicalListItemProperties | Subscribable<HierarchicalListItemProperties>;
|
|
11
|
+
select?: (dataItem: any) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class TreeView extends View<TreeProperties> {
|
|
15
|
+
constructor(properties: TreeProperties) {
|
|
16
|
+
super(
|
|
17
|
+
{
|
|
18
|
+
tagName: "div",
|
|
19
|
+
properties: extendProperties(
|
|
20
|
+
{
|
|
21
|
+
viewType: "KendoTree"
|
|
22
|
+
},
|
|
23
|
+
properties
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private treeView: kendo.ui.TreeView;
|
|
30
|
+
private dataSource: kendo.data.HierarchicalDataSource;
|
|
31
|
+
|
|
32
|
+
build(): void {
|
|
33
|
+
super.build();
|
|
34
|
+
|
|
35
|
+
const viewModel = this.properties;
|
|
36
|
+
|
|
37
|
+
this.dataSource = new kendo.data.HierarchicalDataSource({
|
|
38
|
+
sort: { field: "order", dir: "asc" }
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
this.treeView = new kendo.ui.TreeView(this.element, {
|
|
42
|
+
dataSource: this.dataSource
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.treeView.element.removeAttr("tabindex");
|
|
46
|
+
|
|
47
|
+
if (this.properties.select) {
|
|
48
|
+
this.treeView.bind(
|
|
49
|
+
"select",
|
|
50
|
+
(event: kendo.ui.TreeViewSelectEvent) => {
|
|
51
|
+
const uid = event.node.getAttribute("data-uid");
|
|
52
|
+
const dataItem = this.dataSource.getByUid(uid);
|
|
53
|
+
this.properties.select(dataItem);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
this.treeView.bind(
|
|
58
|
+
"dataBound",
|
|
59
|
+
(event) => {
|
|
60
|
+
//Find all menuitems that needs to be post rendered.
|
|
61
|
+
var selectedItem = unwrap(viewModel.selectedItem);
|
|
62
|
+
if (selectedItem) {
|
|
63
|
+
event.sender.wrapper.find(".k-item").each((index, element: HTMLElement) => {
|
|
64
|
+
const uid = element.getAttribute("data-uid");
|
|
65
|
+
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as any as HierarchicalListItemProperties;
|
|
66
|
+
if (hierarchicalListItemViewModel.id === selectedItem.id) {
|
|
67
|
+
event.sender.select(element);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
event.sender.wrapper.find(".k-item[postrender]").each((index, element: HTMLElement) => {
|
|
73
|
+
const uid = element.getAttribute("data-uid");
|
|
74
|
+
const hierarchicalListItemViewModel = this.dataSource.getByUid(uid) as any as HierarchicalListItemProperties;
|
|
75
|
+
if (hierarchicalListItemViewModel) {
|
|
76
|
+
applyViewModelToElement(hierarchicalListItemViewModel, element, this.subscriptions);
|
|
77
|
+
|
|
78
|
+
if (hierarchicalListItemViewModel[getContent]) {
|
|
79
|
+
const content = hierarchicalListItemViewModel[getContent]();
|
|
80
|
+
if (content instanceof ViewModel) {
|
|
81
|
+
const firstChild = element.firstElementChild as HTMLElement;
|
|
82
|
+
firstChild.style.padding = "0";
|
|
83
|
+
firstChild.innerHTML = "";
|
|
84
|
+
firstChild.appendChild(render(content));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
element.removeAttribute("postrender");
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
this.buildItems(unwrap(viewModel.items));
|
|
94
|
+
if (isObservable(viewModel.items)) {
|
|
95
|
+
this.subscriptions.push(
|
|
96
|
+
viewModel.items.subscribe((items) => {
|
|
97
|
+
this.buildItems(items);
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private buildItems(listItems: Array<HierarchicalListItemProperties>) {
|
|
104
|
+
const itemDictionary: { [id: string]: HierarchicalListItemProperties } = {};
|
|
105
|
+
const topLevelItems = new Array<HierarchicalListItemProperties>();
|
|
106
|
+
|
|
107
|
+
if (listItems) {
|
|
108
|
+
//Add all visible menuItems to a dictionary
|
|
109
|
+
listItems.forEach((listItem) => {
|
|
110
|
+
listItem["attr"] = { postrender: true };
|
|
111
|
+
if (typeof listItem.text !== "string") {
|
|
112
|
+
var content = listItem.text;
|
|
113
|
+
listItem[getContent] = () => { return content };
|
|
114
|
+
listItem.text = "<post>";
|
|
115
|
+
}
|
|
116
|
+
if (unwrap(listItem.visible) !== false) {
|
|
117
|
+
itemDictionary[listItem.id] = listItem;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//Add all the children to their parent
|
|
122
|
+
Object.keys(itemDictionary).forEach((key) => {
|
|
123
|
+
const menuItem = itemDictionary[key];
|
|
124
|
+
|
|
125
|
+
if (menuItem.parentId) {
|
|
126
|
+
//Add the menuItem to its parent
|
|
127
|
+
const parent = itemDictionary[menuItem.parentId];
|
|
128
|
+
if (parent) {
|
|
129
|
+
if (!parent.items) {
|
|
130
|
+
parent.items = [];
|
|
131
|
+
}
|
|
132
|
+
parent.items.push(itemDictionary[menuItem.id]);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
//Add the menuItem to the top level items
|
|
136
|
+
topLevelItems.push(itemDictionary[menuItem.id]);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.dataSource.data(topLevelItems);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function treeView(properties: TreeProperties) {
|
|
146
|
+
return new TreeView(properties);
|
|
147
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./Chart/Chart";
|
|
2
|
+
export * from "./Culture/Culture";
|
|
3
|
+
export * from "./DataSource/DataSource";
|
|
4
|
+
export * from "./Dialog/Dialog";
|
|
5
|
+
export * from "./Editor/Editor";
|
|
6
|
+
export * from "./Grid/Grid";
|
|
7
|
+
export * from "./Menu/Menu";
|
|
8
|
+
export * from "./ObservableObject/ObservableObject";
|
|
9
|
+
export * from "./Tree/Tree";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as leaflet from "leaflet";
|
|
2
|
+
import { IView, getView } from "../../../framework/View";
|
|
3
|
+
import { ViewModel } from "../../../framework/ViewModel";
|
|
4
|
+
|
|
5
|
+
export interface LeafletLabelControlOptions extends leaflet.ControlOptions {
|
|
6
|
+
content: string | IView | ViewModel
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class LeafletLabelControl extends leaflet.Control {
|
|
10
|
+
constructor(options: LeafletLabelControlOptions) {
|
|
11
|
+
super(options);
|
|
12
|
+
|
|
13
|
+
this.content = options.content;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private readonly content: string | IView | ViewModel;
|
|
17
|
+
|
|
18
|
+
onAdd(map: leaflet.Map): HTMLElement {
|
|
19
|
+
const div = document.createElement("div");
|
|
20
|
+
|
|
21
|
+
let view;
|
|
22
|
+
if (this.content instanceof ViewModel) {
|
|
23
|
+
view = getView(this.content);
|
|
24
|
+
if (view) {
|
|
25
|
+
div.appendChild(view.render());
|
|
26
|
+
}
|
|
27
|
+
} else if (typeof this.content === "string") {
|
|
28
|
+
div.innerText = this.content;
|
|
29
|
+
} else {
|
|
30
|
+
view = this.content as IView;
|
|
31
|
+
if (view.render) {
|
|
32
|
+
div.appendChild(view.render());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return div;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function leafletLabelControl(options: LeafletLabelControlOptions) {
|
|
41
|
+
return new LeafletLabelControl(options);
|
|
42
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { isObservable, unwrap, Observable, ObservableArray, Computed } from "knockout";
|
|
2
|
+
import * as leaflet from "leaflet";
|
|
3
|
+
import { View, registerView } from "../../../framework/View";
|
|
4
|
+
import { ViewModel, Properties, extendProperties } from "../../../framework/ViewModel";
|
|
5
|
+
|
|
6
|
+
export interface MapProperties extends Properties {
|
|
7
|
+
renderer?: leaflet.Renderer;
|
|
8
|
+
center?: leaflet.LatLngExpression | Observable<leaflet.LatLngExpression>;
|
|
9
|
+
zoom?: number;
|
|
10
|
+
south?: number;
|
|
11
|
+
north?: number;
|
|
12
|
+
west?: number;
|
|
13
|
+
east?: number;
|
|
14
|
+
tileLayers?: Array<leaflet.TileLayer>;
|
|
15
|
+
layers?: Array<leaflet.Layer> | ObservableArray<leaflet.Layer> | Computed<Array<leaflet.Layer>>;
|
|
16
|
+
controls?: Array<leaflet.Control> | ObservableArray<leaflet.Control>;
|
|
17
|
+
zoomInTitle?: string;
|
|
18
|
+
zoomOutTitle?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class MapView extends View<MapProperties> {
|
|
22
|
+
constructor(properties: MapProperties) {
|
|
23
|
+
super(
|
|
24
|
+
{
|
|
25
|
+
tagName: "div",
|
|
26
|
+
properties: extendProperties(
|
|
27
|
+
{
|
|
28
|
+
viewType: "LeafletMap"
|
|
29
|
+
},
|
|
30
|
+
properties
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private map: leaflet.Map;
|
|
37
|
+
private layers = new Array<leaflet.Layer>();
|
|
38
|
+
private controls = new Array<leaflet.Control>();
|
|
39
|
+
|
|
40
|
+
build(): void {
|
|
41
|
+
super.build();
|
|
42
|
+
|
|
43
|
+
const viewModel = this.properties;
|
|
44
|
+
if (!viewModel.center) {
|
|
45
|
+
viewModel.center = burtonville;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const options: leaflet.MapOptions = {
|
|
49
|
+
renderer: viewModel.renderer,
|
|
50
|
+
zoomControl: false
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//Leaflet can not handle rendering from an element not attached to the DOM
|
|
54
|
+
setTimeout(
|
|
55
|
+
() => {
|
|
56
|
+
this.map = leaflet.map(this.element, options).setView(unwrap(viewModel.center), this.properties.zoom);
|
|
57
|
+
|
|
58
|
+
//Add the language specific zoom element
|
|
59
|
+
leaflet.control.zoom({
|
|
60
|
+
position: "topleft",
|
|
61
|
+
zoomInTitle: viewModel.zoomInTitle,
|
|
62
|
+
zoomOutTitle: viewModel.zoomOutTitle
|
|
63
|
+
}).addTo(this.map);
|
|
64
|
+
|
|
65
|
+
if (this.properties.eventListeners) {
|
|
66
|
+
Object.keys(this.properties.eventListeners).forEach((key) => {
|
|
67
|
+
this.map.on(
|
|
68
|
+
key,
|
|
69
|
+
(event) => {
|
|
70
|
+
this.properties.eventListeners[key](event);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.setTileLayers(viewModel.tileLayers);
|
|
77
|
+
|
|
78
|
+
this.setLayers(unwrap(viewModel.layers));
|
|
79
|
+
if (isObservable(viewModel.layers)) {
|
|
80
|
+
this.subscriptions.push(
|
|
81
|
+
viewModel.layers.subscribe((layers) => {
|
|
82
|
+
this.setLayers(layers);
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.setControls(unwrap(viewModel.controls));
|
|
88
|
+
if (isObservable(viewModel.controls)) {
|
|
89
|
+
this.subscriptions.push(
|
|
90
|
+
viewModel.controls.subscribe((controls) => {
|
|
91
|
+
this.setControls(controls);
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (isObservable(viewModel.center)) {
|
|
97
|
+
this.subscriptions.push(
|
|
98
|
+
viewModel.center.subscribe((center) => {
|
|
99
|
+
this.map.panTo(center);
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
100
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private setTileLayers(tileLayers: Array<leaflet.TileLayer>) {
|
|
109
|
+
if (tileLayers) {
|
|
110
|
+
tileLayers.forEach((tileLayer) => {
|
|
111
|
+
tileLayer.addTo(this.map);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private setLayers(layers: Array<leaflet.Layer>) {
|
|
117
|
+
//Remove existing markers
|
|
118
|
+
this.layers.forEach((layer) => {
|
|
119
|
+
this.map.removeLayer(layer);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
//Reset the layers array
|
|
123
|
+
this.layers = [];
|
|
124
|
+
|
|
125
|
+
//Add the new layers to the array and the map
|
|
126
|
+
if (layers) {
|
|
127
|
+
layers.forEach((layer) => {
|
|
128
|
+
this.layers.push(layer);
|
|
129
|
+
layer.addTo(this.map);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private setControls(controls: Array<leaflet.Control>) {
|
|
135
|
+
//Remove existing controls
|
|
136
|
+
this.controls.forEach((control) => {
|
|
137
|
+
this.map.removeControl(control);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
this.controls = [];
|
|
141
|
+
|
|
142
|
+
if (controls) {
|
|
143
|
+
controls.forEach((control) => {
|
|
144
|
+
this.controls.push(control);
|
|
145
|
+
control.addTo(this.map);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function mapView(properties: MapProperties) {
|
|
152
|
+
return new MapView(properties);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const burtonville: leaflet.LatLngExpression = [50.283939, 5.964070];
|
|
156
|
+
|
|
157
|
+
export class MapViewModel extends ViewModel implements MapProperties {
|
|
158
|
+
constructor(properties: MapProperties) {
|
|
159
|
+
super();
|
|
160
|
+
this.setProperties(this, properties);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
renderer?: leaflet.Renderer;
|
|
164
|
+
center?: leaflet.LatLngExpression | Observable<leaflet.LatLngExpression>;
|
|
165
|
+
zoom?: number;
|
|
166
|
+
south?: number;
|
|
167
|
+
north?: number;
|
|
168
|
+
west?: number;
|
|
169
|
+
east?: number;
|
|
170
|
+
tileLayers?: Array<leaflet.TileLayer>;
|
|
171
|
+
layers?: Array<leaflet.Layer> | ObservableArray<leaflet.Layer> | Computed<Array<leaflet.Layer>>;
|
|
172
|
+
controls?: Array<leaflet.Control> | ObservableArray<leaflet.Control>;
|
|
173
|
+
zoomInTitle?: string;
|
|
174
|
+
zoomOutTitle?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
registerView(
|
|
178
|
+
MapViewModel,
|
|
179
|
+
MapView
|
|
180
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TileLayerOptions, TileLayer } from "leaflet";
|
|
2
|
+
|
|
3
|
+
export interface OpenStreetMapTileLayerOptions extends TileLayerOptions {
|
|
4
|
+
attribution?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class OpenStreetMapTileLayer extends TileLayer {
|
|
8
|
+
constructor(options?: OpenStreetMapTileLayerOptions) {
|
|
9
|
+
if (!options) {
|
|
10
|
+
options = {};
|
|
11
|
+
}
|
|
12
|
+
options.attribution = "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors";
|
|
13
|
+
super("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function openStreetMapTileLayer(options?: OpenStreetMapTileLayerOptions) {
|
|
18
|
+
return new OpenStreetMapTileLayer(options);
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LeafletEvent } from "leaflet";
|
|
2
|
+
|
|
3
|
+
export function getPointerEvent(event: Event | LeafletEvent): PointerEvent {
|
|
4
|
+
const originalEvent = event["originalEvent"];
|
|
5
|
+
if (originalEvent instanceof PointerEvent) {
|
|
6
|
+
return originalEvent as PointerEvent;
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { View } from "../../../framework/View";
|
|
2
|
+
import { Properties, extendProperties} from "../../../framework/ViewModel";
|
|
3
|
+
import { Subscribable } from "knockout";
|
|
4
|
+
|
|
5
|
+
export interface CircleProperties extends Properties {
|
|
6
|
+
cx: number | string | Subscribable<number | string>;
|
|
7
|
+
cy: number | string | Subscribable<number | string>;
|
|
8
|
+
r: number | string | Subscribable<number | string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class CircleView extends View<CircleProperties> {
|
|
12
|
+
constructor(properties: CircleProperties) {
|
|
13
|
+
super(
|
|
14
|
+
{
|
|
15
|
+
tagName: "circle",
|
|
16
|
+
properties: extendProperties(
|
|
17
|
+
{
|
|
18
|
+
viewType: "Circle",
|
|
19
|
+
attributes: {
|
|
20
|
+
cx: properties.cx,
|
|
21
|
+
cy: properties.cy,
|
|
22
|
+
r: properties.r
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
properties
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function circleView(properties: CircleProperties) {
|
|
33
|
+
return new CircleView(properties);
|
|
34
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { View } from "../../../framework/View";
|
|
2
|
+
import { Properties, extendProperties} from "../../../framework/ViewModel";
|
|
3
|
+
import { Subscribable } from "knockout";
|
|
4
|
+
|
|
5
|
+
export interface EllipseProperties extends Properties {
|
|
6
|
+
cx: number | string | Subscribable<number | string>;
|
|
7
|
+
cy: number | string | Subscribable<number | string>;
|
|
8
|
+
rx: number | string | Subscribable<number | string>;
|
|
9
|
+
ry: number | string | Subscribable<number | string>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class EllipseView extends View<EllipseProperties> {
|
|
13
|
+
constructor(properties: EllipseProperties) {
|
|
14
|
+
super(
|
|
15
|
+
{
|
|
16
|
+
tagName: "ellipse",
|
|
17
|
+
properties: extendProperties(
|
|
18
|
+
{
|
|
19
|
+
viewType: "Ellipse",
|
|
20
|
+
attributes: {
|
|
21
|
+
cx: properties.cx,
|
|
22
|
+
cy: properties.cy,
|
|
23
|
+
rx: properties.rx,
|
|
24
|
+
ry: properties.ry
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
properties
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function ellipseView(properties: EllipseProperties) {
|
|
35
|
+
return new EllipseView(properties);
|
|
36
|
+
}
|