mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
adapt stundeplanlib expandObjectInformation when called by getEventsEmployee with an event called extendStundenplanData, which allows extensions like digi anw to plant their own data object inside the stundenplan events in order to conditionally render something like currently in the lehreinheiten calendarEvent.js renderer -> parameterized link to anw extension in order to avoid duplicating functionality across widgets when there is already one doing it very well;
This commit is contained in:
@@ -7,6 +7,7 @@ use \DateTime as DateTime;
|
||||
use \DateTimeZone as DateTimeZone;
|
||||
use \DateInterval as DateInterval;
|
||||
use \DatePeriod as DatePeriod;
|
||||
use CI3_Events as Events;
|
||||
|
||||
class StundenplanLib
|
||||
{
|
||||
@@ -141,7 +142,7 @@ class StundenplanLib
|
||||
return $stundenplan_data;
|
||||
$stundenplan_data = getData($stundenplan_data) ?? [];
|
||||
|
||||
$function_error = $this->expandObjectInformation($stundenplan_data);
|
||||
$function_error = $this->expandObjectInformation($stundenplan_data, true);
|
||||
if ($function_error)
|
||||
return $function_error;
|
||||
|
||||
@@ -286,7 +287,7 @@ class StundenplanLib
|
||||
return success($lektoren);
|
||||
}
|
||||
|
||||
public function expandObjectInformation($data)
|
||||
public function expandObjectInformation($data, $callExtensionsEvent = false)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
@@ -375,6 +376,20 @@ class StundenplanLib
|
||||
$item->lektor = $lektor_obj_array;
|
||||
|
||||
}
|
||||
|
||||
// info retrieved from extensions might not be necessary for some stundenplan use cases so the event
|
||||
// will be gated behind this flag
|
||||
|
||||
if($callExtensionsEvent) {
|
||||
Events::trigger(
|
||||
'extendStundenplanData',
|
||||
function & () use (&$data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function fetchFerienTageEvents($start_date, $end_date, $studiengang_kz)
|
||||
|
||||
@@ -66,6 +66,24 @@ export default {
|
||||
return "d-none d-xl-grid";
|
||||
}
|
||||
},
|
||||
// link into the FHC-Core-Anwesenheiten tool
|
||||
// digi_anw_data is attached per event by the extension's `extendStundenplanData` listener
|
||||
anwLink() {
|
||||
const d = this.event && this.event.digi_anw_data;
|
||||
if (!d || !d.stg_kz || !d.lv_id || !d.sem_kurzbz)
|
||||
return null;
|
||||
const base = FHC_JS_DATA_STORAGE_OBJECT.app_root
|
||||
+ FHC_JS_DATA_STORAGE_OBJECT.ci_router
|
||||
+ '/extensions/FHC-Core-Anwesenheiten/';
|
||||
return base
|
||||
+ `?stg_kz=${encodeURIComponent(d.stg_kz)}`
|
||||
+ `&sem=${encodeURIComponent(d.sem ?? '')}`
|
||||
+ `&lvid=${encodeURIComponent(d.lv_id)}`
|
||||
+ `&sem_kurzbz=${encodeURIComponent(d.sem_kurzbz)}`;
|
||||
},
|
||||
anwLinkTitle() {
|
||||
return this.$p.t('global/digitalesAnwManagement');
|
||||
},
|
||||
},
|
||||
template: /*html*/`
|
||||
<div
|
||||
@@ -96,6 +114,21 @@ export default {
|
||||
... +{{ event.lektor.length - 3 }}
|
||||
</span>
|
||||
</div>
|
||||
<a
|
||||
v-if="anwLink"
|
||||
:href="anwLink"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
class="d-flex align-items-center flex-shrink-0"
|
||||
style="margin-right: 4px"
|
||||
:title="anwLinkTitle"
|
||||
:aria-label="anwLinkTitle"
|
||||
draggable="false"
|
||||
@click.stop
|
||||
@mousedown.stop
|
||||
>
|
||||
<i class="fa fa-arrow-up-right-from-square fs-5" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
`,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user