From 447b689703320bf998a9ec7a8303587dee2347a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Gajda?= Date: Mon, 5 Feb 2024 11:26:28 +0100 Subject: [PATCH 1/2] Inject NovaRequest to controller method instead of constructor to make compatibility with Laravel Octane --- src/Http/Controllers/CalendarController.php | 35 +++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/Http/Controllers/CalendarController.php b/src/Http/Controllers/CalendarController.php index 9bcf6c9..195deb2 100644 --- a/src/Http/Controllers/CalendarController.php +++ b/src/Http/Controllers/CalendarController.php @@ -2,13 +2,13 @@ /* * © Copyright 2022 · Willem Vervuurt, Studio Delfuego - * + * * You can modify, use and distribute this package under one of two licenses: * 1. GNU AGPLv3 - * 2. A perpetual, non-revocable and 100% free (as in beer) do-what-you-want + * 2. A perpetual, non-revocable and 100% free (as in beer) do-what-you-want * license that allows both non-commercial and commercial use, under conditions. * See LICENSE.md for details. - * + * * (it boils down to: do what you want as long as you're building and/or * using calendar views, but don't embed this package or a modified version * of it in free or paid-for software libraries and packages aimed at developers). @@ -28,18 +28,15 @@ class CalendarController extends BaseController { // Must match the hard-coded value in Tool.vue's reload() method const API_PATH_PREFIX = '/nova-vendor/wdelfuego/nova-calendar/'; - - private $request; + private $dataProviders = []; public function __construct(NovaRequest $request) { - $this->request = $request; - // Load data providers, keyed by uri foreach(config('nova-calendar', []) as $calendarKey => $calendarConfig) { - // We are assuming these keys to exist since the Nova Tool + // We are assuming these keys to exist since the Nova Tool // Wdelfuego\NovaCalendar\NovaCalendar does all sorts of checks on initiation // Not sure if that assumption is completely valid but assuming valid config for now $dataProvider = new ($calendarConfig['dataProvider']); @@ -54,33 +51,31 @@ protected function getCalendarDataProviderForUri(string $calendarUri) { throw new \Exception("Unknown calendar uri: $calendarUri"); } - + return $this->dataProviders[$calendarUri]; } - - public function getCalendarData(string $view = 'month') + + public function getCalendarData(NovaRequest $request, string $view = 'month') { - $requestUri = substr($this->request->url(), strlen($this->request->schemeAndHttpHost())); + $requestUri = substr($request->url(), strlen($request->schemeAndHttpHost())); // Get calendar URI from full request URI by ditching the prefix and the last path element (view) $calendarUri = substr($requestUri, strlen(self::API_PATH_PREFIX)); $calendarUri = substr($calendarUri, 0, strrpos($calendarUri, '/')); - $dataProvider = $this->getCalendarDataProviderForUri($calendarUri)->withRequest($this->request); - if($this->request->query('isInitRequest')) + $dataProvider = $this->getCalendarDataProviderForUri($calendarUri)->withRequest($request); + if($request->query('isInitRequest')) { $dataProvider->setActiveFilterKey($dataProvider->defaultFilterKey()); } else { - $dataProvider->setActiveFilterKey($this->request->query('filter')); + $dataProvider->setActiveFilterKey($request->query('filter')); } - + $view = View::get($view); - $view->initFromRequest($this->request); + $view->initFromRequest($request); $view = $dataProvider->customizeView($view); - return $view->calendarData($this->request, $dataProvider); + return $view->calendarData($request, $dataProvider); } - - } From 47a6b726612a649b3a5b3913d356bf2b9780d380 Mon Sep 17 00:00:00 2001 From: Willem Vervuurt Date: Mon, 26 Feb 2024 20:27:42 +0100 Subject: [PATCH 2/2] Sets z-index of events to 0 to fix #68 --- dist/css/tool.css | 2 +- resources/css/tool.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/css/tool.css b/dist/css/tool.css index cb85d1b..8912777 100644 --- a/dist/css/tool.css +++ b/dist/css/tool.css @@ -1 +1 @@ -:root{--nc-transparent:hsla(0,0%,100%,0);--nc-highlight-bg:rgba(var(--colors-primary-500),0.02);--nc-highlight-border:rgba(var(--colors-primary-500),0.4);--nc-weekend-border:rgba(var(--colors-gray-500),0.2);--nc-weekend-bg:rgba(var(--colors-gray-900),0);--nc-event-height-multi-day:2.2em;--nc-event-border:hsla(0,0%,4%,.3);--nc-event-border-radius:7px}.nova-calendar.noselect{-webkit-touch-callout:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.noscrollbar::-webkit-scrollbar{display:none}.noscrollbar{-ms-overflow-style:none;scrollbar-width:none}#nc-control{border:0 solid #555;display:flex;height:3em;justify-content:space-between;margin-bottom:1rem;position:relative}#nc-control .center-items,#nc-control .left-items,#nc-control .right-items{align-items:center;display:flex;gap:8px;justify-content:center}#nc-control a.disabled{opacity:.2;pointer-events:none}#nc-control>a,#nc-control>h1{display:block;left:0;margin-left:auto;margin-right:auto;position:absolute;right:0;text-align:center}#nc-control h1 span{cursor:pointer;margin-left:1rem}#nc-control a.button{border:1px solid rgba(var(--colors-gray-500),.2);border-radius:6px;padding:.5rem}div.nova-calendar{width:100%}div.nova-calendar div.nc-header{display:grid;grid-template-columns:repeat(7,1fr);width:100%}div.nova-calendar div.nc-header div{font-weight:700;padding:.6em .6em .5em;text-align:left;word-break:break-all}div.nova-calendar .week{display:grid;grid-template-columns:repeat(7,1fr);width:100%}div.nova-calendar .nc-col-1{grid-column:1/2}div.nova-calendar .nc-col-2{grid-column:2/3}div.nova-calendar .nc-col-3{grid-column:3/4}div.nova-calendar .nc-col-4{grid-column:4/5}div.nova-calendar .nc-col-5{grid-column:5/6}div.nova-calendar .nc-col-6{grid-column:6/7}div.nova-calendar .nc-col-7{grid-column:7/-1}div.nova-calendar .nc-event.multi.span-1{grid-column-end:span 1}div.nova-calendar .nc-event.multi.span-2{grid-column-end:span 2}div.nova-calendar .nc-event.multi.span-3{grid-column-end:span 3}div.nova-calendar .nc-event.multi.span-4{grid-column-end:span 4}div.nova-calendar .nc-event.multi.span-5{grid-column-end:span 5}div.nova-calendar .nc-event.multi.span-6{grid-column-end:span 6}div.nova-calendar .nc-event.multi.span-7{grid-column-end:span 7}div.nova-calendar .day{border-color:rgba(var(--colors-gray-500),.15);border-width:.5px;grid-row:1/-1;min-height:9em;z-index:0}div.nova-calendar .day:not(.withinRange){background:repeating-linear-gradient(-45deg,rgba(225,225,255,.1),rgba(225,225,255,.1) 4px,hsla(0,0%,39%,.1) 0,hsla(0,0%,39%,.1) 6px);opacity:.5}div.nova-calendar .dayheader{padding:.4em;z-index:1}div.nova-calendar .day .dayheader .daylabel{font-size:9pt;opacity:.84}div.nova-calendar .day.today .dayheader .daylabel{background-color:rgba(var(--colors-primary-500),.2);border-radius:100%;font-size:10pt;font-weight:700;opacity:1;padding:.2em .5em}div.nova-calendar .dayheader .badges{float:right;max-width:80%}div.nova-calendar .dayheader span.badge{font-size:10pt;line-height:12pt;min-width:22px;opacity:.8;padding:.25em;text-align:center}div.nova-calendar .week-events{display:grid;grid-auto-flow:column dense;grid-column:1/-1;grid-row:1;grid-template-columns:repeat(7,1fr);margin-top:2.2em;z-index:2}div.nova-calendar .single-day-events{border:0 solid red;grid-row-start:span 9000;margin-bottom:1em;min-height:2px}div.nova-calendar .nc-event{align-items:center;border-bottom:1px solid var(--nc-event-border);display:grid;font-size:10pt;grid-template-columns:1fr auto;grid-template-rows:auto auto;margin:.1em;min-height:var(--nc-event-height-multi-day);opacity:.92;overflow:hidden;padding:.2em;text-align:left;transition:opacity .25s}div.nova-calendar .nc-event:not(.withinRange){opacity:.6}div.nova-calendar .nc-event:hover{opacity:1}div.nova-calendar .nc-event.starts{border-bottom-left-radius:var(--nc-event-border-radius);border-top-left-radius:var(--nc-event-border-radius)}div.nova-calendar .nc-event.ends{border-bottom-right-radius:var(--nc-event-border-radius);border-top-right-radius:var(--nc-event-border-radius)}div.nova-calendar div.nc-event.clickable{cursor:pointer}div.nova-calendar div.nc-event div.name{border:0 dashed #fff;font-weight:700;grid-column:1/2;grid-row:1/2;margin-left:.2em;margin-right:.2em;overflow:scroll;white-space:nowrap}div.nova-calendar div.nc-event:not(.starts) div.name{font-size:9pt;font-weight:400;opacity:.8;padding-top:.1em}div.nova-calendar div.nc-event div.badges{border:0 solid #0f0;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;grid-column:2/-1;grid-row:1/2;text-align:right}div.nova-calendar div.nc-event div.badges span.badge-bg{background-color:rgba(50,50,64,.5);border-bottom:1px solid rgba(var(--colors-primary-500),.5);border-radius:4px;display:inline-block;margin-left:.5px;margin-right:.5px}div.nova-calendar div.nc-event div.badges span.badge{font-size:9pt;line-height:12pt;min-width:22px;opacity:1;padding:.25em;text-align:center}div.nova-calendar .nc-event div.content{border:0 dashed red;grid-column:1/span 2;grid-row:2/3;overflow:scroll;padding-left:.2em}div.nova-calendar div.nc-event span.time{display:inline-block;font-size:9pt;margin-right:.2em;opacity:.8}div.nova-calendar div.nc-event span.notes{font-size:9pt;line-height:10pt}div.nova-calendar .nc-event.multi{align-items:top;grid-template-columns:auto 1fr auto;grid-template-rows:auto;max-height:var(--nc-event-height-multi-day);overflow:hidden}div.nova-calendar .nc-event:not(.starts){border-left:1px dashed hsla(0,0%,89%,.6);opacity:.8}div.nova-calendar .nc-event:not(.ends){border-right:1px dashed hsla(0,0%,89%,.6)}div.nova-calendar div.nc-event.multi div.name{grid-column:1/2;grid-row:1/-1;overflow:scroll;white-space:nowrap}div.nova-calendar div.nc-event.multi div.badges{grid-column:3/-1;grid-row:1/-1;overflow:scroll;white-space:nowrap}div.nova-calendar div.nc-event.multi div.content{grid-column:2/3;grid-row:1/-1;overflow:scroll;white-space:nowrap} +:root{--nc-transparent:hsla(0,0%,100%,0);--nc-highlight-bg:rgba(var(--colors-primary-500),0.02);--nc-highlight-border:rgba(var(--colors-primary-500),0.4);--nc-weekend-border:rgba(var(--colors-gray-500),0.2);--nc-weekend-bg:rgba(var(--colors-gray-900),0);--nc-event-height-multi-day:2.2em;--nc-event-border:hsla(0,0%,4%,.3);--nc-event-border-radius:7px}.nova-calendar.noselect{-webkit-touch-callout:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.noscrollbar::-webkit-scrollbar{display:none}.noscrollbar{-ms-overflow-style:none;scrollbar-width:none}#nc-control{border:0 solid #555;display:flex;height:3em;justify-content:space-between;margin-bottom:1rem;position:relative}#nc-control .center-items,#nc-control .left-items,#nc-control .right-items{align-items:center;display:flex;gap:8px;justify-content:center}#nc-control a.disabled{opacity:.2;pointer-events:none}#nc-control>a,#nc-control>h1{display:block;left:0;margin-left:auto;margin-right:auto;position:absolute;right:0;text-align:center}#nc-control h1 span{cursor:pointer;margin-left:1rem}#nc-control a.button{border:1px solid rgba(var(--colors-gray-500),.2);border-radius:6px;padding:.5rem}div.nova-calendar{width:100%}div.nova-calendar div.nc-header{display:grid;grid-template-columns:repeat(7,1fr);width:100%}div.nova-calendar div.nc-header div{font-weight:700;padding:.6em .6em .5em;text-align:left;word-break:break-all}div.nova-calendar .week{display:grid;grid-template-columns:repeat(7,1fr);width:100%}div.nova-calendar .nc-col-1{grid-column:1/2}div.nova-calendar .nc-col-2{grid-column:2/3}div.nova-calendar .nc-col-3{grid-column:3/4}div.nova-calendar .nc-col-4{grid-column:4/5}div.nova-calendar .nc-col-5{grid-column:5/6}div.nova-calendar .nc-col-6{grid-column:6/7}div.nova-calendar .nc-col-7{grid-column:7/-1}div.nova-calendar .nc-event.multi.span-1{grid-column-end:span 1}div.nova-calendar .nc-event.multi.span-2{grid-column-end:span 2}div.nova-calendar .nc-event.multi.span-3{grid-column-end:span 3}div.nova-calendar .nc-event.multi.span-4{grid-column-end:span 4}div.nova-calendar .nc-event.multi.span-5{grid-column-end:span 5}div.nova-calendar .nc-event.multi.span-6{grid-column-end:span 6}div.nova-calendar .nc-event.multi.span-7{grid-column-end:span 7}div.nova-calendar .day{border-color:rgba(var(--colors-gray-500),.15);border-width:.5px;grid-row:1/-1;min-height:9em;z-index:0}div.nova-calendar .day:not(.withinRange){background:repeating-linear-gradient(-45deg,rgba(225,225,255,.1),rgba(225,225,255,.1) 4px,hsla(0,0%,39%,.1) 0,hsla(0,0%,39%,.1) 6px);opacity:.5}div.nova-calendar .dayheader{padding:.4em;z-index:1}div.nova-calendar .day .dayheader .daylabel{font-size:9pt;opacity:.84}div.nova-calendar .day.today .dayheader .daylabel{background-color:rgba(var(--colors-primary-500),.2);border-radius:100%;font-size:10pt;font-weight:700;opacity:1;padding:.2em .5em}div.nova-calendar .dayheader .badges{float:right;max-width:80%}div.nova-calendar .dayheader span.badge{font-size:10pt;line-height:12pt;min-width:22px;opacity:.8;padding:.25em;text-align:center}div.nova-calendar .week-events{display:grid;grid-auto-flow:column dense;grid-column:1/-1;grid-row:1;grid-template-columns:repeat(7,1fr);margin-top:2.2em;z-index:0}div.nova-calendar .single-day-events{border:0 solid red;grid-row-start:span 9000;margin-bottom:1em;min-height:2px}div.nova-calendar .nc-event{align-items:center;border-bottom:1px solid var(--nc-event-border);display:grid;font-size:10pt;grid-template-columns:1fr auto;grid-template-rows:auto auto;margin:.1em;min-height:var(--nc-event-height-multi-day);opacity:.92;overflow:hidden;padding:.2em;text-align:left;transition:opacity .25s}div.nova-calendar .nc-event:not(.withinRange){opacity:.6}div.nova-calendar .nc-event:hover{opacity:1}div.nova-calendar .nc-event.starts{border-bottom-left-radius:var(--nc-event-border-radius);border-top-left-radius:var(--nc-event-border-radius)}div.nova-calendar .nc-event.ends{border-bottom-right-radius:var(--nc-event-border-radius);border-top-right-radius:var(--nc-event-border-radius)}div.nova-calendar div.nc-event.clickable{cursor:pointer}div.nova-calendar div.nc-event div.name{border:0 dashed #fff;font-weight:700;grid-column:1/2;grid-row:1/2;margin-left:.2em;margin-right:.2em;overflow:scroll;white-space:nowrap}div.nova-calendar div.nc-event:not(.starts) div.name{font-size:9pt;font-weight:400;opacity:.8;padding-top:.1em}div.nova-calendar div.nc-event div.badges{border:0 solid #0f0;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;grid-column:2/-1;grid-row:1/2;text-align:right}div.nova-calendar div.nc-event div.badges span.badge-bg{background-color:rgba(50,50,64,.5);border-bottom:1px solid rgba(var(--colors-primary-500),.5);border-radius:4px;display:inline-block;margin-left:.5px;margin-right:.5px}div.nova-calendar div.nc-event div.badges span.badge{font-size:9pt;line-height:12pt;min-width:22px;opacity:1;padding:.25em;text-align:center}div.nova-calendar .nc-event div.content{border:0 dashed red;grid-column:1/span 2;grid-row:2/3;overflow:scroll;padding-left:.2em}div.nova-calendar div.nc-event span.time{display:inline-block;font-size:9pt;margin-right:.2em;opacity:.8}div.nova-calendar div.nc-event span.notes{font-size:9pt;line-height:10pt}div.nova-calendar .nc-event.multi{align-items:top;grid-template-columns:auto 1fr auto;grid-template-rows:auto;max-height:var(--nc-event-height-multi-day);overflow:hidden}div.nova-calendar .nc-event:not(.starts){border-left:1px dashed hsla(0,0%,89%,.6);opacity:.8}div.nova-calendar .nc-event:not(.ends){border-right:1px dashed hsla(0,0%,89%,.6)}div.nova-calendar div.nc-event.multi div.name{grid-column:1/2;grid-row:1/-1;overflow:scroll;white-space:nowrap}div.nova-calendar div.nc-event.multi div.badges{grid-column:3/-1;grid-row:1/-1;overflow:scroll;white-space:nowrap}div.nova-calendar div.nc-event.multi div.content{grid-column:2/3;grid-row:1/-1;overflow:scroll;white-space:nowrap} diff --git a/resources/css/tool.css b/resources/css/tool.css index 0ab680b..11f0c6a 100644 --- a/resources/css/tool.css +++ b/resources/css/tool.css @@ -214,7 +214,7 @@ div.nova-calendar .dayheader span.badge { */ div.nova-calendar .week-events { - z-index: 2; + z-index: 0; margin-top: 2.2em; grid-column: 1 / -1; grid-row: 1;