From ccbdcf166f80df887dfcf02d1fbedb85e364a0e9 Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Mon, 10 Feb 2020 08:18:03 -0600 Subject: [PATCH] LP#1862235 - Create MARC Record - Keyboard workflow enhancements LP#1862235 - Create MARC Record - Global Keyboard Shortcut Added ctrl+f3 to launch the create MARC record interface. Signed-off-by: Josh Stompro LP#1862235 - Create MARC Record - Focus on template on load Focus on the template selector dropdown when interface loads. This removes the need to use the mouse, and speeds up using the interface. Pressing tab, then enter will submit the form with the default template selected. If the template needs to be changed, then pressing the first letter of the template will switch between the different options. This adds a directive named autoFocus to staff/cat/catalog/app.js, so adding "auto-focus" to an element will cause that element to have focus on load. Signed-off-by: Josh Stompro LP#1862235 - Set unique page title for create marc record. Add an egCore string for page title translation, and set page title for Create New MARC Record. Signed-off-by: Josh Stompro LP#1862235 - Create MARC Record - focus on item add and call number This change sets the focus on the "Add Item" checkbox when the marc editor is opened with fast item add enabled. This allows the user to just press space to enable Add item. When the add item checkbox is enabled, the focus is moved to the call number field. This adds a directive to app.js called focusOnShow that makes it easy to mark an element to have focus when it becomes visible when using ng-show. I had to add in a bit of redundancy in t_marcedit.tt2, the Add Item checkbox needs to have it's own ng-show directive for the focus-on-show to work. Signed-off-by: Josh Stompro LP#1862235 - Create MARC Record - Hide help button for flat editor The help button only works for the non flat editor, so show it only when flat editor isn't in use. Signed-off-by: Josh Stompro LP#1862235 - Create MARC Record - Flat Editor - Keyboard Shortcut for Saving Adds ctrl+s as a keyboard shortcut for saving the marc record while in the flat text editor. Signed-off-by: Josh Stompro LP#1862235 - Create MARC Record - Non-Flat Editor - Keyboard Shortcuts Added the following shortcuts to the marc editor keyboard shortcuts. Ctrl+s for save, Ctrl+l for validate, Ctrl+? for toggle help Signed-off-by: Josh Stompro LP#1862235 - Create MARC Record - Jump to Flat Editor - Keyboard Shortcut Added ctrl+e to jump to the flat editor textarea. Signed-off-by: Josh Stompro --- Open-ILS/src/templates/staff/cat/catalog/index.tt2 | 4 ++ .../src/templates/staff/cat/catalog/t_new_bib.tt2 | 2 +- .../src/templates/staff/cat/share/t_marcedit.tt2 | 9 ++-- Open-ILS/src/templates/staff/navbar.tt2 | 4 +- .../web/js/ui/default/staff/cat/catalog/app.js | 41 ++++++++++++++++++ .../js/ui/default/staff/cat/services/marcedit.js | 48 ++++++++++++++++++++-- 6 files changed, 100 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/catalog/index.tt2 b/Open-ILS/src/templates/staff/cat/catalog/index.tt2 index be572de284..7bac1a16e6 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/index.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/index.tt2 @@ -64,6 +64,10 @@ s.SERIALS_ISSUANCE_SUCCESS_SAVE = "[% l('Issuance saved') %]"; s.PAGE_TITLE_CATALOG_CONTEXT = "[% l('Catalog') %]"; s.PAGE_TITLE_BIB_DETAIL = "[% l('Bib [_1]', '{{record_id}}') %]"; + s.PAGE_TITLE_CREATE_MARC = "[% l('Create MARC Record') %]"; + + s.HOTKEY_SAVE_RECORD = "[% l('Save Record') %]"; + s.HOTKEY_FOCUS_EDITOR = "[% l('Jump to editor') %]"; }]) diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2 index c5ffa77129..e183b7e98e 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2 @@ -2,7 +2,7 @@
- +
diff --git a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 index 5ba785945b..de6aceb8c2 100644 --- a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 @@ -1,10 +1,10 @@
- +
- +
@@ -46,7 +46,7 @@ - +
@@ -157,6 +157,7 @@
  • [% l('Redo: CTRL-y') %]
  • [% l('Add Row: CTRL+Enter') %]
  • [% l('Insert Row: CTRL+Shift+Enter') %]
  • +
  • [% l('Save Record: CTRL+s') %]
  • @@ -165,6 +166,7 @@
  • [% l('Copy Current Row Below: CTRL+Down') %]
  • [% l('Add Subfield: CTRL+D or CTRL+I') %]
  • [% l('Remove Row: CTRL+Del') %]
  • +
  • [% l('Validate Headings: CTRL+l') %]
  • @@ -173,6 +175,7 @@
  • [% l('Create/Replace 006: Shift+F6') %]
  • [% l('Create/Replace 007: Shift+F7') %]
  • [% l('Create/Replace 008: Shift+F8') %]
  • +
  • [% l('Toggle Help: CTRL+?') %]
  • diff --git a/Open-ILS/src/templates/staff/navbar.tt2 b/Open-ILS/src/templates/staff/navbar.tt2 index 1028f42bb7..62b2f5224e 100644 --- a/Open-ILS/src/templates/staff/navbar.tt2 +++ b/Open-ILS/src/templates/staff/navbar.tt2 @@ -304,7 +304,9 @@
  • - + [% l('Create New MARC Record') %] diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index f05c363295..ad7f57e1c2 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -222,6 +222,8 @@ function($scope , $routeParams , $location , $window , $q , egCore) { $scope.template_name = ''; $scope.new_bib_id = 0; + egCore.strings.setPageTitle(egCore.strings.PAGE_TITLE_CREATE_MARC); + egCore.net.request( 'open-ils.cat', 'open-ils.cat.marc_template.types.retrieve' @@ -269,6 +271,45 @@ function($scope , $routeParams , $location , $window , $q , egCore) { }]) + +.directive('autoFocus', function($timeout) { + return { + restrict: 'AC', + link: function(_scope, _element) { + $timeout(function(){ + _element[0].focus(); + }, 0); + } + }; +}) + +.directive('focusOnShow', function($timeout) { + return { + restrict: 'A', + link: function($scope, $element, $attr) { + if ($attr.ngShow){ + $scope.$watch($attr.ngShow, function(newValue){ + if(newValue){ + $timeout(function(){ + $element[0].focus(); + }, 0); + } + }) + } + if ($attr.ngHide){ + $scope.$watch($attr.ngHide, function(newValue){ + if(!newValue){ + $timeout(function(){ + $element[0].focus(); + }, 0); + } + }) + } + + } + }; +}) + .controller('CatalogCtrl', ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast', 'egGridDataProvider','egHoldGridActions','egProgressDialog','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc', diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js index 09b46d0c2e..f34a87479b 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js @@ -697,9 +697,9 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) }, controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable', - 'egConfirmDialog','egAlertDialog','ngToast','egStrings', + 'egConfirmDialog','egAlertDialog','ngToast','egStrings','hotkeys', function ( $timeout , $scope , $q, $window , egCore , egTagTable , - egConfirmDialog , egAlertDialog , ngToast , egStrings) { + egConfirmDialog , egAlertDialog , ngToast , egStrings, hotkeys) { $scope.onSaveCallback = $scope.onSave; @@ -719,6 +719,37 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) } ); + hotkeys.add({ + combo: 'ctrl+s', + description: egCore.strings.HOTKEY_SAVE_RECORD, + callback: function(event, hotkey) { + + event.preventDefault(); + if($scope.flatEditor.isEnabled){ + $scope.saveFlatTextMARC(); + } + $scope.saveRecord(); + }, + allowIn : ['INPUT','SELECT','TEXTAREA'] + }); + + hotkeys.add({ + combo: 'ctrl+e', + description: egCore.strings.HOTKEY_FOCUS_EDITOR, + callback: function(event, hotkey) { + event.preventDefault(); + if($scope.flatEditor.isEnabled){ + var editor = $window.document.getElementsByTagName('textarea'); + editor[0].focus(); + } + else { + console.log('Jump focus to non-flattext editor not implemented.'); + } + }, + allowIn : ['INPUT','SELECT','TEXTAREA'] + }); + + MARC21.Record.delimiter = '$'; $scope.enable_fast_add = false; @@ -970,7 +1001,18 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) } else if (event.which == 119 && event.shiftKey) { // shift + F8, insert/replace 008 reify008(event); event_return = false; - + } else if (event.which == 83 && event.ctrlKey) { //ctrl + s, save + //alert("Ctrl-s pressed"); + event.preventDefault(); + $scope.saveRecord(); + event_return = false; + } else if (event.which == 76 && event.ctrlKey) { //ctrl + l, validate + event.preventDefault(); + $scope.validateHeadings(); + event_return = false; + } else if (event.which == 191 && event.ctrlKey) { //ctrl + ?, help + $scope.showHelp = !$scope.showHelp; + event_return = true; } else if (event.which == 13 && event.ctrlKey) { // ctrl+enter, insert datafield addDatafield(event, event.shiftKey); // shift key inserts before event_return = false; -- 2.11.0