{BUGFIX} On album update when no day is set for released field
This commit is contained in:
parent
2eb22bb3d6
commit
1a9728fce6
1 changed files with 25 additions and 14 deletions
|
@ -285,6 +285,27 @@ Publié automatiquement via #musictopus`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Méthode permettant de récupérer le détails d'un album
|
||||||
|
*
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
async getOne() {
|
||||||
|
const { itemId: _id } = this.req.params;
|
||||||
|
const { _id: User } = this.req.user;
|
||||||
|
const album = await AlbumsModel.findOne({
|
||||||
|
_id,
|
||||||
|
User,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...album.toJSON(),
|
||||||
|
released: album.released
|
||||||
|
? formatDate(album.released, "MM/dd/yyyy")
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Méthode permettant de mettre à jour un album
|
* Méthode permettant de mettre à jour un album
|
||||||
*
|
*
|
||||||
|
@ -309,7 +330,9 @@ Publié automatiquement via #musictopus`;
|
||||||
|
|
||||||
const values = await getAlbumDetails(album.discogsId);
|
const values = await getAlbumDetails(album.discogsId);
|
||||||
|
|
||||||
return AlbumsModel.findOneAndUpdate(query, values, { new: true });
|
await AlbumsModel.findOneAndUpdate(query, values, { new: true });
|
||||||
|
|
||||||
|
return this.getOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -444,19 +467,7 @@ Publié automatiquement via #musictopus`;
|
||||||
* Méthode permettant d'afficher le détails d'un album
|
* Méthode permettant d'afficher le détails d'un album
|
||||||
*/
|
*/
|
||||||
async loadItem() {
|
async loadItem() {
|
||||||
const { itemId: _id } = this.req.params;
|
const item = await this.getOne();
|
||||||
const { _id: User } = this.req.user;
|
|
||||||
const album = await AlbumsModel.findOne({
|
|
||||||
_id,
|
|
||||||
User,
|
|
||||||
});
|
|
||||||
|
|
||||||
const item = {
|
|
||||||
...album.toJSON(),
|
|
||||||
released: album.released
|
|
||||||
? formatDate(album.released, "MM/dd/yyyy")
|
|
||||||
: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setPageContent("item", item);
|
this.setPageContent("item", item);
|
||||||
this.setPageTitle(
|
this.setPageTitle(
|
||||||
|
|
Loading…
Reference in a new issue