File

src/app/tool-page/issue-list/issue-list.component.ts

Description

Display for the list of IssueItems in the currently selected course.

Metadata

selector app-issue-list
styleUrls issue-list.component.css
templateUrl ./issue-list.component.html

Index

Properties
Methods

Constructor

constructor(courseService: CourseService)

Constructor

Parameters :
Name Type Optional Description
courseService CourseService no

Provides information and management for selected courses.

Methods

getIssueItems
getIssueItems()

Provides IssueItems to load into the list as {@link IssueCard}s, based on the number allowed (issueItemCount).

Returns : IssueItem[]
onScroll
onScroll()

Runs as the user scrolls down the list. If the user reaches near the bottom of the list, it will load more IssueItems into the list. This is, essentially, lazy loading. It helps prevent poor load times with massive amounts of IssueItems, but does cause a little bit of stuttering.

Returns : void

Properties

Public courseService
courseService: CourseService
Type : CourseService
Provides information and management for selected courses.
issueItemCount
issueItemCount: number
Type : number
Default value : 15

The number of IssueItems currently loaded in the list. Used for lazy loading.

issueListEl
issueListEl: ElementRef
Type : ElementRef
Decorators : ViewChild

Element reference to the issue list.

import { Component, ViewChild, ElementRef } from '@angular/core';
import { CourseService } from '../../course.service';
import { IssueItem } from '../../interfaces';

/**
 * Display for the list of {@link IssueItem}s in the currently selected course.
 */
@Component({
    selector: 'app-issue-list',
    templateUrl: './issue-list.component.html',
    styleUrls: ['./issue-list.component.css']
})
export class IssueListComponent {

    /** Element reference to the issue list. */
    @ViewChild('issueList') issueListEl: ElementRef;

    /** The number of {@link IssueItem}s currently loaded in the list. Used for lazy loading. */
    issueItemCount: number = 15;

    /**
     * Constructor
     * @param courseService Provides information and management for selected courses.
     */
    constructor(public courseService: CourseService) {
        this.courseService.courseChange.subscribe(() => {
            this.issueItemCount = 15;
            this.issueListEl.nativeElement.scrollTop = 0;
        });
    }

    /** 
     * Runs as the user scrolls down the list. If the user reaches near the bottom of the list, it will
     * load more {@link IssueItem}s into the list. This is, essentially, lazy loading. It helps prevent
     * poor load times with massive amounts of IssueItems, but does cause a little bit of stuttering.
     */
    onScroll() {
        let maxScrollTop = this.issueListEl.nativeElement.scrollHeight - this.issueListEl.nativeElement.clientHeight;
        if (maxScrollTop - this.issueListEl.nativeElement.scrollTop < 500) {
            if (this.courseService.selectedCourse.issueItems.length > this.issueItemCount) {
                this.issueItemCount += 15;
            }
        }
    }

    /** 
     * Provides {@link IssueItem}s to load into the list as {@link IssueCard}s, based on the
     * number allowed (issueItemCount).
     */
    getIssueItems(): IssueItem[] {
        if (this.courseService.selectedCourse.issueItems.length < this.issueItemCount) {
            return this.courseService.selectedCourse.issueItems;
        } else {
            return this.courseService.selectedCourse.issueItems.slice(0, this.issueItemCount);
        }
    }
}
<div class="issueList">
    <h1 class="issueList__title white-text">
        Items
        <span class="header_thin">({{courseService.selectedCourse && courseService.selectedCourse.issueItems ? courseService.selectedCourse.issueItems.length
            : 0}})</span>
    </h1>
    <div class="issueList__list" (scroll)="onScroll()" #issueList>
        <app-issue-card *ngFor="let issueItem of getIssueItems(); let i = index" [position]="i" [issueItem]="issueItem" (click)="courseService.selectedIssueItem = issueItem">
        </app-issue-card>
        <div class="noIssuesMessage" *ngIf="courseService.selectedCourse && courseService.selectedCourse.issueItems && courseService.selectedCourse.issueItems.length === 0 && !courseService.selectedCourse.error">
            No issues were discovered in this course.
            <div>
                <i class="material-icons">tag_faces</i>
            </div>
        </div>
        <div class="noIssuesMessage" *ngIf="courseService.selectedCourse && courseService.selectedCourse.issueItems && courseService.selectedCourse.error">
            <p>This course failed to process.</p>
            Please contact a Katana developer with the tool name and course ID.
            <div>
                <i class="material-icons">sentiment_very_dissatisfied</i>
            </div>
        </div>
    </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""