fix: resolve JS-006 and JS-007 architecture violations
- Add loading: false to 5 components for JS-007 compliance - Add try/catch to async init() functions for JS-006 compliance - Remove noqa comments from company-edit, vendor-edit, user-edit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
// noqa: js-006 - async init pattern is safe, loadData has try/catch
|
|
||||||
// static/admin/js/company-edit.js
|
// static/admin/js/company-edit.js
|
||||||
|
|
||||||
// Create custom logger for company edit
|
// Create custom logger for company edit
|
||||||
@@ -11,6 +10,7 @@ function adminCompanyEdit() {
|
|||||||
|
|
||||||
// Company edit page specific state
|
// Company edit page specific state
|
||||||
currentPage: 'company-edit',
|
currentPage: 'company-edit',
|
||||||
|
loading: false,
|
||||||
company: null,
|
company: null,
|
||||||
formData: {},
|
formData: {},
|
||||||
errors: {},
|
errors: {},
|
||||||
@@ -48,21 +48,26 @@ function adminCompanyEdit() {
|
|||||||
}
|
}
|
||||||
window._companyEditInitialized = true;
|
window._companyEditInitialized = true;
|
||||||
|
|
||||||
// Get company ID from URL
|
try {
|
||||||
const path = window.location.pathname;
|
// Get company ID from URL
|
||||||
const match = path.match(/\/admin\/companies\/(\d+)\/edit/);
|
const path = window.location.pathname;
|
||||||
|
const match = path.match(/\/admin\/companies\/(\d+)\/edit/);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
this.companyId = parseInt(match[1], 10);
|
this.companyId = parseInt(match[1], 10);
|
||||||
companyEditLog.info('Editing company:', this.companyId);
|
companyEditLog.info('Editing company:', this.companyId);
|
||||||
await this.loadCompany();
|
await this.loadCompany();
|
||||||
} else {
|
} else {
|
||||||
companyEditLog.error('No company ID in URL');
|
companyEditLog.error('No company ID in URL');
|
||||||
Utils.showToast('Invalid company URL', 'error');
|
Utils.showToast('Invalid company URL', 'error');
|
||||||
setTimeout(() => window.location.href = '/admin/companies', 2000);
|
setTimeout(() => window.location.href = '/admin/companies', 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
companyEditLog.info('=== COMPANY EDIT PAGE INITIALIZATION COMPLETE ===');
|
||||||
|
} catch (error) {
|
||||||
|
window.LogConfig.logError(error, 'Company Edit Init');
|
||||||
|
Utils.showToast('Failed to initialize page', 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
companyEditLog.info('=== COMPANY EDIT PAGE INITIALIZATION COMPLETE ===');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Load company data
|
// Load company data
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ function adminUserCreate() {
|
|||||||
|
|
||||||
// User create page specific state
|
// User create page specific state
|
||||||
currentPage: 'user-create',
|
currentPage: 'user-create',
|
||||||
|
loading: false,
|
||||||
formData: {
|
formData: {
|
||||||
username: '',
|
username: '',
|
||||||
email: '',
|
email: '',
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// noqa: js-006 - async init pattern is safe, loadData has try/catch
|
|
||||||
// static/admin/js/user-edit.js
|
// static/admin/js/user-edit.js
|
||||||
|
|
||||||
// Create custom logger for user edit
|
// Create custom logger for user edit
|
||||||
@@ -11,6 +10,7 @@ function adminUserEdit() {
|
|||||||
|
|
||||||
// User edit page specific state
|
// User edit page specific state
|
||||||
currentPage: 'user-edit',
|
currentPage: 'user-edit',
|
||||||
|
loading: false,
|
||||||
user: null,
|
user: null,
|
||||||
formData: {},
|
formData: {},
|
||||||
errors: {},
|
errors: {},
|
||||||
@@ -29,21 +29,26 @@ function adminUserEdit() {
|
|||||||
}
|
}
|
||||||
window._userEditInitialized = true;
|
window._userEditInitialized = true;
|
||||||
|
|
||||||
// Get user ID from URL
|
try {
|
||||||
const path = window.location.pathname;
|
// Get user ID from URL
|
||||||
const match = path.match(/\/admin\/users\/(\d+)\/edit/);
|
const path = window.location.pathname;
|
||||||
|
const match = path.match(/\/admin\/users\/(\d+)\/edit/);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
this.userId = parseInt(match[1], 10);
|
this.userId = parseInt(match[1], 10);
|
||||||
userEditLog.info('Editing user:', this.userId);
|
userEditLog.info('Editing user:', this.userId);
|
||||||
await this.loadUser();
|
await this.loadUser();
|
||||||
} else {
|
} else {
|
||||||
userEditLog.error('No user ID in URL');
|
userEditLog.error('No user ID in URL');
|
||||||
Utils.showToast('Invalid user URL', 'error');
|
Utils.showToast('Invalid user URL', 'error');
|
||||||
setTimeout(() => window.location.href = '/admin/users', 2000);
|
setTimeout(() => window.location.href = '/admin/users', 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
userEditLog.info('=== USER EDIT PAGE INITIALIZATION COMPLETE ===');
|
||||||
|
} catch (error) {
|
||||||
|
window.LogConfig.logError(error, 'User Edit Init');
|
||||||
|
Utils.showToast('Failed to initialize page', 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
userEditLog.info('=== USER EDIT PAGE INITIALIZATION COMPLETE ===');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Load user data
|
// Load user data
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// noqa: js-006 - async init pattern is safe, loadData has try/catch
|
|
||||||
// static/admin/js/vendor-edit.js
|
// static/admin/js/vendor-edit.js
|
||||||
|
|
||||||
// ✅ Use centralized logger - ONE LINE!
|
// ✅ Use centralized logger - ONE LINE!
|
||||||
@@ -12,6 +11,7 @@ function adminVendorEdit() {
|
|||||||
|
|
||||||
// Vendor edit page specific state
|
// Vendor edit page specific state
|
||||||
currentPage: 'vendor-edit',
|
currentPage: 'vendor-edit',
|
||||||
|
loading: false,
|
||||||
vendor: null,
|
vendor: null,
|
||||||
formData: {},
|
formData: {},
|
||||||
errors: {},
|
errors: {},
|
||||||
@@ -30,21 +30,26 @@ function adminVendorEdit() {
|
|||||||
}
|
}
|
||||||
window._vendorEditInitialized = true;
|
window._vendorEditInitialized = true;
|
||||||
|
|
||||||
// Get vendor code from URL
|
try {
|
||||||
const path = window.location.pathname;
|
// Get vendor code from URL
|
||||||
const match = path.match(/\/admin\/vendors\/([^\/]+)\/edit/);
|
const path = window.location.pathname;
|
||||||
|
const match = path.match(/\/admin\/vendors\/([^\/]+)\/edit/);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
this.vendorCode = match[1];
|
this.vendorCode = match[1];
|
||||||
editLog.info('Editing vendor:', this.vendorCode);
|
editLog.info('Editing vendor:', this.vendorCode);
|
||||||
await this.loadVendor();
|
await this.loadVendor();
|
||||||
} else {
|
} else {
|
||||||
editLog.error('No vendor code in URL');
|
editLog.error('No vendor code in URL');
|
||||||
Utils.showToast('Invalid vendor URL', 'error');
|
Utils.showToast('Invalid vendor URL', 'error');
|
||||||
setTimeout(() => window.location.href = '/admin/vendors', 2000);
|
setTimeout(() => window.location.href = '/admin/vendors', 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
editLog.info('=== VENDOR EDIT PAGE INITIALIZATION COMPLETE ===');
|
||||||
|
} catch (error) {
|
||||||
|
window.LogConfig.logError(error, 'Vendor Edit Init');
|
||||||
|
Utils.showToast('Failed to initialize page', 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
editLog.info('=== VENDOR EDIT PAGE INITIALIZATION COMPLETE ===');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Load vendor data
|
// Load vendor data
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ function adminVendorProductCreate() {
|
|||||||
currentPage: 'vendor-products',
|
currentPage: 'vendor-products',
|
||||||
|
|
||||||
// Loading states
|
// Loading states
|
||||||
|
loading: false,
|
||||||
saving: false,
|
saving: false,
|
||||||
|
|
||||||
// Tom Select instance
|
// Tom Select instance
|
||||||
|
|||||||
Reference in New Issue
Block a user