feat: Implement logic to prevent deletion of system tasks and rewards; update APIs and tests accordingly
All checks were successful
Gitea Actions Demo / build-and-push (push) Successful in 34s

This commit is contained in:
2026-02-01 16:57:12 -05:00
parent f14de28daa
commit e42c6c1ef2
16 changed files with 324 additions and 87 deletions

View File

@@ -13,6 +13,7 @@ const props = defineProps<{
onDelete?: (id: string) => void
filterFn?: (item: any) => boolean
getItemClass?: (item: any) => string | string[] | Record<string, boolean>
testItems?: any[] // <-- for test injection
}>()
const emit = defineEmits(['clicked', 'delete', 'loading-complete'])
@@ -36,11 +37,14 @@ const fetchItems = async () => {
loading.value = true
error.value = null
try {
const resp = await fetch(props.fetchUrl)
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
const data = await resp.json()
//console log all data
let itemList = data[props.itemKey || 'items'] || []
// Use testItems if provided
let itemList = props.testItems ?? []
if (!itemList.length) {
const resp = await fetch(props.fetchUrl)
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
const data = await resp.json()
itemList = data[props.itemKey || 'items'] || []
}
if (props.filterFn) itemList = itemList.filter(props.filterFn)
const initiallySelected: string[] = []
await Promise.all(
@@ -63,7 +67,6 @@ const fetchItems = async () => {
item.image_url = null
}
}
//for each item see it there is an 'assigned' field that is true. if so check the item's selectable checkbox
if (props.selectable && item.assigned === true) {
initiallySelected.push(item.id)
}
@@ -120,7 +123,7 @@ const handleDelete = (item: any) => {
@click.stop
/>
<button
v-if="props.deletable"
v-if="props.deletable && item.user_id"
class="delete-btn"
@click.stop="handleDelete(item)"
aria-label="Delete item"