Skip to content

Commit

Permalink
Merge pull request #22233 from colemanw/apiExplorerArgs
Browse files Browse the repository at this point in the history
APIv4 Explorer - Make selected language and format bookmarkable
  • Loading branch information
colemanw authored Dec 18, 2021
2 parents 9e625ea + cf3608d commit a0f4473
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ang/api4Explorer/Explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -75,7 +75,6 @@
{name: 'pipe', label: ts('CV (pipe)'), code: ''}
]
};
this.resultFormat = 'json';
this.resultFormats = [
{
name: 'json',
Expand All @@ -91,11 +90,22 @@
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);
Expand Down Expand Up @@ -879,6 +889,9 @@
};

ctrl.formatResult = function() {
if (!response) {
return;
}
$scope.result = [formatMeta(response.meta)];
switch (ctrl.resultFormat) {
case 'json':
Expand Down

0 comments on commit a0f4473

Please sign in to comment.