105105
106106 $inactiveElements . removeClass ( 'raml-console-is-active' ) ;
107107 $scope . showPanel = false ;
108+ $scope . traits = null ;
108109 } ;
109110 }
110111 } ;
387388
388389 $scope . readTraits = function ( traits ) {
389390 var list = [ ] ;
391+ var traitList = traits || [ ] ;
390392
391- if ( traits ) {
392- traits . map ( function ( trait ) {
393- if ( typeof trait === 'string' ) {
394- list . push ( trait ) ;
395- } else if ( typeof trait === 'object' ) {
396- list . push ( Object . keys ( trait ) . join ( ', ' ) ) ;
397- }
398- } ) ;
399- }
393+ traitList = traitList . concat ( $scope . resource . traits ) ;
394+
395+ traitList . map ( function ( trait ) {
396+ if ( typeof trait === 'object' ) {
397+ trait = Object . keys ( trait ) . join ( ', ' ) ;
398+ }
399+
400+ if ( list . indexOf ( trait ) === - 1 ) {
401+ list . push ( trait ) ;
402+ }
403+ } ) ;
400404
401405 return list . join ( ', ' ) ;
402406 } ;
491495 } else if ( jQuery ( $this ) . hasClass ( 'raml-console-is-active' ) ) {
492496 $scope . showPanel = false ;
493497 $inactiveElements . removeClass ( 'raml-console-is-active' ) ;
498+ $scope . traits = null ;
494499 } else {
495500 jQuery ( $this ) . addClass ( 'raml-console-is-active' ) ;
496501 jQuery ( $this ) . siblings ( '.raml-console-tab' ) . removeClass ( 'raml-console-is-active' ) ;
502+ $scope . traits = null ;
497503 }
498504 } ;
499505 }
16571663 ramlParserWrapper . load ( $scope . src ) ;
16581664 }
16591665
1666+ $scope . readTraits = function getTraits ( traits ) {
1667+ var list = [ ] ;
1668+
1669+ if ( traits ) {
1670+ traits . map ( function ( trait ) {
1671+ if ( typeof trait === 'object' ) {
1672+ list . push ( Object . keys ( trait ) . join ( ', ' ) ) ;
1673+ } else {
1674+ list . push ( trait ) ;
1675+ }
1676+ } ) ;
1677+ }
1678+
1679+ return list . join ( ', ' ) ;
1680+ } ;
1681+
16601682 $scope . updateProxyConfig = function ( status ) {
16611683 $window . RAML . Settings . disableProxy = status ;
16621684 } ;
@@ -5642,7 +5664,9 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
56425664 " </h2>\n" +
56435665 "\n" +
56445666 " <resource-type></resource-type>\n" +
5645- " <span ng-if=\"methodInfo.is\" class=\"raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait\"><b>Trait:</b> {{traits}}</span>\n" +
5667+ " <span ng-if=\"traits\" class=\"raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait\"><b>Traits:</b> {{traits}}</span>\n" +
5668+ "\n" +
5669+ " <span ng-hide=\"traits\" ng-if=\"resource.traits\" class=\"raml-console-flag raml-console-resource-heading-flag\"><b>Traits:</b> {{readTraits(resource.traits)}}</span>\n" +
56465670 "\n" +
56475671 " </div>\n" +
56485672 " <method-list></method-list>\n" +
@@ -5669,7 +5693,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
56695693 " </h3>\n" +
56705694 "\n" +
56715695 " <resource-type></resource-type>\n" +
5672- " <span ng-if=\"methodInfo.is \" class=\"raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait\"><b>Trait :</b> {{traits}}</span>\n" +
5696+ " <span ng-if=\"traits \" class=\"raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait\"><b>Traits :</b> {{traits}}</span>\n" +
56735697 " </div>\n" +
56745698 "\n" +
56755699 " <method-list></method-list>\n" +
0 commit comments