Sha256: e9c2ac909359c628f25afdbd28a04890a45c5a0f7bd2486e6308a939eb8d06b5

Contents?: true

Size: 1.69 KB

Versions: 17

Compression:

Stored size: 1.69 KB

Contents

<%= alchemy_form_for([:admin, node], id: "node_form") do |f| %>
  <% if node.new_record? && node.root? %>
    <%= f.input :menu_type,
      collection: Alchemy::Language.current.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.PageSelect.ItemAdded", (event) => {
    const page = event.detail
    nodeName.setAttribute("placeholder", page.name)
    nodeUrl.value = page.url_path
    nodeUrl.setAttribute("disabled", "disabled")
  })

  form.addEventListener("Alchemy.PageSelect.ItemRemoved", (event) => {
    nodeName.removeAttribute("placeholder")
    nodeUrl.value = ""
    nodeUrl.removeAttribute("disabled")
  })
</script>

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
alchemy_cms-7.1.13 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.12 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.11 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.10 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.9 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.8 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.7 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.6 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.5 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.4 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.3 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.2 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.1 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.0 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.0.pre.rc1 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.0.pre.b2 app/views/alchemy/admin/nodes/_form.html.erb
alchemy_cms-7.1.0.pre.b1 app/views/alchemy/admin/nodes/_form.html.erb