feat(vendor): add frontend for contact info inheritance

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 <noreply@anthropic.com>
This commit is contained in:
2025-12-03 22:36:33 +01:00
parent 846f92e7e4
commit c2228bbded
2 changed files with 166 additions and 22 deletions

View File

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