How to use the xadmin.app.context function in xadmin

To help you get started, we’ve selected a few xadmin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sshwsfc / xadmin / packages / xadmin-antd / src / model / actions / BatchChange.js View on Github external
const BatchChangeBtn = props => {
  const { _t } = app.context
  const [ show, setShow ] = React.useState(false)
  const { canEdit, fields, onBatchChange } = use('actons.batch_change', props)
  const { selected } = use('model.select', props)
  const { model } = use('model', props)

  const onClose = () => setShow(false)

  const renderModel = () => {
    const fs = fields.map(f => f.split('.')[0])
    return (
       _.find(model.form, f => f && f.key == name) || name ) : [ '*' ]
        }, 'required')}
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / model / components / SubMenu.js View on Github external
render() {
    const { _t } = app.context
    const { selected, fields } = this.props
    let items = []
    const showFields = Object.keys(fields).filter(name => fields[name].showInGrid !== false)
    const menuShow = showFields.length <= 10

    for (let name of showFields) {
      let field = fields[name]
        , fieldName = name
        , title = field.title || name
        , fieldSelected = _.indexOf(selected, name) !== -1
        , icon = fieldSelected ?  : 
        , onClick = (e) => {
          this.props.changeFieldDisplay([ fieldName, !fieldSelected ])
        }
      if(menuShow) {
        items.push({icon} {title})
github sshwsfc / xadmin / packages / xadmin-model / src / base.js View on Github external
React.useEffect(() => {
    if(state == null) {
      let initial = initialValues
      if(!initial && model.initialValues) {
        initial = _.isFunction(model.initialValues) ? model.initialValues() : model.initialValues
      }
      app.context.store.dispatch({ type: 'INITIALIZE', model, initial })
      setState('INITIALIZE')
    } else if(state == 'DESTROY') {
      app.context.store.dispatch({ type: 'DESTROY', model })
    }
  }, [ state ])
  if(!model || state != 'INITIALIZE') return null
github sshwsfc / xadmin / packages / xadmin-antd / src / layout / Dashboard.js View on Github external
render() {
    const { _t } = app.context
    return <div>{_t('Welcome, Have a nice day!')}</div>{Block('dashboard.main', this)}
  }
}
github sshwsfc / xadmin / packages / xadmin-antd / src / auth / components / CaptchaCodeInput.js View on Github external
render() {
    const { input, field } = this.props
    const { _t } = app.context

    return (
      
        
          <input>
        
        
          
            <img style="{{">this.setState({ url: this.getCodeUrl() })} src={ this.state.url } /&gt;
          
        
      
    )
  }
}
github sshwsfc / xadmin / packages / xadmin-auth / src / components / SignUp.js View on Github external
const SignUpForm = StoreWrap('auth.sign_up')(({ onSuccess }) =&gt; {
  const { _t } = app.context
  return (
    
      
    
  )
})
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / auth / components / UserMenu.js View on Github external
const UserMenu = StoreWrap('auth.user')(({ user, onLogout, onChangePassword }) =&gt; {
  const { _t } = app.context
  return user &amp;&amp; (
     {user.username}} id="basic-nav-dropdown"&gt;
      
      {_t('Change password')}
      {_t('Logout')}
    
  )
})
github sshwsfc / xadmin / examples / xadmin-demo / src / form / index.js View on Github external
render() {
    const { count, add } = this.props
    const { _t } = app.context

    const FormLayout = (props) =&gt; {
      const { children, invalid, handleSubmit, submitSucceeded, submitting, isCreate } = props
      return (
        <form>
          {children}
          <a>{_t('Add Count')}</a>
        </form>
      )
    }

    return (
      
        {count}
github sshwsfc / xadmin / packages / xadmin-auth / src / components / ResetPasswordForm.js View on Github external
export default StoreWrap('auth.reset_password')(({ onSuccess, location: { query } }) =&gt; {
  const { _t } = app.context
  return (
    
      
    
  )
})
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / model / components / Items.js View on Github external
renderOrder() {
    const { field, order, canOrder } = this.props
    const { _t } = app.context
    let orderItems = []

    if(canOrder) {
      orderItems = [
        { this.props.changeOrder('ASC') }} active={order==='ASC'}&gt; {_t('Sort ASC')},
        { this.props.changeOrder('DESC') }} active={order==='DESC'}&gt; {_t('Sort DESC')}
      ]
      if(order != '') {
        orderItems.push({ this.props.changeOrder('') }}&gt; {_t('Clear order')})
      }
    }
    return orderItems
  }