From c2228bbdeda0ac407a689f3e7b91ac74103fa333 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Wed, 3 Dec 2025 22:36:33 +0100 Subject: [PATCH] feat(vendor): add frontend for contact info inheritance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add UI for vendor contact field inheritance from company: - Show "(from company)" indicator for inherited fields - Add "Reset" button per field to clear override - Add "Reset All to Company" button for bulk reset - Purple border styling for inherited fields - Dynamic placeholder showing company values JavaScript methods: - resetFieldToCompany(fieldName): Reset individual field - resetAllContactToCompany(): Reset all contact fields - hasAnyContactOverride(): Check if any field is overridden 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/templates/admin/vendor-edit.html | 137 ++++++++++++++++++++++----- static/admin/js/vendor-edit.js | 51 ++++++++++ 2 files changed, 166 insertions(+), 22 deletions(-) diff --git a/app/templates/admin/vendor-edit.html b/app/templates/admin/vendor-edit.html index 1d7cfeb2..4dbbf574 100644 --- a/app/templates/admin/vendor-edit.html +++ b/app/templates/admin/vendor-edit.html @@ -164,9 +164,20 @@
-

- Contact Information -

+
+

+ Contact Information +

+ +
@@ -241,27 +302,59 @@
diff --git a/static/admin/js/vendor-edit.js b/static/admin/js/vendor-edit.js index e3a25965..1df1c662 100644 --- a/static/admin/js/vendor-edit.js +++ b/static/admin/js/vendor-edit.js @@ -254,6 +254,57 @@ function adminVendorEdit() { } finally { this.saving = false; } + }, + + // ===== Contact Field Inheritance Methods ===== + + /** + * Reset a single contact field to inherit from company. + * Sets the field to empty string, which the backend converts to null (inherit). + * @param {string} fieldName - The contact field to reset + */ + resetFieldToCompany(fieldName) { + const contactFields = ['contact_email', 'contact_phone', 'website', 'business_address', 'tax_number']; + if (!contactFields.includes(fieldName)) { + editLog.warn('Invalid contact field:', fieldName); + return; + } + + editLog.info(`Resetting ${fieldName} to inherit from company`); + this.formData[fieldName] = ''; + + // Update the vendor object to reflect inheritance (UI indicator) + if (this.vendor) { + this.vendor[`${fieldName}_inherited`] = true; + } + }, + + /** + * Reset all contact fields to inherit from company. + */ + resetAllContactToCompany() { + editLog.info('Resetting all contact fields to inherit from company'); + + const contactFields = ['contact_email', 'contact_phone', 'website', 'business_address', 'tax_number']; + contactFields.forEach(field => { + this.formData[field] = ''; + if (this.vendor) { + this.vendor[`${field}_inherited`] = true; + } + }); + + Utils.showToast('All contact fields reset to company defaults', 'info'); + }, + + /** + * Check if any contact field has a vendor-level override (not inherited). + * @returns {boolean} True if at least one contact field is overridden + */ + hasAnyContactOverride() { + if (!this.vendor) return false; + + const contactFields = ['contact_email', 'contact_phone', 'website', 'business_address', 'tax_number']; + return contactFields.some(field => !this.vendor[`${field}_inherited`]); } }; }