Permalink
Browse files

Implemented the logic to allow the user to edit individual item capti…

…ons by clicking the 'Edit item...' button.
  • Loading branch information...
maratbn committed Jul 1, 2018
1 parent 894c565 commit 5871aa5614ec43de1ce9a1a449d4693943dc9c86
Showing with 25 additions and 1 deletion.
  1. +25 −1 webpack_in/entry.jsx
@@ -107,6 +107,17 @@ class ListWidget extends React.Component {
total_added: state.total_added + 1
});
this._mutateStateToUpdateItemCaption = (state, id, strCaptionNew) => ({
...state,
items: state.items.map(objItem => (
objItem.id === id ? {
...objItem,
caption: strCaptionNew
}
: objItem
))
});
this._mutateStateToUpdateItemChecked = (state, id, isChecked) => ({
...state,
items: state.items.map(objItem => (
@@ -168,7 +179,20 @@ class ListWidget extends React.Component {
strItemNew));
}}/>
<ButtonWidget caption="Edit item..."
isDisabled={ arrItemsSelected.length !== 1 }/>
isDisabled={ arrItemsSelected.length !== 1 }
onClick={() => {
const objItemEdit = arrItemsSelected[0];
const strItemEdited = prompt("Please edit item:",
objItemEdit.caption);
if (strItemEdited === null) {
return;
}
this.setState(this._mutateStateToUpdateItemCaption(
this.state,
objItemEdit.id,
strItemEdited));
}}/>
<ButtonWidget caption={ arrItemsSelected.length > 1 ? "Remove items..."
: "Remove item..." }
isDisabled={ arrItemsSelected.length === 0 }/>

0 comments on commit 5871aa5

Please sign in to comment.