Bug 21411: Address QA concerns

Move to admin
Add a permission
Remove descriptions from table
Clean up template

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2019-04-23 11:17:27 +00:00
parent 164caa7eeb
commit 581d2edd44
14 changed files with 150 additions and 58 deletions

View File

@ -35,7 +35,7 @@ Koha::KeyboardShortcuts - Koha KeyboardShortcut Object set class
=cut
=head3 type
=head3 _type (internal)
=cut
@ -43,6 +43,10 @@ sub _type {
return 'KeyboardShortcut';
}
=head3 object_class (internal)
=cut
sub object_class {
return 'Koha::KeyboardShortcut';
}

View File

@ -47,11 +47,11 @@ my $input = new CGI;
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,
}
);

View File

@ -0,0 +1,35 @@
$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";
}

View File

@ -1,30 +0,0 @@
$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";
}

View File

@ -4332,7 +4332,6 @@ DROP TABLE IF EXISTS `keyboard_shortcuts`;
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;

View File

@ -21,15 +21,15 @@
-- 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");

View File

@ -32,6 +32,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES
( 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'),

View File

@ -138,6 +138,9 @@
[% 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>

View File

@ -0,0 +1,15 @@
[%- 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 -%]

View File

@ -241,6 +241,11 @@
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

View File

@ -211,6 +211,10 @@
<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>

View File

@ -2,17 +2,18 @@
[% USE Asset %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Advanced editor shortcuts</title>
<title>Koha &rsaquo; Administration &rsaquo; 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> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/tools/adveditorshortcuts.pl">Advanced editor shortcuts</a>
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
<a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Advanced editor shortcuts</a>
</div>
<div class="main container-fluid">
@ -25,11 +26,12 @@
<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">
@ -40,7 +42,7 @@
<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 %]">
@ -48,7 +50,8 @@
</tr>
[% END %]
</table>
<input type="submit" value="Save shortcuts">
</fieldset>
</fieldset class="action"><input type="submit" value="Save shortcuts"></fieldset>
</form>
</main>
@ -56,7 +59,7 @@
<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 -->

View File

@ -16,6 +16,7 @@
</div>
[% INCLUDE 'header.inc' %]
[% PROCESS 'keyboard_shortcuts.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a> &rsaquo; Editor</div>
@ -268,7 +269,7 @@
</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>
@ -280,7 +281,7 @@
[% 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>

View File

@ -0,0 +1,52 @@
#!/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;