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
|
||||
|
||||
// Create custom logger for company edit
|
||||
@@ -11,6 +10,7 @@ function adminCompanyEdit() {
|
||||
|
||||
// Company edit page specific state
|
||||
currentPage: 'company-edit',
|
||||
loading: false,
|
||||
company: null,
|
||||
formData: {},
|
||||
errors: {},
|
||||
@@ -48,21 +48,26 @@ function adminCompanyEdit() {
|
||||
}
|
||||
window._companyEditInitialized = true;
|
||||
|
||||
// Get company ID from URL
|
||||
const path = window.location.pathname;
|
||||
const match = path.match(/\/admin\/companies\/(\d+)\/edit/);
|
||||
try {
|
||||
// Get company ID from URL
|
||||
const path = window.location.pathname;
|
||||
const match = path.match(/\/admin\/companies\/(\d+)\/edit/);
|
||||
|
||||
if (match) {
|
||||
this.companyId = parseInt(match[1], 10);
|
||||
companyEditLog.info('Editing company:', this.companyId);
|
||||
await this.loadCompany();
|
||||
} else {
|
||||
companyEditLog.error('No company ID in URL');
|
||||
Utils.showToast('Invalid company URL', 'error');
|
||||
setTimeout(() => window.location.href = '/admin/companies', 2000);
|
||||
if (match) {
|
||||
this.companyId = parseInt(match[1], 10);
|
||||
companyEditLog.info('Editing company:', this.companyId);
|
||||
await this.loadCompany();
|
||||
} else {
|
||||
companyEditLog.error('No company ID in URL');
|
||||
Utils.showToast('Invalid company URL', 'error');
|
||||
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
|
||||
|
||||
@@ -10,6 +10,7 @@ function adminUserCreate() {
|
||||
|
||||
// User create page specific state
|
||||
currentPage: 'user-create',
|
||||
loading: false,
|
||||
formData: {
|
||||
username: '',
|
||||
email: '',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// noqa: js-006 - async init pattern is safe, loadData has try/catch
|
||||
// static/admin/js/user-edit.js
|
||||
|
||||
// Create custom logger for user edit
|
||||
@@ -11,6 +10,7 @@ function adminUserEdit() {
|
||||
|
||||
// User edit page specific state
|
||||
currentPage: 'user-edit',
|
||||
loading: false,
|
||||
user: null,
|
||||
formData: {},
|
||||
errors: {},
|
||||
@@ -29,21 +29,26 @@ function adminUserEdit() {
|
||||
}
|
||||
window._userEditInitialized = true;
|
||||
|
||||
// Get user ID from URL
|
||||
const path = window.location.pathname;
|
||||
const match = path.match(/\/admin\/users\/(\d+)\/edit/);
|
||||
try {
|
||||
// Get user ID from URL
|
||||
const path = window.location.pathname;
|
||||
const match = path.match(/\/admin\/users\/(\d+)\/edit/);
|
||||
|
||||
if (match) {
|
||||
this.userId = parseInt(match[1], 10);
|
||||
userEditLog.info('Editing user:', this.userId);
|
||||
await this.loadUser();
|
||||
} else {
|
||||
userEditLog.error('No user ID in URL');
|
||||
Utils.showToast('Invalid user URL', 'error');
|
||||
setTimeout(() => window.location.href = '/admin/users', 2000);
|
||||
if (match) {
|
||||
this.userId = parseInt(match[1], 10);
|
||||
userEditLog.info('Editing user:', this.userId);
|
||||
await this.loadUser();
|
||||
} else {
|
||||
userEditLog.error('No user ID in URL');
|
||||
Utils.showToast('Invalid user URL', 'error');
|
||||
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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// noqa: js-006 - async init pattern is safe, loadData has try/catch
|
||||
// static/admin/js/vendor-edit.js
|
||||
|
||||
// ✅ Use centralized logger - ONE LINE!
|
||||
@@ -12,6 +11,7 @@ function adminVendorEdit() {
|
||||
|
||||
// Vendor edit page specific state
|
||||
currentPage: 'vendor-edit',
|
||||
loading: false,
|
||||
vendor: null,
|
||||
formData: {},
|
||||
errors: {},
|
||||
@@ -30,21 +30,26 @@ function adminVendorEdit() {
|
||||
}
|
||||
window._vendorEditInitialized = true;
|
||||
|
||||
// Get vendor code from URL
|
||||
const path = window.location.pathname;
|
||||
const match = path.match(/\/admin\/vendors\/([^\/]+)\/edit/);
|
||||
try {
|
||||
// Get vendor code from URL
|
||||
const path = window.location.pathname;
|
||||
const match = path.match(/\/admin\/vendors\/([^\/]+)\/edit/);
|
||||
|
||||
if (match) {
|
||||
this.vendorCode = match[1];
|
||||
editLog.info('Editing vendor:', this.vendorCode);
|
||||
await this.loadVendor();
|
||||
} else {
|
||||
editLog.error('No vendor code in URL');
|
||||
Utils.showToast('Invalid vendor URL', 'error');
|
||||
setTimeout(() => window.location.href = '/admin/vendors', 2000);
|
||||
if (match) {
|
||||
this.vendorCode = match[1];
|
||||
editLog.info('Editing vendor:', this.vendorCode);
|
||||
await this.loadVendor();
|
||||
} else {
|
||||
editLog.error('No vendor code in URL');
|
||||
Utils.showToast('Invalid vendor URL', 'error');
|
||||
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
|
||||
|
||||
@@ -20,6 +20,7 @@ function adminVendorProductCreate() {
|
||||
currentPage: 'vendor-products',
|
||||
|
||||
// Loading states
|
||||
loading: false,
|
||||
saving: false,
|
||||
|
||||
// Tom Select instance
|
||||
|
||||
Reference in New Issue
Block a user