Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TargetPacketItemChooser behavior #1613

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
/>
</v-col>
<v-col
v-if="itemIsArray()"
v-if="chooseItem && itemIsArray()"
cols="1"
class="select"
data-test="array-index"
Expand Down Expand Up @@ -270,11 +270,15 @@ export default {
if (this.allowAllTargets) {
this.targetNames.unshift(this.ALL)
}
// If the initial target name is not set, default to the first target
// which also updates packets and items as needed
if (!this.selectedTargetName) {
this.selectedTargetName = this.targetNames[0].value
this.targetNameChanged(this.selectedTargetName)
} else {
// Selected target name was set but we still have to update packets
this.updatePackets()
}
this.updatePackets()
if (this.unknown) {
this.targetNames.push(this.UNKNOWN)
}
Expand Down Expand Up @@ -320,7 +324,15 @@ export default {
mode: function (newVal, oldVal) {
this.selectedPacketName = null
this.selectedItemName = null
this.updatePackets()
// This also updates packets and items as needed
this.targetNameChanged(this.selectedTargetName)
},
chooseItem: function (newVal, oldVal) {
if (newVal) {
this.updateItems()
} else {
this.itemNames = []
}
},
},
methods: {
Expand Down Expand Up @@ -410,12 +422,12 @@ export default {
reducedType: this.selectedReducedType,
})
this.internalDisabled = false
}
},
)
},
itemIsArray: function () {
let i = this.itemNames.findIndex(
(item) => item.value === this.selectedItemName
(item) => item.value === this.selectedItemName,
)
if (i === -1) {
this.selectedArrayIndex = null
Expand All @@ -433,7 +445,7 @@ export default {
},
arrayIndexes: function () {
let i = this.itemNames.findIndex(
(item) => item.value === this.selectedItemName
(item) => item.value === this.selectedItemName,
)
let indexes = [...Array(this.itemNames[i].array).keys()]
if (this.allowAll) {
Expand Down Expand Up @@ -480,7 +492,7 @@ export default {
(packet) => {
this.description = packet.description
this.hazardous = packet.hazardous
}
},
)
}
}
Expand Down Expand Up @@ -569,7 +581,7 @@ export default {
reducedType: this.selectedReducedType,
})
})
}
},
)
})
},
Expand Down
Loading