-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSaveAsExtension.js
43 lines (38 loc) · 1.33 KB
/
SaveAsExtension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class SaveAsDashboardExtension {
toolbox;
menuItem;
dashboardControl;
name = "dashboard-save-as";
newName = ko.observable("New Dashboard Name");
constructor(dashboardControl) {
this.dashboardControl = dashboardControl;
this.menuItem = {
id: "dashboard-save-as",
title: "Save As...",
template: "dx-save-as-form",
selected: ko.observable(true),
disabled: ko.computed(function () { return !dashboardControl.dashboard(); }),
index: 112,
data: this
};
}
saveAs() {
if (this.isExtensionAvailable()) {
this.toolbox.menuVisible(false);
this.newDashboardExtension.performCreateDashboard(this.newName(), this.dashboardControl.dashboard().getJSON());
}
}
isExtensionAvailable() {
return this.toolbox !== undefined && this.newDashboardExtension !== undefined;
}
start() {
this.toolbox = this.dashboardControl.findExtension("toolbox");
this.newDashboardExtension = this.dashboardControl.findExtension("createDashboard");
if (this.isExtensionAvailable())
this.toolbox.menuItems.push(this.menuItem);
}
stop() {
if (this.isExtensionAvailable())
this.toolbox.menuItems.remove(this.menuItem);
}
}