Fix artiste error when updating
This commit is contained in:
@@ -26,6 +26,7 @@ const isSlugExists = async existingSlug => {
|
||||
}
|
||||
|
||||
const jwennAwtisEpiId = async artistesIds => {
|
||||
console.log('artistesIds', artistesIds)
|
||||
if (artistesIds.length === 0) {
|
||||
throw new ValidationError('Champ obligatoire. Veuillez choisir au moins un artiste.');
|
||||
}
|
||||
@@ -138,7 +139,7 @@ module.exports = {
|
||||
|
||||
const previousParoles = await strapi.db.query('api::parole.parole').findOne({
|
||||
where: {id},
|
||||
populate: {difference: true}
|
||||
populate: {difference: true, artistes: true}
|
||||
})
|
||||
|
||||
if (data.transcription && previousParoles.publishedAt) {
|
||||
@@ -150,8 +151,14 @@ module.exports = {
|
||||
if(!data.publishedAt && data.titre && data.transcription) {
|
||||
strapi.service('api::parole.parole').validateParoles(data.titre, data.transcription)
|
||||
if (data.titre && !data.forceSlug) {
|
||||
const artiste = await jwennAwtisEpiId(data.artistes.connect)
|
||||
data.slug = getSlug(artiste, data.titre)
|
||||
let artistes
|
||||
if (data.artistes.connect.length === 0) {
|
||||
artistes = previousParoles.artistes.map(a => a.alias).join('-')
|
||||
} else {
|
||||
artistes = await jwennAwtisEpiId(data.artistes.connect)
|
||||
}
|
||||
|
||||
data.slug = getSlug(artistes, data.titre)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user