How to use the xadmin.load_dict 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 / render.js View on Github external
(SubPrev, schema) => {
    if(schema.type == 'string' && [ 'time', 'date', 'date-time', 'datetime' ].indexOf(schema.format) > -1) {
      const dtf = app.load_dict('config').date_format || {}
      const format = schema.dateFormat || { time: dtf.time || 'LT', date: dtf.date || 'LL', 
        'date-time': dtf.datetime || 'LLL', 'datetime': dtf.datetime || 'LLL' }[schema.format]
      return ({ value, wrap: WrapComponent }) => {
        if(!_.isNil(value)) {
          const time = moment(value)
          return {time.format(format)}
        } else {
          return <span>-</span>
        }
      }
    } else if(schema.type == 'string' &amp;&amp; schema.enum &amp;&amp; schema.enum_title) {
      return ({ value, wrap: WrapComponent }) =&gt; {
        let result = null
        let index = schema.enum.indexOf(value)
        if(_.isArray(schema.enum_title) &amp;&amp; index &gt; -1) {
          result = schema.enum_title[index]
github sshwsfc / xadmin / packages / xadmin-antd / src / form / components / Array.js View on Github external
export default ({ input, label, meta, field, option, group }) =&gt; {
  let renderItems = field.itemsRender || defaultItemsRender
  if(typeof renderItems === 'string') {
    renderItems = app.load_dict('array_render')[renderItems]
  }
  const { items } = field
  const fieldsBuilder = (name, index, removeBtn, itemLable) =&gt; {
    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 (
    
  )
}