Improve focus behavior for inventory count view

This commit is contained in:
Lance Edgar 2023-12-11 13:16:59 -06:00
parent 0f56b478fc
commit 0609fdebf7

View file

@ -83,6 +83,10 @@ export default {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
focusCases: {
type: Boolean,
default: false,
},
allowEdit: { allowEdit: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -92,6 +96,7 @@ export default {
default: false, default: false,
}, },
}, },
data() { data() {
return { return {
row: {}, row: {},
@ -102,16 +107,6 @@ export default {
this.fetch(this.$route.params.uuid) this.fetch(this.$route.params.uuid)
}, },
updated() {
this.$nextTick(() => {
if (this.shouldAllowCases()) {
this.$refs.cases.focus()
} else {
this.$refs.units.focus()
}
})
},
methods: { methods: {
getIndexUrl() { getIndexUrl() {
@ -165,6 +160,14 @@ export default {
if (this.row.batch_executed || this.row.batch_complete) { if (this.row.batch_executed || this.row.batch_complete) {
// cannot edit this row, so view it instead // cannot edit this row, so view it instead
this.$router.push(this.getViewUrl()) this.$router.push(this.getViewUrl())
} else {
this.$nextTick(() => {
if (this.shouldAllowCases() && this.focusCases) {
this.$refs.cases.focus()
} else {
this.$refs.units.focus()
}
})
} }
}, response => { }, response => {
if (response.status == 403) { // forbidden; redirect to model index if (response.status == 403) { // forbidden; redirect to model index