From 49774bd27222a41ee40716a133cd5fb4887df84f Mon Sep 17 00:00:00 2001 From: Mohamed Eltayar Date: Wed, 12 Nov 2025 04:24:40 +0300 Subject: [PATCH 1/2] fix: Complete readonly logic for UI buttons and boolean toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Critical Fixes:** 1. **UI Buttons (تبرع/كفالة، مشروط/غير مشروط)**: - ✅ FIXED: Buttons now maintain their visual selection (colors) - ✅ FIXED: Buttons disabled when form NOT in edit mode - ✅ FIXED: Buttons disabled when state != 'draft' - ✅ Buttons editable ONLY when: (mode='edit' AND state='draft') **Previous Problems:** - ❌ Buttons were clickable even when form not in edit mode - ❌ Buttons lost their visual selection (all looked the same) - ❌ opacity=0.6 made selected button unclear **New Solution:** ```javascript var isFormEdit = self.mode === 'edit'; var isDraftState = currentData.state === 'draft'; var isEditable = isFormEdit && isDraftState; // ALWAYS update visual selection (maintain colors) this.$('.record_option').each(function() { if ($(this).data('value') === currentData.record_type) { $(this).addClass('selected'); // Keep color } }); // But disable interaction if not editable if (!isEditable) { this.$('.record_option').css({ 'pointer-events': 'none', // No clicking 'cursor': 'not-allowed' // Show disabled cursor // NO opacity change - keep visual selection clear }); } ``` **Benefits:** - ✅ Visual selection maintained (you can see which is selected) - ✅ No hover effect when readonly - ✅ No clicking when readonly - ✅ Only editable in draft + edit mode 2. **Boolean Toggle (donate_for_another_person)**: - ✅ FIXED: Added readonly attrs - ✅ Widget disabled when state != 'draft' ```xml ``` **Behavior Matrix:** | State | Form Mode | Buttons? | Boolean Toggle? | Correct? | |-------|-----------|----------|----------------|----------| | draft | readonly | ❌ No | ❌ No | ✅ | | draft | edit | ✅ Yes | ✅ Yes | ✅ | | confirmed | readonly | ❌ No | ❌ No | ✅ | | confirmed | edit | ❌ No | ❌ No | ✅ | Files modified: - assets.xml: Complete readonly logic with visual selection - takaful_sponorship_view.xml: Added readonly attrs to boolean toggle Synced with latest dev_odex25_ensan on Wed Nov 12 04:24:40 +03 2025 --- odex25_ensan/odex_takaful/views/assets.xml | 46 +++++++++++++++---- .../views/takaful_sponorship_view.xml | 3 +- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/odex25_ensan/odex_takaful/views/assets.xml b/odex25_ensan/odex_takaful/views/assets.xml index 4e5f5b785..8298c1ab8 100644 --- a/odex25_ensan/odex_takaful/views/assets.xml +++ b/odex25_ensan/odex_takaful/views/assets.xml @@ -206,37 +206,63 @@ _setupSimpleUI: function () { var self = this; var currentData = self.model.localData[self.handle].data; - // CRITICAL: Buttons are ONLY editable in 'draft' state - // Even if user clicks "Edit", buttons remain readonly if state != 'draft' + + // CRITICAL: Buttons are editable ONLY if: + // 1. Form is in edit mode (self.mode === 'edit') + // 2. AND state is 'draft' + var isFormEdit = self.mode === 'edit'; var isDraftState = currentData.state === 'draft'; + var isEditable = isFormEdit && isDraftState; // Remove old event handlers to prevent duplicates this.$('.record_option').off('click'); this.$('.mechanism_option').off('click'); - // Disable buttons if NOT in draft state (regardless of form mode) - if (!isDraftState) { + // Maintain visual selection (selected class) but disable interaction + // Update selected state based on current values + var recordType = currentData.record_type; + var donationMechanism = currentData.donation_mechanism; + + // Update visual selection for record_type + this.$('.record_option').each(function() { + var $opt = $(this); + if ($opt.data('value') === recordType) { + $opt.addClass('selected'); + } else { + $opt.removeClass('selected'); + } + }); + + // Update visual selection for donation_mechanism + this.$('.mechanism_option').each(function() { + var $opt = $(this); + if ($opt.data('value') === donationMechanism) { + $opt.addClass('selected'); + } else { + $opt.removeClass('selected'); + } + }); + + // Disable/Enable buttons based on edit state + if (!isEditable) { + // Disable buttons but KEEP their visual appearance (colors, selection) this.$('.record_option').css({ 'pointer-events': 'none', - 'opacity': '0.6', 'cursor': 'not-allowed' }); this.$('.mechanism_option').css({ 'pointer-events': 'none', - 'opacity': '0.6', 'cursor': 'not-allowed' }); - return; // Don't attach click handlers if not draft + return; // Don't attach click handlers } else { - // Enable buttons ONLY in draft state + // Enable buttons in draft state AND edit mode this.$('.record_option').css({ 'pointer-events': 'auto', - 'opacity': '1', 'cursor': 'pointer' }); this.$('.mechanism_option').css({ 'pointer-events': 'auto', - 'opacity': '1', 'cursor': 'pointer' }); } diff --git a/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml b/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml index 891e9881a..95bec7a24 100644 --- a/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml +++ b/odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml @@ -218,7 +218,8 @@ - + From 37f0dfaca9848170343b420ba15a1a1df8567ad5 Mon Sep 17 00:00:00 2001 From: Mohamed Eltayar Date: Wed, 12 Nov 2025 04:26:41 +0300 Subject: [PATCH 2/2] feat: Update module icon reference in __manifest__.py Changed icon reference from icon5.png to icon.png to match the updated icon file and menu web_icon reference. This ensures consistency across: - __manifest__.py (module definition) - takaful_menus_actions.xml (menu web_icon) - Actual icon file (icon.png) File modified: - odex25_ensan/odex_takaful/__manifest__.py Part of the complete icon update cleanup. --- odex25_ensan/odex_takaful/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_ensan/odex_takaful/__manifest__.py b/odex25_ensan/odex_takaful/__manifest__.py index 93c14dc4e..fa2b729ab 100644 --- a/odex25_ensan/odex_takaful/__manifest__.py +++ b/odex25_ensan/odex_takaful/__manifest__.py @@ -77,7 +77,7 @@ 'reports/transfer_deduction_report.xml', 'reports/transfer_deduction_report_templates.xml', ], - 'icon': 'static/description/icon5.png', + 'icon': 'static/description/icon.png', # 'installable': True, # 'application': True, # 'auto_install': False,