mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 04:44:59 +00:00
FIX: Triggering a refresh while subcategory lists was broken.
It would then list all categories isntead of the subcategory you were viewing at that time.
This commit is contained in:
parent
b4e5937850
commit
6c4c542ae3
@ -8,7 +8,6 @@ export default DiscoveryController.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// Don't refresh if we're still loading
|
// Don't refresh if we're still loading
|
||||||
if (this.get('controllers.discovery.loading')) { return; }
|
if (this.get('controllers.discovery.loading')) { return; }
|
||||||
@ -17,7 +16,17 @@ export default DiscoveryController.extend({
|
|||||||
// router and ember throws an error due to missing `handlerInfos`.
|
// router and ember throws an error due to missing `handlerInfos`.
|
||||||
// Lesson learned: Don't call `loading` yourself.
|
// Lesson learned: Don't call `loading` yourself.
|
||||||
this.set('controllers.discovery.loading', true);
|
this.set('controllers.discovery.loading', true);
|
||||||
Discourse.CategoryList.list('categories').then(function(list) {
|
|
||||||
|
var parentCategory = this.get('model.parentCategory');
|
||||||
|
var promise;
|
||||||
|
if (parentCategory) {
|
||||||
|
promise = Discourse.CategoryList.listForParent(parentCategory);
|
||||||
|
} else {
|
||||||
|
promise = Discourse.CategoryList.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
promise.then(function(list) {
|
||||||
self.set('model', list);
|
self.set('model', list);
|
||||||
self.send('loadingComplete');
|
self.send('loadingComplete');
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
/**
|
|
||||||
A data model for containing a list of categories
|
|
||||||
|
|
||||||
@class CategoryList
|
|
||||||
@extends Discourse.Model
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.CategoryList = Ember.ArrayProxy.extend({
|
Discourse.CategoryList = Ember.ArrayProxy.extend({
|
||||||
init: function() {
|
init: function() {
|
||||||
this.set('content', []);
|
this.set('content', []);
|
||||||
@ -50,7 +42,8 @@ Discourse.CategoryList.reopenClass({
|
|||||||
var self = this;
|
var self = this;
|
||||||
return Discourse.ajax('/categories.json?parent_category_id=' + category.get('id')).then(function(result) {
|
return Discourse.ajax('/categories.json?parent_category_id=' + category.get('id')).then(function(result) {
|
||||||
return Discourse.CategoryList.create({
|
return Discourse.CategoryList.create({
|
||||||
categories: self.categoriesFrom(result)
|
categories: self.categoriesFrom(result),
|
||||||
|
parentCategory: category
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -10,71 +10,71 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each c in categories}}
|
{{#each c in categories}}
|
||||||
<tr data-category_id='{{unbound c.id}}' {{bind-attr class="c.description_excerpt:has-description:no-description c.logo_url:has-logo:no-logo"}}>
|
<tr data-category_id='{{unbound c.id}}' {{bind-attr class="c.description_excerpt:has-description:no-description c.logo_url:has-logo:no-logo"}}>
|
||||||
<td class='category' style="border-color: #{{unbound c.color}}">
|
<td class='category' style="border-color: #{{unbound c.color}}">
|
||||||
<div>
|
<div>
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
{{category-title-link category=c}}
|
{{category-title-link category=c}}
|
||||||
{{#if c.unreadTopics}}
|
{{#if c.unreadTopics}}
|
||||||
<a href={{unbound c.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=c.unreadTopics}}'>{{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}}</a>
|
<a href={{unbound c.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=c.unreadTopics}}'>{{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}}</a>
|
||||||
{{/if}}
|
|
||||||
{{#if c.newTopics}}
|
|
||||||
<a href={{unbound c.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=c.newTopics}}'>{{i18n 'filters.new.lower_title_with_count' count=c.newTopics}}</a>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
{{#if c.description_excerpt}}
|
|
||||||
<div class="category-description">
|
|
||||||
{{{c.description_excerpt}}}
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
{{#if c.subcategories}}
|
|
||||||
<div class='subcategories'>
|
|
||||||
{{#each s in c.subcategories}}
|
|
||||||
{{category-link s showParent="true" onlyStripe="true"}}
|
|
||||||
{{#if s.unreadTopics}}
|
|
||||||
<a href={{unbound s.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=s.unreadTopics}}'>{{unbound s.unreadTopics}}</a>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if s.newTopics}}
|
{{#if c.newTopics}}
|
||||||
<a href={{unbound s.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=s.newTopics}}'>{{unbound s.newTopics}}</a>
|
<a href={{unbound c.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=c.newTopics}}'>{{i18n 'filters.new.lower_title_with_count' count=c.newTopics}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{#if c.description_excerpt}}
|
||||||
</td>
|
<div class="category-description">
|
||||||
<td {{bind-attr class="c.archived :latest"}}>
|
{{{c.description_excerpt}}}
|
||||||
{{#each f in c.featuredTopics}}
|
</div>
|
||||||
<div class="featured-topic">
|
{{/if}}
|
||||||
{{topic-status topic=f}}
|
{{#if c.subcategories}}
|
||||||
<a class='title' href="{{unbound f.lastUnreadUrl}}">{{{unbound f.fancy_title}}}</a>
|
<div class='subcategories'>
|
||||||
{{topic-post-badges newPosts=f.totalUnread unseen=f.unseen url=f.lastUnreadUrl}}
|
{{#each s in c.subcategories}}
|
||||||
|
{{category-link s showParent="true" onlyStripe="true"}}
|
||||||
|
{{#if s.unreadTopics}}
|
||||||
|
<a href={{unbound s.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=s.unreadTopics}}'>{{unbound s.unreadTopics}}</a>
|
||||||
|
{{/if}}
|
||||||
|
{{#if s.newTopics}}
|
||||||
|
<a href={{unbound s.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=s.newTopics}}'>{{unbound s.newTopics}}</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
<td {{bind-attr class="c.archived :latest"}}>
|
||||||
|
{{#each f in c.featuredTopics}}
|
||||||
|
<div class="featured-topic">
|
||||||
|
{{topic-status topic=f}}
|
||||||
|
<a class='title' href="{{unbound f.lastUnreadUrl}}">{{{unbound f.fancy_title}}}</a>
|
||||||
|
{{topic-post-badges newPosts=f.totalUnread unseen=f.unseen url=f.lastUnreadUrl}}
|
||||||
|
|
||||||
{{#if controller.latestTopicOnly}}
|
{{#if controller.latestTopicOnly}}
|
||||||
<div class='last-user-info'>
|
<div class='last-user-info'>
|
||||||
{{i18n 'categories.latest_by'}} <a href="{{{unbound f.lastPosterUrl}}}">{{unbound f.last_poster.username}}</a>
|
{{i18n 'categories.latest_by'}} <a href="{{{unbound f.lastPosterUrl}}}">{{unbound f.last_poster.username}}</a>
|
||||||
<a href="{{unbound f.lastPostUrl}}">{{format-age f.last_posted_at}}</a>
|
<a href="{{unbound f.lastPostUrl}}">{{format-age f.last_posted_at}}</a>
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
<a href="{{unbound f.lastPostUrl}}" class="last-posted-at">{{format-age f.last_posted_at}}</a>
|
<a href="{{unbound f.lastPostUrl}}" class="last-posted-at">{{format-age f.last_posted_at}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
|
||||||
</td>
|
|
||||||
<td class='stats' {{bind-attr title="c.topicStatsTitle"}}>
|
|
||||||
<table class="categoryStats">
|
|
||||||
<tbody>
|
|
||||||
{{#each s in c.topicCountStats}}
|
|
||||||
<tr>
|
|
||||||
<td class="value">{{s.value}}</td>
|
|
||||||
<td class="unit"> / {{s.unit}}</td>
|
|
||||||
</tr>
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</td>
|
||||||
</table>
|
<td class='stats' {{bind-attr title="c.topicStatsTitle"}}>
|
||||||
</td>
|
<table class="categoryStats">
|
||||||
</tr>
|
<tbody>
|
||||||
|
{{#each s in c.topicCountStats}}
|
||||||
|
<tr>
|
||||||
|
<td class="value">{{s.value}}</td>
|
||||||
|
<td class="unit"> / {{s.unit}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
{{#if selected}}
|
{{#if selected}}
|
||||||
<div id='bulk-select'>
|
<div id='bulk-select'>
|
||||||
<button class='btn no-text' {{action "showBulkActions"}}><i class="fa fa-wrench"></i></button>
|
{{d-button action="showBulkActions" icon="wrench" class="no-text"}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user