Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 3f74d31

Browse files
committed
refactor: tweak and fix few styling issues with menus
1 parent 9dd661f commit 3f74d31

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

src/app/examples/grid-angular.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ export class GridAngularComponent implements OnInit {
259259
headerRowHeight: 45,
260260
rowHeight: 45, // increase row height so that the ng-select fits in the cell
261261
editable: true,
262+
enableCellMenu: true,
262263
enableCellNavigation: true,
263264
enableColumnPicker: true,
264265
enableExcelCopyBuffer: true,
@@ -269,7 +270,6 @@ export class GridAngularComponent implements OnInit {
269270
this._commandQueue.push(editCommand);
270271
editCommand.execute();
271272
},
272-
enableCellMenu: true,
273273
i18n: this.translate,
274274
params: {
275275
angularUtilService: this.angularUtilService // provide the service to all at once (Editor, Filter, AsyncPostRender)

src/app/examples/grid-contextmenu.component.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
Formatter,
1414
Formatters,
1515
GridOption,
16-
SlickCellMenu,
17-
SlickContextMenu,
1816
unsubscribeAllObservables,
1917
} from './../modules/angular-slickgrid';
2018

@@ -110,12 +108,12 @@ export class GridContextMenuComponent implements OnInit, OnDestroy {
110108
this.angularGrid = angularGrid;
111109
}
112110

113-
get cellMenuInstance(): SlickCellMenu {
114-
return (this.angularGrid?.extensionService?.getExtensionInstanceByName?.(ExtensionName.cellMenu) ?? {});
111+
get cellMenuInstance() {
112+
return this.angularGrid?.extensionService?.getExtensionInstanceByName(ExtensionName.cellMenu);
115113
}
116114

117-
get contextMenuInstance(): SlickContextMenu {
118-
return (this.angularGrid?.extensionService?.getExtensionInstanceByName?.(ExtensionName.contextMenu) ?? {});
115+
get contextMenuInstance() {
116+
return this.angularGrid?.extensionService?.getExtensionInstanceByName(ExtensionName.contextMenu);
119117
}
120118

121119
ngOnInit() {
@@ -434,7 +432,7 @@ export class GridContextMenuComponent implements OnInit, OnDestroy {
434432
onOptionSelected: ((e, args) => {
435433
// change Priority
436434
const dataContext = args && args.dataContext;
437-
if (dataContext && dataContext.hasOwnProperty('priority')) {
435+
if (dataContext?.hasOwnProperty('priority')) {
438436
dataContext.priority = args.item.option;
439437
this.angularGrid.gridService.updateItem(dataContext);
440438
}
@@ -446,15 +444,15 @@ export class GridContextMenuComponent implements OnInit, OnDestroy {
446444
// when showing both Commands/Options, we can just pass an empty array to show over all columns
447445
// else show on all columns except Priority
448446
const showOverColumnIds = showBothList ? [] : ['id', 'title', 'complete', 'start', 'finish', 'completed', 'action'];
449-
this.contextMenuInstance.setOptions({
447+
this.contextMenuInstance?.setOptions({
450448
commandShownOverColumnIds: showOverColumnIds,
451449
// hideCommandSection: !showBothList
452450
});
453451
}
454452

455453
showCellMenuCommandsAndOptions(showBothList: boolean) {
456454
// change via the plugin setOptions
457-
this.cellMenuInstance.setOptions({
455+
this.cellMenuInstance?.setOptions({
458456
hideOptionSection: !showBothList
459457
});
460458

src/app/examples/grid-menu.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
2-
import { AngularGridInstance, Column, ExtensionName, FieldType, Filters, Formatters, GridOption, SlickGridMenu, unsubscribeAllObservables } from './../modules/angular-slickgrid';
2+
import { AngularGridInstance, Column, ExtensionName, FieldType, Filters, Formatters, GridOption, unsubscribeAllObservables } from './../modules/angular-slickgrid';
33
import { TranslateService } from '@ngx-translate/core';
44
import { Subscription } from 'rxjs';
55

src/app/examples/grid-rowdetail.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class GridRowDetailComponent implements OnInit {
3232
columnDefinitions!: Column[];
3333
gridOptions!: GridOption;
3434
dataset!: any[];
35-
extensions!: ExtensionList<any>;
3635
detailViewRowCount = 9;
3736
message = '';
3837
flashAlertType = 'info';
@@ -49,8 +48,8 @@ export class GridRowDetailComponent implements OnInit {
4948
// option 1
5049
return (this.angularGrid.extensions.rowDetailView.instance || {});
5150

52-
// OR options 2
53-
// return (this.angularGrid && this.angularGrid.extensionService.getExtensionInstanceByName(ExtensionName.rowDetailView) || {});
51+
// OR option 2
52+
// return this.angularGrid?.extensionService.getExtensionInstanceByName(ExtensionName.rowDetailView) || {};
5453
}
5554

5655
ngOnInit(): void {
@@ -120,7 +119,7 @@ export class GridRowDetailComponent implements OnInit {
120119

121120
// you can override the logic for showing (or not) the expand icon
122121
// for example, display the expand icon only on every 2nd row
123-
// expandableOverride: (row: number, dataContext: any, grid: SlickGrid) => (dataContext.rowId % 2 === 1),
122+
// expandableOverride: (row: number, dataContext: any) => (dataContext.rowId % 2 === 1),
124123

125124
// Preload View Component
126125
preloadComponent: RowDetailPreloadComponent,

src/app/examples/grid-rowmove.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export class GridRowMoveComponent implements OnInit {
3232
this.angularGrid = angularGrid;
3333
}
3434

35-
get rowMoveInstance(): SlickRowMoveManager {
36-
return (this.angularGrid?.extensionService?.getExtensionInstanceByName?.(ExtensionName.rowMoveManager) ?? {});
35+
get rowMoveInstance() {
36+
return this.angularGrid?.extensionService?.getExtensionInstanceByName(ExtensionName.rowMoveManager) ?? {};
3737
}
3838

3939
ngOnInit(): void {

src/app/modules/angular-slickgrid/extensions/slickRowDetailView.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'slickgrid/plugins/slick.rowdetailview';
22
import 'slickgrid/plugins/slick.rowselectionmodel';
33

4-
import { ApplicationRef, ComponentRef, Injectable, Type, ViewContainerRef } from '@angular/core';
4+
import { ApplicationRef, ComponentRef, Type, ViewContainerRef } from '@angular/core';
55
import {
66
addToArrayWhenNotExists,
77
castObservableToPromise,
@@ -13,8 +13,7 @@ import {
1313
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
1414
import { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';
1515
import { Observable, Subject, Subscription } from 'rxjs';
16-
import * as DOMPurify_ from 'dompurify';
17-
const DOMPurify = DOMPurify_; // patch to fix rollup to work
16+
import * as DOMPurify from 'dompurify';
1817

1918
import { GridOption, RowDetailView } from '../models/index';
2019
import { AngularUtilService } from '../services/angularUtil.service';
@@ -29,7 +28,6 @@ export interface CreatedView {
2928
componentRef?: ComponentRef<any>;
3029
}
3130

32-
@Injectable()
3331
export class SlickRowDetailView extends UniversalSlickRowDetailView {
3432
rowDetailContainer!: ViewContainerRef;
3533
protected _eventHandler!: SlickEventHandler;

0 commit comments

Comments
 (0)