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`]); } }; }