Improved private message user removal, locale edit
replaced array iteration with findProperty (will be renamed and aliased to findBy with Ember 1.1) added modal dialog to verify catched nil-error on topic.rb
This commit is contained in:
parent
b089805dc0
commit
15a973fd45
|
@ -471,7 +471,17 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
},
|
||||
|
||||
removeAllowedUser: function(username) {
|
||||
this.get('details').removeAllowedUser(username);
|
||||
var self = this;
|
||||
bootbox.dialog(I18n.t("private_message_info.remove_allowed_user", {name: username}), [
|
||||
{label: I18n.t("no_value"),
|
||||
'class': 'btn-danger rightg'},
|
||||
{label: I18n.t("yes_value"),
|
||||
'class': 'btn-primary',
|
||||
callback: function() {
|
||||
self.get('details').removeAllowedUser(username);
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -57,11 +57,7 @@ Discourse.TopicDetails = Discourse.Model.extend({
|
|||
type: 'PUT',
|
||||
data: { username: username }
|
||||
}).then(function(res) {
|
||||
users.forEach(function(user, i) {
|
||||
if (user.username === username) {
|
||||
users.removeAt(i);
|
||||
}
|
||||
});
|
||||
users.removeObject(users.findProperty('username', username));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -382,7 +382,12 @@ class Topic < ActiveRecord::Base
|
|||
def remove_allowed_user(username)
|
||||
user = User.where(username: username).first
|
||||
if user
|
||||
topic_allowed_users.where(user_id: user.id).first.destroy
|
||||
topic_user = topic_allowed_users.where(user_id: user.id).first
|
||||
if topic_user
|
||||
topic_user.destroy
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -373,6 +373,7 @@ de:
|
|||
private_message_info:
|
||||
title: "Privates Gespräch"
|
||||
invite: "Andere einladen..."
|
||||
remove_allowed_user: "Willst du {{name}} wirklich aus diesem Gespräch entfernen?"
|
||||
|
||||
email: 'Mail'
|
||||
username: 'Benutzername'
|
||||
|
|
|
@ -372,6 +372,7 @@ en:
|
|||
private_message_info:
|
||||
title: "Private Message"
|
||||
invite: "Invite Others..."
|
||||
remove_allowed_user: "Do you really want to remove {{name}} from this private message?"
|
||||
|
||||
email: 'Email'
|
||||
username: 'Username'
|
||||
|
|
Loading…
Reference in New Issue