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/invite_controller.js
2013-05-31 12:29:38 -04:00

44 lines
1.3 KiB
JavaScript

/**
The modal for inviting a user to a topic
@class InviteController
@extends Discourse.Controller
@namespace Discourse
@uses Discourse.ModalFunctionality
@module Discourse
**/
Discourse.InviteController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
disabled: function() {
if (this.get('saving')) return true;
if (this.blank('email')) return true;
if (!Discourse.Utilities.emailValid(this.get('email'))) return true;
return false;
}.property('email', 'saving'),
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('topic.inviting');
return Em.String.i18n('topic.invite_reply.action');
}.property('saving'),
successMessage: function() {
return Em.String.i18n('topic.invite_reply.success', { email: this.get('email') });
}.property('email'),
createInvite: function() {
var inviteController = this;
this.set('saving', true);
this.set('error', false);
this.get('model').inviteUser(this.get('email')).then(function() {
// Success
inviteController.set('saving', false);
return inviteController.set('finished', true);
}, function() {
// Failure
inviteController.set('error', true);
return inviteController.set('saving', false);
});
return false;
}
});