Refactor and enhance various components and tests
All checks were successful
Chore App Build and Push Docker Images / build-and-push (push) Successful in 1m23s
All checks were successful
Chore App Build and Push Docker Images / build-and-push (push) Successful in 1m23s
- Remove OverrideEditModal.spec.ts test file. - Update ParentPinSetup.vue to handle Enter key for code and PIN inputs. - Modify ChildEditView.vue to add maxlength for age input. - Enhance ChildView.vue with reward confirmation and cancellation dialogs. - Update ParentView.vue to handle pending rewards and confirm edits. - Revise PendingRewardDialog.vue to accept a dynamic message prop. - Expand ChildView.spec.ts to cover reward dialog interactions. - Add tests for ParentView.vue to validate pending reward handling. - Update UserProfile.vue to simplify button styles. - Adjust RewardView.vue to improve delete confirmation handling. - Modify ChildrenListView.vue to clarify child creation instructions. - Refactor EntityEditForm.vue to improve input handling and focus management. - Enhance ItemList.vue to support item selection. - Update LoginButton.vue to focus PIN input on error. - Change ScrollingList.vue empty state color for better visibility. - Remove capture attribute from ImagePicker.vue file input. - Update router/index.ts to redirect logged-in users from auth routes. - Add authGuard.spec.ts to test router authentication logic.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
||||
import ModalDialog from '../shared/ModalDialog.vue'
|
||||
import PendingRewardDialog from './PendingRewardDialog.vue'
|
||||
import TaskConfirmDialog from './TaskConfirmDialog.vue'
|
||||
@@ -52,6 +52,9 @@ const overrideEditTarget = ref<{ entity: Task | Reward; type: 'task' | 'reward'
|
||||
const overrideCustomValue = ref(0)
|
||||
const isOverrideValid = ref(true)
|
||||
const readyItemId = ref<string | null>(null)
|
||||
const pendingEditOverrideTarget = ref<{ entity: Task | Reward; type: 'task' | 'reward' } | null>(
|
||||
null,
|
||||
)
|
||||
|
||||
function handleItemReady(itemId: string) {
|
||||
readyItemId.value = itemId
|
||||
@@ -214,6 +217,12 @@ function handleOverrideDeleted(event: Event) {
|
||||
}
|
||||
|
||||
function handleEditItem(item: Task | Reward, type: 'task' | 'reward') {
|
||||
// If editing a pending reward, warn first
|
||||
if (type === 'reward' && (item as any).redeeming) {
|
||||
pendingEditOverrideTarget.value = { entity: item, type }
|
||||
showPendingRewardDialog.value = true
|
||||
return
|
||||
}
|
||||
overrideEditTarget.value = { entity: item, type }
|
||||
const defaultValue = type === 'task' ? (item as Task).points : (item as Reward).cost
|
||||
overrideCustomValue.value = item.custom_value ?? defaultValue
|
||||
@@ -221,11 +230,34 @@ function handleEditItem(item: Task | Reward, type: 'task' | 'reward') {
|
||||
showOverrideModal.value = true
|
||||
}
|
||||
|
||||
async function confirmPendingRewardAndEdit() {
|
||||
if (!pendingEditOverrideTarget.value) return
|
||||
const item = pendingEditOverrideTarget.value.entity as any
|
||||
await cancelRewardById(item.id)
|
||||
showPendingRewardDialog.value = false
|
||||
const target = pendingEditOverrideTarget.value
|
||||
pendingEditOverrideTarget.value = null
|
||||
// Open override modal directly, bypassing the redeeming check
|
||||
overrideEditTarget.value = target
|
||||
const defaultValue =
|
||||
target.type === 'task' ? (target.entity as Task).points : (target.entity as Reward).cost
|
||||
overrideCustomValue.value = target.entity.custom_value ?? defaultValue
|
||||
validateOverrideInput()
|
||||
showOverrideModal.value = true
|
||||
}
|
||||
|
||||
function validateOverrideInput() {
|
||||
const val = overrideCustomValue.value
|
||||
isOverrideValid.value = typeof val === 'number' && val >= 0 && val <= 10000
|
||||
}
|
||||
|
||||
watch(showOverrideModal, async (newVal) => {
|
||||
if (newVal) {
|
||||
await nextTick()
|
||||
document.getElementById('custom-value')?.focus()
|
||||
}
|
||||
})
|
||||
|
||||
async function saveOverride() {
|
||||
if (!isOverrideValid.value || !overrideEditTarget.value || !child.value) return
|
||||
|
||||
@@ -549,8 +581,18 @@ function goToAssignRewards() {
|
||||
<!-- Pending Reward Dialog -->
|
||||
<PendingRewardDialog
|
||||
v-if="showPendingRewardDialog"
|
||||
@confirm="cancelPendingReward"
|
||||
@cancel="showPendingRewardDialog = false"
|
||||
:message="
|
||||
pendingEditOverrideTarget
|
||||
? 'This reward is currently pending. Changing its cost will cancel the pending request. Would you like to proceed?'
|
||||
: 'A reward is currently pending. It will be cancelled when a chore or penalty is triggered. Would you like to proceed?'
|
||||
"
|
||||
@confirm="pendingEditOverrideTarget ? confirmPendingRewardAndEdit() : cancelPendingReward()"
|
||||
@cancel="
|
||||
() => {
|
||||
showPendingRewardDialog = false
|
||||
pendingEditOverrideTarget = null
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
||||
<!-- Override Edit Modal -->
|
||||
|
||||
Reference in New Issue
Block a user