Merge pull request #626 from htsachakis/adjust-spool-button-on-show
Added adjust spool button
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { getBasePath } from "../../utils/url";
|
import { getBasePath } from "../../utils/url";
|
||||||
import { InboxOutlined, PrinterOutlined, ToTopOutlined } from "@ant-design/icons";
|
import { InboxOutlined, PrinterOutlined, ToTopOutlined, ToolOutlined } from "@ant-design/icons";
|
||||||
import { DateField, NumberField, Show, TextField } from "@refinedev/antd";
|
import { DateField, NumberField, Show, TextField } from "@refinedev/antd";
|
||||||
import { IResourceComponentsProps, useInvalidate, useShow, useTranslate } from "@refinedev/core";
|
import { IResourceComponentsProps, useInvalidate, useShow, useTranslate } from "@refinedev/core";
|
||||||
import { Button, Modal, Typography } from "antd";
|
import { Button, Modal, Typography } from "antd";
|
||||||
@@ -13,7 +13,7 @@ import { enrichText } from "../../utils/parsing";
|
|||||||
import { EntityType, useGetFields } from "../../utils/queryFields";
|
import { EntityType, useGetFields } from "../../utils/queryFields";
|
||||||
import { useCurrencyFormatter } from "../../utils/settings";
|
import { useCurrencyFormatter } from "../../utils/settings";
|
||||||
import { IFilament } from "../filaments/model";
|
import { IFilament } from "../filaments/model";
|
||||||
import { setSpoolArchived } from "./functions";
|
import { setSpoolArchived, useSpoolAdjustModal } from "./functions";
|
||||||
import { ISpool } from "./model";
|
import { ISpool } from "./model";
|
||||||
|
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
@@ -42,6 +42,9 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
|
|||||||
return currencyFormatter.format(price);
|
return currencyFormatter.format(price);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Provides the function to open the spool adjustment modal and the modal component itself
|
||||||
|
const { openSpoolAdjustModal, spoolAdjustModal } = useSpoolAdjustModal();
|
||||||
|
|
||||||
// Function for opening an ant design modal that asks for confirmation for archiving a spool
|
// Function for opening an ant design modal that asks for confirmation for archiving a spool
|
||||||
const archiveSpool = async (spool: ISpool, archive: boolean) => {
|
const archiveSpool = async (spool: ISpool, archive: boolean) => {
|
||||||
await setSpoolArchived(spool, archive);
|
await setSpoolArchived(spool, archive);
|
||||||
@@ -104,9 +107,9 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
|
|||||||
|
|
||||||
const colorObj = record?.filament.multi_color_hexes
|
const colorObj = record?.filament.multi_color_hexes
|
||||||
? {
|
? {
|
||||||
colors: record.filament.multi_color_hexes.split(","),
|
colors: record.filament.multi_color_hexes.split(","),
|
||||||
vertical: record.filament.multi_color_direction === "longitudinal",
|
vertical: record.filament.multi_color_direction === "longitudinal",
|
||||||
}
|
}
|
||||||
: record?.filament.color_hex;
|
: record?.filament.color_hex;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -115,6 +118,13 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
|
|||||||
title={record ? formatTitle(record) : ""}
|
title={record ? formatTitle(record) : ""}
|
||||||
headerButtons={({ defaultButtons }) => (
|
headerButtons={({ defaultButtons }) => (
|
||||||
<>
|
<>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
icon={<ToolOutlined />}
|
||||||
|
onClick={() => record && openSpoolAdjustModal(record)}
|
||||||
|
>
|
||||||
|
{t("spool.titles.adjust")}
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
icon={<PrinterOutlined />}
|
icon={<PrinterOutlined />}
|
||||||
@@ -133,6 +143,7 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{defaultButtons}
|
{defaultButtons}
|
||||||
|
{spoolAdjustModal}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user