A platform for community discussion. Free, open, simple.
Fix: trigger group card on a post's primary group click
Jeff Wong99138b171a71
diff --git a/app/assets/javascripts/discourse/components/user-card-contents.js.es6 b/app/assets/javascripts/discourse/components/user-card-contents.js.es6index da9f8dfdda1..61d34e36a6e 100644--- a/app/assets/javascripts/discourse/components/user-card-contents.js.es6+++ b/app/assets/javascripts/discourse/components/user-card-contents.js.es6@@ -11,6 +11,7 @@ const clickOutsideEventName = "mousedown.outside-user-card";const clickDataExpand = "click.discourse-user-card";const clickMention = "click.discourse-user-mention";const groupClickMention = "click.discourse-group-mention";+const groupClickDataExpand = "click.discourse-group-card"const maxMembersToDisplay = 10;@@ -162,6 +163,12 @@ export default Ember.Component.extend(CleansUp, {return this._show($target.text().replace(/^@/, ''), $target, 'user');});+ $('#main-outlet').on(groupClickDataExpand, '[data-group-card]', (e) => {+ if (wantsNewWindow(e)) { return; }+ const $target = $(e.currentTarget);+ return this._show($target.data('group-card'), $target, 'group');+ });+$('#main-outlet').on(groupClickMention, 'a.mention-group', (e) => {if (wantsNewWindow(e)) { return; }const $target = $(e.target);@@ -247,7 +254,7 @@ export default Ember.Component.extend(CleansUp, {willDestroyElement() {this._super();$('html').off(clickOutsideEventName);- $('#main').off(clickDataExpand).off(clickMention).off(groupClickMention);+ $('#main').off(clickDataExpand).off(clickMention).off(groupClickMention).off(groupClickDataExpand);},actions: {diff --git a/app/assets/javascripts/discourse/widgets/poster-name.js.es6 b/app/assets/javascripts/discourse/widgets/poster-name.js.es6index 5a93ab9fd1e..3fc5c0ee2af 100644--- a/app/assets/javascripts/discourse/widgets/poster-name.js.es6+++ b/app/assets/javascripts/discourse/widgets/poster-name.js.es6@@ -14,7 +14,7 @@ createWidget('poster-name-title', {let titleContents = attrs.title;if (attrs.primaryGroupName) {const href = Discourse.getURL(`/groups/${attrs.primaryGroupName}`);- titleContents = h('a.user-group', { className: attrs.extraClasses, attributes: { href } }, attrs.title);+ titleContents = h('a.user-group', { className: attrs.extraClasses, attributes: { href, 'data-group-card': attrs.primaryGroupName } }, attrs.title);}return titleContents;}