diff --git a/assets/javascripts/discourse/components/param-input.hbs b/assets/javascripts/discourse/components/param-input.hbs
index 80aa942..bfe06f3 100644
--- a/assets/javascripts/discourse/components/param-input.hbs
+++ b/assets/javascripts/discourse/components/param-input.hbs
@@ -7,12 +7,14 @@
@nameProperty="name"
@content={{this.boolTypes}}
@onChange={{this.updateNullableBoolValue}}
+ name={{@info.identifier}}
/>
{{else}}
{{/if}}
{{@info.identifier}}
@@ -22,6 +24,7 @@
@type="number"
@value={{this.value}}
{{on "change" this.updateValue}}
+ name={{@info.identifier}}
/>
{{@info.identifier}}
@@ -30,6 +33,7 @@
@value={{this.value}}
@type="text"
@onChange={{this.updateValue}}
+ name={{@info.identifier}}
/>
{{@info.identifier}}
@@ -38,6 +42,7 @@
@value={{this.value}}
@options={{(hash maximum=1)}}
@onChange={{this.updateValue}}
+ name={{@info.identifier}}
/>
{{@info.identifier}}
@@ -45,11 +50,16 @@
{{@info.identifier}}
{{else}}
-
+
{{@info.identifier}}
{{/if}}
\ No newline at end of file
diff --git a/assets/javascripts/discourse/components/param-input.js b/assets/javascripts/discourse/components/param-input.js
index 81f672b..dfca0f8 100644
--- a/assets/javascripts/discourse/components/param-input.js
+++ b/assets/javascripts/discourse/components/param-input.js
@@ -69,13 +69,13 @@ export default class ParamInput extends Component {
}
} else {
// if no parsed params then get and set default values
- const params = this.args.params;
+ const defaultValue = this.args.info.default;
this.value =
this.args.info.type === "category_id"
- ? this.dasherizeCategoryId(params[identifier])
- : params[identifier];
- this.boolValue = params[identifier] !== "false";
- this.nullableBoolValue = params[identifier];
+ ? this.dasherizeCategoryId(defaultValue)
+ : defaultValue;
+ this.boolValue = defaultValue !== "false";
+ this.nullableBoolValue = defaultValue;
}
}
diff --git a/spec/system/explorer_spec.rb b/spec/system/explorer_spec.rb
new file mode 100644
index 0000000..5aaeeb5
--- /dev/null
+++ b/spec/system/explorer_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+RSpec.describe "Explorer", type: :system, js: true do
+ fab!(:current_user) { Fabricate(:admin) }
+ fab!(:group) { Fabricate(:group, name: "group") }
+ fab!(:group_user) { Fabricate(:group_user, user: current_user, group: group) }
+
+ before { SiteSetting.data_explorer_enabled = true }
+
+ context "with a query using a default param" do
+ fab!(:query_1) do
+ Fabricate(
+ :query,
+ name: "My default param query",
+ description: "Test default param query",
+ sql: "-- [params]\n-- string :limit = 42\n\nSELECT * FROM users LIMIT :limit",
+ user: current_user,
+ )
+ end
+ fab!(:query_group_1) { Fabricate(:query_group, query: query_1, group: group) }
+
+ it "pre-fills the field with the default param" do
+ sign_in(current_user)
+ visit("/g/group/reports/#{query_1.id}")
+
+ expect(page).to have_field("limit", with: 42)
+ end
+ end
+end