chore: auto-merge develop → main
Triggered by: c2004fd fix: scale use — auto-switch conf→sub (g/ml) when scale is active; show scale btn for conf+weight products
This commit is contained in:
+12
-4
@@ -455,7 +455,11 @@ function _scaleAutoFillUse(msg) {
|
|||||||
|
|
||||||
// Determine target unit
|
// Determine target unit
|
||||||
let unit;
|
let unit;
|
||||||
if (_useConfMode && _useConfMode._activeUnit === 'sub') {
|
if (_useConfMode) {
|
||||||
|
// Scale always reads weight (g/ml) — auto-switch to sub-unit mode if still in conf mode
|
||||||
|
if (_useConfMode._activeUnit !== 'sub') {
|
||||||
|
switchUseUnit('sub');
|
||||||
|
}
|
||||||
unit = (_useConfMode.packageUnit || '').toLowerCase();
|
unit = (_useConfMode.packageUnit || '').toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
unit = _useNormalUnit;
|
unit = _useNormalUnit;
|
||||||
@@ -944,7 +948,9 @@ function updateScaleReadButtons() {
|
|||||||
}
|
}
|
||||||
const btnUse = document.getElementById('btn-scale-use');
|
const btnUse = document.getElementById('btn-scale-use');
|
||||||
if (btnUse) {
|
if (btnUse) {
|
||||||
btnUse.style.display = (ready && (_useNormalUnit === 'g' || _useNormalUnit === 'ml')) ? '' : 'none';
|
const canUseByWeight = _useNormalUnit === 'g' || _useNormalUnit === 'ml' ||
|
||||||
|
(_useConfMode && (_useConfMode.packageUnit === 'g' || _useConfMode.packageUnit === 'ml'));
|
||||||
|
btnUse.style.display = (ready && canUseByWeight) ? '' : 'none';
|
||||||
}
|
}
|
||||||
// Live box: visible when scale enabled + connected + on use page + compatible unit
|
// Live box: visible when scale enabled + connected + on use page + compatible unit
|
||||||
const liveBox = document.getElementById('scale-live-box');
|
const liveBox = document.getElementById('scale-live-box');
|
||||||
@@ -8590,8 +8596,10 @@ async function loadUseInventoryInfo() {
|
|||||||
unitSwitch.style.display = 'flex';
|
unitSwitch.style.display = 'flex';
|
||||||
document.getElementById('use-unit-sub').textContent = subLabel;
|
document.getElementById('use-unit-sub').textContent = subLabel;
|
||||||
|
|
||||||
// Default to conf mode — users think in packages; scale auto-switches to sub
|
// If scale is active, start in sub-unit (g/ml) mode — scale always reads weight.
|
||||||
switchUseUnit('conf');
|
// Otherwise default to conf so the user thinks in packages.
|
||||||
|
const _scaleActiveNow = getSettings().scale_enabled && getSettings().scale_gateway_url && _scaleConnected;
|
||||||
|
switchUseUnit(_scaleActiveNow ? 'sub' : 'conf');
|
||||||
|
|
||||||
// Fraction shortcut buttons for conf mode (½, 1, 2 packages)
|
// Fraction shortcut buttons for conf mode (½, 1, 2 packages)
|
||||||
const existingConfFrac = document.getElementById('conf-fraction-btns');
|
const existingConfFrac = document.getElementById('conf-fraction-btns');
|
||||||
|
|||||||
Reference in New Issue
Block a user