Sha256: 51e4bb11fc7d2a0e69cf5604d145bd991d11f9405b1f2e1790b030ba15370f54

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 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) 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

8 entries across 8 versions & 1 rubygems

Version Path
alchemy_cms-7.2.8 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.7 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.6 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.5 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.4 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.3 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.2 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.2.1 app/views/alchemy/admin/nodes/_form.html.erb