summaryrefslogtreecommitdiff
path: root/templates/inventoryListing.hamlet
blob: 7c2c06b2075d59e7afa0e452a7160bd0a8de00fc (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
<div .table>
  <div .tr .sepBelow>
    <div .th>Description
    <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 Entity itemId Item{..} <- stock
    $if Just itemId == (preview updateItem =<< formState)
      $with Just UpdateForm{..} <- formState
         <form .tr .color action=@{UpdateItemR fsUpdateItem}##{toPathPiece fsUpdateItem} method=post enctype=#{fsUpdateEncoding} ##{toPathPiece fsUpdateItem}>
           ^{fsUpdateForm}
           <div .td>
             <button type=submit>
               Save Changes
    $else
      <div .tr .color ##{toPathPiece itemId}>
        <div .kind>#{itemKind}
        <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