dev/core#1818 Upgrade AngularJS from 1.5.11 to 1.8
authorColeman Watts <coleman@civicrm.org>
Tue, 29 Sep 2020 15:53:30 +0000 (11:53 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 1 Oct 2020 12:07:22 +0000 (08:07 -0400)
https://lab.civicrm.org/dev/core/-/issues/1818

The biggest breaking change between 1.5 and 1.8 was the default hashPrefix.
See https://github.com/angular/angular.js/blob/master/CHANGELOG.md#location-due-to-1

Our solution is to force crmApp to use the previous default. This ensures that existing modules
which rely on crmApp for routing (which is nearly all of them) will be unaffected.

New modules like Afform which use their own routing should use the new default recommended by Angular.

ang/crmApp.js
composer.json
composer.lock
ext/afform/docs/quickstart.md
ext/afform/gui/ang/afGuiList.aff.html
ext/afform/html/ang/afHtmlEditor.aff.html
ext/afform/html/ang/afHtmlList.aff.html
js/angular-crmResource/all.js

index c7bb81e29bc9ad1a090e9a020b0f4ad189885156..e3baceb971a6618ba84bcea245725811ffdbaba1 100644 (file)
@@ -3,6 +3,12 @@
   // crmApp should not provide any significant services, and no other
   // 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) {
 
index 8d2b9c1e6e30a22fa3d618ef62a00d9fcd353e54..00a283c7e28f6ffa326f459c6e3e8199811a7da2 100644 (file)
         "path": "bower_components/{$id}"
       },
       "angular": {
-        "url": "https://github.com/angular/bower-angular/archive/v1.5.11.zip"
+        "url": "https://github.com/angular/bower-angular/archive/v1.8.0.zip"
       },
       "angular-bootstrap": {
         "url": "https://github.com/angular-ui/bootstrap-bower/archive/2.5.0.zip"
         "url": "https://github.com/totten/angular-jquery-dialog-service/archive/v0.8.0-civicrm-1.0.zip"
       },
       "angular-mocks": {
-        "url": "https://github.com/angular/bower-angular-mocks/archive/v1.5.11.zip"
+        "url": "https://github.com/angular/bower-angular-mocks/archive/v1.8.0.zip"
       },
       "angular-route": {
-        "url": "https://github.com/angular/bower-angular-route/archive/v1.5.11.zip"
+        "url": "https://github.com/angular/bower-angular-route/archive/v1.8.0.zip"
       },
       "angular-sanitize": {
-        "url": "https://github.com/angular/bower-angular-sanitize/archive/v1.5.11.zip"
+        "url": "https://github.com/angular/bower-angular-sanitize/archive/v1.8.0.zip"
       },
       "angular-ui-sortable": {
         "url": "https://github.com/angular-ui/ui-sortable/archive/v0.19.0.zip"
index ba2584e724451ce1972f91dcd43d371aab3ee3a7..14ceae4a827f00088c2d45e19f9fb0951d15b010 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "197ce47c1897c60cbc5ce809f3d5cf14",
+    "content-hash": "1c717ea7ca80e806702967261c621e3a",
     "packages": [
         {
             "name": "adrienrn/php-mimetyper",
index 53000a16d6770dbe2fb152aef875ecb9e43c5244..37917d7724a4d9f4e898e59884649f1d71034e6a 100644 (file)
@@ -31,7 +31,7 @@ from a local Drupal 7 site:
 ```
 $ cv url "civicrm/hello-world"
 "http://dmaster.localhost/civicrm/hello-world"
-$ cv url "civicrm/hello-world/#/?name=world"
+$ cv url "civicrm/hello-world/#!/?name=world"
 "http://dmaster.localhost/civicrm/hello-world/#/?name=world"
 ```
 
index 763ca8547f63f6f2b14078374c242be1aa6e80c3..4fe9b37a137e1c7ee6fec8c803673e83b1c57933 100644 (file)
@@ -1,4 +1,4 @@
-<a href="#/?name=0" class="btn btn-default">
+<a href="#!/?name=0" class="btn btn-default">
   <i class="crm-i fa-plus"></i> {{ ts('New Form') }}
 </a>
 <div
@@ -22,7 +22,7 @@
     <tbody>
     <tr ng-repeat="availForm in listCtrl.result">
       <td>
-        <a ng-href="#/?name={{availForm.name}}">{{availForm.name}}</a>
+        <a ng-href="#!/?name={{availForm.name}}">{{availForm.name}}</a>
       </td>
       <td>{{availForm.title}}</td>
       <td>
index 7d474d44e5a5d08a0adde4f0afa617f6f1cdd4fa..0cbca87fd24174c052d8d3d7decc6cabc3f7cbf5 100644 (file)
@@ -8,7 +8,7 @@
     <div crm-ui-debug="resultForm"></div>
 
     <div>
-      <a ng-href="#/">{{ts('Back')}}</a>
+      <a ng-href="#!/">{{ts('Back')}}</a>
       |
       <a af-api4-action="['Afform', 'update', {layoutFormat: 'html', where: [['name', '=', resultForm.name]], values:resultForm}]">{{ts('Save')}}</a>
       <span ng-if="resultForm.server_route">
index 4f70a552bccb09c92342a4c00ac68b988e2da506..ad66cc579063f9b341c724f08d419f29d50da22a 100644 (file)
@@ -19,7 +19,7 @@
     <tbody>
     <tr ng-repeat="availForm in listCtrl.result">
       <td>
-        <a ng-href="#/?name={{availForm.name}}">{{availForm.name}}</a>
+        <a ng-href="#!/?name={{availForm.name}}">{{availForm.name}}</a>
       </td>
       <td>{{availForm.title}}</td>
       <td>
index e8eca721b59a5eab9a25ad4323737d9e7e9fc97d..356a582407b997921f773ae65f5dab5fda9b8574 100644 (file)
@@ -34,9 +34,9 @@
 
     var moduleUrl = CRM.angular.bundleUrl;
     $http.get(moduleUrl)
-      .success(function httpSuccess(data) {
+      .then(function httpSuccess(response) {
         templates = [];
-        angular.forEach(data, function(module) {
+        angular.forEach(response.data, function(module) {
           if (module.partials) {
             angular.extend(templates, module.partials);
           }
@@ -45,8 +45,7 @@
           }
         });
         notify();
-      })
-      .error(function httpError() {
+      }, function httpError() {
         templates = [];
         notify();
       });