Added method removeAllowedUser to topic_details.js

perform a request to /t/:id/remove-allowed-user,
then delete the user from the local list
This commit is contained in:
Claus Strasburger 2013-10-01 16:34:04 +02:00
parent 75a8dfc467
commit b089805dc0
2 changed files with 15 additions and 1 deletions

View file

@ -473,6 +473,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
removeAllowedUser: function(username) {
this.get('details').removeAllowedUser(username);
}
});

View file

@ -49,6 +49,19 @@ Discourse.TopicDetails = Discourse.Model.extend({
type: 'POST',
data: { notification_level: v }
});
}
},
removeAllowedUser: function(username) {
var users = this.get('allowed_users');
Discourse.ajax("/t/" + this.get('topic.id') + "/remove-allowed-user", {
type: 'PUT',
data: { username: username }
}).then(function(res) {
users.forEach(function(user, i) {
if (user.username === username) {
users.removeAt(i);
}
});
});
}
});