diff --git a/peachjam/js/components/clipboard.ts b/peachjam/js/components/clipboard.ts index d2242269e..fa9af618a 100644 --- a/peachjam/js/components/clipboard.ts +++ b/peachjam/js/components/clipboard.ts @@ -10,8 +10,23 @@ export class CopyToClipboard { async copy () { try { + const text = this.root.dataset.value; + const html = this.root.dataset.valueHtml; + if (navigator && navigator.clipboard) { - await navigator.clipboard.writeText(this.root.dataset.value || ''); + const items: Record = {}; + + if (text) { + const type = 'text/plain'; + items[type] = new Blob([text], { type }); + } + + if (html) { + const type = 'text/html'; + items[type] = new Blob([html], { type }); + } + + await navigator.clipboard.write([new ClipboardItem(items)]); this.root.innerText = this.root.dataset.confirmation || 'Copied!'; setTimeout(() => { diff --git a/peachjam/settings.py b/peachjam/settings.py index 25d9cee22..40558eb62 100644 --- a/peachjam/settings.py +++ b/peachjam/settings.py @@ -100,6 +100,7 @@ "allauth.account.middleware.AccountMiddleware", "django.middleware.cache.FetchFromCacheMiddleware", "django_htmx.middleware.HtmxMiddleware", + "django.contrib.sites.middleware.CurrentSiteMiddleware", ] ROOT_URLCONF = "peachjam.urls" diff --git a/peachjam/templates/peachjam/_document_table.html b/peachjam/templates/peachjam/_document_table.html index 96af54793..842d970f8 100644 --- a/peachjam/templates/peachjam/_document_table.html +++ b/peachjam/templates/peachjam/_document_table.html @@ -10,7 +10,7 @@
- {% trans 'Title' %} + {{ doc_table_title_label|default_if_none:"Title" }}
@@ -27,7 +27,7 @@
- {% trans 'Date' %} + {{ doc_table_date_label|default_if_none:"Date" }}
diff --git a/peachjam/templates/peachjam/_quick_search.html b/peachjam/templates/peachjam/_quick_search.html index 1565d60e1..d269a342c 100644 --- a/peachjam/templates/peachjam/_quick_search.html +++ b/peachjam/templates/peachjam/_quick_search.html @@ -1,4 +1,5 @@ -
+{% load i18n %} + {% endif %} {% if doc_type %}{% endif %}
+{% trans "Advanced search" %} diff --git a/peachjam/templates/peachjam/judgment_detail.html b/peachjam/templates/peachjam/judgment_detail.html index bcd99f90a..ac213f516 100644 --- a/peachjam/templates/peachjam/judgment_detail.html +++ b/peachjam/templates/peachjam/judgment_detail.html @@ -36,7 +36,8 @@ class="btn btn-outline-secondary btn-xs ms-2" title="{% trans "Copy to clipboard" %}" data-component="CopyToClipboard" - data-value="{{ document.mnc }}" + data-value='{{ document.mnc }}' + data-value-html='{{ document.mnc }}' data-confirmation="{% trans "Copied!" %}"> {% trans "Copy" %} diff --git a/peachjam/templates/peachjam/layouts/document_detail.html b/peachjam/templates/peachjam/layouts/document_detail.html index 0cff88c06..cba642520 100644 --- a/peachjam/templates/peachjam/layouts/document_detail.html +++ b/peachjam/templates/peachjam/layouts/document_detail.html @@ -183,7 +183,8 @@

{{ document.title }}

class="btn btn-outline-secondary btn-xs ms-2" title="{% trans "Copy to clipboard" %}" data-component="CopyToClipboard" - data-value="{{ document.citation }}" + data-value='{{ document.citation }}' + data-value-html='{{ document.citation }}' data-confirmation="{% trans "Copied!" %}"> {% trans "Copy" %} @@ -210,7 +211,8 @@

{{ document.title }}

class="btn btn-outline-secondary btn-xs ms-2" title="{% trans "Copy to clipboard" %}" data-component="CopyToClipboard" - data-value="{{ alternative_name.title }}" + data-value='{{ alternative_name.title }}' + data-value-html='{{ alternative_name.title }}' data-confirmation="{% trans "Copied!" %}"> {% trans "Copy" %} diff --git a/peachjam/views/courts.py b/peachjam/views/courts.py index 0ed4e66df..864fc25e2 100644 --- a/peachjam/views/courts.py +++ b/peachjam/views/courts.py @@ -39,6 +39,8 @@ def get_context_data(self, **kwargs): context["doc_type"] = "Judgment" context["page_title"] = self.page_title() context["doc_table_show_jurisdiction"] = False + context["doc_table_title_label"] = _("Citation") + context["doc_table_date_label"] = _("Judgment date") self.populate_years(context) context["documents"] = self.group_documents(context["documents"]) diff --git a/peachjam/views/generic_views.py b/peachjam/views/generic_views.py index af91ae297..343eec756 100644 --- a/peachjam/views/generic_views.py +++ b/peachjam/views/generic_views.py @@ -136,6 +136,8 @@ def get_context_data(self, **kwargs): self.add_facets(context) self.show_facet_clear_all(context) context["doc_count"] = context["paginator"].count + context["doc_table_title_label"] = _("Title") + context["doc_table_date_label"] = _("Date") return context