Bugzilla – Attachment 79408 Details for
Bug 21411
Advanced cataloging editor - rancor - Allow configuration of Keyboard shortcuts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21411 - Advanced cataloging editor - rancor - Allow configuration of Keyboard
Bug-21411---Advanced-cataloging-editor---rancor---.patch (text/plain), 17.02 KB, created by
Nick Clemens (kidclamp)
on 2018-09-26 12:10:37 UTC
(
hide
)
Description:
Bug 21411 - Advanced cataloging editor - rancor - Allow configuration of Keyboard
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-09-26 12:10:37 UTC
Size:
17.02 KB
patch
obsolete
>From a181e24c6f68022c8a942d8e1dd65510e27c1f0d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 26 Sep 2018 12:05:43 +0000 >Subject: [PATCH] Bug 21411 - Advanced cataloging editor - rancor - Allow > configuration of Keyboard > >This patch allows for redfining the keyboard shortcuts used in rancor. >For now these are set globally (per instance) >Ctrl-S is a codemirror setting and cannot be altered > >To test: > 1 - Apply patches > 2 - update database > 3 - Load the advanced cataloging editor > 4 - Click the "Keyboard shortcuts" button > 5 - Ensure the list looks correct > 6 - Note that 'Ctrl-S' note sit cannot be remapped > 7 - Note the 'Redefine shortcuts' link at the top of the menu > 8 - Confirm all the listed shortcuts work as expected > 9 - Click the 'Redefine' link >10 - Ensure current mappings load correctly >11 - Read explanation and verify it makes sense >12 - Remap some functions >13 - Return to the cataloging editor >14 - Confirm your mappings work >--- > Koha/KeyboardShortcut.pm | 44 ++++++++++++++++ > Koha/KeyboardShortcuts.pm | 50 ++++++++++++++++++ > cataloguing/editor.pl | 8 +++ > .../mysql/atomicupdate/add_keyboard_shortcuts.perl | 31 +++++++++++ > installer/data/mysql/kohastructure.sql | 9 ++++ > .../lib/koha/cateditor/marc-editor.js | 48 ++++++++--------- > .../prog/en/includes/cateditor-ui.inc | 3 ++ > .../prog/en/modules/cataloguing/editor.tt | 53 +++---------------- > .../prog/en/modules/tools/adveditorshortcuts.tt | 61 ++++++++++++++++++++++ > 9 files changed, 237 insertions(+), 70 deletions(-) > create mode 100644 Koha/KeyboardShortcut.pm > create mode 100644 Koha/KeyboardShortcuts.pm > create mode 100644 installer/data/mysql/atomicupdate/add_keyboard_shortcuts.perl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/adveditorshortcuts.tt > >diff --git a/Koha/KeyboardShortcut.pm b/Koha/KeyboardShortcut.pm >new file mode 100644 >index 0000000..4a45f44 >--- /dev/null >+++ b/Koha/KeyboardShortcut.pm >@@ -0,0 +1,44 @@ >+package Koha::KeyboardShortcut; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::KeyboardShortcut - Koha KeyboardShortcut Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'KeyboardShortcut'; >+} >+ >+1; >diff --git a/Koha/KeyboardShortcuts.pm b/Koha/KeyboardShortcuts.pm >new file mode 100644 >index 0000000..af26745 >--- /dev/null >+++ b/Koha/KeyboardShortcuts.pm >@@ -0,0 +1,50 @@ >+package Koha::KeyboardShortcuts; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::KeyboardShortcut; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::KeyboardShortcuts - Koha KeyboardShortcut Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'KeyboardShortcut'; >+} >+ >+sub object_class { >+ return 'Koha::KeyboardShortcut'; >+} >+ >+1; >diff --git a/cataloguing/editor.pl b/cataloguing/editor.pl >index 0806233..adcd04d 100755 >--- a/cataloguing/editor.pl >+++ b/cataloguing/editor.pl >@@ -30,6 +30,7 @@ use C4::Output; > use DBIx::Class::ResultClass::HashRefInflator; > use Koha::Database; > use Koha::MarcSubfieldStructures; >+use Koha::KeyboardShortcuts; > > my $input = CGI->new; > >@@ -45,6 +46,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > my $schema = Koha::Database->new->schema; > >+my @keyboard_shortcuts = Koha::KeyboardShortcuts->search(); >+ >+# Keyboard shortcuts >+$template->param( >+ shortcuts => \@keyboard_shortcuts, >+); >+ > # Available import batches > $template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search( > { >diff --git a/installer/data/mysql/atomicupdate/add_keyboard_shortcuts.perl b/installer/data/mysql/atomicupdate/add_keyboard_shortcuts.perl >new file mode 100644 >index 0000000..cee74ee >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/add_keyboard_shortcuts.perl >@@ -0,0 +1,31 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ unless ( TableExists( 'keyboard_shortcuts' ) ) { >+ $dbh->do(q| >+ CREATE TABLE keyboard_shortcuts ( >+ id int(11) NOT NULL AUTO_INCREMENT, >+ shortcut_name varchar(80) NOT NULL, >+ shortcut_keys varchar(80) NOT NULL, >+ shortcut_desc varchar(200) NOT NULL, >+ PRIMARY KEY (id) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;| >+ ); >+ } >+ $dbh->do(q| >+ INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys, shortcut_desc) VALUES >+ ("insert_copyright","Alt-C","Insert copyright symbol (©)"), >+ ("insert_copyright_sound","Alt-P","Insert copyright symbol (â) (sound recordings)"), >+ ("insert_delimiter","Ctrl-D","Insert delimiter (â¡)"), >+ ("subfield_help","Ctrl-H","Get help on current subfield"), >+ ("link_authorities","Ctrl-Shift-L","Link field to authorities"), >+ ("delete_field","Ctrl-X","Delete current field"), >+ ("delete_subfield","Ctrl-Shift-X","Delete current subfield"), >+ ("new_line","Enter","New field on next line"), >+ ("line_break","Shift-Enter","Insert line break"), >+ ("next_position","Tab","Move to next position"), >+ ("prev_position","Shift-Tab","Move to previous position") >+ ;| >+ ); >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug XXXXX - Add keyboard_shortcuts table)\n"; >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 49a0f18..1b8bdfc 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -4208,6 +4208,15 @@ CREATE TABLE `oauth_access_tokens` ( > PRIMARY KEY (`access_token`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > >+DROP TABLE IF EXISTS `keyboard_shortcuts`; >+CREATE TABLE keyboard_shortcuts ( >+id int(11) NOT NULL AUTO_INCREMENT, >+shortcut_name varchar(80) NOT NULL, >+shortcut_keys varchar(80) NOT NULL, >+shortcut_desc varchar(200) NOT NULL, >+PRIMARY KEY (id) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >+ > /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; > /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; > /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >index 1caf75d..547de5c 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >@@ -135,36 +135,36 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], > return []; > } > } >+ var _editorKeys = {}; > >- var _editorKeys = { >- 'Alt-C': function( cm ) { >+ _editorKeys[insert_copyright] = function( cm ) { > cm.replaceRange( '©', cm.getCursor() ); >- }, >+ } > >- 'Alt-P': function( cm ) { >+ _editorKeys[insert_copyright_sound] = function( cm ) { > cm.replaceRange( 'â', cm.getCursor() ); >- }, >+ } > >- Enter: function( cm ) { >+ _editorKeys[new_line] = function( cm ) { > var cursor = cm.getCursor(); > cm.replaceRange( '\n', { line: cursor.line }, null, 'marcAware' ); > cm.setCursor( { line: cursor.line + 1, ch: 0 } ); >- }, >+ } > >- 'Shift-Enter': function( cm ) { >+ _editorKeys[line_break] = function( cm ) { > var cur = cm.getCursor(); > > cm.replaceRange( "\n", cur, null ); >- }, >+ } > >- 'Ctrl-X': function( cm ) { >+ _editorKeys[delete_field] = function( cm ) { > // Delete line (or cut) > if ( cm.somethingSelected() ) return true; > > cm.execCommand('deleteLine'); >- }, >+ } > >- 'Shift-Ctrl-L': function( cm ) { >+ _editorKeys[link_authorities] = function( cm ) { > // Launch the auth search popup > var field = cm.marceditor.getCurrentField(); > >@@ -186,18 +186,18 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], > } > newin=window.open("../authorities/auth_finder.pl?source=biblio&authtypecode="+authtype+"&index="+index+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); > >- }, >+ } > >- 'Shift-Ctrl-X': function( cm ) { >+ _editorKeys[delete_subfield] = function( cm ) { > // Delete subfield > var field = cm.marceditor.getCurrentField(); > if ( !field ) return; > > var subfield = field.getSubfieldAt( cm.getCursor().ch ); > if ( subfield ) subfield.delete(); >- }, >+ } > >- Tab: function( cm ) { >+ _editorKeys[next_position] = function( cm ) { > // Move through parts of tag/fixed fields > var positions = getTabPositions( cm.marceditor ); > var cur = cm.getCursor(); >@@ -210,9 +210,9 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], > } > > cm.setCursor( { line: cur.line + 1, ch: 0 } ); >- }, >+ } > >- 'Shift-Tab': function( cm ) { >+ _editorKeys[prev_position] = function( cm ) { > // Move backwards through parts of tag/fixed fields > var positions = getTabPositions( cm.marceditor ); > var cur = cm.getCursor(); >@@ -233,15 +233,13 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], > } else { > cm.setCursor( { line: cur.line - 1, ch: 0 } ); > } >- }, >+ } > >- 'Ctrl-D': function( cm ) { >- // Insert subfield delimiter >- var cur = cm.getCursor(); >+ _editorKeys[insert_delimiter] = function(cm){ >+ var cur = cm.getCursor(); > >- cm.replaceRange( "â¡", cur, null ); >- }, >- }; >+ cm.replaceRange( "â¡", cur, null ); >+ } > > // The objects below are part of a field/subfield manipulation API, accessed through the base > // editor object. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index 7dd6f9d..a277eb8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -4,6 +4,9 @@ > [% Asset.js("lib/koha/cateditor/marc-mode.js") | $raw %] > [% Asset.js("lib/require.js") | $raw %] > <script> >+[% FOREACH shortcut IN shortcuts -%] >+ var [% shortcut.shortcut_name | html %] = "[% shortcut.shortcut_keys | html %]"; >+[% END %] > var authInfo = { > [%- FOREACH authtag = authtags -%] > [% authtag.tagfield | html %]: { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >index b282489..246a6dc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >@@ -255,6 +255,7 @@ > </div> > > <div id="shortcuts-contents" style="display: none"> >+<a id="redefine_shortcuts" href="/cgi-bin/koha/tools/adveditorshortcuts.pl">Redefine shortcuts</a> > <table class="table table-condensed"> > <thead> > <tr> >@@ -263,53 +264,15 @@ > </tr> > </thead> > <tbody> >- <tr> >- <td>Alt-C</td> >- <td>Insert copyright symbol (©)</td> >- </tr> >- <tr> >- <td>Alt-P</td> >- <td>Insert copyright symbol (â) (sound recordings)</td> >- </tr> >- <tr> >- <td>Ctrl-D</td> >- <td>Insert delimiter (â¡)</td> >- </tr> >- <tr> >- <td>Ctrl-H</td> >- <td>Get help on current subfield</td> >- </tr> >- <tr> >- <td>Ctrl-Shift-L</td> >- <td>Link field to authorities</td> >- </tr> >+ [% FOREACH shortcut IN shortcuts %] >+ <tr> >+ <td>[% shortcut.shortcut_keys %]</td> >+ <td>[% shortcut.shortcut_desc %]</td> >+ </tr> >+ [% END %] > <tr> > <td>Ctrl-S</td> >- <td>Save record</td> >- </tr> >- <tr> >- <td>Ctrl-X</td> >- <td>Delete current field</td> >- </tr> >- <tr> >- <td>Ctrl-Shift-X</td> >- <td>Delete current subfield</td> >- </tr> >- <tr> >- <td>Enter</td> >- <td>New field on next line</td> >- </tr> >- <tr> >- <td>Shift-Enter</td> >- <td>Insert line break</td> >- </tr> >- <tr> >- <td>Tab</td> >- <td>Move to next position</td> >- </tr> >- <tr> >- <td>Shift-Tab</td> >- <td>Move to previous position</td> >+ <td>Save record (cannot be remapped)</td> > </tr> > </tbody> > </table> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/adveditorshortcuts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/adveditorshortcuts.tt >new file mode 100644 >index 0000000..c0de43e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/adveditorshortcuts.tt >@@ -0,0 +1,61 @@ >+[% USE raw %] >+[% USE Asset %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools › Advanced editor shortcuts</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="adveditor_shortcuts" class="tools"> >+ [% INCLUDE 'header.inc' %] >+ [% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> >+› <a href="/cgi-bin/koha/reviews/adveditorshortcuts.pl">Advanced editor shortcuts</a></div> >+ >+<div id="doc3" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <h1>Advanced editor keyboard shortcuts</h1> >+ <p>Separate keys using a hyphen "-"<p> >+ <p>Control key is "Ctrl"</p> >+ <p>Alt key is "Alt"</p> >+ <p>Shift is "Shift"</p> >+ <p>More docmentation on defining key maps can be found <a href="https://codemirror.net/doc/manual.html#keymaps">here</a></p> >+ >+ <form id="adveditor_shortcuts" method="post" action="/cgi-bin/koha/tools/adveditorshortcuts.pl"> >+ <input type=hidden name="op" value="save" /> >+ >+ <table id="adv_editor_keyboard_shortcuts"> >+ <thead> >+ <th>Description</th> >+ <th>Shortcut keys</th> >+ </thead> >+ <tbody> >+ [% FOREACH shortcut IN shortcuts %] >+ <tr> >+ <td><label for="shortcut_keys">[% shortcut.shortcut_desc %]</label></td> >+ <td> >+ <input type="hidden" name="shortcut_name" value="[% shortcut.shortcut_name %]"> >+ <input type="text" name="shortcut_keys" value="[% shortcut.shortcut_keys %]"> >+ </td> >+ </tr> >+ [% END %] >+ </table> >+ <input type="submit" value="Save shortcuts"> >+ </form> >+ >+ </div> <!-- yui-b --> >+ </div> <!-- yui-main --> >+ >+<div class="yui-b noprint"> >+[% INCLUDE 'tools-menu.inc' %] >+</div> >+ </div> <!-- bd --> >+</div> <!-- doc3 --> >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/tools-menu.js") | $raw %] >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.1.4
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 21411
:
79408
|
79409
|
85365
|
85366
|
85397
|
85398
|
86012
|
86013
|
86014
|
86018
|
86019
|
86020
|
88465
|
88466
|
88467
|
88468
|
89119
|
89179
|
89416
|
89417
|
89418
|
89419
|
89420
|
89421