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
Ghislain Beaulac authored and Ghislain Beaulac committed May 23, 2018
1 parent 9650568 commit 2985528
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/app/examples/grid-localization.component.ts
Expand Up @@ -100,8 +100,8 @@ export class GridLocalizationComponent implements OnInit {
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.translate
Expand Down
11 changes: 6 additions & 5 deletions src/app/modules/angular-slickgrid/global-grid-options.ts
Expand Up @@ -59,11 +59,12 @@ export const GlobalGridOptions: GridOption = {
iconToggleFilterCommand: 'fa fa-random',
menuWidth: 16,
resizeOnShowHeaderRow: true,
showClearAllFiltersCommand: true,
showClearAllSortingCommand: true,
showExportCsvCommand: true,
showRefreshDatasetCommand: true,
showToggleFilterCommand: true
hideClearAllFiltersCommand: false,
hideClearAllSortingCommand: false,
hideExportCsvCommand: false,
hideExportTextDelimitedCommand: true,
hideRefreshDatasetCommand: false,
hideToggleFilterCommand: false
},
headerMenu: {
autoAlign: true,
Expand Down
36 changes: 18 additions & 18 deletions src/app/modules/angular-slickgrid/models/gridMenu.interface.ts
Expand Up @@ -25,12 +25,30 @@ export interface GridMenu {
/** 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, which will show the "Clear All Filters" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
hideClearAllFiltersCommand?: boolean;

/** Defaults to True, which will show the "Clear All Sorting" command in the Grid Menu (Grid Option "enableSorting: true" has to be enabled) */
hideClearAllSortingCommand?: boolean;

/** Defaults to True, which will show 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 "Export to Text Delimited" command in the Grid Menu (Grid Option "enableExport: true" has to be enabled) */
hideExportTextDelimitedCommand?: boolean;

/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideForceFitButton?: boolean;

/** Defaults to True, which will show the "Refresh Dataset" command in the Grid Menu (only works with a Backend Service API) */
hideRefreshDatasetCommand?: boolean;

/** Defaults to True, show/hide 1 of the last 2 checkbox at the end of the picker list */
hideSyncResizeButton?: boolean;

/** Defaults to True, which will show the "Toggle Filter Row" command in the Grid Menu (Grid Option "enableFiltering: true" has to be enabled) */
hideToggleFilterCommand?: boolean;

/** icon for the "Clear All Filters" command */
iconClearAllFiltersCommand?: string;

Expand All @@ -52,24 +70,6 @@ export interface GridMenu {
/** 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 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 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 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 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 True, which will show the "Refresh Dataset" command in the Grid Menu (only works with a Backend Service API) */
showRefreshDatasetCommand?: 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;

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

Expand Down
Expand Up @@ -410,7 +410,7 @@ export class ControlAndPluginService {

if (options.enableFiltering) {
// show grid menu: clear all filters
if (options && options.gridMenu && options.gridMenu.showClearAllFiltersCommand && options.gridMenu.customItems && options.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'clear-filter').length === 0) {
if (options && options.gridMenu && !options.gridMenu.hideClearAllFiltersCommand && options.gridMenu.customItems && options.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'clear-filter').length === 0) {
options.gridMenu.customItems.push(
{
iconCssClass: options.gridMenu.iconClearAllFiltersCommand || 'fa fa-filter text-danger',
Expand All @@ -423,7 +423,7 @@ export class ControlAndPluginService {
}

// show grid menu: toggle filter row
if (options && options.gridMenu && options.gridMenu.showToggleFilterCommand && options.gridMenu.customItems && options.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'toggle-filter').length === 0) {
if (options && options.gridMenu && !options.gridMenu.hideToggleFilterCommand && options.gridMenu.customItems && options.gridMenu.customItems.filter((item: CustomGridMenu) => item.command === 'toggle-filter').length === 0) {
options.gridMenu.customItems.push(
{
iconCssClass: options.gridMenu.iconToggleFilterCommand || 'fa fa-random',
Expand All @@ -436,7 +436,7 @@ export class ControlAndPluginService {
}

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

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

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

Expand Down

0 comments on commit 2985528

Please sign in to comment.