Skip to content

Commit

Permalink
refactor(gridOptions): all Grid Menu showX were renamed hideX
Browse files Browse the repository at this point in the history
- since we had both "hideX" (in SlickGrid) and "showX", it's better to rename them all to "hideX" for consistencies
  • Loading branch information
ghiscoding committed May 26, 2018
1 parent 0bf9d94 commit aa32a56
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 46 deletions.
11 changes: 6 additions & 5 deletions aurelia-slickgrid/src/aurelia-slickgrid/global-grid-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ export const GlobalGridOptions: GridOption = {
},
forceFitColumns: false,
gridMenu: {
hideClearAllFiltersCommand: false,
hideClearAllSortingCommand: false,
hideExportCsvCommand: false,
hideExportTextDelimitedCommand: true,
hideForceFitButton: false,
hideRefreshDatasetCommand: false,
hideToggleFilterCommand: false,
hideSyncResizeButton: true,
iconCssClass: 'fa fa-bars',
iconClearAllFiltersCommand: 'fa fa-filter text-danger',
Expand All @@ -62,11 +68,6 @@ export const GlobalGridOptions: GridOption = {
iconToggleFilterCommand: 'fa fa-random',
menuWidth: 16,
resizeOnShowHeaderRow: true,
showClearAllFiltersCommand: true,
showClearAllSortingCommand: true,
showExportCsvCommand: true,
showRefreshDatasetCommand: true,
showToggleFilterCommand: true
},
headerMenu: {
autoAlign: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,35 @@ export interface GridMenu {
/** Defaults to "Columns" which is the title that shows up over the columns */
columnTitle?: string;

/** Link for the displaying the Grid menu icon image (basically the hamburger menu) */
iconImage?: string;

/** CSS class for the displaying the Grid menu icon image (basically the hamburger menu) */
iconCssClass?: string;

/** Defaults to False, which leads to leaving the menu open after a click */
leaveOpen?: boolean;

/** Defaults to 16 pixels (only the number), which is the width in pixels of the Grid Menu icon */
menuWidth?: number;

/** Defaults to "Force fit columns" which is 1 of the last 2 checkbox title shown at the end of the picker list */
forceFitTitle?: string;

/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideForceFitButton?: boolean;
/** Defaults to false, which will hide the "Clear All Filters" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
hideClearAllFiltersCommand?: boolean;

/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideSyncResizeButton?: boolean;
/** Defaults to false, which will hide the "Clear All Sorting" command in the Grid Menu (Grid Option "enableSorting: true" has to be enabled) */
hideClearAllSortingCommand?: boolean;

/** Defaults to False, which will resize the Header Row and remove the width of the Grid Menu icon from it's total width. */
resizeOnShowHeaderRow?: boolean;
/** Defaults to false, which will hide the "Export to CSV" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
hideExportCsvCommand?: boolean;

/** Defaults to True, which will show the "Clear All Filters" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
showClearAllFiltersCommand?: boolean;
/** Defaults to false, which will hide the "Export to Text Delimited" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
hideExportTextDelimitedCommand?: boolean;

/** Defaults to True, which will show the "Clear All Sorting" command in the Grid Menu (Grid Option "enableSorting: true" has to be enabled) */
showClearAllSortingCommand?: boolean;
/** Defaults to false, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideForceFitButton?: boolean;

/** Defaults to True, which will show the "Export to CSV" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
showExportCsvCommand?: boolean;
/** Defaults to false, which will hide the "Refresh Dataset" command in the Grid Menu (only works with a Backend Service API) */
hideRefreshDatasetCommand?: boolean;

/** Defaults to True, which will show the "Export to Text Delimited" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
showExportTextDelimitedCommand?: boolean;
/** Defaults to false, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideSyncResizeButton?: boolean;

/** Defaults to True, which will show the "Refresh Dataset" command in the Grid Menu (only works with a Backend Service API) */
showRefreshDatasetCommand?: boolean;
/** Defaults to false, which will hide the "Toggle Filter Row" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
hideToggleFilterCommand?: boolean;

/** Defaults to True, which will show the "Toggle Filter Row" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
showToggleFilterCommand?: boolean;
/** CSS class for the displaying the Grid menu icon image (basically the hamburger menu) */
iconCssClass?: string;

/** icon for the "Clear All Filters" command */
iconClearAllFiltersCommand?: string;
Expand All @@ -64,15 +52,30 @@ export interface GridMenu {
/** icon for the "Export to Text Delimited" command */
iconExportTextDelimitedCommand?: string;

/** Link for the displaying the Grid menu icon image (basically the hamburger menu) */
iconImage?: string;

/** icon for the "Refresh Dataset" command */
iconRefreshDatasetCommand?: string;

/** icon for the "Toggle Filter Row" command */
iconToggleFilterCommand?: string;

/** Defaults to False, which leads to leaving the menu open after a click */
leaveOpen?: boolean;

/** Defaults to 16 pixels (only the number), which is the width in pixels of the Grid Menu icon */
menuWidth?: number;

/** Defaults to False, which will resize the Header Row and remove the width of the Grid Menu icon from it's total width. */
resizeOnShowHeaderRow?: boolean;

/** Defaults to "Synchronous resize" which is 1 of the last 2 checkbox title shown at the end of the picker list */
syncResizeTitle?: string;

//
// Events

/** SlickGrid Event fired before the menu is shown. */
onBeforeMenuShow?: (e: Event, args: any) => void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class ControlAndPluginService {

if (this._gridOptions && this._gridOptions.enableFiltering) {
// show grid menu: clear all filters
if (this._gridOptions && this._gridOptions.gridMenu && this._gridOptions.gridMenu.showClearAllFiltersCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'clear-filter').length === 0) {
if (this._gridOptions && this._gridOptions.gridMenu && !this._gridOptions.gridMenu.hideClearAllFiltersCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'clear-filter').length === 0) {
this._gridOptions.gridMenu.customItems.push(
{
iconCssClass: this._gridOptions.gridMenu.iconClearAllFiltersCommand || 'fa fa-filter text-danger',
Expand All @@ -427,7 +427,7 @@ export class ControlAndPluginService {
);
}
// show grid menu: toggle filter row
if (this._gridOptions && this._gridOptions.gridMenu && this._gridOptions.gridMenu.showToggleFilterCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'toggle-filter').length === 0) {
if (this._gridOptions && this._gridOptions.gridMenu && !this._gridOptions.gridMenu.hideToggleFilterCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'toggle-filter').length === 0) {
this._gridOptions.gridMenu.customItems.push(
{
iconCssClass: this._gridOptions.gridMenu.iconToggleFilterCommand || 'fa fa-random',
Expand All @@ -440,7 +440,7 @@ export class ControlAndPluginService {
}

// show grid menu: refresh dataset
if (this._gridOptions && this._gridOptions.gridMenu && this._gridOptions.gridMenu.showRefreshDatasetCommand && backendApi && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'refresh-dataset').length === 0) {
if (this._gridOptions && this._gridOptions.gridMenu && !this._gridOptions.gridMenu.hideRefreshDatasetCommand && backendApi && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'refresh-dataset').length === 0) {
this._gridOptions.gridMenu.customItems.push(
{
iconCssClass: this._gridOptions.gridMenu.iconRefreshDatasetCommand || 'fa fa-refresh',
Expand All @@ -455,7 +455,7 @@ export class ControlAndPluginService {

if (this._gridOptions.enableSorting) {
// show grid menu: clear all sorting
if (this._gridOptions && this._gridOptions.gridMenu && this._gridOptions.gridMenu.showClearAllSortingCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'clear-sorting').length === 0) {
if (this._gridOptions && this._gridOptions.gridMenu && !this._gridOptions.gridMenu.hideClearAllSortingCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'clear-sorting').length === 0) {
this._gridOptions.gridMenu.customItems.push(
{
iconCssClass: this._gridOptions.gridMenu.iconClearAllSortingCommand || 'fa fa-unsorted text-danger',
Expand All @@ -469,7 +469,7 @@ export class ControlAndPluginService {
}

// show grid menu: export to file
if (this._gridOptions && this._gridOptions.enableExport && this._gridOptions.gridMenu && this._gridOptions.gridMenu.showExportCsvCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'export-csv').length === 0) {
if (this._gridOptions && this._gridOptions.enableExport && this._gridOptions.gridMenu && !this._gridOptions.gridMenu.hideExportCsvCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'export-csv').length === 0) {
this._gridOptions.gridMenu.customItems.push(
{
iconCssClass: this._gridOptions.gridMenu.iconExportCsvCommand || 'fa fa-download',
Expand All @@ -481,7 +481,7 @@ export class ControlAndPluginService {
);
}
// show grid menu: export to text file as tab delimited
if (this._gridOptions && this._gridOptions.enableExport && this._gridOptions.gridMenu && this._gridOptions.gridMenu.showExportTextDelimitedCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'export-text-delimited').length === 0) {
if (this._gridOptions && this._gridOptions.enableExport && this._gridOptions.gridMenu && !this._gridOptions.gridMenu.hideExportTextDelimitedCommand && this._gridOptions.gridMenu.customItems && this._gridOptions.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'export-text-delimited').length === 0) {
this._gridOptions.gridMenu.customItems.push(
{
iconCssClass: this._gridOptions.gridMenu.iconExportTextDelimitedCommand || 'fa fa-download',
Expand Down Expand Up @@ -780,9 +780,9 @@ export class ControlAndPluginService {
menuWidth: 18,
customTitle: undefined,
customItems: [],
showClearAllFiltersCommand: true,
showRefreshDatasetCommand: true,
showToggleFilterCommand: true
hideClearAllFiltersCommand: false,
hideRefreshDatasetCommand: false,
hideToggleFilterCommand: false
};
}

Expand Down
4 changes: 2 additions & 2 deletions aurelia-slickgrid/src/examples/slickgrid/example12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export class Example12 {
sanitizeDataExport: true
},
gridMenu: {
showExportCsvCommand: true, // true by default, so it's optional
showExportTextDelimitedCommand: true // false by default, so if you want it, you will need to enable it
hideExportCsvCommand: false, // false by default, so it's optional
hideExportTextDelimitedCommand: false // true by default, so if you want it, you will need to disable the flag
},
params: {
i18n: this.i18n
Expand Down

0 comments on commit aa32a56

Please sign in to comment.