Add subject options and redesign TV dashboard layout
Subject options: - New subject_options table (auto-created on startup) - SubjectOut now includes options list; all eager-loading chains updated - Admin: Options panel per subject with add, inline edit, and delete - WS broadcast and dashboard API include options in block subject data TV dashboard: - Three equal columns: Timer | Activities | Schedule - Activities column shows current subject's options in large readable text - Activities area has subject-colored border and tinted background - Subject name and label displayed correctly using embedded subject data Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
c12f07daa3
commit
c9441a9c9a
11 files changed
+375
-51
No files matched your search
@@ -61,25 +61,57 @@
|
||||
</form>
|
||||
|
||||
<div class="item-list">
|
||||
<div v-for="subject in subjects" :key="subject.id" class="item-row">
|
||||
<template v-if="editingSubject && editingSubject.id === subject.id">
|
||||
<input v-model="editingSubject.name" class="edit-input" required />
|
||||
<input v-model="editingSubject.icon" placeholder="Icon" maxlength="4" style="width:60px" class="edit-input" />
|
||||
<input v-model="editingSubject.color" type="color" title="Color" />
|
||||
<div class="item-actions">
|
||||
<button class="btn-sm btn-primary" @click="saveSubject">Save</button>
|
||||
<button class="btn-sm" @click="editingSubject = null">Cancel</button>
|
||||
<div v-for="subject in subjects" :key="subject.id" class="subject-block">
|
||||
<!-- Subject row -->
|
||||
<div class="item-row">
|
||||
<template v-if="editingSubject && editingSubject.id === subject.id">
|
||||
<input v-model="editingSubject.name" class="edit-input" required />
|
||||
<input v-model="editingSubject.icon" placeholder="Icon" maxlength="4" style="width:60px" class="edit-input" />
|
||||
<input v-model="editingSubject.color" type="color" title="Color" />
|
||||
<div class="item-actions">
|
||||
<button class="btn-sm btn-primary" @click="saveSubject">Save</button>
|
||||
<button class="btn-sm" @click="editingSubject = null">Cancel</button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="item-color" :style="{ background: subject.color }"></div>
|
||||
<span class="item-icon">{{ subject.icon }}</span>
|
||||
<span class="item-name">{{ subject.name }}</span>
|
||||
<div class="item-actions">
|
||||
<button class="btn-sm" @click="startEditSubject(subject)">Edit</button>
|
||||
<button
|
||||
class="btn-sm"
|
||||
@click="expandedSubject = expandedSubject === subject.id ? null : subject.id"
|
||||
>{{ expandedSubject === subject.id ? 'Hide Options' : 'Options' }}</button>
|
||||
<button class="btn-sm btn-danger" @click="deleteSubject(subject.id)">Delete</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Options panel -->
|
||||
<div v-if="expandedSubject === subject.id" class="options-panel">
|
||||
<div class="option-list">
|
||||
<template v-for="opt in subject.options" :key="opt.id">
|
||||
<div v-if="editingOption && editingOption.id === opt.id" class="option-edit-row">
|
||||
<input v-model="editingOption.text" class="option-input" @keyup.enter="saveOption(subject.id)" />
|
||||
<button class="btn-sm btn-primary" @click="saveOption(subject.id)">Save</button>
|
||||
<button class="btn-sm" @click="editingOption = null">Cancel</button>
|
||||
</div>
|
||||
<div v-else class="option-row">
|
||||
<span class="option-text">{{ opt.text }}</span>
|
||||
<div class="item-actions">
|
||||
<button class="btn-sm" @click="startEditOption(opt)">Edit</button>
|
||||
<button class="btn-sm btn-danger" @click="deleteOption(subject.id, opt.id)">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="subject.options.length === 0" class="empty-small">No options yet.</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="item-color" :style="{ background: subject.color }"></div>
|
||||
<span class="item-icon">{{ subject.icon }}</span>
|
||||
<span class="item-name">{{ subject.name }}</span>
|
||||
<div class="item-actions">
|
||||
<button class="btn-sm" @click="startEditSubject(subject)">Edit</button>
|
||||
<button class="btn-sm btn-danger" @click="deleteSubject(subject.id)">Delete</button>
|
||||
</div>
|
||||
</template>
|
||||
<form class="option-add-row" @submit.prevent="addOption(subject.id)">
|
||||
<input v-model="newOptionText" placeholder="Add an option..." class="option-input" required />
|
||||
<button type="submit" class="btn-primary btn-sm">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="subjects.length === 0" class="empty-small">No subjects added yet.</div>
|
||||
</div>
|
||||
@@ -269,6 +301,11 @@ async function deleteChild(id) {
|
||||
const showSubjectForm = ref(false)
|
||||
const newSubject = ref({ name: '', icon: '📚', color: '#10B981' })
|
||||
const editingSubject = ref(null)
|
||||
const expandedSubject = ref(null)
|
||||
|
||||
// Subject options
|
||||
const newOptionText = ref('')
|
||||
const editingOption = ref(null)
|
||||
|
||||
async function loadSubjects() {
|
||||
const res = await api.get('/api/subjects')
|
||||
@@ -305,6 +342,32 @@ async function deleteSubject(id) {
|
||||
}
|
||||
}
|
||||
|
||||
async function addOption(subjectId) {
|
||||
await api.post(`/api/subjects/${subjectId}/options`, {
|
||||
text: newOptionText.value,
|
||||
order_index: subjects.value.find(s => s.id === subjectId)?.options.length || 0,
|
||||
})
|
||||
newOptionText.value = ''
|
||||
await loadSubjects()
|
||||
}
|
||||
|
||||
function startEditOption(opt) {
|
||||
editingOption.value = { id: opt.id, text: opt.text }
|
||||
}
|
||||
|
||||
async function saveOption(subjectId) {
|
||||
await api.patch(`/api/subjects/${subjectId}/options/${editingOption.value.id}`, {
|
||||
text: editingOption.value.text,
|
||||
})
|
||||
editingOption.value = null
|
||||
await loadSubjects()
|
||||
}
|
||||
|
||||
async function deleteOption(subjectId, optionId) {
|
||||
await api.delete(`/api/subjects/${subjectId}/options/${optionId}`)
|
||||
await loadSubjects()
|
||||
}
|
||||
|
||||
// Schedules
|
||||
const templates = ref([])
|
||||
const showCreateForm = ref(false)
|
||||
@@ -535,6 +598,57 @@ h2 { font-size: 1.1rem; color: #94a3b8; text-transform: uppercase; letter-spacin
|
||||
.edit-block-form span { color: #64748b; }
|
||||
.edit-block-form { border: 1px solid #4f46e5; }
|
||||
|
||||
.subject-block { display: flex; flex-direction: column; gap: 0; }
|
||||
|
||||
.options-panel {
|
||||
background: #0f172a;
|
||||
border-radius: 0 0 0.75rem 0.75rem;
|
||||
padding: 0.75rem 1rem;
|
||||
margin-top: -0.5rem;
|
||||
border: 1px solid #1e293b;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.option-list { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
|
||||
|
||||
.option-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
background: #1e293b;
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
|
||||
.option-text { flex: 1; font-size: 0.9rem; }
|
||||
|
||||
.option-edit-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
background: #1e293b;
|
||||
border: 1px solid #4f46e5;
|
||||
border-radius: 0.4rem;
|
||||
}
|
||||
|
||||
.option-input {
|
||||
flex: 1;
|
||||
padding: 0.4rem 0.6rem;
|
||||
background: #0f172a;
|
||||
border: 1px solid #334155;
|
||||
border-radius: 0.4rem;
|
||||
color: #f1f5f9;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.option-add-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.option-add-row .option-input { background: #1e293b; }
|
||||
|
||||
.empty-small { color: #64748b; font-size: 0.9rem; padding: 1rem 0; }
|
||||
|
||||
.btn-primary {
|
||||
|
||||
Reference in new issue
Block a user