|
6 | 6 | import MonacoEditor from '../ui/MonacoEditor.svelte';
|
7 | 7 | import Panel from '../ui/Panel.svelte';
|
8 | 8 | import req from '../../utilities/requests';
|
9 |
| - import { |
10 |
| - constraintActions, |
11 |
| - selectedConstraint, |
12 |
| - } from '../../stores/constraints'; |
| 9 | + import { constraintActions, selectedConstraint } from '../../stores/constraints'; |
13 | 10 |
|
14 | 11 | let constraintType: ConstraintType = 'model';
|
15 | 12 | let debounce: NodeJS.Timeout;
|
|
24 | 21 | onMount(() => {
|
25 | 22 | if ($selectedConstraint) {
|
26 | 23 | constraintType = $selectedConstraint.model_id ? 'model' : 'plan';
|
27 |
| - definition = JSON.stringify( |
28 |
| - JSON.parse($selectedConstraint.definition), |
29 |
| - null, |
30 |
| - 2, |
31 |
| - ); |
| 24 | + definition = JSON.stringify(JSON.parse($selectedConstraint.definition), null, 2); |
32 | 25 | description = $selectedConstraint.description;
|
33 | 26 | name = $selectedConstraint.name;
|
34 | 27 | summary = $selectedConstraint.summary;
|
|
41 | 34 | }
|
42 | 35 | });
|
43 | 36 |
|
44 |
| - async function onDidChangeModelContent( |
45 |
| - event: CustomEvent<{ value: string }>, |
46 |
| - ) { |
| 37 | + async function onDidChangeModelContent(event: CustomEvent<{ value: string }>) { |
47 | 38 | const { detail } = event;
|
48 | 39 | const { value } = detail;
|
49 | 40 |
|
|
75 | 66 | summary,
|
76 | 67 | );
|
77 | 68 | } else {
|
78 |
| - constraintActions.createConstraint( |
79 |
| - constraintType, |
80 |
| - definition, |
81 |
| - description, |
82 |
| - name, |
83 |
| - summary, |
84 |
| - ); |
| 69 | + constraintActions.createConstraint(constraintType, definition, description, name, summary); |
85 | 70 | }
|
86 | 71 | }
|
87 | 72 | </script>
|
88 | 73 |
|
89 | 74 | <Panel>
|
90 | 75 | <svelte:fragment slot="header">
|
91 | 76 | <Chip>Constraint Editor</Chip>
|
92 |
| - <button |
93 |
| - class="st-button secondary ellipsis" |
94 |
| - disabled={!valid} |
95 |
| - on:click={() => saveConstraint()} |
96 |
| - > |
| 77 | + <button class="st-button secondary ellipsis" disabled={!valid} on:click={() => saveConstraint()}> |
97 | 78 | <i class="bi bi-save" style="font-size: 0.8rem" />
|
98 | 79 | Save Constraint
|
99 | 80 | </button>
|
|
105 | 86 | <div class="p-1">
|
106 | 87 | <fieldset>
|
107 | 88 | <label for="type">Type</label>
|
108 |
| - <select |
109 |
| - bind:value={constraintType} |
110 |
| - class="st-select w-100" |
111 |
| - name="type" |
112 |
| - > |
| 89 | + <select bind:value={constraintType} class="st-select w-100" name="type"> |
113 | 90 | <option value="model">Model</option>
|
114 | 91 | <option value="plan">Plan</option>
|
115 | 92 | </select>
|
116 | 93 | </fieldset>
|
117 | 94 |
|
118 | 95 | <fieldset>
|
119 | 96 | <label for="name">Name</label>
|
120 |
| - <input |
121 |
| - bind:value={name} |
122 |
| - autocomplete="off" |
123 |
| - class="st-input w-100" |
124 |
| - name="name" |
125 |
| - required |
126 |
| - /> |
| 97 | + <input bind:value={name} autocomplete="off" class="st-input w-100" name="name" required /> |
127 | 98 | </fieldset>
|
128 | 99 |
|
129 | 100 | <fieldset>
|
130 | 101 | <label for="description">Description</label>
|
131 |
| - <input |
132 |
| - bind:value={description} |
133 |
| - autocomplete="off" |
134 |
| - class="st-input w-100" |
135 |
| - name="description" |
136 |
| - /> |
| 102 | + <input bind:value={description} autocomplete="off" class="st-input w-100" name="description" /> |
137 | 103 | </fieldset>
|
138 | 104 |
|
139 | 105 | <fieldset>
|
140 | 106 | <label for="summary">Summary</label>
|
141 |
| - <input |
142 |
| - bind:value={summary} |
143 |
| - autocomplete="off" |
144 |
| - class="st-input w-100" |
145 |
| - name="summary" |
146 |
| - /> |
| 107 | + <input bind:value={summary} autocomplete="off" class="st-input w-100" name="summary" /> |
147 | 108 | </fieldset>
|
148 | 109 | </div>
|
149 | 110 | </details>
|
|
0 commit comments