New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-common-admin

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-common-admin

A react page container that works with [react-parse](https://www.npmjs.com/package/react-parse) to fetch data from server and display as table/gallery or customs component.

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

react-common-admin

A react page container that works with react-parse to fetch data from server and display as table/gallery or customs component.

Installation

You need to install: Ant Design

npm i react-common-admin --save

Basic Usage

import  React  from  'react';
import {CommonAdmin, fields} from  'react-common-admin'
import {DocFields, TableField} from  './config';

const DocFields = [ // See react-cross-form
{
	key: 'firstName',
	label: 'First Name',
	validators: { presence: true, length: { minimum: 2 } },
	component: fields.TextInput
}]

const TableField = [
{ key: 'objectId',
  title: 'Object Id'
 },
 { key: 'firstName',
  title: 'First Name'
 }
]
export  default  class  Example  extends  React.Component {
render() {
	return (
		<div>
			<CommonAdmin
				schemaName='Example'
				targetName='ExampleScreen'
				title='Example Screen'
				documentProps={{
					fields: DocFields, // Define this fields you want to render
				}}
				collectionProps={{
					fields: TableField
				}}	
			/>
		</div>
	);
}}

Props

keytypeDescription
titlestringtitle to dispaly
targetNamestring
required
react-parse targetName
schemaNamestring
required
react-parse schemaName
functionNamestringreact-parse functionName
When you using clude code the delete from table is not enabled
onShowDocumentModalfunctionFunction that be call when DocumentModal state is changed
fetchExtraDataarrayarray of objects, each object is react-parse collection configuration
[{schemaName: 'Member', targetName: 'MemberData'}]
The data will be avilable for you in the components
documentPropsobject
required
See documentProps
collectionPropsobject
required
See collectionProps

documentProps

keytypeDescription
fieldsarray
required
we use react-cross-form
wrapperelementYou can replace the default side modal wrapper , wrapper get this props
{
isOpen: bollean,
onClose: function,
title: string,
children: react children
}
viewComponentelementSee document viewComponent props
titlestringtitle to display
customTitlefunctionfunction that get {state, props} and return string as title
parseDataBeforePostfunctionoptional - function that call with the data before post, (data) => {return ({...data, {test: 1})}
saveOnBlurboolleandefault is true, run react-parse put when input is blur
messagesobjectYou can display a custom message, this data will pass to your notification service, see initCommonAdmin

document viewComponent props

{
	fetchProps - see react-parse fetchProps;
	onClose, - function - call to close modal
	isOpen - boolean - is modal open
	objectId, - string - empty on new document
	saveOnBlur, - boolean
	fields, - array
	fieldsOptions - fetchExtraData is pass to document as fieldsOptions - pass only for fields that contain a targetName, the key for each value in fieldsOptions is the targetName
	extraData - all fetchExtraData results,
	... all other parameters from your documentProps configuration
}

collectionProps

keytypeDescription
fieldsarray
required
[{key: 'objectId', title: 'Object Id', search: true, formatter: () => {}} ]
viewComponentelementSee collention viewComponent props
titlestringtitle to display
limitnumberreact-parse limit value , default is 10
skipnumberreact-parse skip value , default is 0,
orderstringreact-parse string, default is 'createdAt'
queryobjectreact-parse query, default is {}
onLimitChangedfuncitonif you didn't pass this handlers than your limit is used as initial value and react-common-admin will handle the changes
onSkipChangedfunciton
onOrderChangedfunciton
onPaginationfunciton
onQueryChangedfunciton

collention viewComponent props

{
	fetchProps - see react-parse fetchProps 
	fields - array
	dataHandler - see react-parse dataHandler (clodeCode)
	extraData - all fetchExtraData results
	title - string
	onCreateNewDoc- function - call this and document modal will display
	onEditDoc- function - call this with objectId and document modal will display to edit
	skip - number
	limit - number
	// function to call when you want to set a new value
	onLimitChanged: (limit: number) => {...}
	onSkipChanged: (skip: number) => {...}
	onOrderChanged: (order: string => {...}
	onQueryChanged: (query: object) => {...}
	onPagination: (page: number, pageSize: number) => {...}
	... all other parameters from your collectionProps configuration
}

react-parse fetchProps

see full details in react-parse docs {data, error, status, info. isLoading, refresh, cleanData, put, post, deleteDoc, updateField}

Keywords

react

FAQs

Package last updated on 09 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts