Fix saveOrderTypes: wrong method name and onchange firing during load
- showToast → toast (correct method name) across all settings methods - Clear onchange before setting .checked to prevent save during load Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d947685bbc
commit
30e192e738
2 changed files with 15 additions and 14 deletions
|
|
@ -806,7 +806,7 @@
|
|||
<!-- Toast Container -->
|
||||
<div class="toast-container" id="toastContainer"></div>
|
||||
|
||||
<script src="portal.js?v=14"></script>
|
||||
<script src="portal.js?v=15"></script>
|
||||
|
||||
<!-- Close dropdown when clicking outside -->
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -759,7 +759,7 @@ const Portal = {
|
|||
|
||||
// Edit team member (placeholder)
|
||||
editTeamMember(employeeId) {
|
||||
this.showToast('Team member editing coming soon', 'info');
|
||||
this.toast('Team member editing coming soon', 'info');
|
||||
},
|
||||
|
||||
// Load settings
|
||||
|
|
@ -869,6 +869,7 @@ const Portal = {
|
|||
const orderTypes = (biz.ORDERTYPES || biz.OrderTypes || '1').split(',');
|
||||
const takeawayCheckbox = document.getElementById('orderTypeTakeaway');
|
||||
if (takeawayCheckbox) {
|
||||
takeawayCheckbox.onchange = null;
|
||||
takeawayCheckbox.checked = orderTypes.includes('2');
|
||||
takeawayCheckbox.onchange = () => this.saveOrderTypes();
|
||||
}
|
||||
|
|
@ -901,11 +902,11 @@ const Portal = {
|
|||
})
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.OK) { this.showToast('Tab settings saved!', 'success'); }
|
||||
else { this.showToast(data.ERROR || 'Failed to save tab settings', 'error'); }
|
||||
if (data.OK) { this.toast('Tab settings saved!', 'success'); }
|
||||
else { this.toast(data.ERROR || 'Failed to save tab settings', 'error'); }
|
||||
} catch (err) {
|
||||
console.error('[Portal] Error saving tab settings:', err);
|
||||
this.showToast('Error saving tab settings', 'error');
|
||||
this.toast('Error saving tab settings', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -919,11 +920,11 @@ const Portal = {
|
|||
body: JSON.stringify({ BusinessID: this.config.businessId, OrderTypes: types.join(',') })
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.OK) { this.showToast('Order types saved!', 'success'); }
|
||||
else { this.showToast(data.ERROR || 'Failed to save order types', 'error'); }
|
||||
if (data.OK) { this.toast('Order types saved!', 'success'); }
|
||||
else { this.toast(data.ERROR || 'Failed to save order types', 'error'); }
|
||||
} catch (err) {
|
||||
console.error('[Portal] Error saving order types:', err);
|
||||
this.showToast('Error saving order types', 'error');
|
||||
this.toast('Error saving order types', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -1022,15 +1023,15 @@ const Portal = {
|
|||
const data = await response.json();
|
||||
|
||||
if (data.OK) {
|
||||
this.showToast('Business info saved!', 'success');
|
||||
this.toast('Business info saved!', 'success');
|
||||
// Reload to refresh sidebar etc
|
||||
await this.loadBusinessInfo();
|
||||
} else {
|
||||
this.showToast(data.ERROR || 'Failed to save', 'error');
|
||||
this.toast(data.ERROR || 'Failed to save', 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[Portal] Error saving business info:', err);
|
||||
this.showToast('Error saving business info', 'error');
|
||||
this.toast('Error saving business info', 'error');
|
||||
} finally {
|
||||
btn.textContent = originalText;
|
||||
btn.disabled = false;
|
||||
|
|
@ -1066,13 +1067,13 @@ const Portal = {
|
|||
const data = await response.json();
|
||||
|
||||
if (data.OK) {
|
||||
this.showToast('Hours saved!', 'success');
|
||||
this.toast('Hours saved!', 'success');
|
||||
} else {
|
||||
this.showToast(data.ERROR || 'Failed to save hours', 'error');
|
||||
this.toast(data.ERROR || 'Failed to save hours', 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[Portal] Error saving hours:', err);
|
||||
this.showToast('Error saving hours', 'error');
|
||||
this.toast('Error saving hours', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Reference in a new issue