Skip to content

Commit

Permalink
Merge branch 'develop' into feature/shibui-2394
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 31, 2022
2 parents 0b8ccc8 + 3b8f4db commit e723dfd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ui/src/app/form/component/fields/FilterTargetField.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Editor from 'react-simple-code-editor';
// import 'prismjs/components/prism-javascript';

import { FilterTargetPreview } from '../../../metadata/hoc/FilterTargetPreview';
import { remove } from 'lodash';

const ToggleButton = ({ isOpen, onClick, disabled }) => (
<Button
Expand Down Expand Up @@ -116,10 +117,12 @@ const FilterTargetField = ({
]);
setSearchTerm('');
};
const removeId = (id) => {
setSelectedTarget([
...selectedTarget.filter(t => t !== id)
]);
const removeIdx = (idx) => {
const updated = [
...selectedTarget
];
remove(updated, (v, index) => index === idx);
setSelectedTarget(updated);
};

const onEntityIdsChange = (value) => {
Expand Down Expand Up @@ -289,8 +292,8 @@ const FilterTargetField = ({
<label className="control-label"><Translate value="label.entity-ids-added">Entity Ids Added</Translate></label>
<hr />
<ul className="list-group list-group-sm list-group-scroll">
{selectedTarget.map(id =>
<li key={id} className="list-group-item d-flex justify-content-between align-items-center">
{selectedTarget.map((id, idx) =>
<li key={idx} className="list-group-item d-flex justify-content-between align-items-center">
<FilterTargetPreview entityId={id}>
{(preview, loading, xml) => (
<React.Fragment>
Expand All @@ -306,7 +309,7 @@ const FilterTargetField = ({
}
<Button type="button"
variant="link"
className="text-end" onClick={() => removeId(id)}>
className="text-end" onClick={() => removeIdx(idx)}>
<FontAwesomeIcon icon={faTrash} size="lg" className="text-danger sr-hidden" />
<span className="sr-only"><Translate value="action.remove">Remove</Translate></span>
</Button>
Expand Down

0 comments on commit e723dfd

Please sign in to comment.