Minor UI tweaks
This commit is contained in:
+10
-6
@@ -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('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user