@93 - Wantlist

This commit is contained in:
Damien Broqua 2024-06-15 10:13:22 +02:00
parent bed5139a27
commit a4a3933c6d
24 changed files with 1137 additions and 70 deletions

View file

@ -1,3 +1,4 @@
/* eslint-disable no-undef */
Vue.createApp({
data() {
return {
@ -177,12 +178,15 @@ Vue.createApp({
this.submitting = true;
return axios
.post("/api/v1/albums", {
.post(`/api/v1/${action}`, {
album: this.details,
share: this.share,
})
.then(() => {
window.location.href = "/ma-collection";
window.location.href =
action === "albums"
? "/ma-collection"
: "/ma-liste-de-souhaits";
})
.catch((err) => {
this.submitting = false;

View file

@ -1,3 +1,4 @@
/* eslint-disable no-undef */
Vue.createApp({
data() {
return {
@ -74,7 +75,7 @@ Vue.createApp({
this.sortOrder = `${sortOrder.sort}-${sortOrder.order}`;
let url = `/api/v1/albums?page=${this.page}&sort=${this.sort}&order=${this.order}`;
let url = `/api/v1/${action}?page=${this.page}&sort=${this.sort}&order=${this.order}`;
if (this.artist) {
url += `&artist=${this.formatParams(this.artist)}`;
}
@ -186,7 +187,7 @@ Vue.createApp({
return false;
}
return axios
.delete(`/api/v1/albums/${this.itemId}`)
.delete(`/api/v1/${action}/${this.itemId}`)
.then(() => {
this.fetch();
})

View file

@ -19,6 +19,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
token: "",
message:
"Je viens d'ajouter {artist} - {album} à ma collection !",
wantlist:
"Je viens d'ajouter {artist} - {album} à ma liste de souhaits !",
},
},
loading: false,
@ -58,8 +60,13 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
// eslint-disable-next-line no-unused-vars
async updateProfil() {
this.errors = [];
const { oldPassword, password, passwordConfirm, mastodon, pagination } =
this.formData;
const {
oldPassword,
password,
passwordConfirm,
mastodon,
pagination,
} = this.formData;
if (password && !oldPassword) {
this.errors.push("emptyPassword");

View file

@ -1,3 +1,4 @@
/* eslint-disable no-undef */
if (typeof item !== "undefined") {
Vue.createApp({
data() {
@ -196,7 +197,7 @@ if (typeof item !== "undefined") {
updateItem() {
showToastr("Mise à jour en cours…", true);
axios
.patch(`/api/v1/albums/${this.item._id}`)
.patch(`/api/v1/${action}/${this.item._id}`)
.then((res) => {
showToastr("Mise à jour réalisée avec succès", true);
this.item = res.data;
@ -215,9 +216,12 @@ if (typeof item !== "undefined") {
},
deleteItem() {
axios
.delete(`/api/v1/albums/${this.item._id}`)
.delete(`/api/v1/${action}/${this.item._id}`)
.then(() => {
window.location.href = "/ma-collection";
window.location.href =
action === "albums"
? "/ma-collection"
: "/ma-liste-de-souhaits";
})
.catch((err) => {
showToastr(
@ -238,7 +242,7 @@ if (typeof item !== "undefined") {
}
this.shareSubmiting = true;
axios
.post(`/api/v1/albums/${this.item._id}/share`, {
.post(`/api/v1/${action}/${this.item._id}/share`, {
message: this.shareMessageTransformed,
})
.then(() => {

View file

@ -1,3 +1,4 @@
/* eslint-disable no-undef */
Vue.createApp({
data() {
return {
@ -10,7 +11,10 @@ Vue.createApp({
exportCollection(event) {
event.preventDefault();
window.open(`/api/v1/albums?exportFormat=${this.format}`, "_blank");
window.open(
`/api/v1/${action}?exportFormat=${this.format}`,
"_blank"
);
},
},
}).mount("#exporter");

View file

@ -1,3 +1,4 @@
/* eslint-disable no-undef */
Vue.createApp({
data() {
return {
@ -66,11 +67,11 @@ Vue.createApp({
try {
const res = await axios.get(
`/api/v1/albums?discogsId=${release_id}`
`/api/v1/${action}?discogsId=${release_id}`
);
if (res.status === 204) {
await axios.post("/api/v1/albums", {
await axios.post(`/api/v1/${action}`, {
discogsId: release_id,
share: false,
});