Missed description sections, try to get model to work
This commit is contained in:
parent
c933c50dc2
commit
c52ac59eee
|
@ -2,10 +2,4 @@ import buildPluginAdapter from 'discourse/adapters/build-plugin';
|
|||
|
||||
export default buildPluginAdapter('explorer').extend({
|
||||
|
||||
createRecord(store, type, args) {
|
||||
const typeField = Ember.String.underscore(type);
|
||||
return Discourse.ajax(this.pathFor(store, type), {method: 'POST', data: args}).then(function (json) {
|
||||
return new Result(json[typeField], json);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import showModal from 'discourse/lib/show-modal';
|
||||
import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/query';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
selectedItem: null,
|
||||
|
@ -11,7 +12,8 @@ export default Ember.Controller.extend({
|
|||
dummy() {},
|
||||
|
||||
create() {
|
||||
var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
|
||||
var newQuery = Query.create({name: this.get('newQueryName')});
|
||||
//var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
|
||||
newQuery.save();
|
||||
},
|
||||
|
||||
|
|
|
@ -2,7 +2,11 @@ import RestModel from 'discourse/models/rest';
|
|||
|
||||
const Query = RestModel.extend({
|
||||
createProperties() {
|
||||
return this.getProperties("name", "description");
|
||||
return this.getProperties("name");
|
||||
},
|
||||
|
||||
updateProperties() {
|
||||
return this.getProperties("name", "description", "sql", "defaults");
|
||||
},
|
||||
|
||||
run() {
|
||||
|
@ -12,4 +16,5 @@ const Query = RestModel.extend({
|
|||
|
||||
console.log('query model loaded');
|
||||
|
||||
Discourse.Query = Query;
|
||||
export default Query;
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
<h3>Queries</h3>
|
||||
<table class="query-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="q-name">Name</th>
|
||||
<th class="q-desc">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each query in content}}
|
||||
{{#each content as |query|}}
|
||||
<tr {{action "selectItem" query}}>
|
||||
<td class="q-name">{{query.name}}</td>
|
||||
<td class="q-desc">{{query.description}}</td>
|
||||
|
|
|
@ -240,7 +240,7 @@ SQL
|
|||
def create
|
||||
# guardian.ensure_can_create_explorer_query!
|
||||
|
||||
query = DataExplorer::Query.from_hash params.permit(:name, :sql, :defaults)
|
||||
query = DataExplorer::Query.from_hash params.permit(:name, :sql, :defaults, :description)
|
||||
# Set the ID _only_ if undeleting
|
||||
if params[:recover]
|
||||
query.id = params[:id].to_i
|
||||
|
@ -252,7 +252,7 @@ SQL
|
|||
|
||||
def update
|
||||
query = DataExplorer::Query.find(params[:id].to_i)
|
||||
[:name, :sql, :defaults].each do |sym|
|
||||
[:name, :sql, :defaults, :description].each do |sym|
|
||||
query.send("#{sym}=", params[sym]) if params[sym]
|
||||
end
|
||||
query.save
|
||||
|
|
Loading…
Reference in New Issue