-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(presets): add missing row selections preset option (#11)
* feat(presets): add missing row selections preset option * feat(formatters): add new percentCompleteBarWithText Formatter same as percentCompleteBarFormatter but makes the progress bar thicker and also adds the % text inside the progress bar * fix(filter): Grid Preset Filters should work with Tree Data View - the Tree Data must execute pre-filtering with Tree Data when having Grid Preset Filters
- Loading branch information
1 parent
41a36cc
commit e0a729c
Showing
17 changed files
with
242 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/common/src/formatters/__tests__/percentCompleteBarWithTextFormatter.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Column } from '../../interfaces/index'; | ||
import { percentCompleteBarWithTextFormatter } from '../percentCompleteBarWithTextFormatter'; | ||
|
||
describe('the Percent Complete with Text Formatter', () => { | ||
it('should return an empty string when no value is provided', () => { | ||
const output = percentCompleteBarWithTextFormatter(1, 1, '', {} as Column, {}); | ||
expect(output).toBe(''); | ||
}); | ||
|
||
it('should return empty string when non-numeric value is provided', () => { | ||
const output = percentCompleteBarWithTextFormatter(1, 1, 'hello', {} as Column, {}); | ||
expect(output).toBe(''); | ||
}); | ||
|
||
it('should display a red color bar formatter when number 0 is provided', () => { | ||
const input = 0; | ||
const color = 'red'; | ||
const output = percentCompleteBarWithTextFormatter(1, 1, input, {} as Column, {}); | ||
expect(output).toBe(`<div class="percent-complete-bar-with-text" title="${input}%" style="background:${color}; width:${input}%">${input}%</div>`); | ||
}); | ||
|
||
it('should display a red color bar when value is a negative number', () => { | ||
const input = -15; | ||
const color = 'red'; | ||
const output = percentCompleteBarWithTextFormatter(1, 1, input, {} as Column, {}); | ||
expect(output).toBe(`<div class="percent-complete-bar-with-text" title="${input}%" style="background:${color}; width:${input}%">${input}%</div>`); | ||
}); | ||
|
||
it('should display a silver color bar when value is between 30 and 69', () => { | ||
const input1 = 30; | ||
const input2 = 69; | ||
const color = 'silver'; | ||
const output1 = percentCompleteBarWithTextFormatter(1, 1, input1, {} as Column, {}); | ||
const output2 = percentCompleteBarWithTextFormatter(1, 1, input2, {} as Column, {}); | ||
expect(output1).toBe(`<div class="percent-complete-bar-with-text" title="${input1}%" style="background:${color}; width:${input1}%">${input1}%</div>`); | ||
expect(output2).toBe(`<div class="percent-complete-bar-with-text" title="${input2}%" style="background:${color}; width:${input2}%">${input2}%</div>`); | ||
}); | ||
|
||
it('should display a green color bar when value greater or equal to 70 and is a type string', () => { | ||
const input = '70'; | ||
const color = 'green'; | ||
const output = percentCompleteBarWithTextFormatter(1, 1, input, {} as Column, {}); | ||
expect(output).toBe(`<div class="percent-complete-bar-with-text" title="${input}%" style="background:${color}; width:${input}%">${input}%</div>`); | ||
}); | ||
|
||
it('should display a green color bar with percentage of 100% when number is greater than 100 is provided', () => { | ||
const input = 125; | ||
const color = 'green'; | ||
const output = percentCompleteBarWithTextFormatter(1, 1, input, {} as Column, {}); | ||
expect(output).toBe(`<div class="percent-complete-bar-with-text" title="100%" style="background:${color}; width:100%">100%</div>`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/common/src/formatters/percentCompleteBarWithTextFormatter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Column, Formatter } from './../interfaces/index'; | ||
|
||
export const percentCompleteBarWithTextFormatter: Formatter = (row: number, cell: number, value: any, columnDef: Column, dataContext: any): string => { | ||
const isNumber = (value === null || value === undefined || value === '') ? false : !isNaN(+value); | ||
if (!isNumber) { | ||
return ''; | ||
} | ||
|
||
let color = ''; | ||
let inputNumber = parseFloat(value); | ||
if (inputNumber > 100) { | ||
inputNumber = 100; | ||
} | ||
|
||
if (inputNumber < 30) { | ||
color = 'red'; | ||
} else if (inputNumber < 70) { | ||
color = 'silver'; | ||
} else { | ||
color = 'green'; | ||
} | ||
|
||
return `<div class="percent-complete-bar-with-text" title="${inputNumber}%" style="background:${color}; width:${inputNumber}%">${inputNumber}%</div>`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+951 Bytes
(100%)
packages/vanilla-bundle/dist-grid-bundle-zip/slickgrid-vanilla-bundle.zip
Binary file not shown.
Oops, something went wrong.