=cut
-=head3 type
+=head3 _type (internal)
=cut
return 'KeyboardShortcut';
}
+=head3 object_class (internal)
+
+=cut
+
sub object_class {
return 'Koha::KeyboardShortcut';
}
my $op = $input->param('op') || 'list';
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- { template_name => "tools/adveditorshortcuts.tt",
+ { template_name => "admin/adveditorshortcuts.tt",
query => $input,
type => "intranet",
authnotrequired => 1,
- flagsrequired => {},
+ flagsrequired => { parameters => 'manage_keyboard_shortcuts' },
debug => 1,
}
);
--- /dev/null
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+ unless ( TableExists( 'keyboard_shortcuts' ) ) {
+ $dbh->do(q|
+ CREATE TABLE keyboard_shortcuts (
+ shortcut_name varchar(80) NOT NULL,
+ shortcut_keys varchar(80) NOT NULL,
+ PRIMARY KEY (shortcut_name)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;|
+ );
+ }
+ $dbh->do(q|
+ INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
+ ("insert_copyright","Alt-C"),
+ ("insert_copyright_sound","Alt-P"),
+ ("insert_delimiter","Ctrl-D"),
+ ("subfield_help","Ctrl-H"),
+ ("link_authorities","Shift-Ctrl-L"),
+ ("delete_field","Ctrl-X"),
+ ("delete_subfield","Shift-Ctrl-X"),
+ ("new_line","Enter"),
+ ("line_break","Shift-Enter"),
+ ("next_position","Tab"),
+ ("prev_position","Shift-Tab")
+ ;|
+ );
+ $dbh->do(q|
+ INSERT IGNORE permissions (module_bit, code, description)
+ VALUES
+ (3,'manage_keyboard_shortcuts','Manage keyboard shortcuts for advanced cataloging editor')
+ ;|
+ );
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug XXXXX - Add keyboard_shortcuts table)\n";
+}
+++ /dev/null
-$DBversion = 'XXX';
-if( CheckVersion( $DBversion ) ) {
- unless ( TableExists( 'keyboard_shortcuts' ) ) {
- $dbh->do(q|
- CREATE TABLE keyboard_shortcuts (
- shortcut_name varchar(80) NOT NULL,
- shortcut_keys varchar(80) NOT NULL,
- shortcut_desc varchar(200) NOT NULL,
- PRIMARY KEY (shortcut_name)
- ) 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","Shift-Ctrl-L","Link field to authorities"),
- ("delete_field","Ctrl-X","Delete current field"),
- ("delete_subfield","Shift-Ctrl-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";
-}
CREATE TABLE keyboard_shortcuts (
shortcut_name varchar(80) NOT NULL,
shortcut_keys varchar(80) NOT NULL,
-shortcut_desc varchar(200) NOT NULL,
PRIMARY KEY (shortcut_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- keyboard shortcuts
-INSERT 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","Shift-Ctrl-L","Link field to authorities"),
- ("delete_field","Ctrl-X","Delete current field"),
- ("delete_subfield","Shift-Ctrl-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");
+INSERT INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
+ ("insert_copyright","Alt-C"),
+ ("insert_copyright_sound","Alt-P"),
+ ("insert_delimiter","Ctrl-D"),
+ ("subfield_help","Ctrl-H"),
+ ("link_authorities","Shift-Ctrl-L"),
+ ("delete_field","Ctrl-X"),
+ ("delete_subfield","Shift-Ctrl-X"),
+ ("new_line","Enter"),
+ ("line_break","Shift-Enter"),
+ ("next_position","Tab"),
+ ("prev_position","Shift-Tab");
( 3, 'manage_usage_stats', 'Manage usage statistics settings'),
( 3, 'manage_mana', 'Manage Mana KB content sharing'),
( 3, 'manage_additional_fields', 'Add, edit, or delete additional custom fields for baskets or subscriptions (also requires order_manage or edit_subscription permissions)'),
+ ( 3, 'manage_keyboard_shortcuts', 'Manage keyboard shortcuts for the advanced cataloging editor'),
( 4, 'edit_borrowers', 'Add, modify and view patron information'),
( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
( 6, 'place_holds', 'Place holds for patrons'),
[% IF ( CAN_user_parameters_manage_additional_fields ) %]
<li><a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a></li>
[% END %]
+ [% IF ( CAN_user_parameters_manage_keyboard_shortcuts ) %]
+ <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
+ [% END %]
</ul>
[% END %]
</div>
--- /dev/null
+[%- BLOCK keyboard_shortcut_descriptions -%]
+ [% SWITCH shortcut_name %]
+ [%- CASE 'insert_copyright' -%]<span>Insert copyright symbol (©)</span>
+ [%- CASE 'insert_copyright_sound' -%]<span>Insert copyright symbol (℗) (sound recordings)</span>
+ [%- CASE 'insert_delimiter' -%]<span>Insert delimiter (‡)</span>
+ [%- CASE 'subfield_help' -%]<span>Get help on current subfield</span>
+ [%- CASE 'link_authorities' -%]<span>Link field to authorities</span>
+ [%- CASE 'delete_field' -%]<span>Delete current field</span>
+ [%- CASE 'delete_subfield' -%]<span>Delete current subfield</span>
+ [%- CASE 'new_line' -%]<span>New field on next line</span>
+ [%- CASE 'line_break' -%]<span>Insert line break</span>
+ [%- CASE 'next_position' -%]<span>Move to next position</span>
+ [%- CASE 'prev_position' -%]<span>Move to previous position</span>
+ [%- END -%]
+[%- END -%]
Manage Mana KB content sharing
</span>
<span class="permissioncode">([% name | html %])</span>
+ [%- CASE 'manage_keyboard_shortcuts' -%]
+ <span class="sub_permission manage_keyboard_shortcuts_subpermission">
+ Manage keyboard shortcuts for the advanced cataloging editor
+ </span>
+ <span class="permissioncode">([% name | html %])</span>
[%- CASE 'edit_borrowers' -%]
<span class="sub_permission edit_borrowers_subpermission">
Add, modify and view patron information
<dt><a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a></dt>
<dd>Add additional fields to certain tables</dd>
[% END %]
+ [% IF ( CAN_user_parameters_manage_keyboard_shortcuts ) %]
+ <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
+ <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
+ [% END %]
</dl>
[% END %]
</div>
[% USE Asset %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
-<title>Koha › Tools › Advanced editor shortcuts</title>
+<title>Koha › Administration › Advanced editor shortcuts</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
-<body id="adveditor_shortcuts" class="tools">
+<body id="adveditor_shortcuts" class="admin">
[% INCLUDE 'header.inc' %]
- [% INCLUDE 'cat-search.inc' %]
+ [% INCLUDE 'prefs-admin-search.inc' %]
+ [% PROCESS 'keyboard_shortcuts.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/tools/adveditorshortcuts.pl">Advanced editor shortcuts</a>
+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> ›
+ <a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Advanced editor shortcuts</a>
</div>
<div class="main container-fluid">
<li>Control key is "Ctrl"</li>
<li>Alt key is "Alt"</li>
<li>Shift is "Shift"</li>
- <li>If combing multiple keys they must be in specified order: Shift-Cmd-Ctrl-Alt</li>
+ <li>If combining multiple keys they must be in specified order: Shift-Cmd-Ctrl-Alt</li>
<li><a href="https://codemirror.net/doc/manual.html#keymaps">More documentation on defining key maps</a></li>
</ul>
- <form id="adveditor_shortcuts" method="post" action="/cgi-bin/koha/tools/adveditorshortcuts.pl">
+ <form id="adveditor_shortcuts" method="post" action="/cgi-bin/koha/admin/adveditorshortcuts.pl">
+ <fieldset>
<input type=hidden name="op" value="save" />
<table id="adv_editor_keyboard_shortcuts">
<tbody>
[% FOREACH shortcut IN shortcuts %]
<tr>
- <td><label for="shortcut_keys">[% shortcut.shortcut_desc | html %]</label></td>
+ <td><label for="shortcut_keys">[% PROCESS keyboard_shortcut_descriptions shortcut_name=shortcut.shortcut_name %]</label></td>
<td>
<input type="hidden" name="shortcut_name" value="[% shortcut.shortcut_name | html %]">
<input type="text" name="shortcut_keys" value="[% shortcut.shortcut_keys | html %]">
</tr>
[% END %]
</table>
- <input type="submit" value="Save shortcuts">
+ </fieldset>
+ </fieldset class="action"><input type="submit" value="Save shortcuts"></fieldset>
</form>
</main>
<div class="col-sm-2 col-sm-pull-10">
<aside>
- [% INCLUDE 'tools-menu.inc' %]
+ [% INCLUDE 'admin-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
</div>
[% INCLUDE 'header.inc' %]
+[% PROCESS 'keyboard_shortcuts.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a> › Editor</div>
</div>
<div id="shortcuts-contents" style="display: none">
-<a id="redefine_shortcuts" href="/cgi-bin/koha/tools/adveditorshortcuts.pl">Redefine shortcuts</a>
+<a id="redefine_shortcuts" href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Redefine shortcuts</a>
<table class="table table-condensed">
<thead>
<tr>
[% FOREACH shortcut IN shortcuts %]
<tr>
<td>[% shortcut.shortcut_keys | html %]</td>
- <td>[% shortcut.shortcut_desc | html %]</td>
+ <td>[% PROCESS keyboard_shortcut_descriptions shortcut_name=shortcut.shortcut_name %]</td>
</tr>
[% END %]
<tr>
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright 2019 Koha Development team
+#
+# 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, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+use Test::More tests => 4;
+
+use Koha::Database;
+
+use t::lib::TestBuilder;
+
+BEGIN {
+ use_ok('Koha::KeyboardShortcuts');
+}
+
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
+my $builder = t::lib::TestBuilder->new;
+my $nb_of_shortcuts = Koha::KeyboardShortcuts->search->count;
+
+my $shortcut_hash = {
+ shortcut_name => 'this_cut',
+ shortcut_keys => 'Ctrl-D',
+ shortcut_desc => 'DOES_THE_THING'
+};
+
+my $new_shortcut = Koha::KeyboardShortcut->new($shortcut_hash)->store;
+is( Koha::KeyboardShortcuts->count, $nb_of_shortcuts + 1, 'Adding a new shortcut increases count');
+
+my $found_shortcut = Koha::KeyboardShortcuts->find( "this_cut" );
+is_deeply( $found_shortcut->unblessed, $shortcut_hash, 'We find the right object');
+
+$found_shortcut->delete;
+is( Koha::KeyboardShortcuts->count, $nb_of_shortcuts, 'Deleting a new shortcut works');
+
+$schema->storage->txn_rollback;