A bunch of tweaks to the Users directory
- Move user directory from `/directory` to `/users/` - Defaults to 'weekly' time period - Don't include deleted topics/posts in the results - Move heart icon to header instead of on each row - "Users" instead of "Users found"
This commit is contained in:
@@ -7,6 +7,12 @@ export default Ember.Component.extend(StringBuffer, {
|
||||
rerenderTriggers: ['order', 'asc'],
|
||||
|
||||
renderString(buffer) {
|
||||
|
||||
const icon = this.get('icon');
|
||||
if (icon) {
|
||||
buffer.push(iconHTML(icon));
|
||||
}
|
||||
|
||||
const field = this.get('field');
|
||||
buffer.push(I18n.t('directory.' + field));
|
||||
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
export default Ember.Controller.extend({
|
||||
queryParams: ['order', 'asc'],
|
||||
queryParams: ['period', 'order', 'asc'],
|
||||
period: 'weekly',
|
||||
order: 'likes_received',
|
||||
asc: null,
|
||||
|
||||
@@ -11,10 +11,6 @@ export default function() {
|
||||
});
|
||||
this.resource('topicBySlug', { path: '/t/:slug' });
|
||||
|
||||
this.resource('directory', function() {
|
||||
this.route('show', {path: '/:period'});
|
||||
});
|
||||
|
||||
this.resource('discovery', { path: '/' }, function() {
|
||||
// top
|
||||
this.route('top');
|
||||
@@ -56,6 +52,7 @@ export default function() {
|
||||
});
|
||||
|
||||
// User routes
|
||||
this.resource('users');
|
||||
this.resource('user', { path: '/users/:username' }, function() {
|
||||
this.resource('userActivity', { path: '/activity' }, function() {
|
||||
var self = this;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export default Discourse.Route.extend({
|
||||
beforeModel: function() {
|
||||
this.controllerFor('directory-show').setProperties({ sort: null, asc: null });
|
||||
this.replaceWith('directory.show', 'all');
|
||||
}
|
||||
});
|
||||
+3
-12
@@ -1,31 +1,22 @@
|
||||
export default Discourse.Route.extend({
|
||||
queryParams: {
|
||||
period: { refreshModel: true },
|
||||
order: { refreshModel: true },
|
||||
asc: { refreshModel: true },
|
||||
},
|
||||
|
||||
model(params) {
|
||||
// If we refresh via `refreshModel` set the old model to loading
|
||||
const existing = this.modelFor('directory-show');
|
||||
const existing = this.modelFor('users');
|
||||
if (existing) {
|
||||
existing.set('loading', true);
|
||||
}
|
||||
|
||||
this._period = params.period;
|
||||
return this.store.find('directoryItem', {
|
||||
id: params.period,
|
||||
asc: params.asc,
|
||||
order: params.order
|
||||
});
|
||||
return this.store.find('directoryItem', params);
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({ model, period: this._period });
|
||||
},
|
||||
|
||||
actions: {
|
||||
changePeriod(period) {
|
||||
this.transitionTo('directory.show', period);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
<div class="container">
|
||||
<div class='directory'>
|
||||
{{outlet}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,50 +0,0 @@
|
||||
{{period-chooser period=period action="changePeriod"}}
|
||||
|
||||
{{#loading-spinner condition=model.loading}}
|
||||
{{#if model.length}}
|
||||
<span class='total-rows'>{{i18n "directory.total_rows" count=model.totalRows}}</span>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th> </th>
|
||||
{{directory-toggle field="likes_received" order=order asc=asc}}
|
||||
{{directory-toggle field="likes_given" order=order asc=asc}}
|
||||
{{directory-toggle field="topic_count" order=order asc=asc}}
|
||||
{{directory-toggle field="post_count" order=order asc=asc}}
|
||||
{{directory-toggle field="topics_entered" order=order asc=asc}}
|
||||
{{#if showTimeRead}}
|
||||
<th>{{i18n "directory.time_read"}}</th>
|
||||
{{/if}}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each item in model}}
|
||||
<tr>
|
||||
<td>
|
||||
{{avatar item imageSize="tiny"}}
|
||||
{{#link-to 'user' item.username}}{{unbound item.username}}{{/link-to}}
|
||||
</td>
|
||||
<td class="likes">
|
||||
{{fa-icon "heart"}}
|
||||
{{number item.likes_received}}
|
||||
</td>
|
||||
<td class="likes">
|
||||
{{fa-icon "heart"}}
|
||||
{{number item.likes_given}}
|
||||
</td>
|
||||
<td>{{number item.topic_count}}</td>
|
||||
<td>{{number item.post_count}}</td>
|
||||
<td>{{number item.topics_entered}}</td>
|
||||
{{#if showTimeRead}}
|
||||
<td>{{unbound item.time_read}}</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{loading-spinner condition=model.loadingMore}}
|
||||
{{else}}
|
||||
<div class='clearfix'></div>
|
||||
<p>{{i18n "directory.no_results"}}</p>
|
||||
{{/if}}
|
||||
{{/loading-spinner}}
|
||||
@@ -22,7 +22,7 @@
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
<li>{{#link-to 'directory'}}{{i18n "directory.title"}}{{/link-to}}</li>
|
||||
<li>{{#link-to 'users'}}{{i18n "directory.title"}}{{/link-to}}</li>
|
||||
|
||||
{{plugin-outlet "site-map-links"}}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<div class="container">
|
||||
<div class='directory'>
|
||||
|
||||
{{period-chooser period=period}}
|
||||
|
||||
{{#loading-spinner condition=model.loading}}
|
||||
{{#if model.length}}
|
||||
<span class='total-rows'>{{i18n "directory.total_rows" count=model.totalRows}}</span>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th> </th>
|
||||
{{directory-toggle field="likes_received" order=order asc=asc icon="heart"}}
|
||||
{{directory-toggle field="likes_given" order=order asc=asc icon="heart"}}
|
||||
{{directory-toggle field="topic_count" order=order asc=asc}}
|
||||
{{directory-toggle field="post_count" order=order asc=asc}}
|
||||
{{directory-toggle field="topics_entered" order=order asc=asc}}
|
||||
{{#if showTimeRead}}
|
||||
<th>{{i18n "directory.time_read"}}</th>
|
||||
{{/if}}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each item in model}}
|
||||
<tr>
|
||||
<td>
|
||||
{{avatar item imageSize="tiny"}}
|
||||
{{#link-to 'user' item.username}}{{unbound item.username}}{{/link-to}}
|
||||
</td>
|
||||
<td>{{number item.likes_received}}</td>
|
||||
<td>{{number item.likes_given}}</td>
|
||||
<td>{{number item.topic_count}}</td>
|
||||
<td>{{number item.post_count}}</td>
|
||||
<td>{{number item.topics_entered}}</td>
|
||||
{{#if showTimeRead}}
|
||||
<td>{{unbound item.time_read}}</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{loading-spinner condition=model.loadingMore}}
|
||||
{{else}}
|
||||
<div class='clearfix'></div>
|
||||
<p>{{i18n "directory.no_results"}}</p>
|
||||
{{/if}}
|
||||
{{/loading-spinner}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user