[worked on pagination functionality thomashartman1@gmail.com**20080920170623] hunk ./src/Controller.hs 107 - ++ map (\num -> ( ("job" ++ (show num)), Just "$0") ) [1..2000] + ++ map (\num -> ( ("job" ++ (show num)), Just "$0") ) [1..200] hunk ./src/Controller.hs 109 - jobTable = paintTable (Just ["project","budget"]) jobCells + jobTable = paintTable (Just ["project","budget"]) jobCells (Just (page,resPerPage)) (Just "Job Results: ") + where page = 1 + resPerPage=10 hunk ./src/View.hs 93 -paintTable :: Maybe [String] -> [[String]] -> String -paintTable mbHeaderCells tablecells = table trows - where trows = maybe rows ( (++rows) . paintHeaderTr) mbHeaderCells - rows = paintTrs $ tablecells - +--paintTable :: Maybe [String] -> [[String]] -> String +paintTable mbHeaderCells tableCells0 mbPagination mbRes = + let + trows = maybe rows ( (++rows) . paintHeaderTr) mbHeaderCells + rows = paintTrs $ ( tableCells :: [[String]] ) + tableCells = fromTo 1 toRecord tableCells0 + fromTo fr to xs = take to . drop (fr-1) $ xs + toRecord = maybe len + snd + mbPagination + paginationBar :: String + res = maybe "" id mbRes + paginationBar = res ++ ( concat . intersperse " | " . map f $ paginationRanges ) + where f xs = "" ++ (show . head $ xs) ++ " to " ++ (show . last $ xs) ++ "" + + paginationRanges :: [[Int]] + paginationRanges = maybe + [[1..len]] + (\(p,rsp) -> splitList rsp ([1..len]) ) + mbPagination + len = length tableCells0 + in ( table trows ) ++ paginationBar + +splitList :: Int -> [a] -> [[a]] +splitList _ [] = [] +splitList n l@(x:xs) = + let (a,b') = genericSplitAt n l + b = splitList n b' + in a : b hunk ./templates/jobs.st 3 - $ postJob $

+
$ postJob $

hunk ./todo 6 + + menulink function truncates spaces in viewJobs.