Skip to content

Commit b8d2084

Browse files
Merge branch 'feat/kcs_hazards_step' into develop
2 parents 959e52d + 362ca21 commit b8d2084

2 files changed

Lines changed: 68 additions & 67 deletions

File tree

src/components/SelectionList.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="selection-list pa-4">
33
<v-select
44
v-model="model"
5-
:items="options"
5+
:items="filteredOptions"
66
:label="label"
77
item-title="name"
88
item-value="id"
@@ -34,6 +34,7 @@
3434
label: { type: String, required: true },
3535
options: { type: Array, required: true },
3636
selectionKey: { type: String, default: null },
37+
conditionSource: { type: String, default: null },
3738
/** When true, store + step-complete only after the confirm button (dropdown is pending until then). */
3839
confirmSelection: { type: Boolean, default: false },
3940
confirmLabel: { type: String, default: 'Confirm' },
@@ -55,6 +56,15 @@
5556
},
5657
})
5758
59+
const filteredOptions = computed(() => {
60+
if (!props.conditionSource) {
61+
return props.options
62+
}
63+
const raw = appStore.selections[props.conditionSource]
64+
const selectedId = raw != null && typeof raw === 'object' && 'id' in raw ? raw.id : raw
65+
return props.options.filter(option => !option.condition || option.condition === selectedId)
66+
})
67+
5868
function selectionToStore (value) {
5969
if (!props.selectionKey || value == null) return
6070
const option = props.options.find(o => o.id === value)
@@ -94,4 +104,18 @@
94104
emit('step-complete', { value })
95105
}
96106
})
107+
108+
// Keep state consistent when a dependency changes and current value becomes invalid.
109+
watch(filteredOptions, (nextOptions) => {
110+
const allowedIds = new Set(nextOptions.map(o => o.id))
111+
if (committed.value != null && !allowedIds.has(committed.value)) {
112+
committed.value = null
113+
if (props.selectionKey) {
114+
appStore.setSelection(props.selectionKey, null)
115+
}
116+
}
117+
if (props.confirmSelection && pending.value != null && !allowedIds.has(pending.value)) {
118+
pending.value = null
119+
}
120+
}, { immediate: true })
97121
</script>

src/config/workflow.json

Lines changed: 43 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -164,69 +164,12 @@
164164
}
165165
]
166166
},
167-
{
168-
"id": "archetypeSelection",
169-
"title": "Archetype Selection",
170-
"drawerTitle": "Select the archetype",
171-
"requiredSteps": [
172-
"uom"
173-
],
174-
"explanation": "Select the archetype and confirm to continue.",
175-
"requiresConfirmation": true,
176-
"confirmationSource": "component",
177-
"wps": {
178-
"identifier": "lare_coastal",
179-
"trigger": "stepComplete",
180-
"inputs": [
181-
{
182-
"id": "sessionid",
183-
"type": "LiteralData",
184-
"source": "store:app.wpsResults.initialSetup.sessionid"
185-
}
186-
],
187-
"storeResultAs": "coastalUseCase",
188-
"outputActions": [
189-
{
190-
"action": "removeLayer",
191-
"fromResultKey": "uom",
192-
"path": "layers"
193-
},
194-
{
195-
"action": "addLayer",
196-
"path": "layers"
197-
}
198-
]
199-
},
200-
"components": [
201-
{
202-
"component": "SelectionList",
203-
"componentProps": {
204-
"label": "Archetypes",
205-
"selectionKey": "archetypeSelection",
206-
"options": [
207-
{
208-
"id": "coastal",
209-
"name": "Urban Coastal"
210-
},
211-
{
212-
"id": "agricultural_land",
213-
"name": "Agricultural Land"
214-
},
215-
{
216-
"id": "rural_settlements",
217-
"name": "Rural Settlements"
218-
}
219-
]
220-
}
221-
}
222-
]
223-
},
224167
{
225168
"id": "kcsSelection",
226169
"title": "KCS & Hazards",
227170
"drawerTitle": "Select KCS and hazard",
228171
"requiredSteps": [
229-
"archetypeSelection"
172+
"uom"
230173
],
231174
"explanation": "Select KCS and hazard type, then confirm to run the UOM KCS calculation.",
232175
"requiresConfirmation": true,
@@ -268,25 +211,59 @@
268211
{
269212
"component": "SelectionList",
270213
"componentProps": {
271-
"label": "KCS",
272-
"selectionKey": "kcsSelection",
214+
"label": "Hazards",
215+
"selectionKey": "hazardSelection",
216+
"conditionSource": "uomArchetype",
273217
"options": [
274218
{
275-
"id": "transport",
276-
"name": "Transport"
219+
"id": "salinization",
220+
"name": "Salinization",
221+
"condition": "coastal"
222+
},
223+
{
224+
"id": "flood",
225+
"name": "Flood",
226+
"condition": "coastal"
227+
},
228+
{
229+
"id": "heat",
230+
"name": "Heat",
231+
"condition": "urban"
232+
},
233+
{
234+
"id": "drought",
235+
"name": "Drought",
236+
"condition": "rural"
277237
}
278238
]
279239
}
280240
},
281241
{
282242
"component": "SelectionList",
283243
"componentProps": {
284-
"label": "Hazards",
285-
"selectionKey": "hazardSelection",
244+
"label": "KCS",
245+
"selectionKey": "kcsSelection",
246+
"conditionSource": "hazardSelection",
286247
"options": [
287248
{
288-
"id": "pluvial_RP200",
289-
"name": "Pluvial floods"
249+
"id": "agriculture",
250+
"name": "Agriculture",
251+
"condition": "salinization"
252+
},
253+
{
254+
"id": "transport",
255+
"name": "Transport",
256+
"condition": "flood"
257+
},
258+
{
259+
"id": "agriculture",
260+
"name": "Agriculture",
261+
"condition": "drought"
262+
},
263+
{
264+
"id": "vulnerable_population_hospitals",
265+
"name": "Vulnerable population (Hospitals)",
266+
"condition": "salinization"
290267
}
291268
]
292269
}

0 commit comments

Comments
 (0)