Skip to content

Commit 002d018

Browse files
committed
Add "back" column for deleting spans
Looks like a feature related to #140 It was originally added in 9b43154 but didn't work
1 parent f4a844c commit 002d018

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

admin/src/Components/UiKitIcon.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react";
2+
3+
// See ui-kit documentation for the list of all available icons
4+
// https://getuikit.com/docs/icon
5+
type UiKitIconName = "trash";
6+
7+
type IconProps = {
8+
icon: UiKitIconName;
9+
};
10+
11+
const raise_to_align_with_text: React.CSSProperties = {
12+
display: "inline-block",
13+
transform: "translateY(-2px)", // Make icon vertically aligned with text
14+
};
15+
16+
export default function UiKitIcon({ icon }: IconProps): React.ReactElement {
17+
return <span uk-icon={"icon: " + icon} style={raise_to_align_with_text} />;
18+
}

admin/src/Membership/MemberBoxSpans.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import { Link, useParams } from "react-router-dom";
44
import CollectionTable from "../Components/CollectionTable";
55
import DateShow from "../Components/DateShow";
66
import DateTimeShow from "../Components/DateTimeShow";
7+
import UiKitIcon from "../Components/UiKitIcon";
78
import Collection from "../Models/Collection";
89
import { ADD_LABACCESS_DAYS } from "../Models/ProductAction";
910
import Span from "../Models/Span";
1011
import { get } from "../gateway";
1112
import { confirmModal } from "../message";
1213
import MembershipPeriodsInput from "./MembershipPeriodsInput";
1314

15+
const empty_title_with_nonzero_width = <>&nbsp;&nbsp;&nbsp;&nbsp;</>;
16+
1417
function MemberBoxSpans() {
1518
const { member_id } = useParams();
1619

@@ -79,10 +82,11 @@ function MemberBoxSpans() {
7982
{ title: "#", sort: "span_id" },
8083
{ title: "Typ", sort: "type" },
8184
{ title: "Skapad", sort: "created_at" },
82-
{ title: "" },
85+
{ title: "Ursprung" },
8386
{ title: "Raderad", sort: "deleted_at" },
8487
{ title: "Start", sort: "startdate" },
8588
{ title: "Slut", sort: "enddate" },
89+
{ title: empty_title_with_nonzero_width },
8690
]}
8791
rowComponent={({ item }) => (
8892
<tr>
@@ -110,12 +114,14 @@ function MemberBoxSpans() {
110114
<DateShow date={item.enddate} />
111115
</td>
112116
<td>
113-
<a
114-
onClick={() => deleteItem(item)}
115-
className="removebutton"
116-
>
117-
<i className="uk-icon-trash" />
118-
</a>
117+
{item.deleted_at === null && (
118+
<a
119+
onClick={() => deleteItem(item)}
120+
className="removebutton"
121+
>
122+
<UiKitIcon icon="trash" />
123+
</a>
124+
)}
119125
</td>
120126
</tr>
121127
)}

0 commit comments

Comments
 (0)