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 -->
|
<!-- Toast Container -->
|
||||||
<div class="toast-container" id="toastContainer"></div>
|
<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 -->
|
<!-- Close dropdown when clicking outside -->
|
||||||
<script>
|
<script>
|
||||||
|
|
|
||||||
|
|
@ -759,7 +759,7 @@ const Portal = {
|
||||||
|
|
||||||
// Edit team member (placeholder)
|
// Edit team member (placeholder)
|
||||||
editTeamMember(employeeId) {
|
editTeamMember(employeeId) {
|
||||||
this.showToast('Team member editing coming soon', 'info');
|
this.toast('Team member editing coming soon', 'info');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
|
|
@ -869,6 +869,7 @@ const Portal = {
|
||||||
const orderTypes = (biz.ORDERTYPES || biz.OrderTypes || '1').split(',');
|
const orderTypes = (biz.ORDERTYPES || biz.OrderTypes || '1').split(',');
|
||||||
const takeawayCheckbox = document.getElementById('orderTypeTakeaway');
|
const takeawayCheckbox = document.getElementById('orderTypeTakeaway');
|
||||||
if (takeawayCheckbox) {
|
if (takeawayCheckbox) {
|
||||||
|
takeawayCheckbox.onchange = null;
|
||||||
takeawayCheckbox.checked = orderTypes.includes('2');
|
takeawayCheckbox.checked = orderTypes.includes('2');
|
||||||
takeawayCheckbox.onchange = () => this.saveOrderTypes();
|
takeawayCheckbox.onchange = () => this.saveOrderTypes();
|
||||||
}
|
}
|
||||||
|
|
@ -901,11 +902,11 @@ const Portal = {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.OK) { this.showToast('Tab settings saved!', 'success'); }
|
if (data.OK) { this.toast('Tab settings saved!', 'success'); }
|
||||||
else { this.showToast(data.ERROR || 'Failed to save tab settings', 'error'); }
|
else { this.toast(data.ERROR || 'Failed to save tab settings', 'error'); }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Portal] Error saving tab settings:', 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(',') })
|
body: JSON.stringify({ BusinessID: this.config.businessId, OrderTypes: types.join(',') })
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.OK) { this.showToast('Order types saved!', 'success'); }
|
if (data.OK) { this.toast('Order types saved!', 'success'); }
|
||||||
else { this.showToast(data.ERROR || 'Failed to save order types', 'error'); }
|
else { this.toast(data.ERROR || 'Failed to save order types', 'error'); }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Portal] Error saving order types:', 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();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.OK) {
|
if (data.OK) {
|
||||||
this.showToast('Business info saved!', 'success');
|
this.toast('Business info saved!', 'success');
|
||||||
// Reload to refresh sidebar etc
|
// Reload to refresh sidebar etc
|
||||||
await this.loadBusinessInfo();
|
await this.loadBusinessInfo();
|
||||||
} else {
|
} else {
|
||||||
this.showToast(data.ERROR || 'Failed to save', 'error');
|
this.toast(data.ERROR || 'Failed to save', 'error');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Portal] Error saving business info:', err);
|
console.error('[Portal] Error saving business info:', err);
|
||||||
this.showToast('Error saving business info', 'error');
|
this.toast('Error saving business info', 'error');
|
||||||
} finally {
|
} finally {
|
||||||
btn.textContent = originalText;
|
btn.textContent = originalText;
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
|
|
@ -1066,13 +1067,13 @@ const Portal = {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.OK) {
|
if (data.OK) {
|
||||||
this.showToast('Hours saved!', 'success');
|
this.toast('Hours saved!', 'success');
|
||||||
} else {
|
} else {
|
||||||
this.showToast(data.ERROR || 'Failed to save hours', 'error');
|
this.toast(data.ERROR || 'Failed to save hours', 'error');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Portal] Error saving hours:', 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