@@ -84,7 +84,7 @@ const myCustomTitleValidator = (value: any, args: any) => {
84
84
encapsulation : ViewEncapsulation . None ,
85
85
} )
86
86
export class GridCompositeEditorComponent implements OnDestroy , OnInit {
87
- private _darkModeGrid = false ;
87
+ private _darkMode = false ;
88
88
title = 'Example 30: Composite Editor Modal' ;
89
89
subTitle = `Composite Editor allows you to Create, Clone, Edit, Mass Update & Mass Selection Changes inside a nice Modal Window.
90
90
<br>The modal is simply populated by looping through your column definition list and also uses a lot of the same logic as inline editing (see <a href="https://ghiscoding.gitbook.io/angular-slickgrid/grid-functionalities/composite-editor-modal" target="_blank">Composite Editor - Uncyclo</a>.)` ;
@@ -384,7 +384,7 @@ export class GridCompositeEditorComponent implements OnDestroy, OnInit {
384
384
container : '#demo-container' ,
385
385
rightPadding : 10
386
386
} ,
387
- darkMode : this . _darkModeGrid ,
387
+ darkMode : this . _darkMode ,
388
388
enableAutoSizeColumns : true ,
389
389
enableAutoResize : true ,
390
390
showCustomFooter : true ,
@@ -443,6 +443,15 @@ export class GridCompositeEditorComponent implements OnDestroy, OnInit {
443
443
} ,
444
444
// when using the cellMenu, you can change some of the default options and all use some of the callback methods
445
445
enableCellMenu : true ,
446
+ gridMenu : {
447
+ hideToggleDarkModeCommand : false , // disabled command by default
448
+ onCommand : ( _ , args ) => {
449
+ if ( args . command === 'toggle-dark-mode' ) {
450
+ this . _darkMode = ! this . _darkMode ; // keep local toggle var in sync
451
+ this . toggleBodyBackground ( ) ;
452
+ }
453
+ }
454
+ }
446
455
} ;
447
456
}
448
457
@@ -625,7 +634,7 @@ export class GridCompositeEditorComponent implements OnDestroy, OnInit {
625
634
onRendered : ( modalElm ) => {
626
635
// Bootstrap requires extra attribute when toggling Dark Mode (data-bs-theme="dark")
627
636
// we need to manually add this attribute ourselve before opening the Composite Editor Modal
628
- modalElm . dataset . bsTheme = this . _darkModeGrid ? 'dark' : 'light' ;
637
+ modalElm . dataset . bsTheme = this . _darkMode ? 'dark' : 'light' ;
629
638
} ,
630
639
onSave : ( formValues , _selection , dataContext ) => {
631
640
const serverResponseDelay = 50 ;
@@ -762,16 +771,20 @@ export class GridCompositeEditorComponent implements OnDestroy, OnInit {
762
771
this . editQueue = [ ] ;
763
772
}
764
773
765
- toggleDarkModeGrid ( ) {
766
- this . _darkModeGrid = ! this . _darkModeGrid ;
767
- if ( this . _darkModeGrid ) {
774
+ toggleDarkMode ( ) {
775
+ this . _darkMode = ! this . _darkMode ;
776
+ this . toggleBodyBackground ( ) ;
777
+ this . angularGrid . slickGrid ?. setOptions ( { darkMode : this . _darkMode } ) ;
778
+ }
779
+
780
+ toggleBodyBackground ( ) {
781
+ if ( this . _darkMode ) {
768
782
document . querySelector < HTMLDivElement > ( '.panel-wm-content' ) ! . classList . add ( 'dark-mode' ) ;
769
783
document . querySelector < HTMLDivElement > ( '#demo-container' ) ! . dataset . bsTheme = 'dark' ;
770
784
} else {
771
785
document . querySelector ( '.panel-wm-content' ) ! . classList . remove ( 'dark-mode' ) ;
772
786
document . querySelector < HTMLDivElement > ( '#demo-container' ) ! . dataset . bsTheme = 'light' ;
773
787
}
774
- this . angularGrid . slickGrid ?. setOptions ( { darkMode : this . _darkModeGrid } ) ;
775
788
}
776
789
777
790
mockProducts ( ) {
0 commit comments