aboutsummaryrefslogtreecommitdiff
path: root/app/javascript/controllers/export_controller.js
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2024-03-13 18:03:43 +0100
committerMiquel Sabaté Solà <msabate@suse.com>2024-03-13 18:03:43 +0100
commita7791635aa98f012d35f97c3c5288494bbb28e38 (patch)
treebad987e6b4d10ad2f7cd02e40658d464907595ee /app/javascript/controllers/export_controller.js
downloadoperum-a7791635aa98f012d35f97c3c5288494bbb28e38.tar.gz
operum-a7791635aa98f012d35f97c3c5288494bbb28e38.zip
Initial commit
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'app/javascript/controllers/export_controller.js')
-rw-r--r--app/javascript/controllers/export_controller.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/javascript/controllers/export_controller.js b/app/javascript/controllers/export_controller.js
new file mode 100644
index 0000000..1807799
--- /dev/null
+++ b/app/javascript/controllers/export_controller.js
@@ -0,0 +1,19 @@
+import { Controller } from "@hotwired/stimulus"
+
+// Controller used in the exports#new page. That is, it allows us to change the
+// format to be picked up by the exporter.
+export default class extends Controller {
+ static targets = ["id"]
+
+ connect() {
+ const url = `/searches/${this.idTarget.value}/exports.csv`;
+ document.getElementById("export-format-button").setAttribute('href', url);
+ }
+
+ // Change the format to be used.
+ change() {
+ const format = document.getElementById("export-select-format").value;
+ const url = `/searches/${this.idTarget.value}/exports.${format}`;
+ document.getElementById("export-format-button").setAttribute('href', url);
+ }
+}