Skip to content

Commit

Permalink
Final locations updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Donkie committed Nov 24, 2024
1 parent d142b0e commit 46a9097
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
7 changes: 6 additions & 1 deletion client/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@
"help": {
"list": "Help | Spoolman"
},
"locations": {
"list": "Locations | Spoolman"
},
"filament": {
"list": "Filaments | Spoolman",
"show": "#{{id}} Show Filament | Spoolman",
Expand All @@ -382,7 +385,9 @@
}
},
"locations": {
"locations": "Locations",
"new_location": "New Location",
"no_location": "No Location"
"no_location": "No Location",
"no_locations_help": "This page lets you organize your spools in locations, add some spools to get started!"
}
}
10 changes: 9 additions & 1 deletion client/src/pages/locations/components/location.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Input } from "antd";
import { Button, Input, theme } from "antd";
import type { Identifier, XYCoord } from "dnd-core";
import { useRef, useState } from "react";
import { useDrag, useDrop } from "react-dnd";
Expand All @@ -10,6 +10,8 @@ import { DragItem, ItemTypes, SpoolDragItem } from "../dnd";
import { EMPTYLOC } from "../functions";
import { SpoolList } from "./spoolList";

const { useToken } = theme;

export function Location({
index,
title,
Expand All @@ -31,6 +33,7 @@ export function Location({
locationSpoolOrder: number[];
setLocationSpoolOrder: (spoolOrder: number[]) => void;
}) {
const { token } = useToken();
const t = useTranslate();
const [editTitle, setEditTitle] = useState(false);
const [newTitle, setNewTitle] = useState(title);
Expand Down Expand Up @@ -133,6 +136,10 @@ export function Location({

const canEditTitle = title != EMPTYLOC;

const titleStyle = {
color: canEditTitle ? undefined : token.colorTextTertiary,
};

return (
<div
className={"loc-container " + (title != EMPTYLOC ? "grabable" : "")}
Expand Down Expand Up @@ -161,6 +168,7 @@ export function Location({
setNewTitle(title);
setEditTitle(true);
}}
style={titleStyle}
>
{displayTitle}
</span>
Expand Down
31 changes: 18 additions & 13 deletions client/src/pages/locations/components/locationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,24 @@ export function LocationContainer() {
};

return (
<div className="loc-metacontainer">
{containers}
<div className="newLocContainer">
<Button
type="dashed"
shape="circle"
icon={<PlusOutlined />}
size="large"
style={{
margin: "1em",
}}
onClick={addNewLocation}
/>
<div>
{!isLoading && spoolData.data.length == 0 && (
<div className="no-locations">{t("locations.no_locations_help")}</div>
)}
<div className="loc-metacontainer">
{containers}
<div className="newLocContainer">
<Button
type="dashed"
shape="circle"
icon={<PlusOutlined />}
size="large"
style={{
margin: "1em",
}}
onClick={addNewLocation}
/>
</div>
</div>
</div>
);
Expand Down
12 changes: 8 additions & 4 deletions client/src/pages/locations/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IResourceComponentsProps } from "@refinedev/core";
import { IResourceComponentsProps, useTranslate } from "@refinedev/core";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import React from "react";
Expand All @@ -11,10 +11,14 @@ import "./locations.css";
dayjs.extend(utc);

export const Locations: React.FC<IResourceComponentsProps> = () => {
const t = useTranslate();
return (
<DndProvider backend={HTML5Backend}>
<LocationContainer />
</DndProvider>
<div>
<h1>{t("locations.locations")}</h1>
<DndProvider backend={HTML5Backend}>
<LocationContainer />
</DndProvider>
</div>
);
};

Expand Down

0 comments on commit 46a9097

Please sign in to comment.