feat: implement custom page title setting

closes issue #21
master
Katja Lutz 2 years ago
parent 5548b47253
commit c35a017d91

@ -40,6 +40,7 @@ import {
POSITION_TYPE_AGILE, POSITION_TYPE_AGILE,
POSITION_TYPE_QUANTITY, POSITION_TYPE_QUANTITY,
PrintType, PrintType,
printTypeSelectTitles,
printTypeTitles, printTypeTitles,
PRINT_TYPE_CONFIRMATION, PRINT_TYPE_CONFIRMATION,
PRINT_TYPE_INVOICE, PRINT_TYPE_INVOICE,
@ -349,6 +350,22 @@ const SettingsOverlay: Component = () => {
/> />
</div> </div>
<div class="col-span-2">
<TextInput
label="Titel"
labelMinWidth={fullWidthLabelWidth}
placeholder={
state.project.title
? undefined
: printTypeTitles[uiState.printType]
}
value={state.project.title || ""}
onInput={(evt) =>
setState("project", "title", evt.currentTarget.value)
}
/>
</div>
<div class="col-span-2"> <div class="col-span-2">
<TextArea <TextArea
label="Einleitung" label="Einleitung"
@ -981,7 +998,7 @@ const SettingsOverlay: Component = () => {
value={type} value={type}
selected={type === uiState.printType} selected={type === uiState.printType}
> >
{printTypeTitles[type]} {printTypeSelectTitles[type]}
</option> </option>
)} )}
</For> </For>

@ -28,6 +28,7 @@ import {
createStore, createStore,
createUiStore, createUiStore,
LocalStoreContext, LocalStoreContext,
printTypeSelectTitles,
printTypeTitles, printTypeTitles,
PRINT_TYPE_CONFIRMATION, PRINT_TYPE_CONFIRMATION,
PRINT_TYPE_INVOICE, PRINT_TYPE_INVOICE,
@ -143,7 +144,7 @@ export default function Home() {
(state.project.projectNumber.length > 0 (state.project.projectNumber.length > 0
? `${state.project.projectNumber} - ` ? `${state.project.projectNumber} - `
: "") + : "") +
printTypeTitles[uiState.printType] printTypeSelectTitles[uiState.printType]
); );
const externalTitle = "Räppli - Web App für Schweizerische Rechnungen"; const externalTitle = "Räppli - Web App für Schweizerische Rechnungen";
@ -303,6 +304,10 @@ export default function Home() {
</Show> </Show>
); );
const pageTitle = createMemo(function () {
return state.project.title || printTypeTitles[uiState.printType];
});
return ( return (
<> <>
<Style type="text/css">{` <Style type="text/css">{`
@ -327,7 +332,7 @@ export default function Home() {
<Page> <Page>
<InnerPadding> <InnerPadding>
<PageHeader /> <PageHeader />
<Title>Offerte</Title> <Title>{pageTitle()}</Title>
<Preface /> <Preface />
<PositionsWithData /> <PositionsWithData />
<Conclusion /> <Conclusion />
@ -339,7 +344,7 @@ export default function Home() {
<Page> <Page>
<InnerPadding> <InnerPadding>
<PageHeader /> <PageHeader />
<Title>Auftragsbestätigung</Title> <Title>{pageTitle()}</Title>
<Preface /> <Preface />
<PositionsWithData /> <PositionsWithData />
<Conclusion /> <Conclusion />
@ -351,7 +356,7 @@ export default function Home() {
<Page> <Page>
<InnerPadding> <InnerPadding>
<PageHeader /> <PageHeader />
<Title>Rechnung</Title> <Title>{pageTitle()}</Title>
<Preface /> <Preface />
<PositionsWithData /> <PositionsWithData />
<Show when={localState.paymentTerms}> <Show when={localState.paymentTerms}>

@ -36,10 +36,15 @@ export type PrintType =
export const printTypeTitles = { export const printTypeTitles = {
[PRINT_TYPE_OFFER]: "Offerte", [PRINT_TYPE_OFFER]: "Offerte",
[PRINT_TYPE_CONFIRMATION]: "Bestätigung", [PRINT_TYPE_CONFIRMATION]: "Auftragsbestätigung",
[PRINT_TYPE_INVOICE]: "Rechnung", [PRINT_TYPE_INVOICE]: "Rechnung",
}; };
export const printTypeSelectTitles = {
...printTypeTitles,
[PRINT_TYPE_CONFIRMATION]: "Bestätigung",
};
export const createUiStore = () => export const createUiStore = () =>
createStore_({ createStore_({
lastSaved: 0, lastSaved: 0,
@ -63,6 +68,7 @@ export const storeSchema = z.object({
deliveryNumber: z.string(), deliveryNumber: z.string(),
deliveryDate: z.number().optional(), deliveryDate: z.number().optional(),
date: z.number(), date: z.number(),
title: z.string().optional(),
preface: z.string().optional(), preface: z.string().optional(),
conclusion: z.string().optional(), conclusion: z.string().optional(),
}), }),

Loading…
Cancel
Save