discourse/app/assets/javascripts/discourse/routes/user-invited-show.js.es6

47 lines
1.2 KiB
Text
Raw Normal View History

2015-08-10 17:11:27 -04:00
import Invite from 'discourse/models/invite';
import showModal from "discourse/lib/show-modal";
export default Discourse.Route.extend({
2013-10-10 12:48:26 -04:00
model(params) {
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);
},
afterModel(model) {
if (!model.can_see_invite_details) {
this.replaceWith("userInvited.show", "redeemed");
}
},
setupController(controller, model) {
controller.setProperties({
model: model,
user: this.controllerFor("user").get("model"),
2015-07-11 08:09:12 -04:00
filter: this.inviteFilter,
searchTerm: "",
totalInvites: model.invites.length,
invitesCount: this.get('invitesCount')
});
},
actions: {
showInvite() {
showModal("invite", { model: this.currentUser });
this.controllerFor("invite").reset();
2014-05-27 16:14:37 -04:00
},
uploadSuccess(filename) {
2014-05-27 16:14:37 -04:00
bootbox.alert(I18n.t("user.invited.bulk_invite.success", { filename: filename }));
},
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-10-10 12:48:26 -04:00
}
2014-05-27 16:14:37 -04:00
});