APIv4 Explorer - Make selected language and format bookmarkable with url args
authorColeman Watts <coleman@civicrm.org>
Thu, 9 Dec 2021 16:32:36 +0000 (11:32 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 9 Dec 2021 16:32:36 +0000 (11:32 -0500)
Prefix non-param args with an underscore to avoid conflicts with param names

ang/api4Explorer/Explorer.js

index 991bc2f6f293de42dddb67badf0aa65d5a589c89..fc52999c568c6c6613e1dac4c1d78211bfbeaf12 100644 (file)
@@ -33,7 +33,7 @@
     $scope.availableParams = {};
     params = $scope.params = {};
     $scope.index = '';
-    $scope.selectedTab = {result: 'result', code: 'php'};
+    $scope.selectedTab = {result: 'result'};
     $scope.perm = {
       accessDebugOutput: CRM.checkPerm('access debug output'),
       editGroups: CRM.checkPerm('edit groups')
@@ -75,7 +75,6 @@
         {name: 'pipe', label: ts('CV (pipe)'), code: ''}
       ]
     };
-    this.resultFormat = 'json';
     this.resultFormats = [
       {
         name: 'json',
       formatForSelect2(schema, entities, 'name', ['description', 'icon']);
     }
 
+    // Prefix other url args with an underscore to avoid conflicts with param names
     $scope.$bindToRoute({
       expr: 'index',
-      param: 'index',
+      param: '_index',
       default: ''
     });
+    $scope.$bindToRoute({
+      expr: 'selectedTab.code',
+      param: '_lang',
+      default: 'php'
+    });
+    $scope.$bindToRoute({
+      expr: '$ctrl.resultFormat',
+      param: '_format',
+      default: 'json'
+    });
 
     function ucfirst(str) {
       return str[0].toUpperCase() + str.slice(1);
     };
 
     ctrl.formatResult = function() {
+      if (!response) {
+        return;
+      }
       $scope.result = [formatMeta(response.meta)];
       switch (ctrl.resultFormat) {
         case 'json':