Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Time-out for Bar Notifications from Back-End #7373

Open
Ixorus opened this issue Oct 20, 2024 · 0 comments
Open

Provide Time-out for Bar Notifications from Back-End #7373

Ixorus opened this issue Oct 20, 2024 · 0 comments

Comments

@Ixorus
Copy link

Ixorus commented Oct 20, 2024

nopCommerce version: 4.70

Description of the issue:

Nop's front-end can display bar notifications that automatically disappear after a specified number of milliseconds (for example, /Plugins/Nop.Plugin.Tax.Avalara/Views/Customer/ExemptionCertificates.cshtml )

Nop's back-end can display bar notifications, but they must all be explicitly closed by the user by clicking the close [X] button, potentially interrupting their flow through the site.

Nop uses the NotificationService to create messages to pass to the front-end, and some of the notifications are strictly informational, especially when they are of the form:

_notificationService.SuccessNotification(...)

I have created and tested a modification of the methods in the NotificationService class that add a new optional timeout parameter. This allows back-end services to request that messages be displayed for a specified period of time, and then fade away automatically (using the already existing logic in the displayBarNotification javascript), requiring no user interaction.

The new signatures are:

void SuccessNotification(string message, bool encode = true, int timeout = 0);

void WarningNotification(string message, bool encode = true, int timeout = 0);

void ErrorNotification(string message, bool encode = true, int timeout = 0);

Requesting that the message fade away without user interaction is as easy as adding the extra parameter.

For example, when a user posts a product review, this is the code that runs today:

_notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Reviews.SuccessfullyAdded"));

Allowing it to fade away with the extra parameter:

_notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Reviews.SuccessfullyAdded"), timeout: 3000);

It is a better user experience for the user to have messages like this disappear on their own, especially considering that they can actually see their product review on the page that the bar notification appears on.

The other methods would be called in an identical way:

_notificationService.WarningNotification(message, timeout: 3000);

_notificationService.ErrorNotification(message, timeout: 3000);

If the extra parameter is not added, nothing changes. So, this would not be a breaking change.

Implementation also required small changes to the NotifyData.cs, Shared_Notifications.cshtml and Shared\Notifications.cshtml views.

Can I go ahead and polish this up for inclusion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants