fix: #2534 - Add clearable ratings (#2541)

* Add clearable to RecipeRating, Fix #2534

* Make rating nullable

---------

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
Grygon 2023-09-15 14:10:44 -05:00 committed by GitHub
parent 2dfbe9f08d
commit 9a04b11ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -10,6 +10,7 @@
:size="small ? 15 : undefined"
hover
:value="value"
clearable
@input="updateRating"
@click="updateRating"
></v-rating>
@ -52,7 +53,10 @@ export default defineComponent({
const rating = ref(props.value);
const api = useUserApi();
function updateRating(val: number) {
function updateRating(val: number | null) {
if (val === 0) {
val = null;
}
if (!props.emitOnly) {
api.recipes.patchOne(props.slug, {
rating: val,

View File

@ -206,7 +206,7 @@ export interface Recipe {
recipeCategory?: RecipeCategory[];
tags?: RecipeTag[];
tools?: RecipeTool[];
rating?: number;
rating?: number | null;
orgURL?: string;
dateAdded?: string;
dateUpdated?: string;