osseed / com.osseed.eventcalendar

CiviCRM Event Calendar
GNU General Public License v3.0
10 stars 37 forks source link

BASW-643: Fix calendar for dashlet on dashboard and configure text colour for events calendar events #74

Closed swastikpareek closed 4 years ago

swastikpareek commented 4 years ago

Overview

This PR fixes

Before - text color

Screenshot 2020-05-27 at 9 27 25 PM

After - text color

Screenshot 2020-05-27 at 9 26 36 PM

Before - events calendar on dashboard

Screenshot 2020-05-28 at 12 33 27 PM

After - events calendar on dashboard

ezgif com-optimize

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( see ShowEvents.php). To make it work we had to disable the css which sets the text color of the full calendar events to white . 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.

Screenshot 2020-05-28 at 12 32 10 PM

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 hence full-calendar becomes undefined.

Screenshot 2020-05-28 at 1 34 13 PM Screenshot 2020-05-28 at 1 34 22 PM

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 the ajaxComplete event (which will make sure that if the full calendar library is called through AJAX gets loaded on the page) and then calls the buildCalendar function, making it execute w/o error.

pranav45 commented 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.