Skip to content

Commit

Permalink
feat: add user badge component
Browse files Browse the repository at this point in the history
  • Loading branch information
jakerenzella committed Sep 30, 2022
1 parent cbc157a commit 9fc9e62
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/common/user-badge/user-badge.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<mat-chip-list *ngIf="project" #chipList aria-label="user badge" (click)="goToStudent()">
<mat-chip fxLayout="row" style="padding-left: -0px">
<user-icon size="32" [user]="project.student" style="margin-right: 10px"></user-icon>
<span>{{ project.student.name }}</span>
</mat-chip>
<mat-chip>
<span>{{ project.targetGradeAcronym }}</span>
</mat-chip>
</mat-chip-list>
22 changes: 22 additions & 0 deletions src/app/common/user-badge/user-badge.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UserBadgeComponent } from './user-badge.component';

describe('UserBadgeComponent', () => {
let component: UserBadgeComponent;
let fixture: ComponentFixture<UserBadgeComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [UserBadgeComponent],
}).compileComponents();

fixture = TestBed.createComponent(UserBadgeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
22 changes: 22 additions & 0 deletions src/app/common/user-badge/user-badge.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, Input } from '@angular/core';
import { UIRouter } from '@uirouter/angular';
import { Project, ProjectService } from 'src/app/api/models/doubtfire-model';
import { UserService } from 'src/app/api/services/user.service';

@Component({
selector: 'f-user-badge',
templateUrl: './user-badge.component.html',
styleUrls: ['./user-badge.component.scss'],
})
export class UserBadgeComponent {
constructor(private userService: UserService, private router: UIRouter, private projectService: ProjectService) {}
@Input() project: Project;

goToStudent(): void {
this.router.stateService.go('projects/dashboard', {
projectId: this.project.id,
tutor: true,
taskAbbr: '',
});
}
}
2 changes: 2 additions & 0 deletions src/app/doubtfire-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ import { SignInComponent } from './sessions/states/sign-in/sign-in.component';
import { EditProfileFormComponent } from './common/edit-profile-form/edit-profile-form.component';
import { TransitionHooksService } from './sessions/transition-hooks.service';
import { EditProfileComponent } from './account/edit-profile/edit-profile.component';
import { UserBadgeComponent } from './common/user-badge/user-badge.component';

@NgModule({
// Components we declare
Expand Down Expand Up @@ -237,6 +238,7 @@ import { EditProfileComponent } from './account/edit-profile/edit-profile.compon
SignInComponent,
EditProfileFormComponent,
EditProfileComponent,
UserBadgeComponent,
],
// Module Imports
imports: [
Expand Down
2 changes: 2 additions & 0 deletions src/app/doubtfire-angularjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ import { ObjectSelectComponent } from './common/obect-select/object-select.compo
import { TaskDefinitionService } from './api/services/task-definition.service';
import { EditProfileDialogService } from './common/modals/edit-profile-dialog/edit-profile-dialog.service';
import { GroupService } from './api/services/group.service';
import { UserBadgeComponent } from './common/user-badge/user-badge.component';

export const DoubtfireAngularJSModule = angular.module('doubtfire', [
'doubtfire.config',
Expand Down Expand Up @@ -318,6 +319,7 @@ DoubtfireAngularJSModule.directive(
);
DoubtfireAngularJSModule.directive('objectSelect', downgradeComponent({ component: ObjectSelectComponent }));
DoubtfireAngularJSModule.directive('appHeader', downgradeComponent({ component: HeaderComponent }));
DoubtfireAngularJSModule.directive('userBadge', downgradeComponent({ component: UserBadgeComponent }));
DoubtfireAngularJSModule.directive(
'intelligentDiscussionPlayer',
downgradeComponent({ component: IntelligentDiscussionPlayerComponent })
Expand Down

0 comments on commit 9fc9e62

Please sign in to comment.