diff --git a/assets/javascripts/discourse/components/hljs-code-view.js.es6 b/assets/javascripts/discourse/components/hljs-code-view.js.es6 new file mode 100644 index 0000000..5f47af8 --- /dev/null +++ b/assets/javascripts/discourse/components/hljs-code-view.js.es6 @@ -0,0 +1,17 @@ +import highlightSyntax from 'discourse/lib/highlight-syntax'; + +export default Ember.Component.extend({ + render(buffer) { + buffer.push("
");
+ buffer.push(Handlebars.Utils.escapeExpression(this.get('value')));
+ buffer.push("");
+ },
+
+ _refreshHighlight: Discourse.debounce(function() {
+ this.rerender();
+ }, 50).observes('value'),
+
+ _applyHighlight: function() {
+ highlightSyntax(this.$());
+ }.on('didInsertElement')
+});
diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6
index e900457..4da50b7 100644
--- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6
+++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6
@@ -15,6 +15,10 @@ export default Ember.ArrayController.extend({
saveDisabled: Ember.computed.not('selectedItem.dirty'),
runDisabled: Ember.computed.alias('selectedItem.dirty'),
+ results: Em.computed.alias('selectedItem.results'),
+
+ editing: false,
+ everEditing: false,
selectedItem: function() {
const _id = this.get('selectedQueryId');
@@ -25,16 +29,6 @@ export default Ember.ArrayController.extend({
return item || NoQuery;
}.property('selectedQueryId'),
- results: Em.computed.alias('selectedItem.results'),
-
- addCreatedRecord(record) {
- this.pushObject(record);
- this.set('selectedQueryId', Ember.get(record, 'id'));
- this.get('selectedItem').set('dirty', false);
- this.set('showResults', false);
- this.set('results', null);
- },
-
not_https: function() {
return !(
window.location.protocol === "https:" ||
@@ -43,6 +37,28 @@ export default Ember.ArrayController.extend({
);
}.property(),
+ othersDirty: function() {
+ const selected = this.get('selectedItem');
+ return !!this.get('content').find(function(q) {
+ return q !== selected && q.get('dirty');
+ });
+ }.property('selectedItem', 'selectedItem.dirty'),
+
+ setEverEditing: function() {
+ if (this.get('editing') && !this.get('everEditing')) {
+ this.set('everEditing', true);
+ }
+ }.observes('editing'),
+
+ addCreatedRecord(record) {
+ this.pushObject(record);
+ this.set('selectedQueryId', Ember.get(record, 'id'));
+ this.get('selectedItem').set('dirty', false);
+ this.set('showResults', false);
+ this.set('results', null);
+ this.set('editing', true);
+ },
+
save() {
const self = this;
this.set('loading', true);
diff --git a/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6
index 9091a82..1a1ee9e 100644
--- a/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6
+++ b/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6
@@ -7,6 +7,9 @@ export default Discourse.Route.extend({
const p1 = this.store.findAll('query');
const p2 = Discourse.ajax('/admin/plugins/explorer/schema.json', {cache: true});
return p1.then(function(model) {
+ model.forEach(function(query) {
+ query.markNotDirty();
+ });
return p2.then(function(schema) {
return { content: model, schema: schema };
});
diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs
index b8a9f07..c613299 100644
--- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs
+++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs
@@ -20,6 +20,13 @@
{{/if}}
+{{#if othersDirty}}
+