summaryrefslogtreecommitdiff
path: root/app/views/nodes/new.html.erb
blob: f55745473e89df3ba56f2850691bfda30b1b0429 (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
<h1>Create new node</h1>

<% if @node.errors.any? %>
  <div class="error_messages">
    <ul><% @node.errors.full_messages.each do |msg| %><li><%= msg.to_s.gsub("Slug", "Title") %></li><% end %></ul>
  </div>
<% end %>

<p>What kind of node do you want to create?</p>

<%= form_tag nodes_path do %>
<table id="new_node">
  <tr>
    <td class="description">Type</td>
    <td>
    <% CccConventions::NODE_KINDS.each do |kind, config| %>
      <p>
        <%= radio_button_tag :kind, kind, kind == "generic",
          data: { path_prefix: resolve_kind_text(config[:path_prefix]) } %>
        <%= resolve_kind_text(config[:label]) %>
        <% if config[:hint] %>
          <span class="field_hint"><%= resolve_kind_text(config[:hint]) %></span>
        <% end %>
      </p>
    <% end %>
    </td>
  </tr>
  <tr>
    <td class="description">Title</td>
    <td><%= text_field_tag :title %>
    <span class="field_hint">A URL slug will be generated from this automatically. You can review or adjust it afterward under the "metadata" section's Slug field.</span>
    </td>
  </tr>
  <tr id="parent_search_field">
    <td class="description">Parent</td>
    <td>
      <%= text_field_tag :parent_search_term, @parent_name %>
      <%= hidden_field_tag :parent_id, @parent_id %>
      <div id="search_results">

      </div>
    </td>
  </tr>
  <tr>
  <td class="description">Resulting path</td>
  <td>
    <span id="resulting_path">—</span>
    <button type="button" id="copy_resulting_path" class="unselected">copy</button>
    <span class="field_hint">This preview updates as you type. The final path can still be changed afterward by editing the title (for the last segment) or moving the node to a different parent (for everything before it).</span>
  </td>
  </tr>
  <tr>
    <td></td>
    <td class="right"><%= submit_tag "Create" %></td>
  </tr>
</table>
<% end %>