chore: operation list minor refactor

This commit is contained in:
Roman Hotsiy 2017-04-18 16:42:59 +03:00
parent 6077cc6afd
commit 4839b3ce69
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 10 additions and 3 deletions

View File

@ -1,7 +1,7 @@
<div class="operations">
<div class="tag" *ngFor="let tag of tags; trackBy:trackByTagName" [attr.section]="tag.id">
<div class="tag-info" *ngIf="tag.name">
<h1 class="sharable-header"> <a class="share-link" href="#{{tag.id}}"></a>{{tag.name}} </h1>
<h1 class="sharable-header"> <a class="share-link" href="#{{tag.anchor}}"></a>{{tag.name}} </h1>
<p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
<redoc-externalDocs [docs]="tag.metadata.externalDocs"></redoc-externalDocs>
</div>

View File

@ -12,7 +12,6 @@
.tag-info {
padding: $section-spacing;
box-sizing: border-box;
background-color: white;
width: 60%;
@media (max-width: $right-panel-squash-breakpoint) {

View File

@ -30,7 +30,10 @@ export class OperationsList extends BaseComponent implements OnInit {
if (!menuItem.metadata) return;
if (menuItem.metadata.type === 'tag') {
this.tags.push(menuItem);
this.tags.push({
...menuItem,
anchor: this.buildAnchor(menuItem.id)
});
}
if (menuItem.metadata.type === 'operation' && !menuItem.parent) {
emptyTag.items.push(menuItem);
@ -39,6 +42,11 @@ export class OperationsList extends BaseComponent implements OnInit {
if (emptyTag.items.length) this.tags.push(emptyTag);
}
buildAnchor(tagId):string {
return this.menu.hashFor(tagId,
{ type: 'tag'});
}
trackByTagName(_, el) {
return el.name;
}