Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3 class="h4 mt-2">Documentation</h3>
<div class="flex-fill scroll-box-container">
<div class="scroll-box">
<div class="scroll-box" #scrollBox>
<div *ngIf="documentation; else noDoc" [innerHTML]="documentation | markdown"></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { Component, Input, ChangeDetectionStrategy, ViewChild, ElementRef } from '@angular/core';

@Component({
selector: 'tr-command-documentation',
Expand All @@ -7,5 +7,10 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
})

export class CommandDocumentationComponent {
@Input() documentation = '';
public documentation = '';
@ViewChild('scrollBox', {static: true}) scrollBox: ElementRef;
@Input('documentation') set resetScroll(document: string) {
this.documentation = document;
this.scrollBox.nativeElement.scrollTop = 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h3 class="h4">Commands</h3>
<input type="text" class="form-control form-control-sm" placeholder="Search command" #search (input)="true">
</div>
<div class="flex-fill scroll-box-container command-list-container">
<div class="scroll-box">
<div class="scroll-box" #scrollBox>
<ul>
<li
*ngFor="let command of filteredCommands | searchFilter: 'key': search.value | searchFilter: 'group': activeCategory"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, Output, ChangeDetectionStrategy } from '@angular/core';
import { Component, EventEmitter, Input, Output, ChangeDetectionStrategy, ElementRef, ViewChild } from '@angular/core';

import { Command } from '@app/shared/models/command.interface';

Expand All @@ -15,6 +15,7 @@ export class CommandListComponent {
activeCommand: Command;
activeCategory = '';

@ViewChild('scrollBox', {static: true}) scrollBox: ElementRef;
@Input('commands') set setCommands(data: Array<Command>) {
this.filteredCommands = data;
const array = this.filteredCommands.map(item => item.group);
Expand Down Expand Up @@ -55,6 +56,7 @@ export class CommandListComponent {
* @param category category name
*/
setActiveCategory(category: string) {
this.scrollBox.nativeElement.scrollTop = 0;
this.activeCategory = category;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3 class="h4 position-relative">{{activePattern.title}}</h3>
</button>
</div>

<div class="scroll-box">
<div class="scroll-box" #scrollBox>
<p [innerHTML]="steps[currentStep] | markdown" *ngIf='steps && steps[currentStep]'></p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, HostListener, Input, Output, ChangeDetectionStrategy } from '@angular/core';
import { Component, EventEmitter, HostListener, Input, Output, ChangeDetectionStrategy, ElementRef, ViewChild } from '@angular/core';

import { Pattern } from '@app/shared/models/pattern.interface';

Expand All @@ -15,7 +15,9 @@ enum Paginator {
changeDetection: ChangeDetectionStrategy.OnPush
})
export class PatternContentComponent {
@ViewChild('scrollBox', {static: false}) scrollBox: ElementRef;
@Input('patternContent') set newStep(data: Array<string>) {
this.resetScroll();
this.steps = data;
this.currentStep = 0;
}
Expand Down Expand Up @@ -49,6 +51,8 @@ export class PatternContentComponent {
* @param type boolean (TRUE: previous step, FALSE: next step)
*/
changeStep(type: Paginator) {
this.resetScroll();

switch (type) {
case Paginator.FIRST_PAGE:
this.currentStep = 0;
Expand All @@ -63,4 +67,10 @@ export class PatternContentComponent {
this.currentStep = this.steps.length - 1;
}
}

private resetScroll() {
if (this.scrollBox) {
this.scrollBox.nativeElement.scrollTop = 0;
}
}
}