feat: add View Parent Company link to vendor detail page
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -270,6 +270,16 @@
|
||||
More Actions
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<!-- View Parent Company -->
|
||||
<a
|
||||
:href="'/admin/companies/' + vendor?.company_id + '/edit'"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white transition-colors duration-150 bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none focus:shadow-outline-blue"
|
||||
>
|
||||
<span x-html="$icon('office-building', 'w-4 h-4 mr-2')"></span>
|
||||
View Parent Company
|
||||
</a>
|
||||
|
||||
<!-- Customize Theme -->
|
||||
<a
|
||||
:href="`/admin/vendors/${vendorCode}/theme`"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
|
||||
@@ -278,6 +288,11 @@
|
||||
Customize Theme
|
||||
</a>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-gray-500 dark:text-gray-400">
|
||||
<span x-html="$icon('information-circle', 'w-4 h-4 inline mr-1')"></span>
|
||||
This vendor belongs to company: <strong x-text="vendor?.company_name"></strong>.
|
||||
Contact info and ownership are managed at the company level.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user