Sha256: 9cd35fcccfb3dc06ce66d98077e5e6d1a3c803c3a9eea335846d7b22300e7dd4

Contents?: true

Size: 1.2 KB

Versions: 31

Compression:

Stored size: 1.2 KB

Contents

<% 
   root = Section.root.first
   root.full_path = root.name
   @sections = []
   @sections << root
   @sections += root.all_children_with_name
   @sections.each {|s| s.full_path = "/" + s.full_path unless s == root }
  @block.attachment_file_path = @block.attachment.file_path if @block.attachment_file_path.blank? && !@block.new_record?
%>
<% content_for :html_head do %>
  <% javascript_tag do %>
    jQuery(function($) {
      <% if @block.new_record? %>
        var sectionIdPathMap = <%= @sections.inject({}){|map, sec| map[sec.id.to_s] = sec.path.sub(/\/$/,''); map}.to_json %>
        $('#file_block_attachment_file, #file_block_attachment_section_id').change(function(){ 
            $('#file_block_attachment_file_path').val(sectionIdPathMap[$('#file_block_attachment_section_id').val()]+'/'+$.cms.sanitizeFileName($('#file_block_attachment_file').val())) 
        })
      <% end %>      
    });    
  <% end %>
<% end %>

<%= f.cms_text_field :name %>
<%= f.cms_file_field :attachment_file, :label => "File" %>
<%= f.cms_drop_down :attachment_section_id, 
  @sections.map{|s| [s.full_path, s.id]}, 
  :label => "Section" %>
<%= f.cms_text_field :attachment_file_path, :label => "Path" %>
<%= f.cms_tag_list %>

Version data entries

31 entries across 31 versions & 10 rubygems

Version Path
SFEley-browsercms-3.0.2 app/views/cms/file_blocks/_form.html.erb
buzzware-browsercms-3.0.2 app/views/cms/file_blocks/_form.html.erb
coredumplings-browsercms-3.0.0 app/views/cms/file_blocks/_form.html.erb
nate-browsercms-3.0.210 app/views/cms/file_blocks/_form.html.erb
nate-browsercms-3.0.211 app/views/cms/file_blocks/_form.html.erb
we5-browsercms-3.0.1.1 app/views/cms/file_blocks/_form.html.erb
webficient-browsercms-3.0.1 app/views/cms/file_blocks/_form.html.erb
webficient-browsercms-3.0.2 app/views/cms/file_blocks/_form.html.erb
webficient-browsercms-3.0.3 app/views/cms/file_blocks/_form.html.erb
webficient-browsercms-3.0.4 app/views/cms/file_blocks/_form.html.erb
browsercms-3.1.4 app/views/cms/file_blocks/_form.html.erb
browsercms-3.1.3 app/views/cms/file_blocks/_form.html.erb
bf4-browsercms-3.1.0 app/views/cms/file_blocks/_form.html.erb
drujensen-browsercms-3.2.0 app/views/cms/file_blocks/_form.html.erb
browsercms-3.1.2 app/views/cms/file_blocks/_form.html.erb
browsercms-3.1.1 app/views/cms/file_blocks/_form.html.erb
browsercms-3.1.0 app/views/cms/file_blocks/_form.html.erb
we5-browsercms-3.1.0 app/views/cms/file_blocks/_form.html.erb
browsercms-3.0.6 app/views/cms/file_blocks/_form.html.erb
browsercms-3.0.5 app/views/cms/file_blocks/_form.html.erb