src/app/tool-page/issue-card/issue-card.component.ts
Manages the display for a single IssueItem.
| selector | app-issue-card |
| styleUrls | issue-card.component.css |
| templateUrl | ./issue-card.component.html |
Properties |
|
Methods |
Inputs |
constructor(courseService: CourseService)
|
||||||||
|
Constructor
Parameters :
|
issueItem
|
The IssueItem used by this component.
Type: |
position
|
The position of the component in the IssueListComponent.
Type: |
| getTypeIcon |
getTypeIcon()
|
|
This is used to determine the icon shown at the top left of a card. It is based on the IssueItem's item_type property, or the type of the item in Canvas. (i.e. Page)
Returns :
any
The icon title to use to display the icon. |
| ngAfterViewInit |
ngAfterViewInit()
|
|
This class implements AfterViewInit, which runs after the element is rendered completely on the page. This is so we can add the tooltip data correctly to the type icon.
Returns :
void
|
| Public courseService |
courseService:
|
Type : CourseService
|
|
Provides information and management for selected courses.
|
| typeIcon |
typeIcon:
|
Type : ElementRef
|
Decorators : ViewChild
|
|
Reference to the element in the view for this component that contains it's item type icon (ex. Page, Discussion, Quiz). |
import { Component, Input, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { CourseService } from '../../course.service';
import { IssueItem } from '../../interfaces';
/**
* Manages the display for a single {@link IssueItem}.
*/
@Component({
selector: 'app-issue-card',
templateUrl: './issue-card.component.html',
styleUrls: ['./issue-card.component.css']
})
export class IssueCardComponent implements AfterViewInit {
/**
* The {@link IssueItem} used by this component.
*/
@Input('issueItem') issueItem: IssueItem;
/**
* The position of the component in the {@link IssueListComponent}.
*/
@Input('position') position: number;
/**
* Reference to the element in the view for this component that
* contains it's item type icon (ex. Page, Discussion, Quiz).
*/
@ViewChild('typeIcon') typeIcon: ElementRef;
/**
* Constructor
* @param courseService Provides information and management for selected courses.
*/
constructor(public courseService: CourseService) { }
/**
* This class implements AfterViewInit, which runs after the element
* is rendered completely on the page. This is so we can add the tooltip
* data correctly to the type icon.
*/
ngAfterViewInit() {
if (!this.typeIcon) return;
let types = {
'pages': 'Page',
'assignments': 'Assignment',
'discussions': 'Discussion',
'files': 'File',
'folders': 'Folder',
'quizzes': 'Quiz',
'quizQuestions': 'Quiz Question',
'modules': 'Module',
'moduleItems': 'Module Item',
}
this.typeIcon.nativeElement.setAttribute('data-tooltip', types[this.issueItem.category]);
}
/**
* This is used to determine the icon shown at the top left of a card.
* It is based on the IssueItem's item_type property, or the type of
* the item in Canvas. (i.e. Page)
* @returns {string} The icon title to use to display the icon.
*/
getTypeIcon() {
let typeIcons = {
'pages': 'insert_drive_file',
'assignments': 'assignment',
'discussions': 'question_answer',
'files': 'attach_file',
'folders': 'folder',
'quizzes': 'gavel',
'quizQuestions': 'help_outline',
'modules': 'view_agenda',
'moduleItems': 'view_list',
}
return typeIcons[this.issueItem.category];
}
}
<div id="{{issueItem.item_id}}" [class.selectedCard]="this.courseService.selectedIssueItem === issueItem"
class="issueCard card z-depth-1 scale-transition">
<div class="issueCard_titleLine">
<div>
<i #typeIcon id="typeIcon" materialize="tooltip" class="material-icons issueCard_tag tooltipped" data-position="left">
{{getTypeIcon()}}
</i>
<div class="issueCard_title">
{{issueItem.title}}
</div>
</div>
<a target="_blank" href="{{issueItem.link}}" class="issueCard_link tooltipped" materialize="tooltip" data-position="right"
data-tooltip="Open in Canvas">
<i class="material-icons">open_in_new</i>
</a>
</div>
<ul>
<li *ngFor="let issue of issueItem.issues" class="issueCard_issue ">
<i class="material-icons issueCard_tag" [ngClass]="courseService.getTextColorClasses(issue.status)">
{{courseService.getStatusIcon(issue.status)}}
</i>{{issue.title}}
</li>
</ul>
</div>