Skip to content

Commit

Permalink
Merge pull request #461 from mulesoft/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
agustinlg authored May 30, 2017
2 parents 21196a5 + 96ff07e commit 93f0480
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
24 changes: 18 additions & 6 deletions dist/scripts/api-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
return {
restrict: 'E',
templateUrl: 'directives/documentation.tpl.html',
controller: ['$scope', function($scope) {
controller: ['$scope', 'idGenerator', function($scope, idGenerator) {
$scope.markedOptions = RAML.Settings.marked;

$scope.$watch('securitySchemes', function() {
Expand Down Expand Up @@ -393,7 +393,7 @@
};

$scope.getBodyId = function (bodyType) {
return jQuery.trim(bodyType.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
return idGenerator(bodyType.toString());
};

$scope.bodySelected = function (value) {
Expand Down Expand Up @@ -1660,6 +1660,18 @@
.directive('resourcePanel', RAML.Directives.resourcePanel);
})();

(function () {
'use strict';

angular.module('RAML.Directives')
.factory('idGenerator', [function idGenerator() {
return function(value) {
var id = jQuery.trim(value.replace(/\W/g, ' ')).replace(/\s+/g, '_');
return id === '' ? '-' : id;
};
}]);
})();

(function () {
'use strict';

Expand Down Expand Up @@ -1699,9 +1711,9 @@
'use strict';

angular.module('RAML.Directives')
.factory('resourceId', [function resourceId() {
.factory('resourceId', ['idGenerator', function resourceId(idGenerator) {
return function(resource) {
return jQuery.trim(resource.pathSegments.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
return idGenerator(resource.pathSegments.toString());
};
}]);
})();
Expand Down Expand Up @@ -2132,7 +2144,7 @@
restrict: 'E',
templateUrl: 'directives/root-documentation.tpl.html',
replace: true,
controller: ['$scope', '$timeout', function($scope, $timeout) {
controller: ['$scope', '$timeout', 'idGenerator', function($scope, $timeout, idGenerator) {
$scope.markedOptions = RAML.Settings.marked;
$scope.selectedSection = 'all';

Expand All @@ -2145,7 +2157,7 @@
};

$scope.generateDocId = function (path) {
return jQuery.trim(path.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_').toLowerCase();
return idGenerator(path.toString());
};

$scope.toggleSection = function ($event, key, section) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/directives/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return {
restrict: 'E',
templateUrl: 'directives/documentation.tpl.html',
controller: ['$scope', function($scope) {
controller: ['$scope', 'idGenerator', function($scope, idGenerator) {
$scope.markedOptions = RAML.Settings.marked;

$scope.$watch('securitySchemes', function() {
Expand Down Expand Up @@ -245,7 +245,7 @@
};

$scope.getBodyId = function (bodyType) {
return jQuery.trim(bodyType.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
return idGenerator(bodyType.toString());
};

$scope.bodySelected = function (value) {
Expand Down
11 changes: 11 additions & 0 deletions src/app/directives/resource-tree/id-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(function () {
'use strict';

angular.module('RAML.Directives')
.factory('idGenerator', [function idGenerator() {
return function(value) {
var id = jQuery.trim(value.replace(/\W/g, ' ')).replace(/\s+/g, '_');
return id === '' ? '-' : id;
};
}]);
})();
4 changes: 2 additions & 2 deletions src/app/directives/resource-tree/resource-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
'use strict';

angular.module('RAML.Directives')
.factory('resourceId', [function resourceId() {
.factory('resourceId', ['idGenerator', function resourceId(idGenerator) {
return function(resource) {
return jQuery.trim(resource.pathSegments.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_');
return idGenerator(resource.pathSegments.toString());
};
}]);
})();
4 changes: 2 additions & 2 deletions src/app/directives/root-documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
restrict: 'E',
templateUrl: 'directives/root-documentation.tpl.html',
replace: true,
controller: ['$scope', '$timeout', function($scope, $timeout) {
controller: ['$scope', '$timeout', 'idGenerator', function($scope, $timeout, idGenerator) {
$scope.markedOptions = RAML.Settings.marked;
$scope.selectedSection = 'all';

Expand All @@ -19,7 +19,7 @@
};

$scope.generateDocId = function (path) {
return jQuery.trim(path.toString().replace(/\W/g, ' ')).replace(/\s+/g, '_').toLowerCase();
return idGenerator(path.toString());
};

$scope.toggleSection = function ($event, key, section) {
Expand Down

0 comments on commit 93f0480

Please sign in to comment.