FIX: Remove buffered-render reference
Buffered-render has been removed from core, so this change allows us to keep the same functionality without using the render buffer.
This commit is contained in:
parent
d2ac25857f
commit
6707072ef1
|
@ -1,6 +1,5 @@
|
|||
import { categoryLinkHTML } from "discourse/helpers/category-link";
|
||||
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
|
||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||
import { iconHTML, convertIconClass } from "discourse-common/lib/icon-library";
|
||||
|
||||
function icon_or_image_replacement(str, ctx) {
|
||||
|
@ -47,69 +46,68 @@ function guessUrl(t) {
|
|||
return [dest, name];
|
||||
}
|
||||
|
||||
const QueryRowContentComponent = Ember.Component.extend(
|
||||
bufferedRender({
|
||||
tagName: "tr",
|
||||
const QueryRowContentComponent = Ember.Component.extend({
|
||||
tagName: "tr",
|
||||
rowContents: null,
|
||||
|
||||
buildBuffer(buffer) {
|
||||
const row = this.row;
|
||||
const parentView = this.parentView;
|
||||
const fallback = this.fallbackTemplate;
|
||||
const helpers = {
|
||||
"icon-or-image": icon_or_image_replacement,
|
||||
"category-link": category_badge_replacement,
|
||||
reltime: bound_date_replacement
|
||||
didReceiveAttrs() {
|
||||
const row = this.row;
|
||||
const parentView = this.parentView;
|
||||
const fallback = this.fallbackTemplate;
|
||||
const helpers = {
|
||||
"icon-or-image": icon_or_image_replacement,
|
||||
"category-link": category_badge_replacement,
|
||||
reltime: bound_date_replacement
|
||||
};
|
||||
|
||||
const parts = this.columnTemplates.map((t, idx) => {
|
||||
const value = row[idx],
|
||||
id = parseInt(value, 10);
|
||||
|
||||
const ctx = {
|
||||
value,
|
||||
id,
|
||||
baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri
|
||||
};
|
||||
const params = {};
|
||||
|
||||
const parts = this.columnTemplates.map((t, idx) => {
|
||||
const value = row[idx],
|
||||
id = parseInt(value, 10);
|
||||
if (row[idx] === null) {
|
||||
return "NULL";
|
||||
} else if (t.name === "text") {
|
||||
return esc(row[idx]);
|
||||
}
|
||||
|
||||
const ctx = {
|
||||
value,
|
||||
id,
|
||||
baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri
|
||||
};
|
||||
const params = {};
|
||||
const lookupFunc = parentView[`lookup${t.name.capitalize()}`];
|
||||
if (lookupFunc) {
|
||||
ctx[t.name] = parentView[`lookup${t.name.capitalize()}`](id);
|
||||
}
|
||||
|
||||
if (row[idx] === null) {
|
||||
return "NULL";
|
||||
} else if (t.name === "text") {
|
||||
return esc(row[idx]);
|
||||
}
|
||||
if (t.name === "url") {
|
||||
let [url, name] = guessUrl(value);
|
||||
ctx["href"] = url;
|
||||
ctx["target"] = name;
|
||||
}
|
||||
|
||||
const lookupFunc = parentView[`lookup${t.name.capitalize()}`];
|
||||
if (lookupFunc) {
|
||||
ctx[t.name] = parentView[`lookup${t.name.capitalize()}`](id);
|
||||
}
|
||||
if (
|
||||
t.name === "category" ||
|
||||
t.name === "badge" ||
|
||||
t.name === "reltime"
|
||||
) {
|
||||
// only replace helpers if needed
|
||||
params.helpers = helpers;
|
||||
}
|
||||
|
||||
if (t.name === "url") {
|
||||
let [url, name] = guessUrl(value);
|
||||
ctx["href"] = url;
|
||||
ctx["target"] = name;
|
||||
}
|
||||
try {
|
||||
return new Handlebars.SafeString(
|
||||
(t.template || fallback)(ctx, params)
|
||||
);
|
||||
} catch (e) {
|
||||
return "error";
|
||||
}
|
||||
});
|
||||
|
||||
if (
|
||||
t.name === "category" ||
|
||||
t.name === "badge" ||
|
||||
t.name === "reltime"
|
||||
) {
|
||||
// only replace helpers if needed
|
||||
params.helpers = helpers;
|
||||
}
|
||||
|
||||
try {
|
||||
return new Handlebars.SafeString(
|
||||
(t.template || fallback)(ctx, params)
|
||||
);
|
||||
} catch (e) {
|
||||
return "error";
|
||||
}
|
||||
});
|
||||
|
||||
buffer.push(`<td>${parts.join("</td><td>")}</td>`);
|
||||
}
|
||||
})
|
||||
);
|
||||
this.set("rowContents", `<td>${parts.join("</td><td>")}</td>`.htmlSafe());
|
||||
}
|
||||
});
|
||||
|
||||
export default QueryRowContentComponent;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{{rowContents}}
|
Loading…
Reference in New Issue