Minor UI tweaks

This commit is contained in:
2026-04-12 05:37:57 -04:00
parent 4673de4ae5
commit 225202aacb
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -1618,11 +1618,14 @@ async function handleAddDrug(e) {
});
if (!drugResponse.ok) throw new Error('Failed to add drug');
const createdDrug = await drugResponse.json();
document.getElementById('drugForm').reset();
closeModal(document.getElementById('addModal'));
expandedDrugs.add(createdDrug.id);
await loadDrugs();
showToast('Drug added successfully!', 'success');
closeModal(document.getElementById('addModal'));
openAddVariantModal(createdDrug.id);
showToast('Drug added successfully. Add the first variant next.', 'success');
} catch (error) {
console.error('Error adding drug:', error);
showToast('Failed to add drug. Check the console for details.', 'error');
@@ -1882,7 +1885,7 @@ function inferBaseUnitFromStrength(strength) {
if (value.includes('/ml') || value.includes('ml')) return 'ml';
if (value.includes('tablet')) return 'tablets';
if (value.includes('capsule')) return 'capsules';
return 'units';
return 'tablets';
}
function getVariantPackRowsContainer() {
@@ -1928,7 +1931,7 @@ function appendVariantPackRow(prefill = {}) {
const row = document.createElement('div');
row.className = 'delivery-line variant-pack-row';
const selectedPackUnit = prefill.packUnit || 'bottle';
const selectedPackUnit = prefill.packUnit || 'box';
const selectedSize = prefill.packSize || '';
const baseUnit = document.getElementById('variantUnit')?.value || 'units';
@@ -1983,7 +1986,7 @@ function initializeVariantPackRows() {
variantUnitSelect.value = inferredBaseUnit;
}
appendVariantPackRow({ packUnit: 'bottle' });
appendVariantPackRow({ packUnit: 'box' });
}
function appendEditVariantPackRow(prefill = {}) {
@@ -2965,8 +2968,9 @@ function buildDeliveryPackOptions(variant, selectedPackId = '') {
}
function buildDeliveryLocationOptions(selectedLocationId = '') {
const fallbackLocationId = selectedLocationId || (deliveryLocations.length > 0 ? String(deliveryLocations[0].id) : '');
return [`<option value="">-- Select location --</option>`, ...deliveryLocations.map(location => {
const selected = String(location.id) === String(selectedLocationId) ? ' selected' : '';
const selected = String(location.id) === String(fallbackLocationId) ? ' selected' : '';
return `<option value="${location.id}"${selected}>${escapeHtml(location.name)}</option>`;
})].join('');
}
+1 -1
View File
@@ -274,7 +274,7 @@
<label for="variantUnit">Base Unit *</label>
<select id="variantUnit">
<option value="ml">ml</option>
<option value="tablets">tablets</option>
<option value="tablets" selected>tablets</option>
<option value="capsules">capsules</option>
<option value="units">units</option>
<option value="vials">vials</option>