summaryrefslogtreecommitdiff
path: root/templates/inventoryListing.hamlet
blob: f0ff1e4fded1eaca8b146e57dcd5605939a9661d (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
52
53
54
55
<div .table>
  <div .tr .sepBelow>
    <div .itemH>
    <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}>
        <div .td>
        ^{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}>
           <div .itemId>#{humanId itemId}
           ^{fsUpdateForm}
           <div .td>
             <button type=submit>
               Save Changes
    $else
      <div .tr .color ##{toPathPiece itemId}>
        <div .itemId>#{humanId 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