diff --git a/src/PersonalSettings.vue b/src/PersonalSettings.vue index 208440e..721117a 100644 --- a/src/PersonalSettings.vue +++ b/src/PersonalSettings.vue @@ -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() {