-- |
-- Module:     Yesod.TableView.Widget
-- Copyright:  (c) 2010 Ertugrul Soeylemez
-- License:    BSD3
-- Maintainer: Ertugrul Soeylemez <es@ertes.de>
-- Stability:  experimental
--
-- Class for datatypes displayable in a table view as widgets.

module Yesod.TableView.Widget
    ( -- Table view widgets.
      TableViewWidget(..)
    )
    where

import Yesod


-- | This class defines how types will be rendered in the table view.

class TableViewWidget val where
    -- | Table header (wrapped in a @thead@ element).  This function
    -- will be called once per table.
    tableHeader :: val -> GWidget sub s ()

    -- | Table row.  This function will be called once for each entry in
    -- the table.  All rows will be rendered inside of a @tbody@
    -- element.
    tableRecord :: Int -> Key val -> val -> GWidget sub s ()