added red glow to error rows
This commit is contained in:
parent
a7bc98b34b
commit
37a669f4a1
|
|
@ -59,6 +59,10 @@ frappe.ui.form.on('Property tax return', {
|
|||
if (frm.doc.tam_il) {
|
||||
frm.set_value('il_erzinde', 0);
|
||||
toggle_field_readonly(frm);
|
||||
|
||||
// Clear warnings when switching to tam_il
|
||||
validate_minimum_asset_value(frm);
|
||||
|
||||
if (frm.doc.il) {
|
||||
reload_property_tax_data(frm);
|
||||
}
|
||||
|
|
@ -384,6 +388,14 @@ function validate_minimum_asset_value(frm) {
|
|||
const field2 = frm.get_field('warning_elave_2_html');
|
||||
if (field1) field1.$wrapper.hide();
|
||||
if (field2) field2.$wrapper.hide();
|
||||
|
||||
// Remove emoji from both tabs
|
||||
show_warning_if_needed(frm, 'elave_1', false);
|
||||
show_warning_if_needed(frm, 'elave_2', false);
|
||||
|
||||
// Clear any cell highlights
|
||||
highlight_invalid_cells(frm, [], []);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -418,6 +430,9 @@ function validate_minimum_asset_value(frm) {
|
|||
console.log('Əlavə 2 invalid rows:', invalid_rows_2);
|
||||
}
|
||||
|
||||
// Highlight invalid cells in red
|
||||
highlight_invalid_cells(frm, invalid_rows_1, invalid_rows_2);
|
||||
|
||||
// Show/hide warnings and set validation state
|
||||
show_warning_if_needed(frm, 'elave_1', has_error_elave_1);
|
||||
show_warning_if_needed(frm, 'elave_2', has_error_elave_2);
|
||||
|
|
@ -482,9 +497,11 @@ function update_tab_title(frm, table_name, has_error) {
|
|||
const $tab = $(this);
|
||||
const text = $tab.text().trim();
|
||||
|
||||
// Check if this is the tab we want to update
|
||||
if (text === base_title || text === `🔴 ${base_title}`) {
|
||||
// Check if this is the tab we want to update (with or without emoji)
|
||||
if (text === base_title || text === `🔴 ${base_title}` || text.includes(base_title)) {
|
||||
// Always set to the correct state (with or without emoji)
|
||||
$tab.text(tab_title);
|
||||
console.log(`Updated tab "${base_title}" to: "${tab_title}"`);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
@ -493,6 +510,61 @@ function update_tab_title(frm, table_name, has_error) {
|
|||
}, 200);
|
||||
}
|
||||
|
||||
function highlight_invalid_cells(frm, invalid_rows_1, invalid_rows_2) {
|
||||
// Clear any existing highlights first
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// Remove previous highlights from both tables - target the whole cell div
|
||||
$('[data-fieldname="elave_1"] [data-fieldname="hesabatiliərzindəəsasvəsaitlərinqalıqdəyəri"]').css({
|
||||
'background-color': '',
|
||||
'border': '',
|
||||
'box-shadow': ''
|
||||
});
|
||||
$('[data-fieldname="elave_2"] [data-fieldname="hesabatilierzindeuçotaalınan"]').css({
|
||||
'background-color': '',
|
||||
'border': '',
|
||||
'box-shadow': ''
|
||||
});
|
||||
|
||||
// Highlight Əlavə 1 invalid cells (503.2)
|
||||
if (invalid_rows_1.length > 0) {
|
||||
console.log('Highlighting Əlavə 1 invalid rows:', invalid_rows_1.map(r => r.row));
|
||||
invalid_rows_1.forEach(item => {
|
||||
const rowIdx = item.row - 1; // Convert to 0-based data-idx
|
||||
// Target the whole cell container (not just .static-area)
|
||||
const $cell = $(`[data-fieldname="elave_1"] .grid-row[data-idx="${rowIdx}"] [data-fieldname="hesabatiliərzindəəsasvəsaitlərinqalıqdəyəri"]`);
|
||||
console.log(` Row ${item.row} (data-idx=${rowIdx}): Found ${$cell.length} elements`);
|
||||
if ($cell.length > 0) {
|
||||
$cell.css({
|
||||
'background-color': '#ffe6e6',
|
||||
'border': '2px solid #ff0000'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Highlight Əlavə 2 invalid cells (503.1)
|
||||
if (invalid_rows_2.length > 0) {
|
||||
console.log('Highlighting Əlavə 2 invalid rows:', invalid_rows_2.map(r => r.row));
|
||||
invalid_rows_2.forEach(item => {
|
||||
const rowIdx = item.row - 1; // Convert to 0-based data-idx
|
||||
// Target the whole cell container (not just .static-area)
|
||||
const $cell = $(`[data-fieldname="elave_2"] .grid-row[data-idx="${rowIdx}"] [data-fieldname="hesabatilierzindeuçotaalınan"]`);
|
||||
console.log(` Row ${item.row} (data-idx=${rowIdx}): Found ${$cell.length} elements`);
|
||||
if ($cell.length > 0) {
|
||||
$cell.css({
|
||||
'background-color': '#ffe6e6',
|
||||
'border': '2px solid #ff0000'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Could not highlight cells:', e);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// ==================== END VALIDATION ====================
|
||||
|
||||
// Обработчики для дочерней таблицы Elave 2 - автоматический пересчет суммы binalar
|
||||
|
|
|
|||
Loading…
Reference in New Issue