Skip to content

Commit

Permalink
feat: add api methods to control the chart toolbar items
Browse files Browse the repository at this point in the history
chart toolbar items can be add/removed now using the api methods
(configuration & api) `addChartToolbarItem` & `removeChartToolbarItem`
  • Loading branch information
hyyan committed Jul 19, 2019
1 parent 13a5871 commit cedd618
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 6 deletions.
96 changes: 94 additions & 2 deletions BBjGridExWidget.bbj
Expand Up @@ -761,12 +761,16 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
field public BBjNumber SuppressMultiRangeSelection! = null()
rem /**
rem * Set to true to enable charting
rem *
rem *
rem * <br><b><small>#Enterprise</small></b>
rem * <br><b><small>#Configuration</small></b>
rem */
field public BBjNumber EnableCharts! = null()
rem /**
rem * An array which contains the supported toolbar items
rem */
field protected HashSet ChartToolbarItems! = new HashSet()
rem /**
rem * The grid languages manager
rem */
field protected BBjGridExWidgetLanguageManager LanguageManager! = new BBjGridExWidgetLanguageManager()
Expand Down Expand Up @@ -1043,6 +1047,38 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
methodret "never"
methodend
rem /**
rem * Constant value which defines that chart toolbar settings item
rem *
rem * @return BBjString
rem */
method public static BBjString CAHRT_TOOLBAR_SETTINGS()
methodret "chartSettings"
methodend
rem /**
rem * Constant value which defines that chart toolbar data item
rem *
rem * @return BBjString
rem */
method public static BBjString CAHRT_TOOLBAR_DATA()
methodret "chartData"
methodend
rem /**
rem * Constant value which defines that chart toolbar format item
rem *
rem * @return BBjString
rem */
method public static BBjString CAHRT_TOOLBAR_FORMAT()
methodret "chartFormat"
methodend
rem /**
rem * Constant value which defines that chart toolbar download item
rem *
rem * @return BBjString
rem */
method public static BBjString CAHRT_TOOLBAR_DOWNLOAD()
methodret "chartDownload"
methodend
rem /**
rem * Make Hex Color
rem *
rem * Convert the given BBjColor to a hex color string
Expand Down Expand Up @@ -1093,6 +1129,7 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
method public BBjGridExWidget(BBjWindow wnd!, BBjNumber id!, BBjNumber x!, BBjNumber y!, BBjNumber w!, BBjNumber h!)
#super!.create(wnd!,id!,x!,y!,w!,h!)
#RS!.createIndex()
#fillChartToolbarItems()
methodend
rem /**
rem * The constructor that creates the widget on wnd!
Expand All @@ -1111,6 +1148,7 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
#setTemplate(template$)
#super!.create(wnd!,id!,x!,y!,w!,h!)
#RS!.createIndex()
#fillChartToolbarItems()
methodend
rem /**
rem * The constructor that creates the widget in the ChildWindow
Expand All @@ -1120,6 +1158,7 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
method public BBjGridExWidget(BBjChildWindow wnd!)
#super!.create(wnd!)
#RS!.createIndex()
#fillChartToolbarItems()
methodend
rem /**
rem * The constructor that creates the widget in the ChildWindow
Expand All @@ -1133,6 +1172,7 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
#setTemplate(template$)
#super!.create(wnd!)
#RS!.createIndex()
#fillChartToolbarItems()
methodend
REM /**
REM * Get the unique control type
Expand Down Expand Up @@ -2163,7 +2203,7 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
options!.addProperty("overlayLoadingTemplate",#getOverlayLoadingTemplate(), err=*next)
options!.addProperty("overlayNoRowsTemplate",#getOverlayNoRowsTemplate(), err=*next)
rem Charts
rem ===========================
rem ===========================
options!.addProperty("enableCharts",#getEnableCharts().booleanValue(), err=*next)
rem Tree Data
rem ===========================
Expand Down Expand Up @@ -2196,6 +2236,9 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
context!.addProperty("contextMenu",#ContextMenu!.toString(), err=*next)
context!.addProperty("navigateToNextCell",Iff(#NavigationBehavior! = #GRID_NAVIGATION_BEHAVIOUR_NEXT_ROW() , 1 , 0), err=*next)
context!.addProperty("getDataPath",#getDataPathTemplate(), err=*next)
if(#getEnableCharts() <> null() and #getEnableCharts() = 1) then
context!.addProperty("chartToolbarItems",new Gson().toJson(#getChartToolbarItems()), err=*next)
fi
options!.add("context",context!)
methodret options!
methodend
Expand Down Expand Up @@ -2587,6 +2630,46 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
methodret v!
methodend
rem /**
rem * Enable a chart toolbar item
rem *
rem * <br><b><small>#Enterprise</small></b>
rem * <br><b><small>#Configuration</small></b>
rem * <br><b><small>#API</small></b>
rem *
rem * @see CAHRT_TOOLBAR_SETTINGS()
rem * @see CAHRT_TOOLBAR_DATA()
rem * @see CAHRT_TOOLBAR_FORMAT()
rem * @see CAHRT_TOOLBAR_DOWNLOAD()
rem */
method public void addChartToolbarItem(BBjString item!)
#ChartToolbarItems!.add(item!)

if(#IsReady! and (#getEnableCharts() <> null() and #getEnableCharts() = 1)) then
#executeScript("gw_updateContext('" + #GRIDID$ + "', 'chartToolbarItems','" + new Gson().toJson(#getChartToolbarItems()) + "')")
FI
methodend
rem /**
rem * Disable a chart toolbar item
rem *
rem * <br><b><small>#Enterprise</small></b>
rem * <br><b><small>#Configuration</small></b>
rem * <br><b><small>#API</small></b>
rem *
rem * @see CAHRT_TOOLBAR_SETTINGS()
rem * @see CAHRT_TOOLBAR_DATA()
rem * @see CAHRT_TOOLBAR_FORMAT()
rem * @see CAHRT_TOOLBAR_DOWNLOAD()
rem */
method public void removeChartToolbarItem(BBjString item!)
if #ChartToolbarItems!.contains(item!) then
#ChartToolbarItems!.remove(item!)
FI

if(#IsReady! and (#getEnableCharts() <> null() and #getEnableCharts() = 1)) then
#executeScript("gw_updateContext('" + #GRIDID$ + "', 'chartToolbarItems','" + new Gson().toJson(#getChartToolbarItems()) + "')")
FI
methodend
rem /**
rem * Set the focus on the given row id and the given column
rem *
rem * <br><b><small>#API</small></b>
Expand Down Expand Up @@ -3161,6 +3244,15 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
#executeScript("gw_updateContext('" + #GRIDID$ + "', 'interests','" + new Gson().toJson(#getInterests()) + "')")
methodend
rem /**
rem * The method will add the default chart toolbar items
rem */
method protected void fillChartToolbarItems()
#getChartToolbarItems().add(#CAHRT_TOOLBAR_SETTINGS())
#getChartToolbarItems().add(#CAHRT_TOOLBAR_DATA())
#getChartToolbarItems().add(#CAHRT_TOOLBAR_FORMAT())
#getChartToolbarItems().add(#CAHRT_TOOLBAR_DOWNLOAD())
methodend
rem /**
rem * Get the grid template
rem *
rem * @return BBjString parsed html template
Expand Down
40 changes: 39 additions & 1 deletion client/dist/bbj-grid-widget.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions client/dist/bbj-grid-widget.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/dist/report.html

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions client/src/api/charts.js
@@ -0,0 +1,22 @@
/*
* This file is part of the BBjGridExWidget plugin.
* (c) Basis Europe <eu@basis.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* Return the chart toolbar items defined in the grid's context
*
* @param {Object} params
* @returns {Array} array of supported chart items
*/
export function gw_getChartToolbarItems(params) {
return params
.api
.gridOptionsWrapper
.gridOptions
.context
.chartToolbarItems || [];
}
2 changes: 2 additions & 0 deletions client/src/api/init.js
Expand Up @@ -9,6 +9,7 @@
import { gw_extendColumnDefinitions } from "./columns";
import { gw_navigateToNextRow } from "./rows";
import { gw_getContextMenu } from "./menus";
import { gw_getChartToolbarItems } from "./charts";
import { gw_getDocument, gw_addGrid} from "./utilities";
import {
gw_onRowDoubleClicked,
Expand Down Expand Up @@ -86,6 +87,7 @@ function gw_parseOptions(options) {
onGridReady: e => { gw_onReadyEvent(id, e) } ,
getRowNodeId: data => gw_getRowNodeId(id, data) ,
getContextMenuItems: params => gw_getContextMenu(id, params) ,
"getChartToolbarItems": gw_getChartToolbarItems ,
"popupParent": gw_getDocument().body,
"onRowDoubleClicked": gw_debounce(gw_onRowDoubleClicked, debounceDuration) ,
"onSelectionChanged": gw_debounce(gw_onSelectionChanged, debounceDuration) ,
Expand Down

0 comments on commit cedd618

Please sign in to comment.