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
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:
@@ -164,6 +164,8 @@ const editingId = ref(null)
|
|||||||
const stackOptions = ref([])
|
const stackOptions = ref([])
|
||||||
const labelOptions = ref([])
|
const labelOptions = ref([])
|
||||||
const participantOptions = 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 })))
|
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
|
* Fills the stack/label/user dropdowns for a board without touching the
|
||||||
form.targetStackId = null
|
* current selection — that separation matters: editing a workflow has to
|
||||||
form.filterUserIds = []
|
* load the same options but must keep the stored stacks and filters.
|
||||||
form.filterLabelIds = []
|
*/
|
||||||
|
async function loadBoardOptions(boardId) {
|
||||||
stackOptions.value = []
|
stackOptions.value = []
|
||||||
labelOptions.value = []
|
labelOptions.value = []
|
||||||
participantOptions.value = []
|
participantOptions.value = []
|
||||||
|
loadedBoardId.value = boardId ?? null
|
||||||
|
|
||||||
if (!boardId) {
|
if (!boardId) {
|
||||||
return
|
return
|
||||||
@@ -249,13 +253,29 @@ async function onBoardChange(boardId) {
|
|||||||
participantOptions.value = participants.map((participant) => ({ value: participant.uid, label: participant.displayName }))
|
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() {
|
function startCreate() {
|
||||||
Object.assign(form, emptyForm())
|
Object.assign(form, emptyForm())
|
||||||
editingId.value = null
|
editingId.value = null
|
||||||
formError.value = ''
|
formError.value = ''
|
||||||
stackOptions.value = []
|
loadBoardOptions(null)
|
||||||
labelOptions.value = []
|
|
||||||
participantOptions.value = []
|
|
||||||
showForm.value = true
|
showForm.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +293,7 @@ async function editWorkflow(workflow) {
|
|||||||
editingId.value = workflow.id
|
editingId.value = workflow.id
|
||||||
formError.value = ''
|
formError.value = ''
|
||||||
showForm.value = true
|
showForm.value = true
|
||||||
await onBoardChange(workflow.boardId)
|
await loadBoardOptions(workflow.boardId)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelForm() {
|
function cancelForm() {
|
||||||
|
|||||||
Reference in New Issue
Block a user