Integrating new form binder
This commit is contained in:
6
website/package-lock.json
generated
6
website/package-lock.json
generated
@@ -10214,9 +10214,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-form-binder": {
|
"react-form-binder": {
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-form-binder/-/react-form-binder-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-form-binder/-/react-form-binder-1.2.0.tgz",
|
||||||
"integrity": "sha512-48bPtvfHTsgi8CBbKx3FHNI2H6xwCbVHkZn+wjmTUcqfdug/M7qev6+ssvwU16USSr+IHu8bUJVD3Q0xYT8o1Q==",
|
"integrity": "sha512-VFeiB5nCe01WU5aVJILMw7GLgOPsYJvdJEL9WRz7qecKDZx30sKA5bLDOWHsWQDZhediIr3KLpFkPxj0u89tDg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"eventemitter3": "2.0.3",
|
"eventemitter3": "2.0.3",
|
||||||
"prop-types": "15.6.0",
|
"prop-types": "15.6.0",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"radium": "^0.22.0",
|
"radium": "^0.22.0",
|
||||||
"react": "^16.2.0",
|
"react": "^16.2.0",
|
||||||
"react-dom": "^16.2.0",
|
"react-dom": "^16.2.0",
|
||||||
"react-form-binder": "^1.1.0",
|
"react-form-binder": "^1.2.0",
|
||||||
"react-router-dom": "^4.1.1",
|
"react-router-dom": "^4.1.1",
|
||||||
"regexp-pattern": "^1.0.4",
|
"regexp-pattern": "^1.0.4",
|
||||||
"socket.io-client": "^2.0.3"
|
"socket.io-client": "^2.0.3"
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ export class App extends Component {
|
|||||||
window.location.replace('/')
|
window.location.replace('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleProfile() {
|
||||||
|
window.location.replace('/profile')
|
||||||
|
}
|
||||||
|
|
||||||
handleChangeTitle(title) {
|
handleChangeTitle(title) {
|
||||||
this.setState({ title })
|
this.setState({ title })
|
||||||
}
|
}
|
||||||
@@ -66,6 +70,7 @@ export class App extends Component {
|
|||||||
)
|
)
|
||||||
headerButtonsRight = (
|
headerButtonsRight = (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
<HeaderButton icon='profile' onClick={this.handleProfile} />
|
||||||
<HeaderButton icon='logout' onClick={this.handleLogout} />
|
<HeaderButton icon='logout' onClick={this.handleLogout} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
@@ -75,7 +80,7 @@ export class App extends Component {
|
|||||||
<Router basename='/'>
|
<Router basename='/'>
|
||||||
<Column minHeight='100vh'>
|
<Column minHeight='100vh'>
|
||||||
<Column.Item height={sizeInfo.headerHeight - sizeInfo.headerBorderWidth}>
|
<Column.Item height={sizeInfo.headerHeight - sizeInfo.headerBorderWidth}>
|
||||||
<Box color={colorInfo.headerButtonBackground} borderBottom={`${sizeInfo.headerBorderWidth}px solid ${colorInfo.headerBorder}`}>
|
<Box background={colorInfo.headerButtonBackground} borderBottom={{ width: sizeInfo.headerBorderWidth, color: colorInfo.headerBorder }}>
|
||||||
<Row minWidth='100vw'>
|
<Row minWidth='100vw'>
|
||||||
<Row.Item>{headerButtonsLeft}</Row.Item>
|
<Row.Item>{headerButtonsLeft}</Row.Item>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
@@ -96,7 +101,7 @@ export class App extends Component {
|
|||||||
<ProtectedRoute path='/' component={Home} />
|
<ProtectedRoute path='/' component={Home} />
|
||||||
</Switch>
|
</Switch>
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<Box color={colorInfo.headerButtonBackground} borderTop={`${sizeInfo.headerBorderWidth}px solid ${colorInfo.headerBorder}`}>
|
<Box background={colorInfo.headerButtonBackground} borderTop={{ width: sizeInfo.headerBorderWidth, color: colorInfo.headerBorder }}>
|
||||||
<Text color='dimmed' margin={10}>{'v' + versionInfo.version} {versionInfo.copyright}</Text>
|
<Text color='dimmed' margin={10}>{'v' + versionInfo.version} {versionInfo.copyright}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class ForgotPassword extends React.Component {
|
|||||||
isValid: (r, v) => (regExpPattern.email.test(v))
|
isValid: (r, v) => (regExpPattern.email.test(v))
|
||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class Login extends Component {
|
|||||||
initValue: true
|
initValue: true
|
||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class ResetPassword extends React.Component {
|
|||||||
isValid: (r, v) => (v !== '' && v === r.getField('newPassword').value)
|
isValid: (r, v) => (v !== '' && v === r.getField('newPassword').value)
|
||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified && !r.allValid)
|
isDisabled: (r) => (!r.anyModified && !r.allValid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class ChangeEmailModal extends React.Component {
|
|||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
isDisabled: (r) => (!r.allValid),
|
isDisabled: (r) => (!r.allValid),
|
||||||
nonValue: true
|
noValue: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export class ChangePasswordModal extends React.Component {
|
|||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
isDisabled: (r) => (!r.allValid),
|
isDisabled: (r) => (!r.allValid),
|
||||||
nonValue: true
|
noValue: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export class ProfileForm extends React.Component {
|
|||||||
isValid: (r, v) => (v === '' || regExpPattern.ssn.test(v))
|
isValid: (r, v) => (v === '' || regExpPattern.ssn.test(v))
|
||||||
},
|
},
|
||||||
save: {
|
save: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ export class UserForm extends React.Component {
|
|||||||
isDisabled: (r) => (r._id)
|
isDisabled: (r) => (r._id)
|
||||||
},
|
},
|
||||||
emailValidated: {
|
emailValidated: {
|
||||||
|
initValue: false,
|
||||||
isDisabled: (r) => (!r._id)
|
isDisabled: (r) => (!r._id)
|
||||||
},
|
},
|
||||||
changeEmail: {
|
changeEmail: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r._id)
|
isDisabled: (r) => (!r._id)
|
||||||
},
|
},
|
||||||
resendEmail: {
|
resendEmail: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r._id || !!r.getFieldValue('emailValidated'))
|
isDisabled: (r) => (!r._id || !!r.getFieldValue('emailValidated'))
|
||||||
},
|
},
|
||||||
firstName: {
|
firstName: {
|
||||||
@@ -41,20 +42,23 @@ export class UserForm extends React.Component {
|
|||||||
},
|
},
|
||||||
administrator: {
|
administrator: {
|
||||||
isValid: (r, v) => true,
|
isValid: (r, v) => true,
|
||||||
|
initValue: false,
|
||||||
isDisabled: (r) => (api.loggedInUser._id === r._id), // Adding a new user
|
isDisabled: (r) => (api.loggedInUser._id === r._id), // Adding a new user
|
||||||
alwaysGet: true,
|
alwaysGet: true,
|
||||||
},
|
},
|
||||||
remove: {
|
remove: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isVisible: (r) => (r._id),
|
isVisible: (r) => (r._id),
|
||||||
isDisabled: (r) => (api.loggedInUser._id === r._id)
|
isDisabled: (r) => (api.loggedInUser._id === r._id)
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified)
|
isDisabled: (r) => {
|
||||||
|
return !r.anyModified
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
nonValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified || !r.allValid),
|
isDisabled: (r) => (!r.anyModified || !r.allValid),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ export class Users extends Component {
|
|||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={20} />
|
<Row.Item width={20} />
|
||||||
<Row.Item grow>
|
<Row.Item grow>
|
||||||
<Box border={`${sizeInfo.headerBorderWidth}px solid ${colorInfo.headerBorder}`} radius={sizeInfo.formBoxRadius}>
|
<Box border={{ width: sizeInfo.headerBorderWidth, color: colorInfo.headerBorder }} radius={sizeInfo.formBoxRadius}>
|
||||||
{
|
{
|
||||||
this.state.selectedUser
|
this.state.selectedUser
|
||||||
? <UserForm user={this.state.selectedUser} onSave={this.handleSave}
|
? <UserForm user={this.state.selectedUser} onSave={this.handleSave}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Checkbox } from 'ui'
|
import { Checkbox } from 'ui'
|
||||||
import { reactAutoBind } from 'auto-bind2'
|
import { reactAutoBind } from 'auto-bind2'
|
||||||
|
import { fontInfo } from 'ui/style'
|
||||||
|
|
||||||
export default class BoundCheckbox extends React.Component {
|
export default class BoundCheckbox extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -36,7 +37,20 @@ export default class BoundCheckbox extends React.Component {
|
|||||||
const { visible, disabled, value } = this.state
|
const { visible, disabled, value } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Checkbox visible={visible} disabled={disabled} value={!!value} name={name} label={label} />
|
<div style={visible ? {} : { display: 'none' }}>
|
||||||
|
<Checkbox id={name} disabled={disabled} value={value} onChange={this.handleChange} />
|
||||||
|
<label
|
||||||
|
htmlFor={name}
|
||||||
|
style={{
|
||||||
|
marginLeft: 10,
|
||||||
|
verticalAlign: 'top',
|
||||||
|
fontSize: fontInfo.size.medium,
|
||||||
|
fontFamily: fontInfo.family,
|
||||||
|
color: disabled ? fontInfo.color.dimmed : fontInfo.color.normal,
|
||||||
|
}}>
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,15 +17,36 @@ class Box extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children, background, borderTop, borderBottom, borderLeft,
|
let {
|
||||||
borderRight, border, radius } = this.props
|
children, background,
|
||||||
|
borderTop, borderBottom, borderLeft, borderRight,
|
||||||
|
border, radius } = this.props
|
||||||
|
const flatten = (border) => {
|
||||||
|
if (!border) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
border.style = border.style || 'solid'
|
||||||
|
border.width = border.width || 1
|
||||||
|
border.color = border.color || 'black'
|
||||||
|
|
||||||
|
return (border.width.toString() + 'px ' + border.style + ' ' + border.color)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border) {
|
||||||
|
borderTop = borderBottom = borderLeft = borderRight = flatten(border)
|
||||||
|
} else {
|
||||||
|
borderTop = flatten(borderTop)
|
||||||
|
borderBottom = flatten(borderBottom)
|
||||||
|
borderLeft = flatten(borderLeft)
|
||||||
|
borderRight = flatten(borderRight)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={[
|
<div style={[
|
||||||
{ height: '100%', width: '100%' },
|
{ height: '100%', width: '100%', borderTop, borderBottom, borderLeft, borderRight },
|
||||||
background && { backgroundColor: background },
|
background && { backgroundColor: background },
|
||||||
radius && { borderRadius: radius },
|
radius && { borderRadius: radius },
|
||||||
border ? { border } : { borderTop, borderBottom, borderLeft, borderRight },
|
|
||||||
]}>
|
]}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ import Radium from 'radium'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { reactAutoBind } from 'auto-bind2'
|
import { reactAutoBind } from 'auto-bind2'
|
||||||
import { fontInfo, colorInfo, sizeInfo } from './style'
|
import { colorInfo, sizeInfo } from './style'
|
||||||
|
|
||||||
class Checkbox extends Component {
|
class Checkbox extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
value: PropTypes.bool,
|
value: PropTypes.bool,
|
||||||
label: PropTypes.string,
|
|
||||||
visible: PropTypes.bool,
|
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
name: PropTypes.string,
|
id: PropTypes.string,
|
||||||
|
onChange: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
static style = {
|
static style = {
|
||||||
@@ -59,10 +58,6 @@ class Checkbox extends Component {
|
|||||||
checkmarkUnchecked: {
|
checkmarkUnchecked: {
|
||||||
display: 'none'
|
display: 'none'
|
||||||
},
|
},
|
||||||
|
|
||||||
label: {
|
|
||||||
marginLeft: 10,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -73,32 +68,32 @@ class Checkbox extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick() {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.setState({ checked: !this.state.checked })
|
if (nextProps !== this.props) {
|
||||||
|
this.setState({ checked: nextProps.value })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClick(e) {
|
||||||
|
const checked = !this.state.checked
|
||||||
|
|
||||||
|
this.setState({ checked })
|
||||||
|
|
||||||
|
if (this.props.onChange) {
|
||||||
|
this.props.onChange(e, { checked })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { visible, name, label, disabled } = this.props
|
const { id, disabled } = this.props
|
||||||
const { checked } = this.state
|
const { checked } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={[!visible && { display: 'none' }]}>
|
|
||||||
<div style={[Checkbox.style.checkbox, disabled ? Checkbox.style.checkboxDisabled : !checked ? Checkbox.style.checkboxUnchecked : null]}
|
<div style={[Checkbox.style.checkbox, disabled ? Checkbox.style.checkboxDisabled : !checked ? Checkbox.style.checkboxUnchecked : null]}
|
||||||
onClick={disabled ? null : this.onClick}>
|
onClick={disabled ? null : this.onClick}>
|
||||||
<input id={name} type='checkbox' style={Checkbox.style.input} disabled={disabled} />
|
<input id={id} type='checkbox' style={Checkbox.style.input} disabled={disabled} />
|
||||||
<div style={[Checkbox.style.checkmark, !checked && Checkbox.style.checkmarkUnchecked]} />
|
<div style={[Checkbox.style.checkmark, !checked && Checkbox.style.checkmarkUnchecked]} />
|
||||||
</div>
|
</div>
|
||||||
<label
|
|
||||||
htmlFor={name}
|
|
||||||
style={[Checkbox.style.label, {
|
|
||||||
verticalAlign: 'top',
|
|
||||||
fontSize: fontInfo.size.medium,
|
|
||||||
fontFamily: fontInfo.family,
|
|
||||||
color: disabled ? fontInfo.color.dimmed : fontInfo.color.normal,
|
|
||||||
}]}>
|
|
||||||
{label}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ class List extends Component {
|
|||||||
fontFamily: fontInfo.family,
|
fontFamily: fontInfo.family,
|
||||||
}}>
|
}}>
|
||||||
<Box
|
<Box
|
||||||
border={`${sizeInfo.listBorderWidth}px solid ${colorInfo.listBorder}`}
|
border={{ width: sizeInfo.listBorderWidth, color: colorInfo.listBorder }}
|
||||||
radius={sizeInfo.formBoxRadius}>
|
radius={sizeInfo.formBoxRadius}>
|
||||||
<div style={{
|
<div style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
overflow: 'scroll'
|
overflowY: 'scroll',
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
@@ -49,7 +49,7 @@ List.Item = Radium(class ListItem extends Component {
|
|||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
display: 'table-row',
|
display: 'table-row',
|
||||||
background: active ? colorInfo.listBackgroundActive : colorInfo.listBackground,
|
background: active ? colorInfo.listBackgroundActive : 'transparent',
|
||||||
':hover': {
|
':hover': {
|
||||||
background: colorInfo.listBackgroundHover
|
background: colorInfo.listBackgroundHover
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user