In this episode, we're adding the ability to archive whole columns on our board, similar to how we previously archived cards. We start by making some changes in the database: we create a migration to add an archived_at
timestamp column to our columns table, just like we did before for cards.
Then we update our Column model to support archiving, by copying over the necessary casts and scopes from the Card model. This allows us to filter out archived columns when displaying the list.
Next, we focus on the UI. We create a new DropdownButton
component (instead of a link) for our dropdown menu, so users can click to archive a column. We hook this button up using Livewire by adding a method to handle the archive action. When you click it, the column gets archived by setting its archived_at
value.
After someone archives a column, we want the board to update and hide that column. To keep things simple for now, we trigger a full board refresh by dispatching a board updated
event and listening for that in the parent component, even though it's not the most efficient solution.
By the end, you can click a button in the column's dropdown to archive it, and it will immediately disappear from the board view!