added fixes for bug plan 1.0.6RC01
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 5m43s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 5m43s
This commit is contained in:
@@ -68,6 +68,7 @@ const childPenaltyListRef = ref()
|
||||
const childRewardListRef = ref()
|
||||
const childKindnessListRef = ref()
|
||||
const showPendingRewardDialog = ref(false)
|
||||
const lastEditedItem = ref<{ id: string; type: 'task' | 'reward' } | null>(null)
|
||||
|
||||
// Chore approve/reject
|
||||
const showChoreApproveDialog = ref(false)
|
||||
@@ -243,14 +244,20 @@ function handleChildModified(event: Event) {
|
||||
function handleOverrideSet(event: Event) {
|
||||
const payload = event.payload as ChildOverrideSetPayload
|
||||
if (child.value && payload.override.child_id === child.value.id) {
|
||||
// Refresh the appropriate list to show the override badge
|
||||
if (payload.override.entity_type === 'task') {
|
||||
childChoreListRef.value?.refresh()
|
||||
childKindnessListRef.value?.refresh()
|
||||
childPenaltyListRef.value?.refresh()
|
||||
} else if (payload.override.entity_type === 'reward') {
|
||||
childRewardListRef.value?.refresh()
|
||||
const editedId = lastEditedItem.value?.id ?? null
|
||||
const scrollAfterRefresh = (listRef: typeof childChoreListRef) => {
|
||||
listRef.value?.refresh().then(() => {
|
||||
if (editedId) listRef.value?.scrollToItem(editedId)
|
||||
})
|
||||
}
|
||||
if (payload.override.entity_type === 'task') {
|
||||
scrollAfterRefresh(childChoreListRef)
|
||||
scrollAfterRefresh(childKindnessListRef)
|
||||
scrollAfterRefresh(childPenaltyListRef)
|
||||
} else if (payload.override.entity_type === 'reward') {
|
||||
scrollAfterRefresh(childRewardListRef)
|
||||
}
|
||||
lastEditedItem.value = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,6 +431,7 @@ async function doExtendTime(item: ChildTask, e: MouseEvent) {
|
||||
alert(`Error: ${msg}`)
|
||||
return
|
||||
}
|
||||
childChoreListRef.value?.refresh()
|
||||
setTimeout(() => resetExpiryTimers(), 300)
|
||||
}
|
||||
|
||||
@@ -459,6 +467,25 @@ function isChoreInactive(item: ChildTask): boolean {
|
||||
return !isChoreScheduledToday(item) || isChoreExpired(item)
|
||||
}
|
||||
|
||||
// ── Sorting ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function parentChoreSortPriority(item: ChildTask): number {
|
||||
if (isChorePending(item)) return 0
|
||||
if (!isChoreScheduledToday(item)) return 4
|
||||
if (isChoreCompletedToday(item)) return 3
|
||||
if (isChoreExpired(item)) return 2
|
||||
return 1 // general / active
|
||||
}
|
||||
|
||||
function parentChoreSort(a: ChildTask, b: ChildTask): number {
|
||||
return parentChoreSortPriority(a) - parentChoreSortPriority(b)
|
||||
}
|
||||
|
||||
function parentRewardSort(a: RewardStatus, b: RewardStatus): number {
|
||||
if (a.redeeming !== b.redeeming) return a.redeeming ? -1 : 1
|
||||
return 0
|
||||
}
|
||||
|
||||
// ── Expiry timers ─────────────────────────────────────────────────────────────
|
||||
|
||||
function clearExpiryTimers() {
|
||||
@@ -556,6 +583,10 @@ async function saveOverride() {
|
||||
)
|
||||
|
||||
if (res.ok) {
|
||||
lastEditedItem.value = {
|
||||
id: overrideEditTarget.value.entity.id,
|
||||
type: overrideEditTarget.value.type,
|
||||
}
|
||||
showOverrideModal.value = false
|
||||
} else {
|
||||
const { msg } = parseErrorResponse(res)
|
||||
@@ -600,6 +631,8 @@ onMounted(async () => {
|
||||
|
||||
if (route.params.id) {
|
||||
const idParam = Array.isArray(route.params.id) ? route.params.id[0] : route.params.id
|
||||
const scrollToId = typeof route.query.scrollTo === 'string' ? route.query.scrollTo : null
|
||||
const entityType = typeof route.query.entityType === 'string' ? route.query.entityType : null
|
||||
if (idParam !== undefined) {
|
||||
const promise = fetchChildData(idParam)
|
||||
promise.then((data) => {
|
||||
@@ -609,6 +642,15 @@ onMounted(async () => {
|
||||
rewards.value = data.rewards || []
|
||||
}
|
||||
loading.value = false
|
||||
if (scrollToId) {
|
||||
setTimeout(() => {
|
||||
if (entityType === 'chore') {
|
||||
childChoreListRef.value?.scrollToItem(scrollToId)
|
||||
} else if (entityType === 'reward') {
|
||||
childRewardListRef.value?.scrollToItem(scrollToId)
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -765,25 +807,41 @@ const confirmTriggerReward = async () => {
|
||||
|
||||
function goToAssignTasks() {
|
||||
if (child.value?.id) {
|
||||
router.push({ name: 'ChoreAssignView', params: { id: child.value.id } })
|
||||
router.push({
|
||||
name: 'ChoreAssignView',
|
||||
params: { id: child.value.id },
|
||||
query: { name: child.value.name },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function goToAssignBadHabits() {
|
||||
if (child.value?.id) {
|
||||
router.push({ name: 'PenaltyAssignView', params: { id: child.value.id } })
|
||||
router.push({
|
||||
name: 'PenaltyAssignView',
|
||||
params: { id: child.value.id },
|
||||
query: { name: child.value.name },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function goToAssignKindness() {
|
||||
if (child.value?.id) {
|
||||
router.push({ name: 'KindnessAssignView', params: { id: child.value.id } })
|
||||
router.push({
|
||||
name: 'KindnessAssignView',
|
||||
params: { id: child.value.id },
|
||||
query: { name: child.value.name },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function goToAssignRewards() {
|
||||
if (child.value?.id) {
|
||||
router.push({ name: 'RewardAssignView', params: { id: child.value.id } })
|
||||
router.push({
|
||||
name: 'RewardAssignView',
|
||||
params: { id: child.value.id },
|
||||
query: { name: child.value.name },
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -816,6 +874,7 @@ function goToAssignRewards() {
|
||||
})
|
||||
"
|
||||
:filter-fn="(item) => item.type === 'chore'"
|
||||
:sort-fn="parentChoreSort"
|
||||
>
|
||||
<template #item="{ item }: { item: ChildTask }">
|
||||
<!-- Kebab menu -->
|
||||
@@ -983,6 +1042,7 @@ function goToAssignRewards() {
|
||||
@edit-item="(item) => handleEditItem(item, 'reward')"
|
||||
@item-ready="handleItemReady"
|
||||
:getItemClass="(item) => ({ reward: true })"
|
||||
:sort-fn="parentRewardSort"
|
||||
>
|
||||
<template #item="{ item }: { item: RewardStatus }">
|
||||
<div class="item-name">{{ item.name }}</div>
|
||||
|
||||
Reference in New Issue
Block a user