0.0.1 • Published 2 days ago

@stepanjakl/apostrophe-read-only-field v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

This module adds a schema field type designed solely for displaying relevant data in read-only mode, without allowing any editing capability.

This module is used primarily in Apostrophe Stripe packages such as stripe-checkout or stripe-products.

Installation

Use your preferred package manager to install the module:

npm install read-only-field@npm:@stepanjakl/apostrophe-read-only-field

Usage

First, add the installed module to your configuration in the app.js root file:

require('apostrophe')({
  shortName: 'project-name',
  modules: {
    'read-only-field': {}
  }
});

Then, easily add the field type to any module that accepts the fields property. The schema field object accepts optional parameters such as copyToClipboard, openInNewTab, and openInNewTabPrepend. See the example below:

module.exports = {
  extend: '@apostrophecms/piece-type',
  fields: {
    add: {
      name: {
        type: 'readOnly',
        label: 'Name',
        copyToClipboard: true,
        openInNewTab: true,
        openInNewTabPrepend: `${process.env.STRIPE_DASHBOARD_BASE_URL}${process.env.STRIPE_TEST_MODE === 'false' ? '' : '/test'}/prices/`
      }
    }
  }
}