From 3cc03fd28ae63faaf82cefe90b15916f3638f770 Mon Sep 17 00:00:00 2001
From: lord_alan <alanslists@gmail.com>
Date: Fri, 7 May 2021 11:25:31 +0100
Subject: [PATCH] Add Mass Select/Deselect eventhandler

---
 .../v7/modules/Calendar/resources/Calendar.js | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/layouts/v7/modules/Calendar/resources/Calendar.js b/layouts/v7/modules/Calendar/resources/Calendar.js
index e3926669f..f96694335 100644
--- a/layouts/v7/modules/Calendar/resources/Calendar.js
+++ b/layouts/v7/modules/Calendar/resources/Calendar.js
@@ -911,8 +911,30 @@ Vtiger.Class("Calendar_Calendar_Js", {
 					thisInstance.registerFeedChangeEvent();
 					thisInstance.registerFeedsColorEditEvent();
 					thisInstance.registerFeedDeleteEvent();
+					thisInstance.registerFeedMassSelectEvent();
 				});
 	},
+
+	/**
+	 * Event listener for change on mass select checkbox.
+	 * Click/set true/false on all non-matching checkboxes & 
+	 * trigger change event. Contributed by Libertus Solutions
+	**/
+	registerFeedMassSelectEvent : function() {
+		var container = jQuery('#calendarview-feeds');
+		var calendarFeeds = jQuery('ul.feedslist input.toggleCalendarFeed', container);
+		jQuery('input.mass-select', container).on('change', function() {
+			var massSelectchecked = this.checked;
+			calendarFeeds.each(function(i) {
+				// Only trigger change where necessary
+				if(this.checked != massSelectchecked) {
+					this.checked = massSelectchecked;
+					jQuery(this).change();
+				}
+			});
+		});
+	},
+
 	changeWidgetDisplayState: function (widget, state) {
 		var key = widget.data('widgetName') + '_WIDGET_DISPLAY_STATE';
 		app.storage.set(key, state);
-- 
GitLab