Files
fizzy/app/controllers/cards_controller.rb
T
Jason Zimdars 5560976091 Merge branch 'main' into gold-cards
* main:
  Try a segmented toggle for engagement
  Fix tests
  Rework min card design and meta section for all cards
  Move `title` to the `img` element so we get hover in both cases
  Remove sorting filter UI
  Sort Considering and Doing by `updated_at`
  Restore comment action icon
  Fix dot escaping container
  Seen cards should be flat
  Ensure overflow cards are hidden
  Arrow needs to match derived color
  Dialog target needs to be present
  This isn't necessary in the mini card template
  Revert "The button and dialog need not render in previews"
2025-04-10 16:42:45 -05:00

56 lines
1.4 KiB
Ruby

require "ostruct"
class CardsController < ApplicationController
include CollectionScoped, FilterScoped
skip_before_action :set_collection, only: :index
before_action :set_card, only: %i[ show edit update destroy ]
PAGE_SIZE = 50
def index
@considering = page_and_filter_for @filter.with(engagement_status: "considering", indexed_by: "latest"), per_page: PAGE_SIZE
@doing = page_and_filter_for @filter.with(engagement_status: "doing", indexed_by: "latest"), per_page: PAGE_SIZE
@closed = page_and_filter_for @filter.with(indexed_by: "closed"), per_page: PAGE_SIZE
end
def create
redirect_to @collection.cards.create!
end
def show
end
def edit
end
def destroy
@card.destroy!
redirect_to cards_path(collection_ids: [ @card.collection ]), notice: deleted_notice
end
def update
@card.update! card_params
redirect_to @card
end
private
def set_card
@card = @collection.cards.find params[:id]
end
def page_and_filter_for(filter, per_page: nil, cards: filter.cards)
OpenStruct.new \
page: GearedPagination::Recordset.new(cards, per_page:).page(1),
filter: filter
end
def card_params
params.expect(card: [ :status, :title, :color, :due_on, :image, :draft_comment, tag_ids: [] ])
end
def deleted_notice
"Card deleted" unless @card.creating?
end
end