From 89a1a5c21d32c63fbb75f8bef99f77c2976bd457 Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Tue, 16 Nov 2021 01:53:46 +0100 Subject: [PATCH] Allow to populate the search-fields via request-parameter "search". Signed-off-by: Claus-Justus Heine --- lib/Controller/PageController.php | 2 ++ src/script.js | 19 +++++++++++++++---- templates/content/index.php | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 74aa5fd1e..423643b86 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -55,6 +55,8 @@ public function index(): TemplateResponse { $this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); $params = array('user' => $this->userId); + $searchString = $this->request->getParam('search'); + $params['search'] = $searchString; $this->initialStateService->provideInitialState($this->appName, 'photos', $this->config->getAppValue('photos', 'enabled', 'no') === 'yes'); $response = new TemplateResponse('maps', 'index', $params); diff --git a/src/script.js b/src/script.js index 48dc9c90a..e93d70a19 100644 --- a/src/script.js +++ b/src/script.js @@ -116,11 +116,12 @@ import { brify, getUrlParameter, formatAddress } from './utils'; }); }, - restoreOptions: function () { + restoreOptions: function (afterRestore) { var that = this; var url = generateUrl('/apps/maps/getOptionsValues'); var req = {}; var optionsValues = {}; + afterRestore = afterRestore || function() {}; $.ajax({ type: 'POST', url: url, @@ -366,10 +367,15 @@ import { brify, getUrlParameter, formatAddress } from './utils'; //if (optionsValues.hasOwnProperty('routingEnabled') && optionsValues.routingEnabled === 'true') { // routingController.toggleRouting(); //} + + afterRestore(); + }).fail(function() { OC.Notification.showTemporary( t('maps', 'Failed to restore options values') ); + + afterRestore(); }); } }; @@ -2139,8 +2145,14 @@ import { brify, getUrlParameter, formatAddress } from './utils'; searchController.initController(mapController.map); // once controllers have been set/initialized, we can restore option values from server - optionsController.restoreOptions(); - geoLinkController.showLinkLocation(); + optionsController.restoreOptions(function() { + geoLinkController.showLinkLocation(); + if ($('#search-term').val() !== '') { + mapController.locControl.stop(); + searchController.setSearchAutocomplete(searchController.SEARCH_BAR); + searchController.submitSearchForm(); + } + }); // Popup $(document).on('click', '#opening-hours-header', function() { @@ -2240,4 +2252,3 @@ import { brify, getUrlParameter, formatAddress } from './utils'; }); })(jQuery, OC); - diff --git a/templates/content/index.php b/templates/content/index.php index bb89243ab..9a1c74eca 100644 --- a/templates/content/index.php +++ b/templates/content/index.php @@ -29,7 +29,7 @@ ?>