|
Line 0
Link Here
|
| 0 |
- |
1 |
$(document).ready(function() { |
|
|
2 |
|
| 3 |
// Detect that we were redirected here after login and re-open modal |
| 4 |
let urlParams = new URLSearchParams(window.location.search); |
| 5 |
if (urlParams.has('modal')) { |
| 6 |
let modal = urlParams.get('modal'); |
| 7 |
history.replaceState && history.replaceState( |
| 8 |
null, '', location.pathname + location.search.replace(/[\?&]modal=[^&]+/, '').replace(/^&/, '?') |
| 9 |
); |
| 10 |
if (modal == 'concern') { |
| 11 |
$("#addConcernModal").modal('show'); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
$('#addConcernModal').on('show.bs.modal', function(e) { |
| 16 |
if (logged_in_user_id === "") { |
| 17 |
$('#modalAuth').append('<input type="hidden" name="return" value="' + window.location.pathname + window.location.search + '&modal=concern" />'); |
| 18 |
$('#loginModal').modal('show'); |
| 19 |
return false; |
| 20 |
} |
| 21 |
}); |
| 22 |
|
| 23 |
$('#addConcernModal').on('click', '#addConfirm', function(e) { |
| 24 |
let concern_title = $('#concern_title').val(); |
| 25 |
let concern_body = $('#concern_body').val(); |
| 26 |
let biblio_id = $('#concern_biblio').val(); |
| 27 |
let reporter_id = $('#concern_reporter').val(); |
| 28 |
|
| 29 |
params = { |
| 30 |
title: concern_title, |
| 31 |
body: concern_body, |
| 32 |
biblio_id: biblio_id, |
| 33 |
reporter_id: reporter_id, |
| 34 |
}; |
| 35 |
|
| 36 |
$.ajax({ |
| 37 |
url: '/api/v1/public/tickets', |
| 38 |
type: 'POST', |
| 39 |
data: JSON.stringify(params), |
| 40 |
success: function(data) { |
| 41 |
$('#addConcernModal').modal('hide'); |
| 42 |
$('#concern_body').val(''); |
| 43 |
}, |
| 44 |
contentType: "json" |
| 45 |
}); |
| 46 |
}); |
| 47 |
}); |