View | Details | Raw Unified | Return to bug 21411
Collapse All | Expand All

(-)a/Koha/KeyboardShortcuts.pm (-1 / +5 lines)
Lines 35-41 Koha::KeyboardShortcuts - Koha KeyboardShortcut Object set class Link Here
35
35
36
=cut
36
=cut
37
37
38
=head3 type
38
=head3 _type (internal)
39
39
40
=cut
40
=cut
41
41
Lines 43-48 sub _type { Link Here
43
    return 'KeyboardShortcut';
43
    return 'KeyboardShortcut';
44
}
44
}
45
45
46
=head3 object_class (internal)
47
48
=cut
49
46
sub object_class {
50
sub object_class {
47
    return 'Koha::KeyboardShortcut';
51
    return 'Koha::KeyboardShortcut';
48
}
52
}
(-)a/tools/adveditorshortcuts.pl (-2 / +2 lines)
Lines 47-57 my $input = new CGI; Link Here
47
my $op               = $input->param('op') || 'list';
47
my $op               = $input->param('op') || 'list';
48
48
49
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
49
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
50
    {   template_name   => "tools/adveditorshortcuts.tt",
50
    {   template_name   => "admin/adveditorshortcuts.tt",
51
        query           => $input,
51
        query           => $input,
52
        type            => "intranet",
52
        type            => "intranet",
53
        authnotrequired => 1,
53
        authnotrequired => 1,
54
        flagsrequired   => {},
54
        flagsrequired   => { parameters => 'manage_keyboard_shortcuts' },
55
        debug           => 1,
55
        debug           => 1,
56
    }
56
    }
57
);
57
);
(-)a/installer/data/mysql/atomicupdate/Bug_21411_add_keyboard_shortcuts.perl (+35 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    unless ( TableExists( 'keyboard_shortcuts' ) ) {
4
        $dbh->do(q|
5
            CREATE TABLE keyboard_shortcuts (
6
            shortcut_name varchar(80) NOT NULL,
7
            shortcut_keys varchar(80) NOT NULL,
8
            PRIMARY KEY (shortcut_name)
9
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;|
10
        );
11
    }
12
    $dbh->do(q|
13
        INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
14
        ("insert_copyright","Alt-C"),
15
        ("insert_copyright_sound","Alt-P"),
16
        ("insert_delimiter","Ctrl-D"),
17
        ("subfield_help","Ctrl-H"),
18
        ("link_authorities","Shift-Ctrl-L"),
19
        ("delete_field","Ctrl-X"),
20
        ("delete_subfield","Shift-Ctrl-X"),
21
        ("new_line","Enter"),
22
        ("line_break","Shift-Enter"),
23
        ("next_position","Tab"),
24
        ("prev_position","Shift-Tab")
25
        ;|
26
    );
27
    $dbh->do(q|
28
        INSERT IGNORE permissions (module_bit, code, description)
29
        VALUES
30
        (3,'manage_keyboard_shortcuts','Manage keyboard shortcuts for advanced cataloging editor')
31
        ;|
32
    );
33
    SetVersion( $DBversion );
34
    print "Upgrade to $DBversion done (Bug XXXXX - Add keyboard_shortcuts table)\n";
35
}
(-)a/installer/data/mysql/atomicupdate/add_keyboard_shortcuts.perl (-30 lines)
Lines 1-30 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    unless ( TableExists( 'keyboard_shortcuts' ) ) {
4
        $dbh->do(q|
5
            CREATE TABLE keyboard_shortcuts (
6
            shortcut_name varchar(80) NOT NULL,
7
            shortcut_keys varchar(80) NOT NULL,
8
            shortcut_desc varchar(200) NOT NULL,
9
            PRIMARY KEY (shortcut_name)
10
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;|
11
        );
12
    }
13
    $dbh->do(q|
14
        INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys, shortcut_desc) VALUES
15
        ("insert_copyright","Alt-C","Insert copyright symbol (©)"),
16
        ("insert_copyright_sound","Alt-P","Insert copyright symbol (℗) (sound recordings)"),
17
        ("insert_delimiter","Ctrl-D","Insert delimiter (‡)"),
18
        ("subfield_help","Ctrl-H","Get help on current subfield"),
19
        ("link_authorities","Shift-Ctrl-L","Link field to authorities"),
20
        ("delete_field","Ctrl-X","Delete current field"),
21
        ("delete_subfield","Shift-Ctrl-X","Delete current subfield"),
22
        ("new_line","Enter","New field on next line"),
23
        ("line_break","Shift-Enter","Insert line break"),
24
        ("next_position","Tab","Move to next position"),
25
        ("prev_position","Shift-Tab","Move to previous position")
26
        ;|
27
    );
28
    SetVersion( $DBversion );
29
    print "Upgrade to $DBversion done (Bug XXXXX - Add keyboard_shortcuts table)\n";
30
}
(-)a/installer/data/mysql/kohastructure.sql (-1 lines)
Lines 4332-4338 DROP TABLE IF EXISTS `keyboard_shortcuts`; Link Here
4332
CREATE TABLE keyboard_shortcuts (
4332
CREATE TABLE keyboard_shortcuts (
4333
shortcut_name varchar(80) NOT NULL,
4333
shortcut_name varchar(80) NOT NULL,
4334
shortcut_keys varchar(80) NOT NULL,
4334
shortcut_keys varchar(80) NOT NULL,
4335
shortcut_desc varchar(200) NOT NULL,
4336
PRIMARY KEY (shortcut_name)
4335
PRIMARY KEY (shortcut_name)
4337
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4336
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4338
4337
(-)a/installer/data/mysql/en/mandatory/keyboard_shortcuts.sql (-12 / +12 lines)
Lines 21-35 Link Here
21
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
22
23
-- keyboard shortcuts
23
-- keyboard shortcuts
24
INSERT INTO keyboard_shortcuts (shortcut_name, shortcut_keys, shortcut_desc) VALUES
24
INSERT INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
25
    ("insert_copyright","Alt-C","Insert copyright symbol (©)"),
25
    ("insert_copyright","Alt-C"),
26
    ("insert_copyright_sound","Alt-P","Insert copyright symbol (℗) (sound recordings)"),
26
    ("insert_copyright_sound","Alt-P"),
27
    ("insert_delimiter","Ctrl-D","Insert delimiter (‡)"),
27
    ("insert_delimiter","Ctrl-D"),
28
    ("subfield_help","Ctrl-H","Get help on current subfield"),
28
    ("subfield_help","Ctrl-H"),
29
    ("link_authorities","Shift-Ctrl-L","Link field to authorities"),
29
    ("link_authorities","Shift-Ctrl-L"),
30
    ("delete_field","Ctrl-X","Delete current field"),
30
    ("delete_field","Ctrl-X"),
31
    ("delete_subfield","Shift-Ctrl-X","Delete current subfield"),
31
    ("delete_subfield","Shift-Ctrl-X"),
32
    ("new_line","Enter","New field on next line"),
32
    ("new_line","Enter"),
33
    ("line_break","Shift-Enter","Insert line break"),
33
    ("line_break","Shift-Enter"),
34
    ("next_position","Tab","Move to next position"),
34
    ("next_position","Tab"),
35
    ("prev_position","Shift-Tab","Move to previous position");
35
    ("prev_position","Shift-Tab");
(-)a/installer/data/mysql/userpermissions.sql (+1 lines)
Lines 32-37 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
32
   ( 3, 'manage_usage_stats', 'Manage usage statistics settings'),
32
   ( 3, 'manage_usage_stats', 'Manage usage statistics settings'),
33
   ( 3, 'manage_mana', 'Manage Mana KB content sharing'),
33
   ( 3, 'manage_mana', 'Manage Mana KB content sharing'),
34
   ( 3, 'manage_additional_fields', 'Add, edit, or delete additional custom fields for baskets or subscriptions (also requires order_manage or edit_subscription permissions)'),
34
   ( 3, 'manage_additional_fields', 'Add, edit, or delete additional custom fields for baskets or subscriptions (also requires order_manage or edit_subscription permissions)'),
35
   ( 3, 'manage_keyboard_shortcuts', 'Manage keyboard shortcuts for the advanced cataloging editor'),
35
   ( 4, 'edit_borrowers', 'Add, modify and view patron information'),
36
   ( 4, 'edit_borrowers', 'Add, modify and view patron information'),
36
   ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
37
   ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
37
   ( 6, 'place_holds', 'Place holds for patrons'),
38
   ( 6, 'place_holds', 'Place holds for patrons'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (+3 lines)
Lines 138-143 Link Here
138
            [% IF ( CAN_user_parameters_manage_additional_fields ) %]
138
            [% IF ( CAN_user_parameters_manage_additional_fields ) %]
139
                <li><a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a></li>
139
                <li><a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a></li>
140
            [% END %]
140
            [% END %]
141
            [% IF ( CAN_user_parameters_manage_keyboard_shortcuts ) %]
142
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
143
            [% END %]
141
        </ul>
144
        </ul>
142
    [% END %]
145
    [% END %]
143
</div>
146
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/keyboard_shortcuts.inc (+15 lines)
Line 0 Link Here
1
[%- BLOCK keyboard_shortcut_descriptions -%]
2
    [% SWITCH shortcut_name %]
3
    [%- CASE 'insert_copyright' -%]<span>Insert copyright symbol (©)</span>
4
    [%- CASE 'insert_copyright_sound' -%]<span>Insert copyright symbol (℗) (sound recordings)</span>
5
    [%- CASE 'insert_delimiter' -%]<span>Insert delimiter (‡)</span>
6
    [%- CASE 'subfield_help' -%]<span>Get help on current subfield</span>
7
    [%- CASE 'link_authorities' -%]<span>Link field to authorities</span>
8
    [%- CASE 'delete_field' -%]<span>Delete current field</span>
9
    [%- CASE 'delete_subfield' -%]<span>Delete current subfield</span>
10
    [%- CASE 'new_line' -%]<span>New field on next line</span>
11
    [%- CASE 'line_break' -%]<span>Insert line break</span>
12
    [%- CASE 'next_position' -%]<span>Move to next position</span>
13
    [%- CASE 'prev_position' -%]<span>Move to previous position</span>
14
    [%- END -%]
15
[%- END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+5 lines)
Lines 241-246 Link Here
241
            Manage Mana KB content sharing
241
            Manage Mana KB content sharing
242
        </span>
242
        </span>
243
        <span class="permissioncode">([% name | html %])</span>
243
        <span class="permissioncode">([% name | html %])</span>
244
    [%- CASE 'manage_keyboard_shortcuts' -%]
245
        <span class="sub_permission manage_keyboard_shortcuts_subpermission">
246
            Manage keyboard shortcuts for the advanced cataloging editor
247
        </span>
248
        <span class="permissioncode">([% name | html %])</span>
244
    [%- CASE 'edit_borrowers' -%]
249
    [%- CASE 'edit_borrowers' -%]
245
        <span class="sub_permission edit_borrowers_subpermission">
250
        <span class="sub_permission edit_borrowers_subpermission">
246
            Add, modify and view patron information
251
            Add, modify and view patron information
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (+4 lines)
Lines 211-216 Link Here
211
                    <dt><a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a></dt>
211
                    <dt><a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a></dt>
212
                    <dd>Add additional fields to certain tables</dd>
212
                    <dd>Add additional fields to certain tables</dd>
213
                    [% END %]
213
                    [% END %]
214
                    [% IF ( CAN_user_parameters_manage_keyboard_shortcuts ) %]
215
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
216
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
217
                    [% END %]
214
                </dl>
218
                </dl>
215
            [% END %]
219
            [% END %]
216
            </div>
220
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/adveditorshortcuts.tt (-10 / +13 lines)
Lines 2-18 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Tools &rsaquo; Advanced editor shortcuts</title>
5
<title>Koha &rsaquo; Administration &rsaquo; Advanced editor shortcuts</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
7
</head>
8
<body id="adveditor_shortcuts" class="tools">
8
<body id="adveditor_shortcuts" class="admin">
9
    [% INCLUDE 'header.inc' %]
9
    [% INCLUDE 'header.inc' %]
10
    [% INCLUDE 'cat-search.inc' %]
10
    [% INCLUDE 'prefs-admin-search.inc' %]
11
    [% PROCESS 'keyboard_shortcuts.inc' %]
11
12
12
<div id="breadcrumbs">
13
<div id="breadcrumbs">
13
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
14
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
14
    <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
15
    <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
15
    <a href="/cgi-bin/koha/tools/adveditorshortcuts.pl">Advanced editor shortcuts</a>
16
    <a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Advanced editor shortcuts</a>
16
</div>
17
</div>
17
18
18
<div class="main container-fluid">
19
<div class="main container-fluid">
Lines 25-35 Link Here
25
                    <li>Control key is "Ctrl"</li>
26
                    <li>Control key is "Ctrl"</li>
26
                    <li>Alt key is "Alt"</li>
27
                    <li>Alt key is "Alt"</li>
27
                    <li>Shift is "Shift"</li>
28
                    <li>Shift is "Shift"</li>
28
                    <li>If combing multiple keys they must be in specified order: Shift-Cmd-Ctrl-Alt</li>
29
                    <li>If combining multiple keys they must be in specified order: Shift-Cmd-Ctrl-Alt</li>
29
                    <li><a href="https://codemirror.net/doc/manual.html#keymaps">More documentation on defining key maps</a></li>
30
                    <li><a href="https://codemirror.net/doc/manual.html#keymaps">More documentation on defining key maps</a></li>
30
                </ul>
31
                </ul>
31
32
32
                <form id="adveditor_shortcuts" method="post" action="/cgi-bin/koha/tools/adveditorshortcuts.pl">
33
                <form id="adveditor_shortcuts" method="post" action="/cgi-bin/koha/admin/adveditorshortcuts.pl">
34
                    <fieldset>
33
                    <input type=hidden name="op" value="save" />
35
                    <input type=hidden name="op" value="save" />
34
36
35
                    <table id="adv_editor_keyboard_shortcuts">
37
                    <table id="adv_editor_keyboard_shortcuts">
Lines 40-46 Link Here
40
                        <tbody>
42
                        <tbody>
41
                           [% FOREACH shortcut IN shortcuts %]
43
                           [% FOREACH shortcut IN shortcuts %]
42
                        <tr>
44
                        <tr>
43
                            <td><label for="shortcut_keys">[% shortcut.shortcut_desc | html %]</label></td>
45
                            <td><label for="shortcut_keys">[% PROCESS keyboard_shortcut_descriptions shortcut_name=shortcut.shortcut_name %]</label></td>
44
                            <td>
46
                            <td>
45
                                <input type="hidden" name="shortcut_name" value="[% shortcut.shortcut_name | html %]">
47
                                <input type="hidden" name="shortcut_name" value="[% shortcut.shortcut_name | html %]">
46
                                <input type="text" name="shortcut_keys" value="[% shortcut.shortcut_keys | html %]">
48
                                <input type="text" name="shortcut_keys" value="[% shortcut.shortcut_keys | html %]">
Lines 48-54 Link Here
48
                        </tr>
50
                        </tr>
49
                   [% END %]
51
                   [% END %]
50
                   </table>
52
                   </table>
51
                   <input type="submit" value="Save shortcuts">
53
                   </fieldset>
54
                   </fieldset class="action"><input type="submit" value="Save shortcuts"></fieldset>
52
               </form>
55
               </form>
53
56
54
           </main>
57
           </main>
Lines 56-62 Link Here
56
59
57
        <div class="col-sm-2 col-sm-pull-10">
60
        <div class="col-sm-2 col-sm-pull-10">
58
            <aside>
61
            <aside>
59
                [% INCLUDE 'tools-menu.inc' %]
62
                [% INCLUDE 'admin-menu.inc' %]
60
            </aside>
63
            </aside>
61
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
64
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
62
    </div> <!-- /.row -->
65
    </div> <!-- /.row -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt (-2 / +3 lines)
Lines 16-21 Link Here
16
   </div>
16
   </div>
17
17
18
[% INCLUDE 'header.inc' %]
18
[% INCLUDE 'header.inc' %]
19
[% PROCESS 'keyboard_shortcuts.inc' %]
19
20
20
<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>
21
<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>
21
22
Lines 268-274 Link Here
268
</div>
269
</div>
269
270
270
<div id="shortcuts-contents" style="display: none">
271
<div id="shortcuts-contents" style="display: none">
271
<a id="redefine_shortcuts" href="/cgi-bin/koha/tools/adveditorshortcuts.pl">Redefine shortcuts</a>
272
<a id="redefine_shortcuts" href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Redefine shortcuts</a>
272
<table class="table table-condensed">
273
<table class="table table-condensed">
273
    <thead>
274
    <thead>
274
        <tr>
275
        <tr>
Lines 280-286 Link Here
280
        [% FOREACH shortcut IN shortcuts %]
281
        [% FOREACH shortcut IN shortcuts %]
281
            <tr>
282
            <tr>
282
                <td>[% shortcut.shortcut_keys | html %]</td>
283
                <td>[% shortcut.shortcut_keys | html %]</td>
283
                <td>[% shortcut.shortcut_desc | html %]</td>
284
                <td>[% PROCESS keyboard_shortcut_descriptions shortcut_name=shortcut.shortcut_name %]</td>
284
            </tr>
285
            </tr>
285
        [% END %]
286
        [% END %]
286
        <tr>
287
        <tr>
(-)a/t/db_dependent/Koha/KeyboardShortcuts.t (-1 / +52 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2019 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use Test::More tests => 4;
22
23
use Koha::Database;
24
25
use t::lib::TestBuilder;
26
27
BEGIN {
28
    use_ok('Koha::KeyboardShortcuts');
29
}
30
31
my $schema = Koha::Database->new->schema;
32
$schema->storage->txn_begin;
33
34
my $builder = t::lib::TestBuilder->new;
35
my $nb_of_shortcuts = Koha::KeyboardShortcuts->search->count;
36
37
my $shortcut_hash = {
38
    shortcut_name => 'this_cut',
39
    shortcut_keys => 'Ctrl-D',
40
    shortcut_desc => 'DOES_THE_THING'
41
};
42
43
my $new_shortcut = Koha::KeyboardShortcut->new($shortcut_hash)->store;
44
is( Koha::KeyboardShortcuts->count, $nb_of_shortcuts + 1, 'Adding a new shortcut increases count');
45
46
my $found_shortcut = Koha::KeyboardShortcuts->find( "this_cut" );
47
is_deeply( $found_shortcut->unblessed, $shortcut_hash, 'We find the right object');
48
49
$found_shortcut->delete;
50
is( Koha::KeyboardShortcuts->count, $nb_of_shortcuts, 'Deleting a new shortcut works');
51
52
$schema->storage->txn_rollback;

Return to bug 21411