-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on refactor from class to functional
- Loading branch information
1 parent
5571ef3
commit c4d510b
Showing
16 changed files
with
1,090 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
export default function BooleanField(props) { | ||
return ( | ||
<FormControl error={Boolean(props.error)} component="fieldset"> | ||
<FormGroup> | ||
<FormControlLabel | ||
label="" | ||
control={ | ||
<Checkbox | ||
{...props} | ||
value={String(props.value)} | ||
checked={Boolean(props.value)} | ||
onChange={(event) => props.onChange(event.target.checked)} | ||
style={{ | ||
padding: 0, | ||
width: 24, | ||
marginLeft: 9 | ||
}} | ||
inputProps={{ | ||
'aria-label': props.columnDef.title | ||
}} | ||
/> | ||
} | ||
/> | ||
</FormGroup> | ||
<FormHelperText>{props.helperText}</FormHelperText> | ||
</FormControl> | ||
); | ||
} |
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,31 @@ | ||
import React from 'react'; | ||
|
||
export default function CurrencyField(props) { | ||
return ( | ||
<TextField | ||
{...props} | ||
placeholder={props.columnDef.editPlaceholder || props.columnDef.title} | ||
style={{ float: 'right' }} | ||
type="number" | ||
value={props.value === undefined ? '' : props.value} | ||
onChange={(event) => { | ||
let value = event.target.valueAsNumber; | ||
if (!value && value !== 0) { | ||
value = undefined; | ||
} | ||
return props.onChange(value); | ||
}} | ||
InputProps={{ | ||
style: { | ||
fontSize: 13, | ||
textAlign: 'right' | ||
} | ||
}} | ||
inputProps={{ | ||
'aria-label': props.columnDef.title | ||
}} | ||
onKeyDown={props.onKeyDown} | ||
autoFocus={props.autoFocus} | ||
/> | ||
); | ||
} |
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,51 @@ | ||
import React from 'react'; | ||
import DateFnsUtils from '@date-io/date-fns'; | ||
import { MuiPickersUtilsProvider, DatePicker } from '@material-ui/pickers'; | ||
|
||
export default function DateField({ | ||
columnDef, | ||
value, | ||
onChange, | ||
locale, | ||
...rest | ||
}) { | ||
const getProps = () => { | ||
const { | ||
columnDef, | ||
rowData, | ||
onRowDataChange, | ||
errorState, | ||
onBulkEditRowChanged, | ||
scrollWidth, | ||
...remaining | ||
} = rest; | ||
return remaining; | ||
}; | ||
|
||
const dateFormat = | ||
columnDef.dateSetting && columnDef.dateSetting.format | ||
? columnDef.dateSetting.format | ||
: 'dd.MM.yyyy'; | ||
|
||
const datePickerProps = getProps(); | ||
|
||
return ( | ||
<MuiPickersUtilsProvider utils={DateFnsUtils} locale={locale}> | ||
<DatePicker | ||
{...datePickerProps} | ||
format={dateFormat} | ||
value={value || null} | ||
onChange={onChange} | ||
clearable | ||
InputProps={{ | ||
style: { | ||
fontSize: 13 | ||
} | ||
}} | ||
inputProps={{ | ||
'aria-label': `${columnDef.title}: press space to edit` | ||
}} | ||
/> | ||
</MuiPickersUtilsProvider> | ||
); | ||
} |
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,25 @@ | ||
import React from 'react'; | ||
import DateFnsUtils from '@date-io/date-fns'; | ||
import { MuiPickersUtilsProvider, DateTimePicker } from '@material-ui/pickers'; | ||
|
||
export default function DateTimeField(props) { | ||
return ( | ||
<MuiPickersUtilsProvider utils={DateFnsUtils} locale={props.locale}> | ||
<DateTimePicker | ||
{...props} | ||
format="dd.MM.yyyy HH:mm:ss" | ||
value={props.value || null} | ||
onChange={props.onChange} | ||
clearable | ||
InputProps={{ | ||
style: { | ||
fontSize: 13 | ||
} | ||
}} | ||
inputProps={{ | ||
'aria-label': `${props.columnDef.title}: press space to edit` | ||
}} | ||
/> | ||
</MuiPickersUtilsProvider> | ||
); | ||
} |
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 React from 'react'; | ||
|
||
export default function LookupField(props) { | ||
return ( | ||
<FormControl error={Boolean(props.error)}> | ||
<Select | ||
{...props} | ||
value={props.value === undefined ? '' : props.value} | ||
onChange={(event) => props.onChange(event.target.value)} | ||
style={{ | ||
fontSize: 13 | ||
}} | ||
SelectDisplayProps={{ 'aria-label': props.columnDef.title }} | ||
> | ||
{Object.keys(props.columnDef.lookup).map((key) => ( | ||
<MenuItem key={key} value={key}> | ||
{props.columnDef.lookup[key]} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
{Boolean(helperText) && <FormHelperText>{helperText}</FormHelperText>} | ||
</FormControl> | ||
); | ||
} |
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,32 @@ | ||
import React from 'react'; | ||
|
||
let renders = 0; | ||
|
||
export default function TextField(props) { | ||
return ( | ||
<TextField | ||
{...props} | ||
fullWidth | ||
style={props.columnDef.type === 'numeric' ? { float: 'right' } : {}} | ||
type={props.columnDef.type === 'numeric' ? 'number' : 'text'} | ||
placeholder={props.columnDef.editPlaceholder || props.columnDef.title} | ||
value={props.value === undefined ? '' : props.value} | ||
onChange={(event) => | ||
props.onChange( | ||
props.columnDef.type === 'numeric' | ||
? event.target.valueAsNumber | ||
: event.target.value | ||
) | ||
} | ||
InputProps={{ | ||
style: { | ||
minWidth: 50, | ||
fontSize: 13 | ||
} | ||
}} | ||
inputProps={{ | ||
'aria-label': props.columnDef.title | ||
}} | ||
/> | ||
); | ||
} |
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 React from 'react'; | ||
import DateFnsUtils from '@date-io/date-fns'; | ||
|
||
export default function TimeField(props) { | ||
return ( | ||
<MuiPickersUtilsProvider utils={DateFnsUtils} locale={props.locale}> | ||
<TimePicker | ||
{...getProps()} | ||
format="HH:mm:ss" | ||
value={props.value || null} | ||
onChange={props.onChange} | ||
clearable | ||
InputProps={{ | ||
style: { | ||
fontSize: 13 | ||
} | ||
}} | ||
inputProps={{ | ||
'aria-label': `${props.columnDef.title}: press space to edit` | ||
}} | ||
/> | ||
</MuiPickersUtilsProvider> | ||
); | ||
} |
Oops, something went wrong.