Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Embedded Arrays for Admin On Rest

License

NotificationsYou must be signed in to change notification settings

MhdSyrwan/aor-embedded-array

Repository files navigation

npmnpmnpmTravis

aor-embedded-array

A custom field/input component forAdmin-on-rest that provides the ability to represent embedded arrays.

screenshot

Installation

Install with:

npm install --save aor-embedded-array

or

yarn add aor-embedded-array

Usage

Basic Usage

Define theCreate andEdit View like this:

<EmbeddedArrayInputsource="links"><LongTextInputsource="url"/><LongTextInputsource="context"/><EmbeddedArrayInputsource="metadata"><TextInputsource="name"/><TextInputsource="value"/></EmbeddedArrayInput></EmbeddedArrayInput>

Define theShow andList View like this:

<EmbeddedArrayFieldsource="links"><UrlFieldsource="url"/><TextFieldsource="context"/><EmbeddedArrayFieldsource="metadata"><TextFieldsource="name"/><TextFieldsource="value"/></EmbeddedArrayField></EmbeddedArrayField>

For primitive arrays, define the Views the same way but without the source prop for the unique child:

<EmbeddedArrayInputsource="links"><LongTextInput/></EmbeddedArrayInput>

Using Custom action buttons

importFlatButtonfrom'material-ui/FlatButton';importActionDeleteIconfrom'material-ui/svg-icons/action/delete';constCustomDeleteButton=({items, index})=>(<FlatButtonkey={index}secondarylabel="Delete"icon={<ActionDeleteIcon/>}onClick={()=>{// Take custom actionconsole.log(items,index);items.remove(index);}}/>)
varstyle={actionsContainerStyle:{display:"inline-block",clear:"both",float:"right",padding:"2em 0em 0em 0em"}}<EmbeddedArrayInputsource="links"actionsContainerStyle={style.actionsContainerStyle}customButtons={[<CustomDeleteButtonkey={0}/>]}><UrlFieldsource="url"/><TextFieldsource="context"/> </EmbeddedArrayInput>

Customizing Add and Remove buttons' labels

You can make use of the translation system provided byadmin-on-rest and set the following translation paths:

  1. aor.input.embedded_array.add to set Add Button's label.
  2. aor.input.embedded_array.remove to set Remove Button's label.

Also, you can change the translation path's themselves by providing values for propslabelAdd andlabelRemove.

You can learn more about admin-on-rest's translation system from this link:https://marmelab.com/admin-on-rest/Translation.html

Passing props to customize style

There are four style props you can pass to customize style, those areactionsContainerStyle,innerContainerStyle,labelStyle &insertDividers.

Default values of those are as follows

actionsContainerStyle:{clear:'both',margin:'1em',display:'block',textAlign:'right',},
innerContainerStyle:{padding:'0 1em 1em 1em',width:'90%',display:'inline-block',},
labelContainerStyle:{padding:'1.2em 1em 0 0',width:'90%',display:'inline-block',},
labelStyle:{top:0,position:'relative',textTransform:'capitalize',},

You can also passinsertDividers value astrue orfalse to get the divider or not. Default value forinsertDividers is true.

About

Embedded Arrays for Admin On Rest

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp