This moves the finder logic out of the component

This commit is contained in:
lreeves 2014-07-22 20:11:21 -04:00
parent dffe528400
commit 9c2f4b55ac
3 changed files with 11 additions and 4 deletions

View File

@ -34,8 +34,8 @@ export default Em.Component.extend({
return g.name;
},
dataSource: function(term) {
// TODO: Components should definitely not perform queries
return Discourse.Group.findAll({search: term, ignore_automatic: true}).then(function(groups){
return self.get("groupFinder")(term).then(function(groups){
if(!selectedGroups){
return groups;
}

View File

@ -48,7 +48,7 @@ export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
}.property('model'),
/**
Is Private Topic? (i.e. visible only to specific group members)
Is Private Topic? (i.e. visible only to specific group members)
@property isPrivateTopic
**/
@ -80,6 +80,13 @@ export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
}
}.property('isPrivateTopic'),
/**
Function to find groups.
**/
groupFinder: function(term) {
return Discourse.Group.findAll({search: term, ignore_automatic: true});
},
/**
The "success" text for when the invite was created.

View File

@ -15,7 +15,7 @@
{{#if isAdmin}}
<label>{{{groupInstructions}}}</label>
{{group-selector includeAuto=false groupNames=groupNames placeholderKey="topic.invite_private.group_name"}}
{{group-selector includeAuto=false groupFinder=groupFinder groupNames=groupNames placeholderKey="topic.invite_private.group_name"}}
{{/if}}
{{/if}}
</div>