Skip to content

Commit c5a1f45

Browse files
committed
Manage projects
1 parent 7442cd1 commit c5a1f45

20 files changed

+354
-9
lines changed

angular.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@
2424
"src/assets"
2525
],
2626
"styles": [
27+
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
2728
"src/styles.css"
28-
],
29-
"scripts": []
29+
],
30+
"scripts": [
31+
"./node_modules/jquery/dist/jquery.min.js",
32+
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
33+
]
3034
},
3135
"configurations": {
3236
"production": {

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"@angular/platform-browser": "~9.0.3",
2020
"@angular/platform-browser-dynamic": "~9.0.3",
2121
"@angular/router": "~9.0.3",
22+
"bootstrap": "^4.4.1",
23+
"jquery": "^3.4.1",
2224
"rxjs": "~6.5.4",
2325
"tslib": "^1.10.0",
2426
"zone.js": "~0.10.2"

src/app/app-routing.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ReportsComponent } from './components/options-sidebar/reports/reports.c
55
import { TimeClockComponent } from './components/options-sidebar/time-clock/time-clock.component';
66
import { TimeEntriesComponent } from './components/options-sidebar/time-entries/time-entries.component';
77
import { TimeOffComponent } from './components/options-sidebar/time-off/time-off.component';
8+
import { ProjectManagementComponent } from './components/options-sidebar/project-management/project-management.component';
89

910

1011
const routes: Routes = [
@@ -13,6 +14,7 @@ const routes: Routes = [
1314
{path: 'time-clock', component: TimeClockComponent},
1415
{path: 'time-entries', component: TimeEntriesComponent},
1516
{path: 'time-off', component: TimeOffComponent},
17+
{path: 'project-management', component: ProjectManagementComponent},
1618
{path: '', pathMatch: 'full', redirectTo: 'getting-started'},
1719
{path: '**', pathMatch: 'full', redirectTo: 'getting-started'},
1820
];

src/app/app.module.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
34

45
import { AppRoutingModule } from './app-routing.module';
56
import { AppComponent } from './app.component';
67
import { NavbarComponent } from './components/shared/navbar/navbar.component';
78
import { UserComponent } from './components/shared/user/user.component';
89
import { SidebarComponent } from './components/shared/sidebar/sidebar.component';
910
import { ClockComponent } from './components/shared/clock/clock.component';
10-
11+
import { ProjectManagementComponent } from './components/options-sidebar/project-management/project-management.component';
12+
import { ProjectListComponent } from './components/shared/project-list/project-list.component';
13+
import { CreateProjectComponent } from './components/shared/create-project/create-project.component';
1114
@NgModule({
1215
declarations: [
1316
AppComponent,
1417
NavbarComponent,
1518
UserComponent,
1619
SidebarComponent,
1720
ClockComponent,
21+
ProjectManagementComponent,
22+
ProjectListComponent,
23+
CreateProjectComponent
1824
],
1925
imports: [
2026
BrowserModule,
21-
AppRoutingModule
27+
AppRoutingModule,
28+
FormsModule,
29+
ReactiveFormsModule
2230
],
2331
providers: [],
2432
bootstrap: [AppComponent]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.parent {
2+
display: flex;
3+
}
4+
5+
.item {
6+
width: 50%;
7+
margin: 2em;
8+
min-height: 500px;
9+
max-height: 500px;
10+
}
11+
12+
@media screen and (max-width: 600px){
13+
.parent {
14+
flex-direction: column-reverse;
15+
}
16+
17+
.item {
18+
width: auto;
19+
min-height: 200px;
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
<div class="parent">
3+
4+
<app-create-project class="item"
5+
[projectToEdit] = "project"
6+
(savedProject)="updateProject($event)"
7+
(cancelForm) = "cancelForm()"
8+
>
9+
</app-create-project>
10+
11+
<app-project-list class="item"
12+
[projects] = "projects"
13+
(editProject) = "editProject($event)"
14+
>
15+
</app-project-list>
16+
</div>
17+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ProjectManagementComponent } from './project-management.component';
4+
5+
describe('ProjectManagementComponent', () => {
6+
let component: ProjectManagementComponent;
7+
let fixture: ComponentFixture<ProjectManagementComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ ProjectManagementComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ProjectManagementComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Project } from '../../../interfaces/project';
3+
import { Input } from '@angular/core';
4+
import { Output, EventEmitter } from '@angular/core';
5+
@Component({
6+
selector: 'app-project-management',
7+
templateUrl: './project-management.component.html',
8+
styleUrls: ['./project-management.component.css']
9+
})
10+
export class ProjectManagementComponent implements OnInit {
11+
12+
editedProjectId;
13+
14+
project: Project;
15+
16+
projects: Project[] = [
17+
{ id: 1, name: 'GoSpace', details: 'Improve workspaces', status: 'Active', completed: false},
18+
{ id: 2, name: 'MidoPlay', details: 'Lottery', status: 'Inactive', completed: true}
19+
];
20+
21+
constructor() { }
22+
23+
ngOnInit(): void {
24+
}
25+
26+
updateProject(projectData): void {
27+
if (this.editedProjectId) {
28+
const projectIndex = this.projects.findIndex((project => project.id === this.editedProjectId));
29+
this.projects[projectIndex].name = projectData.name;
30+
this.projects[projectIndex].details = projectData.details;
31+
this.projects[projectIndex].status = projectData.status;
32+
this.projects[projectIndex].completed = projectData.completed;
33+
} else {
34+
const newProject: Project = { id: this.projects.length + 1, name: projectData.name,
35+
details: projectData.details, status: projectData.status, completed: false
36+
};
37+
this.projects = this.projects.concat(newProject);
38+
}
39+
console.log(this.projects);
40+
}
41+
42+
editProject(projectId) {
43+
this.editedProjectId = projectId;
44+
this.project = this.projects.filter((project) => project.id === projectId)[0];
45+
}
46+
47+
cancelForm() {
48+
this.project = null;
49+
}
50+
}

src/app/components/shared/create-project/create-project.component.css

Whitespace-only changes.

0 commit comments

Comments
 (0)