Skip to content

Commit

Permalink
Merge pull request #343 from pkpdapp-team/fixes
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
martinjrobins authored Feb 8, 2024
2 parents 87c5e5f + 58ea44e commit cea689d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions frontend-v2/src/components/DropdownButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const DropdownButton: React.FC<Props> = ({
data-cy={`dropdown-button-popover`}
anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
transformOrigin={{ vertical: "top", horizontal: "left" }}
style={{ zIndex: 9999 }}
>
{options.map((option, index) => (
<ListItemButton
Expand Down
2 changes: 1 addition & 1 deletion frontend-v2/src/features/main/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default function Sidebar() {
sx={{
width: { sm: `100%` },
ml: { sm: `${drawerWidth}px` },
zIndex: 10010000,
zIndex: 9998,
backgroundColor: "white",
}}
>
Expand Down
3 changes: 2 additions & 1 deletion frontend-v2/src/features/model/Model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ const Model: React.FC = () => {
if (model.pk_model === null) {
tabErrors[tabKeys[0]] = "Please select a PK model to simulate";
}
const isTumourModel = pd_model?.is_library_model && pd_model?.name.startsWith("tumour_growth");
const hasPdModel = model.pd_model !== null;
const isTumourModel = hasPdModel && pd_model?.is_library_model && pd_model?.name.startsWith("tumour_growth");
const noKillModel = !model.pd_model2;
if (model.pd_model && model.mappings.length === 0) {
// put exception for tumour growth models with no kill
Expand Down
6 changes: 3 additions & 3 deletions frontend-v2/src/features/simulation/SimulationSliderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ interface SimulationSliderProps {
slider: SimulationSlider;
onChange: (value: number) => void;
onSave: (value: number) => void;
remove: (index: number) => void;
onRemove: () => void;
units: UnitRead[];
}

const SimulationSliderView: React.FC<SimulationSliderProps> = ({
index,
slider,
onChange,
remove,
onRemove,
onSave,
units,
}) => {
Expand Down Expand Up @@ -88,7 +88,7 @@ const SimulationSliderView: React.FC<SimulationSliderProps> = ({
};

const handleDelete = () => {
remove(index);
onRemove();
};

const handleWider = () => {
Expand Down
10 changes: 7 additions & 3 deletions frontend-v2/src/features/simulation/Simulations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ const Simulations: React.FC = () => {
return <div>Not found</div>;
}

const orderedSliders = sliders.map((slider) => {
const orderedSliders = sliders.map((slider, i) => {
const variable = variables.find((v) => v.id === slider.variable);
return { ...slider, priority: variable ? paramPriority(variable) : 0 };
return { ...slider, priority: variable ? paramPriority(variable) : 0, fieldArrayIndex: i };
});
orderedSliders.sort((a, b) => a.priority - b.priority);

Expand Down Expand Up @@ -501,6 +501,10 @@ const Simulations: React.FC = () => {
setSliderValues({ ...sliderValues, [slider.variable]: value });
setLoadingSimulate(true);
};

const handleRemoveSlider = (index: number) => () => {
removeSlider(index);
}

const handleSaveSlider = (slider: SimulationSlider) => (value: number) => {
const variable = variables?.find((v) => v.id === slider.variable);
Expand Down Expand Up @@ -653,7 +657,7 @@ const Simulations: React.FC = () => {
index={index}
slider={slider}
onChange={handleChangeSlider(slider)}
remove={removeSlider}
onRemove={handleRemoveSlider(slider.fieldArrayIndex)}
onSave={handleSaveSlider(slider)}
units={units}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Growth = if(TS > 1e12,
kge*TS^gamma) in [mL/h]
desc: Tumor growth rate

dot(TS) = Growth in [mL/h]
dot(TS) = Growth in [mL]
desc: Tumor volume/ size
2 changes: 2 additions & 0 deletions pkpdapp/pkpdapp/models/dose.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def copy(self, stored_protocol):
'start_time': self.start_time,
'amount': self.amount,
'duration': self.duration,
'repeats': self.repeats,
'repeat_interval': self.repeat_interval,
'read_only': True,
}
return Dose.objects.create(**stored_dose_kwargs)
6 changes: 5 additions & 1 deletion pkpdapp/pkpdapp/tests/test_models/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def test_copy(self):
project=self.project,
)
protocol = Protocol.objects.create(name="my protocol")
dose = protocol.doses.create(amount=1.0, start_time=0.0)
dose = protocol.doses.create(
amount=1.0, start_time=0.0, repeats=2, repeat_interval=1.1
)
protocol.doses.set([dose])
a1 = pkpd_model.variables.get(qname="PKCompartment.A1")
a1.protocol = protocol
Expand Down Expand Up @@ -98,6 +100,8 @@ def test_copy(self):
self.assertNotEqual(new_dose.pk, dose.pk)
self.assertEqual(new_dose.amount, 1.0)
self.assertEqual(new_dose.start_time, 0.0)
self.assertEqual(new_dose.repeats, 2)
self.assertEqual(new_dose.repeat_interval, 1.1)

# check that the simulation is there and has the right name
self.assertEqual(new_project.simulations.count(), 1)
Expand Down

0 comments on commit cea689d

Please sign in to comment.