<% @f = f %>

<div class="box tabular">
  <div class="splitcontent">
    <div class="splitcontentleft">
      <p><%= f.text_field :title, :size => '100%', :label => l(:label_cms_title) %></p>
      <p><%= f.text_field :name, :size => 30, :required => true, :label => l(:label_cms_name)  %></p>
      <p><%= f.text_field :slug, :size => 30, :required => true, :label => l(:label_cms_slug)  %></p>
      <% if @page.valid_parents.any? %>
        <p>
          <%= f.select :parent_id, pages_options_for_select(@page.valid_parents), :include_blank => true, :label => :label_cms_page_parent %>
          <%= javascript_tag do %>
            $(document).ready(function(){
              $('#page_parent_id').select2({ containerCssClass : "page-select icon icon-page" });
            });
          <% end %>
        </p>
      <% end %>
      <p><%= f.select :status_id, cms_statuses_for_select, :label => l(:label_cms_status)  %></p>
      <p>
        <%= render :partial => 'cms_pages/form_tags' %>
      </p>
    </div>

    <div class="splitcontentright">
      <p><%= f.select :visibility, cms_visibilities_for_select(@page.visibility || "public"), :label => l(:label_cms_visibility)  %></p>
      <p>
        <%= f.select :layout_id, cms_layouts_for_select %>
      </p>
      <p>
        <%= f.check_box :is_cached, :label => l(:label_cms_is_cached) %>
      </p>
      <p>
        <%= f.select :filter_id, filter_options_for_select(@page.filter_id), {:label => l(:label_cms_filter)}, {:id => "text_filter_select", :onchange => "editor.setOption('mode', $('option:selected', this).data('mode'));return false"} %>
      </p>
      <p>
        <%= f.date_field :page_date, :size => 10, :label =>  l(:label_cms_page_date)  %>
        <%= calendar_for('page_page_date') %>
      </p>
    </div>
  </div>

  <p id="attachments_form">
    <label><%= l(:label_attachment_plural) %></label>
    <%= render :partial => 'attachments/form', :locals => {:container => @page} %>
  </p>

  <% edit_page_tabs = [{:name => 'content', :partial => 'content_tab', :label => :label_cms_content}]  %>
  <% edit_page_tabs << {:name => 'page_parts', :partial => 'page_parts_tab', :label => :label_cms_part_plural} if @page.parts.any? %>
  <% edit_page_tabs << {:name => 'page_fields', :partial => 'page_fields_tab', :label => :label_cms_field_plural} %>

  <% @pages = @page.children_pages.includes(:layout, :author, :children_pages) %>
  <% edit_page_tabs << {:name => 'sub_pages', :partial => 'sub_pages_tab', :label => :label_cms_sub_pages} unless @pages.blank? %>

  <%= render_tabs edit_page_tabs %>

</div>



<% content_for :header_tags do %>
  <%= code_mirror_tags %>
  <%= javascript_include_tag 'redmine_cms', :plugin => 'redmine_cms'  %>
<% end %>

