Skip to content

Commit

Permalink
Changed how the dragged ba
Browse files Browse the repository at this point in the history
cklog item and placeholder look. Also reformatted code to make future updates to backlog item type easier
  • Loading branch information
Higunio320 committed Mar 26, 2024
1 parent 3175b20 commit 12e77d4
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 155 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="flex flex-row space-x-8 items-center w-full h-14 bg-stone-700 rounded-md shadow-lg shadow-amber-400/30">
<h2 class="ml-2">{{backlogItem.title}}</h2>
<h2>{{backlogItem.description}}</h2>
<app-status-select [backlogItem]="backlogItem"></app-status-select>
<app-backlog-type [backlogItem]="backlogItem"></app-backlog-type>
<div class="w-10 h-10">
<app-user-avatar [user]="backlogItem.assignee" [isEmpty]="!backlogItem.assignee"></app-user-avatar>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.avatar-container {
width: 2.5em;
height: 2.5em;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BacklogDragComponent } from './backlog-drag.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [BacklogDragComponent]
})
.compileComponents();

fixture = TestBed.createComponent(BacklogDragComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, Input } from '@angular/core';
import { BacklogItem } from "@interfaces/boards/backlog/backlog.item";
import { StatusSelectComponent } from "@pages/boards/backlog/backlog-item-table/status-select/status-select.component";
import { BacklogTypeComponent } from "@pages/boards/backlog/backlog-item-table/backlog-type/backlog-type.component";
import { UserAvatarComponent } from "@pages/utils/user-avatar/user-avatar.component";

@Component({
selector: 'app-backlog-drag',
standalone: true,
imports: [
StatusSelectComponent,
BacklogTypeComponent,
UserAvatarComponent
],
templateUrl: './backlog-drag.component.html',
styleUrl: './backlog-drag.component.scss'
})
export class BacklogDragComponent {

@Input() backlogItem!: BacklogItem;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Status</th>
<td mat-cell *matCellDef="let backlogItem">
<div class="status-background" [ngClass]="getStatusClass(backlogItem.status)">
<mat-select [panelWidth]="null" [(value)]="backlogItem.status">
@for (status of statuses; track status) {
<mat-option (click)="updateBacklogItem(backlogItem)"
class="status-panel-{{getStatusClass(status)}}" [value]="status">{{ status.replace('_', ' ')}}
</mat-option>
}
</mat-select>
</div>
<app-status-select [backlogItem]="backlogItem" (statusChange)="updateBacklogItem($event)"></app-status-select>
</td>
</ng-container>

Expand All @@ -29,28 +21,7 @@
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Type</th>
<td mat-cell *matCellDef="let backlogItem">
@switch (backlogItem.itemType) {
@case (BacklogItemType.BUG) {
<div matTooltip="Bug" class="type-icon" style="background-color: #ff0000;">
<ng-icon name="bootstrapBugFill"></ng-icon>
</div>
}
@case (BacklogItemType.STORY) {
<div matTooltip="Story" class="type-icon" style="background-color: #005f9f;">
<ng-icon name="featherBook"></ng-icon>
</div>
}
@case (BacklogItemType.TASK) {
<div matTooltip="Task" class="type-icon" style="background-color: #00910a; ">
<ng-icon name="matTask"></ng-icon>
</div>
}
@case (BacklogItemType.EPIC) {
<div matTooltip="Epic" class="type-icon" style="background-color: #5200af;">
<ng-icon name="octContainer"></ng-icon>
</div>
}
}
<app-backlog-type [backlogItem]="backlogItem"></app-backlog-type>
</td>
</ng-container>

Expand All @@ -75,6 +46,8 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr class="table-row" mat-row *matRowDef="let row; columns: displayedColumns;"
(mouseover)="hoveredRow = row" (mouseleave)="hoveredRow = null" cdkDrag>
<app-backlog-drag *cdkDragPreview [backlogItem]="row"></app-backlog-drag>
<div class="bg-stone-500 border-dotted border-2 border-stone-400 transition-transform h-12 w-full" *cdkDragPlaceholder></div>
</tr>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ import { MatTooltip } from "@angular/material/tooltip";
import { BacklogItemList } from "@interfaces/boards/backlog/backlog.item.list";
import {
CdkDrag,
CdkDragDrop,
CdkDragDrop, CdkDragPlaceholder,
CdkDragPreview,
CdkDropList,
moveItemInArray,
transferArrayItem
} from "@angular/cdk/drag-drop";
import { MatTab } from "@angular/material/tabs";
import { BacklogComponent } from "@pages/boards/backlog/backlog.component";
import { StatusSelectComponent } from "@pages/boards/backlog/backlog-item-table/status-select/status-select.component";
import { BacklogTypeComponent } from "@pages/boards/backlog/backlog-item-table/backlog-type/backlog-type.component";
import { BacklogDragComponent } from "@pages/boards/backlog/backlog-item-table/backlog-drag/backlog-drag.component";

@Component({
selector: 'app-backlog-item-table',
Expand Down Expand Up @@ -64,7 +67,11 @@ import { BacklogComponent } from "@pages/boards/backlog/backlog.component";
MatSortHeader,
CdkDropList,
CdkDrag,
CdkDragPreview
CdkDragPreview,
StatusSelectComponent,
BacklogTypeComponent,
BacklogDragComponent,
CdkDragPlaceholder
],
templateUrl: './backlog-item-table.component.html',
styleUrl: './backlog-item-table.component.scss',
Expand Down Expand Up @@ -94,16 +101,6 @@ export class BacklogItemTableComponent implements AfterViewInit, OnDestroy{
hoveredRow: BacklogItem | null = null;
isLoading: boolean = true;

statuses: BacklogItemStatus[] = [
BacklogItemStatus.TODO,
BacklogItemStatus.IN_PROGRESS,
BacklogItemStatus.DONE
];

getStatusClass(status: BacklogItemStatus): string {
return status.replace(' ', '_');
}

deleteItem(item: BacklogItem): void {
this.backlogItemService.deleteBacklogItem(item).pipe(take(1)).subscribe((deletedItem: BacklogItem) => {
this.dataToDisplay = this.dataToDisplay.filter((i) => i !== item);
Expand Down Expand Up @@ -177,9 +174,10 @@ export class BacklogItemTableComponent implements AfterViewInit, OnDestroy{
if(previousTable) {
previousTable.table.renderRows();
}
event.container.data[event.currentIndex].sprintId = this.sprintId;
this.updateBacklogItem(event.container.data[event.currentIndex]);
}
event.container.data[event.currentIndex].sprintId = this.sprintId;
this.updateBacklogItem(event.container.data[event.currentIndex]);

this.table.renderRows();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@switch (backlogItem.itemType) {
@case (BacklogItemType.BUG) {
<div matTooltip="Bug" class="type-icon" style="background-color: #ff0000;">
<ng-icon name="bootstrapBugFill"></ng-icon>
</div>
}
@case (BacklogItemType.STORY) {
<div matTooltip="Story" class="type-icon" style="background-color: #005f9f;">
<ng-icon name="featherBook"></ng-icon>
</div>
}
@case (BacklogItemType.TASK) {
<div matTooltip="Task" class="type-icon" style="background-color: #00910a; ">
<ng-icon name="matTask"></ng-icon>
</div>
}
@case (BacklogItemType.EPIC) {
<div matTooltip="Epic" class="type-icon" style="background-color: #5200af;">
<ng-icon name="octContainer"></ng-icon>
</div>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.type-icon {
height: 2em;
width: 2em;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BacklogTypeComponent } from './backlog-type.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [BacklogTypeComponent]
})
.compileComponents();

fixture = TestBed.createComponent(BacklogTypeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, Input } from '@angular/core';
import { BacklogItem } from "@interfaces/boards/backlog/backlog.item";
import { BacklogItemType } from "@core/enum/BacklogItemType";
import { MatTooltip } from "@angular/material/tooltip";
import { NgIcon } from "@ng-icons/core";

@Component({
selector: 'app-backlog-type',
standalone: true,
imports: [
MatTooltip,
NgIcon
],
templateUrl: './backlog-type.component.html',
styleUrl: './backlog-type.component.scss'
})
export class BacklogTypeComponent {

@Input() backlogItem!: BacklogItem;
protected readonly BacklogItemType = BacklogItemType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="status-background" [ngClass]="getStatusClass(backlogItem.status)">
<mat-select [panelWidth]="null" [(value)]="backlogItem.status">
@for (status of statuses; track status) {
<mat-option (click)="updateBacklogItem()"
class="status-panel-{{getStatusClass(status)}}" [value]="status">{{ status.replace('_', ' ')}}
</mat-option>
}
</mat-select>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
mat-select {
width: max-content;
margin-left: 0.5em;
margin-right: 0.5em;
}

.status-background {
border-radius: 5px;
width: max-content;
height: 2em;
display: flex;
align-items: center;
justify-content: center;
}

.status-background:hover {
cursor: pointer;
}

.status-background.TODO {
background-color: #464444;
}

.status-background.TODO:hover {
background-color: lighten(#464444, 10%);
}

.status-background.IN_PROGRESS {
background-color: rgba(67,183,239,0.35);
}

.status-background.IN_PROGRESS:hover {
background-color: lighten(rgba(67,183,239,0.35), 10%);
}

.status-background.DONE {
background-color: rgba(14,168,4,0.35);
}

.status-background.DONE:hover {
background-color: lighten(rgba(14,168,4,0.35), 10%);
}

.status-panel {
font-size: 0.5em;
width: 3em;
}

.status-panel-TODO {
background-color: #464444!important;
}

.status-panel-TODO:hover {
background-color: lighten(#464444, 10%)!important;
}

.status-panel-IN_PROGRESS {
background-color: rgba(67,183,239,0.35)!important;
}

.status-panel-IN_PROGRESS:hover {
background-color: lighten(rgba(67,183,239,0.35), 10%)!important;
}

.status-panel-DONE {
background-color: rgba(14,168,4, 0.55)!important;
}

.status-panel-DONE:hover {
background-color: lighten(rgba(14,168,4, 0.55), 10%)!important;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { StatusSelectComponent } from './status-select.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [StatusSelectComponent]
})
.compileComponents();

fixture = TestBed.createComponent(StatusSelectComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

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

0 comments on commit 12e77d4

Please sign in to comment.