summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2010-08-08 07:07:20 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2010-08-08 07:07:20 +0000
commita1b607480abc6649f9531b1fd8a7d20c3c656084 (patch)
treec23e04bd9922308d8c00f9e3962a02bdcb120248 /app
parent5b64f0ff969db3f0a99c1c780ab03d842da6b59d (diff)
downloadredmine-a1b607480abc6649f9531b1fd8a7d20c3c656084.tar.gz
redmine-a1b607480abc6649f9531b1fd8a7d20c3c656084.zip
Refactor: added link_to_project helper to handle links to projects
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3924 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb27
-rw-r--r--app/helpers/projects_helper.rb2
-rw-r--r--app/helpers/queries_helper.rb2
-rw-r--r--app/views/admin/projects.rhtml2
-rw-r--r--app/views/issues/_list_simple.rhtml2
-rw-r--r--app/views/news/_news.rhtml2
-rw-r--r--app/views/news/index.rhtml2
-rw-r--r--app/views/users/_memberships.rhtml2
-rw-r--r--app/views/users/show.rhtml2
-rw-r--r--app/views/welcome/index.rhtml2
10 files changed, 30 insertions, 15 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d6fd16a6e..2c334b7f0 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -103,6 +103,23 @@ module ApplicationHelper
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision))
end
+ # Generates a link to a project if active
+ # Examples:
+ #
+ # link_to_project(project) # => link to the specified project overview
+ # link_to_project(project, :action=>'settings') # => link to project settings
+ # link_to_project(project, {:only_path => false}, :class => "project") # => 3rd arg adds html options
+ # link_to_project(project, {}, :class => "project") # => html options with default url (project overview)
+ #
+ def link_to_project(project, options={}, html_options = nil)
+ if project.active?
+ url = {:controller => 'projects', :action => 'show', :id => project}.merge(options)
+ link_to(h(project), url, html_options)
+ else
+ h(project)
+ end
+ end
+
def toggle_link(name, id, options={})
onclick = "Element.toggle('#{id}'); "
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
@@ -368,12 +385,12 @@ module ApplicationHelper
ancestors = (@project.root? ? [] : @project.ancestors.visible)
if ancestors.any?
root = ancestors.shift
- b << link_to(h(root), {:controller => 'projects', :action => 'show', :id => root, :jump => current_menu_item}, :class => 'root')
+ b << link_to_project(root, {:jump => current_menu_item}, :class => 'root')
if ancestors.size > 2
b << '&#8230;'
ancestors = ancestors[-2, 2]
end
- b += ancestors.collect {|p| link_to(h(p), {:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item}, :class => 'ancestor') }
+ b += ancestors.collect {|p| link_to_project(p, {:jump => current_menu_item}, :class => 'ancestor') }
end
b << h(@project)
b.join(' &#187; ')
@@ -605,8 +622,7 @@ module ApplicationHelper
end
when 'project'
if p = Project.visible.find_by_id(oid)
- link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
- :class => 'project'
+ link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
end
elsif sep == ':'
@@ -648,8 +664,7 @@ module ApplicationHelper
end
when 'project'
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
- link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
- :class => 'project'
+ link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 044ccfb77..3b089c111 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -72,7 +72,7 @@ module ProjectsHelper
end
classes = (ancestors.empty? ? 'root' : 'child')
s << "<li class='#{classes}'><div class='#{classes}'>" +
- link_to(h(project), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
+ link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
s << "</div>\n"
ancestors << project
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 594c8a79a..26be63693 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -50,7 +50,7 @@ module QueriesHelper
when 'User'
link_to_user value
when 'Project'
- link_to(h(value), :controller => 'projects', :action => 'show', :id => value)
+ link_to_project value
when 'Version'
link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
when 'TrueClass'
diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml
index dc7bb97ed..46b68e4cc 100644
--- a/app/views/admin/projects.rhtml
+++ b/app/views/admin/projects.rhtml
@@ -27,7 +27,7 @@
<tbody>
<% project_tree(@projects) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= css_project_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
- <td class="name"><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %></td>
+ <td class="name"><%= link_to_project(project, :action => 'settings') %></td>
<td><%= textilizable project.short_description, :project => project %></td>
<td align="center"><%= checked_image project.is_public? %></td>
<td align="center"><%= format_date(project.created_on) %></td>
diff --git a/app/views/issues/_list_simple.rhtml b/app/views/issues/_list_simple.rhtml
index 38823765e..dd7f48946 100644
--- a/app/views/issues/_list_simple.rhtml
+++ b/app/views/issues/_list_simple.rhtml
@@ -14,7 +14,7 @@
<%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;') %>
<%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %>
</td>
- <td class="project"><%= link_to(h(issue.project), :controller => 'projects', :action => 'show', :id => issue.project) %></td>
+ <td class="project"><%= link_to_project(issue.project) %></td>
<td class="tracker"><%=h issue.tracker %></td>
<td class="subject">
<%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>)
diff --git a/app/views/news/_news.rhtml b/app/views/news/_news.rhtml
index e95e8a557..8f481f09c 100644
--- a/app/views/news/_news.rhtml
+++ b/app/views/news/_news.rhtml
@@ -1,4 +1,4 @@
-<p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless @project %>
+<p><%= link_to_project(news.project) + ': ' unless @project %>
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<br />
diff --git a/app/views/news/index.rhtml b/app/views/news/index.rhtml
index 11a39232c..8b7cc66e1 100644
--- a/app/views/news/index.rhtml
+++ b/app/views/news/index.rhtml
@@ -28,7 +28,7 @@
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<% @newss.each do |news| %>
- <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %>
+ <h3><%= link_to_project(news.project) + ': ' unless news.project == @project %>
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %></h3>
<p class="author"><%= authoring news.created_on, news.author %></p>
diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml
index 4c71f81ba..441294708 100644
--- a/app/views/users/_memberships.rhtml
+++ b/app/views/users/_memberships.rhtml
@@ -15,7 +15,7 @@
<% next if membership.new_record? %>
<tr id="member-<%= membership.id %>" class="<%= cycle 'odd', 'even' %> class">
<td class="project">
- <%= link_to h(membership.project), {:controller => 'projects', :action => 'show', :id => membership.project} %>
+ <%= link_to_project membership.project %>
</td>
<td class="roles">
<span id="member-<%= membership.id %>-roles"><%=h membership.roles.sort.collect(&:to_s).join(', ') %></span>
diff --git a/app/views/users/show.rhtml b/app/views/users/show.rhtml
index 82634b010..df5aec825 100644
--- a/app/views/users/show.rhtml
+++ b/app/views/users/show.rhtml
@@ -24,7 +24,7 @@
<h3><%=l(:label_project_plural)%></h3>
<ul>
<% for membership in @memberships %>
- <li><%= link_to(h(membership.project.name), :controller => 'projects', :action => 'show', :id => membership.project) %>
+ <li><%= link_to_project(membership.project) %>
(<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li>
<% end %>
</ul>
diff --git a/app/views/welcome/index.rhtml b/app/views/welcome/index.rhtml
index a0ada7cce..6ac09c153 100644
--- a/app/views/welcome/index.rhtml
+++ b/app/views/welcome/index.rhtml
@@ -20,7 +20,7 @@
<% for project in @projects %>
<% @project = project %>
<li>
- <%= link_to h(project.name), :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
+ <%= link_to_project project %> (<%= format_time(project.created_on) %>)
<%= textilizable project.short_description, :project => project %>
</li>
<% end %>
'backport/48331/stable28'>backport/48331/stable28 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/lib/l10n/cs.js
blob: ae814c009beb1c73dee7b15d833b6bfef165d7da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280