Skip to content

Commit

Permalink
Merge pull request #585 from NBISweden/fix/reset-selling-herd
Browse files Browse the repository at this point in the history
Fix/reset selling herd
  • Loading branch information
Jonas Hagberg authored Dec 12, 2022
2 parents 0c8007b + 41e5372 commit 973d08c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ def next_individual_number(herd, birth_date, breeding_event):
fn.COALESCE(
Breeding.birth_date,
Breeding.breed_date + 30,
)
),
Breeding.id,
]
)
events = (
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/individual_add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export function IndividualAdd({
if (!mother) {
return;
}
console.log("Mother get is", mother);
let herds = mother.herd_tracking;

if (herds.length > 0) {
Expand Down Expand Up @@ -357,8 +356,8 @@ export function IndividualAdd({
getIndnumbSuggestion(limitedBreedingInput);
}
} else if (
individual?.origin_herd.herd === "GX1" ||
individual?.origin_herd.herd === "MX1"
individual?.origin_herd?.herd === "GX1" ||
individual?.origin_herd?.herd === "MX1"
) {
handleUpdateIndividual("number", null);
}
Expand Down Expand Up @@ -549,7 +548,6 @@ export function IndividualAdd({
const getIndnumbSuggestion = async (
BreedingMatch: Breeding | LimitedBreeding
) => {
console.log(BreedingMatch);
post(`/api/breeding/nextind/`, BreedingMatch).then(
(json) => {
switch (json.status) {
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/individual_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ export function IndividualForm({
label: `${c.id} - ${c.name}`,
};
});
} else if (
individual &&
colors &&
Object.keys(colors).includes(individual.genebank)
) {
return colors[individual.genebank].map((c) => {
return {
id: c.id,
comment: c.comment,
value: c.name,
label: `${c.id} - ${c.name}`,
};
});
}
return [];
}, [colors, genebank]);
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/individual_sellingform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export function IndividualSellingForm({
<Autocomplete
key={herdKey}
options={herdOptions}
value={herdOptions.find((option) => option.herd == individual.herd)}
value={
herdOptions.find((option) => option.herd == individual.herd) ?? null
}
getOptionLabel={(option: LimitedHerd) => herdLabel(option)}
renderInput={(params) => (
<TextField
Expand Down

0 comments on commit 973d08c

Please # to comment.