diff --git a/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Application/EmailNotificaions/EmailNotificationManager.cs b/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Application/EmailNotificaions/EmailNotificationManager.cs index 991862240..1d75f4b77 100644 --- a/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Application/EmailNotificaions/EmailNotificationManager.cs +++ b/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Application/EmailNotificaions/EmailNotificationManager.cs @@ -230,10 +230,14 @@ public async Task GetPendingEmailsCountAsync() public async Task BuildEmailObjectWithAttachmentsAsync(EmailLog emailLog) { + var persistedUtcSendOn = emailLog.SendOnDateTime.HasValue + ? DateTime.SpecifyKind(emailLog.SendOnDateTime.Value, DateTimeKind.Utc) + : (DateTime?)null; + // Get base email object (without attachments) var emailObject = await GetEmailObjectAsync( new EmailMessageParams(emailLog.ToAddress, emailLog.Body, emailLog.Subject, - emailLog.FromAddress, emailLog.TemplateName, emailLog.CC, emailLog.BCC, emailLog.SendOnDateTime), + emailLog.FromAddress, emailLog.TemplateName, emailLog.CC, emailLog.BCC, persistedUtcSendOn), emailLog.BodyType, excludeTemplate: true); diff --git a/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Web/Views/Settings/NotificationsSettingGroup/Default.js b/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Web/Views/Settings/NotificationsSettingGroup/Default.js index 11e47948b..df77c828f 100644 --- a/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Web/Views/Settings/NotificationsSettingGroup/Default.js +++ b/applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.Web/Views/Settings/NotificationsSettingGroup/Default.js @@ -1,11 +1,5 @@  $(function () { - - let dropdownItems = []; - let emailAttachmentsTable = null; - let templatesDataTable = null; - let originalFormValues = {}; - const UiElements = { saveButton: $("#saveTemplateBtn"), discardButton: $("#discardTemaplateBtn"), @@ -15,14 +9,66 @@ $(function () { templatesTable: $('#TemplatesTable') } + const NotificationUiElements = { + settingForm: $("#NotificationsSettingsForm"), + saveButton: $("#NotificationsSaveButton"), + discardButton: $("#NotificationsDiscardButton") + } + + let initialFormState = NotificationUiElements.settingForm.serialize(); + let dropdownItems = []; + let emailAttachmentsTable = null; + let templatesDataTable = null; + let originalFormValues = {}; + function init() { $('#email-attachments-section').hide(); initializeTemplateDataTables(); initializeDivider(); initializeTabPersistence(); initializeRecipientSelect(); + checkFormChanges(); + } + + function checkFormChanges() { + let currentFormState = NotificationUiElements.settingForm.serialize(); + let isFormChanged = currentFormState !== initialFormState; + + NotificationUiElements.saveButton.prop('disabled', !isFormChanged); + NotificationUiElements.discardButton.prop('disabled', !isFormChanged); } + NotificationUiElements.settingForm.on('input change', function () { + checkFormChanges(); + }); + + NotificationUiElements.settingForm.on('submit', function (event) { + event.preventDefault(); + + if (!$(this).valid()) { + return; + } + + let form = $(this).serializeFormToObject(); + unity.notifications.emailNotifications.emailNotification.updateSettings(form).then(function (result) { + $(document).trigger("AbpSettingSaved"); + initialFormState = NotificationUiElements.settingForm.serialize(); + checkFormChanges(); + }).then(function () { + abp.notify.success('Settings saved successfully.'); + }).$catch(function (e) { + console.warn('Failed to save settings:', e); + abp.notify.error('Failed to save settings.'); + }); + + }); + + NotificationUiElements.discardButton.on('click', function () { + NotificationUiElements.settingForm[0].reset(); + initialFormState = NotificationUiElements.settingForm.serialize(); + checkFormChanges(); + }); + init(); // ── Tab State Persistence ───────────────────────────────────────────── diff --git a/applications/Unity.GrantManager/src/Unity.GrantManager.Domain.Shared/Localization/GrantManager/en.json b/applications/Unity.GrantManager/src/Unity.GrantManager.Domain.Shared/Localization/GrantManager/en.json index aa8153113..3f0b38750 100644 --- a/applications/Unity.GrantManager/src/Unity.GrantManager.Domain.Shared/Localization/GrantManager/en.json +++ b/applications/Unity.GrantManager/src/Unity.GrantManager.Domain.Shared/Localization/GrantManager/en.json @@ -563,7 +563,7 @@ "ProgramDetails:Branch": "Branch", "ProgramDetails:Description": "Description", "ProgramDetails:SaveChanges": "Save Changes", - "ProgramDetails:ResetChanges": "Reset", + "ProgramDetails:ResetChanges": "Discard Changes", "ProgramDetails:NoChanges": "No changes to save.", "ProgramDetails:ChangesReset": "Changes have been reset to original values.", "ProgramDetails:SaveSuccess": "Program details updated successfully.",