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:
Blake Erickson 2020-01-11 06:04:14 -07:00
parent d2ac25857f
commit 6707072ef1
2 changed files with 56 additions and 57 deletions

View File

@ -1,6 +1,5 @@
import { categoryLinkHTML } from "discourse/helpers/category-link"; import { categoryLinkHTML } from "discourse/helpers/category-link";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter"; import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
import { bufferedRender } from "discourse-common/lib/buffered-render";
import { iconHTML, convertIconClass } from "discourse-common/lib/icon-library"; import { iconHTML, convertIconClass } from "discourse-common/lib/icon-library";
function icon_or_image_replacement(str, ctx) { function icon_or_image_replacement(str, ctx) {
@ -47,69 +46,68 @@ function guessUrl(t) {
return [dest, name]; return [dest, name];
} }
const QueryRowContentComponent = Ember.Component.extend( const QueryRowContentComponent = Ember.Component.extend({
bufferedRender({ tagName: "tr",
tagName: "tr", rowContents: null,
buildBuffer(buffer) { didReceiveAttrs() {
const row = this.row; const row = this.row;
const parentView = this.parentView; const parentView = this.parentView;
const fallback = this.fallbackTemplate; const fallback = this.fallbackTemplate;
const helpers = { const helpers = {
"icon-or-image": icon_or_image_replacement, "icon-or-image": icon_or_image_replacement,
"category-link": category_badge_replacement, "category-link": category_badge_replacement,
reltime: bound_date_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) => { if (row[idx] === null) {
const value = row[idx], return "NULL";
id = parseInt(value, 10); } else if (t.name === "text") {
return esc(row[idx]);
}
const ctx = { const lookupFunc = parentView[`lookup${t.name.capitalize()}`];
value, if (lookupFunc) {
id, ctx[t.name] = parentView[`lookup${t.name.capitalize()}`](id);
baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri }
};
const params = {};
if (row[idx] === null) { if (t.name === "url") {
return "NULL"; let [url, name] = guessUrl(value);
} else if (t.name === "text") { ctx["href"] = url;
return esc(row[idx]); ctx["target"] = name;
} }
const lookupFunc = parentView[`lookup${t.name.capitalize()}`]; if (
if (lookupFunc) { t.name === "category" ||
ctx[t.name] = parentView[`lookup${t.name.capitalize()}`](id); t.name === "badge" ||
} t.name === "reltime"
) {
// only replace helpers if needed
params.helpers = helpers;
}
if (t.name === "url") { try {
let [url, name] = guessUrl(value); return new Handlebars.SafeString(
ctx["href"] = url; (t.template || fallback)(ctx, params)
ctx["target"] = name; );
} } catch (e) {
return "error";
}
});
if ( this.set("rowContents", `<td>${parts.join("</td><td>")}</td>`.htmlSafe());
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>`);
}
})
);
export default QueryRowContentComponent; export default QueryRowContentComponent;

View File

@ -0,0 +1 @@
{{rowContents}}