FIX: Old Ember idioms
This commit is contained in:
parent
414cda5578
commit
8d72e979a5
|
@ -1,18 +1,19 @@
|
||||||
import debounce from 'discourse/lib/debounce';
|
import debounce from 'discourse/lib/debounce';
|
||||||
import highlightSyntax from 'discourse/lib/highlight-syntax';
|
import highlightSyntax from 'discourse/lib/highlight-syntax';
|
||||||
|
import { bufferedRender } from 'discourse-common/lib/buffered-render';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend(bufferedRender({
|
||||||
render(buffer) {
|
buildBuffer(buffer) {
|
||||||
buffer.push("<pre><code class='" + this.get('codeClass') + "'>");
|
buffer.push("<pre><code class='" + this.get('codeClass') + "'>");
|
||||||
buffer.push(Handlebars.Utils.escapeExpression(this.get('value')));
|
buffer.push(Handlebars.Utils.escapeExpression(this.get('value')));
|
||||||
buffer.push("</code></pre>");
|
buffer.push("</code></pre>");
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshHighlight: debounce(function() {
|
_refreshHighlight: debounce(function() {
|
||||||
this.rerender();
|
this.rerenderBuffer();
|
||||||
}, 50).observes('value'),
|
}, 50).observes('value'),
|
||||||
|
|
||||||
_applyHighlight: function() {
|
_applyHighlight: function() {
|
||||||
highlightSyntax(this.$());
|
highlightSyntax(this.$());
|
||||||
}.on('didInsertElement')
|
}.on('didInsertElement')
|
||||||
});
|
}));
|
||||||
|
|
|
@ -38,19 +38,26 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
boolTypes: [ {name: I18n.t('explorer.types.bool.true'), id: 'Y'}, {name: I18n.t('explorer.types.bool.false'), id: 'N'}, {name: I18n.t('explorer.types.bool.null_'), id: '#null'} ],
|
boolTypes: [ {name: I18n.t('explorer.types.bool.true'), id: 'Y'}, {name: I18n.t('explorer.types.bool.false'), id: 'N'}, {name: I18n.t('explorer.types.bool.null_'), id: '#null'} ],
|
||||||
|
|
||||||
value: function(key, value, previousValue) {
|
value: Ember.computed('params', 'info.identifier', {
|
||||||
if (arguments.length > 1) {
|
get() {
|
||||||
|
return this.get('params')[this.get('info.identifier')];
|
||||||
|
},
|
||||||
|
set(key, value) {
|
||||||
this.get('params')[this.get('info.identifier')] = value.toString();
|
this.get('params')[this.get('info.identifier')] = value.toString();
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
return this.get('params')[this.get('info.identifier')];
|
}),
|
||||||
}.property('params', 'info.identifier'),
|
|
||||||
|
|
||||||
valueBool: function(key, value, previousValue) {
|
valueBool: Ember.computed('params', 'info.identifier', {
|
||||||
if (arguments.length > 1) {
|
get() {
|
||||||
this.get('params')[this.get('info.identifier')] = (!!value).toString();
|
return this.get('params')[this.get('info.identifier')] !== 'false';
|
||||||
|
},
|
||||||
|
set(key, value) {
|
||||||
|
value = !!value;
|
||||||
|
this.get('params')[this.get('info.identifier')] = value.toString();
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
return this.get('params')[this.get('info.identifier')] !== 'false';
|
}),
|
||||||
}.property('params', 'info.identifier'),
|
|
||||||
|
|
||||||
valid: function() {
|
valid: function() {
|
||||||
const type = this.get('info.type'),
|
const type = this.get('info.type'),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
import { ajax } from 'discourse/lib/ajax';
|
||||||
import Badge from 'discourse/models/badge';
|
import Badge from 'discourse/models/badge';
|
||||||
|
import { getOwner } from 'discourse-common/lib/get-owner';
|
||||||
|
|
||||||
function randomIdShort() {
|
function randomIdShort() {
|
||||||
return 'xxxxxxxx'.replace(/[xy]/g, function() {
|
return 'xxxxxxxx'.replace(/[xy]/g, function() {
|
||||||
|
@ -66,7 +67,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
}.property('content', 'columns.@each'),
|
}.property('content', 'columns.@each'),
|
||||||
|
|
||||||
fallbackTemplate: function() {
|
fallbackTemplate: function() {
|
||||||
return this.container.lookup('template:explorer/text.raw');
|
return getOwner(this).lookup('template:explorer/text.raw');
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
columnTemplates: function() {
|
columnTemplates: function() {
|
||||||
|
@ -79,7 +80,8 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
if (self.get('content.colrender')[idx]) {
|
if (self.get('content.colrender')[idx]) {
|
||||||
viewName = self.get('content.colrender')[idx];
|
viewName = self.get('content.colrender')[idx];
|
||||||
}
|
}
|
||||||
return {name: viewName, template: self.container.lookup('template:explorer/' + viewName + '.raw')};
|
const template = getOwner(self).lookup('template:explorer/' + viewName + '.raw');
|
||||||
|
return {name: viewName, template };
|
||||||
});
|
});
|
||||||
}.property('content', 'columns.@each'),
|
}.property('content', 'columns.@each'),
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
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';
|
||||||
|
|
||||||
function icon_or_image_replacement(str, ctx) {
|
function icon_or_image_replacement(str, ctx) {
|
||||||
str = Ember.get(ctx.contexts[0], str);
|
str = Ember.get(ctx.contexts[0], str);
|
||||||
|
@ -28,10 +27,10 @@ function bound_date_replacement(str, ctx) {
|
||||||
|
|
||||||
const esc = Handlebars.Utils.escapeExpression;
|
const esc = Handlebars.Utils.escapeExpression;
|
||||||
|
|
||||||
const QueryRowContentComponent = Ember.Component.extend({
|
const QueryRowContentComponent = Ember.Component.extend(bufferedRender({
|
||||||
tagName: "tr",
|
tagName: "tr",
|
||||||
|
|
||||||
render: function(buffer) {
|
buildBuffer(buffer) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const row = this.get('row');
|
const row = this.get('row');
|
||||||
const parent = self.get('parent');
|
const parent = self.get('parent');
|
||||||
|
@ -76,6 +75,6 @@ const QueryRowContentComponent = Ember.Component.extend({
|
||||||
|
|
||||||
buffer.push("<td>" + parts.join("</td><td>") + "</td>");
|
buffer.push("<td>" + parts.join("</td><td>") + "</td>");
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
export default QueryRowContentComponent;
|
export default QueryRowContentComponent;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ajax } from 'discourse/lib/ajax';
|
||||||
|
|
||||||
const NoQuery = Query.create({name: "No queries", fake: true});
|
const NoQuery = Query.create({name: "No queries", fake: true});
|
||||||
|
|
||||||
export default Ember.ArrayController.extend({
|
export default Ember.Controller.extend({
|
||||||
queryParams: { selectedQueryId: "id" },
|
queryParams: { selectedQueryId: "id" },
|
||||||
selectedQueryId: null,
|
selectedQueryId: null,
|
||||||
showResults: false,
|
showResults: false,
|
||||||
|
@ -44,7 +44,7 @@ export default Ember.ArrayController.extend({
|
||||||
}.observes('editing'),
|
}.observes('editing'),
|
||||||
|
|
||||||
addCreatedRecord(record) {
|
addCreatedRecord(record) {
|
||||||
this.pushObject(record);
|
this.get('model').pushObject(record);
|
||||||
this.set('selectedQueryId', Ember.get(record, 'id'));
|
this.set('selectedQueryId', Ember.get(record, 'id'));
|
||||||
this.get('selectedItem').set('dirty', false);
|
this.get('selectedItem').set('dirty', false);
|
||||||
this.set('showResults', false);
|
this.set('showResults', false);
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { ajax } from 'discourse/lib/ajax';
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
controllerName: 'admin-plugins-explorer',
|
controllerName: 'admin-plugins-explorer',
|
||||||
queryParams: { id: { replace: true } },
|
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
const p1 = this.store.findAll('query');
|
const p1 = this.store.findAll('query');
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{~#each row in rows}}
|
{{~#each rows as |row|}}
|
||||||
{{~query-row-content row=row columnTemplates=columnTemplates parent=controller}}
|
{{~query-row-content row=row columnTemplates=columnTemplates parent=controller}}
|
||||||
{{~/each}}
|
{{~/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue