mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Clicking on expanded user actions uses user expansion. Also added
integration test.
This commit is contained in:
parent
bcfd2778d7
commit
504d61de94
6 changed files with 39 additions and 25 deletions
|
@ -32,7 +32,7 @@ export default Em.Component.extend({
|
||||||
if (c.get('usersExpanded')) {
|
if (c.get('usersExpanded')) {
|
||||||
var postUrl;
|
var postUrl;
|
||||||
c.get('users').forEach(function(u) {
|
c.get('users').forEach(function(u) {
|
||||||
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + (u.get('username_lower')) + "\">";
|
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + u.get('username_lower') + "\" data-user-expand=\"" + u.get('username_lower') + "\">";
|
||||||
if (u.post_url) {
|
if (u.post_url) {
|
||||||
postUrl = postUrl || u.post_url;
|
postUrl = postUrl || u.post_url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ export default {
|
||||||
$currentTarget.data('ember-action') ||
|
$currentTarget.data('ember-action') ||
|
||||||
$currentTarget.data('auto-route') ||
|
$currentTarget.data('auto-route') ||
|
||||||
$currentTarget.data('share-url') ||
|
$currentTarget.data('share-url') ||
|
||||||
|
$currentTarget.data('user-expand') ||
|
||||||
|
$currentTarget.hasClass('mention') ||
|
||||||
$currentTarget.hasClass('ember-view') ||
|
$currentTarget.hasClass('ember-view') ||
|
||||||
$currentTarget.hasClass('lightbox') ||
|
$currentTarget.hasClass('lightbox') ||
|
||||||
href.indexOf("mailto:") === 0 ||
|
href.indexOf("mailto:") === 0 ||
|
||||||
|
|
|
@ -234,7 +234,6 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
|
|
||||||
_destroyedPostView: function() {
|
_destroyedPostView: function() {
|
||||||
Discourse.ScreenTrack.current().stopTracking(this.get('elementId'));
|
Discourse.ScreenTrack.current().stopTracking(this.get('elementId'));
|
||||||
this._unbindExpandMentions();
|
|
||||||
}.on('willDestroyElement'),
|
}.on('willDestroyElement'),
|
||||||
|
|
||||||
_postViewInserted: function() {
|
_postViewInserted: function() {
|
||||||
|
@ -262,23 +261,8 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
Em.run.scheduleOnce('afterRender', this, '_insertQuoteControls');
|
Em.run.scheduleOnce('afterRender', this, '_insertQuoteControls');
|
||||||
|
|
||||||
this._applySearchHighlight();
|
this._applySearchHighlight();
|
||||||
this._bindExpandMentions();
|
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
_bindExpandMentions: function() {
|
|
||||||
var self = this;
|
|
||||||
this.$('.cooked').on('click.discourse-mention', 'a.mention', function(e) {
|
|
||||||
var $target = $(e.target);
|
|
||||||
self.appEvents.trigger('poster:expand', $target);
|
|
||||||
self.get('controller').send('expandPostUsername', $target.text());
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
_unbindExpandMentions: function() {
|
|
||||||
this.$('.cooked').off('click.discourse-mention');
|
|
||||||
},
|
|
||||||
|
|
||||||
_applySearchHighlight: function() {
|
_applySearchHighlight: function() {
|
||||||
var highlight = this.get('controller.searchHighlight');
|
var highlight = this.get('controller.searchHighlight');
|
||||||
var cooked = this.$('.cooked');
|
var cooked = this.$('.cooked');
|
||||||
|
|
|
@ -2,18 +2,13 @@ import { renderAvatar } from 'discourse/helpers/user-avatar';
|
||||||
|
|
||||||
export default Ember.View.extend({
|
export default Ember.View.extend({
|
||||||
tagName: 'a',
|
tagName: 'a',
|
||||||
attributeBindings: ['href'],
|
attributeBindings: ['href', 'data-user-expand'],
|
||||||
classNameBindings: ['content.extras'],
|
classNameBindings: ['content.extras'],
|
||||||
|
|
||||||
user: Em.computed.alias('content.user'),
|
user: Em.computed.alias('content.user'),
|
||||||
href: Em.computed.alias('user.path'),
|
href: Em.computed.alias('user.path'),
|
||||||
|
|
||||||
click: function(e) {
|
'data-user-expand': Em.computed.alias('user.username'),
|
||||||
var user = this.get('user');
|
|
||||||
this.appEvents.trigger('poster:expand', $(e.target));
|
|
||||||
this.get('controller').send('expandUser', user);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
var av = renderAvatar(this.get('content'), {usernamePath: 'user.username', imageSize: 'small'});
|
var av = renderAvatar(this.get('content'), {usernamePath: 'user.username', imageSize: 'small'});
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import CleansUp from 'discourse/mixins/cleans-up';
|
import CleansUp from 'discourse/mixins/cleans-up';
|
||||||
|
|
||||||
var clickOutsideEventName = "mousedown.outside-user-expansion";
|
var clickOutsideEventName = "mousedown.outside-user-expansion",
|
||||||
|
clickDataExpand = "click.discourse-user-expand",
|
||||||
|
clickMention = "click.discourse-user-mention";
|
||||||
|
|
||||||
export default Discourse.View.extend(CleansUp, {
|
export default Discourse.View.extend(CleansUp, {
|
||||||
elementId: 'user-expansion',
|
elementId: 'user-expansion',
|
||||||
|
@ -21,6 +23,21 @@ export default Discourse.View.extend(CleansUp, {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#main-outlet').on(clickDataExpand, '[data-user-expand]', function(e) {
|
||||||
|
var $target = $(e.currentTarget);
|
||||||
|
self._posterExpand($target);
|
||||||
|
self.get('controller').show($target.data('user-expand'));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#main-outlet').on(clickMention, 'a.mention', function(e) {
|
||||||
|
var $target = $(e.target);
|
||||||
|
self._posterExpand($target);
|
||||||
|
var username = $target.text().replace(/^@/, '');
|
||||||
|
self.get('controller').show(username);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
_posterExpand: function(target) {
|
_posterExpand: function(target) {
|
||||||
|
@ -50,6 +67,9 @@ export default Discourse.View.extend(CleansUp, {
|
||||||
|
|
||||||
_removeEvents: function() {
|
_removeEvents: function() {
|
||||||
$('html').off(clickOutsideEventName);
|
$('html').off(clickOutsideEventName);
|
||||||
|
$('#main').off(clickDataExpand);
|
||||||
|
$('#main').off(clickMention);
|
||||||
|
|
||||||
this.appEvents.off('poster:expand', this, '_posterExpand');
|
this.appEvents.off('poster:expand', this, '_posterExpand');
|
||||||
}.on('willDestroyElement')
|
}.on('willDestroyElement')
|
||||||
|
|
||||||
|
|
13
test/javascripts/integration/user-expansion-test.js.es6
Normal file
13
test/javascripts/integration/user-expansion-test.js.es6
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
integration("User Expansion");
|
||||||
|
|
||||||
|
test("expansion", function() {
|
||||||
|
visit('/');
|
||||||
|
|
||||||
|
ok(find('#user-expansion:visible').length === 0, 'user expansion is invisible by default');
|
||||||
|
click('a[data-user-expand=eviltrout]:first');
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
ok(find('#user-expansion:visible').length === 1, 'expansion should appear');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in a new issue