Add option to hide attachments of issue, if amount of file is to high
This commit is contained in:
parent
dc93df7080
commit
7adb11491d
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 3.2.0
|
||||
|
||||
- add option to hide issue attachments, if number of file is too high
|
||||
- rubocop offenses has been fixed
|
||||
|
||||
## 3.1.0
|
||||
|
||||
- Fix missing label for view all documents
|
||||
|
@ -18,7 +18,7 @@ module AdditionalsQueriesHelper
|
||||
end
|
||||
|
||||
def additionals_query_session_key(object_type)
|
||||
"#{object_type}_query".to_sym
|
||||
:"#{object_type}_query"
|
||||
end
|
||||
|
||||
def additionals_retrieve_query(object_type, user_filter: nil, search_string: nil)
|
||||
|
@ -42,7 +42,7 @@ class AdditionalsChart
|
||||
|
||||
def build_values_without_gaps(data, gap_value = 0)
|
||||
values = []
|
||||
labels.each do |label, _label_id|
|
||||
labels.each_key do |label|
|
||||
values << if data.key? label
|
||||
data[label]
|
||||
else
|
||||
|
@ -264,7 +264,7 @@ module AdditionalsQuery
|
||||
end
|
||||
|
||||
def results_scope(**options)
|
||||
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten!.to_a.compact_blank
|
||||
order_option = [group_by_sort_order, options[:order] || sort_clause].flatten!.to_a.compact_blank
|
||||
|
||||
objects_scope(**options.except(:order, :limit, :offset))
|
||||
.order(order_option)
|
||||
|
@ -24,10 +24,10 @@ class Dashboard < ActiveRecord::Base
|
||||
VISIBILITY_ROLES = 1
|
||||
VISIBILITY_PUBLIC = 2
|
||||
|
||||
scope :by_project, (->(project_id) { where project_id: project_id if project_id.present? })
|
||||
scope :sorted, (-> { order :name })
|
||||
scope :welcome_only, (-> { where dashboard_type: DashboardContentWelcome::TYPE_NAME })
|
||||
scope :project_only, (-> { where dashboard_type: DashboardContentProject::TYPE_NAME })
|
||||
scope :by_project, ->(project_id) { where project_id: project_id if project_id.present? }
|
||||
scope :sorted, -> { order :name }
|
||||
scope :welcome_only, -> { where dashboard_type: DashboardContentWelcome::TYPE_NAME }
|
||||
scope :project_only, -> { where dashboard_type: DashboardContentProject::TYPE_NAME }
|
||||
|
||||
safe_attributes 'name', 'description', 'enable_sidebar',
|
||||
'locked', 'always_expose', 'project_id', 'author_id',
|
||||
@ -267,7 +267,7 @@ class Dashboard < ActiveRecord::Base
|
||||
def editable?(user = User.current)
|
||||
return false unless user
|
||||
|
||||
(user.admin? || (author == user && user.allowed_to?(:save_dashboards, project, global: true)))
|
||||
user.admin? || (author == user && user.allowed_to?(:save_dashboards, project, global: true))
|
||||
end
|
||||
|
||||
def deletable?(user = User.current)
|
||||
|
@ -24,4 +24,11 @@ module IssuesShow
|
||||
insert_before: 'erb[loud]:contains("render_private_notes_indicator")',
|
||||
original: '38ddc174974d0a0ee482dd73070ee80baebe9e4d',
|
||||
partial: 'issues/additionals_note_history'
|
||||
|
||||
Deface::Override.new virtual_path: 'issues/show',
|
||||
name: 'show-issue-attachments',
|
||||
replace: 'erb[silent]:contains("if @issue.attachments.any?")',
|
||||
closing_selector: 'erb[silent]:contains("end")',
|
||||
original: 'e2a825486b3b1ba51c0e2fa1f72bdd5e98e1b964',
|
||||
partial: 'issues/hide_attachments'
|
||||
end
|
||||
|
@ -6,7 +6,12 @@ p
|
||||
= additionals_settings_textarea :new_ticket_message
|
||||
em.info = l :new_ticket_message_info
|
||||
|
||||
br
|
||||
p
|
||||
= additionals_settings_numberfield :issue_hide_max_attachments,
|
||||
min: 0, max: 1000, size: 5
|
||||
em.info
|
||||
= l :info_issue_hide_max_attachments
|
||||
|
||||
p = additionals_settings_checkbox :new_issue_on_profile
|
||||
p = additionals_settings_checkbox :issue_assign_to_me
|
||||
p = additionals_settings_checkbox :issue_note_with_author
|
||||
|
15
app/views/issues/_hide_attachments.html.slim
Normal file
15
app/views/issues/_hide_attachments.html.slim
Normal file
@ -0,0 +1,15 @@
|
||||
- if @issue.attachments.any?
|
||||
- file_count = @issue.attachments.length
|
||||
- if file_count > Additionals.setting(:issue_hide_max_attachments).to_i
|
||||
fieldset.collapsible.collapsed.hide-attachments
|
||||
legend onclick="toggleFieldset(this);" class="icon icon-collapsed"
|
||||
strong
|
||||
= l :label_attachment_plural
|
||||
= " (#{file_count})"
|
||||
.hidden
|
||||
= link_to_attachments @issue, thumbnails: true
|
||||
- else
|
||||
hr
|
||||
p
|
||||
strong = l :label_attachment_plural
|
||||
= link_to_attachments @issue, thumbnails: true
|
@ -25,6 +25,11 @@ span.dashboard-locked {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
fieldset.hide-attachments {
|
||||
padding-left: 0;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
#my-page.dashboard .settings input[type='text'],
|
||||
#my-page.dashboard .settings input[type='password'],
|
||||
#my-page.dashboard .settings input[type='url'] {
|
||||
|
@ -210,3 +210,5 @@ cs:
|
||||
wiki_pdf_remove_attachments_info: "Pokud je aktivní, připojené soubory Wiki se nebudou zobrazovat v zobrazení PDF."
|
||||
wiki_pdf_remove_title_info: "Pokud je aktivní, informace o názvu Wiki se nebudou zobrazovat v zobrazení PDF."
|
||||
label_document_view_all: "Zobrazit všechny dokumenty"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ de:
|
||||
wiki_pdf_remove_attachments_info: Wenn aktiv, werden die an der Wiki Seite angehängten Dateien nicht in der PDF Ansicht angezeigt.
|
||||
wiki_pdf_remove_title_info: Wenn aktiv, wird der Wiki Titel nicht in der PDF Ansicht angezeigt.
|
||||
label_document_view_all: Alle Dokumente anzeigen
|
||||
label_issue_hide_max_attachments: Max. angezeigte Dateien
|
||||
info_issue_hide_max_attachments: Wird die hier angegene Anzahl überschritten, werden alle Dateianhänge im Ticket eingeklappt/versteckt dargestellt.
|
||||
|
@ -210,3 +210,5 @@ en:
|
||||
wiki_pdf_remove_attachments_info: "When active the attached Wiki files will not be displayed in PDF view."
|
||||
wiki_pdf_remove_title_info: "When active the Wiki title info will not be displayed in PDF view."
|
||||
label_document_view_all: View all documents
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ es:
|
||||
wiki_pdf_remove_attachments_info: "Cuando está activa, los adjuntos no serán mostrados en los PDF."
|
||||
wiki_pdf_remove_title_info: "Cuando está activa, el título de la Wiki no será mostrado en los PDF."
|
||||
label_document_view_all: "Todos los documentos"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ fr:
|
||||
wiki_pdf_remove_attachments_info: "Lorsqu'ils sont actifs, les fichiers Wiki joints ne seront pas affichés en vue PDF."
|
||||
wiki_pdf_remove_title_info: "Lorsqu'elle est active, l'information sur le titre du wiki ne sera pas affichée dans la vue PDF."
|
||||
label_document_view_all: "Voir tous les documents"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ it:
|
||||
wiki_pdf_remove_attachments_info: "Quando è attivo, il Wiki file allegati non verranno visualizzati nella vista PDF."
|
||||
wiki_pdf_remove_title_info: "Quando è attivo, le informazioni sul titolo del Wiki non verranno visualizzate nella vista PDF."
|
||||
label_document_view_all: "Vedi tutti i documenti"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ ja:
|
||||
wiki_pdf_remove_attachments_info: "アクティブな場合、添付されたWikiファイルはPDFビューに表示されません。"
|
||||
wiki_pdf_remove_title_info: "アクティブな場合、Wikiのタイトル情報はPDFビューに表示されません。"
|
||||
label_document_view_all: "すべての資料を見る"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ ko:
|
||||
wiki_pdf_remove_attachments_info: 활성화 된 경우 첨부 된 Wiki 파일은 PDF보기에 표시되지 않습니다.
|
||||
wiki_pdf_remove_title_info: 활성화되면 위키 제목 정보가 PDF보기에 표시되지 않습니다.
|
||||
label_document_view_all: "모든 문서 보기"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ pl:
|
||||
wiki_pdf_remove_attachments_info: "Gdy jest aktywny, załączone pliki Wiki nie będą wyświetlane w widoku PDF."
|
||||
wiki_pdf_remove_title_info: "Gdy jest aktywny, informacja o tytule Wiki nie będzie wyświetlana w widoku PDF."
|
||||
label_document_view_all: "Zobacz wszystkie dokumenty"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ pt-BR:
|
||||
wiki_pdf_remove_attachments_info: "Quando ativo, os arquivos Wiki anexos não serão exibidos na visualização em PDF."
|
||||
wiki_pdf_remove_title_info: "Quando ativo, o título do Wiki não será exibido na visualização em PDF."
|
||||
label_document_view_all: "Veja todos os documentos"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ ru:
|
||||
wiki_pdf_remove_attachments_info: "Если флажок установлен, вложенные Вики-файлы не будут отображаться в PDF-формате."
|
||||
wiki_pdf_remove_title_info: "При активации этого параметра информация о названии Вики не будет отображаться в PDF-формате."
|
||||
label_document_view_all: "Посмотреть все документы"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@
|
||||
wiki_pdf_remove_attachments_info: "當啟用時,Wiki附件將不會顯示在PDF中。"
|
||||
wiki_pdf_remove_title_info: "當啟用時,Wiki標題訊息不會顯示在PDF中"
|
||||
label_document_view_all: "查看所有文件"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -210,3 +210,5 @@ zh:
|
||||
wiki_pdf_remove_attachments_info: 当启用时,Wiki 附件将不会显示在 PDF 视图中。
|
||||
wiki_pdf_remove_title_info: 当启用时,Wiki 标题信息将不会显示在 PDF 视图中。
|
||||
label_document_view_all: "查看所有文件"
|
||||
label_issue_hide_max_attachments: Show max. files
|
||||
info_issue_hide_max_attachments: If the number of files entered here is exceeding all file attachments of an issue are displayed hidden.
|
||||
|
@ -17,6 +17,7 @@ issue_auto_assign_status: ''
|
||||
issue_change_status_in_sidebar: 0
|
||||
issue_current_user_status: 0
|
||||
issue_freezed_with_close: 0
|
||||
issue_hide_max_attachments: 10
|
||||
issue_note_with_author: 0
|
||||
issue_fast_description_edit: 0
|
||||
issue_status_change: 0
|
||||
|
@ -59,7 +59,7 @@ module Additionals
|
||||
end
|
||||
|
||||
def additionals_i18n_title(options, title)
|
||||
i18n_title = "#{title}_#{::I18n.locale}".to_sym
|
||||
i18n_title = :"#{title}_#{::I18n.locale}"
|
||||
if options.key? i18n_title
|
||||
options[i18n_title]
|
||||
elsif options.key? title
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
module Additionals
|
||||
module PluginVersion
|
||||
VERSION = '3.1.0' unless defined? Additionals::PluginVersion::VERSION
|
||||
VERSION = '3.2.0-main' unless defined? Additionals::PluginVersion::VERSION
|
||||
end
|
||||
end
|
||||
|
@ -268,7 +268,7 @@ module CrudControllerBase
|
||||
end
|
||||
|
||||
def form_params(action)
|
||||
crud_params = @crud["#{action}_params".to_sym]
|
||||
crud_params = @crud[:"#{action}_params"]
|
||||
if @crud[:form]
|
||||
{ id: id_value, @crud[:form] => crud_params }
|
||||
else
|
||||
|
@ -13,7 +13,7 @@ class IssuesControllerTest < Additionals::ControllerTest
|
||||
:workflows,
|
||||
:custom_fields, :custom_values, :custom_fields_projects, :custom_fields_trackers,
|
||||
:time_entries,
|
||||
:watchers,
|
||||
:watchers, :attachments,
|
||||
:journals, :journal_details,
|
||||
:repositories, :changesets,
|
||||
:queries
|
||||
@ -219,4 +219,22 @@ class IssuesControllerTest < Additionals::ControllerTest
|
||||
assert_select 'h4.note-header .badge-author', count: 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_attachments
|
||||
with_plugin_settings 'additionals', issue_hide_max_attachments: 10 do
|
||||
get :show, params: { id: 3 }
|
||||
|
||||
assert_response :success
|
||||
assert_select 'fieldset.hide-attachments', count: 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_attachments_as_hidden
|
||||
with_plugin_settings 'additionals', issue_hide_max_attachments: 0 do
|
||||
get :show, params: { id: 3 }
|
||||
|
||||
assert_response :success
|
||||
assert_select 'fieldset.hide-attachments', count: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user