Tagging allowed for the first CF if the format is a list only

This commit is contained in:
Karel Pičman 2019-03-22 10:24:43 +01:00
parent 5c3cad5dd4
commit 853bce1cf0
2 changed files with 43 additions and 43 deletions

View File

@ -158,13 +158,10 @@ class DmsfController < ApplicationController
def tag_changed def tag_changed
# Tag filter # Tag filter
params[:dmsf_folder][:custom_field_values].each do |key, value| if params[:dmsf_folder]
redirect_to dmsf_folder_path( params[:dmsf_folder][:custom_field_values].each do |key, value|
id: @project, return redirect_to dmsf_folder_path id: @project, folder_id: @folder, custom_field_id: key, custom_value: value
folder_id: @folder, end
custom_field_id: key,
custom_value: value)
return
end end
redirect_to :back redirect_to :back
end end

View File

@ -88,43 +88,46 @@
<%= error_messages_for('dmsf_workflow') %> <%= error_messages_for('dmsf_workflow') %>
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post, <<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %> :class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
<%= hidden_field_tag('action') %> <%= hidden_field_tag('action') %>
<% unless @system_folder %> <% unless @system_folder %>
<div id="dmsf_buttons" class="dmsf_controls" style="float: left"> <div id="dmsf_buttons" class="dmsf_controls" style="float: left">
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries', <%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries',
:class => 'toggle-selection') if @file_view_allowed %> :class => 'toggle-selection') if @file_view_allowed %>
<%= submit_tag(l(:field_mail), :title => l(:title_send_checked_by_email), :name => 'email_entries', <%= submit_tag(l(:field_mail), :title => l(:title_send_checked_by_email), :name => 'email_entries',
:class => 'toggle-selection') if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %> :class => 'toggle-selection') if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %>
<% if @file_delete_allowed %> <% if @file_delete_allowed %>
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'delete_entries', <%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'delete_entries',
:class => 'toggle-selection', :data => { :confirm => l(:text_are_you_sure) }) if @file_delete_allowed %> :class => 'toggle-selection', :data => { :confirm => l(:text_are_you_sure) }) if @file_delete_allowed %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<% unless @system_folder %> <% unless @system_folder %>
<% values = @folder ? @folder.custom_field_values : DmsfFolder.new.custom_field_values %> <% values = @folder ? @folder.custom_field_values : DmsfFolder.new.custom_field_values %>
<% unless values.empty? %> <% unless values.empty? %>
<div id="dmsf_tag" class="dmsf_controls" style="float: right"> <% values.sort! { |a, b| a.custom_field.position <=> b.custom_field.position } %>
<% custom_value = values.first %> <% custom_value = values.first %>
<% custom_value.custom_field.is_required = false %> <% if custom_value.custom_field.format.is_a?(Redmine::FieldFormat::ListFormat) %>
<% custom_value.value = params[:custom_value].present? ? params[:custom_value] : '' %> <div id="dmsf_tag" class="dmsf_controls" style="float: right">
<%= h(custom_value.custom_field.name) %>: <% custom_value.custom_field.is_required = false %>
<%= custom_value.custom_field.format.edit_tag(self, <% custom_value.value = params[:custom_value].present? ? params[:custom_value] : '' %>
custom_field_tag_id(:dmsf_folder, custom_value.custom_field), <%= h(custom_value.custom_field.name) %>:
custom_field_tag_name(:dmsf_folder, custom_value.custom_field), <%= custom_value.custom_field.format.edit_tag(self,
custom_value, custom_field_tag_id(:dmsf_folder, custom_value.custom_field),
:class => "#{custom_value.custom_field.field_format}_cf", custom_field_tag_name(:dmsf_folder, custom_value.custom_field),
:style => 'width: auto') %> custom_value,
</div> :class => "#{custom_value.custom_field.field_format}_cf",
<% end %> :style => 'width: auto') %>
<% end %> </div>
<% if @tree_view %> <% end %>
<%= render(:partial => 'tree_view') %>
<% else %>
<%= render(:partial => 'list_view') %>
<% end %> <% end %>
<% end %>
<% if @tree_view %>
<%= render(:partial => 'tree_view') %>
<% else %>
<%= render(:partial => 'list_view') %>
<% end %>
<% end %> <% end %>
<%= context_menu %> <%= context_menu %>