diff --git a/application/WarehouseShippingNote/WarehouseShippingNoteController.php b/application/WarehouseShippingNote/WarehouseShippingNoteController.php index 7936fc276..160dc9691 100644 --- a/application/WarehouseShippingNote/WarehouseShippingNoteController.php +++ b/application/WarehouseShippingNote/WarehouseShippingNoteController.php @@ -30,6 +30,7 @@ class WarehouseShippingNoteController extends TTCrud { protected array $defaultOrder = ['key' => 'create', 'order' => 'DESC']; protected array $additionalJSVariables = ['WAREHOUSE_ADMIN' => true]; + protected array $additionalHead = ['']; protected array $infoMessages = ['create' => 'Lieferschein wurde erstellt.', 'update' => 'Lieferschein wurde aktualisiert', @@ -593,4 +594,31 @@ class WarehouseShippingNoteController extends TTCrud { $logs = WarehouseLogModel::getAll(['table' => 'WarehouseShippingNote','rowId' => $shippingNoteId], null, 0, ['order' => 'DESC', 'key' => 'create']); self::returnJson($logs); } + + protected function swAction() { + $javascript = "self.addEventListener('install', event => { + console.log('Patching PWA Service Worker: Installing...'); +}); + +self.addEventListener('activate', event => { + console.log('Patching PWA Service Worker: Activating...'); +}); + +self.addEventListener('fetch', event => { + event.respondWith(fetch(event.request)); +}); + +console.log('Patching PWA Service Worker: Script loaded.');"; + + header("Content-Type: application/javascript"); + header("Service-Worker-Allowed: /"); + header("Cache-Control: no-cache"); + header("Pragma: no-cache"); + header("Expires: 0"); + + echo $javascript; + exit; + + } + } diff --git a/lib/TTCrud/TTCrud.php b/lib/TTCrud/TTCrud.php index e4fa5144f..928d8f3b0 100644 --- a/lib/TTCrud/TTCrud.php +++ b/lib/TTCrud/TTCrud.php @@ -8,6 +8,7 @@ * @property array $columns * @property array $additionalActions * @property array $additionalJSVariables + * @property array $additionalHead * @property array $infoMessages * @property bool $onlyView * @property array $defaultOrder @@ -80,6 +81,7 @@ class TTCrud extends mfBaseController { ]; if (!empty($this->additionalJSVariables) && is_array($this->additionalJSVariables)) $JS_VARIABLES = array_merge($JS_VARIABLES, $this->additionalJSVariables); + if (!empty($this->additionalHead) && is_array($this->additionalHead)) $this->layout()->set('additionalHead', $this->additionalHead); Helper::renderVue($this, $pageName, $this->headerTitle, $JS_VARIABLES); } diff --git a/public/assets/pwa/shipping-note-manifest.json b/public/assets/pwa/shipping-note-manifest.json new file mode 100644 index 000000000..650fe3b25 --- /dev/null +++ b/public/assets/pwa/shipping-note-manifest.json @@ -0,0 +1,22 @@ +{ + "name": "thetool Lieferscheine", + "short_name": "Lieferscheine", + "description": "Lieferscheine für thetool.", + "start_url": "/WarehouseShippingNote/", + "scope": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "/assets/images/pwa-thetool-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/assets/images/pwa-thetool-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} \ No newline at end of file diff --git a/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js b/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js index 8b6ff886b..919ad5e90 100644 --- a/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js +++ b/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js @@ -460,3 +460,15 @@ Vue.component('warehouse-shipping-note', { }, } }) + +window.addEventListener('DOMContentLoaded', () => { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/WarehouseShippingNote/sw', { scope: '/' }) + .then(registration => { + console.log('Patching PWA Service Worker registered with scope:', registration.scope); + }) + .catch(error => { + console.error('Patching PWA Service Worker registration failed:', error); + }); + } +}) \ No newline at end of file