# Adding a New Site Configuration Setting When adding a single new setting to the Site Configuration modal, you MUST update **6 places** across the codebase. Missing any one will cause silent failures. ## Checklist (ordered, follow exactly) ### 1. `settings.js` — Add default value ```javascript // In the `let appSettings = { ... }` block (~line 8) notifyBeforePromised: 0, // 0 = off, 15/30/60 = minutes before promised time ``` ### 2. `settings.js` — Populate form on load (`populateSiteSettingsForm`) ```javascript // ~line 244 setValue('notify-before-promised', appSettings.notifyBeforePromised, 0); ``` Use `setChecked()` for checkboxes/toggles, `setValue()` for selects/inputs. ### 3. `settings.js` — Save handler (`setupUnifiedSiteSettingsModalHandlers`) ×2 There are TWO save handlers that must both read the new field: ```javascript // ~line 277 (inside setupUnifiedSiteSettingsModalHandlers) appSettings.notifyBeforePromised = parseInt(document.getElementById('notify-before-promised')?.value ?? '0'); // ~line 1008 (window.saveSiteSettings bridge — repair-orders inline onclick) appSettings.notifyBeforePromised = parseInt(document.getElementById('notify-before-promised')?.value ?? '0'); ``` Use `replace_all=true` when patching since the two blocks are identical. ### 4. `settings.js` — Auto-save binding (`attachSiteSettingsAutoSave`) ```javascript // ~line 559 bind('notify-before-promised', 'change', (el) => appSettings.notifyBeforePromised = parseInt(el.value || '0')); ``` Use `'change'` for selects, `'change'` for checkboxes. ### 5. `settings.js` — Realtime sync (`subscribeToRealtimeSettings`) ```javascript // ~line 677 setIfSafe('notify-before-promised', String(appSettings.notifyBeforePromised ?? 0)); ``` Use `String()` for value fields, `!!` + `'checked'` for checkbox fields. ### 6. ALL FOUR HTML pages — Add the form control - `repair-orders.html` — inside `#site-settings-modal` → Notifications card - `appointments.html` — inside `#site-settings-modal` → Notifications card - `customers.html` — inside `#site-settings-modal` → Notifications card - `index.html` — inside `#site-settings-modal` → Notifications card All four pages need the identical HTML block. Find the `Critical Alerts` toggle section and add the new control right after it, before the closing `` of the Notifications card. Template for a select dropdown: ```html
Help text explaining the setting
Help text