This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/user_invited_controller.js

41 lines
1021 B
JavaScript

/**
This controller handles actions related to a user's invitations
@class UserInvitedController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
Discourse.UserInvitedController = Ember.ArrayController.extend({
_searchTermChanged: Discourse.debounce(function() {
var self = this;
Discourse.Invite.findInvitedBy(self.get('user'), this.get('searchTerm')).then(function (invites) {
self.set('model', invites);
});
}, 250).observes('searchTerm'),
maxInvites: function() {
return Discourse.SiteSettings.invites_shown;
}.property(),
showSearch: function() {
if (Em.isNone(this.get('searchTerm')) && this.get('model.length') === 0) { return false; }
return true;
}.property('searchTerm', 'model.length'),
truncated: function() {
return this.get('model.length') === Discourse.SiteSettings.invites_shown;
}.property('model.length'),
actions: {
rescind: function(invite) {
invite.rescind();
return false;
}
}
});