0👍
Ok I figured it out, after messing a bit with Excel:
updateRarities(trait, raritySlider){
var property = this.currentCollection.properties.items.find(property => property.id === trait.propertyID);
// sum of every raritySlider
let sumOfSliders = 0;
for (let i = 0; i < property.traits.items.length; i++) {
sumOfSliders = Number(sumOfSliders) + Number(property.traits.items[i].raritySlider);
}
for (let i = 0; i < property.traits.items.length; i++) {
if (property.traits.items[i].id !== trait.id) {
let updatedTrait = {
id: property.traits.items[i].id,
// calculate the rarity of the other traits
rarity: 1/sumOfSliders*property.traits.items[i].raritySlider,
updatedAt: new Date(),
}
API.graphql(graphqlOperation(mutations.updateTrait, { input: updatedTrait}));
}
else {
let updatedTrait = {
id: trait.id,
rarity: 1/sumOfSliders*raritySlider,
raritySlider: raritySlider,
updatedAt: new Date(),
}
API.graphql(graphqlOperation(mutations.updateTrait, { input: updatedTrait}));
}
}
}
I just needed to sum the value of the sliders.
- [Vuejs]-How to display data from id sent from other page in vue js
- [Vuejs]-Example of SwiperJs slider with Vue3 option API
Source:stackexchange.com