|
1 | | -<% resource_limit = 30 %> |
| 1 | +<% resource_limit = UsersHelper.user_profile_resource_limit %> |
2 | 2 | <div class="wrapper collapsing-wrapper-tb"> |
3 | 3 | <%- model_class = Profile -%> |
4 | 4 |
|
|
143 | 143 |
|
144 | 144 | <div class="row"> |
145 | 145 | <% materials = @user.materials.limit(resource_limit) %> |
| 146 | + <% materials_count = @user.materials.count %> |
146 | 147 | <% upcoming_events = @user.events.not_finished %> |
147 | 148 | <% past_events = @user.events.finished %> |
148 | 149 | <% events = upcoming_events.limit(resource_limit) %> |
149 | | - <% workflows = @user.workflows.visible_by(current_user) %> |
150 | | - <% collections = @user.collections.limit(resource_limit) %> |
| 150 | + <% events_count = @user.events.count %> |
| 151 | + <% workflows = @user.workflows.visible_by(current_user).limit(resource_limit) %> |
| 152 | + <% workflows_count = @user.workflows.visible_by(current_user).count %> |
| 153 | + <% collections = @user.collections.visible_by(current_user).limit(resource_limit) %> |
| 154 | + <% collections_count = @user.collections.visible_by(current_user).count %> |
151 | 155 |
|
152 | 156 | <ul class="nav nav-tabs"> |
153 | 157 |
|
154 | 158 | <!-- Tab: Events --> |
155 | 159 | <% if TeSS::Config.feature['events'] %> |
156 | 160 | <%= tab('Events', icon_class_for_model('events'), 'events', active: true, |
157 | | - disabled: { check: @user.events.count.zero?, message: 'No registered events' }, |
158 | | - count: @user.events.count) %> |
| 161 | + disabled: { check: events_count.zero?, message: 'No registered events' }, |
| 162 | + count: events_count) %> |
159 | 163 | <% end %> |
160 | 164 |
|
161 | 165 | <!-- Tab: Materials --> |
162 | 166 | <% if TeSS::Config.feature['materials'] %> |
163 | 167 | <%= tab('Materials', icon_class_for_model('materials'), 'materials', |
164 | 168 | disabled: { check: materials.none?, message: 'No registered training materials' }, |
165 | | - count: @user.materials.count) %> |
| 169 | + count: materials_count) %> |
166 | 170 | <% end %> |
167 | 171 |
|
168 | 172 | <!-- Tab: Collections --> |
169 | 173 | <% if TeSS::Config.feature['collections'] %> |
170 | 174 | <%= tab('Collections', icon_class_for_model('collections'), 'collections', |
171 | 175 | disabled: { check: collections.none?, message: 'No registered collections' }, |
172 | | - count: @user.collections.count) %> |
| 176 | + count: collections_count) %> |
173 | 177 | <% end %> |
174 | 178 |
|
175 | 179 | <!-- Tab: Workflows --> |
176 | 180 | <% if TeSS::Config.feature['workflows'] %> |
177 | 181 | <%= tab('Workflows', icon_class_for_model('workflows'), 'workflows', |
178 | 182 | disabled: { check: workflows.none?, message: 'No workflows' }, |
179 | | - count: workflows.count) %> |
| 183 | + count: workflows_count) %> |
180 | 184 | <% end %> |
181 | 185 | </ul> |
182 | 186 |
|
|
214 | 218 | <div id="materials" class="tab-pane fade"> |
215 | 219 | <div class="row"> |
216 | 220 | <div class="search-results-count"> |
217 | | - <%= (materials.count > 0 ? "Showing" : "Found") + " #{pluralize(materials.count, "material")}#{(@user.materials.count > resource_limit) ? " out of #{@user.materials.count}" : ''}." %> |
218 | | - <%= link_to('View all results.', materials_path(user: @user.username)) if (@user.materials.count > resource_limit) %> |
| 221 | + <%= (materials.count > 0 ? "Showing" : "Found") + " #{pluralize(materials.count, "material")}#{(materials_count > resource_limit) ? " out of #{materials_count}" : ''}." %> |
| 222 | + <%= link_to('View all results', materials_path(user: @user.username)) if (materials_count > resource_limit) %> |
219 | 223 | </div> |
220 | 224 | <% materials.each do |material| %> |
221 | 225 | <%= render material %> |
|
229 | 233 | <div id="collections" class="tab-pane fade"> |
230 | 234 | <div class="row"> |
231 | 235 | <div class="search-results-count"> |
232 | | - <%= (collections.count > 0 ? "Showing" : "Found") + " #{pluralize(collections.count, "collection")}#{(@user.collections.count > resource_limit) ? " out of #{@user.collections.count}" : ''}." %> |
233 | | - <%= link_to('View all results.', collections(user: @user.username)) if (@user.collections.count > resource_limit) %> |
| 236 | + <%= (collections.count > 0 ? "Showing" : "Found") + " #{pluralize(collections.count, "collection")}#{(collections_count > resource_limit) ? " out of #{collections_count}" : ''}." %> |
| 237 | + <%= link_to('View all results', collections_path(user: @user.username)) if (collections_count > resource_limit) %> |
234 | 238 | </div> |
235 | 239 | <% collections.each do |collection| %> |
236 | 240 | <%= render collection %> |
|
244 | 248 | <div id="workflows" class="tab-pane fade"> |
245 | 249 | <div class="row"> |
246 | 250 | <div class="search-results-count"> |
247 | | - <%= pluralize(workflows.count, 'workflow') %> found |
| 251 | + <%= (workflows.count > 0 ? "Showing" : "Found") + " #{pluralize(workflows.count, "workflow")}#{(workflows_count > resource_limit) ? " out of #{workflows_count}" : ''}." %> |
| 252 | + <%= link_to('View all results', workflows_path(user: @user.username)) if (workflows_count > resource_limit) %> |
248 | 253 | </div> |
249 | 254 | <% if workflows.any? %> |
250 | 255 | <ul class="masonry media-grid" style="margin-top: 15px;"> |
|
0 commit comments