Browse Source
Merge pull request #6997 from PMExtra/ng-schematics-string-enum-patch
Fix enum file template with string enum.
pull/7057/head
Levent Arman Özak
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
1 deletions
-
npm/ng-packs/packages/schematics/src/commands/api/files-enum/proxy/__namespace@dir__/__name@kebab__.enum.ts.template
-
npm/ng-packs/packages/schematics/src/utils/text.ts
|
|
|
@ -2,7 +2,7 @@ import { mapEnumToOptions } from '@abp/ng.core'; |
|
|
|
|
|
|
|
export enum <%= name %> {<% |
|
|
|
for (let member of members) { %> |
|
|
|
<%= member.key %> = <%= member.value %>,<% } %> |
|
|
|
<%= member.key %> = <%= quote(member.value) %>,<% } %> |
|
|
|
} |
|
|
|
|
|
|
|
export const <%= camel(name) %>Options = mapEnumToOptions(<%= name %>); |
|
|
|
|
|
|
|
@ -10,6 +10,9 @@ export const macro = (text: string) => upper(snake(text)); |
|
|
|
export const dir = (text: string) => |
|
|
|
strings.dasherize(text.replace(/\./g, '/').replace(/\/\//g, '/')); |
|
|
|
|
|
|
|
export const quote = (value: number | string) => |
|
|
|
typeof value === 'string' ? `'${value.replace(/'/g, '\\\'')}'` : value; |
|
|
|
|
|
|
|
function _(text: string): string { |
|
|
|
return text.replace(/\./g, '_'); |
|
|
|
} |
|
|
|
|