bonuses: templates full-width list, drag-create modal, auto-evaluate, outstanding/completed states
This commit is contained in:
@@ -134,15 +134,12 @@
|
||||
}
|
||||
|
||||
function enhanceCreate() {
|
||||
return async ({ result, formData }: any) => {
|
||||
return async ({ result }: any) => {
|
||||
if (result.type === 'success') {
|
||||
showCreateModal = false
|
||||
const rec = result.data?.record
|
||||
if (rec) {
|
||||
templates = [rec as ChoreTemplate, ...templates]
|
||||
if (famStore.fam?.featureFlags?.optimisticUpdates) {
|
||||
famStore.applyRecord('chore_templates', rec, 'create')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,9 +158,6 @@
|
||||
customName: editCustomName || undefined,
|
||||
seasonIds: editSeasonIds.length > 0 ? editSeasonIds : [],
|
||||
} as AssignedChore
|
||||
if (famStore.fam?.featureFlags?.optimisticUpdates) {
|
||||
famStore.applyRecord('assigned_chores', assigned[idx], 'update')
|
||||
}
|
||||
}
|
||||
}
|
||||
closeEdit()
|
||||
@@ -175,27 +169,24 @@
|
||||
if (result.type === 'success' && editingTemplate) {
|
||||
const tid = editingTemplate!.id
|
||||
const idx = templates.findIndex((t: any) => t.id === tid)
|
||||
if (idx !== -1) {
|
||||
templates[idx] = {
|
||||
...templates[idx],
|
||||
name: editTplName,
|
||||
defaultFrequency: editTplFreq,
|
||||
defaultType: editTplType,
|
||||
defaultValue: editTplValue,
|
||||
} as ChoreTemplate
|
||||
}
|
||||
if (idx !== -1) {
|
||||
templates[idx] = {
|
||||
...templates[idx],
|
||||
name: editTplName,
|
||||
defaultFrequency: editTplFreq,
|
||||
defaultType: editTplType,
|
||||
defaultValue: editTplValue,
|
||||
} as ChoreTemplate
|
||||
assigned = assigned.map((a: any) =>
|
||||
a.templateId === tid
|
||||
? { ...a, frequency: editTplFreq, type: editTplType, value: editTplValue }
|
||||
: a
|
||||
) as AssignedChore[]
|
||||
if (famStore.fam?.featureFlags?.optimisticUpdates) {
|
||||
famStore.applyRecord('chore_templates', templates[idx], 'update')
|
||||
}
|
||||
closeEditTemplate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -239,7 +230,7 @@
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<button onclick={() => openEditTemplate(t)} class="edit-btn" title="Edit template">✎</button>
|
||||
<form method="POST" action="?/deleteTemplate" use:enhance={() => { return async ({ result, formData }) => { if (result.type === 'success') { const id = formData.get('id'); templates = templates.filter((t) => t.id !== id) as ChoreTemplate[]; if (famStore.fam?.featureFlags?.optimisticUpdates) { const rec = result.data.record; if (rec) famStore.applyRecord('chore_templates', { ...rec, id }, 'delete'); } } }; }}>
|
||||
<form method="POST" action="?/deleteTemplate" use:enhance={() => { return async ({ result, formData }) => { if (result.type === 'success') { const id = formData.get('id'); templates = templates.filter((t) => t.id !== id) as ChoreTemplate[]; } }; }}>
|
||||
<input type="hidden" name="id" value={t.id} />
|
||||
<button type="submit" class="del-btn" title="Delete template">×</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user