Move the rating logic outside of the rating widget

That way it's easier to re-use the component if that's ever required.

CURA-6013
This commit is contained in:
Jaime van Kessel 2018-12-10 10:40:54 +01:00
parent 04f3601c27
commit 098adc45ff
2 changed files with 20 additions and 2 deletions

View file

@ -177,6 +177,21 @@ Item
numRatings: details.num_ratings
userRating: details.user_rating
enabled: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn
onRated:
{
toolbox.ratePackage(details.id, rating)
var index = toolbox.packagesModel.find("id", details.id)
if(index != -1)
{
// Found the package
toolbox.packagesModel.setProperty(index, "user_rating", rating)
toolbox.packagesModel.setProperty(index, "num_ratings", details.num_ratings + 1)
// Hack; This is because the current selection is an outdated copy, so we need to re-copy it.
base.selection = toolbox.packagesModel.getItem(index)
}
}
}
}
Rectangle