Keep the stored stacks and filters when editing a workflow
Build package / php-lint (8.2) (push) Successful in 43s
Build package / php-lint (8.3) (push) Successful in 40s
Build package / php-lint (8.4) (push) Successful in 39s
Build package / xml-lint (push) Successful in 11s
Build package / unit-tests (push) Successful in 37s
Build package / package (push) Successful in 58s

editWorkflow() filled the form and then called onBoardChange() to populate
the dependent dropdowns -- but that function exists to *reset* them, so it
immediately nulled sourceStackId, targetStackId and both filter lists again.
The board stayed selected because it is not one of the fields it clears.

Split the two responsibilities: loadBoardOptions() only fetches the
stack/label/user lists, onBoardChange() clears the dependent selection and
then delegates to it. Editing now calls loadBoardOptions() directly.

onBoardChange() additionally ignores re-picking the board that is already
loaded, so selecting the same entry again no longer wipes the form.
This commit is contained in:
Patrick Niebeling
2026-08-13 14:51:28 +02:00
parent b37a0db123
commit 01fdd51b5a
+29 -9
View File
@@ -164,6 +164,8 @@ const editingId = ref(null)
const stackOptions = ref([])
const labelOptions = ref([])
const participantOptions = ref([])
// Which board the three lists above currently belong to.
const loadedBoardId = ref(null)
const boardOptions = computed(() => boards.value.map((board) => ({ value: board.id, label: board.title })))
@@ -223,14 +225,16 @@ async function loadAll() {
}
}
async function onBoardChange(boardId) {
form.sourceStackId = null
form.targetStackId = null
form.filterUserIds = []
form.filterLabelIds = []
/**
* Fills the stack/label/user dropdowns for a board without touching the
* current selection — that separation matters: editing a workflow has to
* load the same options but must keep the stored stacks and filters.
*/
async function loadBoardOptions(boardId) {
stackOptions.value = []
labelOptions.value = []
participantOptions.value = []
loadedBoardId.value = boardId ?? null
if (!boardId) {
return
@@ -249,13 +253,29 @@ async function onBoardChange(boardId) {
participantOptions.value = participants.map((participant) => ({ value: participant.uid, label: participant.displayName }))
}
/**
* Only for the board dropdown: a *different* board invalidates everything
* that referenced the old one. Re-picking the same board is a no-op, so it
* doesn't silently wipe the form.
*/
async function onBoardChange(boardId) {
if (boardId === loadedBoardId.value) {
return
}
form.sourceStackId = null
form.targetStackId = null
form.filterUserIds = []
form.filterLabelIds = []
await loadBoardOptions(boardId)
}
function startCreate() {
Object.assign(form, emptyForm())
editingId.value = null
formError.value = ''
stackOptions.value = []
labelOptions.value = []
participantOptions.value = []
loadBoardOptions(null)
showForm.value = true
}
@@ -273,7 +293,7 @@ async function editWorkflow(workflow) {
editingId.value = workflow.id
formError.value = ''
showForm.value = true
await onBoardChange(workflow.boardId)
await loadBoardOptions(workflow.boardId)
}
function cancelForm() {