aboutsummaryrefslogtreecommitdiff
path: root/app/javascript/controllers
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2024-03-15 11:15:53 +0100
committerMiquel Sabaté Solà <msabate@suse.com>2024-03-15 11:22:28 +0100
commit16739684bb7ca55d71c22cbd103ca8c058c33ecc (patch)
treeefb06331b0c96910d037e9ed8e23d39c4146487c /app/javascript/controllers
parentfd64bb953f4794b8cc79aa5149e761c77229f9d9 (diff)
downloadoperum-16739684bb7ca55d71c22cbd103ca8c058c33ecc.tar.gz
operum-16739684bb7ca55d71c22cbd103ca8c058c33ecc.zip
things: provide a simple way to follow links
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'app/javascript/controllers')
-rw-r--r--app/javascript/controllers/thing_controller.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/javascript/controllers/thing_controller.js b/app/javascript/controllers/thing_controller.js
new file mode 100644
index 0000000..1518216
--- /dev/null
+++ b/app/javascript/controllers/thing_controller.js
@@ -0,0 +1,17 @@
+import { Controller } from "@hotwired/stimulus"
+
+// Gathers all the methods that are relevant when manipulating things.
+export default class extends Controller {
+ // Update the external link depending on the changed value. The link will also
+ // be hidden/shown depending if the current URL is empty or not.
+ updateLink() {
+ let cur = document.getElementById("thing_url").value.trim();
+
+ if (cur === "") {
+ document.getElementById("thing-external-url-id").classList.add('hidden');
+ } else {
+ document.getElementById("thing-external-url-id").classList.remove('hidden');
+ document.getElementById("thing-external-url-id").href = cur;
+ }
+ }
+}