Skip to content

Commit

Permalink
Fixed delete functionality to remove from list
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 17, 2021
1 parent b26c7ff commit 152673d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ tooltip.bundle-name=A user friendly name to identify the bundle
action.attribute-bundles=Attribute bundles
label.new-attribute-bundle=New attribute bundle
label.edit-attribute-bundle=Edit attribute bundle
label.bundled-attributes=Bundles Attributes
label.bundled-attributes=Bundled Attributes
label.attribute-bundles=Attribute Bundles
message.user-role-admin-group=Cannot change group for ROLE_ADMIN users.

label.roles-management=Role Management
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/hoc/attribute/AttributeBundleApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ export function AttributeBundleApi({ id, children }) {
dispatch(createNotificationAction(
`Bundle has been deleted.`
));
cb();
cb && cb();
}
}

return (
<DeleteConfirmation title={`message.delete-attribute-title`} body={`message.delete-attribute-body`}>
{(block) =>
<div>{children(load, find, create, update, (id) => block(() => remove(id)), loading)}</div>
<div>{children(load, find, create, update, (id, cb) => block(() => remove(id, cb)), loading)}</div>
}
</DeleteConfirmation>
);
Expand Down
8 changes: 6 additions & 2 deletions ui/src/app/metadata/hoc/attribute/AttributeBundleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ export function AttributeBundleList({ load, children }) {

/*eslint-disable react-hooks/exhaustive-deps*/
React.useEffect(() => {
load((list) => setBundles(list));
reload();
}, []);

const reload = () => {
load((list) => setBundles(list));
};

return (
<React.Fragment>{children(bundles)}</React.Fragment>
<React.Fragment>{children(bundles, reload)}</React.Fragment>
);
}
8 changes: 4 additions & 4 deletions ui/src/app/metadata/view/MetadataAttributeBundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import { AttributeBundleApi } from '../hoc/attribute/AttributeBundleApi';
import { AttributeBundleList } from '../hoc/attribute/AttributeBundleList';
import { TruncateText } from '../../core/components/TruncateText';

export function MetadataAttributeBundles({ entities, onDelete }) {
export function MetadataAttributeBundles({}) {

return (
<AttributeBundleApi>
{(load, find, create, update, remove, loading) =>
<AttributeBundleList load={load}>
{(bundles) =>
{(bundles, reload) =>
<div className="container-fluid p-3">
<section className="section">
<div className="section-body border border-top-0 border-primary">
<div className="section-header bg-primary p-2 text-light">
<span className="lead">
<Translate value="label.custom-entity-attributes">Attribute Bundles</Translate>
<Translate value="label.attribute-bundles">Attribute Bundles</Translate>
</span>
</div>
<div className="p-3">
Expand Down Expand Up @@ -57,7 +57,7 @@ export function MetadataAttributeBundles({ entities, onDelete }) {
<Translate value="action.edit">Edit</Translate>
</span>
</Link>
<Button variant="link" className="text-danger" onClick={() => remove(bundle.resourceId)}>
<Button variant="link" className="text-danger" onClick={() => remove(bundle.resourceId, reload)}>
<FontAwesomeIcon icon={faTrash} size="lg" />
<span className="sr-only">
<Translate value="action.delete">Delete</Translate>
Expand Down

0 comments on commit 152673d

Please sign in to comment.