2017-03-28 15:09:03 +02:00
|
|
|
(function() {
|
|
|
|
var showNotFound = function() {
|
|
|
|
$('.dossier-link .text-info').hide();
|
|
|
|
$('.dossier-link .text-warning').show();
|
|
|
|
};
|
|
|
|
|
|
|
|
var showData = function(data) {
|
2017-04-26 16:15:48 +02:00
|
|
|
$('.dossier-link .dossier-text-summary').text(data.textSummary);
|
2017-03-28 15:09:03 +02:00
|
|
|
$('.dossier-link .text-info').show();
|
|
|
|
$('.dossier-link .text-warning').hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
var hideEverything = function() {
|
|
|
|
$('.dossier-link .text-info').hide();
|
|
|
|
$('.dossier-link .text-warning').hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
var fetchProcedureLibelle = function(e) {
|
|
|
|
var dossierId = $(e.target).val();
|
|
|
|
if(dossierId) {
|
2017-04-26 16:15:48 +02:00
|
|
|
$.get('/users/dossiers/' + dossierId + '/text_summary')
|
2017-03-28 15:09:03 +02:00
|
|
|
.done(showData)
|
|
|
|
.fail(showNotFound);
|
|
|
|
} else {
|
|
|
|
hideEverything();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var timeOut = null;
|
|
|
|
var debounceFetchProcedureLibelle = function(e) {
|
|
|
|
if(timeOut){ clearTimeout(timeOut); }
|
|
|
|
timeOut = setTimeout(function() { fetchProcedureLibelle(e); }, 300);
|
|
|
|
};
|
|
|
|
|
|
|
|
$(document).on('input', '[data-type=dossier-link]', debounceFetchProcedureLibelle);
|
|
|
|
})();
|