Fix 'You must choose a category' when a category is already chosen
This commit is contained in:
parent
30cfa33629
commit
adbb6a19bb
|
@ -334,6 +334,10 @@ Discourse.Composer = Discourse.Model.extend({
|
|||
reply: opts.reply || this.get("reply") || ""
|
||||
});
|
||||
|
||||
if (!this.get('categoryName') && !Discourse.SiteSettings.allow_uncategorized_topics && Discourse.Category.list().length > 0) {
|
||||
this.set('categoryName', Discourse.Category.list()[0].get('name'));
|
||||
}
|
||||
|
||||
if (opts.postId) {
|
||||
this.set('loading', true);
|
||||
Discourse.Post.load(opts.postId).then(function(result) {
|
||||
|
|
|
@ -176,3 +176,15 @@ test('clearState', function() {
|
|||
blank(composer.get('title'));
|
||||
|
||||
});
|
||||
|
||||
test('initial category when uncategorized is allowed', function() {
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = true;
|
||||
var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1});
|
||||
equal(composer.get('categoryName'),undefined,"Uncategorized by default");
|
||||
});
|
||||
|
||||
test('initial category when uncategorized is not allowed', function() {
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = false;
|
||||
var composer = Discourse.Composer.open({action: 'createTopic', draftKey: 'asfd', draftSequence: 1});
|
||||
ok(composer.get('categoryName') !== undefined, "Not uncategorized by default");
|
||||
});
|
Loading…
Reference in New Issue