2015-08-10 17:11:27 -04:00
|
|
|
import Invite from 'discourse/models/invite';
|
2015-07-31 10:53:18 -04:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2014-11-19 14:37:43 -05:00
|
|
|
|
2015-07-31 10:53:18 -04:00
|
|
|
export default Discourse.Route.extend({
|
2013-10-10 12:48:26 -04:00
|
|
|
|
2015-07-31 10:53:18 -04:00
|
|
|
model(params) {
|
2015-08-24 15:03:25 -04:00
|
|
|
const self = this;
|
|
|
|
Invite.findInvitedCount(self.modelFor("user")).then(function (result) {
|
|
|
|
self.set('invitesCount', result);
|
|
|
|
});
|
|
|
|
self.inviteFilter = params.filter;
|
|
|
|
return Invite.findInvitedBy(self.modelFor("user"), params.filter);
|
2013-10-30 15:45:13 -04:00
|
|
|
},
|
|
|
|
|
2015-07-31 10:53:18 -04:00
|
|
|
afterModel(model) {
|
2015-07-23 08:52:43 -04:00
|
|
|
if (!model.can_see_invite_details) {
|
2015-07-31 10:53:18 -04:00
|
|
|
this.replaceWith("userInvited.show", "redeemed");
|
2015-07-23 08:52:43 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-10 15:01:15 -04:00
|
|
|
setupController(controller, model) {
|
2013-11-05 17:52:50 -05:00
|
|
|
controller.setProperties({
|
|
|
|
model: model,
|
2015-07-31 10:53:18 -04:00
|
|
|
user: this.controllerFor("user").get("model"),
|
2015-07-11 08:09:12 -04:00
|
|
|
filter: this.inviteFilter,
|
2015-07-31 10:53:18 -04:00
|
|
|
searchTerm: "",
|
2015-08-24 15:03:25 -04:00
|
|
|
totalInvites: model.invites.length,
|
|
|
|
invitesCount: this.get('invitesCount')
|
2013-11-05 17:52:50 -05:00
|
|
|
});
|
2013-11-06 12:56:26 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2015-03-10 15:01:15 -04:00
|
|
|
showInvite() {
|
2015-07-31 10:53:18 -04:00
|
|
|
showModal("invite", { model: this.currentUser });
|
|
|
|
this.controllerFor("invite").reset();
|
2014-05-27 16:14:37 -04:00
|
|
|
},
|
|
|
|
|
2015-03-10 15:01:15 -04:00
|
|
|
uploadSuccess(filename) {
|
2014-05-27 16:14:37 -04:00
|
|
|
bootbox.alert(I18n.t("user.invited.bulk_invite.success", { filename: filename }));
|
|
|
|
},
|
|
|
|
|
2015-03-10 15:01:15 -04:00
|
|
|
uploadError(filename, message) {
|
2014-05-27 16:14:37 -04:00
|
|
|
bootbox.alert(I18n.t("user.invited.bulk_invite.error", { filename: filename, message: message }));
|
2013-11-06 12:56:26 -05:00
|
|
|
}
|
2013-10-10 12:48:26 -04:00
|
|
|
}
|
2014-05-27 16:14:37 -04:00
|
|
|
});
|