-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ComponentDisplay to typescript enum. remove 'enum' from dependencies. TS errors remaining: 133 in 35 files
- Loading branch information
Showing
9 changed files
with
76 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
import Enum from 'enum'; | ||
|
||
export default new Enum({ | ||
enum ComponentDisplay { | ||
// This enum is actually declared in dynamicforms.mixins.field_render.py | ||
TABLE: 1, | ||
FORM: 2, | ||
DIALOG: 3, | ||
}, { freeze: true }); | ||
TABLE = 1, | ||
FORM = 2, | ||
DIALOG = 3, | ||
} | ||
|
||
namespace ComponentDisplay { | ||
export function fromString(display: string) { | ||
if (display.toUpperCase() === 'TABLE') return ComponentDisplay.TABLE; | ||
if (display.toUpperCase() === 'FORM') return ComponentDisplay.FORM; | ||
if (display.toUpperCase() === 'DIALOG') return ComponentDisplay.DIALOG; | ||
return ComponentDisplay.TABLE; | ||
} | ||
|
||
export function isDefined(display: number | string) { | ||
const check = (typeof display === 'number') ? display : ComponentDisplay.fromString(display as string); | ||
return Object.values(ComponentDisplay).includes(check); | ||
} | ||
} | ||
|
||
Object.freeze(ComponentDisplay); | ||
|
||
export default ComponentDisplay; |
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