Skip to content
Egor Stambakio edited this page Jun 4, 2018 · 3 revisions

CRUD Editor

CircleCI npm version Dependency Status NPM Downloads badge-license

Getting started

Installation:

npm i @opuscapita/react-crudeditor

Minimal setup:

import createEditor from '@opuscapita/react-crudeditor'
import modelDefinition from './modelDefinition'

const ContractEditor = createEditor(<Model Definition>)

// ...use it later
// <ContractEditor/>

<Model Definition> is a single object:

// modelDefinition.js
import { FIELD_TYPE_STRING } from '@opuscapita/react-crudeditor'

export default {
  model: {
    name: 'Contract',
    
    fields: {
      contractId: {
        unique: true,
        type: FIELD_TYPE_STRING,
        constraints: {
          required: true
        }
      },
      description: {
        type: FIELD_TYPE_STRING
      }
    },
    
    validate: () => true
  },
  
  permissions: {
    crudOperations: {
      create: true,
      edit: true,
      delete: true,
      view: true
    }
  },
  
  api: { get, search, delete, create, update }, // API functions
  
  ui: {
    create: { formLayout },
    edit: { formLayout },
    show: { formLayout }
  }
}

TODO

Not implemented:

  • isCreateSupported,
  • duplicationConfiguration,
  • cmlExportConfiguration.
  • Allow custom operations to overwrite standard operations.
Clone this wiki locally