Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/3715 rebased make multi select box drag&drop sorting feature optional #3874

Open
wants to merge 3 commits into
base: 8.4
Choose a base branch
from
Open
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