From 829d6e30a11fdb2a6f3362e2327b84ef94861c0c Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Thu, 26 Oct 2017 12:28:18 +0300 Subject: [PATCH] Use *allowSwitchToDesigner* API --- dist/dashboard-panel.js | 2 +- dist/dashboard-panel.min.js | 2 +- src/dashboard-panel.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/dashboard-panel.js b/dist/dashboard-panel.js index 04f762f..8b7915f 100644 --- a/dist/dashboard-panel.js +++ b/dist/dashboard-panel.js @@ -44,7 +44,7 @@ var CustomExtensions; var toViewerItem = new DevExpress.Dashboard.DashboardToolbarItem("toviewer", function () { return _this.switchToViewer(); }); toViewerItem.template = "dashboard-custom-panel-extension-viewer-button"; toViewerItem.disabled = ko.pureComputed(function () { return !!_this._dashboardControl.dashboard(); }); - this.allowSwitchToDesigner(_dashboardControl.params.workingMode !== "ViewerOnly"); + this.allowSwitchToDesigner(_dashboardControl.allowSwitchToDesigner); this._toolbarElement.items.push(toViewerItem); this.desingerToViewerAction = { orderNo: 60, diff --git a/dist/dashboard-panel.min.js b/dist/dashboard-panel.min.js index 9960d95..f4fdcd1 100644 --- a/dist/dashboard-panel.min.js +++ b/dist/dashboard-panel.min.js @@ -1 +1 @@ -var CustomExtensions;!function(o){var t=function(){function o(o){var t=this;this._dashboardControl=o,this.name="custom-dashboard-panel",this._customTemplate={name:"dashboard-custom-panel-extension",data:this},this.panelWidth=250,this.visible=ko.observable(!1),this.allowSwitchToDesigner=ko.observable(!0),this.selectedItemKeys=ko.observableArray(),this.availableDashboards=ko.observableArray(),this.showPanelAsync=function(o){var e=$.Deferred();return t.visible(!0),setTimeout(function(){o.surfaceLeft=t.panelWidth,e.resolve(o)},500),e.promise()},this.hidePanelAsync=function(o){var e=$.Deferred();return t.visible(!1),setTimeout(function(){o.surfaceLeft=0,e.resolve(o)},500),e.promise()},this.switchToViewer=function(){t._dashboardControl.switchToViewer(),t.updateDashboardsList()},this.switchToDesigner=function(){t._dashboardControl.switchToDesigner()},this._toolbarElement=new DevExpress.Dashboard.DashboardToolbarGroup("viewer-button","",100);var e=new DevExpress.Dashboard.DashboardToolbarItem("toviewer",function(){return t.switchToViewer()});e.template="dashboard-custom-panel-extension-viewer-button",e.disabled=ko.pureComputed(function(){return!!t._dashboardControl.dashboard()}),this.allowSwitchToDesigner("ViewerOnly"!==o.params.workingMode),this._toolbarElement.items.push(e),this.desingerToViewerAction={orderNo:60,action:this.showPanelAsync},this.viewerToDesignerAction={orderNo:20,action:this.hidePanelAsync},this.visible(!this._dashboardControl.isDesignMode()),this.selectedItemKeys.subscribe(function(o){if(o.length){var e=o[0];t._dashboardControl.dashboardContainer()&&t._dashboardControl.dashboardContainer().id!=e&&t._dashboardControl.loadDashboard(e)}})}return o.prototype.start=function(){var o=this;this._dashboardControl.customTemplates.push(this._customTemplate);var t=this._dashboardControl.findExtension("toolbox");t&&t.toolbarGroups.push(this._toolbarElement),this._dashboardControl.dashboardContainer.subscribe(function(t){t&&o._validateSelection(t,o.availableDashboards())}),this.availableDashboards.subscribe(function(t){return o._validateSelection(o._dashboardControl.dashboardContainer(),t)}),this._dashboardControl.isDesignMode()||this._dashboardControl.surfaceLeft(this.panelWidth),this.left=ko.computed(function(){return o.visible()?0:-o.panelWidth}),this.updateDashboardsList()},o.prototype.stop=function(){var o=this._dashboardControl.findExtension("toolbox");o&&o.toolbarGroups.remove(this._toolbarElement),this._dashboardControl.customTemplates.remove(this._customTemplate)},o.prototype.updateDashboardsList=function(){var o=this;this._dashboardControl.dashboardContainer();this._dashboardControl.requestDashboardList().done(function(t){o.availableDashboards(t)})},o.prototype._validateSelection=function(o,t){if(o){var e=t.filter(function(t){return t.id===o.id})[0];e&&this.selectedItemKeys([e.id])}},o}();o.CustomDashboardPanelExtension=t}(CustomExtensions||(CustomExtensions={})); \ No newline at end of file +var CustomExtensions;!function(o){var t=function(){function o(o){var t=this;this._dashboardControl=o,this.name="custom-dashboard-panel",this._customTemplate={name:"dashboard-custom-panel-extension",data:this},this.panelWidth=250,this.visible=ko.observable(!1),this.allowSwitchToDesigner=ko.observable(!0),this.selectedItemKeys=ko.observableArray(),this.availableDashboards=ko.observableArray(),this.showPanelAsync=function(o){var e=$.Deferred();return t.visible(!0),setTimeout(function(){o.surfaceLeft=t.panelWidth,e.resolve(o)},500),e.promise()},this.hidePanelAsync=function(o){var e=$.Deferred();return t.visible(!1),setTimeout(function(){o.surfaceLeft=0,e.resolve(o)},500),e.promise()},this.switchToViewer=function(){t._dashboardControl.switchToViewer(),t.updateDashboardsList()},this.switchToDesigner=function(){t._dashboardControl.switchToDesigner()},this._toolbarElement=new DevExpress.Dashboard.DashboardToolbarGroup("viewer-button","",100);var e=new DevExpress.Dashboard.DashboardToolbarItem("toviewer",function(){return t.switchToViewer()});e.template="dashboard-custom-panel-extension-viewer-button",e.disabled=ko.pureComputed(function(){return!!t._dashboardControl.dashboard()}),this.allowSwitchToDesigner(o.allowSwitchToDesigner),this._toolbarElement.items.push(e),this.desingerToViewerAction={orderNo:60,action:this.showPanelAsync},this.viewerToDesignerAction={orderNo:20,action:this.hidePanelAsync},this.visible(!this._dashboardControl.isDesignMode()),this.selectedItemKeys.subscribe(function(o){if(o.length){var e=o[0];t._dashboardControl.dashboardContainer()&&t._dashboardControl.dashboardContainer().id!=e&&t._dashboardControl.loadDashboard(e)}})}return o.prototype.start=function(){var o=this;this._dashboardControl.customTemplates.push(this._customTemplate);var t=this._dashboardControl.findExtension("toolbox");t&&t.toolbarGroups.push(this._toolbarElement),this._dashboardControl.dashboardContainer.subscribe(function(t){t&&o._validateSelection(t,o.availableDashboards())}),this.availableDashboards.subscribe(function(t){return o._validateSelection(o._dashboardControl.dashboardContainer(),t)}),this._dashboardControl.isDesignMode()||this._dashboardControl.surfaceLeft(this.panelWidth),this.left=ko.computed(function(){return o.visible()?0:-o.panelWidth}),this.updateDashboardsList()},o.prototype.stop=function(){var o=this._dashboardControl.findExtension("toolbox");o&&o.toolbarGroups.remove(this._toolbarElement),this._dashboardControl.customTemplates.remove(this._customTemplate)},o.prototype.updateDashboardsList=function(){var o=this;this._dashboardControl.dashboardContainer();this._dashboardControl.requestDashboardList().done(function(t){o.availableDashboards(t)})},o.prototype._validateSelection=function(o,t){if(o){var e=t.filter(function(t){return t.id===o.id})[0];e&&this.selectedItemKeys([e.id])}},o}();o.CustomDashboardPanelExtension=t}(CustomExtensions||(CustomExtensions={})); \ No newline at end of file diff --git a/src/dashboard-panel.ts b/src/dashboard-panel.ts index 96a9072..b705944 100644 --- a/src/dashboard-panel.ts +++ b/src/dashboard-panel.ts @@ -27,7 +27,7 @@ module CustomExtensions { toViewerItem.template = "dashboard-custom-panel-extension-viewer-button"; toViewerItem.disabled = ko.pureComputed(() => !!this._dashboardControl.dashboard()); - this.allowSwitchToDesigner(_dashboardControl.params.workingMode !== "ViewerOnly"); + this.allowSwitchToDesigner(_dashboardControl.allowSwitchToDesigner); this._toolbarElement.items.push(toViewerItem);