+ {(description || tableProps.pagination) && (
+
+ {description && {description}
}
+ {tableProps.pagination && (
+
+
+
+ )}
+
+ )}
+
+
+ {
+ const value = event.target.value;
+ setSearchValue(value);
+ if (value === "") {
+ applySearchFilter("");
+ }
+ }}
+ onSearch={(value) => {
+ setSearchValue(value);
+ applySearchFilter(value);
+ }}
+ />
+
+
+
+
+ }
+ onClick={() => {
+ setSearchValue("");
+ setFilters([], "replace");
+ setCurrentPage(1);
+ }}
+ >
+ {t("buttons.clearFilters")}
+
+
+
+ ({
+ key: columnId,
+ label: getColumnLabel(columnId),
+ })),
+ selectedKeys: showColumns,
+ selectable: true,
+ multiple: true,
+ onDeselect: (info) => {
+ setShowColumns(info.selectedKeys as string[]);
+ },
+ onSelect: (info) => {
+ setShowColumns(info.selectedKeys as string[]);
+ },
+ }}
+ >
+ }>{t("buttons.hideColumns")}
+
+
+
+
+
{
+ selectUnselectFiltered(e.target.checked);
+ }}
+ >
+ {t("printing.filamentSelect.selectAll")}
+
+
+ {t("printing.filamentSelect.selectedTotal", {
+ count: selectedItems.length,
+ })}
+
+
+ {onPrint && (
+
+ )}
+ {onExport && (
+
+ )}
+
+
+
+
+
+ (
+ handleSelectItem(item.id)} />
+ ),
+ },
+ SortedColumn({
+ ...commonProps,
+ id: "id",
+ i18ncat: "filament",
+ width: 70,
+ }),
+ FilteredQueryColumn({
+ ...commonProps,
+ id: "spool_count",
+ dataId: "spool_count",
+ i18ncat: "filament",
+ width: 120,
+ includeEmptyFilter: false,
+ filterValueQuery: useSpoolmanSpoolCounts(),
+ transform: (value) => value ?? 0,
+ }),
+ FilteredQueryColumn({
+ ...commonProps,
+ id: "vendor.name",
+ i18nkey: "filament.fields.vendor_name",
+ width: 200,
+ filterValueQuery: useSpoolmanVendors(),
+ }),
+ SpoolIconColumn({
+ ...commonProps,
+ id: "name",
+ i18ncat: "filament",
+ width: 360,
+ color: (record: IFilamentCollapsed) =>
+ record.multi_color_hexes
+ ? {
+ colors: record.multi_color_hexes.split(","),
+ vertical: record.multi_color_direction === "longitudinal",
+ }
+ : record.color_hex,
+ filterValueQuery: useSpoolmanFilamentNames(),
+ }),
+ FilteredQueryColumn({
+ ...commonProps,
+ id: "material",
+ i18ncat: "filament",
+ width: 140,
+ filterValueQuery: useSpoolmanMaterials(),
+ }),
+ ])}
+ />
+
+
+ >
+ );
+};
+
+export default FilamentSelectModal;
diff --git a/client/src/pages/printing/index.tsx b/client/src/pages/printing/index.tsx
index f6ddc4246..4760c3735 100644
--- a/client/src/pages/printing/index.tsx
+++ b/client/src/pages/printing/index.tsx
@@ -2,29 +2,39 @@ import { PageHeader } from "@refinedev/antd";
import { useTranslate } from "@refinedev/core";
import { theme } from "antd";
import { Content } from "antd/es/layout/layout";
-import dayjs from "dayjs";
-import utc from "dayjs/plugin/utc";
+import { useEffect, useMemo } from "react";
import { useNavigate, useSearchParams } from "react-router";
import SpoolQRCodePrintingDialog from "./spoolQrCodePrintingDialog";
-import SpoolSelectModal from "./spoolSelectModal";
-
-dayjs.extend(utc);
const { useToken } = theme;
export const Printing = () => {
const { token } = useToken();
const t = useTranslate();
- const [searchParams, setSearchParams] = useSearchParams();
+ const [searchParams] = useSearchParams();
const navigate = useNavigate();
const spoolIds = searchParams.getAll("spools").map(Number);
- const step = spoolIds.length > 0 ? 1 : 0;
+ const returnUrl = searchParams.get("return");
+ const selectionPath = useMemo(() => {
+ const params = new URLSearchParams();
+ if (returnUrl) {
+ params.set("return", returnUrl);
+ }
+ const query = params.toString();
+ return `/spool/labels${query ? `?${query}` : ""}`;
+ }, [returnUrl]);
+
+ useEffect(() => {
+ if (spoolIds.length === 0) {
+ navigate(selectionPath, { replace: true });
+ }
+ }, [navigate, selectionPath, spoolIds.length]);
return (
<>