Compare commits

...

6 commits

Author SHA1 Message Date
Lance Edgar 3d02e46f2a Update changelog 2024-06-03 11:40:09 -05:00
Lance Edgar f21a7298fe Optionally allow decimal quantities for receiving 2024-05-31 10:58:44 -05:00
Lance Edgar b04fa3eb72 Update changelog 2024-05-29 09:43:53 -05:00
Lance Edgar 32d1bd430f Show actual error text if applicable, for receiving failure 2024-04-11 14:14:01 -05:00
Lance Edgar b6e8b74eef Update changelog 2024-03-26 12:57:49 -05:00
Lance Edgar 18936d9efd Add delay when fetching rows data for model CRUD component
hoping this actually works, but can't reproduce the problem locally so
will just have to wait and see
2023-12-29 19:38:41 -06:00
7 changed files with 223 additions and 11 deletions

View file

@ -5,6 +5,20 @@ All notable changes to 'byjove' will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
## [0.1.26] - 2024-06-03
### Changed
- Optionally allow decimal quantities for receiving.
## [0.1.25] - 2024-05-29
### Changed
- Show actual error text if applicable, for receiving failure.
## [0.1.24] - 2024-03-26
### Changed
- Add delay when fetching rows data for model CRUD component.
## [0.1.23] - 2023-12-26 ## [0.1.23] - 2023-12-26
### Changed ### Changed
- Improve focus behavior for inventory count view. - Improve focus behavior for inventory count view.

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "byjove", "name": "byjove",
"version": "0.1.23", "version": "0.1.26",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "byjove", "name": "byjove",
"version": "0.1.23", "version": "0.1.26",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"dependencies": { "dependencies": {
"vue": "^2.7.14" "vue": "^2.7.14"

View file

@ -1,6 +1,6 @@
{ {
"name": "byjove", "name": "byjove",
"version": "0.1.23", "version": "0.1.26",
"description": "Generic-ish app components for Vue.js frontend to Tailbone API backend", "description": "Generic-ish app components for Vue.js frontend to Tailbone API backend",
"keywords": [ "keywords": [
"rattail", "rattail",

View file

@ -511,7 +511,14 @@ export default {
this.record = response.data.data this.record = response.data.data
this.$emit('refresh', this.record) this.$emit('refresh', this.record)
if (this.hasRows) { if (this.hasRows) {
// TODO: was seeing occasional errors when a batch
// view was loaded, and it tried to fetch rows but
// somehow the uuid was not passed along and
// server failed to build a query filter. so
// hoping the nextTick() delay fixes it..?
this.$nextTick(() => {
this.fetchRows(uuid) this.fetchRows(uuid)
})
} }
}, response => { }, response => {
if (response.status == 403) { // forbidden if (response.status == 403) { // forbidden

View file

@ -0,0 +1,152 @@
<template>
<b-input :name="name"
:value="value"
ref="input"
:placeholder="placeholder"
:size="size"
:icon-pack="iconPack"
:icon="icon"
:disabled="disabled"
:custom-class="customClass"
@focus="notifyFocus"
@blur="notifyBlur"
@keydown.native="keyDown"
@input="valueChanged"
/>
</template>
<script>
export default {
name: 'NumericInput',
props: {
name: String,
value: [Number, String],
placeholder: String,
iconPack: String,
icon: String,
size: String,
disabled: Boolean,
allowEnter: Boolean,
customClass: String,
},
methods: {
focus() {
this.$refs.input.focus()
},
notifyFocus(event) {
this.$emit('focus', event)
},
notifyBlur(event) {
this.$emit('blur', event)
},
keyDown(event) {
// by default we only allow numeric keys, and general navigation
// keys, but we might also allow Enter key
if (!this.key_modifies(event) && !this.key_allowed(event)) {
if (!this.allowEnter || event.which != 13) {
event.preventDefault()
}
}
},
/*
* Determine if a keypress would modify the value of a textbox.
*
* Note that this implies that the keypress is also *valid* in the context of a
* numeric textbox.
*
* Returns `true` if the keypress is valid and would modify the textbox value,
* or `false` otherwise.
*/
key_modifies(event) {
if (event.which >= 48 && event.which <= 57) { // Numeric (QWERTY)
if (! event.shiftKey) { // shift key means punctuation instead of numeric
return true;
}
} else if (event.which >= 96 && event.which <= 105) { // Numeric (10-Key)
return true;
} else if (event.which == 109 || event.which == 173) { // hyphen (negative sign)
return true;
} else if (event.which == 110 || event.which == 190) { // period/decimal
return true;
} else if (event.which == 8) { // Backspace
return true;
} else if (event.which == 46) { // Delete
return true;
} else if (event.ctrlKey && event.which == 86) { // Ctrl+V
return true;
} else if (event.ctrlKey && event.which == 88) { // Ctrl+X
return true;
}
return false;
},
/*
* Determine if a keypress is allowed in the context of a textbox.
*
* The purpose of this function is to let certain "special" keys (e.g. function
* and navigational keys) to pass through, so they may be processed as they
* would for a normal textbox.
*
* Note that this function does *not* check for keys which would actually
* modify the value of the textbox. It is assumed that the caller will have
* already used `key_modifies()` for that.
*
* Returns `true` if the keypress is allowed, or `false` otherwise.
*/
key_allowed(event) {
// Allow anything with modifiers (except Shift).
if (event.altKey || event.ctrlKey || event.metaKey) {
// ...but don't allow Ctrl+X or Ctrl+V
return event.which != 86 && event.which != 88;
}
// Allow function keys.
if (event.which >= 112 && event.which <= 123) {
return true;
}
// Allow Home/End/arrow keys.
if (event.which >= 35 && event.which <= 40) {
return true;
}
// Allow Tab key.
if (event.which == 9) {
return true;
}
// allow Escape key
if (event.which == 27) {
return true;
}
return false;
},
select() {
this.$el.children[0].select()
},
valueChanged(value) {
this.$emit('input', value)
}
},
}
</script>

View file

@ -0,0 +1,28 @@
// Import vue component
import NumericInput from './NumericInput.vue'
// Declare install function executed by Vue.use()
export function install(Vue) {
if (install.installed) return;
install.installed = true;
Vue.component('NumericInput', NumericInput);
}
// Create module definition for Vue.use()
const plugin = {
install,
};
// Auto-install when vue is found (eg. in browser via <script> tag)
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue;
}
if (GlobalVue) {
GlobalVue.use(plugin);
}
// To allow use as module (npm/webpack/etc.) export component
export default NumericInput

View file

@ -159,10 +159,13 @@
<b-field grouped> <b-field grouped>
<b-field class="control"> <b-field class="control">
<b-input v-model="inputQuantity" <numeric-input v-if="allowDecimalQuantities"
v-model="inputQuantity"
custom-class="receiving-quantity-input" />
<b-input v-else
v-model="inputQuantity"
type="number" type="number"
custom-class="receiving-quantity-input"> custom-class="receiving-quantity-input" />
</b-input>
</b-field> </b-field>
<b-field class="control"> <b-field class="control">
<b-radio-button v-model="inputUOM" <b-radio-button v-model="inputUOM"
@ -246,8 +249,11 @@
</template> </template>
<script> <script>
import NumericInput from '../numeric-input/NumericInput.vue'
export default { export default {
name: 'ByjoveReceiving', name: 'ByjoveReceiving',
components: {NumericInput},
props: { props: {
productKey: { productKey: {
type: String, type: String,
@ -257,6 +263,10 @@ export default {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
allowDecimalQuantities: {
type: Boolean,
default: false,
},
allowExpired: { allowExpired: {
type: Boolean, type: Boolean,
default: true, default: true,
@ -333,7 +343,8 @@ export default {
addAmount() { addAmount() {
let amount = parseInt(this.inputQuantity) let amount = this.inputQuantity
amount = this.allowDecimalQuantities ? parseFloat(amount) : parseInt(amount)
if (!amount) { if (!amount) {
this.$buefy.toast.open({ this.$buefy.toast.open({
message: "Please specify an amount", message: "Please specify an amount",
@ -359,17 +370,17 @@ export default {
} }
this.$http.post(url, params).then(response => { this.$http.post(url, params).then(response => {
if (response.data.data) { if (!response.data.error) {
this.$router.push(`/receiving/${this.row.batch_uuid}`) this.$router.push(`/receiving/${this.row.batch_uuid}`)
} else { } else {
this.$buefy.toast.open({ this.$buefy.toast.open({
message: response.data.error || "Failed to post receiving!", message: response.data.error,
type: 'is-danger', type: 'is-danger',
}) })
} }
}, response => { }, response => {
this.$buefy.toast.open({ this.$buefy.toast.open({
message: "Failed to post receiving!", message: "Save failed: unknown error",
type: 'is-danger', type: 'is-danger',
}) })
}) })