Skip to content

Commit

Permalink
Ability to change list name
Browse files Browse the repository at this point in the history
  • Loading branch information
spencercarli committed Sep 8, 2015
1 parent 8954593 commit e7ee8d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ReactNativeTodos/app/components/Lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,26 @@ let Lists = React.createClass({
},

handleMoreClick(list) {
let options = ["Make Private", "Delete List", "Cancel"];
let options = ["Make Private", "Change List Name", "Delete List", "Cancel"];

if (list.userId) {
options[0] = "Make Public";
}

ActionSheetIOS.showActionSheetWithOptions({
options: options,
cancelButtonIndex: 2,
destructiveButtonIndex: 1,
cancelButtonIndex: options.length - 1,
destructiveButtonIndex: options.length - 2,
},
(buttonIndex) => {
if (buttonIndex === 1) {
if (buttonIndex === options.length - 2) {
this.props.deleteList(list);
} else if (list.userId && buttonIndex === 0) {
this.props.changePublicity(list, false);
} else if (buttonIndex === 0) {
this.props.changePublicity(list, true);
} else if (buttonIndex === 1) {
this.props.changeListName(list);
}
});
},
Expand Down
16 changes: 16 additions & 0 deletions ReactNativeTodos/app/components/ListsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,29 @@ let ListsContainer = React.createClass({
);
},

handleChangeListName(list) {
AlertIOS.prompt(
'Change List Name',
list.name,
[
{text: 'Cancel'},
{text: 'Save', onPress: (name) => {
this.props.navigator.pop();
let mod = {$set: {name: name}}
ddp.call('Lists.update', [list._id, mod]);
}},
]
);
},

render() {
return (
<Lists
lists={this.state.lists}
navigator={this.props.navigator}
changePublicity={this.handleChangePublicityClick}
deleteList={this.handleDeleteListClick}
changeListName={this.handleChangeListName}
/>
);
}
Expand Down

0 comments on commit e7ee8d4

Please sign in to comment.