diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 index e307996..2e1d9a1 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 @@ -3,6 +3,7 @@ import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/qu export default Ember.ArrayController.extend({ selectedQueryId: null, + results: null, dirty: false, loading: false, @@ -25,11 +26,13 @@ export default Ember.ArrayController.extend({ create() { const self = this; this.set('loading', true); + this.set('showCreate', false); var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')}); newQuery.save().then(function(result) { self.pushObject(result.target); - self.set('selectedItem', result.target); + self.set('selectedQueryId', result.target.id); self.set('selectedItem.dirty', false); + self.set('results', null); }).finally(function() { self.set('loading', false); }); @@ -37,6 +40,11 @@ export default Ember.ArrayController.extend({ importQuery() { showModal('import-query'); + this.set('showCreate', false); + }, + + showCreate() { + this.set('showCreate', true); }, editName() { @@ -59,11 +67,11 @@ export default Ember.ArrayController.extend({ const self = this; this.set('loading', true); this.store.find('query', this.get('selectedItem.id')).then(function(result) { - debugger; const query = self.get('selectedItem'); query.setProperties(result.getProperties(Query.updatePropertyNames)); query.markNotDirty(); self.set('editName', false); + self.set('results', null); }).finally(function() { self.set('loading', false); }); diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs index d4b8f1d..de28987 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs @@ -1,10 +1,16 @@

Queries

-{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}} -{{d-button action="create" label="explorer.create" icon="plus"}} -{{d-button action="importQuery" label="explorer.import.label" icon="upload" class="import-button"}} - -{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="name" content=content castInteger="true"}} - +
+ {{combo-box valueAttribute="id" value=selectedQueryId nameProperty="name" content=content castInteger="true"}} + {{d-button action="showCreate" icon="plus" class="no-text"}} + {{d-button action="importQuery" label="explorer.import.label" icon="upload"}} +
+{{#if showCreate}} +
+ {{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}} + {{d-button action="create" label="explorer.create" icon="plus"}} +
+{{/if}} +
{{partial "admin/plugins-explorer-show" model=selectedItem}}
diff --git a/assets/stylesheets/tagging.scss b/assets/stylesheets/explorer.scss similarity index 84% rename from assets/stylesheets/tagging.scss rename to assets/stylesheets/explorer.scss index 8e46739..e1ef59a 100644 --- a/assets/stylesheets/tagging.scss +++ b/assets/stylesheets/explorer.scss @@ -1,7 +1,9 @@ .query-list { - overflow-y: scroll; - max-height: 15em; + margin: 10px 0; +} +.query-create { + margin: 10px 0; } .query-edit { diff --git a/plugin.rb b/plugin.rb index 3c5127c..e75f56d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -5,7 +5,7 @@ # url: https://github.com/discourse/discourse-data-explorer enabled_site_setting :data_explorer_enabled -register_asset 'stylesheets/tagging.scss' +register_asset 'stylesheets/explorer.scss' # route: /admin/plugins/explorer add_admin_route 'explorer.title', 'explorer' @@ -231,7 +231,7 @@ SQL end # guardian.ensure_can_see! query - render_serialized query, DataExplorer::QuerySerializer, root: 'queries' + render_serialized query, DataExplorer::QuerySerializer, root: 'query' end # Helper endpoint for logic