Add copy MusicBrainz ID button
This commit is contained in:
@@ -32,6 +32,14 @@ let liveSocket = new LiveSocket("/live", Socket, {
|
|||||||
topbar.config({barColors: {0: "#FD4F00"}, shadowColor: "rgba(0, 0, 0, .3)"})
|
topbar.config({barColors: {0: "#FD4F00"}, shadowColor: "rgba(0, 0, 0, .3)"})
|
||||||
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
|
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
|
||||||
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
|
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
|
||||||
|
window.addEventListener("music_library:clipcopy", (event) => {
|
||||||
|
if ("clipboard" in navigator) {
|
||||||
|
const text = event.target.textContent;
|
||||||
|
navigator.clipboard.writeText(text);
|
||||||
|
} else {
|
||||||
|
alert("Sorry, your browser does not support clipboard copy.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// connect if there are any LiveViews on the page
|
// connect if there are any LiveViews on the page
|
||||||
liveSocket.connect()
|
liveSocket.connect()
|
||||||
|
|||||||
@@ -56,10 +56,24 @@
|
|||||||
<dt class="text-sm font-medium leading-6 text-zinc-900 dark:text-zinc-400">
|
<dt class="text-sm font-medium leading-6 text-zinc-900 dark:text-zinc-400">
|
||||||
<%= gettext("MusicBrainz ID") %>
|
<%= gettext("MusicBrainz ID") %>
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
<dd class="mt-1 text-sm flex leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||||
<a href={musicbrainz_url(@record)}>
|
<a href={musicbrainz_url(@record)}>
|
||||||
<code><%= @record.musicbrainz_id %></code>
|
<code id={"mb-#{@record.musicbrainz_id}"}><%= @record.musicbrainz_id %></code>
|
||||||
</a>
|
</a>
|
||||||
|
<button
|
||||||
|
class="transition-colors"
|
||||||
|
phx-click={
|
||||||
|
JS.dispatch("music_library:clipcopy", to: "#mb-" <> @record.musicbrainz_id)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span class="sr-only"><%= gettext("Copy MusicBrainz ID to clipboard") %></span>
|
||||||
|
<.icon
|
||||||
|
name="hero-clipboard-document"
|
||||||
|
class="-mt-1 h-5 w-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
data-slot="icon"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
||||||
|
|||||||
@@ -56,10 +56,24 @@
|
|||||||
<dt class="text-sm font-medium leading-6 text-zinc-900 dark:text-zinc-400">
|
<dt class="text-sm font-medium leading-6 text-zinc-900 dark:text-zinc-400">
|
||||||
<%= gettext("MusicBrainz ID") %>
|
<%= gettext("MusicBrainz ID") %>
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
<dd class="mt-1 text-sm flex leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||||
<a href={musicbrainz_url(@record)}>
|
<a href={musicbrainz_url(@record)}>
|
||||||
<code><%= @record.musicbrainz_id %></code>
|
<code id={"mb-#{@record.musicbrainz_id}"}><%= @record.musicbrainz_id %></code>
|
||||||
</a>
|
</a>
|
||||||
|
<button
|
||||||
|
class="transition-colors"
|
||||||
|
phx-click={
|
||||||
|
JS.dispatch("music_library:clipcopy", to: "#mb-" <> @record.musicbrainz_id)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span class="sr-only"><%= gettext("Copy MusicBrainz ID to clipboard") %></span>
|
||||||
|
<.icon
|
||||||
|
name="hero-clipboard-document"
|
||||||
|
class="-mt-1 h-5 w-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
data-slot="icon"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ msgstr ""
|
|||||||
msgid "Attempting to reconnect"
|
msgid "Attempting to reconnect"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/record_live/show.html.heex:95
|
#: lib/music_library_web/live/record_live/show.html.heex:109
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Back to records"
|
msgid "Back to records"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:87
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:101
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Back to wishlist"
|
msgid "Back to wishlist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -125,8 +125,8 @@ msgstr ""
|
|||||||
msgid "Import from MusicBrainz"
|
msgid "Import from MusicBrainz"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/record_live/show.html.heex:75
|
#: lib/music_library_web/live/record_live/show.html.heex:89
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:67
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:81
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Inserted at"
|
msgid "Inserted at"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -201,7 +201,7 @@ msgstr ""
|
|||||||
msgid "Purchased at"
|
msgid "Purchased at"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/record_live/show.html.heex:67
|
#: lib/music_library_web/live/record_live/show.html.heex:81
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Purchased on"
|
msgid "Purchased on"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -307,8 +307,8 @@ msgstr ""
|
|||||||
msgid "Types"
|
msgid "Types"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/record_live/show.html.heex:83
|
#: lib/music_library_web/live/record_live/show.html.heex:97
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:75
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:89
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Updated at"
|
msgid "Updated at"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -345,3 +345,9 @@ msgstr ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "close"
|
msgid "close"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/live/record_live/show.html.heex:69
|
||||||
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:69
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Copy MusicBrainz ID to clipboard"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user