From 745742010e1000a9c410d162c3bd358b1e06e44c Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Thu, 2 Jul 2026 15:39:19 +0530 Subject: [PATCH] dashboard changes --- .../email_template/email_template_models.dart | 2 - lib/presentation/hrPolicyDetails.dart | 66 ++++++++++++------- web/email-editor.html | 66 ++++++++++++++++++- 3 files changed, 105 insertions(+), 29 deletions(-) diff --git a/lib/presentation/email_template/email_template_models.dart b/lib/presentation/email_template/email_template_models.dart index 3d83c40..79686a6 100644 --- a/lib/presentation/email_template/email_template_models.dart +++ b/lib/presentation/email_template/email_template_models.dart @@ -187,9 +187,7 @@ const kDefaultEnrollmentReminderHtmlBody = r''' diff --git a/lib/presentation/hrPolicyDetails.dart b/lib/presentation/hrPolicyDetails.dart index 8805f5c..9af0cd7 100755 --- a/lib/presentation/hrPolicyDetails.dart +++ b/lib/presentation/hrPolicyDetails.dart @@ -518,6 +518,21 @@ class _HrPolicyDetailsState extends State status == 'enrolled' || status == 'submitted'; + String _getRowStatus(Map row) { + final raw = localTokenType == 'pre' + ? (row['emp_status'] ?? row['status']) + : row['status']; + return raw?.toString().toLowerCase().trim() ?? ''; + } + + String? _getRowStatusRaw(Map row) { + final raw = localTokenType == 'pre' + ? (row['emp_status'] ?? row['status']) + : row['status']; + final value = raw?.toString().trim(); + return value == null || value.isEmpty ? null : value; + } + String _getLoggedInValue(Map row) { final loggedInRaw = row['logged_in'] ?? row['emp_is_active']; final value = loggedInRaw?.toString().toLowerCase().trim() ?? ''; @@ -544,7 +559,7 @@ class _HrPolicyDetailsState extends State : const Color(0xFFE8EAF6); bool _matchesPreStatusFilter(Map row, String filter) { - final status = row['status']?.toString().toLowerCase().trim() ?? ''; + final status = _getRowStatus(row); final relationship = row['relationship']?.toString().toLowerCase().trim() ?? ''; switch (filter) { @@ -566,7 +581,7 @@ class _HrPolicyDetailsState extends State } bool _matchesSearch(Map row, String lowerQuery) { - final status = row['status']?.toString().toLowerCase().trim() ?? ''; + final status = _getRowStatus(row); bool statusMatch; if (lowerQuery == 'active' || lowerQuery == 'inactive') { @@ -662,7 +677,7 @@ class _HrPolicyDetailsState extends State item['gender'] ?? '', item['mobile'] ?? '', item['email_corporate'] ?? '', - item['status'] ?? '', + _getRowStatusRaw(item) ?? '', ]); } @@ -1914,7 +1929,7 @@ class _HrPolicyDetailsState extends State int draft = 0; for (final item in originalData) { - final status = item['status']?.toString().toLowerCase().trim() ?? ''; + final status = _getRowStatus(item); final relationship = item['relationship']?.toString().toLowerCase().trim() ?? ''; @@ -2233,11 +2248,11 @@ class _HrPolicyDetailsState extends State child: Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( - color: getStatusColor(item['status'] ?? ''), + color: getStatusColor(_getRowStatusRaw(item) ?? ''), borderRadius: BorderRadius.circular(10), ), child: Text( - _getStatusDisplayLabel(item['status']), + _getStatusDisplayLabel(_getRowStatusRaw(item)), textAlign: TextAlign.center, style: _dataBold, ), @@ -3559,6 +3574,7 @@ class _ReminderMailConfigDialogState extends State<_ReminderMailConfigDialog> { response['message']?.toString() ?? 'Reminder mail configuration saved successfully', ); + Navigator.pop(context); } else { ToastHelper.showErrorToast( context, @@ -3787,25 +3803,25 @@ class _ReminderMailConfigDialogState extends State<_ReminderMailConfigDialog> { const SizedBox(height: 14), _buildDaysField(), const SizedBox(height: 20), - OutlinedButton.icon( - onPressed: isBusy ? null : _openTemplateEditor, - icon: const Icon(Icons.edit_outlined, size: 18), - label: Text( - 'Edit Email Template', - style: GoogleFonts.poppins( - fontSize: 13, - fontWeight: FontWeight.w600, - ), - ), - style: OutlinedButton.styleFrom( - foregroundColor: const Color(0xFF009195), - side: const BorderSide(color: Color(0xFF009195)), - padding: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 12, - ), - ), - ), + // OutlinedButton.icon( + // onPressed: isBusy ? null : _openTemplateEditor, + // icon: const Icon(Icons.edit_outlined, size: 18), + // label: Text( + // 'Edit Email Template', + // style: GoogleFonts.poppins( + // fontSize: 13, + // fontWeight: FontWeight.w600, + // ), + // ), + // style: OutlinedButton.styleFrom( + // foregroundColor: const Color(0xFF009195), + // side: const BorderSide(color: Color(0xFF009195)), + // padding: const EdgeInsets.symmetric( + // horizontal: 16, + // vertical: 12, + // ), + // ), + // ), ], ), ), diff --git a/web/email-editor.html b/web/email-editor.html index 8b1558c..940b846 100644 --- a/web/email-editor.html +++ b/web/email-editor.html @@ -85,10 +85,54 @@ } const content = extractBodyContent(fullHtml); editor.setComponents(content); + makePlaceholderTokensEditable(); editor.refresh(); lastExportedHtml = exportFullHtml(); } + function makePlaceholderTokensEditable() { + if (destroyed || !editor) return; + const wrapper = editor.getWrapper(); + if (!wrapper) return; + + const visit = function (cmp) { + if (!cmp || typeof cmp.get !== 'function') return; + + const content = (cmp.get('content') || '').toString(); + if (/\{\{[^{}]+\}\}/.test(content)) { + cmp.set('editable', true); + cmp.set('selectable', true); + cmp.set('hoverable', true); + cmp.set('copyable', true); + } + + const children = cmp.components && cmp.components(); + if (children && typeof children.each === 'function') { + children.each(function (child) { + visit(child); + }); + } + }; + + visit(wrapper); + + // Ensure rendered canvas nodes containing placeholders are editable too. + // Some newsletter/table components keep internal text nodes read-only unless + // contenteditable is explicitly set on the live DOM element. + const doc = editor.Canvas && editor.Canvas.getDocument + ? editor.Canvas.getDocument() + : null; + if (!doc) return; + + const nodes = doc.querySelectorAll('*'); + nodes.forEach(function (el) { + if (!el || !el.innerHTML) return; + if (/\{\{[^{}]+\}\}/.test(el.innerHTML)) { + el.setAttribute('contenteditable', 'true'); + } + }); + } + function insertToken(token) { if (destroyed || !editor) return; const selected = editor.getSelected(); @@ -96,10 +140,25 @@ ? selected : editor.getWrapper().components().at(0); if (cmp && cmp.append) { - cmp.append('' + token + ''); + cmp.append({ + type: 'text', + content: token, + editable: true, + selectable: true, + hoverable: true, + copyable: true, + }); } else { - editor.addComponents('' + token + ''); + editor.addComponents({ + type: 'text', + content: token, + editable: true, + selectable: true, + hoverable: true, + copyable: true, + }); } + makePlaceholderTokensEditable(); scheduleChange(); } @@ -142,6 +201,9 @@ }); editor.on('update', scheduleChange); + editor.on('component:selected', function () { + makePlaceholderTokensEditable(); + }); if (pendingHtml) { loadHtml(pendingHtml);
- Policy Name: {{policy_name}}
Policy Number: {{policy_no}}
- Employee Code: {{emp_code}}
Enrollment Open Date: {{enrollment_open_date}}
Enrollment Close Date: {{enrollment_close_date}}