DEV: uses discourse-common/lib/raw-templates (#98)

This commit is contained in:
Joffrey JAFFEUX 2021-02-24 19:49:26 +01:00 committed by GitHub
parent 1e5e0e14ad
commit 69f1e5d13b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 18 deletions

View File

@ -1,3 +1,4 @@
import { findRawTemplate } from "discourse-common/lib/raw-templates";
import I18n from "I18n"; import I18n from "I18n";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
@ -36,22 +37,6 @@ const QueryResultComponent = Ember.Component.extend({
chartValues: Ember.computed.mapBy("content.rows", "1"), chartValues: Ember.computed.mapBy("content.rows", "1"),
showChart: false, showChart: false,
init() {
this._super(...arguments);
// TODO: After `__DISCOURSE_RAW_TEMPLATES` is in stable this should be updated
// to use only `import { findRawTemplate } from "discourse-common/lib/raw-templates"`
if (window.__DISCOURSE_RAW_TEMPLATES) {
this.findRawTemplate = requirejs(
"discourse-common/lib/raw-templates"
).findRawTemplate;
} else {
this.findRawTemplate = requirejs(
"discourse/lib/raw-templates"
).findRawTemplate;
}
},
@computed("content.result_count") @computed("content.result_count")
resultCount(count) { resultCount(count) {
if (count === this.get("content.default_limit")) { if (count === this.get("content.default_limit")) {
@ -100,7 +85,7 @@ const QueryResultComponent = Ember.Component.extend({
@computed @computed
fallbackTemplate() { fallbackTemplate() {
return this.findRawTemplate("javascripts/explorer/text"); return findRawTemplate("javascripts/explorer/text");
}, },
@computed("content", "columns.[]") @computed("content", "columns.[]")
@ -114,7 +99,7 @@ const QueryResultComponent = Ember.Component.extend({
viewName = this.get("content.colrender")[idx]; viewName = this.get("content.colrender")[idx];
} }
const template = this.findRawTemplate(`javascripts/explorer/${viewName}`); const template = findRawTemplate(`javascripts/explorer/${viewName}`);
return { name: viewName, template }; return { name: viewName, template };
}); });