Don't display 404 errors when using the "Jump to..." box

Currently, typing an ID in the "Jump to..." box in the header allows the
user to jump directly to an object with a given ID. However, if a GET
for an object with that ID for the supported objects (currently Story,
Project, and Project Group) results in a 404, an error notification is
created, which gives a needless impression of something going wrong.

The lack of an object in the list of things with the entered ID is
sufficient indication that the object doesn't exist, without the extra
error message.

This commit adds a notification interceptor which stops 404 errors
raised between the "Jump to..." GET requests being sent and all of them
being resolved from being displayed to the user.

There is a small chance that this could cause useful 404 errors to be
missed, but the user would have to do something to cause it whilst the
other requests are still in-flight, which seems unlikely enough to be
acceptable to me.

Change-Id: I723d61479370e49b1e36ede0a118ad5d4464907f
Story: 2000466
Task: 2751
Story: 2002140
Task: 19830
This commit is contained in:
Adam Coldrick 2018-08-07 21:16:42 +01:00
parent fd8e560f95
commit 2d00cd8127
1 changed files with 14 additions and 1 deletions

View File

@ -22,7 +22,7 @@ angular.module('storyboard').controller('HeaderController',
function ($q, $scope, $rootScope, $state, $modal, NewStoryService,
Session, SessionState, CurrentUser, Criteria, Notification,
Priority, Project, Story, ProjectGroup, NewWorklistService,
NewBoardService, SessionModalService) {
NewBoardService, SessionModalService, Severity) {
'use strict';
function resolveCurrentUser() {
@ -172,11 +172,23 @@ angular.module('storyboard').controller('HeaderController',
searchString = searchString || '';
var searches = [];
var headerGET = false;
Notification.intercept(function(message) {
if (message.type === 'http' &&
message.severity === Severity.ERROR &&
message.message === 404 &&
headerGET
) {
return true;
}
});
if (searchString.match(/^[0-9]+$/)) {
var getProjectGroupDeferred = $q.defer();
var getProjectDeferred = $q.defer();
var getStoryDeferred = $q.defer();
headerGET = true;
ProjectGroup.get({id: searchString},
function (result) {
@ -214,6 +226,7 @@ angular.module('storyboard').controller('HeaderController',
searches.push(Story.criteriaResolver(searchString, 5));
}
$q.all(searches).then(function (searchResults) {
headerGET = false;
var criteria = [
Criteria.create('Text', searchString)
];