before_filter :authorize
helper :attachments
+ helper :custom_fields
def index
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
:label => :label_project_plural},
{:name => 'VersionCustomField', :partial => 'custom_fields/index',
:label => :label_version_plural},
+ {:name => 'DocumentCustomField', :partial => 'custom_fields/index',
+ :label => :label_document_plural},
{:name => 'UserCustomField', :partial => 'custom_fields/index',
:label => :label_user_plural},
{:name => 'GroupCustomField', :partial => 'custom_fields/index',
belongs_to :project
belongs_to :category, :class_name => "DocumentCategory"
acts_as_attachable :delete_permission => :delete_documents
+ acts_as_customizable
acts_as_searchable :columns => ['title', "#{table_name}.description"],
:preload => :project
where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
}
- safe_attributes 'category_id', 'title', 'description'
+ safe_attributes 'category_id', 'title', 'description', 'custom_fields', 'custom_field_values'
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_documents, project)
--- /dev/null
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class DocumentCustomField < CustomField
+ def type_name
+ :label_document_plural
+ end
+end
<p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %></p>
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
+
+<% @document.custom_field_values.each do |value| %>
+ <p><%= custom_field_tag_with_label :document, value %></p>
+<% end %>
</div>
<%= wikitoolbar_for 'document_description' %>
<p><em><%=h @document.category.name %><br />
<%= format_date @document.created_on %></em></p>
+
+<% if @document.custom_field_values.any? %>
+<ul>
+ <% render_custom_field_values(@document) do |custom_field, formatted| %>
+ <li><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li>
+ <% end %>
+</ul>
+<% end %>
+
<div class="wiki">
<%= textilizable @document, :description, :attachments => @document.attachments %>
</div>
end
class RecordList < List
- self.customized_class_names = %w(Issue TimeEntry Version Project)
+ self.customized_class_names = %w(Issue TimeEntry Version Document Project)
def cast_single_value(custom_field, value, customized=nil)
target_class.find_by_id(value.to_i) if value.present?