fix: resolve all architecture validation warnings
JavaScript improvements: - Add try/catch error handling to all async init() functions - Move initialization guards before try/catch blocks (JS-005) - Use centralized logger in i18n.js with silent fallback (JS-001) - Add loading state to icons-page.js (JS-007) Payments module structure: - Add templates/, static/, and locales/ directories (MOD-005) - Add locale files for en, de, fr, lb (MOD-006) Architecture validation now passes with 0 errors, 0 warnings, 0 info. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -66,22 +66,27 @@ function adminVendorProductCreate() {
|
||||
},
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
try {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
|
||||
adminVendorProductCreateLog.info('Vendor Product Create init() called');
|
||||
adminVendorProductCreateLog.info('Vendor Product Create init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
if (window._adminVendorProductCreateInitialized) {
|
||||
adminVendorProductCreateLog.warn('Already initialized, skipping');
|
||||
return;
|
||||
// Guard against multiple initialization
|
||||
if (window._adminVendorProductCreateInitialized) {
|
||||
adminVendorProductCreateLog.warn('Already initialized, skipping');
|
||||
return;
|
||||
}
|
||||
window._adminVendorProductCreateInitialized = true;
|
||||
|
||||
// Initialize Tom Select
|
||||
this.initVendorSelect();
|
||||
|
||||
adminVendorProductCreateLog.info('Vendor Product Create initialization complete');
|
||||
} catch (error) {
|
||||
adminVendorProductCreateLog.error('Init failed:', error);
|
||||
this.error = 'Failed to initialize product create page';
|
||||
}
|
||||
window._adminVendorProductCreateInitialized = true;
|
||||
|
||||
// Initialize Tom Select
|
||||
this.initVendorSelect();
|
||||
|
||||
adminVendorProductCreateLog.info('Vendor Product Create initialization complete');
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,11 +76,6 @@ function adminVendorProductEdit() {
|
||||
},
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
|
||||
adminVendorProductEditLog.info('Vendor Product Edit init() called, ID:', this.productId);
|
||||
|
||||
// Guard against multiple initialization
|
||||
if (window._adminVendorProductEditInitialized) {
|
||||
adminVendorProductEditLog.warn('Already initialized, skipping');
|
||||
@@ -88,10 +83,20 @@ function adminVendorProductEdit() {
|
||||
}
|
||||
window._adminVendorProductEditInitialized = true;
|
||||
|
||||
// Load product data
|
||||
await this.loadProduct();
|
||||
try {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
|
||||
adminVendorProductEditLog.info('Vendor Product Edit initialization complete');
|
||||
adminVendorProductEditLog.info('Vendor Product Edit init() called, ID:', this.productId);
|
||||
|
||||
// Load product data
|
||||
await this.loadProduct();
|
||||
|
||||
adminVendorProductEditLog.info('Vendor Product Edit initialization complete');
|
||||
} catch (error) {
|
||||
adminVendorProductEditLog.error('Init failed:', error);
|
||||
this.error = 'Failed to initialize product edit page';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
50
app/modules/catalog/static/vendor/js/products.js
vendored
50
app/modules/catalog/static/vendor/js/products.js
vendored
@@ -112,37 +112,37 @@ function vendorProducts() {
|
||||
},
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
|
||||
vendorProductsLog.info('Products init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
if (window._vendorProductsInitialized) {
|
||||
vendorProductsLog.warn('Already initialized, skipping');
|
||||
return;
|
||||
}
|
||||
window._vendorProductsInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
// Load platform settings for rows per page
|
||||
if (window.PlatformSettings) {
|
||||
this.pagination.per_page = await window.PlatformSettings.getRowsPerPage();
|
||||
}
|
||||
|
||||
try {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('catalog');
|
||||
|
||||
vendorProductsLog.info('Products init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
if (window._vendorProductsInitialized) {
|
||||
vendorProductsLog.warn('Already initialized, skipping');
|
||||
return;
|
||||
}
|
||||
window._vendorProductsInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
// Load platform settings for rows per page
|
||||
if (window.PlatformSettings) {
|
||||
this.pagination.per_page = await window.PlatformSettings.getRowsPerPage();
|
||||
}
|
||||
|
||||
await this.loadProducts();
|
||||
|
||||
vendorProductsLog.info('Products initialization complete');
|
||||
} catch (error) {
|
||||
vendorProductsLog.error('Init failed:', error);
|
||||
this.error = 'Failed to initialize products page';
|
||||
}
|
||||
|
||||
vendorProductsLog.info('Products initialization complete');
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user