Tuesday morning, 9 AM

This commit is contained in:
Kane York
2015-06-30 09:07:33 -07:00
parent a12c906c9a
commit 95a50e1116
10 changed files with 60 additions and 104 deletions
@@ -3,21 +3,34 @@ import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/qu
export default Ember.ArrayController.extend({
selectedItem: null,
dirty: false,
loading: false,
markDirty: function() {
this.set('dirty', true);
}.observes('selectedItem.name', 'selectedItem.description', 'selectedItem.sql'),
actions: {
selectItem(item) {
this.set('selectedItem', item);
this.setProperties({
selectedItem: item,
editName: false
});
this.set('dirty', false);
},
dummy() {},
create() {
const self = this;
this.set('loading', true);
var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
newQuery.save().then(function(result) {
self.pushObject(result.target);
self.set('selectedItem', result.target);
debugger;
self.set('dirty', false);
}).finally(function() {
self.set('loading', false);
});
},
@@ -25,7 +38,38 @@ export default Ember.ArrayController.extend({
showModal('import-query');
},
editName() {
this.setProperties({
editName: true,
dirty: true
});
},
save() {
const self = this;
this.set('loading', true);
this.get('selectedItem').save().then(function(result) {
debugger;
}).finally(function() {
self.set('loading', false);
});
},
discard() {
const self = this;
this.set('loading', true);
this.store.find('query', this.selectedItem.id).then(function(result) {
self.set('selectedItem', result);
}).finally(function() {
self.set('loading', false);
});
},
run() {
if (this.get('dirty')) {
self.set('results', {errors: [I18n.t('errors.explorer.dirty')]});
return;
}
const self = this;
this.set('loading', true);
Discourse.ajax("/admin/plugins/explorer/query/" + this.get('selectedItem.id') + "/run", {
@@ -1,21 +1,23 @@
{{#if model}}
{{#if selectedItem}}
<div class="name">
{{#if editName}}
{{text-field value=model.name}}
{{text-field value=selectedItem.name}}
{{else}}
<h2>{{model.name}}</h2>
<h2>{{selectedItem.name}}</h2>
{{d-button action="editName" icon="pencil" class="no-text"}}
{{/if}}
</div>
<div class="desc">
{{#if editName}}
{{textarea value=model.description}}
{{#if controller.editName}}
{{textarea value=selectedItem.description}}
{{else}}
{{model.description}}
{{selectedItem.description}}
{{/if}}
</div>
<div class="sql">
{{textarea value=model.sql}}
{{textarea value=selectedItem.sql}}
</div>
{{d-button action="run" label="explorer.run"}}
{{d-button action="save" label="explorer.save" disabled=saveDisabled}}
{{d-button action="discard" class="no-text danger" icon="trash" disabled=saveDisabled}}
{{d-button action="run" label="explorer.run" disabled=runDisabled}}
{{/if}}
@@ -22,9 +22,10 @@
</div>
<hr>
<div class="query-edit">
{{render "admin/plugins-explorer-show" selectedItem}}
{{partial "admin/plugins-explorer-show" model=selectedItem}}
</div>
<hr>
{{conditional-loading-spinner condition=loading}}
<div class="query-results">
{{results}}
</div>