How to use the xadmin.get 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-model / src / relate.js View on Github external
const RelateAction = props => {
  const { model, item } = use('model', props)
  const actions = []

  const models = app.get('models')
  Object.keys(models).forEach(key => {
    const m = models[key]
    for(let pname of Object.keys(m.properties || {})) {
      const prop = m.properties[pname]
      if(prop.type == 'object' && (prop.relateTo == model.key || prop.relateTo == model.name)) {
        actions.push(m)
        continue
      }
    }
  })

  return actions.length ?  : null
}
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / model / components / ChildrenModel.js View on Github external
render() {
    const { parent, model, refFilter, refData, refField, modelProps, children, header, ...props } = this.props
    const { _t } = app.context

    const cmodel = _.isString(model) ? app.get('models')[model] : model
    const schema = {
      ...cmodel,
      parent,
      item_actions: [
        ...(cmodel.item_actions || []),
        item => {_t('Edit')}
      ],
      permission: {
        ...cmodel.permission,
        edit: false,
        childEdit: cmodel.permission && cmodel.permission.edit
      },
      ...modelProps
    }
    const initialValues = {
      wheres: { filters: refFilter || { [refField]: parent.id } }
github sshwsfc / xadmin / packages / xadmin-model / src / relate.js View on Github external
(f, schema, options) => {
    if(schema.type == 'object' && schema.relateTo) {
      const models = app.get('models')
      const relateName = schema.relateTo
      if(models[relateName]) {
        const model = models[relateName]
        f.type = 'filter_relate'
        f.schema = model
        f.displayField = model.displayField || 'name'
      }
    }
    return f
  } 
]
github sshwsfc / xadmin / packages / xadmin-plugins / src / reldetail.js View on Github external
return ({ value, wrap }) => {
        
        if(value && value.id !== undefined && schema.showDetail === true && Object.keys(app.get('models')).indexOf(schema.relateTo) >= 0) {
          const newWrap = ({ children }) => (
            
              
                {children}
              
            
          )
          return 
        } else {
          return 
        }
      }
    }
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / form / components / Array.js View on Github external
export default ({ input, label, field, option }) => {
  let renderItems = field.itemsRender || defaultItemsRender
  if(typeof renderItems === 'string') {
    renderItems = app.get('array_render')[renderItems]
  }
  const { items } = field
  const fieldsBuilder = (name, index, removeBtn, itemLable) => {
    const itemLabel = itemLable || (<div>{removeBtn ? removeBtn : ''}</div>)
    const itemFields = items.fields ? 
      (items.fields.map(f =&gt; prefixFieldKey(f, name + '.'))) : 
      [ { ...items, key: name, name: name, label: itemLabel } ]

    return objectBuilder(itemFields, items.render, option)
  }
  return (
    
  )
}
github sshwsfc / xadmin / packages / xadmin-model / src / actions.js View on Github external
'model.batchActions': props =&gt; {
      const { model } = use('model', props)
      const modelActions = app.get('modelBatchActions')
      const actions = model.batchActions === undefined ? 
        Object.keys(modelActions).filter(k =&gt; modelActions[k].default) : model.batchActions
  
      const renderActions = React.useCallback(actProps =&gt; {
        return actions ? actions.map((action, i) =&gt; {
          const Action = _.isString(action) &amp;&amp; modelActions[action] ? modelActions[action].component : action
          if(Action) {
            return 
          }
          return null
        }).filter(Boolean) : null
      }, [ actions ])
  
      return { ...props, actions, renderActions }
    },
    'actons.batch_delete': props =&gt; {
github sshwsfc / xadmin / packages / xadmin-ui / src / index.js View on Github external
const C = args =&gt; {
  if(typeof args == 'string') {
    return app.get('components')[args]
  } else {
    const { is, ...props } = args
    const Component = C(is)
    if(Component) 
      return 
    else
      return <div>Component {is} not found.</div>
  }
}
github sshwsfc / xadmin / packages / xadmin-antd / src / model / components / ChildrenModel.js View on Github external
const ChildrenModel = props =&gt; {
  const [ show, setShow ] = React.useState(false)
  const { parent, model, refFilter, refData, refField, modelProps, children, header, value, onClose, refreshTimeout, ...extProps } = props
  
  const handleCancel = () =&gt; {
    setShow(false)
    onClose &amp;&amp; onClose()
  }

  const cmodel = _.isString(model) ? app.get('models')[model] : model
  const schema = {
    ...cmodel,
    parent,
    itemActions: [
      ...(cmodel.itemActions || []),
      item =&gt; {_t('Edit')}
    ],
    permission: {
      ...cmodel.permission,
      edit: false,
      childEdit: cmodel.permission &amp;&amp; cmodel.permission.edit
    },
    ...modelProps
  }
  const initialValues = {
    wheres: { filters: refFilter || { [refField]: parent.id } }
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / auth / components / SignIn.js View on Github external
export default ({ error, children, invalid, handleSubmit, submitting }) =&gt; {
  const { auth } = app.get('config')
  return (
    
      <form>
        
          
            
              <h4>{_t('Please Login')}</h4>
            
            {children}
            {error &amp;&amp; <strong>{error}</strong>}
            <button disabled="{invalid" type="submit">
               {_t('Login')}</button>
            { auth.can_signup &amp;&amp; (<div>{_t('Not registed')}? <a href="#">app.go('/signup')}&gt;{_t('please signup')}</a></div>) }
            { auth.can_reset_password &amp;&amp; (<div>{_t('Forgot password')}? <a href="#">app.go('/forget_password')}&gt;{_t('reset password')}</a></div>) }
          
        </form>