File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 13
13
import Table from ' ../ui/Table.svelte' ;
14
14
import ConstraintEditor from ' ./ConstraintEditor.svelte' ;
15
15
16
+ export let initialPlans: PlanList [] = [];
17
+
18
+ let constraintModelId: number | null = null ;
16
19
let filterText: string = ' ' ;
17
20
let filteredConstraints: Constraint [] = [];
18
21
let selectedConstraint: Constraint | null = null ;
29
32
selectedConstraint = null ;
30
33
}
31
34
}
35
+ $ : constraintModelId = getConstraintModelId (selectedConstraint );
32
36
33
37
async function deleteConstraint(id : number ) {
34
38
const success = await effects .deleteConstraint (id );
42
46
}
43
47
}
44
48
49
+ function getConstraintModelId(selectedConstraint : Constraint | null ): number | null {
50
+ if (selectedConstraint !== null ) {
51
+ const { model_id, plan_id } = selectedConstraint ;
52
+
53
+ if (plan_id !== null ) {
54
+ const plan = initialPlans .find (plan => plan .id === plan_id );
55
+ if (plan ) {
56
+ return plan .model_id ;
57
+ }
58
+ } else if (model_id !== null ) {
59
+ return model_id ;
60
+ }
61
+ }
62
+
63
+ return null ;
64
+ }
65
+
45
66
function toggleConstraint(event : CustomEvent <Constraint >) {
46
67
const { detail : clickedConstraint } = event ;
47
68
110
131
111
132
<ConstraintEditor
112
133
constraintDefinition ={selectedConstraint ?.definition ?? ' No Constraint Selected' }
113
- constraintModelId ={ selectedConstraint ?. model_id }
134
+ { constraintModelId }
114
135
readOnly ={true }
115
136
title =" Constraint - Definition Editor (Read-only)"
116
137
/>
Original file line number Diff line number Diff line change 1
1
<svelte:options immutable ={true } />
2
2
3
- <script lang =" ts" >
3
+ <script lang =" ts" context =" module" >
4
+ import type { Load } from ' @sveltejs/kit' ;
4
5
import Constraints from ' ../../components/constraints/Constraints.svelte' ;
6
+ import effects from ' ../../utilities/effects' ;
7
+
8
+ export const load: Load = async () => {
9
+ const { plans : initialPlans } = await effects .getPlansAndModels ();
10
+
11
+ return {
12
+ props: {
13
+ initialPlans ,
14
+ },
15
+ };
16
+ };
17
+ </script >
18
+
19
+ <script lang =" ts" >
20
+ export let initialPlans: PlanList [] = [];
5
21
</script >
6
22
7
- <Constraints />
23
+ <Constraints { initialPlans } />
You can’t perform that action at this time.
0 commit comments