Skip to content

Commit

Permalink
feat: added label overrides on AccordionFormList
Browse files Browse the repository at this point in the history
Signed-off-by: Haris Spahija <haris.spahija@pon.com>
  • Loading branch information
HarisSpahijaPon committed Oct 28, 2019
1 parent 4808ec2 commit 36bfdd6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions package/src/components/AccordionFormList/v1/AccordionFormList.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class AccordionFormList extends Component {
* Text to show on the button for adding a new item to the list
*/
addNewItemButtonText: PropTypes.string,
/**
* The text for the "Cancel" text, if it is shown.
*/
cancelButtonText: PropTypes.string,
/**
* You can provide a `className` prop that will be applied to the outermost DOM element
* rendered by this component. We do not recommend using this for styling purposes, but
Expand Down Expand Up @@ -156,13 +160,19 @@ class AccordionFormList extends Component {
/**
* Handles item deletion from list
*/
onItemDeleted: PropTypes.func
onItemDeleted: PropTypes.func,
/**
* The text for the "Save" text, if it is shown.
*/
saveButtonText: PropTypes.string
};

static defaultProps = {
addNewItemButtonText: "Add an item",
deleteItemButtonText: "Delete this item",
entryFormSubmitButtonText: "Add item",
cancelButtonText: "Cancel",
saveButtonText: "Save",
isWaiting: false,
onItemDeleted() {}
};
Expand Down Expand Up @@ -207,10 +217,12 @@ class AccordionFormList extends Component {
renderAccordion() {
const {
addNewItemButtonText,
cancelButtonText,
components: { Accordion, Button, iconPlus, ItemEditForm },
deleteItemButtonText,
isWaiting,
items
items,
saveButtonText
} = this.props;

return (
Expand Down Expand Up @@ -250,10 +262,10 @@ class AccordionFormList extends Component {
this.toggleAccordionForItem(id);
}}
>
Cancel
{cancelButtonText}
</Button>
<Button onClick={() => this._refs[`editForm_${id}`].submit()} isShortHeight isWaiting={isWaiting}>
Save Changes
{saveButtonText}
</Button>
</FormActions>
</Accordion>
Expand All @@ -269,7 +281,7 @@ class AccordionFormList extends Component {
}

renderEntryForm() {
const { components: { Button, ItemAddForm }, entryFormSubmitButtonText, isWaiting, itemAddFormProps } = this.props;
const { cancelButtonText, components: { Button, ItemAddForm }, entryFormSubmitButtonText, isWaiting, itemAddFormProps } = this.props;
return (
<Fragment>
<ItemAddForm
Expand All @@ -280,7 +292,7 @@ class AccordionFormList extends Component {
/>
<FormActions>
<Button actionType="secondary" onClick={this.handleEntryFormCancel}>
Cancel
{cancelButtonText}
</Button>
<Button onClick={() => this._addItemForm.submit()} isWaiting={isWaiting}>
{entryFormSubmitButtonText}
Expand Down

0 comments on commit 36bfdd6

Please sign in to comment.