Bugzilla – Attachment 94368 Details for
Bug 23388
Make system preferences links
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23388: [WIP] Make system preferences links
Bug-23388-WIP-Make-system-preferences-links.patch (text/plain), 7.93 KB, created by
Owen Leonard
on 2019-10-17 12:11:55 UTC
(
hide
)
Description:
Bug 23388: [WIP] Make system preferences links
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2019-10-17 12:11:55 UTC
Size:
7.93 KB
patch
obsolete
>From d72f4222bfef585ef6f4de4727dadf2af79b45be Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 1 Aug 2019 17:28:53 +0000 >Subject: [PATCH] Bug 23388: [WIP] Make system preferences links > >This alternate solution adds a link which when clicked will copy a URL >linking directly to the corresponding system preference. > >To test, apply the patch and view system preferences. > >Hovering the mouse over any row in the system preferences table should >trigger the display of an anchor link at the end of the row. Hovering >over the link should display a tooltip, "Copy link to this preference." >Clicking the link should copy it to your clipboard. > >Test that the link is copied correctly and that it works to link you to >the preference in question. > >Known issues: Because of the way the page is drawn, the browser's >calculation of where to scroll isn't accurate, meaning the target >preference will sometimes be hidden by the floating toolbar. > >Question: "Hover" isn't a mobile/touch-friendly interaction. Show the >link all the time? Show it at narrower browser widths? >--- > koha-tmpl/intranet-tmpl/prog/css/preferences.css | 17 +++++++++++++++++ > .../prog/en/modules/admin/preferences.tt | 15 ++++++++++++--- > .../intranet-tmpl/prog/js/pages/preferences.js | 21 +++++++++++++++++++-- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 13 +++++++++++++ > 4 files changed, 61 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/preferences.css b/koha-tmpl/intranet-tmpl/prog/css/preferences.css >index 7ecce1be4d9..521db6d0aac 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/preferences.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/preferences.css >@@ -134,4 +134,21 @@ span.overridden { > border: 1px solid #EEE; > margin: 1em 1em 1em 0; > resize: vertical; >+} >+ >+.name-cell:target { >+ background-color: #FFC; >+} >+ >+.permalink { >+ bottom: 0; >+ display: inline-block; >+ padding: 5px; >+ position: absolute; >+ right: 0; >+} >+ >+.pref-cell > div { >+ padding-right: 1em; >+ position: relative; > } >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >index 764f1645d95..a9f27568a89 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >@@ -52,9 +52,11 @@ > [% ELSE %] > [% IF ( loop.first ) %]<table class="preferences"><thead><tr><th>Preference</th><th>Value</th></tr></thead><tbody>[% END %] > <tr class="name-row"> >- <td class="name-cell"> >+ <td id="link_[% FOREACH NAME IN LINE.NAMES %][% NAME.name | html %][% UNLESS ( loop.last ) %]__[% END %][% END %]" class="name-cell"> > <code> >+ [% SET is_pref = 0 %] > [% FOREACH NAME IN LINE.NAMES %] >+ [% SET is_pref = 1 %] > <label for="pref_[% NAME.name | html %]"> > [% IF ( NAME.jumped ) %] > <span class="term" id="jumped">[% NAME.name | html %]</span> >@@ -74,7 +76,8 @@ > [% END %] > </code> > </td> >- <td><div> >+ <td class="pref-cell"> >+ <div> > [% FOREACH CHUNK IN LINE.CHUNKS %] > [% IF ( CHUNK.type_text ) %] > [% CHUNK.contents | $raw %] >@@ -143,7 +146,11 @@ > </ul> <!-- / ul.sortable --> > [% END %] > [% END %] >- </div></td> >+ [% IF ( is_pref ) %] >+ <a class="permalink" style="display:none" data-toggle="tooltip" data-placement="left" title="Copy link to this preference" href="[% Koha.Preference("staffClientBaseURL") | uri %]/cgi-bin/koha/admin/preferences.pl?tab=[% TAB.tab_id | uri %]#link_[% FOREACH NAME IN LINE.NAMES %][% NAME.name | html %][% UNLESS ( loop.last ) %]__[% END %][% END %]"><i class="fa fa-link fa-rotate-180"></i></a> >+ [% END %] >+ </div> >+ </td> > </tr> > [% IF ( loop.last ) %]</tbody></table>[% END %] > [% END %] >@@ -212,6 +219,8 @@ > var MSG_ALL_VALUE_WARN = _("Note: _ALL_ value will override all other values"); > var MSG_UPD_LOC_FORMAT_WARN = _("The following values are not formatted correctly:"); > var MSG_INVALID = _( "Error: presence of invalid data prevent saving. Please make the corrections and try again." ); >+ var MSG_COPY_TO_CLIPBOARD = _( "Copy link to this preference" ); >+ var MSG_COPIED_TO_CLIPBOARD = _( "Link copied to the clipboard" ); > </script> > [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] > [% Asset.js("js/ajax.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >index d5db030e7b9..7c99c2e4b06 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >@@ -1,4 +1,4 @@ >-/* global KOHA MSG_MADE_CHANGES CodeMirror MSG_CLICK_TO_EXPAND MSG_CLICK_TO_COLLAPSE to_highlight search_jumped humanMsg MSG_NOTHING_TO_SAVE MSG_MODIFIED MSG_SAVING MSG_SAVED_PREFERENCE dataTablesDefaults */ >+/* global KOHA MSG_MADE_CHANGES CodeMirror MSG_CLICK_TO_EXPAND MSG_CLICK_TO_COLLAPSE to_highlight search_jumped humanMsg MSG_NOTHING_TO_SAVE MSG_MODIFIED MSG_SAVING MSG_SAVED_PREFERENCE dataTablesDefaults copyToClipboard MSG_COPIED_TO_CLIPBOARD MSG_COPY_TO_CLIPBOARD */ > // We can assume 'KOHA' exists, as we depend on KOHA.AJAX > > KOHA.Preferences = { >@@ -68,6 +68,10 @@ $( document ).ready( function () { > KOHA.Preferences.Modified = true; > } > >+ $(".pref-cell").on("hover", function(){ >+ $(this).find(".permalink").toggle(); >+ }); >+ > $( '.prefs-tab' ) > .find( 'input.preference, textarea.preference' ).on('input', function () { > if ( this.defaultValue === undefined || this.value != this.defaultValue ) mark_modified.call( this ); >@@ -205,4 +209,17 @@ $( document ).ready( function () { > email: true > }); > }); >-} ); >+ >+ $(".permalink").on("click", function(e){ >+ e.preventDefault(); >+ copyToClipboard( $(this).attr("href") ); >+ $(this).attr("data-original-title", MSG_COPIED_TO_CLIPBOARD ) >+ .tooltip("show"); >+ }); >+ >+ $(".permalink").tooltip({ >+ delay: { "show": 100, "hide": 500 } >+ }).on("hidden.bs.tooltip", function(){ >+ $(this).attr("data-original-title", MSG_COPY_TO_CLIPBOARD ); >+ }); >+}); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 4c6f96c92bd..eef38da5eb9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -232,3 +232,16 @@ function keep_text(clicked_index) { > searchboxes[i].value = persist; > } > } >+ >+// https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f >+function copyToClipboard( text ){ >+ var el = document.createElement("textarea"); // Create a <textarea> element >+ el.value = text; // Set its value to the string that you want copied >+ el.setAttribute("readonly", ""); // Make it readonly to be tamper-proof >+ el.style.position = "absolute"; >+ el.style.left = "-9999px"; // Move outside the screen to make it invisible >+ document.body.appendChild(el); // Append the <textarea> element to the HTML document >+ el.select(); // Select the <textarea> content >+ document.execCommand("copy"); // Copy - only works as a result of a user action (e.g. click events) >+ document.body.removeChild(el); // Remove the <textarea> element >+} >\ No newline at end of file >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23388
:
91840
|
91841
|
91846
|
91847
| 94368