@@ -0,0 +1,22 | |||
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2015 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | class DocumentCustomField < CustomField | |
|
19 | def type_name | |
|
20 | :label_document_plural | |
|
21 | end | |
|
22 | end |
@@ -24,6 +24,7 class DocumentsController < ApplicationController | |||
|
24 | 24 | before_filter :authorize |
|
25 | 25 | |
|
26 | 26 | helper :attachments |
|
27 | helper :custom_fields | |
|
27 | 28 | |
|
28 | 29 | def index |
|
29 | 30 | @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' |
@@ -28,6 +28,8 module CustomFieldsHelper | |||
|
28 | 28 | :label => :label_project_plural}, |
|
29 | 29 | {:name => 'VersionCustomField', :partial => 'custom_fields/index', |
|
30 | 30 | :label => :label_version_plural}, |
|
31 | {:name => 'DocumentCustomField', :partial => 'custom_fields/index', | |
|
32 | :label => :label_document_plural}, | |
|
31 | 33 | {:name => 'UserCustomField', :partial => 'custom_fields/index', |
|
32 | 34 | :label => :label_user_plural}, |
|
33 | 35 | {:name => 'GroupCustomField', :partial => 'custom_fields/index', |
@@ -20,6 +20,7 class Document < ActiveRecord::Base | |||
|
20 | 20 | belongs_to :project |
|
21 | 21 | belongs_to :category, :class_name => "DocumentCategory" |
|
22 | 22 | acts_as_attachable :delete_permission => :delete_documents |
|
23 | acts_as_customizable | |
|
23 | 24 | |
|
24 | 25 | acts_as_searchable :columns => ['title', "#{table_name}.description"], |
|
25 | 26 | :preload => :project |
@@ -39,7 +40,7 class Document < ActiveRecord::Base | |||
|
39 | 40 | where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args)) |
|
40 | 41 | } |
|
41 | 42 | |
|
42 | safe_attributes 'category_id', 'title', 'description' | |
|
43 | safe_attributes 'category_id', 'title', 'description', 'custom_fields', 'custom_field_values' | |
|
43 | 44 | |
|
44 | 45 | def visible?(user=User.current) |
|
45 | 46 | !user.nil? && user.allowed_to?(:view_documents, project) |
@@ -4,6 +4,10 | |||
|
4 | 4 | <p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %></p> |
|
5 | 5 | <p><%= f.text_field :title, :required => true, :size => 60 %></p> |
|
6 | 6 | <p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p> |
|
7 | ||
|
8 | <% @document.custom_field_values.each do |value| %> | |
|
9 | <p><%= custom_field_tag_with_label :document, value %></p> | |
|
10 | <% end %> | |
|
7 | 11 | </div> |
|
8 | 12 | |
|
9 | 13 | <%= wikitoolbar_for 'document_description' %> |
@@ -11,6 +11,15 | |||
|
11 | 11 | |
|
12 | 12 | <p><em><%=h @document.category.name %><br /> |
|
13 | 13 | <%= format_date @document.created_on %></em></p> |
|
14 | ||
|
15 | <% if @document.custom_field_values.any? %> | |
|
16 | <ul> | |
|
17 | <% render_custom_field_values(@document) do |custom_field, formatted| %> | |
|
18 | <li><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li> | |
|
19 | <% end %> | |
|
20 | </ul> | |
|
21 | <% end %> | |
|
22 | ||
|
14 | 23 | <div class="wiki"> |
|
15 | 24 | <%= textilizable @document, :description, :attachments => @document.attachments %> |
|
16 | 25 | </div> |
@@ -592,7 +592,7 module Redmine | |||
|
592 | 592 | end |
|
593 | 593 | |
|
594 | 594 | class RecordList < List |
|
595 | self.customized_class_names = %w(Issue TimeEntry Version Project) | |
|
595 | self.customized_class_names = %w(Issue TimeEntry Version Document Project) | |
|
596 | 596 | |
|
597 | 597 | def cast_single_value(custom_field, value, customized=nil) |
|
598 | 598 | target_class.find_by_id(value.to_i) if value.present? |
General Comments 0
You need to be logged in to leave comments.
Login now