From 210c1531dcbc1d2133f9f6439e14c9d11cdc66a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Mon, 6 May 2024 18:16:17 +0200 Subject: [PATCH 01/10] Changed showing backlog item details process --- .../backlog-item-table.component.html | 18 +++++++++++++++--- .../boards/backlog/backlog.component.html | 13 +++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html index 0ff20b54..e6c6e908 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html @@ -1,8 +1,10 @@ + + @@ -10,17 +12,20 @@ + + + @@ -43,11 +48,18 @@

-

- + + + +
Status Title

{{ backlogItem.title }}

Description{{ backlogItem.description }} Type
diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog.component.html index 044c78b2..62e829a1 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.html @@ -10,14 +10,23 @@ {{ sprint.startDate }} - {{ sprint.endDate }} - + + + }
- + +
+ + + + } diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.scss b/corn-frontend/src/app/pages/boards/backlog/backlog.component.scss index 383692e2..1076974d 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.scss +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.scss @@ -1,14 +1,48 @@ @import '../../../../styles/theme'; + $background-color: map-get($dark-color-settings, container-background-color); $background-color-hover: lighten($background-color, 5%); table .table-row:hover { - cursor: pointer; - background-color: $background-color-hover; - outline: 1.5px solid rgba(194, 194, 194, 0.8); + cursor: pointer; + background-color: $background-color-hover; + outline: 1.5px solid rgba(194, 194, 194, 0.8); } .avatar-container { - width: 2.5em; - height: 2.5em; -} \ No newline at end of file + width: 2.5em; + height: 2.5em; +} + +.sprints-menu { + display: inline-flex; + flex-direction: column; + min-width: 180px; + max-width: 280px; + background-color: #282727; + padding: 6px 0; +} + +.sprints-menu-item { + background-color: transparent; + cursor: pointer; + border: none; + @apply p-1.5; + + user-select: none; + min-width: 64px; + line-height: 36px; + + display: flex; + align-items: center; + flex-direction: row; + flex: 1; +} + +.sprints-menu-item:hover { + background-color: #3b3739; +} + +.sprints-menu-item:active { + background-color: #4f4a4c; +} diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts index 38566c10..0800f18f 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnInit, QueryList, ViewChildren, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, OnInit, QueryList, ViewChild, ViewChildren, ViewEncapsulation } from '@angular/core'; import { MatButton } from "@angular/material/button"; import { MatDialog } from "@angular/material/dialog"; import { BacklogFormComponent } from "@pages/boards/backlog/backlog-form/backlog-form.component"; @@ -15,6 +15,10 @@ import { } from "@angular/material/expansion"; import { SprintService } from "@core/services/boards/backlog/sprint/sprint.service"; import { DatePipe, NgForOf } from "@angular/common"; +import { MatMenu, MatMenuItem, MatMenuModule, MatMenuTrigger } from "@angular/material/menu"; +import { CdkContextMenuTrigger, CdkMenu, CdkMenuItem } from "@angular/cdk/menu"; +import { MatIcon } from "@angular/material/icon"; +import { MatRipple } from "@angular/material/core"; @Component({ selector: 'app-backlog', @@ -28,7 +32,12 @@ import { DatePipe, NgForOf } from "@angular/common"; MatExpansionPanelHeader, NgForOf, BacklogItemTableComponent, - DatePipe + DatePipe, + MatMenuModule, + CdkContextMenuTrigger, + CdkMenu, + CdkMenuItem, + MatRipple, ], templateUrl: './backlog.component.html', styleUrl: './backlog.component.scss', @@ -90,4 +99,17 @@ export class BacklogComponent implements OnInit { findBacklogItemTableById(id: string): BacklogItemTableComponent | undefined { return this.backlogItemTableComponents.find(table => table.sprintId.toString() === id); } + + deleteSprint(sprintId: number): void { + this.sprintService + .deleteSprint(sprintId) + .pipe(take(1)) + .subscribe(() => { + this.sprints = this.sprints.filter(sprint => sprint.sprintId !== sprintId); + }); + } + + editSprint(sprint: Sprint): void { + // TODO Add editing sprint data + } } From 02f175986b05907843d254fcffb5471cb7a3045e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Tue, 7 May 2024 13:44:30 +0200 Subject: [PATCH 04/10] Fixed localisation of context menu --- .../src/app/pages/boards/backlog/backlog.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog.component.html index 174ea23b..daf154d7 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.html @@ -1,7 +1,7 @@ @for (sprint of sprints; track sprint) { - - + + {{ sprint.sprintName }} From 5d6cfe5a212d6658b51f7fde46bff9c8abae66ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Tue, 7 May 2024 16:49:30 +0200 Subject: [PATCH 05/10] Added form for editting sprints --- corn-frontend/src/app/app.config.ts | 2 + .../backlog-edit-form.component.html | 54 +++++++++++++++++ .../backlog-edit-form.component.scss | 0 .../backlog-edit-form.component.spec.ts | 23 ++++++++ .../backlog-edit-form.component.ts | 58 +++++++++++++++++++ .../backlog-item-table.component.html | 3 +- .../pages/boards/backlog/backlog.component.ts | 14 +++-- 7 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html create mode 100644 corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.scss create mode 100644 corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.spec.ts create mode 100644 corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts diff --git a/corn-frontend/src/app/app.config.ts b/corn-frontend/src/app/app.config.ts index c7f53e87..28b3f8bf 100644 --- a/corn-frontend/src/app/app.config.ts +++ b/corn-frontend/src/app/app.config.ts @@ -7,6 +7,7 @@ import { provideAnimations } from '@angular/platform-browser/animations'; import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; import { ErrorInterceptor } from '@core/interceptors/error.interceptor'; import { KeycloakAngularModule, KeycloakBearerInterceptor, KeycloakService } from 'keycloak-angular'; +import { provideNativeDateAdapter } from "@angular/material/core"; function initializeKeycloak(keycloak: KeycloakService) { return () => @@ -50,5 +51,6 @@ export const appConfig: ApplicationConfig = { deps: [KeycloakService] }, KeycloakService, + provideNativeDateAdapter() ] }; diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html new file mode 100644 index 00000000..a6d9b7ff --- /dev/null +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html @@ -0,0 +1,54 @@ +
+
+
+ {{ data.sprintName }} +
+ + + Sprint Name + + + + + + Sprint Goal + + + + {{ goal.value.length }} / 500 + + + + Start Date + + + + + + + + + + End Date + + + + + + + +
+ +
+ + + +
+
diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.scss b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.spec.ts b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.spec.ts new file mode 100644 index 00000000..e93df9f8 --- /dev/null +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BacklogEditFormComponent } from './backlog-edit-form.component'; + +describe('BacklogEditFormComponent', () => { + let component: BacklogEditFormComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [BacklogEditFormComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(BacklogEditFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts new file mode 100644 index 00000000..ffb54212 --- /dev/null +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts @@ -0,0 +1,58 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { + MAT_DIALOG_DATA, + MatDialogActions, + MatDialogContent, + MatDialogModule, + MatDialogRef +} from "@angular/material/dialog"; +import { Sprint } from "@interfaces/boards/backlog/sprint"; +import { MatButtonModule } from "@angular/material/button"; +import { MatFormFieldModule } from "@angular/material/form-field"; +import { MatInputModule } from "@angular/material/input"; +import { MatDatepickerModule } from "@angular/material/datepicker"; +import { MatNativeDateModule } from "@angular/material/core"; +import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angular/forms"; + +@Component({ + selector: 'app-backlog-edit-form', + standalone: true, + imports: [ + MatDialogContent, + MatDialogActions, + MatButtonModule, + MatDialogModule, + MatFormFieldModule, + MatInputModule, + MatDatepickerModule, + MatNativeDateModule, + ReactiveFormsModule + ], + templateUrl: './backlog-edit-form.component.html', + styleUrl: './backlog-edit-form.component.scss' +}) +export class BacklogEditFormComponent implements OnInit { + + protected formGroup !: FormGroup; + + constructor(@Inject(MAT_DIALOG_DATA) public data: Sprint, + public dialogRef: MatDialogRef, + private formBuilder: FormBuilder) { + } + + ngOnInit(): void { + this.formGroup = this.formBuilder.group({ + sprintName: new FormControl(this.data.sprintName, [ + Validators.required + ]), + goal: new FormControl(this.data.sprintDescription, []), + startDate: new FormControl(this.data.startDate, [ + Validators.required + ]), + endDate: new FormControl(this.data.endDate, [ + Validators.required + ]) + }); + } + +} diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html index 2a2940fb..e89b4c62 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-item-table/backlog-item-table.component.html @@ -22,7 +22,7 @@

{{ backlogItem.title }}

Description - {{ backlogItem.description }} + {{ backlogItem.description }} @@ -60,7 +60,6 @@

{{ backlogItem.title }}

diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts index 0800f18f..482d5ebd 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnInit, QueryList, ViewChild, ViewChildren, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, OnInit, QueryList, ViewChildren, ViewEncapsulation } from '@angular/core'; import { MatButton } from "@angular/material/button"; import { MatDialog } from "@angular/material/dialog"; import { BacklogFormComponent } from "@pages/boards/backlog/backlog-form/backlog-form.component"; @@ -15,10 +15,10 @@ import { } from "@angular/material/expansion"; import { SprintService } from "@core/services/boards/backlog/sprint/sprint.service"; import { DatePipe, NgForOf } from "@angular/common"; -import { MatMenu, MatMenuItem, MatMenuModule, MatMenuTrigger } from "@angular/material/menu"; +import { MatMenuModule } from "@angular/material/menu"; import { CdkContextMenuTrigger, CdkMenu, CdkMenuItem } from "@angular/cdk/menu"; -import { MatIcon } from "@angular/material/icon"; import { MatRipple } from "@angular/material/core"; +import { BacklogEditFormComponent } from "@pages/boards/backlog/backlog-edit-form/backlog-edit-form.component"; @Component({ selector: 'app-backlog', @@ -110,6 +110,12 @@ export class BacklogComponent implements OnInit { } editSprint(sprint: Sprint): void { - // TODO Add editing sprint data + const dialogRef = this.dialog.open(BacklogEditFormComponent, { + enterAnimationDuration: '300ms', + exitAnimationDuration: '100ms', + data: sprint + }); + + dialogRef.afterClosed().pipe(take(1)).subscribe(); } } From 7071895ca6db5df3c264ca75de1cda54f174a764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Tue, 7 May 2024 20:16:01 +0200 Subject: [PATCH 06/10] Added updating sprints details and fixed deleting sprint --- .../api/sprint/SprintServiceImpl.java | 36 ++++++++----- .../interfaces/BacklogItemRepository.java | 7 +++ .../sprint/interfaces/SprintRepository.java | 4 +- .../api/sprint/SprintServiceTest.java | 2 +- corn-frontend/src/app/app.config.ts | 4 +- .../backlog/sprint-request.interfaces.ts | 6 +++ .../boards/backlog/sprint/sprint.service.ts | 6 +-- .../backlog-edit-form.component.html | 27 ++++++++-- .../backlog-edit-form.component.ts | 24 ++++++++- .../pages/boards/backlog/backlog.component.ts | 52 ++++++++++++++++++- 10 files changed, 143 insertions(+), 25 deletions(-) create mode 100644 corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts diff --git a/corn-backend/src/main/java/dev/corn/cornbackend/api/sprint/SprintServiceImpl.java b/corn-backend/src/main/java/dev/corn/cornbackend/api/sprint/SprintServiceImpl.java index ab04e025..a74abd9f 100644 --- a/corn-backend/src/main/java/dev/corn/cornbackend/api/sprint/SprintServiceImpl.java +++ b/corn-backend/src/main/java/dev/corn/cornbackend/api/sprint/SprintServiceImpl.java @@ -3,6 +3,7 @@ import dev.corn.cornbackend.api.sprint.data.SprintRequest; import dev.corn.cornbackend.api.sprint.data.SprintResponse; import dev.corn.cornbackend.api.sprint.interfaces.SprintService; +import dev.corn.cornbackend.entities.backlog.item.interfaces.BacklogItemRepository; import dev.corn.cornbackend.entities.project.Project; import dev.corn.cornbackend.entities.project.interfaces.ProjectRepository; import dev.corn.cornbackend.entities.sprint.Sprint; @@ -13,6 +14,7 @@ import dev.corn.cornbackend.utils.exceptions.sprint.InvalidSprintDateException; import dev.corn.cornbackend.utils.exceptions.sprint.SprintDoesNotExistException; import dev.corn.cornbackend.utils.exceptions.sprint.SprintEndDateMustBeAfterStartDate; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -38,10 +40,11 @@ public class SprintServiceImpl implements SprintService { private static final String SPRINTS_ON_PAGE = "Sprints found on page : {}"; private final SprintRepository sprintRepository; private final ProjectRepository projectRepository; + private final BacklogItemRepository backlogItemRepository; private final SprintMapper sprintMapper; @Override - public final SprintResponse addNewSprint(SprintRequest sprintRequest, User user) { + public SprintResponse addNewSprint(SprintRequest sprintRequest, User user) { if (sprintRequest.endDate().isBefore(sprintRequest.startDate())) { throw new SprintEndDateMustBeAfterStartDate(sprintRequest.startDate(), sprintRequest.endDate()); @@ -73,7 +76,7 @@ public final SprintResponse addNewSprint(SprintRequest sprintRequest, User user) } @Override - public final SprintResponse getSprintById(long sprintId, User user) { + public SprintResponse getSprintById(long sprintId, User user) { log.info("Getting sprint with id: {} for user: {}", sprintId, user); Sprint sprint = resolveSprintForProjectMember(sprintId, user); @@ -84,7 +87,7 @@ public final SprintResponse getSprintById(long sprintId, User user) { } @Override - public final List getSprintsOnPage(int page, long projectId, User user) { + public List getSprintsOnPage(int page, long projectId, User user) { log.info("Getting sprints in project {} on page: {} for user: {}", projectId, page, user); Pageable pageable = PageRequest.of(page, SPRINTS_PER_PAGE); @@ -97,7 +100,7 @@ public final List getSprintsOnPage(int page, long projectId, Use } @Override - public final SprintResponse updateSprintsName(String name, long sprintId, User user) { + public SprintResponse updateSprintsName(String name, long sprintId, User user) { log.info("Updating sprint with id: {} name to: {}", sprintId, name); Sprint sprintToUpdate = sprintRepository.findByIdWithProjectOwner(sprintId, user) @@ -115,7 +118,7 @@ public final SprintResponse updateSprintsName(String name, long sprintId, User u } @Override - public final SprintResponse updateSprintsDescription(String description, long sprintId, User user) { + public SprintResponse updateSprintsDescription(String description, long sprintId, User user) { log.info("Updating sprint with id: {} description to: {}", sprintId, description); Sprint sprintToUpdate = sprintRepository.findByIdWithProjectOwner(sprintId, user) @@ -133,10 +136,10 @@ public final SprintResponse updateSprintsDescription(String description, long sp } @Override - public final SprintResponse updateSprintsStartDate(LocalDate startDate, long sprintId, User user) { + public SprintResponse updateSprintsStartDate(LocalDate startDate, long sprintId, User user) { log.info("Updating sprint with id: {} startDate to: {}", sprintId, startDate); - if (sprintRepository.existsEndDateBeforeDate(startDate)) { + if (sprintRepository.existsSprintPeriodWithGivenDate(startDate)) { throw new InvalidSprintDateException("Start date cannot be after any existing sprint's end date"); } Sprint sprintToUpdate = sprintRepository.findByIdWithProjectOwner(sprintId, user) @@ -157,10 +160,10 @@ public final SprintResponse updateSprintsStartDate(LocalDate startDate, long spr } @Override - public final SprintResponse updateSprintsEndDate(LocalDate endDate, long sprintId, User user) { + public SprintResponse updateSprintsEndDate(LocalDate endDate, long sprintId, User user) { log.info("Updating sprint with id: {} endDate to: {}", sprintId, endDate); - if (sprintRepository.existsEndDateBeforeDate(endDate)) { + if (sprintRepository.existsSprintPeriodWithGivenDate(endDate)) { throw new InvalidSprintDateException("End date cannot be before any existing sprint's end date"); } Sprint sprintToUpdate = sprintRepository.findByIdWithProjectOwner(sprintId, user) @@ -181,7 +184,8 @@ public final SprintResponse updateSprintsEndDate(LocalDate endDate, long sprintI } @Override - public final SprintResponse deleteSprint(long sprintId, User user) { + @Transactional + public SprintResponse deleteSprint(long sprintId, User user) { log.info("Deleting sprint with id: {}", sprintId); Sprint sprintToDelete = sprintRepository.findByIdWithProjectOwner(sprintId, user) @@ -189,6 +193,12 @@ public final SprintResponse deleteSprint(long sprintId, User user) { log.info("Found sprint to delete: {}", sprintToDelete); + log.info("Moving all sprints backlog items to backlog..."); + + backlogItemRepository.updateSprintItemsToBacklog(sprintToDelete); + + log.info("Deleting sprint..."); + sprintRepository.deleteById(sprintId); log.info("Deleted sprint with id: {}", sprintToDelete); @@ -197,7 +207,7 @@ public final SprintResponse deleteSprint(long sprintId, User user) { } @Override - public final List getCurrentAndFutureSprints(long projectId, User user) { + public List getCurrentAndFutureSprints(long projectId, User user) { log.info("Getting current and future sprints for project with id: {}", projectId); Project project = resolveProjectForProjectMember(projectId, user); @@ -217,7 +227,7 @@ public final List getCurrentAndFutureSprints(long projectId, Use } @Override - public final Page getSprintsAfterSprint(long sprintId, Pageable pageable, User user) { + public Page getSprintsAfterSprint(long sprintId, Pageable pageable, User user) { log.info("Getting sprints after: {}", sprintId); Sprint sprint = resolveSprintForProjectMember(sprintId, user); @@ -233,7 +243,7 @@ public final Page getSprintsAfterSprint(long sprintId, Pageable } @Override - public final Page getSprintsBeforeSprint(long sprintId, Pageable pageable, User user) { + public Page getSprintsBeforeSprint(long sprintId, Pageable pageable, User user) { log.info("Getting sprints before: {}", sprintId); Sprint sprint = resolveSprintForProjectMember(sprintId, user); diff --git a/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java b/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java index ae37fa92..1557e337 100644 --- a/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java +++ b/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java @@ -7,6 +7,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @@ -53,4 +54,10 @@ public interface BacklogItemRepository extends JpaRepository * @return List of BacklogItems associated with the Project */ Page findByProjectAndSprintIsNull(Project project, Pageable pageable); + + @Modifying + @Query(""" + update BacklogItem b SET b.sprint = null where b.sprint = :sprint + """) + void updateSprintItemsToBacklog(Sprint sprint); } diff --git a/corn-backend/src/main/java/dev/corn/cornbackend/entities/sprint/interfaces/SprintRepository.java b/corn-backend/src/main/java/dev/corn/cornbackend/entities/sprint/interfaces/SprintRepository.java index 05241751..e2ae51f2 100644 --- a/corn-backend/src/main/java/dev/corn/cornbackend/entities/sprint/interfaces/SprintRepository.java +++ b/corn-backend/src/main/java/dev/corn/cornbackend/entities/sprint/interfaces/SprintRepository.java @@ -94,9 +94,9 @@ select count(s) > 0 from Sprint s */ @Query(""" select count(*) > 0 from Sprint s - where s.endDate < :date + where s.endDate <= :date and s.startDate >= :date """) - boolean existsEndDateBeforeDate(LocalDate date); + boolean existsSprintPeriodWithGivenDate(LocalDate date); /** * Finds all sprints with given project that have end date after specified date and pages them diff --git a/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java b/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java index e25a7a9e..56bbb636 100644 --- a/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java +++ b/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java @@ -447,7 +447,7 @@ final void test_updateSprintsStartDate_shouldThrowInvalidSprintDateException() { User owner = ADD_SPRINT_DATA.project().getOwner(); // when - when(sprintRepository.existsEndDateBeforeDate(newStartDate)) + when(sprintRepository.existsSprintPeriodWithGivenDate(newStartDate)) .thenReturn(true); // then diff --git a/corn-frontend/src/app/app.config.ts b/corn-frontend/src/app/app.config.ts index 28b3f8bf..b726a357 100644 --- a/corn-frontend/src/app/app.config.ts +++ b/corn-frontend/src/app/app.config.ts @@ -8,6 +8,7 @@ import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@a import { ErrorInterceptor } from '@core/interceptors/error.interceptor'; import { KeycloakAngularModule, KeycloakBearerInterceptor, KeycloakService } from 'keycloak-angular'; import { provideNativeDateAdapter } from "@angular/material/core"; +import { DatePipe } from "@angular/common"; function initializeKeycloak(keycloak: KeycloakService) { return () => @@ -51,6 +52,7 @@ export const appConfig: ApplicationConfig = { deps: [KeycloakService] }, KeycloakService, - provideNativeDateAdapter() + provideNativeDateAdapter(), + DatePipe ] }; diff --git a/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts b/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts new file mode 100644 index 00000000..7d4e7d11 --- /dev/null +++ b/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts @@ -0,0 +1,6 @@ +export interface SprintRequest { + sprintName: string; + goal: string; + startDate: string; + endDate: string; +} \ No newline at end of file diff --git a/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts b/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts index b840f771..47e049c1 100644 --- a/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts +++ b/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts @@ -43,11 +43,11 @@ export class SprintService { }); } - editSprintEndDate(sprint: Sprint): Observable { + editSprintEndDate(endDate: string, sprintId: number): Observable { return this.http.put(ApiUrl.UPDATE_SPRINTS_END_DATE, {}, { params: { - endDate: sprint.endDate, - sprintId: sprint.sprintId + endDate: endDate, + sprintId: sprintId } }); } diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html index a6d9b7ff..cded0168 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html @@ -7,7 +7,16 @@ Sprint Name - + + + {{ sprintsName.value.length }} / 50 + + @if (formGroup.controls['sprintName'].hasError('required')) { + + The sprints name is required. + + } @@ -32,6 +41,12 @@ + + @if (formGroup.controls['startDate'].hasError('required')) { + + The start date is required. + + } @@ -43,12 +58,18 @@ + + @if (formGroup.controls['endDate'].hasError('required')) { + + The end date is required. + + }
- + - +
diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts index ffb54212..1b851f19 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts @@ -13,6 +13,8 @@ import { MatInputModule } from "@angular/material/input"; import { MatDatepickerModule } from "@angular/material/datepicker"; import { MatNativeDateModule } from "@angular/material/core"; import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angular/forms"; +import { SprintRequest } from "@interfaces/boards/backlog/sprint-request.interfaces"; +import { DatePipe } from "@angular/common"; @Component({ selector: 'app-backlog-edit-form', @@ -37,7 +39,8 @@ export class BacklogEditFormComponent implements OnInit { constructor(@Inject(MAT_DIALOG_DATA) public data: Sprint, public dialogRef: MatDialogRef, - private formBuilder: FormBuilder) { + private formBuilder: FormBuilder, + private datePipe: DatePipe) { } ngOnInit(): void { @@ -55,4 +58,23 @@ export class BacklogEditFormComponent implements OnInit { }); } + submitSprintEdit(): void { + if (this.formGroup.invalid) { + return; + } + const sprintsName: string = this.formGroup.get('sprintName')?.value; + const goal: string = this.formGroup.get('goal')?.value; + const startDate: Date = this.formGroup.get('startDate')?.value; + const endDate: Date = this.formGroup.get('endDate')?.value; + + const sprintRequest: SprintRequest = { + sprintName: sprintsName, + goal: goal, + startDate: this.datePipe.transform(startDate, "yyyy-MM-dd") as string, + endDate: this.datePipe.transform(endDate, "yyyy-MM-dd") as string + }; + console.log(sprintRequest); + + this.dialogRef.close(sprintRequest); + } } diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts index 482d5ebd..2ed3f192 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts @@ -19,6 +19,7 @@ import { MatMenuModule } from "@angular/material/menu"; import { CdkContextMenuTrigger, CdkMenu, CdkMenuItem } from "@angular/cdk/menu"; import { MatRipple } from "@angular/material/core"; import { BacklogEditFormComponent } from "@pages/boards/backlog/backlog-edit-form/backlog-edit-form.component"; +import { SprintRequest } from "@interfaces/boards/backlog/sprint-request.interfaces"; @Component({ selector: 'app-backlog', @@ -116,6 +117,55 @@ export class BacklogComponent implements OnInit { data: sprint }); - dialogRef.afterClosed().pipe(take(1)).subscribe(); + dialogRef.afterClosed().pipe(take(1)).subscribe((newSprintData: SprintRequest) => { + if (!newSprintData) { + return; + } + if (newSprintData.sprintName !== sprint.sprintName) { + sprint.sprintName = this.updateSprintsName(newSprintData, sprint); + } + if (newSprintData.goal !== sprint.sprintDescription) { + sprint.sprintDescription = this.updateSprintsGoal(newSprintData, sprint); + } + if (newSprintData.startDate !== sprint.startDate) { + sprint.startDate = this.updateSprintStartDate(newSprintData, sprint); + } + if (newSprintData.endDate !== sprint.endDate) { + sprint.endDate = this.updateSprintEndDate(newSprintData, sprint); + } + this.sprints = this.sprints.map(s => s.sprintId === sprint.sprintId ? sprint : s); + }); + } + + private updateSprintsName(newSprintData: SprintRequest, sprint: Sprint): string { + this.sprintService + .editSprintName(newSprintData.sprintName, sprint.sprintId) + .pipe(take(1)) + .subscribe(); + return newSprintData.sprintName; + } + + private updateSprintsGoal(newSprintData: SprintRequest, sprint: Sprint): string { + this.sprintService + .editSprintDescription(newSprintData.goal, sprint.sprintId) + .pipe(take(1)) + .subscribe(); + return newSprintData.goal; + } + + private updateSprintStartDate(newSprintData: SprintRequest, sprint: Sprint): string { + this.sprintService + .editSprintStartDate(newSprintData.startDate, sprint.sprintId) + .pipe(take(1)) + .subscribe(); + return newSprintData.startDate; + } + + private updateSprintEndDate(newSprintData: SprintRequest, sprint: Sprint): string { + this.sprintService + .editSprintEndDate(newSprintData.endDate, sprint.sprintId) + .pipe(take(1)) + .subscribe(); + return newSprintData.endDate; } } From 54684fd809961c39c407217b9310281017d1a6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Tue, 7 May 2024 20:30:08 +0200 Subject: [PATCH 07/10] Added delete sprint dialog --- .../pages/boards/backlog/backlog.component.ts | 23 ++++++++++++++----- .../delete-dialog/delete-dialog.component.ts | 22 +++++++++--------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts index 2ed3f192..ef452374 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.ts @@ -20,6 +20,7 @@ import { CdkContextMenuTrigger, CdkMenu, CdkMenuItem } from "@angular/cdk/menu"; import { MatRipple } from "@angular/material/core"; import { BacklogEditFormComponent } from "@pages/boards/backlog/backlog-edit-form/backlog-edit-form.component"; import { SprintRequest } from "@interfaces/boards/backlog/sprint-request.interfaces"; +import { DeleteDialogComponent } from "@pages/utils/delete-dialog/delete-dialog.component"; @Component({ selector: 'app-backlog', @@ -102,12 +103,22 @@ export class BacklogComponent implements OnInit { } deleteSprint(sprintId: number): void { - this.sprintService - .deleteSprint(sprintId) - .pipe(take(1)) - .subscribe(() => { - this.sprints = this.sprints.filter(sprint => sprint.sprintId !== sprintId); - }); + const dialogRef = this.dialog.open(DeleteDialogComponent, { + enterAnimationDuration: '300ms', + exitAnimationDuration: '100ms', + }); + + dialogRef.afterClosed().pipe(take(1)).subscribe((result) => { + if (result === false) { + return; + } + this.sprintService + .deleteSprint(sprintId) + .pipe(take(1)) + .subscribe(() => { + this.sprints = this.sprints.filter(sprint => sprint.sprintId !== sprintId); + }); + }); } editSprint(sprint: Sprint): void { diff --git a/corn-frontend/src/app/pages/utils/delete-dialog/delete-dialog.component.ts b/corn-frontend/src/app/pages/utils/delete-dialog/delete-dialog.component.ts index 7ae914d0..bf964543 100644 --- a/corn-frontend/src/app/pages/utils/delete-dialog/delete-dialog.component.ts +++ b/corn-frontend/src/app/pages/utils/delete-dialog/delete-dialog.component.ts @@ -3,17 +3,17 @@ import { MatDialogActions, MatDialogClose, MatDialogContent, MatDialogTitle } fr import { MatButton } from "@angular/material/button"; @Component({ - selector: 'app-delete-dialog', - standalone: true, - imports: [ - MatDialogTitle, - MatDialogContent, - MatDialogActions, - MatButton, - MatDialogClose - ], - templateUrl: './delete-dialog.component.html', - styleUrl: './delete-dialog.component.scss' + selector: 'app-delete-dialog', + standalone: true, + imports: [ + MatDialogTitle, + MatDialogContent, + MatDialogActions, + MatButton, + MatDialogClose + ], + templateUrl: './delete-dialog.component.html', + styleUrl: './delete-dialog.component.scss' }) export class DeleteDialogComponent { From c241ec160d58e43d3b3ff0faa584b8e9363db277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Tue, 7 May 2024 20:53:28 +0200 Subject: [PATCH 08/10] Added creation of sprints --- corn-frontend/src/app/core/enum/api-url.ts | 2 + .../backlog/sprint-edit-data.interfaces.ts | 6 ++ .../backlog/sprint-request.interfaces.ts | 5 +- .../boards/backlog/sprint/sprint.service.ts | 6 ++ .../backlog-edit-form.component.html | 5 +- .../backlog-edit-form.component.ts | 7 +-- .../boards/backlog/backlog.component.html | 5 ++ .../pages/boards/backlog/backlog.component.ts | 55 ++++++++++++++++--- 8 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 corn-frontend/src/app/core/interfaces/boards/backlog/sprint-edit-data.interfaces.ts diff --git a/corn-frontend/src/app/core/enum/api-url.ts b/corn-frontend/src/app/core/enum/api-url.ts index 60523fe5..a55809e4 100644 --- a/corn-frontend/src/app/core/enum/api-url.ts +++ b/corn-frontend/src/app/core/enum/api-url.ts @@ -17,6 +17,7 @@ export enum ApiUrl { UPDATE_SPRINTS_START_DATE = SPRINT_API_URL + '/updateSprintsStartDate', UPDATE_SPRINTS_END_DATE = SPRINT_API_URL + '/updateSprintsEndDate', UPDATE_SPRINTS_DESCRIPTION = SPRINT_API_URL + '/updateSprintsDescription', + CREATE_SPRINT = SPRINT_API_URL + '/addSprint', GET_PROJECT_MEMBERS = PROJECT_MEMBER_API_URL + '/getMembers', @@ -24,4 +25,5 @@ export enum ApiUrl { UPDATE_COMMENT = BACKLOG_ITEM_COMMENT_API_RUL + '/update', CREATE_COMMENT = BACKLOG_ITEM_COMMENT_API_RUL + '/add', DELETE_COMMENT = BACKLOG_ITEM_COMMENT_API_RUL + '/delete', + } diff --git a/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-edit-data.interfaces.ts b/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-edit-data.interfaces.ts new file mode 100644 index 00000000..9015c839 --- /dev/null +++ b/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-edit-data.interfaces.ts @@ -0,0 +1,6 @@ +export interface SprintEditData { + sprintName: string; + goal: string; + startDate: string; + endDate: string; +} \ No newline at end of file diff --git a/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts b/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts index 7d4e7d11..b285e16a 100644 --- a/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts +++ b/corn-frontend/src/app/core/interfaces/boards/backlog/sprint-request.interfaces.ts @@ -1,6 +1,7 @@ export interface SprintRequest { sprintName: string; - goal: string; + description: string; startDate: string; endDate: string; -} \ No newline at end of file + projectId: number; +} diff --git a/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts b/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts index 47e049c1..454b9f4c 100644 --- a/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts +++ b/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts @@ -5,6 +5,8 @@ import { Sprint } from "@interfaces/boards/backlog/sprint"; import { ApiUrl } from "@core/enum/api-url"; import { StorageService } from "@core/services/storage.service"; import { StorageKey } from "@core/enum/storage-key.enum"; +import { SprintEditData } from "@interfaces/boards/backlog/sprint-edit-data.interfaces"; +import { SprintRequest } from "@interfaces/boards/backlog/sprint-request.interfaces"; @Injectable({ providedIn: 'root' @@ -78,4 +80,8 @@ export class SprintService { } }); } + + createSprint(result: SprintRequest): Observable { + return this.http.post(ApiUrl.CREATE_SPRINT, result); + } } \ No newline at end of file diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html index cded0168..9e9ba796 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.html @@ -70,6 +70,9 @@
- +
diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts index 1b851f19..4759e806 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts +++ b/corn-frontend/src/app/pages/boards/backlog/backlog-edit-form/backlog-edit-form.component.ts @@ -13,7 +13,7 @@ import { MatInputModule } from "@angular/material/input"; import { MatDatepickerModule } from "@angular/material/datepicker"; import { MatNativeDateModule } from "@angular/material/core"; import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angular/forms"; -import { SprintRequest } from "@interfaces/boards/backlog/sprint-request.interfaces"; +import { SprintEditData } from "@interfaces/boards/backlog/sprint-edit-data.interfaces"; import { DatePipe } from "@angular/common"; @Component({ @@ -63,17 +63,16 @@ export class BacklogEditFormComponent implements OnInit { return; } const sprintsName: string = this.formGroup.get('sprintName')?.value; - const goal: string = this.formGroup.get('goal')?.value; + const goal: string = this.formGroup.get('goal')?.value || ""; const startDate: Date = this.formGroup.get('startDate')?.value; const endDate: Date = this.formGroup.get('endDate')?.value; - const sprintRequest: SprintRequest = { + const sprintRequest: SprintEditData = { sprintName: sprintsName, goal: goal, startDate: this.datePipe.transform(startDate, "yyyy-MM-dd") as string, endDate: this.datePipe.transform(endDate, "yyyy-MM-dd") as string }; - console.log(sprintRequest); this.dialogRef.close(sprintRequest); } diff --git a/corn-frontend/src/app/pages/boards/backlog/backlog.component.html b/corn-frontend/src/app/pages/boards/backlog/backlog.component.html index daf154d7..04db7d19 100644 --- a/corn-frontend/src/app/pages/boards/backlog/backlog.component.html +++ b/corn-frontend/src/app/pages/boards/backlog/backlog.component.html @@ -33,6 +33,11 @@
+ +
{ + dialogRef.afterClosed().pipe(take(1)).subscribe((newSprintData: SprintEditData) => { if (!newSprintData) { return; } @@ -148,7 +154,42 @@ export class BacklogComponent implements OnInit { }); } - private updateSprintsName(newSprintData: SprintRequest, sprint: Sprint): string { + createNewSprint(): void { + const newSprint: Sprint = { + sprintId: -1, + projectId: -1, + sprintName: `Sprint ${ this.sprints.length + 1 }`, + sprintDescription: '', + startDate: '', + endDate: '' + } + const dialogRef = this.dialog.open(BacklogEditFormComponent, { + enterAnimationDuration: '300ms', + exitAnimationDuration: '100ms', + data: newSprint + }); + + dialogRef.afterClosed().pipe(take(1)).subscribe((result: SprintEditData) => { + if (!result) { + return; + } + const request: SprintRequest = { + projectId: this.localStorage.getValueFromStorage(StorageKey.PROJECT_ID), + sprintName: result.sprintName, + description: result.goal, + startDate: result.startDate, + endDate: result.endDate + } + this.sprintService + .createSprint(request) + .pipe(take(1)) + .subscribe((sprint: Sprint) => { + this.sprints.push(sprint); + }); + }); + } + + private updateSprintsName(newSprintData: SprintEditData, sprint: Sprint): string { this.sprintService .editSprintName(newSprintData.sprintName, sprint.sprintId) .pipe(take(1)) @@ -156,7 +197,7 @@ export class BacklogComponent implements OnInit { return newSprintData.sprintName; } - private updateSprintsGoal(newSprintData: SprintRequest, sprint: Sprint): string { + private updateSprintsGoal(newSprintData: SprintEditData, sprint: Sprint): string { this.sprintService .editSprintDescription(newSprintData.goal, sprint.sprintId) .pipe(take(1)) @@ -164,7 +205,7 @@ export class BacklogComponent implements OnInit { return newSprintData.goal; } - private updateSprintStartDate(newSprintData: SprintRequest, sprint: Sprint): string { + private updateSprintStartDate(newSprintData: SprintEditData, sprint: Sprint): string { this.sprintService .editSprintStartDate(newSprintData.startDate, sprint.sprintId) .pipe(take(1)) @@ -172,7 +213,7 @@ export class BacklogComponent implements OnInit { return newSprintData.startDate; } - private updateSprintEndDate(newSprintData: SprintRequest, sprint: Sprint): string { + private updateSprintEndDate(newSprintData: SprintEditData, sprint: Sprint): string { this.sprintService .editSprintEndDate(newSprintData.endDate, sprint.sprintId) .pipe(take(1)) From d6fe9c51d8185509f6428899fdbb63f30e636d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Tue, 7 May 2024 21:00:23 +0200 Subject: [PATCH 09/10] Fixed test --- .../backlog/item/interfaces/BacklogItemRepository.java | 7 ++++++- .../dev/corn/cornbackend/api/sprint/SprintServiceTest.java | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java b/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java index 3fc7e925..95a41f0a 100644 --- a/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java +++ b/corn-backend/src/main/java/dev/corn/cornbackend/entities/backlog/item/interfaces/BacklogItemRepository.java @@ -63,9 +63,14 @@ public interface BacklogItemRepository extends JpaRepository */ Page findByProjectAndSprintIsNull(Project project, Pageable pageable); + /** + * Moves all backlog items from sprint to backlog + * + * @param sprint Sprint to move BacklogItems from + */ @Modifying @Query(""" - update BacklogItem b SET b.sprint = null where b.sprint = :sprint + UPDATE BacklogItem b SET b.sprint = null WHERE b.sprint = :sprint """) void updateSprintItemsToBacklog(Sprint sprint); diff --git a/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java b/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java index 56bbb636..8e6f3de3 100644 --- a/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java +++ b/corn-backend/src/test/java/dev/corn/cornbackend/api/sprint/SprintServiceTest.java @@ -2,6 +2,7 @@ import dev.corn.cornbackend.api.sprint.data.SprintRequest; import dev.corn.cornbackend.api.sprint.data.SprintResponse; +import dev.corn.cornbackend.entities.backlog.item.interfaces.BacklogItemRepository; import dev.corn.cornbackend.entities.project.interfaces.ProjectRepository; import dev.corn.cornbackend.entities.sprint.Sprint; import dev.corn.cornbackend.entities.sprint.interfaces.SprintMapper; @@ -43,8 +44,13 @@ class SprintServiceTest { @Mock private SprintRepository sprintRepository; + @Mock private ProjectRepository projectRepository; + + @Mock + private BacklogItemRepository backlogItemRepository; + @Mock private SprintMapper MAPPER; From f45afa1e3c54ef749983b517f9b700535b6943be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20P=C3=B3=C5=82torak?= Date: Wed, 8 May 2024 16:13:23 +0200 Subject: [PATCH 10/10] Optimized imports --- .../app/core/services/boards/backlog/sprint/sprint.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts b/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts index 454b9f4c..5492fcc6 100644 --- a/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts +++ b/corn-frontend/src/app/core/services/boards/backlog/sprint/sprint.service.ts @@ -5,7 +5,6 @@ import { Sprint } from "@interfaces/boards/backlog/sprint"; import { ApiUrl } from "@core/enum/api-url"; import { StorageService } from "@core/services/storage.service"; import { StorageKey } from "@core/enum/storage-key.enum"; -import { SprintEditData } from "@interfaces/boards/backlog/sprint-edit-data.interfaces"; import { SprintRequest } from "@interfaces/boards/backlog/sprint-request.interfaces"; @Injectable({