Fix column selection features and button theme
0c93a153
dobromirts
committed
4 changed files
context-menu.component.html
/projects/igniteui-angular-extras/src/lib/context-menu/context-menu.component.html-1+1
/projects/igniteui-angular-extras/src/lib/context-menu/context-menu.component.html
Add comment 1 <span #analyticsBtn class="analytics-btn">
Add comment 2 Minus   <button #btn igxIconButton="flat" (click)="toggleTabMenu()">
Add comment 2 Plus   <button #btn class="analytics-button" igxIconButton="flat" (click)="toggleTabMenu()">
Add comment 3 <igx-icon #icon class="icon" family="material">insert_chart_outlined</igx-icon>
Add comment 4 </button>
Add comment 5 </span>
context-menu.component.scss
/projects/igniteui-angular-extras/src/lib/context-menu/context-menu.component.scss-6+15
/projects/igniteui-angular-extras/src/lib/context-menu/context-menu.component.scss
Add comment 5 $sb-size: 8px
Add comment 6 );
Add comment 7
Add comment 8 Minus  .analytics-btn {
Add comment 9 Minus   @include button(button-theme(
Add comment 10 Minus   $foreground: #fff,
Add comment 11 Minus   $background: #335e3b,
Add comment 12 Minus   $hover-background: #459a55,
Add comment 13 Minus   $border-radius: 0));
Add comment 8 Plus  :host ::ng-deep {
Add comment 9 Plus   $analytics-btn: button-theme(
Add comment 10 Plus   $foreground: contrast-color($color: 'gray', $variant: 900),
Add comment 11 Plus   $background: color($color: 'success', $variant: 500, $opacity: .8),
Add comment 12 Plus   $hover-background: color($color: 'success'),
Add comment 13 Plus   $hover-foreground: contrast-color($color: 'gray', $variant: 900),
Add comment 14 Plus   $focus-background: color($color: 'success'),
Add comment 15 Plus   $focus-foreground: contrast-color($color: 'gray', $variant: 900),
Add comment 16 Plus   $border-radius: 0
Add comment 17 Plus   );
Add comment 18 Plus  
Add comment 19 Plus   .analytics-button {
Add comment 20 Plus   @include css-vars($analytics-btn);
Add comment 21 Plus   --ig-size: var(--ig-size-small);
Add comment 22 Plus   }
Add comment 14 23 }
Add comment 15 24
Add comment 16 25 .disableButton {
igx-context-menu.directive.ts
/projects/igniteui-angular-extras/src/lib/context-menu/igx-context-menu.directive.ts-1+60
/projects/igniteui-angular-extras/src/lib/context-menu/igx-context-menu.directive.ts
Add comment 16 IgxOverlayService,
Add comment 17 OverlayCancelableEventArgs,
Add comment 18 VerticalAlignment,
Add comment 19 Minus   OverlaySettings
Add comment 19 Plus   OverlaySettings,
Add comment 20 Plus   IColumnSelectionEventArgs
Add comment 20 21 } from '@infragistics/igniteui-angular';
Add comment 21 22 import { Subject } from 'rxjs';
Add comment 22 23 import { debounceTime, filter, merge, takeUntil } from 'rxjs/operators';
Add comment 92 93 this.contentObserver = new ResizeObserver(() => this.gridResizeNotify.next());
Add comment 93 94 this.contentObserver.observe(this.grid.nativeElement);
Add comment 94 95
Add comment 96 Plus   this.grid.columnSelectionChanging.pipe(debounceTime(100))
Add comment 97 Plus   .subscribe((args: IColumnSelectionEventArgs) => {
Add comment 98 Plus   if (args.newSelection && args.oldSelection && !this._collapsed) {
Add comment 99 Plus   this.close();
Add comment 100 Plus   }
Add comment 101 Plus   this.grid.clearCellSelection();
Add comment 102 Plus   this.chartsDirective.chartData = this.grid.getSelectedColumnsData();
Add comment 103 Plus   if (!this._collapsed) {
Add comment 104 Plus   this.onButtonClose.emit();
Add comment 105 Plus   }
Add comment 106 Plus   this.renderHeaderButton();
Add comment 107 Plus   });
Add comment 108 Plus  
Add comment 95 109 this.grid.rangeSelected.pipe(takeUntil(this.destroy$))
Add comment 96 110 .subscribe((args) => {
Add comment 97 111 this._range = args;
Add comment 154 168 this._collapsed ? this.show() : this.overlayService.reposition(this._id);
Add comment 155 169 }
Add comment 156 170
Add comment 171 Plus   private renderHeaderButton() {
Add comment 172 Plus   const selectedColumns = this.grid.selectedColumns();
Add comment 173 Plus   if (selectedColumns.length === 0) {
Add comment 174 Plus   return;
Add comment 175 Plus   }
Add comment 176 Plus  
Add comment 177 Plus   this._analyticsBtnSettings.positionStrategy = new AutoPositionStrategy({
Add comment 178 Plus   horizontalDirection: HorizontalAlignment.Right,
Add comment 179 Plus   horizontalStartPoint: HorizontalAlignment.Right,
Add comment 180 Plus   verticalStartPoint: VerticalAlignment.Bottom,
Add comment 181 Plus   verticalDirection: VerticalAlignment.Bottom, closeAnimation: null
Add comment 182 Plus   });
Add comment 183 Plus  
Add comment 184 Plus   const selectedColumnsIndexes = selectedColumns.map(c => c.visibleIndex).sort((a, b) => a - b);
Add comment 185 Plus   let colIndex = selectedColumnsIndexes[selectedColumnsIndexes.length - 1];
Add comment 186 Plus   let rowIndex = undefined;
Add comment 187 Plus  
Add comment 188 Plus   while (selectedColumnsIndexes.length) {
Add comment 189 Plus   if (this.grid.navigation.isColumnFullyVisible(colIndex)) {
Add comment 190 Plus   break;
Add comment 191 Plus   }
Add comment 192 Plus   selectedColumnsIndexes.pop();
Add comment 193 Plus   colIndex = selectedColumnsIndexes[selectedColumnsIndexes.length - 1];
Add comment 194 Plus   }
Add comment 195 Plus  
Add comment 196 Plus   if (!selectedColumnsIndexes.length) {
Add comment 197 Plus   return;
Add comment 198 Plus   }
Add comment 199 Plus  
Add comment 200 Plus   const col = selectedColumns.find(c => c.visibleIndex === colIndex);
Add comment 201 Plus  
Add comment 202 Plus   if (!col) {
Add comment 203 Plus   return;
Add comment 204 Plus   }
Add comment 205 Plus  
Add comment 206 Plus   const headerCell = col.headerCell.nativeElement;
Add comment 207 Plus   this._analyticsBtnSettings.target = headerCell;
Add comment 208 Plus   this._analyticsBtnSettings.scrollStrategy = new AbsoluteScrollStrategy();
Add comment 209 Plus   const info = this.overlayService.getOverlayById(this._id);
Add comment 210 Plus   if (info) {
Add comment 211 Plus   info.settings.positionStrategy = this._analyticsBtnSettings.positionStrategy;
Add comment 212 Plus   }
Add comment 213 Plus   this._collapsed ? this.show() : this.overlayService.reposition(this._id);
Add comment 214 Plus   }
Add comment 215 Plus  
Add comment 157 216 private show() {
Add comment 158 217 if (!this._collapsed) { return; }
Add comment 159 218 this._collapsed = false;
grid-data-analysis.component.html
/src/app/grid-data-analysis/grid-data-analysis.component.html
/src/app/grid-data-analysis/grid-data-analysis.component.html