mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Can delete movie
This commit is contained in:
parent
a34d10619c
commit
9b16f83693
@ -18,6 +18,19 @@ ComunicWeb.components.movies.interface = {
|
|||||||
|
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a movie
|
||||||
|
*
|
||||||
|
* @param {number} movieID The ID of the movie to delete
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
delete: function(movieID) {
|
||||||
|
return api("movies/delete", {
|
||||||
|
movieID: movieID
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -147,10 +147,12 @@ ComunicWeb.components.movies.picker = {
|
|||||||
|
|
||||||
//Process the list of movies
|
//Process the list of movies
|
||||||
var i;
|
var i;
|
||||||
for(i in list){
|
for(i in list) {
|
||||||
|
|
||||||
|
const movie = list[i];
|
||||||
|
|
||||||
//Create a line
|
//Create a line
|
||||||
var line = createElem2({
|
const line = createElem2({
|
||||||
appendTo: tableBody,
|
appendTo: tableBody,
|
||||||
type: "tr",
|
type: "tr",
|
||||||
});
|
});
|
||||||
@ -187,7 +189,7 @@ ComunicWeb.components.movies.picker = {
|
|||||||
type: "td",
|
type: "td",
|
||||||
});
|
});
|
||||||
|
|
||||||
var chooseButton = createElem2({
|
const chooseButton = createElem2({
|
||||||
appendTo: actionCell,
|
appendTo: actionCell,
|
||||||
type: "button",
|
type: "button",
|
||||||
class: "btn btn-primary",
|
class: "btn btn-primary",
|
||||||
@ -203,6 +205,33 @@ ComunicWeb.components.movies.picker = {
|
|||||||
//Call callback
|
//Call callback
|
||||||
callback(list[this.getAttribute("data-movie-num")]);
|
callback(list[this.getAttribute("data-movie-num")]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add delete button
|
||||||
|
createElem2({
|
||||||
|
appendTo: actionCell,
|
||||||
|
type: "button",
|
||||||
|
class: "btn btn-danger",
|
||||||
|
innerHTML: "Delete",
|
||||||
|
onclick: () => {
|
||||||
|
|
||||||
|
if(!ComunicWeb.common.messages.confirm("Do you really want to delete this movie ?", async res => {
|
||||||
|
|
||||||
|
if(!res)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ComunicWeb.components.movies.interface.delete(movie.id)
|
||||||
|
line.remove();
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
notify("Could not delete movie!", "danger");
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user