Looks like it's working
This commit is contained in:
parent
e0e7022538
commit
7f96ea5632
|
@ -4,6 +4,7 @@ const Escape = Handlebars.Utils.escapeExpression;
|
|||
|
||||
import avatarTemplate from 'discourse/lib/avatar-template';
|
||||
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
||||
import Badge from 'discourse/models/badge';
|
||||
|
||||
var defaultFallback = function(buffer, content, defaultRender) { defaultRender(buffer, content); };
|
||||
|
||||
|
@ -16,10 +17,14 @@ function randomIdShort() {
|
|||
});
|
||||
}
|
||||
|
||||
function transformedRelTable(table) {
|
||||
function transformedRelTable(table, modelClass) {
|
||||
const result = {};
|
||||
table.forEach(function(item) {
|
||||
result[item.id] = item;
|
||||
if (modelClass) {
|
||||
result[item.id] = modelClass.create(item);
|
||||
} else {
|
||||
result[item.id] = item;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
@ -87,10 +92,32 @@ const QueryResultComponent = Ember.Component.extend({
|
|||
transformedUserTable: function() {
|
||||
return transformedRelTable(this.get('content.relations.user'));
|
||||
}.property('content.relations.user'),
|
||||
transformedBadgeTable: function() {
|
||||
return transformedRelTable(this.get('content.relations.badge'), Badge);
|
||||
}.property('content.relations.badge'),
|
||||
transformedPostTable: function() {
|
||||
return transformedRelTable(this.get('content.relations.post'));
|
||||
}.property('content.relations.post'),
|
||||
transformedTopicTable: function() {
|
||||
return transformedRelTable(this.get('content.relations.topic'));
|
||||
}.property('content.relations.topic'),
|
||||
|
||||
lookupUser: function(id) {
|
||||
lookupUser(id) {
|
||||
return this.get('transformedUserTable')[id];
|
||||
},
|
||||
lookupBadge(id) {
|
||||
return this.get('transformedBadgeTable')[id];
|
||||
},
|
||||
lookupPost(id) {
|
||||
return this.get('transformedPostTable')[id];
|
||||
},
|
||||
lookupTopic(id) {
|
||||
return this.get('transformedTopicTable')[id];
|
||||
},
|
||||
|
||||
lookupCategory(id) {
|
||||
return this.site.get('categoriesById')[id];
|
||||
},
|
||||
|
||||
downloadResult(format) {
|
||||
// Create a frame to submit the form in (?)
|
||||
|
|
|
@ -1,5 +1,29 @@
|
|||
import binarySearch from 'discourse/plugins/discourse-data-explorer/discourse/lib/binary-search';
|
||||
import avatarTemplate from 'discourse/lib/avatar-template';
|
||||
|
||||
function icon_or_image_replacement(str, ctx) {
|
||||
str = Ember.get(ctx.contexts[0], str);
|
||||
if (Ember.isEmpty(str)) { return ""; }
|
||||
|
||||
if (str.indexOf('fa-') === 0) {
|
||||
return new Handlebars.SafeString("<i class='fa " + str + "'></i>");
|
||||
} else {
|
||||
return new Handlebars.SafeString("<img src='" + str + "'>");
|
||||
}
|
||||
}
|
||||
|
||||
function shorthandTinyAvatar(username, uploadId, ctx) {
|
||||
username = Ember.get(ctx.contexts[0], username);
|
||||
uploadId = Ember.get(ctx.contexts[0], uploadId);
|
||||
return new Handlebars.SafeString(Discourse.Utilities.avatarImg({
|
||||
size: "tiny",
|
||||
extraClasses: '',
|
||||
title: username,
|
||||
avatarTemplate: avatarTemplate(username, uploadId)
|
||||
}));
|
||||
}
|
||||
|
||||
const esc = Handlebars.Utils.escapeExpression;
|
||||
|
||||
const QueryRowContentComponent = Ember.Component.extend({
|
||||
tagName: "tr",
|
||||
|
@ -12,18 +36,29 @@ const QueryRowContentComponent = Ember.Component.extend({
|
|||
const self = this;
|
||||
const row = this.get('row');
|
||||
const relations = this.get('extra.relations');
|
||||
const parent = self.get('parent');
|
||||
|
||||
const parts = this.get('columnTemplates').map(function(t, idx) {
|
||||
const params = {};
|
||||
const ctx = {};
|
||||
const params = {}
|
||||
if (t.name === "text") {
|
||||
return row[idx];
|
||||
return esc(row[idx]);
|
||||
} else if (t.name === "user") {
|
||||
params.user = self.get('parent').lookupUser(parseInt(row[idx]));
|
||||
ctx.user = parent.lookupUser(parseInt(row[idx]));
|
||||
if (!ctx.user) {
|
||||
return esc(row[idx]);
|
||||
}
|
||||
} else if (t.name === "badge") {
|
||||
ctx.badge = parent.lookupBadge(parseInt(row[idx]));
|
||||
params.helpers = {"icon-or-image": icon_or_image_replacement};
|
||||
} else if (t.name === "post") {
|
||||
ctx.post = parent.lookupPost(parseInt(row[idx]));
|
||||
params.helpers = {avatar: shorthandTinyAvatar};
|
||||
} else {
|
||||
params.value = row[idx];
|
||||
ctx.value = row[idx];
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString(t.template(params));
|
||||
return new Handlebars.SafeString(t.template(ctx, params));
|
||||
});
|
||||
|
||||
buffer.push("<td>" + parts.join("</td><td>") + "</td>");
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
{{! source: badge-button component }}
|
||||
<span class="user-badge {{badge.badgeTypeClassName}}" title="{{badge.displayDescription}}" data-badge-name="{{badge.name}}">{{icon-or-image badge.icon}} <span class="badge-display-name">{{badge.displayName}}</span></span>
|
|
@ -0,0 +1,4 @@
|
|||
<aside class="quote" data-post="{{post.post_number}}" data-topic="{{post.topic_id}}"><div class="title" style="cursor: pointer;">
|
||||
<div class="quote-controls">{{!<i class="fa fa-chevron-down" title="expand/collapse"></i>}}<a href="/t/via-quote/{{post.topic_id}}/{{post.post_number}}" title="go to the quoted post" class="quote-other-topic"></a></div>
|
||||
{{avatar post.username post.uploaded_avatar_id}}{{post.username}}:</div>
|
||||
<blockquote><p>{{{post.excerpt}}}</p></blockquote></aside>
|
|
@ -1,5 +1 @@
|
|||
{{#if user}}
|
||||
<a href="/users/{{user.username}}/activity">{{avatar user imageSize="tiny"}} {{user.username}}</a>
|
||||
{{else}}
|
||||
User #{{value}} (deleted)
|
||||
{{/if}}
|
||||
<a href="/users/{{user.username}}/activity">{{avatar user imageSize="tiny"}} {{user.username}}</a>
|
||||
|
|
Loading…
Reference in New Issue