プロジェクト

全般

プロフィール

Vote #69715

未完了

Allow to disable feature attachment

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
-
開始日:
2011/04/16
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
0
issue_org_id:
8168
author_id:
11022
assigned_to_id:
0
comments:
6
status_id:
1
tracker_id:
2
plus1:
1
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

Attachment max. size
should be as
Attachment max. size (zero for disabling feature)


journals

issue should be renamed to "Allow to disable feature attachment"
I don't have permission for that
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
We will have new custom field format "File" in Redmine 3.4.0 (#6719). It would be great if we can disable default "Files" field by tracker like #25052.

We can configure to show specific field name (e.g. "Screenshot", "Error log", "Patch" ...) instead of generic "Files" if this feature is implemented.
--------------------------------------------------------------------------------
I investigated, but I abandoned it.
I did the following things.

1. Add attachment to tracker.
<pre><code class="diff">
diff --git a/app/models/tracker.rb b/app/models/tracker.rb
index d90ab3e15..9c3c9a1a8 100644
--- a/app/models/tracker.rb
+++ b/app/models/tracker.rb
@@ -21,7 +21,7 @@ class Tracker < ActiveRecord::Base
CORE_FIELDS_UNDISABLABLE = %w(project_id tracker_id subject priority_id is_private).freeze
# Fields that can be disabled
# Other (future) fields should be appended, not inserted!
- CORE_FIELDS = %w(assigned_to_id category_id fixed_version_id parent_issue_id start_date due_date estimated_hours done_ratio description).freeze
+ CORE_FIELDS = %w(assigned_to_id category_id fixed_version_id parent_issue_id start_date due_date estimated_hours done_ratio description filename).freeze
CORE_FIELDS_ALL = (CORE_FIELDS_UNDISABLABLE + CORE_FIELDS).freeze

before_destroy :check_integrity
</code></pre>

2. Hide the attachmented file area of [issues/new] and [issues/edit].
<pre><code class="diff">
diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb
index 22a174a11..2f5b3416d 100644
--- a/app/views/issues/new.html.erb
+++ b/app/views/issues/new.html.erb
@@ -44,3 +44,13 @@
<% content_for :header_tags do %>
<%= robot_exclusion_tag %>
<% end %>
+
+<%= javascript_tag do %>
+$(document).ready(function(){
+ <% if @issue.disabled_core_fields.include?('filename') %>
+ $('#attachments_form').hide();
+ <% else %>
+ $('#attachments_form').show();
+ <% end %>
+});
+<% end %>
diff --git a/app/views/issues/new.js.erb b/app/views/issues/new.js.erb
index 702d922ab..b0fc1eefa 100644
--- a/app/views/issues/new.js.erb
+++ b/app/views/issues/new.js.erb
@@ -4,4 +4,10 @@ replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
$("#watchers_form_container").html('<%= escape_javascript(render :partial => 'issues/watchers_form') %>');
<% when "issue_category_id" %>
$('#issue_assigned_to_id').find('option').first().html('<%= escape_javascript(@issue.category.try(:assigned_to).try(:name)).presence || '&nbsp;'.html_safe %>');
+<% when "issue_tracker_id" %>
+ <% if @issue.disabled_core_fields.include?('filename') %>
+ $('#attachments_form').hide();
+ <% else %>
+ $('#attachments_form').show();
+ <% end %>
<% end %>
</code></pre>
<pre><code class="diff">
diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb
index 3afaee4ca..05bdbb72f 100644
--- a/app/views/issues/_edit.html.erb
+++ b/app/views/issues/_edit.html.erb
@@ -77,3 +77,12 @@

<% end %>

+<%= javascript_tag do %>
+$(document).ready(function(){
+ <% if @issue.disabled_core_fields.include?('filename') %>
+ $('#new-attachments').parent().hide();
+ <% else %>
+ $('#new-attachments').parent().show();
+ <% end %>
+});
+<% end %>
diff --git a/app/views/issues/edit.js.erb b/app/views/issues/edit.js.erb
index 8c94aeceb..b02f93671 100644
--- a/app/views/issues/edit.js.erb
+++ b/app/views/issues/edit.js.erb
@@ -5,3 +5,9 @@ replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
<% else %>
$('#log_time').hide();
<% end %>
+
+<% if @issue.disabled_core_fields.include?('filename') %>
+ $('#new-attachments').parent().hide();
+<% else %>
+ $('#new-attachments').parent().show();
+<% end %>
</code></pre>

However, there seems to be more considerations.
for example,
* Reflects "read only" and "required" to attached files..
* Disable drag & drop of attached files.

etc.

--------------------------------------------------------------------------------
+1

This is related to #24623
--------------------------------------------------------------------------------


related_issues

duplicates,Closed,24836,Option to disable file upload

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0