Skip to content

Commit 0117cdf

Browse files
committed
Fix traits at resource level
1 parent 4a66ad4 commit 0117cdf

File tree

10 files changed

+75
-27
lines changed

10 files changed

+75
-27
lines changed

dist/examples/github.raml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ securitySchemes:
4343
- "delete_repo"
4444
- "notifications"
4545
- "gist"
46-
securedBy: [ oauth_2_0, basic ]
46+
securedBy: [ null, oauth_2_0, basic ]
4747
mediaType: application/json
4848
resourceTypes:
4949
- base:

dist/scripts/api-console.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105

106106
$inactiveElements.removeClass('raml-console-is-active');
107107
$scope.showPanel = false;
108+
$scope.traits = null;
108109
};
109110
}
110111
};
@@ -387,16 +388,19 @@
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
};
@@ -491,9 +495,11 @@
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
}
@@ -1657,6 +1663,22 @@
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" +

dist/styles/api-console-dark-theme.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ th {
16991699
}
17001700

17011701
.raml-console-tab.raml-console-is-active {
1702-
z-index: 1;
1702+
z-index: 5;
17031703
color: #fff;
17041704
}
17051705

dist/styles/api-console-light-theme.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ th {
16991699
}
17001700

17011701
.raml-console-tab.raml-console-is-active {
1702-
z-index: 1;
1702+
z-index: 5;
17031703
color: #333;
17041704
}
17051705

src/app/directives/close-button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
$inactiveElements.removeClass('raml-console-is-active');
1515
$scope.showPanel = false;
16+
$scope.traits = null;
1617
};
1718
}
1819
};

src/app/directives/method-list.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,19 @@
5959

6060
$scope.readTraits = function (traits) {
6161
var list = [];
62+
var traitList = traits || [];
6263

63-
if (traits) {
64-
traits.map(function (trait) {
65-
if (typeof trait === 'string') {
66-
list.push(trait);
67-
} else if (typeof trait === 'object') {
68-
list.push(Object.keys(trait).join(', '));
69-
}
70-
});
71-
}
64+
traitList = traitList.concat($scope.resource.traits);
65+
66+
traitList.map(function (trait) {
67+
if (typeof trait === 'object') {
68+
trait = Object.keys(trait).join(', ');
69+
}
70+
71+
if (list.indexOf(trait) === -1) {
72+
list.push(trait);
73+
}
74+
});
7275

7376
return list.join(', ');
7477
};
@@ -163,9 +166,11 @@
163166
} else if (jQuery($this).hasClass('raml-console-is-active')) {
164167
$scope.showPanel = false;
165168
$inactiveElements.removeClass('raml-console-is-active');
169+
$scope.traits = null;
166170
} else {
167171
jQuery($this).addClass('raml-console-is-active');
168172
jQuery($this).siblings('.raml-console-tab').removeClass('raml-console-is-active');
173+
$scope.traits = null;
169174
}
170175
};
171176
}

src/app/resources/resources.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@
4343
ramlParserWrapper.load($scope.src);
4444
}
4545

46+
$scope.readTraits = function getTraits(traits) {
47+
var list = [];
48+
49+
if (traits) {
50+
traits.map(function (trait) {
51+
if (typeof trait === 'object') {
52+
list.push(Object.keys(trait).join(', '));
53+
} else {
54+
list.push(trait);
55+
}
56+
});
57+
}
58+
59+
return list.join(', ');
60+
};
61+
4662
$scope.updateProxyConfig = function (status) {
4763
$window.RAML.Settings.disableProxy = status;
4864
};

src/app/resources/resources.tpl.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ <h2 class="raml-console-resource-heading raml-console-resource-heading-large">
5151
</h2>
5252

5353
<resource-type></resource-type>
54-
<span ng-if="methodInfo.is" class="raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait"><b>Trait:</b> {{traits}}</span>
54+
<span ng-if="traits" class="raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait"><b>Traits:</b> {{traits}}</span>
55+
56+
<span ng-hide="traits" ng-if="resource.traits" class="raml-console-flag raml-console-resource-heading-flag"><b>Traits:</b> {{readTraits(resource.traits)}}</span>
5557

5658
</div>
5759
<method-list></method-list>
@@ -78,7 +80,7 @@ <h3 class="raml-console-resource-heading" ng-click="showResourceDescription($eve
7880
</h3>
7981

8082
<resource-type></resource-type>
81-
<span ng-if="methodInfo.is" class="raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait"><b>Trait:</b> {{traits}}</span>
83+
<span ng-if="traits" class="raml-console-flag raml-console-resource-heading-flag raml-console-resource-trait"><b>Traits:</b> {{traits}}</span>
8284
</div>
8385

8486
<method-list></method-list>

src/assets/examples/github.raml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ securitySchemes:
4343
- "delete_repo"
4444
- "notifications"
4545
- "gist"
46-
securedBy: [ oauth_2_0, basic ]
46+
securedBy: [ null, oauth_2_0, basic ]
4747
mediaType: application/json
4848
resourceTypes:
4949
- base:

src/scss/_tab.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
}
277277

278278
.tab.is-active {
279-
z-index: 1;
279+
z-index: 5;
280280

281281
color: $color-console-tab-active;
282282
}

0 commit comments

Comments
 (0)