Simplify confirm delete interaction
parent
6f1c665cd3
commit
ec9caa85a8
|
@ -84,7 +84,7 @@ const RowButtons = ({
|
||||||
<div className="tvm-actions">
|
<div className="tvm-actions">
|
||||||
<DeleteConfirmButtons onDelete={() => onDelete(id)} />
|
<DeleteConfirmButtons onDelete={() => onDelete(id)} />
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-info btn-edit"
|
className="btn btn-sm btn-info btn-edit btn-square"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
// prevent subsequent 'onSubmit' that is caused by an unknown source,
|
// prevent subsequent 'onSubmit' that is caused by an unknown source,
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import React, {PropTypes, Component} from 'react'
|
import React, {PropTypes, Component} from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
|
|
||||||
import OnClickOutside from 'shared/components/OnClickOutside'
|
import OnClickOutside from 'shared/components/OnClickOutside'
|
||||||
import ConfirmButtons from 'shared/components/ConfirmButtons'
|
import ConfirmButtons from 'shared/components/ConfirmButtons'
|
||||||
|
|
||||||
const DeleteButton = ({onClickDelete}) => (
|
const DeleteButton = ({onClickDelete, buttonSize}) => (
|
||||||
<button
|
<button
|
||||||
className="btn btn-xs btn-danger admin-table--hidden"
|
className={classnames('btn btn-danger admin-table--hidden', {
|
||||||
|
[buttonSize]: buttonSize,
|
||||||
|
})}
|
||||||
onClick={onClickDelete}
|
onClick={onClickDelete}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
|
@ -35,7 +38,7 @@ class DeleteConfirmButtons extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {onDelete, item} = this.props
|
const {onDelete, item, buttonSize} = this.props
|
||||||
const {isConfirming} = this.state
|
const {isConfirming} = this.state
|
||||||
|
|
||||||
return isConfirming
|
return isConfirming
|
||||||
|
@ -43,8 +46,12 @@ class DeleteConfirmButtons extends Component {
|
||||||
onConfirm={onDelete}
|
onConfirm={onDelete}
|
||||||
item={item}
|
item={item}
|
||||||
onCancel={this.handleCancel}
|
onCancel={this.handleCancel}
|
||||||
|
buttonSize={buttonSize}
|
||||||
|
/>
|
||||||
|
: <DeleteButton
|
||||||
|
onClickDelete={this.handleClickDelete}
|
||||||
|
buttonSize={buttonSize}
|
||||||
/>
|
/>
|
||||||
: <DeleteButton onClickDelete={this.handleClickDelete} />
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +59,17 @@ const {func, oneOfType, shape, string} = PropTypes
|
||||||
|
|
||||||
DeleteButton.propTypes = {
|
DeleteButton.propTypes = {
|
||||||
onClickDelete: func.isRequired,
|
onClickDelete: func.isRequired,
|
||||||
|
buttonSize: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteConfirmButtons.propTypes = {
|
DeleteConfirmButtons.propTypes = {
|
||||||
item: oneOfType([(string, shape())]),
|
item: oneOfType([(string, shape())]),
|
||||||
onDelete: func.isRequired,
|
onDelete: func.isRequired,
|
||||||
|
buttonSize: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteConfirmButtons.defaultProps = {
|
||||||
|
buttonSize: 'btn-sm',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OnClickOutside(DeleteConfirmButtons)
|
export default OnClickOutside(DeleteConfirmButtons)
|
||||||
|
|
|
@ -191,11 +191,6 @@ $tvmp-table-gutter: 8px;
|
||||||
|
|
||||||
.btn-edit {
|
.btn-edit {
|
||||||
order: 1;
|
order: 1;
|
||||||
width: 30px;
|
|
||||||
text-align: center;
|
|
||||||
padding-left: 0 !important;
|
|
||||||
padding-right: 0 !important;
|
|
||||||
> span.icon {margin: 0 !important;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> .btn {margin-left: $tvmp-table-gutter;}
|
> .btn {margin-left: $tvmp-table-gutter;}
|
||||||
|
@ -204,17 +199,9 @@ $tvmp-table-gutter: 8px;
|
||||||
/* Janky, but doing this quick & dirty for now */
|
/* Janky, but doing this quick & dirty for now */
|
||||||
.btn-danger {
|
.btn-danger {
|
||||||
order: 2;
|
order: 2;
|
||||||
height: 30px !important;
|
|
||||||
line-height: 30px !important;
|
|
||||||
padding: 0 9px !important;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
}
|
||||||
.confirm-buttons > .btn {
|
.confirm-buttons > .btn {
|
||||||
height: 30px !important;
|
|
||||||
width: 30px !important;
|
|
||||||
margin-left: $tvmp-table-gutter !important;
|
margin-left: $tvmp-table-gutter !important;
|
||||||
font-size: 13px;
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
}
|
||||||
/* Hide the edit button when confirming a delete */
|
/* Hide the edit button when confirming a delete */
|
||||||
.confirm-buttons + .btn-edit {
|
.confirm-buttons + .btn-edit {
|
||||||
|
|
Loading…
Reference in New Issue