dashboard changes

This commit is contained in:
Surendiran 2026-07-02 15:39:19 +05:30
parent af571b914a
commit 745742010e
3 changed files with 105 additions and 29 deletions

View File

@ -187,9 +187,7 @@ const kDefaultEnrollmentReminderHtmlBody = r'''<!DOCTYPE html>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="border:1px solid #e5e7eb;border-radius:8px;background-color:#f9fafb;margin-bottom:24px;"> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="border:1px solid #e5e7eb;border-radius:8px;background-color:#f9fafb;margin-bottom:24px;">
<tr> <tr>
<td style="padding:16px 18px;font-size:14px;line-height:22px;color:#374151;"> <td style="padding:16px 18px;font-size:14px;line-height:22px;color:#374151;">
<strong style="color:#111827;">Policy Name:</strong> {{policy_name}}<br>
<strong style="color:#111827;">Policy Number:</strong> {{policy_no}}<br> <strong style="color:#111827;">Policy Number:</strong> {{policy_no}}<br>
<strong style="color:#111827;">Employee Code:</strong> {{emp_code}}<br>
<strong style="color:#111827;">Enrollment Open Date:</strong> {{enrollment_open_date}}<br> <strong style="color:#111827;">Enrollment Open Date:</strong> {{enrollment_open_date}}<br>
<strong style="color:#111827;">Enrollment Close Date:</strong> {{enrollment_close_date}} <strong style="color:#111827;">Enrollment Close Date:</strong> {{enrollment_close_date}}
</td> </td>

View File

@ -518,6 +518,21 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
status == 'enrolled' || status == 'enrolled' ||
status == 'submitted'; status == 'submitted';
String _getRowStatus(Map<String, dynamic> row) {
final raw = localTokenType == 'pre'
? (row['emp_status'] ?? row['status'])
: row['status'];
return raw?.toString().toLowerCase().trim() ?? '';
}
String? _getRowStatusRaw(Map<String, dynamic> 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<String, dynamic> row) { String _getLoggedInValue(Map<String, dynamic> row) {
final loggedInRaw = row['logged_in'] ?? row['emp_is_active']; final loggedInRaw = row['logged_in'] ?? row['emp_is_active'];
final value = loggedInRaw?.toString().toLowerCase().trim() ?? ''; final value = loggedInRaw?.toString().toLowerCase().trim() ?? '';
@ -544,7 +559,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
: const Color(0xFFE8EAF6); : const Color(0xFFE8EAF6);
bool _matchesPreStatusFilter(Map<String, dynamic> row, String filter) { bool _matchesPreStatusFilter(Map<String, dynamic> row, String filter) {
final status = row['status']?.toString().toLowerCase().trim() ?? ''; final status = _getRowStatus(row);
final relationship = row['relationship']?.toString().toLowerCase().trim() ?? ''; final relationship = row['relationship']?.toString().toLowerCase().trim() ?? '';
switch (filter) { switch (filter) {
@ -566,7 +581,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
} }
bool _matchesSearch(Map<String, dynamic> row, String lowerQuery) { bool _matchesSearch(Map<String, dynamic> row, String lowerQuery) {
final status = row['status']?.toString().toLowerCase().trim() ?? ''; final status = _getRowStatus(row);
bool statusMatch; bool statusMatch;
if (lowerQuery == 'active' || lowerQuery == 'inactive') { if (lowerQuery == 'active' || lowerQuery == 'inactive') {
@ -662,7 +677,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
item['gender'] ?? '', item['gender'] ?? '',
item['mobile'] ?? '', item['mobile'] ?? '',
item['email_corporate'] ?? '', item['email_corporate'] ?? '',
item['status'] ?? '', _getRowStatusRaw(item) ?? '',
]); ]);
} }
@ -1914,7 +1929,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
int draft = 0; int draft = 0;
for (final item in originalData) { for (final item in originalData) {
final status = item['status']?.toString().toLowerCase().trim() ?? ''; final status = _getRowStatus(item);
final relationship = final relationship =
item['relationship']?.toString().toLowerCase().trim() ?? ''; item['relationship']?.toString().toLowerCase().trim() ?? '';
@ -2233,11 +2248,11 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: getStatusColor(item['status'] ?? ''), color: getStatusColor(_getRowStatusRaw(item) ?? ''),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
child: Text( child: Text(
_getStatusDisplayLabel(item['status']), _getStatusDisplayLabel(_getRowStatusRaw(item)),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: _dataBold, style: _dataBold,
), ),
@ -3559,6 +3574,7 @@ class _ReminderMailConfigDialogState extends State<_ReminderMailConfigDialog> {
response['message']?.toString() ?? response['message']?.toString() ??
'Reminder mail configuration saved successfully', 'Reminder mail configuration saved successfully',
); );
Navigator.pop(context);
} else { } else {
ToastHelper.showErrorToast( ToastHelper.showErrorToast(
context, context,
@ -3787,25 +3803,25 @@ class _ReminderMailConfigDialogState extends State<_ReminderMailConfigDialog> {
const SizedBox(height: 14), const SizedBox(height: 14),
_buildDaysField(), _buildDaysField(),
const SizedBox(height: 20), const SizedBox(height: 20),
OutlinedButton.icon( // OutlinedButton.icon(
onPressed: isBusy ? null : _openTemplateEditor, // onPressed: isBusy ? null : _openTemplateEditor,
icon: const Icon(Icons.edit_outlined, size: 18), // icon: const Icon(Icons.edit_outlined, size: 18),
label: Text( // label: Text(
'Edit Email Template', // 'Edit Email Template',
style: GoogleFonts.poppins( // style: GoogleFonts.poppins(
fontSize: 13, // fontSize: 13,
fontWeight: FontWeight.w600, // fontWeight: FontWeight.w600,
), // ),
), // ),
style: OutlinedButton.styleFrom( // style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFF009195), // foregroundColor: const Color(0xFF009195),
side: const BorderSide(color: Color(0xFF009195)), // side: const BorderSide(color: Color(0xFF009195)),
padding: const EdgeInsets.symmetric( // padding: const EdgeInsets.symmetric(
horizontal: 16, // horizontal: 16,
vertical: 12, // vertical: 12,
), // ),
), // ),
), // ),
], ],
), ),
), ),

View File

@ -85,10 +85,54 @@
} }
const content = extractBodyContent(fullHtml); const content = extractBodyContent(fullHtml);
editor.setComponents(content); editor.setComponents(content);
makePlaceholderTokensEditable();
editor.refresh(); editor.refresh();
lastExportedHtml = exportFullHtml(); 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) { function insertToken(token) {
if (destroyed || !editor) return; if (destroyed || !editor) return;
const selected = editor.getSelected(); const selected = editor.getSelected();
@ -96,10 +140,25 @@
? selected ? selected
: editor.getWrapper().components().at(0); : editor.getWrapper().components().at(0);
if (cmp && cmp.append) { if (cmp && cmp.append) {
cmp.append('<span>' + token + '</span>'); cmp.append({
type: 'text',
content: token,
editable: true,
selectable: true,
hoverable: true,
copyable: true,
});
} else { } else {
editor.addComponents('<span>' + token + '</span>'); editor.addComponents({
type: 'text',
content: token,
editable: true,
selectable: true,
hoverable: true,
copyable: true,
});
} }
makePlaceholderTokensEditable();
scheduleChange(); scheduleChange();
} }
@ -142,6 +201,9 @@
}); });
editor.on('update', scheduleChange); editor.on('update', scheduleChange);
editor.on('component:selected', function () {
makePlaceholderTokensEditable();
});
if (pendingHtml) { if (pendingHtml) {
loadHtml(pendingHtml); loadHtml(pendingHtml);