feat(documents): per-document custom-field print picker on offer/issued-order/invoice detail
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import SectionsEditor, {
|
||||
type DocumentSection,
|
||||
} from "../components/document/SectionsEditor";
|
||||
import LockBanner from "../components/document/LockBanner";
|
||||
import CustomFieldsPrintPicker from "../components/document/CustomFieldsPrintPicker";
|
||||
import { useDocumentLock } from "../hooks/useDocumentLock";
|
||||
import { useUnsavedChangesGuard } from "../hooks/useUnsavedChangesGuard";
|
||||
import { useDocumentPdf } from "../hooks/useDocumentPdf";
|
||||
@@ -137,6 +138,7 @@ interface IssuedOrderSavePayload {
|
||||
internal_notes: string;
|
||||
items: IssuedOrderItemPayload[];
|
||||
sections: IssuedOrderSectionPayload[];
|
||||
selected_custom_fields: number[];
|
||||
status?: string;
|
||||
}
|
||||
|
||||
@@ -164,6 +166,9 @@ export default function IssuedOrderDetail() {
|
||||
emptyDocumentItem(),
|
||||
]);
|
||||
const [sections, setSections] = useState<DocumentSection[]>([]);
|
||||
const [selectedCustomFields, setSelectedCustomFields] = useState<number[]>(
|
||||
[],
|
||||
);
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
const [saving, setSaving] = useState(false);
|
||||
// Which save action is in flight ("draft" | the live status | "save"), so
|
||||
@@ -308,6 +313,7 @@ export default function IssuedOrderDetail() {
|
||||
}))
|
||||
: [];
|
||||
setSections(mappedSections);
|
||||
setSelectedCustomFields(d.selected_custom_fields ?? []);
|
||||
|
||||
setLockedBy(d.locked_by ?? null);
|
||||
// Acquire the edit lock when nobody holds it, the order is still
|
||||
@@ -430,6 +436,7 @@ export default function IssuedOrderDetail() {
|
||||
content: s.content,
|
||||
position: i,
|
||||
})),
|
||||
selected_custom_fields: selectedCustomFields,
|
||||
};
|
||||
// Only set status when a target is given (create-as-draft / create-as-live
|
||||
// / finalize). Editing a live order sends no status — the backend keeps
|
||||
@@ -874,6 +881,15 @@ export default function IssuedOrderDetail() {
|
||||
placeholder="Objednáváme si u Vás: (ponechte prázdné pro výchozí)"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Box sx={{ mt: 2 }}>
|
||||
<CustomFieldsPrintPicker
|
||||
fields={companySettings?.custom_fields ?? []}
|
||||
selected={selectedCustomFields}
|
||||
disabled={!editable}
|
||||
onChange={setSelectedCustomFields}
|
||||
/>
|
||||
</Box>
|
||||
</Card>
|
||||
|
||||
{/* Items */}
|
||||
|
||||
Reference in New Issue
Block a user