-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from thoughtworks/conversation
Conversation
- Loading branch information
Showing
47 changed files
with
1,949 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { VotingEvent } from 'src/app/models/voting-event'; | ||
import { Technology } from './models/technology'; | ||
import { Credentials } from './models/credentials'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class AppSessionService { | ||
private votingEvents: VotingEvent[]; | ||
private selectedVotingEvent: VotingEvent; | ||
private selectedTechnology: Technology; | ||
private credentials: Credentials; | ||
|
||
constructor() {} | ||
|
||
getVotingEvents() { | ||
return this.votingEvents; | ||
} | ||
setVotingEvents(votingEvents: VotingEvent[]) { | ||
this.votingEvents = votingEvents; | ||
} | ||
|
||
getSelectedVotingEvent() { | ||
return this.selectedVotingEvent; | ||
} | ||
setSelectedVotingEvent(votingEvent: VotingEvent) { | ||
this.selectedVotingEvent = votingEvent; | ||
} | ||
|
||
getSelectedTechnology() { | ||
return this.selectedTechnology; | ||
} | ||
setSelectedTechnology(technology: Technology) { | ||
this.selectedTechnology = technology; | ||
} | ||
|
||
getCredentials() { | ||
return this.credentials; | ||
} | ||
setCredentials(credentials: Credentials) { | ||
this.credentials = credentials; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/app/components/voting-event-select/voting-event-select.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="selection-section"> | ||
<div class="event-selection"> | ||
<mat-form-field> | ||
<mat-select #eventSelect placeholder="Choose a voting event" id="eventSelectEl" (selectionChange)="eventSelected(eventSelect)"> | ||
<mat-option *ngFor="let votingEvent of appSession.getVotingEvents()" [value]="votingEvent.name"> | ||
{{votingEvent.name}} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
</div> | ||
</div> | ||
|
||
<div class="select-actions"> | ||
<button #selectButton mat-flat-button color="accent" [class.button-disabled]="!votingEventName" | ||
[class.button-enabled]="votingEventName" [disabled]="!votingEventName" (click)="goToIdentification()"> | ||
<span class="button-text"> Select Event </span> | ||
</button> | ||
</div> |
39 changes: 39 additions & 0 deletions
39
src/app/components/voting-event-select/voting-event-select.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@import "../../styles/abstracts/mixins"; | ||
|
||
$selection-sections-max-width: 480px; | ||
|
||
.selection-section { | ||
margin: 1.3rem auto; | ||
padding: 0 1.3rem; | ||
max-width: $selection-sections-max-width; | ||
|
||
.event-selection { | ||
display: block; | ||
} | ||
|
||
mat-form-field { | ||
width: 100%; | ||
} | ||
|
||
.voter { | ||
margin-bottom: 2rem; | ||
|
||
.voter-input { | ||
width: 100%; | ||
@include byor-input; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: .3rem; | ||
} | ||
} | ||
|
||
.button-disabled { | ||
border: none; | ||
} | ||
|
||
.button-text { | ||
color: #ffffff; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/app/components/voting-event-select/voting-event-select.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { AppMaterialModule } from '../../app-material.module'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { VotingEventSelectComponent } from './voting-event-select.component'; | ||
import { AppSessionService } from 'src/app/app-session.service'; | ||
import { VotingEvent } from 'src/app/models/voting-event'; | ||
|
||
class MockAppSessionService { | ||
private votingEvents: VotingEvent[]; | ||
|
||
constructor() { | ||
this.votingEvents = [{ _id: '123', name: 'an event', status: 'open', creationTS: 'abc' }]; | ||
} | ||
|
||
getVotingEvents() { | ||
return this.votingEvents; | ||
} | ||
} | ||
|
||
describe('VotingEventSelectComponent', () => { | ||
let component: VotingEventSelectComponent; | ||
let fixture: ComponentFixture<VotingEventSelectComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [AppMaterialModule, RouterTestingModule, BrowserAnimationsModule], | ||
declarations: [VotingEventSelectComponent], | ||
providers: [{ provide: AppSessionService, useClass: MockAppSessionService }] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(VotingEventSelectComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
src/app/components/voting-event-select/voting-event-select.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { AppSessionService } from '../../app-session.service'; | ||
import { VotingEvent } from 'src/app/models/voting-event'; | ||
import { MatSelect } from '@angular/material/select'; | ||
import { getIdentificationRoute } from 'src/app/utils/voting-event-flow.util'; | ||
import { Router } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'byor-voting-event-select', | ||
templateUrl: './voting-event-select.component.html', | ||
styleUrls: ['./voting-event-select.component.scss'] | ||
}) | ||
export class VotingEventSelectComponent implements OnInit { | ||
votingEventName: string; | ||
|
||
constructor(public appSession: AppSessionService, private router: Router) {} | ||
|
||
ngOnInit() {} | ||
|
||
eventSelected(eventSelect: MatSelect) { | ||
this.votingEventName = eventSelect.value; | ||
} | ||
|
||
goToIdentification() { | ||
const votingEvent = this.appSession.getVotingEvents().find((ve) => ve.name === this.votingEventName); | ||
this.appSession.setSelectedVotingEvent(votingEvent); | ||
const route = getIdentificationRoute(votingEvent); | ||
this.router.navigate([route]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Credentials { | ||
userId?: string; | ||
nickname?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { VotingEventStep } from './voting-event-step'; | ||
import { VotingEvent } from './voting-event'; | ||
|
||
export interface VotingEventFlow { | ||
steps: VotingEventStep[]; | ||
} |
Oops, something went wrong.