aboutsummaryrefslogtreecommitdiff
path: root/src/guff/views/ecrs/test.ecr
blob: d36b62c61f325ef40c41384e972d57392ab578df (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<h1><%= h(TITLE) %></h1>

<%
  [{
    id:     "draft",
    name:   "Draft Posts",

    actions: [{
      id:   "posted",
      name: "Post",
    }, {
      id:   "deleted",
      name: "Delete",
    }],
  }, {
    id:     "posted",
    name:   "Posted",

    actions: [{
      id:   "draft",
      name: "Draft",
    }, {
      id:   "deleted",
      name: "Delete",
    }],
  }, {
    id:     "deleted",
    name:   "Deleted Posts",

    actions: [{
      id: "draft",
      name: "Draft",
    }],
  }].each do |kind|
%>
  <h2><%=
    h(kind[:name] as String)
  %></h2>

  <table>
    <thead>
      <tr>
        <th>ID</th>
        <th>Created At</th>
        <th>Name</th>
        <th>Body</th>
        <th colspan='2'>Actions</th>
      </tr>
    </thead>

    <tbody><% posts(kind[:id] as String).rows.each do |post| %>
      <tr>
        <td><%=
          h(post.row["post_id"].to_s)
        %></td>

        <td><%=
          h(post.row["created_at"].to_s)
        %></td>

        <td><%=
          h(post.row["name"].to_s)
        %></td>

        <td><%=
          post.row["body"].to_s
        %></td>

        <% (kind[:actions] as Array(Hash(Symbol, String))).each do |a| %>
          <td>
            <form
              method='post'
              action='/test/set_state'
            >
              <input
                type='hidden'
                name='post_id'
                value='<%= h(post.row["post_id"].to_s) %>'
              />

              <input
                type='hidden'
                name='state'
                value='<%= a[:id] %>'
              </input>

              <input
                type='submit'
                title='Set post to <%= h(a[:id]) %>..'
                value='<%= h(a[:name]) %>'
              />
            </form>
          </td>
        <% end %>
      </tr>
    <% end %></tbody>
  </table>
<% end %>

<div class='section'>
  <form
    method='post'
    action='/test/add_post'
  >
    <label for='post-name'>
      Name
    </label><br/>

    <input
      type='text'
      id='post-name'
      name='name'
      title='Enter post title'
      placeholder='Post Title'
      value=''
    />

    <br/>

    <label for='post-slug'>
      Slug
    </label><br/>

    <input
      type='text'
      id='post-slug'
      name='slug'
      title='Enter post slug'
      placeholder='post-slug'
      value=''
    />

    <br/>

    <label for='post-body'>
      Post Body
    </label><br/>

    <textarea
      id='post-body'
      name='body'
    ></textarea>

    <br/>

    <label for='post-tags'>
      Tags (space-delimited)
    </label><br/>

    <input
      type='text'
      id='post-tags'
      name='tags'
      title='Enter post tags'
      placeholder='some post tags'
      value=''
    />

    <br/>

    <input
      type='submit'
      title='Create new post.'
      value='Add Post'
    />
  </form>
</div>