Sha256: af2d706418df566600f539785271bd8bae6cd577c62c0802a838653e08092ff0

Contents?: true

Size: 1.7 KB

Versions: 6

Compression:

Stored size: 1.7 KB

Contents

<%= alchemy_form_for([:admin, node], id: "node_form") do |f| %>
  <% if node.new_record? && node.root? %>
    <%= f.input :menu_type,
      collection: Alchemy::Current.language.available_menu_names.map { |n| [I18n.t(n, scope: [:alchemy, :menu_names]), n] },
      include_blank: false,
      input_html: { is: 'alchemy-select' } %>
  <% else %>
    <% if node.root? %>
      <%= f.input :name %>
    <% else %>
      <%= f.input :name, input_html: {
        autofocus: true,
        value: node.page && node.read_attribute(:name).blank? ? nil : node.name,
        placeholder: node.page ? node.page.name : nil
      } %>
      <%= render Alchemy::Admin::PageSelect.new(node.page, allow_clear: true, query_params: {contentpages: true}) do %>
        <%= f.input :page_id, label: Alchemy::Page.model_name.human %>
      <% end %>
      <%= f.input :url, input_html: { disabled: node.page }, hint: Alchemy.t(:node_url_hint) %>
      <%= f.input :title %>
      <%= f.input :nofollow %>
      <%= f.input :external %>
      <%= f.hidden_field :parent_id %>
    <% end %>
  <% end %>
  <%= f.hidden_field :language_id %>
  <%= f.submit button_label %>
<% end %>

<script>
  const nodeName = document.getElementById("node_name")
  const nodeUrl = document.getElementById("node_url")
  const form = document.getElementById("node_form")

  form.addEventListener("Alchemy.RemoteSelect.Change", (event) => {
    const page = event.detail.added

    if (page) {
      nodeName.setAttribute("placeholder", page.name)
      nodeUrl.value = page.url_path
      nodeUrl.setAttribute("disabled", "disabled")
    } else {
      nodeName.removeAttribute("placeholder")
      nodeUrl.value = ""
      nodeUrl.removeAttribute("disabled")
    }
  })
</script>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.3.4 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.3.3 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.3.2 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.3.1 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.3.0 app/views/alchemy/admin/nodes/_form.html.erb