diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb index 85c00360..d8758cd4 100644 --- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb +++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb @@ -32,9 +32,11 @@ module RedmineDmsf def view_attachments_form_top(context={}) html = '' + container = context[:container] + description = defined?(EasyExtensions) && EasySetting.value('attachment_description') # Radio buttons - if allowed_to_attach_documents(context[:container]) - html << '
' + if allowed_to_attach_documents(container) && allowed_to_attach_attachments(container) + html << (description ? '
" html << radio_button_tag('dmsf_attachments_upload_choice', 'Attachments', @@ -42,7 +44,7 @@ module RedmineDmsf onchange: "$('.attachments-container:not(.dmsf-uploader)').show(); $('.dmsf-uploader').parent().hide(); return false;") html << l(:label_basic_attachments) html << '' - unless context[:container] && context[:container].new_record? + unless container && container.new_record? classes << ' dmsf_attachments_label' end html << "' - html << '
' + html << (description ? '' : '') if User.current.pref.dmsf_attachments_upload_choice == 'DMSF' html << context[:hook_caller].late_javascript_tag("$('.attachments-container:not(.dmsf-uploader)').hide();") end end # Upload form - html.html_safe + attach_documents_form(context, false, - defined?(EasyExtensions) && EasySetting.value('attachment_description')) + if allowed_to_attach_documents(container) + html << attach_documents_form(context, false, description) + end + unless allowed_to_attach_attachments(container) + html << context[:hook_caller].late_javascript_tag("$('.attachments-container:not(.dmsf-uploader)').hide();") + end + html.html_safe end def view_issues_show_description_bottom(context={}) @@ -93,8 +100,8 @@ module RedmineDmsf end def view_issues_edit_notes_bottom_style(context={}) - if (User.current.pref.dmsf_attachments_upload_choice == 'Attachments') || - !allowed_to_attach_documents(context[:container]) + if ((User.current.pref.dmsf_attachments_upload_choice == 'Attachments') || + !allowed_to_attach_documents(context[:container])) && allowed_to_attach_attachments(context[:container]) '' else 'display: none' @@ -110,6 +117,13 @@ module RedmineDmsf (container.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) end + def allowed_to_attach_attachments(container) + unless defined?(EasyExtensions) + true + end + container.project && container.project.module_enabled?(:documents) + end + def get_links(container) links = [] if defined?(container.dmsf_files) && User.current.allowed_to?(:view_dmsf_files, container.project) && @@ -148,7 +162,7 @@ module RedmineDmsf container = context[:container] if allowed_to_attach_documents(container) html = (description ? '" + html << " style=\"#{(User.current.pref.dmsf_attachments_upload_choice == 'Attachments') && allowed_to_attach_attachments(container) ? 'display: none;' : ''}\">" if label html << "" html << "