refinery/refinerycms

View on GitHub
resources/app/views/refinery/admin/resources/insert.html.erb

Summary

Maintainability
Test Coverage
<% user_can_modify_resources = current_refinery_user.has_plugin?("refinery_files") %>
<div class="clearfix">
  <div id="dialog_menu_left">
    <% if (any_resources = @resources.any?) %>
      <span id="existing_resource_radio" class="radio<%= ' selected_radio' if @resource.errors.empty? %>">
        <input type="radio" name="resource_type" value="existing_resource" id="resource_type_existing" <%= 'checked="true"'.html_safe if @resource.errors.empty? %> />
        <label for="resource_type_existing" class="stripped">
          <%= t('.existing') %>
        </label>
      </span>
    <% end %>
    <% if user_can_modify_resources %>
      <span id="upload_resource_radio" class="radio<%= ' selected_radio' if @resource.errors.any? or @resources.empty? %>">
        <input type="radio" name="resource_type" value="upload_resource" id="resource_type_upload" <%= 'checked="true"'.html_safe if @resources.empty? or @resource.errors.any? %> />
        <label for="resource_type_upload" class="stripped">
          <%= t('.new') %>
        </label>
      </span>
    <% end %>
  </div>

  <div id="dialog_main">
    <% if any_resources or user_can_modify_resources %>
      <%= render 'existing_resource' if any_resources %>

      <% if user_can_modify_resources %>
        <div id="upload_resource_area" class="dialog_area" <%= 'style="display:none;"'.html_safe if any_resources and @resource.errors.empty? %>>
          <%= render 'form', :insert => true %>
        </div>
      <% end %>
    <% else %>
      <% flash.now[:error] = t('.no_files') %>
      <%= render '/refinery/admin/form_actions', :f => nil,
                 :cancel_url => '',
                 :hide_cancel => false,
                 :hide_delete => true,
                 :hide_submit => true,
                 :cancel_button_text => t('close', :scope => 'refinery.admin.form_actions'),
                 :cancel_title => nil %>
    <% end %>
  </div>
</div>

<% content_for :javascripts do %>
  <script>
    $(document).ready(function(){
    <% unless user_can_modify_resources %>
      link_dialog.init();
    <% end %>
      resource_picker.init(<%= @callback.present? ? "self.parent.#{@callback}" : 'null' %>);
    });
  </script>
<% end %>