Skip to content

Commit 89eeb59

Browse files
committed
Merge branch '6.0/add-modify-calendar-callback' into 6.0-trunk
2 parents 9f3b677 + 0f3300f commit 89eeb59

5 files changed

Lines changed: 52 additions & 26 deletions

File tree

share/html/Search/Elements/Calendar

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,21 +586,20 @@ $TempQuery .= RT::Search::Calendar::DatesClauses(\@Dates, $date->strftime("%F"),
586586

587587
$m->callback( CallbackName => 'BeforeFindTickets', ARGSRef => \%ARGS, QueryRef => \$TempQuery, FormatRef => \$TempFormat );
588588

589-
my $DownloadQueryString =
590-
$m->comp(
591-
'/Elements/QueryString',
592-
Query => $TempQuery,
593-
Format => $Format,
594-
Order => $Order,
595-
OrderBy => $OrderBy,
596-
);
597-
598589
my $Calendar;
599590

600591
# This is the expensive part of the processing, so only run this when
601592
# htmx is rendering the main content.
602593
if ( $m->request_path =~ /^(?:\/SelfService)?\/Views|Calendar.html/ ) {
603594
$Calendar = RT::Search::Calendar::GetCalendarTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"), $starts_field, $ends_field);
595+
596+
$m->callback(
597+
CallbackName => 'ModifyCalendar',
598+
CalendarRef => \$Calendar,
599+
BeginDate => $date->strftime("%F"),
600+
EndDate => $end->strftime("%F"),
601+
SavedSearchObj => $SavedSearchObj,
602+
);
604603
}
605604

606605
my $BaseURL;

share/html/Search/Elements/CalendarEvent

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ data-object="<% $Object->Type %>-<% $Object->id %>"
104104

105105
% if ( $first_day_of_the_event || $DayOfWeek eq 1 ) {
106106
hx-get="<% RT->Config->Get("WebPath") . ( $session{CurrentUser}->Privileged ? '' : '/SelfService' ) %>/Helpers/CalendarEventInfo?<% QueryString( event => $Object->Type . '-' . $Object->id, SavedSearchId => $SavedSearchId, Format => $Format ) %>"
107-
hx-trigger="mouseover once"
107+
hx-trigger="calendar-hover once"
108108
hx-target="find .calendar-event-detail"
109109
% }
110110
>

share/static/css/elevator/calendar.css

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,21 @@ table.rt-calendar .ticket-entry span.calendar-event-detail {
192192
overflow-wrap: break-word;
193193
}
194194

195-
/* Position popup above when in bottom rows */
196-
table.rt-calendar tbody tr:last-child .ticket-entry span.calendar-event-detail,
197-
table.rt-calendar tbody tr:nth-last-child(2) .ticket-entry span.calendar-event-detail {
195+
/* Position popup above when JS determines there is insufficient space below */
196+
table.rt-calendar .ticket-entry span.calendar-event-detail.popup-above {
198197
top: auto;
199198
bottom: calc(100% - 2px);
200199
margin-top: 0;
201200
margin-bottom: 2px;
202201
}
203202

204-
/* Create a hover bridge to prevent popup from disappearing */
203+
/* Position popup right-aligned when JS determines it would overflow the right edge */
204+
table.rt-calendar .ticket-entry span.calendar-event-detail.popup-right {
205+
left: unset;
206+
right: 0;
207+
}
208+
209+
/* Create a hover bridge to prevent popup from disappearing when moving mouse into it */
205210
table.rt-calendar .ticket-entry span.calendar-event-detail::before {
206211
content: '';
207212
position: absolute;
@@ -213,8 +218,7 @@ table.rt-calendar .ticket-entry span.calendar-event-detail::before {
213218
}
214219

215220
/* Hover bridge for upward-positioned popups */
216-
table.rt-calendar tbody tr:last-child .ticket-entry span.calendar-event-detail::before,
217-
table.rt-calendar tbody tr:nth-last-child(2) .ticket-entry span.calendar-event-detail::before {
221+
table.rt-calendar .ticket-entry span.calendar-event-detail.popup-above::before {
218222
top: auto;
219223
bottom: -6px;
220224
}
@@ -248,16 +252,6 @@ table.rt-calendar .ticket-entry span.calendar-event-detail:hover {
248252
display: block !important;
249253
}
250254

251-
table.rt-calendar td.weekday-7 .ticket-entry:hover span.calendar-event-detail,
252-
table.rt-calendar td.weekday-7 .ticket-entry span.calendar-event-detail:hover,
253-
table.rt-calendar td.weekday-6 .ticket-entry:hover span.calendar-event-detail,
254-
table.rt-calendar td.weekday-6 .ticket-entry span.calendar-event-detail:hover,
255-
table.rt-calendar td.weekday-5 .ticket-entry:hover span.calendar-event-detail,
256-
table.rt-calendar td.weekday-5 .ticket-entry span.calendar-event-detail:hover {
257-
left: unset;
258-
right: 24px;
259-
}
260-
261255
.event-icon {
262256
float: left;
263257
margin-right: 5px;

share/static/js/init.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
document.addEventListener('htmx:afterSwap', function(evt) {
2+
const popup = evt.detail.elt;
3+
if (popup.classList && popup.classList.contains('calendar-event-detail')) {
4+
const entry = popup.closest('.ticket-entry');
5+
if (entry) positionCalendarPopup(entry);
6+
}
7+
});
8+
19
document.addEventListener('htmx:configRequest', function(evt) {
210
for ( const param in evt.detail.parameters ) {
311
if ( evt.detail.parameters[param + 'Type'] === 'text/html' && RT.CKEditor.instances[param] ) {
@@ -873,6 +881,20 @@ document.addEventListener('htmx:load', function(evt) {
873881
}
874882

875883
expandCalendar(elt);
884+
885+
// Delay calendar popup requests so that mousing across the calendar
886+
// does not fire a request for every ticket the cursor passes over.
887+
// Also calculate popup position from viewport bounds rather than
888+
// relying on CSS row/column heuristics.
889+
elt.querySelectorAll('.ticket-entry[hx-trigger]').forEach(function(el) {
890+
el.addEventListener('mouseenter', function() {
891+
positionCalendarPopup(el);
892+
el._calendarHoverTimer = setTimeout(() => htmx.trigger(el, 'calendar-hover'), 200);
893+
});
894+
el.addEventListener('mouseleave', function() {
895+
clearTimeout(el._calendarHoverTimer);
896+
});
897+
});
876898
});
877899

878900
/* Load the owner dropdown when the user clicks the pencil in basics */

share/static/js/util.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,17 @@ function submitInlineEdit(editor, cell) {
17611761
htmx.trigger(editor.get(0), 'submit');
17621762
};
17631763

1764+
function positionCalendarPopup(entry) {
1765+
const popup = entry.querySelector('.calendar-event-detail');
1766+
if (!popup) return;
1767+
1768+
const rect = entry.getBoundingClientRect();
1769+
const popupWidth = 350; // matches CSS width
1770+
1771+
popup.classList.toggle('popup-above', window.innerHeight - rect.bottom < 250);
1772+
popup.classList.toggle('popup-right', window.innerWidth - rect.left < popupWidth);
1773+
}
1774+
17641775
// Override toggle so when user clicks the dropdown button, current value won't be cleared.
17651776
(function () {
17661777
var orig_toggle = jQuery.fn.combobox.Constructor.prototype.toggle;

0 commit comments

Comments
 (0)