From e094e81649b3711b27a6e5ee4c9e69adc89bdea8 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Tue, 2 Dec 2025 19:39:46 +0100 Subject: [PATCH] feat: add View Parent Company link to vendor detail page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add "View Parent Company" button in More Actions section - Show parent company name in info text - Add deleteVendor function to vendor-edit.js 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/templates/admin/vendor-detail.html | 15 ++++++++++ static/admin/js/vendor-edit.js | 41 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/app/templates/admin/vendor-detail.html b/app/templates/admin/vendor-detail.html index 38ae60e5..0e8e68d7 100644 --- a/app/templates/admin/vendor-detail.html +++ b/app/templates/admin/vendor-detail.html @@ -270,6 +270,16 @@ More Actions +

+ + This vendor belongs to company: . + Contact info and ownership are managed at the company level. +

{% endblock %} diff --git a/static/admin/js/vendor-edit.js b/static/admin/js/vendor-edit.js index 368e50c5..e3a25965 100644 --- a/static/admin/js/vendor-edit.js +++ b/static/admin/js/vendor-edit.js @@ -213,6 +213,47 @@ function adminVendorEdit() { } finally { this.saving = false; } + }, + + // Delete vendor + async deleteVendor() { + editLog.info('Delete vendor requested'); + + const vendorName = this.vendor?.name || this.vendorCode; + if (!confirm(`Are you sure you want to delete "${vendorName}"?\n\n⚠️ WARNING: This will permanently delete:\n• All products\n• All orders\n• All customers\n• All team members\n\nThis action cannot be undone!`)) { + editLog.info('Delete cancelled by user'); + return; + } + + // Double confirmation for safety + if (!confirm(`FINAL CONFIRMATION\n\nType OK to permanently delete "${vendorName}" and ALL associated data.`)) { + editLog.info('Delete cancelled at final confirmation'); + return; + } + + this.saving = true; + try { + const url = `/admin/vendors/${this.vendorCode}?confirm=true`; + window.LogConfig.logApiCall('DELETE', url, null, 'request'); + + const response = await apiClient.delete(url); + + window.LogConfig.logApiCall('DELETE', url, response, 'response'); + + Utils.showToast('Vendor deleted successfully', 'success'); + editLog.info('Vendor deleted successfully'); + + // Redirect to vendors list + setTimeout(() => { + window.location.href = '/admin/vendors'; + }, 1500); + + } catch (error) { + window.LogConfig.logError(error, 'Delete Vendor'); + Utils.showToast(error.message || 'Failed to delete vendor', 'error'); + } finally { + this.saving = false; + } } }; }