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

(-)a/Koha/KeyboardShortcut.pm (+44 lines)
Line 0 Link Here
1
package Koha::KeyboardShortcut;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::KeyboardShortcut - Koha KeyboardShortcut Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'KeyboardShortcut';
42
}
43
44
1;
(-)a/Koha/KeyboardShortcuts.pm (+50 lines)
Line 0 Link Here
1
package Koha::KeyboardShortcuts;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::KeyboardShortcut;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::KeyboardShortcuts - Koha KeyboardShortcut Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'KeyboardShortcut';
44
}
45
46
sub object_class {
47
    return 'Koha::KeyboardShortcut';
48
}
49
50
1;
(-)a/cataloguing/editor.pl (+8 lines)
Lines 30-35 use C4::Output; Link Here
30
use DBIx::Class::ResultClass::HashRefInflator;
30
use DBIx::Class::ResultClass::HashRefInflator;
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::MarcSubfieldStructures;
32
use Koha::MarcSubfieldStructures;
33
use Koha::KeyboardShortcuts;
33
34
34
my $input = CGI->new;
35
my $input = CGI->new;
35
36
Lines 45-50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
45
46
46
my $schema = Koha::Database->new->schema;
47
my $schema = Koha::Database->new->schema;
47
48
49
my @keyboard_shortcuts = Koha::KeyboardShortcuts->search();
50
51
# Keyboard shortcuts
52
$template->param(
53
    shortcuts => \@keyboard_shortcuts,
54
);
55
48
# Available import batches
56
# Available import batches
49
$template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search(
57
$template->{VARS}->{editable_batches} = [ $schema->resultset('ImportBatch')->search(
50
    {
58
    {
(-)a/installer/data/mysql/atomicupdate/add_keyboard_shortcuts.perl (+31 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
            id int(11) NOT NULL AUTO_INCREMENT,
7
            shortcut_name varchar(80) NOT NULL,
8
            shortcut_keys varchar(80) NOT NULL,
9
            shortcut_desc varchar(200) NOT NULL,
10
            PRIMARY KEY (id)
11
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;|
12
        );
13
    }
14
    $dbh->do(q|
15
        INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys, shortcut_desc) VALUES
16
        ("insert_copyright","Alt-C","Insert copyright symbol (©)"),
17
        ("insert_copyright_sound","Alt-P","Insert copyright symbol (℗) (sound recordings)"),
18
        ("insert_delimiter","Ctrl-D","Insert delimiter (‡)"),
19
        ("subfield_help","Ctrl-H","Get help on current subfield"),
20
        ("link_authorities","Ctrl-Shift-L","Link field to authorities"),
21
        ("delete_field","Ctrl-X","Delete current field"),
22
        ("delete_subfield","Ctrl-Shift-X","Delete current subfield"),
23
        ("new_line","Enter","New field on next line"),
24
        ("line_break","Shift-Enter","Insert line break"),
25
        ("next_position","Tab","Move to next position"),
26
        ("prev_position","Shift-Tab","Move to previous position")
27
        ;|
28
    );
29
    SetVersion( $DBversion );
30
    print "Upgrade to $DBversion done (Bug XXXXX - Add keyboard_shortcuts table)\n";
31
}
(-)a/installer/data/mysql/kohastructure.sql (+9 lines)
Lines 4208-4213 CREATE TABLE `oauth_access_tokens` ( Link Here
4208
    PRIMARY KEY (`access_token`)
4208
    PRIMARY KEY (`access_token`)
4209
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4209
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4210
4210
4211
DROP TABLE IF EXISTS `keyboard_shortcuts`;
4212
CREATE TABLE keyboard_shortcuts (
4213
id int(11) NOT NULL AUTO_INCREMENT,
4214
shortcut_name varchar(80) NOT NULL,
4215
shortcut_keys varchar(80) NOT NULL,
4216
shortcut_desc varchar(200) NOT NULL,
4217
PRIMARY KEY (id)
4218
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4219
4211
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
4220
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
4212
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
4221
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
4213
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
4222
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js (-25 / +23 lines)
Lines 135-170 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
135
            return [];
135
            return [];
136
        }
136
        }
137
    }
137
    }
138
    var _editorKeys = {};
138
139
139
    var _editorKeys = {
140
    _editorKeys[insert_copyright] =  function( cm ) {
140
        'Alt-C': function( cm ) {
141
            cm.replaceRange( '©', cm.getCursor() );
141
            cm.replaceRange( '©', cm.getCursor() );
142
        },
142
        }
143
143
144
        'Alt-P': function( cm ) {
144
    _editorKeys[insert_copyright_sound] = function( cm ) {
145
            cm.replaceRange( '℗', cm.getCursor() );
145
            cm.replaceRange( '℗', cm.getCursor() );
146
        },
146
        }
147
147
148
        Enter: function( cm ) {
148
    _editorKeys[new_line] = function( cm ) {
149
            var cursor = cm.getCursor();
149
            var cursor = cm.getCursor();
150
            cm.replaceRange( '\n', { line: cursor.line }, null, 'marcAware' );
150
            cm.replaceRange( '\n', { line: cursor.line }, null, 'marcAware' );
151
            cm.setCursor( { line: cursor.line + 1, ch: 0 } );
151
            cm.setCursor( { line: cursor.line + 1, ch: 0 } );
152
        },
152
        }
153
153
154
        'Shift-Enter': function( cm ) {
154
    _editorKeys[line_break] =  function( cm ) {
155
            var cur = cm.getCursor();
155
            var cur = cm.getCursor();
156
156
157
            cm.replaceRange( "\n", cur, null );
157
            cm.replaceRange( "\n", cur, null );
158
        },
158
        }
159
159
160
        'Ctrl-X': function( cm ) {
160
    _editorKeys[delete_field] =  function( cm ) {
161
            // Delete line (or cut)
161
            // Delete line (or cut)
162
            if ( cm.somethingSelected() ) return true;
162
            if ( cm.somethingSelected() ) return true;
163
163
164
            cm.execCommand('deleteLine');
164
            cm.execCommand('deleteLine');
165
        },
165
        }
166
166
167
        'Shift-Ctrl-L': function( cm ) {
167
    _editorKeys[link_authorities] =  function( cm ) {
168
            // Launch the auth search popup
168
            // Launch the auth search popup
169
            var field = cm.marceditor.getCurrentField();
169
            var field = cm.marceditor.getCurrentField();
170
170
Lines 186-203 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
186
            }
186
            }
187
            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');
187
            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');
188
188
189
        },
189
        }
190
190
191
        'Shift-Ctrl-X': function( cm ) {
191
    _editorKeys[delete_subfield] = function( cm ) {
192
            // Delete subfield
192
            // Delete subfield
193
            var field = cm.marceditor.getCurrentField();
193
            var field = cm.marceditor.getCurrentField();
194
            if ( !field ) return;
194
            if ( !field ) return;
195
195
196
            var subfield = field.getSubfieldAt( cm.getCursor().ch );
196
            var subfield = field.getSubfieldAt( cm.getCursor().ch );
197
            if ( subfield ) subfield.delete();
197
            if ( subfield ) subfield.delete();
198
        },
198
        }
199
199
200
        Tab: function( cm ) {
200
     _editorKeys[next_position] =  function( cm ) {
201
            // Move through parts of tag/fixed fields
201
            // Move through parts of tag/fixed fields
202
            var positions = getTabPositions( cm.marceditor );
202
            var positions = getTabPositions( cm.marceditor );
203
            var cur = cm.getCursor();
203
            var cur = cm.getCursor();
Lines 210-218 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
210
            }
210
            }
211
211
212
            cm.setCursor( { line: cur.line + 1, ch: 0 } );
212
            cm.setCursor( { line: cur.line + 1, ch: 0 } );
213
        },
213
        }
214
214
215
        'Shift-Tab': function( cm ) {
215
    _editorKeys[prev_position] = function( cm ) {
216
            // Move backwards through parts of tag/fixed fields
216
            // Move backwards through parts of tag/fixed fields
217
            var positions = getTabPositions( cm.marceditor );
217
            var positions = getTabPositions( cm.marceditor );
218
            var cur = cm.getCursor();
218
            var cur = cm.getCursor();
Lines 233-247 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
233
            } else {
233
            } else {
234
                cm.setCursor( { line: cur.line - 1, ch: 0 } );
234
                cm.setCursor( { line: cur.line - 1, ch: 0 } );
235
            }
235
            }
236
        },
236
        }
237
237
238
        'Ctrl-D': function( cm ) {
238
    _editorKeys[insert_delimiter] = function(cm){
239
            // Insert subfield delimiter
239
        var cur = cm.getCursor();
240
            var cur = cm.getCursor();
241
240
242
            cm.replaceRange( "‡", cur, null );
241
        cm.replaceRange( "‡", cur, null );
243
        },
242
    }
244
    };
245
243
246
    // The objects below are part of a field/subfield manipulation API, accessed through the base
244
    // The objects below are part of a field/subfield manipulation API, accessed through the base
247
    // editor object.
245
    // editor object.
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (+3 lines)
Lines 4-9 Link Here
4
[% Asset.js("lib/koha/cateditor/marc-mode.js") | $raw %]
4
[% Asset.js("lib/koha/cateditor/marc-mode.js") | $raw %]
5
[% Asset.js("lib/require.js") | $raw %]
5
[% Asset.js("lib/require.js") | $raw %]
6
<script>
6
<script>
7
[% FOREACH shortcut IN shortcuts -%]
8
    var [% shortcut.shortcut_name | html %] = "[% shortcut.shortcut_keys | html %]";
9
[% END %]
7
    var authInfo = {
10
    var authInfo = {
8
        [%- FOREACH authtag = authtags -%]
11
        [%- FOREACH authtag = authtags -%]
9
            [% authtag.tagfield | html %]: {
12
            [% authtag.tagfield | html %]: {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt (-45 / +8 lines)
Lines 255-260 Link Here
255
</div>
255
</div>
256
256
257
<div id="shortcuts-contents" style="display: none">
257
<div id="shortcuts-contents" style="display: none">
258
<a id="redefine_shortcuts" href="/cgi-bin/koha/tools/adveditorshortcuts.pl">Redefine shortcuts</a>
258
<table class="table table-condensed">
259
<table class="table table-condensed">
259
    <thead>
260
    <thead>
260
        <tr>
261
        <tr>
Lines 263-315 Link Here
263
        </tr>
264
        </tr>
264
    </thead>
265
    </thead>
265
    <tbody>
266
    <tbody>
266
        <tr>
267
        [% FOREACH shortcut IN shortcuts %]
267
            <td>Alt-C</td>
268
            <tr>
268
            <td>Insert copyright symbol (©)</td>
269
                <td>[% shortcut.shortcut_keys %]</td>
269
        </tr>
270
                <td>[% shortcut.shortcut_desc %]</td>
270
        <tr>
271
            </tr>
271
            <td>Alt-P</td>
272
        [% END %]
272
            <td>Insert copyright symbol (℗) (sound recordings)</td>
273
        </tr>
274
        <tr>
275
            <td>Ctrl-D</td>
276
            <td>Insert delimiter (‡)</td>
277
        </tr>
278
        <tr>
279
            <td>Ctrl-H</td>
280
            <td>Get help on current subfield</td>
281
        </tr>
282
        <tr>
283
            <td>Ctrl-Shift-L</td>
284
            <td>Link field to authorities</td>
285
        </tr>
286
        <tr>
273
        <tr>
287
            <td>Ctrl-S</td>
274
            <td>Ctrl-S</td>
288
            <td>Save record</td>
275
            <td>Save record (cannot be remapped)</td>
289
        </tr>
290
        <tr>
291
            <td>Ctrl-X</td>
292
            <td>Delete current field</td>
293
        </tr>
294
        <tr>
295
            <td>Ctrl-Shift-X</td>
296
            <td>Delete current subfield</td>
297
        </tr>
298
        <tr>
299
            <td>Enter</td>
300
            <td>New field on next line</td>
301
        </tr>
302
        <tr>
303
            <td>Shift-Enter</td>
304
            <td>Insert line break</td>
305
        </tr>
306
        <tr>
307
            <td>Tab</td>
308
            <td>Move to next position</td>
309
        </tr>
310
        <tr>
311
            <td>Shift-Tab</td>
312
            <td>Move to previous position</td>
313
        </tr>
276
        </tr>
314
    </tbody>
277
    </tbody>
315
</table>
278
</table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/adveditorshortcuts.tt (-1 / +61 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Tools &rsaquo; Advanced editor shortcuts</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
8
<body id="adveditor_shortcuts" class="tools">
9
    [% INCLUDE 'header.inc' %]
10
    [% INCLUDE 'cat-search.inc' %]
11
12
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
13
&rsaquo; <a href="/cgi-bin/koha/reviews/adveditorshortcuts.pl">Advanced editor shortcuts</a></div>
14
15
<div id="doc3" class="yui-t2">
16
    <div id="bd">
17
        <div id="yui-main">
18
            <div class="yui-b">
19
                <h1>Advanced editor keyboard shortcuts</h1>
20
                <p>Separate keys using a hyphen "-"<p>
21
                <p>Control key is "Ctrl"</p>
22
                <p>Alt key is "Alt"</p>
23
                <p>Shift is "Shift"</p>
24
                <p>More docmentation on defining key maps can be found <a href="https://codemirror.net/doc/manual.html#keymaps">here</a></p>
25
26
                <form id="adveditor_shortcuts" method="post" action="/cgi-bin/koha/tools/adveditorshortcuts.pl">
27
                    <input type=hidden name="op" value="save" />
28
29
                    <table id="adv_editor_keyboard_shortcuts">
30
                        <thead>
31
                            <th>Description</th>
32
                            <th>Shortcut keys</th>
33
                        </thead>
34
                        <tbody>
35
                           [% FOREACH shortcut IN shortcuts %]
36
                        <tr>
37
                            <td><label for="shortcut_keys">[% shortcut.shortcut_desc %]</label></td>
38
                            <td>
39
                                <input type="hidden" name="shortcut_name" value="[% shortcut.shortcut_name %]">
40
                                <input type="text" name="shortcut_keys" value="[% shortcut.shortcut_keys %]">
41
                           </td>
42
                        </tr>
43
                   [% END %]
44
                   </table>
45
                   <input type="submit" value="Save shortcuts">
46
               </form>
47
48
           </div> <!-- yui-b -->
49
        </div> <!-- yui-main -->
50
51
<div class="yui-b noprint">
52
[% INCLUDE 'tools-menu.inc' %]
53
</div>
54
    </div> <!-- bd -->
55
</div> <!-- doc3 -->
56
57
[% MACRO jsinclude BLOCK %]
58
    [% Asset.js("js/tools-menu.js") | $raw %]
59
[% END %]
60
61
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 21411