diff --git a/app/views/issues/_show_issue_view_right.html.erb b/app/views/issues/_show_issue_view_right.html.erb
index 06f8593..bbdf1e6 100644
--- a/app/views/issues/_show_issue_view_right.html.erb
+++ b/app/views/issues/_show_issue_view_right.html.erb
@@ -5,7 +5,10 @@
diff --git a/app/views/vehicles/_details.html.erb b/app/views/vehicles/_details.html.erb
index 2875758..097a6f4 100644
--- a/app/views/vehicles/_details.html.erb
+++ b/app/views/vehicles/_details.html.erb
@@ -18,7 +18,9 @@
| <%= t(:field_vin) %> |
- <%= @vin[0] if @vin %><%=@vin[1] if @vin%> |
+
+ <%= @vin[0] if @vin %><%=@vin[1] if @vin%>
+ |
<%= t(:label_trim) %> |
diff --git a/assets/javascripts/copy.js b/assets/javascripts/copy.js
new file mode 100644
index 0000000..801694d
--- /dev/null
+++ b/assets/javascripts/copy.js
@@ -0,0 +1,28 @@
+async function handleCopy(event) {
+ console.log("Copy link clicked");
+ // 1. Prevent the link from actually navigating
+ event.preventDefault();
+
+ // 2. Grab the text from our span
+ const text = document.getElementById('vin').innerText;
+
+ try {
+ // 3. Write to clipboard
+ await navigator.clipboard.writeText(text);
+
+ // 4. Update the UI to show it worked
+ const link = event.target;
+ const originalText = link.innerText;
+ link.innerText = "Copied!";
+ link.style.color = "#4CAF50"; // Turn green
+
+ // 5. Reset after 2 seconds
+ setTimeout(() => {
+ link.innerText = originalText;
+ link.style.color = "";
+ }, 2000);
+
+ } catch (err) {
+ console.error('Unable to copy', err);
+ }
+}
\ No newline at end of file
diff --git a/lib/vehicles/hooks/view_hook_listener.rb b/lib/vehicles/hooks/view_hook_listener.rb
index 3420f46..c02eefc 100644
--- a/lib/vehicles/hooks/view_hook_listener.rb
+++ b/lib/vehicles/hooks/view_hook_listener.rb
@@ -14,7 +14,8 @@ module Vehicles
def view_layouts_base_html_head(context = {})
safe_join([
- stylesheet_link_tag('style', plugin: :redmine_qbo_vehicles, media: :all)
+ stylesheet_link_tag('style', plugin: :redmine_qbo_vehicles, media: :all),
+ javascript_include_tag('copy', plugin: :redmine_qbo_vehicles)
])
end