Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
soupette committed Oct 1, 2019
1 parent ea0b72f commit 2dc5df9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ function ListItem({
moveRelation,
nextSearch,
onRemove,
source,
targetModel,
}) {
const to = `/plugins/${pluginId}/${targetModel}/${data.id}?redirectUrl=${nextSearch}`;
const to = `/plugins/${pluginId}/${targetModel}/${data.id}?source=${source}&redirectUrl=${nextSearch}`;

const originalIndex = findRelation(data.id).index;
const [{ isDragging }, drag, preview] = useDrag({
Expand Down Expand Up @@ -72,6 +73,7 @@ ListItem.propTypes = {
moveRelation: PropTypes.func,
nextSearch: PropTypes.string,
onRemove: PropTypes.func,
source: PropTypes.string.isRequired,
targetModel: PropTypes.string,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function SelectMany({
onRemove,
options,
placeholder,
source,
targetModel,
value,
}) {
Expand Down Expand Up @@ -62,7 +63,8 @@ function SelectMany({
id={name}
filterOption={(candidate, input) => {
if (!isEmpty(value)) {
const isSelected = value.findIndex(item => item.id === candidate.value.id) !== -1;
const isSelected =
value.findIndex(item => item.id === candidate.value.id) !== -1;
if (isSelected) {
return false;
}
Expand Down Expand Up @@ -98,6 +100,7 @@ function SelectMany({
moveRelation={moveRelation}
nextSearch={nextSearch}
onRemove={() => onRemove(`${name}.${index}`)}
source={source}
targetModel={targetModel}
/>
))}
Expand All @@ -111,6 +114,7 @@ function SelectMany({

SelectMany.defaultProps = {
move: () => {},
source: 'content-manager',
value: null,
};

Expand All @@ -128,6 +132,7 @@ SelectMany.propTypes = {
onRemove: PropTypes.func.isRequired,
options: PropTypes.array.isRequired,
placeholder: PropTypes.node.isRequired,
source: PropTypes.string,
targetModel: PropTypes.string.isRequired,
value: PropTypes.array,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ function SelectWrapper({
pathname,
search,
} = useEditView();
const source = isEmpty(plugin) ? 'content-manager' : plugin;
const [state, setState] = useState({
_q: '',
_limit: 20,
_start: 0,
source: isEmpty(plugin) ? 'content-manager' : plugin,
source,
});
const [options, setOptions] = useState([]);
const [isLoading, setIsLoading] = useState(true);
Expand Down Expand Up @@ -128,7 +129,7 @@ function SelectWrapper({
const nextSearch = `${pathname}${search}`;
const to = `/plugins/${pluginId}/${targetModel}/${
value ? value.id : null
}?redirectUrl=${nextSearch}`;
}?source=${source}&redirectUrl=${nextSearch}`;
const link =
value === null ||
value === undefined ||
Expand Down Expand Up @@ -185,6 +186,7 @@ function SelectWrapper({
placeholder
)
}
source={source}
targetModel={targetModel}
value={value}
/>
Expand Down

0 comments on commit 2dc5df9

Please sign in to comment.