Skip to content

Commit

Permalink
confirm before close + fix buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
S1B41 committed Nov 13, 2020
1 parent 1d36848 commit 56c4c1b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions imports/ui/noteList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class notelist extends Component {

onEdit() {
if (!this.state.value) {
this.setState({ editModal: false });
return;
}

Expand All @@ -35,6 +36,15 @@ class notelist extends Component {
confirm("remove note?") && Notes.remove({ _id });
}

onClose() {
if (!this.state.value) {
this.setState({ currentNote: null, editModal: false });
} else {
confirm("Discard changes?") &&
this.setState({ currentNote: null, editModal: false });
}
}

modal() {
if (!this.state.editModal) {
return null;
Expand All @@ -44,7 +54,7 @@ class notelist extends Component {

const customStyles = {
content: {
width: "40%",
width: "50%",
top: "50%",
left: "50%",
right: "auto",
Expand All @@ -70,12 +80,20 @@ class notelist extends Component {
}
className="form-control"
/>
<button onClick={() => this.onEdit()}>save</button>
<button
onClick={() => this.setState({ currentNote: null, editModal: false })}
>
close
</button>
<div style={{ marginTop: 10 }}>
<button
className="btn btn-success btn-sm"
onClick={() => this.onEdit()}
>
save
</button>
<button
className="btn btn-dark btn-sm ml-1"
onClick={() => this.onClose()}
>
close
</button>
</div>
</Modal>
);
}
Expand Down

0 comments on commit 56c4c1b

Please sign in to comment.