Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2ff9ba4
feat: add value/label for p_app_method
SvenVw Jun 16, 2025
a58b367
feat: Add new function `getSoilParameterDescription` to obtain detail…
SvenVw Jun 16, 2025
2fb2db3
feat: Improve design of the fertilizer form page by making it more in…
SvenVw Jun 16, 2025
0e2fe59
feat: export types
SvenVw Jun 16, 2025
4356a53
refactor: remove not used import
SvenVw Jun 16, 2025
c962751
feat: Replace p_type_** with p_type at all fertilizer functions
SvenVw Jun 16, 2025
1505b4c
refactor: replace p_type usage at fdm-calculator
SvenVw Jun 16, 2025
fc75c27
fix: fix parameter description
SvenVw Jun 16, 2025
17facb6
fix: description of options for p_type
SvenVw Jun 16, 2025
072f778
feat: switch to select for p_type
SvenVw Jun 16, 2025
0ba9291
feat: make p_app_method_options to multiselect
SvenVw Jun 16, 2025
29723a3
feat: add checkboxes for application methods
SvenVw Jun 16, 2025
349cee7
fix: improve description
SvenVw Jun 16, 2025
bc125a8
feat: add p_app_method_options to form submission
SvenVw Jun 16, 2025
3bb59e0
feat: use new form for exisiting fertilizers as well
SvenVw Jun 16, 2025
e37b6f0
feat: add `p_app_method_options` as parameter of Fertilizer Catalogue
SvenVw Jun 17, 2025
75693e4
feat: Add parameter `p_app_method_options` to `fertilizer_catalogue` …
SvenVw Jun 17, 2025
7f95233
feat: make various types available
SvenVw Jun 17, 2025
8ea36cb
feat: implement p_app_method_options in various fertilizer functions
SvenVw Jun 17, 2025
5eb69f8
fix: type errors
SvenVw Jun 17, 2025
ef6a9d1
refactor: update test
SvenVw Jun 17, 2025
ac05d8b
fix: at `syncCatalogue` that when item already exists, but the hash h…
SvenVw Jun 17, 2025
592732e
fix: set updated value
SvenVw Jun 17, 2025
d7219c1
feat: use 2 columns for application methods on large screens
SvenVw Jun 17, 2025
2355d88
fix: validation of optional fields
SvenVw Jun 17, 2025
0102095
feat: add validation that p_n_wc is required when p_n_rt is provided
SvenVw Jun 17, 2025
b8fc220
chore: style
SvenVw Jun 17, 2025
4cc29dc
fix: form parsing for more complex types
SvenVw Jun 17, 2025
5f9e9e0
feat: Add application method to form for fertilizer application
SvenVw Jun 18, 2025
78ebd90
fix: store p_app_method
SvenVw Jun 18, 2025
3f79b0e
feat: Show application method for each application in the list of fe…
SvenVw Jun 18, 2025
36803f1
feat: Add feature to select an existing fertilizer as template for a…
SvenVw Jun 18, 2025
68ff33b
fix: validation errors
SvenVw Jun 18, 2025
a41b0dc
refactor: remove not used conponent
SvenVw Jun 18, 2025
2015d13
fix: typo
SvenVw Jun 18, 2025
634bf26
fix: unit test
SvenVw Jun 18, 2025
04a0c09
fix: add validation for selecting an option for p_app_method
SvenVw Jun 18, 2025
517c467
fix: Reject empty values rather than just requiring one truthy element
SvenVw Jun 18, 2025
e9389f3
fix: prevent possbible runtime crash when option is missing
SvenVw Jun 18, 2025
ef50866
fix: type
SvenVw Jun 18, 2025
6fb4f35
refactor: remove obsolete types
SvenVw Jun 18, 2025
eac4cd5
fix: validation for selecting at least 1 application method
SvenVw Jun 18, 2025
27dec38
fix: type
SvenVw Jun 18, 2025
d1ea37e
fix: updateFertilizerFromCatalogue silently wipes existing type flags
SvenVw Jun 18, 2025
e2773a9
nitpicks
SvenVw Jun 18, 2025
23bced7
fix
SvenVw Jun 18, 2025
b36b09f
Merge branch 'development' into add-application-method
SvenVw Jun 18, 2025
ed7cd2d
Merge branch 'development' into add-application-method
SvenVw Jun 18, 2025
955f854
fix: unit conversion at calculation of N supply by other fertilizers
SvenVw Jun 18, 2025
a5bd600
fix: inserting pseudocolumn
SvenVw Jun 18, 2025
3e339fd
fix: remove double conversion
SvenVw Jun 19, 2025
86e777d
fix: copy errors in name
SvenVw Jun 19, 2025
a2bd823
fix: unit
SvenVw Jun 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eleven-parrots-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Display the application method for each fertilizer application in the list
5 changes: 5 additions & 0 deletions .changeset/fluffy-steaks-follow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-calculator": patch
---

Fix unit conversion at calculation of N supply by other fertilizers
5 changes: 5 additions & 0 deletions .changeset/fresh-buses-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": patch
---

Replace the `p_type_*` boolean flags with the unified `p_type` field across all fertilizer functions
5 changes: 5 additions & 0 deletions .changeset/little-carrots-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-data": minor
---

Add `p_app_method_options` as parameter of Fertilizer Catalogue
5 changes: 5 additions & 0 deletions .changeset/new-knives-bet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-core": patch
---

Fixes a bug in `syncCatalogue` where, when an item already exists but its hash has changed, the other properties were not updated
5 changes: 5 additions & 0 deletions .changeset/poor-towns-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Add a feature to select an existing fertilizer as a template for new fertilizers
5 changes: 5 additions & 0 deletions .changeset/quick-states-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Improve the design of the fertilizer form page by making it more intuitive and clear.
5 changes: 5 additions & 0 deletions .changeset/rich-donkeys-stay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-data": minor
---

Expose the `ApplicationMethods` union type in the `@svenvw/fdm-data` package
5 changes: 5 additions & 0 deletions .changeset/shaggy-dancers-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-core": minor
---

Add the new function `getSoilParameterDescription` to obtain details about fertilizer parameters
5 changes: 5 additions & 0 deletions .changeset/silver-mice-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Add an application-method field to the fertilizer-application form
5 changes: 5 additions & 0 deletions .changeset/tidy-apes-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-core": minor
---

Add the parameter `p_app_method_options` to `fertilizer_catalogue` to represent the possible methods that can be used to apply the fertilizer
59 changes: 56 additions & 3 deletions fdm-app/app/components/blocks/fertilizer-applications/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ import {
PopoverContent,
PopoverTrigger,
} from "~/components/ui/popover"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "~/components/ui/select"
import { cn } from "~/lib/utils"
import { Combobox } from "../../custom/combobox"
import { LoadingSpinner } from "../../custom/loadingspinner"
import { Combobox } from "~/components/custom/combobox"
import { LoadingSpinner } from "~/components/custom/loadingspinner"
import { FormSchema } from "./formschema"
import type { FertilizerOption } from "./types.d"

Expand All @@ -40,10 +47,19 @@ export function FertilizerApplicationForm({
resolver: zodResolver(FormSchema),
defaultValues: {
p_id: undefined,
p_app_method: undefined,
p_app_amount: undefined,
p_app_date: new Date(),
},
})
const p_id = form.watch("p_id")
const selectedFertilizer = options.find((option) => option.value === p_id)

useEffect(() => {
if (p_id) {
form.setValue("p_app_method", "")
}
}, [p_id, form.setValue])

Comment thread
SvenVw marked this conversation as resolved.
useEffect(() => {
if (form.formState.isSubmitSuccessful) {
Expand Down Expand Up @@ -75,6 +91,43 @@ export function FertilizerApplicationForm({
}
/>
</div>
<FormField
control={form.control}
name="p_app_method"
render={({ field }) => (
<FormItem>
<FormLabel>
Toedingsmethode
<span className="text-red-500">*</span>
</FormLabel>
<Select
onValueChange={field.onChange}
value={field.value ?? ""}
disabled={!selectedFertilizer}
>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Selecteer een methode" />
</SelectTrigger>
</FormControl>
<SelectContent>
{selectedFertilizer?.applicationMethodOptions?.map(
(option) => (
<SelectItem
key={option.value}
value={option.value}
Comment thread
SvenVw marked this conversation as resolved.
>
{option.label}
</SelectItem>
),
)}
</SelectContent>
</Select>
<FormDescription />
<FormMessage />
</FormItem>
)}
/>
<div>
<FormField
control={form.control}
Expand Down Expand Up @@ -182,7 +235,7 @@ export function FertilizerApplicationForm({
)}
/>
</div>
<div className="justify-end items-end">
<div className="flex justify-end items-baseline">
<Button type="submit">
{form.formState.isSubmitting ? (
<div className="flex items-center space-x-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const FormSchema = z.object({
.finite({
message: "Hoeveelheid moet een geheel getal zijn",
}),
p_app_method: z.string().min(1, "Toepassingsmethode is verplicht"),
p_app_date: z.coerce.date({
required_error: "Datum is verplicht",
invalid_type_error: "Datum is ongeldig",
Expand Down
17 changes: 16 additions & 1 deletion fdm-app/app/components/blocks/fertilizer-applications/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import { format } from "date-fns"
import { Button } from "~/components/ui/button"
import { LoadingSpinner } from "../../custom/loadingspinner"
import type { FertilizerApplication } from "./types.d"
import type { ApplicationMethods } from "@svenvw/fdm-data"

export function FertilizerApplicationsList({
fertilizerApplications,
applicationMethodOptions,
fetcher,
}: {
fertilizerApplications: FertilizerApplication[]
applicationMethodOptions: {
value: ApplicationMethods
label: string
}[]
fetcher: {
state: string
submit: (
Expand All @@ -21,6 +27,7 @@ export function FertilizerApplicationsList({

fetcher.submit({ p_app_id }, { method: "DELETE" })
}

return (
<div className="space-y-4">
{/* <div className="text-sm font-medium">Meststoffen</div> */}
Expand All @@ -34,7 +41,15 @@ export function FertilizerApplicationsList({
<p className="text-sm font-medium leading-none">
{application.p_name_nl}
</p>
{/* <p className="text-sm text-muted-foreground">m@example.com</p> */}
<p className="text-sm text-muted-foreground">
{application.p_app_method
? applicationMethodOptions.find(
(x) =>
x.value ===
application.p_app_method,
)?.label
: "Toedieningsmethode niet bekend"}
</p>
</div>
<div>
<p className="text-sm font-light leading-none">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import type { ApplicationMethods } from "@svenvw/fdm-data"

export interface FertilizerApplication {
p_app_id: string
p_app_ids: string[]
p_name_nl: string
p_app_amount: number
p_app_date: Date
p_app_method: ApplicationMethods | null
}

export interface FertilizerOption {
value: string
label: string
applicationMethodOptions: {
value: ApplicationMethods
label: string
}[]
}

export interface FertilizerApplicationsFormProps {
Expand Down
Loading