Skip to content

Commit

Permalink
Merge pull request #1604 from ghiscoding/chore/excel-export-cleanup
Browse files Browse the repository at this point in the history
chore(export): cleanup code in Excel Export
  • Loading branch information
ghiscoding authored Jul 13, 2024
2 parents a177fff + de9460d commit f03cc6c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
6 changes: 3 additions & 3 deletions packages/common/src/styles/slick-editors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@
&.outside {
@media only screen and (min-width: 769px) {
color: var(--slick-editor-modal-close-btn-outside-color, $slick-editor-modal-close-btn-outside-color);
&:hover {
color: var(--slick-editor-modal-close-btn-outside-color-hover, $slick-editor-modal-close-btn-outside-color-hover);
}
font-size: var(--slick-editor-modal-close-btn-outside-font-size, $slick-editor-modal-close-btn-outside-font-size);
right: var(--slick-editor-modal-close-btn-outside-right, $slick-editor-modal-close-btn-outside-right);
top: var(--slick-editor-modal-close-btn-outside-top, $slick-editor-modal-close-btn-outside-top);
&:hover {
color: var(--slick-editor-modal-close-btn-outside-color-hover, $slick-editor-modal-close-btn-outside-color-hover);
}
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions packages/common/src/styles/slick-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@
}
}
&.odd .slick-cell {
background: inherit;
&.selected {
background-color: var(--slick-row-selected-color, $slick-row-selected-color);
}
&.copied {
background: var(--slick-copied-cell-bg-color-transition, $slick-copied-cell-bg-color-transition);
transition: var(--slick-copied-cell-transition, $slick-copied-cell-transition);
}
background: inherit;
}
&.highlight {
background: var(--slick-row-highlight-background-color, $slick-row-highlight-background-color);
Expand Down Expand Up @@ -629,11 +629,13 @@

@mixin ResetColumns () {
/* like TH */
background: var(--slick-header-background-color, $slick-header-background-color);
font-family: var(--slick-font-family, $slick-font-family);
color: var(--slick-header-text-color, $slick-header-text-color);
font-size: var(--slick-header-font-size, $slick-header-font-size);
font-weight: var(--slick-header-font-weight, $slick-header-font-weight);
& {
background: var(--slick-header-background-color, $slick-header-background-color);
font-family: var(--slick-font-family, $slick-font-family);
color: var(--slick-header-text-color, $slick-header-text-color);
font-size: var(--slick-header-font-size, $slick-header-font-size);
font-weight: var(--slick-header-font-weight, $slick-header-font-weight);
}
a, a:visited {
color: var(--slick-text-color, $slick-text-color);
}
Expand Down
33 changes: 16 additions & 17 deletions packages/common/src/styles/slick-plugins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ li.hidden {
min-width: var(--slick-column-picker-min-width, $slick-column-picker-min-width);
padding: var(--slick-column-picker-padding, $slick-column-picker-padding);
scrollbar-color: var(--slick-scrollbar-color, $slick-scrollbar-color);
box-shadow: var(--slick-column-picker-box-shadow, $slick-column-picker-box-shadow);
z-index: var(--slick-column-picker-z-index, $slick-column-picker-z-index);
@-moz-document url-prefix() {
/* add right padding to avoid scrollback showing over text, that is for Firefox since WebKit is ok */
padding: var(--slick-column-picker-padding-firefox, $slick-column-picker-padding-firefox);
}
box-shadow: var(--slick-column-picker-box-shadow, $slick-column-picker-box-shadow);
z-index: var(--slick-column-picker-z-index, $slick-column-picker-z-index);

.close {
float: right;
Expand Down Expand Up @@ -174,13 +174,13 @@ li.hidden {
&.mdi-icon-picker-uncheck {
@include generateSvgStyle('slick-column-picker-icon-unchecked-svg', $slick-column-picker-icon-unchecked-svg-path);
opacity: var(--slick-column-picker-unchecked-opacity, $slick-column-picker-unchecked-opacity); /* unchecked icon */
&:hover {
opacity: var(--slick-column-picker-opacity-hover, $slick-column-picker-opacity-hover);
}

// since we use the div container with a border, we don't actually need an icon for unchecked
// BUT since we want to keep the same size, we can simply hide the mask to keep the same size
visibility: var(--slick-column-picker-icon-unchecked-color-visibility, $slick-column-picker-icon-unchecked-color-visibility);
&:hover {
opacity: var(--slick-column-picker-opacity-hover, $slick-column-picker-opacity-hover);
}
}
}
& + span.checkbox-label {
Expand Down Expand Up @@ -407,16 +407,16 @@ li.hidden {
border-radius: var(--slick-menu-border-radius, $slick-menu-border-radius);
min-width: var(--slick-menu-min-width, $slick-menu-min-width);
padding: var(--slick-menu-padding, $slick-menu-padding);
@-moz-document url-prefix() {
/* add right padding to avoid scrollback showing over text, that is for Firefox since WebKit is ok */
padding: var(--slick-menu-padding-firefox, $slick-menu-padding-firefox);
}
z-index: 100000;
cursor: default;
display: inline-block;
overflow-x: hidden;
overflow-y: auto;
resize: both;
z-index: 100000;
@-moz-document url-prefix() {
/* add right padding to avoid scrollback showing over text, that is for Firefox since WebKit is ok */
padding: var(--slick-menu-padding-firefox, $slick-menu-padding-firefox);
}

/* make sure that other UI frameworks aren't overriding our properties (Bulma was one of them affecting this) */
&.dropdown,
Expand Down Expand Up @@ -624,13 +624,13 @@ li.hidden {
&.mdi-icon-uncheck {
@include generateSvgStyle('slick-checkbox-icon-unchecked-svg', $slick-checkbox-icon-unchecked-svg-path);
opacity: var(--slick-checkbox-unchecked-opacity, $slick-checkbox-unchecked-opacity); /* unchecked icon */
&:hover {
opacity: var(--slick-checkbox-opacity-hover, $slick-checkbox-opacity-hover);
}

// since we use the div container with a border, we don't actually need an icon for unchecked
// BUT since we want to keep the same size, we can simply hide the mask to keep the same size
visibility: var(--slick-checkbox-icon-unchecked-color-visibility, $slick-checkbox-icon-unchecked-color-visibility);
&:hover {
opacity: var(--slick-checkbox-opacity-hover, $slick-checkbox-opacity-hover);
}
}
}
}
Expand Down Expand Up @@ -1036,6 +1036,9 @@ input.search-filter {
height: var(--slick-slider-filter-height, $slick-slider-filter-height);
padding: var(--slick-slider-filter-runnable-track-padding, $slick-slider-filter-runnable-track-padding);

/*fix for FF unable to apply focus style bug */
border: var(--slick-slider-filter-border, $slick-slider-filter-border);

/* change runnable track color while in focus on all browsers */
&:focus {
outline: none;
Expand All @@ -1061,10 +1064,6 @@ input.search-filter {
}

/* Mozilla Firefox specific */

/*fix for FF unable to apply focus style bug */
border: var(--slick-slider-filter-border, $slick-slider-filter-border);

&::-moz-range-track {
height: var(--slick-slider-filter-runnable-track-height, $slick-slider-filter-runnable-track-height);
border: none;
Expand Down
21 changes: 8 additions & 13 deletions packages/excel-export/src/excelExport.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
// wrap in a Promise so that we can add loading spinner
return new Promise(resolve => {
// prepare the Excel Workbook & Sheet
// we can use ExcelBuilder constructor with WebPack but we need to use function calls with RequireJS/SystemJS
const worksheetOptions = { name: this._excelExportOptions.sheetName || 'Sheet1' };
this._workbook = new Workbook();
this._sheet = this._workbook.createWorksheet(worksheetOptions);
Expand All @@ -158,14 +157,10 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
const boldFormat = this._stylesheet.createFormat({ font: { bold: true } });
const stringFormat = this._stylesheet.createFormat({ format: '@' });
const numberFormat = this._stylesheet.createFormat({ format: '0' });
this._stylesheetFormats = {
boldFormat,
numberFormat,
stringFormat,
};
this._stylesheetFormats = { boldFormat, numberFormat, stringFormat };
this._sheet.setColumnFormats([boldFormat]);

// get the CSV output from the grid data
// get all data by reading all DataView rows
const dataOutput = this.getDataOutput();

// trigger a download file
Expand Down Expand Up @@ -344,7 +339,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
if (!groupByColumnHeader && this._gridOptions.enableTranslate && this._translaterService?.translate) {
groupByColumnHeader = this._translaterService.translate(`${getTranslationPrefix(this._gridOptions)}GROUP_BY`);
} else if (!groupByColumnHeader) {
groupByColumnHeader = this._locales && this._locales.TEXT_GROUP_BY;
groupByColumnHeader = this._locales?.TEXT_GROUP_BY;
}

// get grouped column titles and if found, we will add a "Group by" column at the first column index
Expand All @@ -366,7 +361,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
protected getColumnGroupedHeaderTitles(columns: Column[]): Array<KeyTitlePair> {
const groupedColumnHeaders: Array<KeyTitlePair> = [];

if (columns && Array.isArray(columns)) {
if (Array.isArray(columns)) {
// Populate the Grouped Column Header, pull the columnGroup(Key) defined
columns.forEach((columnDef) => {
let groupedHeaderTitle = '';
Expand Down Expand Up @@ -396,7 +391,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
protected getColumnHeaders(columns: Column[]): Array<KeyTitlePair> | null {
const columnHeaders: Array<KeyTitlePair> = [];

if (columns && Array.isArray(columns)) {
if (Array.isArray(columns)) {
// Populate the Column Header, pull the name defined
columns.forEach((columnDef) => {
let headerTitle = '';
Expand Down Expand Up @@ -570,9 +565,9 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
protected readGroupedRowTitle(itemObj: any): string {
const groupName = stripTags(itemObj.title);

if (this._excelExportOptions && this._excelExportOptions.addGroupIndentation) {
const collapsedSymbol = this._excelExportOptions && this._excelExportOptions.groupCollapsedSymbol || '⮞';
const expandedSymbol = this._excelExportOptions && this._excelExportOptions.groupExpandedSymbol || '⮟';
if (this._excelExportOptions?.addGroupIndentation) {
const collapsedSymbol = this._excelExportOptions?.groupCollapsedSymbol || '⮞';
const expandedSymbol = this._excelExportOptions?.groupExpandedSymbol || '⮟';
const chevron = itemObj.collapsed ? collapsedSymbol : expandedSymbol;
return chevron + ' ' + addWhiteSpaces(5 * itemObj.level) + groupName;
}
Expand Down

0 comments on commit f03cc6c

Please sign in to comment.