diff --git a/src/main/webapp/app/controllers/settings/fieldPredicatesController.js b/src/main/webapp/app/controllers/settings/fieldPredicatesController.js index 622edaa36f..23749a7bc0 100644 --- a/src/main/webapp/app/controllers/settings/fieldPredicatesController.js +++ b/src/main/webapp/app/controllers/settings/fieldPredicatesController.js @@ -39,7 +39,9 @@ vireo.controller('FieldPredicatesController', function ($controller, $timeout, $ $scope.selectFieldPredicate = function(index) { $scope.resetFieldPredicates(); - var filtereFieldPredicates = $filter('filter')($scope.fieldPredicates, $scope.dragAndDropTextFilterValue[$scope.dragAndDropSelectedFilter]); + // Filter exactly the way draganddroplist renders the list, otherwise the index + // handed back by the list does not point at the predicate the user acted on. + var filtereFieldPredicates = $filter('filter')($scope.fieldPredicates, $scope.dragAndDropTextFilterValue); $scope.modalData = filtereFieldPredicates[index]; }; diff --git a/src/main/webapp/app/controllers/submission/submissionListController.js b/src/main/webapp/app/controllers/submission/submissionListController.js index b0689e4e37..7686123ccf 100644 --- a/src/main/webapp/app/controllers/submission/submissionListController.js +++ b/src/main/webapp/app/controllers/submission/submissionListController.js @@ -1026,6 +1026,24 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle column.status = !column.status ? 'previouslyDisabled' : undefined; }; + // Keyboard accessible equivalent of dragging a column to a new position. See issue #1674. + var moveInList = function(list, index, offset) { + var destination = index + offset; + + if (destination < 0 || destination >= list.length) { + return; + } + + list.splice(destination, 0, list.splice(index, 1)[0]); + updateChange(true); + }; + + $scope.moveColumn = moveInList; + + var moveFilterColumn = function(index, offset) { + moveInList(filterColumns.userFilterColumns, index, offset); + }; + $scope.displayedColumnOptions = createDisplayedColumnOptions(); $scope.disabledColumnOptions = createDisabledColumnOptions(); @@ -1073,6 +1091,7 @@ vireo.controller("SubmissionListController", function (NgTableParams, $controlle "filterColumns": filterColumns, "disableFilter": disableFilter, "enableFilter": enableFilter, + "moveFilterColumn": moveFilterColumn, "displayedFilterColumnOptions": displayedFilterColumnOptions, "disabledFilterColumnOptions": disabledFilterColumnOptions, "saveUserFilters": $scope.saveUserFilters, diff --git a/src/main/webapp/app/directives/dragAndDropListDirective.js b/src/main/webapp/app/directives/dragAndDropListDirective.js index 837b7835c1..9612af815d 100644 --- a/src/main/webapp/app/directives/dragAndDropListDirective.js +++ b/src/main/webapp/app/directives/dragAndDropListDirective.js @@ -24,6 +24,7 @@ vireo.directive("draganddroplist", function($filter) { 'selectedFilter': '=?', 'textFilterValue': '=?', 'passiveFilter': '=?', + 'allowRemove': '=?', 'isEditable': '&', }, controller: function($scope) { @@ -37,6 +38,61 @@ vireo.directive("draganddroplist", function($filter) { if(typeof $scope.itemView == 'undefined') { $scope.itemView = 'views/directives/dragAndDropItem.html'; } + + // Keyboard accessible alternatives to the drag gestures. Drag and drop cannot be + // the only way to reorder or remove an item. See issue #1674. + + $scope.itemControlsView = 'views/directives/dragAndDropItemControls.html'; + + $scope.canReorder = function () { + return !!($scope.listeners && $scope.listeners.canReorder && $scope.listeners.canReorder()); + }; + + // Lists whose items are deleted somewhere other than the trash can (the embargo + // tables delete from their edit modal) opt out with allow-remove="false". + $scope.canRemove = function () { + if ($scope.allowRemove === false) { + return false; + } + return !!($scope.listeners && $scope.listeners.canRemove && $scope.listeners.canRemove()); + }; + + $scope.moveUp = function (index) { + $scope.listeners.moveItem($scope.scopeValue, index, index - 1); + }; + + $scope.moveDown = function (index) { + $scope.listeners.moveItem($scope.scopeValue, index, index + 1); + }; + + $scope.removeItem = function (index) { + $scope.listeners.removeAt(index); + }; + + // Used to give each control an accessible name that identifies the row it acts on, + // so "Remove" is announced as "Remove Masters of Science" rather than just "Remove". + $scope.itemLabel = function (item) { + var parts = []; + + if (item) { + angular.forEach($scope.properties, function (property) { + var value = item[property]; + if (angular.isString(value) || angular.isNumber(value)) { + parts.push(value); + } else if (value && angular.isString(value.name)) { + parts.push(value.name); + } + }); + } + + if (parts.length > 0) { + return parts.join(' '); + } + + // The table list view passes column headings rather than item keys as + // properties, so fall back to whatever the item calls itself. + return (item && (item.name || item.label || item.gloss)) || 'this item'; + }; }, link: function($scope, elem, attr) { $scope.properties = angular.fromJson(attr.properties); diff --git a/src/main/webapp/app/directives/keyboardClickableDirective.js b/src/main/webapp/app/directives/keyboardClickableDirective.js new file mode 100644 index 0000000000..deb5b04344 --- /dev/null +++ b/src/main/webapp/app/directives/keyboardClickableDirective.js @@ -0,0 +1,53 @@ +/** + * Makes a non interactive element that carries an ng-click reachable and operable + * from the keyboard, without changing how it looks. Adds a tab stop and a button + * role when the element does not already declare them, and activates the element + * on Enter or Space the way a native button would. + * + * Use it on clickable spans, images and list items. Native controls (button, a[href], + * input, select, textarea) already do this and do not need the attribute. + */ +vireo.directive("keyboardClickable", function () { + + var ENTER = 13; + var SPACE = 32; + + return { + restrict: 'A', + link: function ($scope, element, attrs) { + + if (attrs.tabindex === undefined) { + element.attr('tabindex', '0'); + } + + if (attrs.role === undefined) { + element.attr('role', 'button'); + } + + var isDisabled = function () { + return element.attr('disabled') !== undefined || element.hasClass('disabled'); + }; + + var onKeydown = function (event) { + if (event.which !== ENTER && event.which !== SPACE) { + return; + } + + if (isDisabled()) { + return; + } + + // Space scrolls the page by default and Enter may submit a surrounding form. + event.preventDefault(); + + element[0].click(); + }; + + element.on('keydown', onKeydown); + + $scope.$on('$destroy', function () { + element.off('keydown', onKeydown); + }); + } + }; +}); diff --git a/src/main/webapp/app/factories/dragAndDropListenerFactory.js b/src/main/webapp/app/factories/dragAndDropListenerFactory.js index 75748e5a39..d2c6c71be7 100644 --- a/src/main/webapp/app/factories/dragAndDropListenerFactory.js +++ b/src/main/webapp/app/factories/dragAndDropListenerFactory.js @@ -51,6 +51,10 @@ vireo.factory('DragAndDropListenerFactory', function($q, ModalService) { }); }; + var relocate = function(list, from, to) { + list.splice(to, 0, list.splice(from, 1)[0]); + }; + var dragControls = { getListener: function () { return listener; @@ -115,6 +119,53 @@ vireo.factory('DragAndDropListenerFactory', function($q, ModalService) { }); } }, + + // Keyboard accessible equivalents of the drag gestures above. These drive the + // per item controls rendered by the draganddroplist directive so that reordering + // and removal never require a pointer. See issue #1674. + + canReorder: function() { + return angular.isFunction(listener.reorder); + }, + + canRemove: function() { + return angular.isFunction(listener.select) && !!listener.confirm.remove.modal; + }, + + // Mirrors dropping an item on the trash can: select it, then hand off to the + // same confirmation modal the drag gesture opens. + removeAt: function(index) { + if(!dragControls.canRemove()) { + return; + } + original = angular.copy(listener.model); + listener.select(index); + updateRequest(); + ModalService.openModal(listener.confirm.remove.modal); + }, + + // Mirrors dragging an item to a new slot. The list passed in is the rendered + // list, which is what the sortable mutates and what the reorder end points + // expect positions against. + moveItem: function(list, from, to) { + if(!dragControls.canReorder() || !angular.isArray(list)) { + return $q.when(); + } + if(from === to || to < 0 || to >= list.length) { + return $q.when(); + } + original = angular.copy(listener.model); + relocate(list, from, to); + updateRequest(); + return listener.reorder(from + 1, to + 1).then(function(res) { + var message = angular.fromJson(res.body); + if (message.meta.status !== "SUCCESS") { + relocate(list, to, from); + angular.extend(listener.model, original); + } + }); + }, + containerPositioning: 'relative', containment: drag.container }; diff --git a/src/main/webapp/app/resources/styles/sass/app.scss b/src/main/webapp/app/resources/styles/sass/app.scss index 1ba8ab43ed..6c2575caae 100644 --- a/src/main/webapp/app/resources/styles/sass/app.scss +++ b/src/main/webapp/app/resources/styles/sass/app.scss @@ -687,8 +687,9 @@ h4 { background: #efefef; border: dashed thick #fefefe; padding-top: 35px; + padding-bottom: 10px; width: 250px; - height: 150px; + min-height: 150px; color: #696969; border-radius: 5px; transition: all 0.35s ease-in; @@ -742,6 +743,13 @@ h4 { cursor: pointer; } +/* The drop zone is also operable from the keyboard through this button, which opens the + file picker, so the focus has to be visible. */ +.upload-drop-zone .invisible-button:focus { + outline: 2px solid #337ab7; + outline-offset: 2px; +} + .upload-drop-zone.dragging .glyphicon-upload, .upload-drop-zone.reject .glyphicon-ban-circle { transition: all 0.35s ease-in; @@ -1482,6 +1490,39 @@ input[type=color]:focus { display: inline-block; } +/* The move buttons are a keyboard alternative to dragging, so unlike the hint arrows + they stay visible rather than waiting for a hover. See issue #1674. */ +.displayed-column, +.disabled-column { + display: flex; + align-items: center; +} + +.displayed-column > [as-sortable-item-handle], +.disabled-column > [as-sortable-item-handle] { + flex: 1 1 auto; + min-width: 0; +} + +.displayed-column > .item-controls, +.disabled-column > .item-controls { + flex: 0 0 auto; + margin-left: 8px; +} + +.displayed-column .item-controls .glyphicon, +.disabled-column .item-controls .glyphicon { + display: inline-block; +} + +.displayed-column .item-controls .item-control:focus, +.disabled-column .item-controls .item-control:focus, +.displayed-column [as-sortable-item-handle]:focus, +.disabled-column [as-sortable-item-handle]:focus { + outline: 2px solid #337ab7; + outline-offset: 2px; +} + .column-background { list-style-type: none; margin: 0; diff --git a/src/main/webapp/app/resources/styles/sass/directives/_dragAndDropList.scss b/src/main/webapp/app/resources/styles/sass/directives/_dragAndDropList.scss index a2aaf8178a..65ccec03dd 100644 --- a/src/main/webapp/app/resources/styles/sass/directives/_dragAndDropList.scss +++ b/src/main/webapp/app/resources/styles/sass/directives/_dragAndDropList.scss @@ -24,3 +24,55 @@ .as-sortable-placeholder { border: 1px solid #dcdcdc; } + +/******************************************************** + * Keyboard accessible alternatives to the drag gestures * + ********************************************************/ + +.list-dragdrop > li > .list-dragdrop-item, +.list-dragdrop > li > .item-controls-wrapper { + display: inline-block; + vertical-align: middle; +} + +.list-dragdrop > li > .item-controls-wrapper { + margin-left: 8px; +} + +.item-controls { + white-space: nowrap; +} + +.item-controls .item-control { + color: #666666; +} + +.item-controls .item-control-remove { + color: #a94442; +} + +.item-controls .item-control[disabled] { + opacity: 0.35; +} + +/* The edit pencil used to appear only while the row was hovered, which put it out of + reach of the keyboard. It is always rendered now and leans on colour for emphasis. */ +.edit-setting-icon { + color: #999999; + margin-left: 6px; +} + +.list-dragdrop > li:hover .edit-setting-icon, +.list-dragdrop > li:focus-within .edit-setting-icon, +.edit-setting-icon:hover, +.edit-setting-icon:focus { + color: #333333; +} + +/* Every control reached by tabbing needs to show where the focus is. */ +.item-controls .item-control:focus, +.edit-setting-icon:focus, +[keyboard-clickable]:focus { + outline: 2px solid #337ab7; + outline-offset: 2px; +} diff --git a/src/main/webapp/app/views/admin/settings/workflow/embargoTypes.html b/src/main/webapp/app/views/admin/settings/workflow/embargoTypes.html index 9a0b349db2..ee53600e85 100644 --- a/src/main/webapp/app/views/admin/settings/workflow/embargoTypes.html +++ b/src/main/webapp/app/views/admin/settings/workflow/embargoTypes.html @@ -10,8 +10,9 @@

Default Embargoes

ProQuest Embargoes {{ item[property] }} - + \ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropCustomAction.html b/src/main/webapp/app/views/directives/dragAndDropCustomAction.html index d74c9cf879..ab695c3a99 100644 --- a/src/main/webapp/app/views/directives/dragAndDropCustomAction.html +++ b/src/main/webapp/app/views/directives/dragAndDropCustomAction.html @@ -2,11 +2,13 @@ {{ item.position }}. - - + + {{item.label}} - - \ No newline at end of file + + diff --git a/src/main/webapp/app/views/directives/dragAndDropDegree.html b/src/main/webapp/app/views/directives/dragAndDropDegree.html index 902adf8689..7e2085de71 100644 --- a/src/main/webapp/app/views/directives/dragAndDropDegree.html +++ b/src/main/webapp/app/views/directives/dragAndDropDegree.html @@ -1,5 +1,5 @@
{{ item.position }}. {{item[properties[0]]}} ({{item[properties[1]].name}}) - +
diff --git a/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html b/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html index 23615c9ca7..e7eb2a28c1 100644 --- a/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html +++ b/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html @@ -1,5 +1,5 @@
{{ item.position }}. {{item[property]}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropDocumentType.html b/src/main/webapp/app/views/directives/dragAndDropDocumentType.html index b2ff8a094b..ba5a2c6ddd 100644 --- a/src/main/webapp/app/views/directives/dragAndDropDocumentType.html +++ b/src/main/webapp/app/views/directives/dragAndDropDocumentType.html @@ -4,5 +4,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html b/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html index dce24e8a56..cff8ccbe1a 100644 --- a/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html +++ b/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html @@ -3,5 +3,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropEmbargo.html b/src/main/webapp/app/views/directives/dragAndDropEmbargo.html index 1001ace3b8..5c6439a404 100644 --- a/src/main/webapp/app/views/directives/dragAndDropEmbargo.html +++ b/src/main/webapp/app/views/directives/dragAndDropEmbargo.html @@ -12,7 +12,9 @@ Indefinite {{item.duration}} - - - + + + + diff --git a/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html b/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html index 628c1b9562..7dca10e5f2 100644 --- a/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html +++ b/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html @@ -4,5 +4,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html b/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html index 628c1b9562..7dca10e5f2 100644 --- a/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html +++ b/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html @@ -4,5 +4,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html b/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html index a606c48c29..e87cede547 100644 --- a/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html +++ b/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html @@ -3,6 +3,6 @@ {{ item[property] }}* - + diff --git a/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html b/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html index 491e2c399b..b3d0d2210a 100644 --- a/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html +++ b/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html @@ -1,5 +1,5 @@
{{ item.position }}. {{toString({month:item[property]})}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropItemControls.html b/src/main/webapp/app/views/directives/dragAndDropItemControls.html new file mode 100644 index 0000000000..c9288c8a4e --- /dev/null +++ b/src/main/webapp/app/views/directives/dragAndDropItemControls.html @@ -0,0 +1,36 @@ + +
+ + + + + + + +
diff --git a/src/main/webapp/app/views/directives/dragAndDropLanguage.html b/src/main/webapp/app/views/directives/dragAndDropLanguage.html index 2ff9c304bd..9ea32fa829 100644 --- a/src/main/webapp/app/views/directives/dragAndDropLanguage.html +++ b/src/main/webapp/app/views/directives/dragAndDropLanguage.html @@ -4,5 +4,5 @@ {{ item[property] }} - + \ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropList.html b/src/main/webapp/app/views/directives/dragAndDropList.html index e6f446f259..f23806967f 100644 --- a/src/main/webapp/app/views/directives/dragAndDropList.html +++ b/src/main/webapp/app/views/directives/dragAndDropList.html @@ -24,9 +24,12 @@
  1. -
    +
    + +
diff --git a/src/main/webapp/app/views/directives/dragAndDropNote.html b/src/main/webapp/app/views/directives/dragAndDropNote.html index b4889dc057..0cd91d99ac 100644 --- a/src/main/webapp/app/views/directives/dragAndDropNote.html +++ b/src/main/webapp/app/views/directives/dragAndDropNote.html @@ -1,6 +1,6 @@
{{ item.position }}. {{ item[property] }} - +
diff --git a/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html b/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html index ab73542b79..fd099a040a 100644 --- a/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html +++ b/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html @@ -1,4 +1,4 @@
{{item[property]}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropTable.html b/src/main/webapp/app/views/directives/dragAndDropTable.html index f4f6401541..e987690abe 100644 --- a/src/main/webapp/app/views/directives/dragAndDropTable.html +++ b/src/main/webapp/app/views/directives/dragAndDropTable.html @@ -10,7 +10,7 @@ - + diff --git a/src/main/webapp/app/views/directives/trashCan.html b/src/main/webapp/app/views/directives/trashCan.html index e7368f3d4e..8d06230dea 100644 --- a/src/main/webapp/app/views/directives/trashCan.html +++ b/src/main/webapp/app/views/directives/trashCan.html @@ -1,10 +1,10 @@
- +
-

Remove items by dragging them to trash can

+

Remove items by dragging them to the trash can, or with the remove button beside each item.

- +
diff --git a/src/main/webapp/app/views/inputtype/input-file.html b/src/main/webapp/app/views/inputtype/input-file.html index cf4f682064..f70f109a05 100644 --- a/src/main/webapp/app/views/inputtype/input-file.html +++ b/src/main/webapp/app/views/inputtype/input-file.html @@ -11,11 +11,11 @@
- - + Preview of {{fieldValue.fileInfo.name}} +
- - + +
@@ -64,16 +64,16 @@
{{header}}{{header}}
-

{{fieldValue.fileInfo.name | limitTo: 25}}{{fieldValue.fileInfo.name.length > 25 ? '...' : ''}}

+

{{fieldValue.fileInfo.name | limitTo: 25}}{{fieldValue.fileInfo.name.length > 25 ? '...' : ''}}

{{fieldValue.fileInfo.size | readableFileSize}} - + - - + + {{fieldValue.progress + '%'}} diff --git a/src/main/webapp/app/views/modals/submissions/customizeFilters.html b/src/main/webapp/app/views/modals/submissions/customizeFilters.html index a2085f034b..a4ee13862b 100644 --- a/src/main/webapp/app/views/modals/submissions/customizeFilters.html +++ b/src/main/webapp/app/views/modals/submissions/customizeFilters.html @@ -8,13 +8,21 @@