Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`<MultiSelectBox/> should render correctly. 1`] = `
ListPreviewElement={[Function]}
MultiSelectBox_ListPreviewSortable={[Function]}
SelectBox={[Function]}
allowDragging={true}
allowEmpty={true}
dndType="multiselect-box-value"
onCreateNew={[MockFunction]}
Expand All @@ -28,6 +29,7 @@ exports[`<MultiSelectBox/> should render correctly. 1`] = `
ListPreviewElement={[Function]}
MultiSelectBox_ListPreviewSortable={[Function]}
SelectBox={[Function]}
allowDragging={true}
allowEmpty={true}
dndType="multiselect-box-value"
onCreateNew={[MockFunction]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class MultiSelectBox extends PureComponent {
*/
disabled: PropTypes.bool,

/**
* Allows dragging.
*/
allowDragging: PropTypes.bool,

/**
* Additional className wich will be applied
*/
Expand Down Expand Up @@ -165,6 +170,7 @@ class MultiSelectBox extends PureComponent {
optionValueField: 'value',
dndType: 'multiselect-box-value',
allowEmpty: true,
allowDragging: true,
ListPreviewElement: SelectBox_Option_SingleLine
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class MultiSelectBox_ListPreviewSortable extends PureComponent {
values: PropTypes.arrayOf(PropTypes.string),
onValuesChange: PropTypes.func.isRequired,
ListPreviewElement: PropTypes.any.isRequired,
allowDragging: PropTypes.bool,

// API with MultiSelectBox
optionValueAccessor: PropTypes.func.isRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const spec = {
index: props.index
};
},
canDrag({values, disabled}) {
return !disabled && (values && values.length > 1);
canDrag({values, disabled, allowDragging}) {
return allowDragging && !disabled && (values && values.length > 1);
}
}, (connect, monitor) => ({
connectDragSource: connect.dragSource(),
Expand All @@ -65,6 +65,7 @@ export default class MultiSelectBox_ListPreviewSortable_DraggableListPreviewElem
}),
values: PropTypes.arrayOf(PropTypes.string),
disabled: PropTypes.bool,
allowDragging: PropTypes.bool,

// Drag&Drop specific propTypes
dndType: PropTypes.string.isRequired,
Expand Down Expand Up @@ -103,6 +104,7 @@ export default class MultiSelectBox_ListPreviewSortable_DraggableListPreviewElem
const {
option,
disabled,
allowDragging,
connectDragSource,
connectDropTarget,
isDragging,
Expand All @@ -117,7 +119,7 @@ export default class MultiSelectBox_ListPreviewSortable_DraggableListPreviewElem

// TODO Loading State: const {icon, label} = option || {label: `[Loading ${value}]`};

const isDraggable = !disabled && (values && values.length > 1);
const isDraggable = allowDragging && !disabled && (values && values.length > 1);

const finalClassNames = mergeClassNames({
[theme.selectedOptions__item]: true,
Expand Down
Loading