OpusCapita / react-crudeditor

OpusCapita React CRUD Editor
https://opuscapita.github.io/react-crudeditor/branches/master/?currentComponentName=ContractEditor&maxContainerWidth=100%25&showSidebar=false
Apache License 2.0
20 stars 1 forks source link

Add possibility to disable any action on search list in CRUD editor #273

Closed estambakio-sc closed 6 years ago

estambakio-sc commented 6 years ago
Meta-Info Value
ExtProjectId JCPROC-01
Original Estimation 8h
Remaining Estimation 0h
estambakio-sc commented 6 years ago

TODO: allow functions in permissions configuration.

Current state: crud permissions are defined in modelDefinition as boolean values.

permissions: {
    crudOperations: {
      create: true,
      edit: true,
      delete: true,
      view: true
    }
  }

Goal: crud permissions can be defined as boolean or functions (previous behavior preserved):

permissions: {
    crudOperations: {
      create: () => <boolean>,
      edit: ({ instance }) => <boolean>,
      delete: ({ instance }) => <boolean>,
      view: () => <boolean>
    }
  },

Example of such function:

edit: arg => arg ? arg.instance.canBeEdited : true
estambakio-sc commented 6 years ago

ui.VIEW_NAME.standardOperations will be removed, because it duplicates new permissions functionality in current application (disabling Delete based on instance).

estambakio-sc commented 6 years ago

Demo link

nstoliar-sc commented 6 years ago

Tested. Navigation by instances in CRUD-editor is make correctly. Buttons of instances are displayed according permissions. Please, merge with master branch. Spent 1 hour.