From 0609fdebf7cae3c4d8642edfa940c602ab384e18 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 11 Dec 2023 13:16:59 -0600 Subject: [PATCH] Improve focus behavior for inventory count view --- src/components/inventory/ByjoveInventory.vue | 23 +++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/inventory/ByjoveInventory.vue b/src/components/inventory/ByjoveInventory.vue index 31e84e7..b6201c7 100644 --- a/src/components/inventory/ByjoveInventory.vue +++ b/src/components/inventory/ByjoveInventory.vue @@ -83,6 +83,10 @@ export default { type: Boolean, default: true, }, + focusCases: { + type: Boolean, + default: false, + }, allowEdit: { type: Boolean, default: false, @@ -92,6 +96,7 @@ export default { default: false, }, }, + data() { return { row: {}, @@ -102,16 +107,6 @@ export default { this.fetch(this.$route.params.uuid) }, - updated() { - this.$nextTick(() => { - if (this.shouldAllowCases()) { - this.$refs.cases.focus() - } else { - this.$refs.units.focus() - } - }) - }, - methods: { getIndexUrl() { @@ -165,6 +160,14 @@ export default { if (this.row.batch_executed || this.row.batch_complete) { // cannot edit this row, so view it instead this.$router.push(this.getViewUrl()) + } else { + this.$nextTick(() => { + if (this.shouldAllowCases() && this.focusCases) { + this.$refs.cases.focus() + } else { + this.$refs.units.focus() + } + }) } }, response => { if (response.status == 403) { // forbidden; redirect to model index