##// END OF EJS Templates
Missing select name....
Jean-Philippe Lang -
r15549:ac7e5f4db2ce
parent child
Show More
@@ -1,119 +1,119
1 1 # encoding: utf-8
2 2 #
3 3 # Redmine - project management software
4 4 # Copyright (C) 2006-2016 Jean-Philippe Lang
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; either version 2
9 9 # of the License, or (at your option) any later version.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
20 20 module MyHelper
21 21 # Renders the blocks
22 22 def render_blocks(blocks, user, options={})
23 23 s = ''.html_safe
24 24
25 25 if blocks.present?
26 26 blocks.each do |block|
27 27 content = render_block_content(block, user)
28 28 if content.present?
29 29 if options[:edit]
30 30 close = link_to(l(:button_delete), {:action => "remove_block", :block => block}, :method => 'post', :class => "icon-only icon-close")
31 31 content = close + content_tag('div', content, :class => 'handle')
32 32 end
33 33
34 34 s << content_tag('div', content, :class => "mypage-box", :id => "block-#{block}")
35 35 end
36 36 end
37 37 end
38 38 s
39 39 end
40 40
41 41 # Renders a single block content
42 42 def render_block_content(block, user)
43 43 unless Redmine::MyPage.blocks.key?(block)
44 44 Rails.logger.warn("Unknown block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
45 45 return
46 46 end
47 47
48 48 begin
49 49 render(:partial => "my/blocks/#{block}", :locals => {:user => user})
50 50 rescue ActionView::MissingTemplate
51 51 Rails.logger.warn("Template missing for block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
52 52 return nil
53 53 end
54 54 end
55 55
56 56 def block_select_tag(user)
57 57 disabled = user.pref.my_page_layout.values.flatten
58 58 options = content_tag('option')
59 59 Redmine::MyPage.block_options.each do |label, block|
60 60 options << content_tag('option', label, :value => block, :disabled => disabled.include?(block))
61 61 end
62 content_tag('select', options, :id => "block-select")
62 select_tag('block', options, :id => "block-select")
63 63 end
64 64
65 65 def calendar_items(startdt, enddt)
66 66 Issue.visible.
67 67 where(:project_id => User.current.projects.map(&:id)).
68 68 where("(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)", startdt, enddt, startdt, enddt).
69 69 includes(:project, :tracker, :priority, :assigned_to).
70 70 references(:project, :tracker, :priority, :assigned_to).
71 71 to_a
72 72 end
73 73
74 74 def documents_items
75 75 Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).to_a
76 76 end
77 77
78 78 def issuesassignedtome_items
79 79 Issue.visible.open.
80 80 assigned_to(User.current).
81 81 limit(10).
82 82 includes(:status, :project, :tracker, :priority).
83 83 references(:status, :project, :tracker, :priority).
84 84 order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC")
85 85 end
86 86
87 87 def issuesreportedbyme_items
88 88 Issue.visible.open.
89 89 where(:author_id => User.current.id).
90 90 limit(10).
91 91 includes(:status, :project, :tracker).
92 92 references(:status, :project, :tracker).
93 93 order("#{Issue.table_name}.updated_on DESC")
94 94 end
95 95
96 96 def issueswatched_items
97 97 Issue.visible.open.on_active_project.watched_by(User.current.id).recently_updated.limit(10)
98 98 end
99 99
100 100 def news_items
101 101 News.visible.
102 102 where(:project_id => User.current.projects.map(&:id)).
103 103 limit(10).
104 104 includes(:project, :author).
105 105 references(:project, :author).
106 106 order("#{News.table_name}.created_on DESC").
107 107 to_a
108 108 end
109 109
110 110 def timelog_items
111 111 TimeEntry.
112 112 where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, User.current.today - 6, User.current.today).
113 113 joins(:activity, :project).
114 114 references(:issue => [:tracker, :status]).
115 115 includes(:issue => [:tracker, :status]).
116 116 order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC").
117 117 to_a
118 118 end
119 119 end
General Comments 0
You need to be logged in to leave comments. Login now