refact(rating): label interface and usage

This commit is contained in:
Daniel Klein 2024-09-17 09:05:34 +02:00
parent da00ab91c2
commit c35e1cf99a
2 changed files with 10 additions and 8 deletions

View file

@ -224,7 +224,7 @@ export const useData = defineStore('data', () => {
value = (field as any[])?.length value = (field as any[])?.length
if (value) { if (value) {
isValid = value >= ref.condition.minLength isValid = value >= ref.condition.minLength
positive = `${value} ${ref.positive}${value > 1 ? 's' : ''}` positive = `${value} ${ref.label.positive}${value > 1 ? 's' : ''}`
} }
} }
if (ref.condition.equals) { if (ref.condition.equals) {
@ -241,11 +241,11 @@ export const useData = defineStore('data', () => {
rankPoints += isValid ? ref.points : 0 rankPoints += isValid ? ref.points : 0
return { return {
isValid, isValid,
label: ref.label, label: ref.label.name,
positive: positive ? positive : ref.positive, positive: positive ? positive : ref.label.positive,
negative: ref.negative, negative: ref.label.negative,
value, value,
} } as ProjectRatingItem
}) })
return { return {
type: rank.id, type: rank.id,

View file

@ -8,9 +8,11 @@ export interface Rank {
interface Reference { interface Reference {
field: keyof Project field: keyof Project
label: string label: {
name: string
positive: string positive: string
negative: string negative: string
}
condition: Condition condition: Condition
points: number points: number
} }