Closed (fixed)
Project:
Sitewide Alert
Version:
3.1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Aug 2022 at 19:02 UTC
Updated:
29 Jan 2026 at 23:44 UTC
Jump to comment: Most recent
Comments
Comment #3
mortona2k commentedThis MR adds the necessary variables in the sitewide_alert preprocess and template.
It uses a static variable to count the number of times the preprocess has been called.
Total count comes from SitewideAlertManager->activeVisibleSitewideAlerts().
Comment #4
mortona2k commentedI realized there is JS to handle closing alerts and adding new ones. The number handling should go in there so it can get recalculated as needed.
Comment #5
smustgrave commentedLets land this in the 3.0.x branch first.
Comment #6
smustgrave commentedyea lets add a config option for this.
Comment #8
dlevchik commented- Merged 3.x into MR
- Added config option for 'Show alerts count'
- Added translation for @current_count of @total_count alerts
- Fixed db queries in a preprocess loop for total count by static caching it
- Added JS function updateAlertCount on initAlerts and removeAlert. Message is dynamic and translatable
Comment #9
smustgrave commentedCan you update MR for 3.0.x
Comment #11
dlevchik commentedCreated new MR: https://git.drupalcode.org/project/sitewide_alert/-/merge_requests/66
Comment #12
smustgrave commentedNice, lets add some test coverage for this.
Comment #13
dlevchik commentedAdded tests, it is a FunctionalJavascriptTest. I wanted to test the alerts count change on adding new alert and dismissing another alert, and it kinda become also a test for sitewide_alert_block and refresh_interval. Hope you don't mind such a big test. Besides, there was no test cases for those things before, so it may be to the benefit
Also, a question maybe we may think of: should we hide alerts count when there is only one alert available for user? This also needs to be done via JS I believe, since dismissed alerts are in localStorage
Comment #15
smustgrave commentedShould make them appear inline vs stacked.
Comment #18
smustgrave commentedNeeded this for a client project but noticed an issue, besides the test failure
When you dismiss an alert and reload the page, 1 alert will show but count is now off.
Comment #20
smustgrave commentedFixed that issue and added additional coverage for it.
Comment #22
smustgrave commentedNot reverting yet but need to make the tests better seem to randomly fail
Comment #25
smustgrave commentedRe-ran a few times and tests pass more consistently