summaryrefslogtreecommitdiff
path: root/templates/inventoryListing.hamlet
blob: 3be43dba2783b45a3e9960c9ae1feae5fe838400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<div .table>
  <div .tr .sepBelow>
    <div .th>Item
    <div .th>Type
    <div .th>Bought
    <div .th>Expires
    <div .th>Opened
    <div .th>Actions
  $if isJust (preview insertForm =<< formState)
    $with Just InsertForm{..} <- formState
      <form .tr .sepBelow action=@{InventoryListingR} method=post enctype=#{fsInsertEncoding}>
        ^{fsInsertForm}
        <div .td>
          <button type=submit>
            Insert
  $forall WithType (Entity itemId Item{..}) itemType <- stock
    $if Just itemId == (preview updateId =<< formState)
      $with Just UpdateForm{..} <- formState
         <form .tr .color action=@{UpdateItemR fsUpdateId}##{toPathPiece fsUpdateId} method=post enctype=#{fsUpdateEncoding} ##{toPathPiece fsUpdateId}>
           ^{fsUpdateForm}
           <div .td>
             <button type=submit>
               Save Changes
    $else
      <div .tr .color ##{toPathPiece itemId}>
        <div .kind>#{itemKind}
        <div .type>#{itemType}
        <div .td .day>
          $maybe bought <- itemBought
            #{dayFormat bought}
          $nothing
            <hr>
        <div .td .day>
          $maybe expires <- itemExpires
            #{dayFormat expires}
          $nothing
            <hr>
        <div .td .day>
          $maybe opened <- itemOpened
            #{dayFormat opened}
          $nothing
            <form method=post action=@{OpenItemR itemId}>
              <button type=submit>
                Open
        <div .td>
          <form method=get action=@{UpdateItemR itemId}##{toPathPiece itemId}>
            <button type=submit>
              Edit
          <form method=post action=@{DeleteItemR itemId}>
            <button type=submit>
              Delete