From 6e78c43056b31a936620cf5ba7cd1af91afc4ae6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 26 Apr 2021 19:27:13 -0400 Subject: [PATCH] Globally reset angular hashPrefix In dev/core#1818 a reset was added to remove the ! character after the # to maintain consistency with previous versions of Angular. It was added to crmApp which yeilded inconsistent results, as crmApp isn't used everywhere. This adds the reset globally. --- Civi/Angular/AngularLoader.php | 1 + Civi/Angular/Page/Modules.php | 6 +++++- ang/crmApp.js | 5 ----- ang/resetLocationProviderHashPrefix.js | 9 +++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 ang/resetLocationProviderHashPrefix.js diff --git a/Civi/Angular/AngularLoader.php b/Civi/Angular/AngularLoader.php index 6ddd90ed09..c887e9d13f 100644 --- a/Civi/Angular/AngularLoader.php +++ b/Civi/Angular/AngularLoader.php @@ -155,6 +155,7 @@ class AngularLoader { $headOffset = 0; $config = \CRM_Core_Config::singleton(); if ($config->debug) { + $res->addScriptFile('civicrm', 'ang/resetLocationProviderHashPrefix.js', 101, $this->getRegion(), FALSE); foreach ($moduleNames as $moduleName) { foreach ($this->angular->getResources($moduleName, 'css', 'cacheUrl') as $url) { $res->addStyleUrl($url, self::DEFAULT_MODULE_WEIGHT + (++$headOffset), $this->getRegion()); diff --git a/Civi/Angular/Page/Modules.php b/Civi/Angular/Page/Modules.php index d7957629ab..83a72da5cc 100644 --- a/Civi/Angular/Page/Modules.php +++ b/Civi/Angular/Page/Modules.php @@ -85,7 +85,11 @@ class Modules extends \CRM_Core_Page { case 'angular-modules.js': $moduleNames = $page->parseModuleNames($event->params['modules'] ?? NULL, $angular); $event->mimeType = 'application/javascript'; - $event->content = $page->digestJs($angular->getResources($moduleNames, 'js', 'path')); + $files = array_merge( + [\Civi::resources()->getPath('civicrm', 'ang/resetLocationProviderHashPrefix.js')], + $angular->getResources($moduleNames, 'js', 'path') + ); + $event->content = $page->digestJs($files); break; case 'angular-modules.css': diff --git a/ang/crmApp.js b/ang/crmApp.js index e3baceb971..388ad98ae0 100644 --- a/ang/crmApp.js +++ b/ang/crmApp.js @@ -4,11 +4,6 @@ // modules should depend on it. var crmApp = angular.module('crmApp', CRM.angular.modules); - // dev/core#1818 use angular 1.5 default of # instead of 1.6+ default of #! - crmApp.config(['$locationProvider', function($locationProvider) { - $locationProvider.hashPrefix(""); - }]); - crmApp.config(['$routeProvider', function($routeProvider) { diff --git a/ang/resetLocationProviderHashPrefix.js b/ang/resetLocationProviderHashPrefix.js new file mode 100644 index 0000000000..eb70026aeb --- /dev/null +++ b/ang/resetLocationProviderHashPrefix.js @@ -0,0 +1,9 @@ +(function(angular, $, _) { + + // dev/core#1818 use angular 1.5 default of # instead of 1.6+ default of #! + angular.module('ng') + .config(['$locationProvider', function($locationProvider) { + $locationProvider.hashPrefix(''); + }]); + +})(angular, CRM.$, CRM._); -- 2.25.1