Fixed error handling
This commit is contained in:
parent
98f59fc20f
commit
66d03aae98
5 changed files with 23 additions and 15 deletions
|
@ -1,9 +1,5 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
function droplabAjaxException(message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Ajax = {
|
const Ajax = {
|
||||||
_loadUrlData: function _loadUrlData(url) {
|
_loadUrlData: function _loadUrlData(url) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -58,9 +54,7 @@ const Ajax = {
|
||||||
this._loadUrlData(config.endpoint)
|
this._loadUrlData(config.endpoint)
|
||||||
.then(function(d) {
|
.then(function(d) {
|
||||||
self._loadData(d, config, self);
|
self._loadData(d, config, self);
|
||||||
}, config.onError).catch(function(e) {
|
}, config.onError).catch(config.onError);
|
||||||
throw new droplabAjaxException(e.message || e);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
|
|
@ -68,7 +68,7 @@ const AjaxFilter = {
|
||||||
this._loadUrlData(url)
|
this._loadUrlData(url)
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
self._loadData(data, config, self);
|
self._loadData(data, config, self);
|
||||||
}, config.onError);
|
}, config.onError).catch(config.onError);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global Flash */
|
||||||
|
|
||||||
import Ajax from '~/droplab/plugins/ajax';
|
import Ajax from '~/droplab/plugins/ajax';
|
||||||
import Filter from '~/droplab/plugins/filter';
|
import Filter from '~/droplab/plugins/filter';
|
||||||
|
|
||||||
|
@ -13,6 +15,11 @@ require('./filtered_search_dropdown');
|
||||||
endpoint,
|
endpoint,
|
||||||
method: 'setData',
|
method: 'setData',
|
||||||
loadingTemplate: this.loadingTemplate,
|
loadingTemplate: this.loadingTemplate,
|
||||||
|
onError() {
|
||||||
|
/* eslint-disable no-new */
|
||||||
|
new Flash('An error occured fetching the dropdown data.');
|
||||||
|
/* eslint-enable no-new */
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Filter: {
|
Filter: {
|
||||||
filterFunction: gl.DropdownUtils.filterWithSymbol.bind(null, this.symbol, input),
|
filterFunction: gl.DropdownUtils.filterWithSymbol.bind(null, this.symbol, input),
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global Flash */
|
||||||
|
|
||||||
import AjaxFilter from '~/droplab/plugins/ajax_filter';
|
import AjaxFilter from '~/droplab/plugins/ajax_filter';
|
||||||
|
|
||||||
require('./filtered_search_dropdown');
|
require('./filtered_search_dropdown');
|
||||||
|
@ -18,6 +20,11 @@ require('./filtered_search_dropdown');
|
||||||
},
|
},
|
||||||
searchValueFunction: this.getSearchInput.bind(this),
|
searchValueFunction: this.getSearchInput.bind(this),
|
||||||
loadingTemplate: this.loadingTemplate,
|
loadingTemplate: this.loadingTemplate,
|
||||||
|
onError() {
|
||||||
|
/* eslint-disable no-new */
|
||||||
|
new Flash('An error occured fetching the dropdown data.');
|
||||||
|
/* eslint-enable no-new */
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ describe 'Dropdown milestone', :feature, :js do
|
||||||
it 'should load all the milestones when opened' do
|
it 'should load all the milestones when opened' do
|
||||||
filtered_search.set('milestone:')
|
filtered_search.set('milestone:')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to be > 0
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,37 +84,37 @@ describe 'Dropdown milestone', :feature, :js do
|
||||||
it 'filters by name' do
|
it 'filters by name' do
|
||||||
filtered_search.send_keys('v1')
|
filtered_search.send_keys('v1')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to eq(1)
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by case insensitive name' do
|
it 'filters by case insensitive name' do
|
||||||
filtered_search.send_keys('V1')
|
filtered_search.send_keys('V1')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to eq(1)
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by name with symbol' do
|
it 'filters by name with symbol' do
|
||||||
filtered_search.send_keys('%v1')
|
filtered_search.send_keys('%v1')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to eq(1)
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by case insensitive name with symbol' do
|
it 'filters by case insensitive name with symbol' do
|
||||||
filtered_search.send_keys('%V1')
|
filtered_search.send_keys('%V1')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to eq(1)
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by special characters' do
|
it 'filters by special characters' do
|
||||||
filtered_search.send_keys('(+')
|
filtered_search.send_keys('(+')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to eq(1)
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by special characters with symbol' do
|
it 'filters by special characters with symbol' do
|
||||||
filtered_search.send_keys('%(+')
|
filtered_search.send_keys('%(+')
|
||||||
|
|
||||||
expect(dropdown_milestone_size).to eq(1)
|
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue