Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add Clock In
  • Loading branch information
jorgecod committed Mar 17, 2020
commit 747e09f2c385ec32b96c63b59bf73f3b2f3cd426
11 changes: 10 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
Expand All @@ -11,6 +12,10 @@ import { ClockComponent } from './components/shared/clock/clock.component';
import { ProjectManagementComponent } from './components/options-sidebar/project-management/project-management.component';
import { ProjectListComponent } from './components/shared/project-list/project-list.component';
import { CreateProjectComponent } from './components/shared/create-project/create-project.component';
import { TimeClockComponent } from './components/options-sidebar/time-clock/time-clock.component';
import { DetailsFieldsComponent } from './components/shared/details-fields/details-fields.component';
import { ProjectListHoverComponent } from './components/shared/project-list-hover/project-list-hover.component';

@NgModule({
declarations: [
AppComponent,
Expand All @@ -20,9 +25,13 @@ import { CreateProjectComponent } from './components/shared/create-project/creat
ClockComponent,
ProjectManagementComponent,
ProjectListComponent,
CreateProjectComponent
CreateProjectComponent,
TimeClockComponent,
DetailsFieldsComponent,
ProjectListHoverComponent,
],
imports: [
CommonModule,
BrowserModule,
AppRoutingModule,
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.content-ClockIn {
padding: 2.1rem 1rem;
}

.timer {
align-items: center;
display: flex;
height: 100%;
justify-content: center;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<div class="text-center mt-5">

<p>time-clock works!</p>

</div>
<div class="container">
<div class="row">
<div class="col content-ClockIn">
<h5>PROJECTS</h5>
<app-project-list-hover
[projects]="projects"
(showFields)="setShowFields($event)"
></app-project-list-hover>
<br />
<div *ngIf="showFields">
<app-details-fields></app-details-fields>
</div>
</div>
<div class="col content-ClockIn">
<div class="timer">
<h5>Timer Here!</h5>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from "@angular/core/testing";

import { TimeClockComponent } from './time-clock.component';
import { TimeClockComponent } from "./time-clock.component";

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

Expand All @@ -15,9 +15,8 @@ describe('TimeClockComponent', () => {

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

beforeEach(() => {
Expand All @@ -26,7 +25,7 @@ describe('TimeClockComponent', () => {
fixture.detectChanges();
});

it('should be created', () => {
it("should be created", () => {
expect(component).toBeTruthy();
});

Expand All @@ -39,4 +38,10 @@ describe('TimeClockComponent', () => {
expect(h1tag.textContent).toBe('time-clock works!');
}));

it("should set showfileds as true", () => {
const show = true;
component.showFields = show;
component.setShowFields(show);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting this field to true twice?

expect(component.showFields).toBe(true);
});
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit } from "@angular/core";

@Component({
selector: 'app-time-clock',
templateUrl: './time-clock.component.html',
styleUrls: ['./time-clock.component.css']
selector: "app-time-clock",
templateUrl: "./time-clock.component.html",
styleUrls: ["./time-clock.component.css"]
})
export class TimeClockComponent implements OnInit {
projects = [
{ id: "P1", name: "Project 1" },
{ id: "P2", name: "Project 2" },
{ id: "P3", name: "Project 3" },
{ id: "P4", name: "Project 4" }
];

constructor() { }
showFields: boolean;

ngOnInit(): void {
}
constructor() {}

ngOnInit(): void {}

setShowFields(show: boolean) {
this.showFields = show;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.span-width {
width: 6rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<form>
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<label class="input-group-text span-width" for="inputGroupSelect01">Activity</label>
</div>
<select class="custom-select" id="inputGroupSelect01">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text span-width" id="inputGroup-sizing-sm"
>Jira Ticket</span
>
</div>
<input
type="text"
class="form-control"
aria-label="Small"
aria-describedby="inputGroup-sizing-sm"
/>
</div>
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text span-width" id="inputGroup-sizing-sm">Technology</span>
</div>
<input
type="text"
class="form-control"
aria-label="Small"
aria-describedby="inputGroup-sizing-sm"
/>
</div>
<div class="form-group">
<label for="NotesTextarea">Notes</label>
<textarea class="form-control" id="NotesTextarea" rows="3"></textarea>
</div>
</form>
<button class="btn btn-danger btn-sm">
Clock Out
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DetailsFieldsComponent } from './details-fields.component';

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

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

beforeEach(() => {
fixture = TestBed.createComponent(DetailsFieldsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-details-fields',
templateUrl: './details-fields.component.html',
styleUrls: ['./details-fields.component.css']
})
export class DetailsFieldsComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.content-projects {
max-height: 10rem;
overflow-x: auto;
}

.content-projects > li {
cursor: pointer;
font-size: 0.8rem;
padding: 0.5rem 0.8rem;
}

.button-clockIn {
font-size: 0.7rem;
padding: 0 0.3rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<ul class="list-group content-projects">
<li
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"
*ngFor="let item of projects; let i = index"
(mouseenter)="showButton = i"
(mouseleave)="showButton = -1"
(click)="clockIn(item.id)"
[ngClass]="{ active: selectedId === item.id }"
>
{{ item.name }}
<span
*ngIf="showButton === i && selectedId !== item.id"
class="badge badge-light"
>Clock In</span
>
</li>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { async, ComponentFixture, TestBed } from "@angular/core/testing";

import { ProjectListHoverComponent } from "./project-list-hover.component";

describe("ProjectListHoverComponent", () => {
let component: ProjectListHoverComponent;
let fixture: ComponentFixture<ProjectListHoverComponent>;

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

beforeEach(() => {
fixture = TestBed.createComponent(ProjectListHoverComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
});

it("should set selectedId with Id", () => {
const id: string = "P1";
component.clockIn(id);
expect(component.selectedId).toBe(id);
});

it("should emit showFields event", () => {
const id: string = "P1";
component.showFields.subscribe((showFields: boolean) =>
expect(showFields).toEqual(true)
);
component.clockIn(id);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";

@Component({
selector: "app-project-list-hover",
templateUrl: "./project-list-hover.component.html",
styleUrls: ["./project-list-hover.component.css"]
})
export class ProjectListHoverComponent implements OnInit {
@Input() projects: any;
@Output() showFields = new EventEmitter<boolean>();

selectedId: string;
showButton: number;

constructor() {
this.showButton = -1;
}

ngOnInit(): void {}

clockIn(id: string) {
this.selectedId = id;
this.showFields.emit(true);
}
}