feat(select-entries): save the collections of activities
This commit is contained in:
parent
df25bfa9ac
commit
32389d740e
1 changed files with 21 additions and 4 deletions
|
@ -138,10 +138,11 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
|||
})
|
||||
$('.btn-save-selected').on('click', function(e){
|
||||
e.preventDefault()
|
||||
let content = Array()
|
||||
let bf_activite = Array()
|
||||
$.each( $('.selected'), function( key, value ) {
|
||||
content.push(value.getAttribute('data-tag'))
|
||||
bf_activite[value.getAttribute('data-tag')] = value.getAttribute('data-tag')
|
||||
});
|
||||
bf_activite = Object.assign({}, bf_activite)
|
||||
const settings = {
|
||||
async: true,
|
||||
crossDomain: true,
|
||||
|
@ -150,11 +151,27 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
|||
headers: {
|
||||
Authorization: 'Bearer ScTSZnBTCw6SWnpThhAAodKh4brbwrnHwxn5jzIsOLxjk4SotxlFbrqnZnEEvVvb'
|
||||
},
|
||||
data: JSON.stringify({ bf_titre: $('#title').val(), bf_activite: content, id_typeannonce: 21 }),
|
||||
data: JSON.stringify({ bf_titre: $('#title').val(), bf_activite, id_typeannonce: 21 }),
|
||||
contentType: 'application/json'
|
||||
};
|
||||
$.ajax(settings).done(function (response) {
|
||||
console.log(response);
|
||||
toastMessage(
|
||||
"La sélection est créée, allons la voir!",
|
||||
2000,
|
||||
'alert alert-success'
|
||||
)
|
||||
setTimeout(function() { window.location.href = response.success }, 2000)
|
||||
|
||||
}).fail(function (response) {
|
||||
const regex = /can not be generated from/gm;
|
||||
if (response.statusText == "error" && regex.exec(response.responseText)) {
|
||||
toastMessage(
|
||||
"Veuillez renseigner un titre pour la sélection",
|
||||
3000,
|
||||
'alert alert-danger'
|
||||
)
|
||||
}
|
||||
|
||||
});
|
||||
return false;
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue