FIX: ensures group_ids are not "" or nil (#39)
This commit is contained in:
parent
c58748474a
commit
4196321e41
|
@ -7,7 +7,7 @@ import {
|
||||||
observes
|
observes
|
||||||
} from "ember-addons/ember-computed-decorators";
|
} from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
const NoQuery = Query.create({ name: "No queries", fake: true });
|
const NoQuery = Query.create({ name: "No queries", fake: true, group_ids: [] });
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
queryParams: { selectedQueryId: "id" },
|
queryParams: { selectedQueryId: "id" },
|
||||||
|
@ -45,12 +45,17 @@ export default Ember.Controller.extend({
|
||||||
|
|
||||||
@computed("selectedQueryId")
|
@computed("selectedQueryId")
|
||||||
selectedItem(selectedQueryId) {
|
selectedItem(selectedQueryId) {
|
||||||
const id = parseInt(selectedQueryId);
|
const id = parseInt(selectedQueryId, 10);
|
||||||
const item = this.model.find(q => q.id === id);
|
const item = this.model.findBy("id", id);
|
||||||
|
|
||||||
!isNaN(id)
|
!isNaN(id)
|
||||||
? this.set("showRecentQueries", false)
|
? this.set("showRecentQueries", false)
|
||||||
: this.set("showRecentQueries", true);
|
: this.set("showRecentQueries", true);
|
||||||
if (id < 0) this.set("editDisabled", true);
|
|
||||||
|
if (id < 0) {
|
||||||
|
this.set("editDisabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
return item || NoQuery;
|
return item || NoQuery;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -658,7 +658,8 @@ SQL
|
||||||
[:name, :description, :sql, :created_by, :created_at, :last_run_at].each do |sym|
|
[:name, :description, :sql, :created_by, :created_at, :last_run_at].each do |sym|
|
||||||
query.send("#{sym}=", h[sym].strip) if h[sym]
|
query.send("#{sym}=", h[sym].strip) if h[sym]
|
||||||
end
|
end
|
||||||
query.group_ids = h[:group_ids]
|
group_ids = (h[:group_ids] == "" || !h[:group_ids]) ? [] : h[:group_ids]
|
||||||
|
query.group_ids = group_ids
|
||||||
query.id = h[:id].to_i if h[:id]
|
query.id = h[:id].to_i if h[:id]
|
||||||
query
|
query
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue