Closed swastikpareek closed 4 years ago
@swastikpareek Thanks for PR.have checked the dashboard issue as you mentioned in PR but on the latest normal CiviCRM, it works fine for me. If you have enabled the Shoreditch
extension it causes that issue. so will merge your PR then it will work for both.
Overview
This PR fixes
Text color on the calendar events. currently all calendar events have text color of white(no matter of their background color) and this creates a contrasting UX problem. The text become very unclear to read if background color of events on the calendar are too light)
Fix the calendar on events dashlet on dashboard page. Initially, the events dashlet on dashboard doesn't show events. Now we fix this.
Before - text color
After - text color
Before - events calendar on dashboard
After - events calendar on dashboard
Technical Details
Text color.
We used a PHP function which will return contrasting color on the basis of the hex code. The solution was encouraged from here - https://stackoverflow.com/questions/1331591 This function will return white color hex code if bg is too dark and returns white color if bg is too light. This function is then used to provide
textColor
to the full calendar JS library events items( seeShowEvents.php
). To make it work we had to disable the css which sets the text color of the full calendar events towhite
. See (_events.css
)Events on Dashlet
The issue with this is that the full calendar library was not attached on the page at the time of load but was attached by the AJAX (XHR) call.
In this way when full calendar template (compiled HTML) was added via AJAX there is a race condition which happens in which
buildCalendar
which calls the full calendar API function gets initiated before the related full calendar library is even finished loading. And hencefull-calendar
becomes undefined.To fix this, we created a promise which will check if
fullCalendar
function is available under jQuery on load or not and if it doesn't then it waits for theajaxComplete
event (which will make sure that if the full calendar library is called through AJAX gets loaded on the page) and then calls thebuildCalendar
function, making it execute w/o error.