-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin-ui): Correctly display configurable money values
- Loading branch information
1 parent
1b13aa3
commit 3546071
Showing
11 changed files
with
81 additions
and
4 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { SentenceCasePipe } from './sentence-case.pipe'; | ||
|
||
describe('SentenceCasePipe:', () => { | ||
let sentenceCasePipe: SentenceCasePipe; | ||
beforeEach(() => (sentenceCasePipe = new SentenceCasePipe())); | ||
|
||
it('works with multiple words', () => { | ||
expect(sentenceCasePipe.transform('foo bar baz')).toBe('Foo bar baz'); | ||
expect(sentenceCasePipe.transform('fOo BAR baZ')).toBe('Foo bar baz'); | ||
}); | ||
|
||
it('splits camelCase', () => { | ||
expect(sentenceCasePipe.transform('fooBarBaz')).toBe('Foo bar baz'); | ||
expect(sentenceCasePipe.transform('FooBarbaz')).toBe('Foo barbaz'); | ||
}); | ||
|
||
it('unexpected input', () => { | ||
expect(sentenceCasePipe.transform(null as any)).toBe(null); | ||
expect(sentenceCasePipe.transform(undefined as any)).toBe(undefined); | ||
expect(sentenceCasePipe.transform([] as any)).toEqual([]); | ||
expect(sentenceCasePipe.transform(123 as any)).toEqual(123); | ||
}); | ||
}); |
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 { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
/** | ||
* Formats a string into sentence case (first letter of first word uppercase). | ||
*/ | ||
@Pipe({ name: 'sentenceCase' }) | ||
export class SentenceCasePipe implements PipeTransform { | ||
transform(value: any): any { | ||
if (typeof value === 'string') { | ||
let lower: string; | ||
if (isCamelCase(value)) { | ||
lower = value.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase(); | ||
} else { | ||
lower = value.toLowerCase(); | ||
} | ||
return lower.charAt(0).toUpperCase() + lower.slice(1); | ||
} | ||
return value; | ||
} | ||
} | ||
|
||
function isCamelCase(value: string): boolean { | ||
return /^[a-zA-Z]+[A-Z][a-zA-Z]+$/.test(value); | ||
} |
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