update it

This commit is contained in:
Sukchan Lee 2017-07-05 23:02:30 +09:00
parent e87de4262d
commit 72e7d59392
2 changed files with 41 additions and 6 deletions

View File

@ -61,11 +61,13 @@ const Confirm = ({ visible, onOutside, message, buttons }) => {
Confirm.propTypes = { Confirm.propTypes = {
visible: PropTypes.bool, visible: PropTypes.bool,
disabled: PropTypes.bool,
onOutside: PropTypes.func, onOutside: PropTypes.func,
} }
Confirm.defaultProps = { Confirm.defaultProps = {
visible: false, visible: false,
disabled: true,
onOutside: () => {}, onOutside: () => {},
} }

View File

@ -26,6 +26,10 @@ class Collection extends Component {
action: '', action: '',
visible: false, visible: false,
dimmed: false dimmed: false
},
confirm: {
visible: false,
imsi: ''
} }
}; };
@ -110,10 +114,30 @@ class Collection extends Component {
update: (imsi) => { update: (imsi) => {
this.documentHandler.show('update', { imsi }); this.documentHandler.show('update', { imsi });
}, },
delete: (imsi) => { }
const { dispatch } = this.props }
dispatch(deleteSubscriber(imsi));
} confirmHandler = {
show: (imsi) => {
this.setState({
confirm: {
visible: true,
imsi
}
})
},
hide: () => {
this.setState({
confirm: {
visible: false
}
})
},
delete: () => {
this.confirmHandler.hide();
const { dispatch } = this.props
dispatch(deleteSubscriber(this.state.confirm.imsi));
} }
} }
@ -121,7 +145,8 @@ class Collection extends Component {
const { const {
handleSearchChange, handleSearchChange,
handleSearchClear, handleSearchClear,
documentHandler documentHandler,
confirmHandler
} = this; } = this;
const { const {
@ -150,7 +175,7 @@ class Collection extends Component {
deletedImsi={status.id} deletedImsi={status.id}
onShow={documentHandler.actions.browser} onShow={documentHandler.actions.browser}
onEdit={documentHandler.actions.update} onEdit={documentHandler.actions.update}
onDelete={documentHandler.actions.delete} onDelete={confirmHandler.show}
search={search} search={search}
/> />
{isLoading && <Spinner md />} {isLoading && <Spinner md />}
@ -165,6 +190,14 @@ class Collection extends Component {
{ ...document } { ...document }
onHide={documentHandler.hide} /> onHide={documentHandler.hide} />
<Dimmed visible={document.dimmed} /> <Dimmed visible={document.dimmed} />
<Confirm
visible={this.state.confirm.visible}
message="Delete this subscriber?"
onOutside={confirmHandler.hide}
buttons={[
{ text: "CANCEL", action: confirmHandler.hide, info:true },
{ text: "DELETE", action: confirmHandler.delete, danger:true }
]}/>
</Layout.Content> </Layout.Content>
) )
} }