Skip to content

Commit d1a1963

Browse files
authored
Add Drop button to item cards (#27)
- Add markDropped method to WatchListService - Add Drop button to ItemCardComponent (disabled when completed/dropped) - Handle markDropped in home and item-list components
1 parent 5a5a0ef commit d1a1963

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/app/components/home/home.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ItemCardComponent } from '../item-card/item-card.component';
2222
[item]="nextSeries()!"
2323
(markWatched)="markSeriesWatched()"
2424
(markCompleted)="markSeriesCompleted()"
25+
(markDropped)="markSeriesDropped()"
2526
/>
2627
</div>
2728
} @else {
@@ -43,6 +44,7 @@ import { ItemCardComponent } from '../item-card/item-card.component';
4344
[item]="nextMovie()!"
4445
(markWatched)="markMovieWatched()"
4546
(markCompleted)="markMovieCompleted()"
47+
(markDropped)="markMovieDropped()"
4648
/>
4749
</div>
4850
} @else {
@@ -123,4 +125,20 @@ export class HomeComponent {
123125
this.updateNextItems();
124126
}
125127
}
128+
129+
markSeriesDropped(): void {
130+
const series = this.nextSeries();
131+
if (series) {
132+
this.watchListService.markDropped(series.id);
133+
this.updateNextItems();
134+
}
135+
}
136+
137+
markMovieDropped(): void {
138+
const movie = this.nextMovie();
139+
if (movie) {
140+
this.watchListService.markDropped(movie.id);
141+
this.updateNextItems();
142+
}
143+
}
126144
}

src/app/components/item-card/item-card.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ import { statusBadgeClass } from '../../utils/status.utils';
5858
Mark Completed
5959
</button>
6060
}
61+
<button (click)="markDropped.emit()" [disabled]="item().status === 'completed' || item().status === 'dropped'" class="px-4 py-2 border border-light-border dark:border-dark-border rounded bg-light-bg-secondary dark:bg-dark-bg-secondary text-light-font dark:text-dark-font cursor-pointer text-sm hover:not-disabled:bg-light-bg-tertiary dark:hover:not-disabled:bg-dark-bg-tertiary disabled:opacity-50 disabled:cursor-not-allowed">
62+
Drop
63+
</button>
6164
</div>
6265
</div>
6366
`
@@ -68,6 +71,7 @@ export class ItemCardComponent {
6871
item = input.required<Item>();
6972
markWatched = output<void>();
7073
markCompleted = output<void>();
74+
markDropped = output<void>();
7175
protected statusBadgeClass = statusBadgeClass;
7276

7377
progressPercent = computed(() => {

src/app/components/item-list/item-list.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import { ItemCardComponent } from '../item-card/item-card.component';
5858
[item]="item"
5959
(markWatched)="markWatched(item.id)"
6060
(markCompleted)="markCompleted(item.id)"
61+
(markDropped)="markDropped(item.id)"
6162
/>
6263
} @empty {
6364
<p class="text-center text-light-font-muted dark:text-dark-font-muted p-8">
@@ -112,4 +113,8 @@ export class ItemListComponent {
112113
markCompleted(itemId: string): void {
113114
this.watchListService.markCompleted(itemId);
114115
}
116+
117+
markDropped(itemId: string): void {
118+
this.watchListService.markDropped(itemId);
119+
}
115120
}

src/app/services/watch-list.service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ export class WatchListService {
131131
});
132132
}
133133

134+
markDropped(itemId: string): void {
135+
const item = this.getItemById(itemId);
136+
if (!item) return;
137+
138+
this.updateItem({
139+
...item,
140+
status: 'dropped'
141+
});
142+
}
143+
134144
getItemById(itemId: string): Item | undefined {
135145
const data = this.storageService.getData();
136146
return data.items[itemId];

0 commit comments

Comments
 (0)