add spool count in locations with a setting to enable / disable the display
This commit is contained in:
@@ -399,6 +399,10 @@
|
|||||||
"round_prices": {
|
"round_prices": {
|
||||||
"label": "Zaokrouhlené ceny",
|
"label": "Zaokrouhlené ceny",
|
||||||
"tooltip": "Zaokrouhlete ceny na nejbližší celé číslo."
|
"tooltip": "Zaokrouhlete ceny na nejbližší celé číslo."
|
||||||
|
},
|
||||||
|
"show_spool_count": {
|
||||||
|
"label": "Zobrazit počet cívek",
|
||||||
|
"tooltip": "Zobrazit počet cívek pro každé umístění."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": "Nastavení"
|
"settings": "Nastavení"
|
||||||
|
|||||||
@@ -365,6 +365,10 @@
|
|||||||
"round_prices": {
|
"round_prices": {
|
||||||
"label": "Gerundeter Preis",
|
"label": "Gerundeter Preis",
|
||||||
"tooltip": "Rundet die Preise auf die nächsthöhere ganze Zahl."
|
"tooltip": "Rundet die Preise auf die nächsthöhere ganze Zahl."
|
||||||
|
},
|
||||||
|
"show_spool_count": {
|
||||||
|
"label": "Spulenanzahl anzeigen",
|
||||||
|
"tooltip": "Zeigt die Anzahl der Spulen am jeweiligen Ort an."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra_fields": {
|
"extra_fields": {
|
||||||
|
|||||||
@@ -322,6 +322,10 @@
|
|||||||
"round_prices": {
|
"round_prices": {
|
||||||
"label": "Round prices",
|
"label": "Round prices",
|
||||||
"tooltip": "Round prices to the nearest whole number."
|
"tooltip": "Round prices to the nearest whole number."
|
||||||
|
},
|
||||||
|
"show_spool_count": {
|
||||||
|
"label": "Show Spool Count",
|
||||||
|
"tooltip": "Show the number of spools for each location."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra_fields": {
|
"extra_fields": {
|
||||||
|
|||||||
@@ -362,6 +362,10 @@
|
|||||||
"base_url": {
|
"base_url": {
|
||||||
"label": "URL base",
|
"label": "URL base",
|
||||||
"tooltip": "La URL base que se utilizará al generar funciones como códigos QR."
|
"tooltip": "La URL base que se utilizará al generar funciones como códigos QR."
|
||||||
|
},
|
||||||
|
"show_spool_count": {
|
||||||
|
"label": "Mostrar cantidad de bobinas",
|
||||||
|
"tooltip": "Mostrar el número de bobinas para cada ubicación."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra_fields": {
|
"extra_fields": {
|
||||||
|
|||||||
@@ -365,7 +365,12 @@
|
|||||||
"round_prices": {
|
"round_prices": {
|
||||||
"label": "Afgeronde prijzen",
|
"label": "Afgeronde prijzen",
|
||||||
"tooltip": "Rond prijzen af op het dichtstbijzijnde gehele getal."
|
"tooltip": "Rond prijzen af op het dichtstbijzijnde gehele getal."
|
||||||
|
},
|
||||||
|
"show_spool_count": {
|
||||||
|
"label": "Spoelaantal weergeven",
|
||||||
|
"tooltip": "Toon het aantal spoelen per locatie."
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"extra_fields": {
|
"extra_fields": {
|
||||||
"tab": "Extra velden",
|
"tab": "Extra velden",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { ISpool } from "../../spools/model";
|
|||||||
import { DragItem, ItemTypes, SpoolDragItem } from "../dnd";
|
import { DragItem, ItemTypes, SpoolDragItem } from "../dnd";
|
||||||
import { EMPTYLOC } from "../functions";
|
import { EMPTYLOC } from "../functions";
|
||||||
import { SpoolList } from "./spoolList";
|
import { SpoolList } from "./spoolList";
|
||||||
|
import { useGetSetting } from "../../../utils/querySettings";
|
||||||
|
|
||||||
const { useToken } = theme;
|
const { useToken } = theme;
|
||||||
|
|
||||||
@@ -139,6 +140,10 @@ export function Location({
|
|||||||
const titleStyle = {
|
const titleStyle = {
|
||||||
color: canEditTitle ? undefined : token.colorTextTertiary,
|
color: canEditTitle ? undefined : token.colorTextTertiary,
|
||||||
};
|
};
|
||||||
|
const showSpoolCount = JSON.parse(useGetSetting("show_spool_count").data?.value ?? "false");
|
||||||
|
const spoolCountStyle = {
|
||||||
|
color: token.colorTextQuaternary,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -169,8 +174,11 @@ export function Location({
|
|||||||
setEditTitle(true);
|
setEditTitle(true);
|
||||||
}}
|
}}
|
||||||
style={titleStyle}
|
style={titleStyle}
|
||||||
>
|
>
|
||||||
{displayTitle}
|
{displayTitle}
|
||||||
|
{showSpoolCount && (
|
||||||
|
<span style={spoolCountStyle}>{" "}({spools.length})</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{showDelete && <Button icon={<DeleteOutlined />} size="small" type="text" onClick={onDelete} />}
|
{showDelete && <Button icon={<DeleteOutlined />} size="small" type="text" onClick={onDelete} />}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export function GeneralSettings() {
|
|||||||
const setBaseUrl = useSetSetting("base_url");
|
const setBaseUrl = useSetSetting("base_url");
|
||||||
const setCurrency = useSetSetting("currency");
|
const setCurrency = useSetSetting("currency");
|
||||||
const setRoundPrices = useSetSetting("round_prices");
|
const setRoundPrices = useSetSetting("round_prices");
|
||||||
|
const setShowSpoolCount = useSetSetting("show_spool_count");
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [messageApi, contextHolder] = message.useMessage();
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
@@ -19,6 +20,7 @@ export function GeneralSettings() {
|
|||||||
currency: JSON.parse(settings.data.currency.value),
|
currency: JSON.parse(settings.data.currency.value),
|
||||||
base_url: JSON.parse(settings.data.base_url.value),
|
base_url: JSON.parse(settings.data.base_url.value),
|
||||||
round_prices: JSON.parse(settings.data.round_prices.value),
|
round_prices: JSON.parse(settings.data.round_prices.value),
|
||||||
|
show_spool_count: JSON.parse(settings.data.show_spool_count.value),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [settings.data, form]);
|
}, [settings.data, form]);
|
||||||
@@ -31,7 +33,7 @@ export function GeneralSettings() {
|
|||||||
}, [setCurrency.isSuccess, messageApi, t]);
|
}, [setCurrency.isSuccess, messageApi, t]);
|
||||||
|
|
||||||
// Handle form submit
|
// Handle form submit
|
||||||
const onFinish = (values: { currency: string; base_url: string, round_prices: boolean }) => {
|
const onFinish = (values: { currency: string; base_url: string, round_prices: boolean, show_spool_count: boolean }) => {
|
||||||
// Check if the currency has changed
|
// Check if the currency has changed
|
||||||
if (settings.data?.currency.value !== JSON.stringify(values.currency)) {
|
if (settings.data?.currency.value !== JSON.stringify(values.currency)) {
|
||||||
setCurrency.mutate(values.currency);
|
setCurrency.mutate(values.currency);
|
||||||
@@ -45,6 +47,11 @@ export function GeneralSettings() {
|
|||||||
if (settings.data?.round_prices.value !== JSON.stringify(values.round_prices)) {
|
if (settings.data?.round_prices.value !== JSON.stringify(values.round_prices)) {
|
||||||
setRoundPrices.mutate(values.round_prices);
|
setRoundPrices.mutate(values.round_prices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the setting to show spool count has changed
|
||||||
|
if (settings.data?.show_spool_count.value !== JSON.stringify(values.show_spool_count)) {
|
||||||
|
setShowSpoolCount.mutate(values.show_spool_count);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
@@ -55,6 +62,8 @@ export function GeneralSettings() {
|
|||||||
initialValues={{
|
initialValues={{
|
||||||
currency: settings.data?.currency.value,
|
currency: settings.data?.currency.value,
|
||||||
round_prices: settings.data?.round_prices.value,
|
round_prices: settings.data?.round_prices.value,
|
||||||
|
base_url: settings.data?.base_url.value,
|
||||||
|
show_spool_count: settings.data?.show_spool_count.value,
|
||||||
}}
|
}}
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
style={{
|
style={{
|
||||||
@@ -102,6 +111,15 @@ export function GeneralSettings() {
|
|||||||
<Checkbox />
|
<Checkbox />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label={t("settings.general.show_spool_count.label")}
|
||||||
|
tooltip={t("settings.general.show_spool_count.tooltip")}
|
||||||
|
name="show_spool_count"
|
||||||
|
valuePropName="checked"
|
||||||
|
>
|
||||||
|
<Checkbox />
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item wrapperCol={{ offset: 8, span: 16 }}>
|
<Form.Item wrapperCol={{ offset: 8, span: 16 }}>
|
||||||
<Button type="primary" htmlType="submit" loading={settings.isFetching || setCurrency.isLoading}>
|
<Button type="primary" htmlType="submit" loading={settings.isFetching || setCurrency.isLoading}>
|
||||||
{t("buttons.save")}
|
{t("buttons.save")}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ def parse_setting(key: str) -> SettingDefinition:
|
|||||||
|
|
||||||
register_setting("currency", SettingType.STRING, json.dumps("EUR"))
|
register_setting("currency", SettingType.STRING, json.dumps("EUR"))
|
||||||
register_setting("round_prices", SettingType.BOOLEAN, json.dumps(obj=False))
|
register_setting("round_prices", SettingType.BOOLEAN, json.dumps(obj=False))
|
||||||
|
register_setting("show_spool_count", SettingType.BOOLEAN, json.dumps(obj=False))
|
||||||
register_setting("print_presets", SettingType.ARRAY, json.dumps([]))
|
register_setting("print_presets", SettingType.ARRAY, json.dumps([]))
|
||||||
|
|
||||||
register_setting("extra_fields_vendor", SettingType.ARRAY, json.dumps([]))
|
register_setting("extra_fields_vendor", SettingType.ARRAY, json.dumps([]))
|
||||||
|
|||||||
Reference in New Issue
Block a user