Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #1826 #1948

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions core/app/views/refinery/admin/_resource_picker.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<%
conditions ||= nil
insert_text = "<span id='no_resource_selected_#{field}' class='nothing_selected' #{"style='display: none;'" if resource.present?}>
insert_text = %Q{<span id="no_resource_selected_#{field}" class="nothing_selected" #{'style="display: none;"'.html_safe if resource.present?}>
#{t('.no_resource_selected')}
</span>".html_safe
</span>}.html_safe
insert_link = refinery.insert_admin_resources_path({
:dialog => true,
:update_resource => "current_resource_#{field}",
:update_text => "current_resource_text_#{field}",
:callback => "resource_changed_#{field}",
:field => [f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, ""), field].join('_'),
:field => [f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, ''), field].join('_'),
:current_link => "#{resource.url if resource.present?}",
:height => 480,
:conditions => conditions
Expand All @@ -20,21 +20,21 @@
:name => t('.name'),
:id => "current_resource_link_#{field}"
%>
<div id='current_resource_container_<%= field %>' style='margin-top: 10px<%= ";display: none" unless resource.present? %>'>
<div id="current_resource_container_<%= field %>" style="margin-top: 10px;<%= 'display: none' unless resource.present? %>">
<%= link_to "#{refinery_icon_tag('page_white_put.png')} ".html_safe +
content_tag(
:span,
"#{resource.title} (#{resource.file_name})",
resource.present? ? "#{resource.title} (#{resource.file_name})" : '',
:id => "current_resource_text_#{field}"
),
resource.url,
"#{resource.url if resource.present?}",
:id => "current_resource_#{field}",
:target => "_blank" if resource.present? %>
:target => '_blank' %>
</div>
<br/>
<%= link_to t('.remove_current'), "",
<%= link_to t('.remove_current'), '',
:id => "remove_resource_#{field}",
:style => "#{"display:none;" unless resource.present?}" %>
:style => "#{'display:none;' unless resource.present?}" %>
</div>

<% content_for :javascripts do %>
Expand All @@ -43,25 +43,24 @@
$('#remove_resource_<%= field %>').show();
$('#current_resource_container_<%= field %>').show();
$('#no_resource_selected_<%= field %>').hide();
$('iframe#dialog_iframe').dialog("close");
$('iframe#dialog_iframe').remove().parents(".ui-dialog").remove();
$('#<%= f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "") %>_<%= field %>').val(callback_args.id);
$('#current_resource_link_<%= field %>').attr('href', $('#current_resource_link_<%= field %>').attr('href').replace(/current_link=([^&])*&/, "current_link=" + callback_args.href + "&"));
$("#current_resource_<%= field %>").attr('href', callback_args.href);
$('iframe#dialog_iframe').dialog('close');
$('iframe#dialog_iframe').remove().parents('.ui-dialog').remove();
$('#<%= f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, '') %>_<%= field %>').val(callback_args.id);
$('#current_resource_link_<%= field %>').attr('href', $('#current_resource_link_<%= field %>').attr('href').replace(/current_link=([^&])*&/, 'current_link=' + callback_args.href + '&'));
$('#current_resource_<%= field %>').attr('href', callback_args.href);
$('#current_resource_text_<%= field %>').html(callback_args.html);
}
};

$(document).ready(function(e) {
$('#remove_resource_<%= field %>').click(function(e) {
$('#<%= f.object_name %>_<%= field %>').val("");
$('#<%= f.object_name %>_<%= field %>').val('');
$('#current_resource_container_<%= field %>').hide();
$('#current_resource_text_<%= field %>').html('');
$('#no_resource_selected_<%= field %>').show();
$('#current_resource_link_<%= field %>').attr('href', $('#current_resource_link_<%= field %>').attr('href').replace(/current_link=([^&])*&/, "current_link=&"));
$('#current_resource_link_<%= field %>').attr('href', $('#current_resource_link_<%= field %>').attr('href').replace(/current_link=([^&])*&/, 'current_link=&'));
$(this).hide();
e.preventDefault();
});
});
</script>
<% end %>

<% end %>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div id='existing_resource_area' class='dialog_area' <%= "style='display:none;'" if @resource.errors.any? %>>
<input type='hidden' name='linked_resource' id='linked_resource' />
<div id='existing_resource_area_content' class='clearfix'>
<div id='pages_list' class='pages_list'>
<ul class='link_list'>
<div id="existing_resource_area" class="dialog_area" <%= 'style="display:none;"'.html_safe if @resource.errors.any? %>>
<input type="hidden" name="linked_resource" id="linked_resource" />
<div id="existing_resource_area_content" class="clearfix">
<div id="pages_list" class="pages_list">
<ul class="link_list">
<% @resources.each do |resource| -%>
<% resource_linked = (resource.url == params[:current_link]) if params[:current_link].present? %>
<li<%= " class='linked'" if resource_linked %>>
<% resource_linked = ((@resource_id.present? && @resource_id == resource.id) || (params[:current_link].present? && resource.url == params[:current_link])) %>
<li<%= ' class="linked"'.html_safe if resource_linked %>>
<%= link_to "#{resource.title} (#{resource.file_name})", asset_paths.compute_public_path(resource.url, ''),
:title => t('.link_to_file'),
:rel => resource.title,
Expand Down
28 changes: 14 additions & 14 deletions resources/app/views/refinery/admin/resources/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<%= form_for @resource, :url => (@url_override || @resource.new_record? ? refinery.admin_resources_path : refinery.admin_resource_path(@resource)),
:html => { :multipart => true },
:as => "resource" do |f| -%>
<%= form_for @resource, :url => (@url_override || (@resource.persisted? ? refinery.admin_resource_path(@resource) : refinery.admin_resources_path)),
:html => { :multipart => true },
:as => 'resource' do |f| %>

<%= render '/refinery/admin/error_messages',
:object => @resource,
:include_object_name => false %>

<div class='field'>
<div class="field">
<% if action_name =~ /(edit)|(update)/ %>
<%= link_to t('.download_current'), @resource.url,
:title => @resource.title %>
Expand All @@ -18,28 +18,28 @@
<% end %>
</div>

<div class='field' id='maximum_file_size'>
<div class="field" id="maximum_file_size">
<label>
<%= t('.maximum_file_size', :bytes => number_to_human_size(Refinery::Resources.max_file_size)) %>
</label>
</div>

<%= render '/refinery/admin/form_actions', :f => f,
:continue_editing => false,
:hide_cancel => (@app_dialog or action_name == "insert" or from_dialog?),
:hide_cancel => (@app_dialog or action_name == 'insert' or from_dialog?),
:delete_title => t('delete', :scope => 'refinery.admin.resources'),
:delete_confirmation => (t('message', :scope => 'refinery.admin.delete',
:title => @resource.title) if @resource.persisted?) %>

<% if @app_dialog -%>
<input type='hidden' name='app_dialog' value='<%= @app_dialog %>' />
<input type='hidden' name='field' value='<%= @field %>' />
<input type='hidden' name='update_resource' value='<%= @update_resource %>' />
<input type='hidden' name='update_text' value='<%= @update_text %>' />
<input type='hidden' name='thumbnail' value='<%= @thumbnail %>' />
<input type='hidden' name='callback' value='<%= @callback %>' />
<input type='hidden' name='conditions' value='<%= @conditions %>' />
<input type='hidden' name='current_link' value='<%= @current_link %>' />
<input type="hidden" name="app_dialog" value="<%= @app_dialog %>" />
<input type="hidden" name="field" value="<%= @field %>" />
<input type="hidden" name="update_resource" value="<%= @update_resource %>" />
<input type="hidden" name="update_text" value="<%= @update_text %>" />
<input type="hidden" name="thumbnail" value="<%= @thumbnail %>" />
<input type="hidden" name="callback" value="<%= @callback %>" />
<input type="hidden" name="conditions" value="<%= @conditions %>" />
<input type="hidden" name="current_link" value="<%= @current_link %>" />
<% end -%>
<% end -%>
<% content_for :javascripts do %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% if searching? %>
<%= link_to t('cancel_search', :scope => 'refinery.admin.search'), refinery.admin_resources_path, :class => "cancel-search" %>
<%= link_to t('cancel_search', :scope => 'refinery.admin.search'), refinery.admin_resources_path, :class => 'cancel-search' %>
<h2><%= t('results_for_html', :scope => 'refinery.admin.search', :query => h(params[:search])).html_safe %></h2>
<% end %>
<div class='pagination_container'>
<div class="pagination_container">
<% if @resources.any? %>
<%= render 'resources' %>
<% else %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
<span class='title <%= resource.ext.try(:downcase) %>'>
<li class="clearfix record <%= cycle('on', 'on-hover') %>">
<span class="title <%= resource.ext.try(:downcase) %>">
<%= resource.title %><%= ".#{resource.ext}" if resource.ext %>
<span class="preview">- <%= number_to_human_size(resource.size) %></span>
</span>
<span class='actions'>
<span class="actions">
<%= link_to refinery_icon_tag('page_white_put.png'),
resource.url,
:title => t('.download', :size => number_to_human_size(resource.size)) %>
Expand Down
4 changes: 2 additions & 2 deletions resources/app/views/refinery/admin/resources/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id='records' class='files'>
<div id="records" class="files">
<%= render 'records' %>
</div>
<div id='actions'>
<div id="actions">
<%= render 'actions' %>
</div>
24 changes: 12 additions & 12 deletions resources/app/views/refinery/admin/resources/insert.html.erb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<% user_can_modify_resources = ::Refinery::Plugins.active.names.include?("refinery_files") %>
<div class='clearfix'>
<div id='dialog_menu_left'>
<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'" if @resource.errors.empty? %> />
<label for='resource_type_existing' class='stripped'>
<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'" if @resources.empty? or @resource.errors.any? %> />
<label for='resource_type_upload' class='stripped'>
<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'>
<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;'" if any_resources and @resource.errors.empty? %>>
<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 %>
Expand All @@ -47,7 +47,7 @@
<% unless user_can_modify_resources %>
link_dialog.init();
<% end %>
resource_picker.init(<%= @callback.present? ? "self.parent.#{@callback}" : "null" %>);
resource_picker.init(<%= @callback.present? ? "self.parent.#{@callback}" : 'null' %>);
});
</script>
<% end %>
<% end %>