9.6 KiB
9.6 KiB
Quick Fix Guide - v1.1.5 to v1.2.0
Time Required: 30 minutes
Difficulty: Easy
Impact: Critical bugs fixed
🎯 Two Bugs to Fix
Bug #1: Div Display Pagination (CRITICAL)
File: /assets/public.js
Lines: 137-179
Time: 15 minutes
Bug #2: Card Display Colors (MINOR)
File: /assets/public.js
Lines: 307-308
Time: 5 minutes
🔧 Bug #1 Fix: Div Display Pagination
Current Code (BROKEN)
}else if(res.settings.display == 'div') {
$.each(res.rows, function(index, item) {
resultData = item;
var header_color = res.settings.header;
var value_color = res.settings.value;
$.each(item, function(q,r){
var id = q.replace(' ', '_').replace('.', '_').toLowerCase();
var prefix = '';
var type = '';
var button_text = '';
var hidden = 'no';
$.each(res.output, function(o,p){
if(q == p.key){
prefix = p.prefix;
type = p.type;
button_text = p.button_text;
if('hide' in p){
hidden = p.hide;
}
}
});
if(hidden == 'yes'){
return;
}
if(type == 'link_button'){
r = '<a href="'+r+'" class="button dw-checker-value-button">'+button_text+'</a>';
}else if(type == 'whatsapp_button'){
r = '<a href="https://wa.me/'+r+'" class="button dw-checker-value-button">'+button_text+'</a>';
}
// BUG: Container created per field (WRONG!)
if(index == 0){
resultDiv += '<div class="dw-checker-result-container" data-pagination="'+index+'">';
}else{
resultDiv += '<table class="dw-checker-result-container" data-pagination="'+index+'" style="display: none;">';
}
resultDiv += '<div class="dw-checker-result-div" style="border-bottom-color: '+res.settings.divider+'; border-bottom-width: '+res.settings.divider_width+'px;">';
resultDiv += '<div class="result-header"><span class="dw-checker-result-header" style="color:'+header_color+';">'+q+'</span></div>';
resultDiv += '<div class="result-value"><span class="dw-checker-result-value" style="color:'+value_color+';">'+prefix+r+'</span></div>';
resultDiv += '</div></div>';
});
});
this_checker.find('.dw-checker-result').find('.dw-checker-results').html(resultDiv);
}
Fixed Code (CORRECT)
}else if(res.settings.display == 'div') {
$.each(res.rows, function(index, item) {
resultData = item;
var header_color = res.settings.header;
var value_color = res.settings.value;
// Create container div for this row (CORRECT!)
if(index == 0){
resultDiv += '<div class="dw-checker-result-container" data-pagination="'+index+'">';
}else{
resultDiv += '<div class="dw-checker-result-container" data-pagination="'+index+'" style="display: none;">';
}
// Loop through each field in the row
$.each(item, function(q,r){
var id = q.replace(' ', '_').replace('.', '_').toLowerCase();
var prefix = '';
var type = '';
var button_text = '';
var hidden = 'no';
$.each(res.output, function(o,p){
if(q == p.key){
prefix = p.prefix;
type = p.type;
button_text = p.button_text;
if('hide' in p){
hidden = p.hide;
}
}
});
if(hidden == 'yes'){
return;
}
if(type == 'link_button'){
r = '<a href="'+r+'" class="button dw-checker-value-button">'+button_text+'</a>';
}else if(type == 'whatsapp_button'){
r = '<a href="https://wa.me/'+r+'" class="button dw-checker-value-button">'+button_text+'</a>';
}
resultDiv += '<div class="dw-checker-result-div" style="border-bottom-color: '+res.settings.divider+'; border-bottom-width: '+res.settings.divider_width+'px;">';
resultDiv += '<div class="result-header"><span class="dw-checker-result-header" style="color:'+header_color+';">'+q+'</span></div>';
resultDiv += '<div class="result-value"><span class="dw-checker-result-value" style="color:'+value_color+';">'+prefix+r+'</span></div>';
resultDiv += '</div>';
});
// Close container div for this row (CORRECT!)
resultDiv += '</div>';
});
this_checker.find('.dw-checker-result').find('.dw-checker-results').html(resultDiv);
}
What Changed?
- ✅ Moved container creation outside field loop
- ✅ Changed
<table>to<div>for consistency - ✅ Proper closing of container div
- ✅ One container per row (not per field)
🔧 Bug #2 Fix: Card Display Colors
Current Code (BROKEN)
resultDiv += `<div class="dw-checker-single-card" style="background-color: `+bg_color+`; color: `+text_color+`; border-color: `+res.settings.divider+`; border-width: `+res.settings.divider_width+`px;">
<span class="dw-checker-card-header" style="color:`+value_color+`">`+q+`</span>
<span class="dw-checker-card-value" style="color:`+value_color+`">`+prefix+r+`</span>
</div>`;
Fixed Code (CORRECT)
resultDiv += `<div class="dw-checker-single-card" style="background-color: `+bg_color+`; color: `+text_color+`; border-color: `+res.settings.divider+`; border-width: `+res.settings.divider_width+`px;">
<span class="dw-checker-card-header" style="color:`+text_color+`">`+q+`</span>
<span class="dw-checker-card-value" style="color:`+text_color+`">`+prefix+r+`</span>
</div>`;
What Changed?
- ✅ Changed
value_colortotext_color(line 307) - ✅ Changed
value_colortotext_color(line 308)
Why? Each card should use its own text_color from output settings, not the global value_color.
📋 Step-by-Step Instructions
Step 1: Backup Current File
cd /Users/dwindown/Local Sites/sejoli/app/public/wp-content/plugins/dw-sheet-data-checker-pro/extracted_latest/dw-sheet-data-checker-pro
cp assets/public.js assets/public.js.backup
Step 2: Open File in Editor
# Open in your preferred editor
code assets/public.js
# or
nano assets/public.js
Step 3: Fix Bug #1 (Lines 137-179)
- Find line 137:
}else if(res.settings.display == 'div') { - Replace the entire block with the fixed code above
- Save file
Step 4: Fix Bug #2 (Lines 307-308)
- Find line 307:
<span class="dw-checker-card-header" style="color:+value_color+"> - Replace
value_colorwithtext_color - Find line 308:
<span class="dw-checker-card-value" style="color:+value_color+"> - Replace
value_colorwithtext_color - Save file
Step 5: Test Changes
- Create a test checker with div display
- Add multiple matching records
- Test pagination works
- Create a test checker with card display
- Set different text colors per card
- Verify colors apply correctly
✅ Testing Checklist
Div Display Test
- Create checker with div display
- Search returns 2+ results
- Pagination buttons appear
- Clicking pagination switches results
- Only one result visible at a time
- No console errors
- HTML structure is valid (no mixed div/table)
Card Display Test
- Create checker with card display
- Set different text colors for different cards
- Search returns results
- Each card shows its configured text color
- Background colors work
- No console errors
All Display Types Test
- Vertical table works
- Standard table works
- Div display works (after fix)
- Card display works (after fix)
- Link buttons work
- WhatsApp buttons work
- Hide/show works
- Prefix works
🚀 After Fixing
Update Version
Edit dw-sheet-data-checker-pro.php:
// Line 5
* Version: 1.2.0
// Line 28
define( 'SHEET_CHECKER_PRO_VERSION', '1.2.0' );
Create Changelog
Create CHANGELOG.md:
# Changelog
## [1.2.0] - 2024-11-15
### Fixed
- Fixed div display pagination structure
- Fixed card display text color not using per-card settings
- Improved HTML structure for div display
### Changed
- Updated version to 1.2.0
## [1.1.5] - 2024
- Added WhatsApp button type
- Added TSV format support
- Added responsive card grid
- Refactored to modular template system
- Integrated Handlebars.js
Deploy
- Test thoroughly on staging
- Clear browser cache
- Deploy to production
- Monitor for errors
- Notify users
🎯 Expected Results
Before Fix
- ❌ Div display pagination broken
- ❌ Card colors don't work per-card
- ❌ Multiple results fail in div display
- ❌ Invalid HTML structure
After Fix
- ✅ Div display pagination works perfectly
- ✅ Card colors work per-card
- ✅ Multiple results display correctly
- ✅ Valid HTML structure
- ✅ All 4 display types fully functional
📞 Need Help?
If you encounter issues:
- Check Console: Look for JavaScript errors
- Inspect HTML: Verify structure is correct
- Test Individually: Test each display type separately
- Revert if Needed: Use backup file
- Contact Support: @dwindown on Telegram
Time to Fix: 30 minutes
Difficulty: Easy
Impact: High
Risk: Low (easy to revert)
Ready to fix? Let's do this! 🚀