diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5f2a9e6..0bd7cc2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,7 +4,7 @@ import { DashboardComponent } from './components/dashboard/dashboard.component'; import { UserstoryTableComponent } from './components/tabels/userstory/userstory-table.component'; import { TaskTableComponent } from './components/tabels/task/task-table.component'; import { SprintTableComponent } from './components/tabels/sprint/sprint-table.component'; -import {BacklogComponent} from './components/backlog-table/backlog.component'; +import {BacklogComponent} from './components/backlog/backlog.component'; const routes: Routes = [ { path: 'tasks', component: TaskTableComponent }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4cdd16a..583b131 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -16,7 +16,7 @@ import { TaskTableComponent } from './components/tabels/task/task-table.componen import { SprintTableComponent } from './components/tabels/sprint/sprint-table.component'; import { DashboardComponent } from './components/dashboard/dashboard.component'; import { UserstoryInnerTableComponent } from './components/userstory-inner-table/userstory-inner-table.component'; -import { BacklogComponent } from './components/backlog-table/backlog.component'; +import { BacklogComponent } from './components/backlog/backlog.component'; @NgModule({ declarations: [ diff --git a/src/app/components/backlog-table/backlog.component.html b/src/app/components/backlog-table/backlog.component.html deleted file mode 100644 index b0295e3..0000000 --- a/src/app/components/backlog-table/backlog.component.html +++ /dev/null @@ -1,62 +0,0 @@ -
-
- -

Backlog

-
-
-
-
- -
-
-
-
-

Backlog

-
-
-
-

{{story.title}}

-
Prio: {{story.priority}}
-

{{story.content}}

-
- Category: {{story.categoryid || "N/A"}} - Status: {{story.statusid || "N/A"}} -
-
- -
-
-
-
-
-
- -
- -

Sprint-Backlog - Aktueller Sprint: {{this.currentSprint.title}}

-
-
-
-

{{story.title}}

-
Prio: {{story.priority}}
-

{{story.content}}

-
- Category: {{story.categoryid || "N/A"}} - Status: {{story.statusid || "N/A"}} -
-
- -
-
-
-
-
-
-
-
diff --git a/src/app/components/backlog-table/backlog.component.ts b/src/app/components/backlog-table/backlog.component.ts deleted file mode 100644 index f67c1fb..0000000 --- a/src/app/components/backlog-table/backlog.component.ts +++ /dev/null @@ -1,160 +0,0 @@ -import { Component } from '@angular/core'; -import { - BackendService, - ScrumTask, - ScrumUserstory, - ScrumStatus, - ScrumCategory, - ScrumSprint, -} from '../../services/backend.service'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { TableComponentBase } from '../../services/table-component.base'; -import { getNumberForPriority } from '../../services/sorting.service'; -import { UserstoryFormComponent } from '../userstory-form/userstory-form.component'; -import { ActivatedRoute } from '@angular/router'; -import { SprintFormComponent } from '../sprint-form/sprint-form.component'; - - -@Component({ - selector: 'app-backlog', - templateUrl: './backlog.component.html', - styleUrls: ['./backlog.component.css'], -}) -export class BacklogComponent extends TableComponentBase< - ScrumUserstory -> { - public tasks: ScrumTask[] = []; - public filterPriority: string | null = null; - public status: ScrumStatus[] = []; - public categories: ScrumCategory[] = []; - public sprints: ScrumSprint[] = []; - - public backlog: ScrumUserstory[] = []; - public choosen: ScrumUserstory[] = []; - - constructor( - private backendService: BackendService, - private modalService: NgbModal, - private route: ActivatedRoute, - ) { - super(); - backendService.getSprints().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.sprints.push(...response.body); - } - }); - backendService.getUserstories().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.backlog = response.body.filter(u => u.sprintid == null); - this.choosen = response.body.filter(u => u.sprintid == this.currentSprint.id); - } - }); - backendService.getTasks().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.tasks.push(...response.body); - } - }); - backendService.getAllStatus().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.status.push(...response.body); - } - }); - backendService.getCategories().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.categories.push(...response.body); - } - }); - } - - public deleteUserstory(userstory: ScrumUserstory) { - this.backendService.deleteUserstory(userstory).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - const index = this.items.indexOf(userstory); - if (index !== -1) { - this.items.splice(index, 1); - } - } - - public openUserstoryForm(editUserstory?: ScrumUserstory) { - const modalRef = this.modalService.open(UserstoryFormComponent, { - backdrop: 'static', - keyboard: true, - size: 'lg' - }); - if (editUserstory === null) { - modalRef.result.then((result) => { - this.items.push(result); - }); - } - modalRef.componentInstance.userstory = editUserstory; - } - - public getNumberOfTasks(userstory: ScrumUserstory) { - return this.tasks.filter((t) => t.userstoryid === userstory.id).length; - } - - getCategoryTitleById(id) { - var category = this.categories.find((x) => x.id === id); - if (!category) { - return 'N/A'; - } - return category.title; - } - - // Sprint-Backlog - - public addToSprintBacklog(userstory: ScrumUserstory) { - this.choosen.push(userstory); - const index = this.backlog.indexOf(userstory); - this.backlog.splice(index, 1); - userstory.sprintid = this.currentSprint.id; - this.backendService.putUserstory(userstory).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } - - public deleteFromSprintBacklog(userstory: ScrumUserstory){ - const index = this.choosen.indexOf(userstory); - this.choosen.splice(index, 1); - this.backlog.push(userstory) - userstory.sprintid = null; - this.backendService.putUserstory(userstory).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } - - public get currentSprint(): ScrumSprint { - const now = Date.now(); - return this.sprints.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now); - } - - public openSprintForm(editSprint?: ScrumSprint) { - const modalRef = this.modalService.open(SprintFormComponent, { - backdrop: 'static', - keyboard: true, - }); - if (editSprint === null) { - modalRef.result.then(result => { - this.items.push(result); - }); - } - modalRef.componentInstance.sprint = editSprint; - } -} diff --git a/src/app/components/backlog-table/backlog.component.css b/src/app/components/backlog/backlog.component.css similarity index 100% rename from src/app/components/backlog-table/backlog.component.css rename to src/app/components/backlog/backlog.component.css diff --git a/src/app/components/backlog/backlog.component.html b/src/app/components/backlog/backlog.component.html new file mode 100644 index 0000000..d1d1592 --- /dev/null +++ b/src/app/components/backlog/backlog.component.html @@ -0,0 +1,97 @@ +
+
+

Backlog

+
+
+
+ +
+
+ +
+
+

Backlog

+
+
+
+ +

+ Aktuell läuft kein Sprint. + Zur Sprint Übersicht +

+
+ +

Aktueller Sprint:

+

Sprint:

+ +
+
+
+
+ +
+
+
+
+
+

{{story.title}}

+
Prio: + {{story.priority}}
+

{{story.content}}

+
+ Category: + {{story.categoryid || "N/A"}} + Status: + {{story.statusid || "N/A"}} +
+
+ +
+
+
+
+
+ +
+
+
+
+

{{story.title}}

+
Prio: + {{story.priority}}
+

{{story.content}}

+
+ Category: + {{story.categoryid || "N/A"}} + Status: + {{story.statusid || "N/A"}} +
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/components/backlog/backlog.component.ts b/src/app/components/backlog/backlog.component.ts new file mode 100644 index 0000000..6581fae --- /dev/null +++ b/src/app/components/backlog/backlog.component.ts @@ -0,0 +1,156 @@ +import { Component } from '@angular/core'; +import { + BackendService, + ScrumUserstory, + ScrumStatus, + ScrumCategory, + ScrumSprint, +} from '../../services/backend.service'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { SprintFormComponent } from '../sprint-form/sprint-form.component'; + + +@Component({ + selector: 'app-backlog', + templateUrl: './backlog.component.html', + styleUrls: ['./backlog.component.css'], +}) + + +export class BacklogComponent{ + public status: ScrumStatus[] = []; + public categories: ScrumCategory[] = []; + public sprints: ScrumSprint[] = []; + public storys: ScrumUserstory[] = []; + public selectedSprint: ScrumSprint; + + /** + * Constructor of the class that initialized the communication with the backend + * @param backendService + * @param modalService + */ + constructor( + private backendService: BackendService, + private modalService: NgbModal, + ) { + backendService.getSprints().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.sprints.push(...response.body); + this.selectedSprint = this.currentSprint; + } + }); + backendService.getUserstories().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.storys.push(...response.body); + } + }); + backendService.getAllStatus().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.status.push(...response.body); + } + }); + backendService.getCategories().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.categories.push(...response.body); + } + }); + } + + /** + * Formats an ISO DateString to a simple date string in the format "DD.MM.YYYY" + * @param isoFormatString date formatted as an ISO DateString (Date objects get converted implicitly) + */ + public toDateString(isoFormatString) { + const date = new Date(isoFormatString); + return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`; + } + + //#region getters + + /** + * Getter that returns an array with all userstories that are in the currently selected sprint. + * The relation to the sprint is determined by the userstory's sprintid. + * If no sprint is selected it just returns an empty array. + */ + public get choosen(): ScrumUserstory[] + { + if(this.selectedSprint === undefined){return null;} + return this.storys.filter(u => u.sprintid == this.selectedSprint.id); + } + + /** + * Getter that returns an array with all userstories that aren't in any sprint. + * The relation to no sprint is determined by the userstory's sprintid being undefined. + */ + public get backlog(): ScrumUserstory[] + { + return this.storys.filter(u => u.sprintid === undefined); + } + + /** + * Getter that returns the current sprint. + * The current sprint is selected by determining if todays date is between the startDate and the endDate of the sprint. + */ + public get currentSprint(): ScrumSprint { + const now = Date.now(); + return this.sprints.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now); + } + + //#endregion getters + + //#region backlogFunctions + + /** + * Adds a userstory to the currently selected sprint by changing it's sprintid to the current sprint's id + * @param userstory userstory object that shall be added to the selected sprint's backlog + */ + public addToSprintBacklog(userstory: ScrumUserstory) { + userstory.sprintid = this.selectedSprint.id; + this.backendService.putUserstory(userstory).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + + /** + * Deletes a userstory from the currently selected sprint by changing it's sprintid to undefined + * @param userstory userstory object that shall be removed from the selected sprint's backlog + */ + public deleteFromSprintBacklog(userstory: ScrumUserstory){ + userstory.sprintid = undefined; + this.backendService.putUserstory(userstory).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + + //#endregion backlogFunctions + + //#region modals + /** + * Opens the SprintForm Modal to let the user create a new sprint. + * The created sprint get pushed to the database and the local sprints array. + */ + public openSprintForm() { + const modalRef = this.modalService.open(SprintFormComponent, { + backdrop: 'static', + keyboard: true, + size: "md", + }); + + modalRef.result.then(result => { + this.sprints.push(result); + }); + } + //#endregion modals +} diff --git a/src/app/components/userstory-inner-table/userstory-inner-table.component.html b/src/app/components/userstory-inner-table/userstory-inner-table.component.html index 2706790..9b4d907 100644 --- a/src/app/components/userstory-inner-table/userstory-inner-table.component.html +++ b/src/app/components/userstory-inner-table/userstory-inner-table.component.html @@ -32,18 +32,22 @@ - - Priorität - - - - - + +
+ Priorität: +
+ {{filterPriority || "All"}} +
+ + +
+
+ + + + + +
Category