FIX: Show badge names in query results (#92)
* FIX: Show badge names in query results
This commit is contained in:
parent
d1ab0e5fbe
commit
9d86b8b653
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class DataExplorer::SmallBadgeSerializer < ApplicationSerializer
|
class DataExplorer::SmallBadgeSerializer < ApplicationSerializer
|
||||||
attributes :id, :name, :badge_type, :description, :icon
|
attributes :id, :name, :display_name, :badge_type, :description, :icon
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{! source: badge-button component }}
|
{{! source: badge-button component }}
|
||||||
<a href="{{baseuri}}/badges/{{badge.id}}/{{badge.name}}"
|
<a href="{{baseuri}}/badges/{{badge.id}}/{{badge.name}}"
|
||||||
class="user-badge {{badge.badgeTypeClassName}}"
|
class="user-badge {{badge.badgeTypeClassName}}"
|
||||||
title="{{badge.displayDescription}}"
|
title="{{badge.display_name}}"
|
||||||
data-badge-name="{{badge.name}}">{{icon-or-image badge.icon}}
|
data-badge-name="{{badge.name}}">{{icon-or-image badge.icon}}
|
||||||
<span class="badge-display-name">{{badge.displayName}}</span></a>
|
<span class="badge-display-name">{{badge.display_name}}</span></a>
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
import componentTest, {
|
||||||
|
setupRenderingTest,
|
||||||
|
} from "discourse/tests/helpers/component-test";
|
||||||
|
import {
|
||||||
|
discourseModule,
|
||||||
|
queryAll,
|
||||||
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
|
discourseModule(
|
||||||
|
"Data Explorer Plugin | Integration | Component | query-result",
|
||||||
|
function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
componentTest("it renders badge names in query results", {
|
||||||
|
template: hbs`{{query-result content=content}}`,
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
const results = {
|
||||||
|
colrender: { 0: "badge" },
|
||||||
|
relations: {
|
||||||
|
badge: [
|
||||||
|
{
|
||||||
|
description: "description",
|
||||||
|
icon: "fa-user",
|
||||||
|
id: 1,
|
||||||
|
name: "badge name",
|
||||||
|
display_name: "badge display name",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
result_count: 1,
|
||||||
|
columns: ["badge_id"],
|
||||||
|
rows: [[1]],
|
||||||
|
};
|
||||||
|
this.set("content", results);
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.ok(
|
||||||
|
queryAll(
|
||||||
|
"table tbody tr:nth-child(1) td:nth-child(1) span"
|
||||||
|
).text() === "badge display name"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
Loading…
Reference in New Issue