##// END OF EJS Templates
Refactoring of tabs rendering....
Jean-Philippe Lang -
r2757:ede9960444ed
parent child
Show More
@@ -0,0 +1,19
1 <% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>
2
3 <div class="tabs">
4 <ul>
5 <% tabs.each do |tab| -%>
6 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
7 :id => "tab-#{tab[:name]}",
8 :class => (tab[:name] != selected_tab ? nil : 'selected'),
9 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
10 <% end -%>
11 </ul>
12 </div>
13
14 <% tabs.each do |tab| -%>
15 <%= content_tag('div', render(:partial => tab[:partial], :locals => {:tab => tab} ),
16 :id => "tab-content-#{tab[:name]}",
17 :style => (tab[:name] != selected_tab ? 'display:none' : nil),
18 :class => 'tab-content') %>
19 <% end -%>
@@ -0,0 +1,32
1 <table class="list">
2 <thead><tr>
3 <th width="30%"><%=l(:field_name)%></th>
4 <th><%=l(:field_field_format)%></th>
5 <th><%=l(:field_is_required)%></th>
6 <% if tab[:name] == 'IssueCustomField' %>
7 <th><%=l(:field_is_for_all)%></th>
8 <th><%=l(:label_used_by)%></th>
9 <% end %>
10 <th><%=l(:button_sort)%></th>
11 <th width="10%"></th>
12 </tr></thead>
13 <tbody>
14 <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
15 <tr class="<%= cycle("odd", "even") %>">
16 <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
17 <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
18 <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
19 <% if tab[:name] == 'IssueCustomField' %>
20 <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
21 <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
22 <% end %>
23 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
24 <td align="center">
25 <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
26 </td>
27 </tr>
28 <% end; reset_cycle %>
29 </tbody>
30 </table>
31
32 <p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
@@ -132,6 +132,15 module ApplicationHelper
132 s
132 s
133 end
133 end
134
134
135 # Renders tabs and their content
136 def render_tabs(tabs)
137 if tabs.any?
138 render :partial => 'common/tabs', :locals => {:tabs => tabs}
139 else
140 content_tag 'p', l(:label_no_data), :class => "nodata"
141 end
142 end
143
135 # Renders the project quick-jump box
144 # Renders the project quick-jump box
136 def render_project_jump_box
145 def render_project_jump_box
137 # Retrieve them now to avoid a COUNT query
146 # Retrieve them now to avoid a COUNT query
@@ -18,11 +18,11
18 module CustomFieldsHelper
18 module CustomFieldsHelper
19
19
20 def custom_fields_tabs
20 def custom_fields_tabs
21 tabs = [{:name => 'IssueCustomField', :label => :label_issue_plural},
21 tabs = [{:name => 'IssueCustomField', :partial => 'custom_fields/index', :label => :label_issue_plural},
22 {:name => 'TimeEntryCustomField', :label => :label_spent_time},
22 {:name => 'TimeEntryCustomField', :partial => 'custom_fields/index', :label => :label_spent_time},
23 {:name => 'ProjectCustomField', :label => :label_project_plural},
23 {:name => 'ProjectCustomField', :partial => 'custom_fields/index', :label => :label_project_plural},
24 {:name => 'UserCustomField', :label => :label_user_plural},
24 {:name => 'UserCustomField', :partial => 'custom_fields/index', :label => :label_user_plural},
25 {:name => 'GroupCustomField', :label => :label_group_plural}
25 {:name => 'GroupCustomField', :partial => 'custom_fields/index', :label => :label_group_plural}
26 ]
26 ]
27 end
27 end
28
28
@@ -1,53 +1,5
1 <h2><%=l(:label_custom_field_plural)%></h2>
1 <h2><%=l(:label_custom_field_plural)%></h2>
2
2
3 <% selected_tab = params[:tab] ? params[:tab].to_s : custom_fields_tabs.first[:name] %>
3 <%= render_tabs custom_fields_tabs %>
4
5 <div class="tabs">
6 <ul>
7 <% custom_fields_tabs.each do |tab| -%>
8 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
9 :id => "tab-#{tab[:name]}",
10 :class => (tab[:name] != selected_tab ? nil : 'selected'),
11 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
12 <% end -%>
13 </ul>
14 </div>
15
16 <% custom_fields_tabs.each do |tab| %>
17 <div id="tab-content-<%= tab[:name] %>" class="tab-content" style="<%= tab[:name] != selected_tab ? 'display:none' : nil %>">
18 <table class="list">
19 <thead><tr>
20 <th width="30%"><%=l(:field_name)%></th>
21 <th><%=l(:field_field_format)%></th>
22 <th><%=l(:field_is_required)%></th>
23 <% if tab[:name] == 'IssueCustomField' %>
24 <th><%=l(:field_is_for_all)%></th>
25 <th><%=l(:label_used_by)%></th>
26 <% end %>
27 <th><%=l(:button_sort)%></th>
28 <th width="10%"></th>
29 </tr></thead>
30 <tbody>
31 <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
32 <tr class="<%= cycle("odd", "even") %>">
33 <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
34 <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
35 <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
36 <% if tab[:name] == 'IssueCustomField' %>
37 <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
38 <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
39 <% end %>
40 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
41 <td align="center">
42 <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
43 </td>
44 </tr>
45 <% end; reset_cycle %>
46 </tbody>
47 </table>
48
49 <p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
50 </div>
51 <% end %>
52
4
53 <% html_title(l(:label_custom_field_plural)) -%>
5 <% html_title(l(:label_custom_field_plural)) -%>
@@ -1,23 +1,5
1 <h2><%= link_to l(:label_group_plural), groups_path %> &#187; <%= h(@group) %></h2>
1 <h2><%= link_to l(:label_group_plural), groups_path %> &#187; <%= h(@group) %></h2>
2
2
3 <% selected_tab = params[:tab] ? params[:tab].to_s : group_settings_tabs.first[:name] %>
3 <%= render_tabs group_settings_tabs %>
4
5 <div class="tabs">
6 <ul>
7 <% group_settings_tabs.each do |tab| -%>
8 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
9 :id => "tab-#{tab[:name]}",
10 :class => (tab[:name] != selected_tab ? nil : 'selected'),
11 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
12 <% end -%>
13 </ul>
14 </div>
15
16 <% group_settings_tabs.each do |tab| -%>
17 <%= content_tag('div', render(:partial => tab[:partial]),
18 :id => "tab-content-#{tab[:name]}",
19 :style => (tab[:name] != selected_tab ? 'display:none' : nil),
20 :class => 'tab-content') %>
21 <% end -%>
22
4
23 <% html_title(l(:label_group), @group, l(:label_administration)) -%>
5 <% html_title(l(:label_group), @group, l(:label_administration)) -%>
@@ -1,29 +1,5
1 <h2><%=l(:label_settings)%></h2>
1 <h2><%=l(:label_settings)%></h2>
2
2
3 <% tabs = project_settings_tabs %>
3 <%= render_tabs project_settings_tabs %>
4
5 <% if tabs.any? %>
6 <% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>
7
8 <div class="tabs">
9 <ul>
10 <% tabs.each do |tab| -%>
11 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
12 :id => "tab-#{tab[:name]}",
13 :class => (tab[:name] != selected_tab ? nil : 'selected'),
14 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
15 <% end -%>
16 </ul>
17 </div>
18
19 <% tabs.each do |tab| -%>
20 <%= content_tag('div', render(:partial => tab[:partial]),
21 :id => "tab-content-#{tab[:name]}",
22 :style => (tab[:name] != selected_tab ? 'display:none' : nil),
23 :class => 'tab-content') %>
24 <% end -%>
25 <% else %>
26 <p class="nodata"><%= l(:label_no_data) %></p>
27 <% end %>
28
4
29 <% html_title(l(:label_settings)) -%>
5 <% html_title(l(:label_settings)) -%>
@@ -1,23 +1,5
1 <h2><%= l(:label_settings) %></h2>
1 <h2><%= l(:label_settings) %></h2>
2
2
3 <% selected_tab = params[:tab] ? params[:tab].to_s : administration_settings_tabs.first[:name] %>
3 <%= render_tabs administration_settings_tabs %>
4
5 <div class="tabs">
6 <ul>
7 <% administration_settings_tabs.each do |tab| -%>
8 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
9 :id => "tab-#{tab[:name]}",
10 :class => (tab[:name] != selected_tab ? nil : 'selected'),
11 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
12 <% end -%>
13 </ul>
14 </div>
15
16 <% administration_settings_tabs.each do |tab| -%>
17 <%= content_tag('div', render(:partial => tab[:partial]),
18 :id => "tab-content-#{tab[:name]}",
19 :style => (tab[:name] != selected_tab ? 'display:none' : nil),
20 :class => 'tab-content') %>
21 <% end -%>
22
4
23 <% html_title(l(:label_settings), l(:label_administration)) -%>
5 <% html_title(l(:label_settings), l(:label_administration)) -%>
@@ -4,24 +4,6
4
4
5 <h2><%= link_to l(:label_user_plural), :controller => 'users', :action => 'index' %> &#187; <%=h @user.login %></h2>
5 <h2><%= link_to l(:label_user_plural), :controller => 'users', :action => 'index' %> &#187; <%=h @user.login %></h2>
6
6
7 <% selected_tab = params[:tab] ? params[:tab].to_s : user_settings_tabs.first[:name] %>
7 <%= render_tabs user_settings_tabs %>
8
9 <div class="tabs">
10 <ul>
11 <% user_settings_tabs.each do |tab| -%>
12 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
13 :id => "tab-#{tab[:name]}",
14 :class => (tab[:name] != selected_tab ? nil : 'selected'),
15 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
16 <% end -%>
17 </ul>
18 </div>
19
20 <% user_settings_tabs.each do |tab| -%>
21 <%= content_tag('div', render(:partial => tab[:partial]),
22 :id => "tab-content-#{tab[:name]}",
23 :style => (tab[:name] != selected_tab ? 'display:none' : nil),
24 :class => 'tab-content') %>
25 <% end -%>
26
8
27 <% html_title(l(:label_user), @user.login, l(:label_administration)) -%>
9 <% html_title(l(:label_user), @user.login, l(:label_administration)) -%>
General Comments 0
You need to be logged in to leave comments. Login now