mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
feat(planner): bring the plan tab and every trip dialog into the new look
The Plan tab was the last trip tab still in the old design. It now reads like Bookings, Costs, Lists, Files and Collab, without losing a function: - Day plan: each day is a card with a head band (day tile with weather, stay and rental pills, a "+" menu for place, stay, transport, transit and note), rows with "..." menus, white badges and a white route bar. - Places column: add, search and filters in three rows, a show dropdown, category and rating filters, and a selection bar at the foot. - Place inspector, day details and the stay editor on the shared dialog frame; the place form in the editor look with the name in the head band. - Clicking a booking or transport anywhere on the plan opens the booking detail popup first; Edit leads to the editor. The popup is one host shared with the Bookings and Transports tabs. - Files and Collab dialogs, notes, polls, links and chat moved to the same frame; shared DialogShell and dialogParts hold the building blocks. - The map hover card shows the place photo and follows the theme. Every new and reworded string is translated into all locales, and a few older English leftovers (help center, cost split, import hints) with them. Phone screens keep their own look.
This commit is contained in:
@@ -868,7 +868,7 @@ describe('TodoListPanel — new task pane', () => {
|
||||
|
||||
await user.type(screen.getByPlaceholderText('Task name'), 'Pack bags');
|
||||
await user.type(screen.getByPlaceholderText('Description (optional)'), 'rain gear');
|
||||
await user.click(within(screen.getByRole('region', { name: 'New task' })).getByRole('button', { name: 'Add list' }));
|
||||
await user.click(within(screen.getByRole('dialog', { name: 'New task' })).getByRole('button', { name: 'Add list' }));
|
||||
await user.type(await screen.findByPlaceholderText('List name'), 'Prep ');
|
||||
await user.keyboard('{Enter}');
|
||||
await user.click(screen.getByRole('button', { name: 'P1' }));
|
||||
@@ -890,7 +890,7 @@ describe('TodoListPanel — new task pane', () => {
|
||||
const user = userEvent.setup();
|
||||
await openNew();
|
||||
|
||||
await user.click(within(screen.getByRole('region', { name: 'New task' })).getByRole('button', { name: 'Add list' }));
|
||||
await user.click(within(screen.getByRole('dialog', { name: 'New task' })).getByRole('button', { name: 'Add list' }));
|
||||
await user.type(await screen.findByPlaceholderText('List name'), 'Prep');
|
||||
await user.keyboard('{Escape}');
|
||||
|
||||
@@ -1122,7 +1122,7 @@ describe('TodoListPanel — remaining paths', () => {
|
||||
|
||||
rerender(<TodoListPanel tripId={1} items={[buildTodoItem({ id: 40, name: 'Plan route', checked: 0 })]} addItemSignal={1} />);
|
||||
await screen.findByText('Create task');
|
||||
await user.click(within(screen.getByRole('region', { name: 'New task' })).getByRole('button', { name: 'Add list' }));
|
||||
await user.click(within(screen.getByRole('dialog', { name: 'New task' })).getByRole('button', { name: 'Add list' }));
|
||||
input = await screen.findByPlaceholderText('List name');
|
||||
await user.type(input, 'Prep');
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Add' }));
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Fragment, useState, useEffect, type CSSProperties } from 'react'
|
||||
import { Fragment, useId, useState, useEffect, type CSSProperties } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
import { useCanDo } from '../../store/permissionsStore'
|
||||
import { useToast } from '../shared/Toast'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { Check, Plus, Flag, X, Calendar, User, AlertCircle, Inbox, CheckCheck, Trash2 } from 'lucide-react'
|
||||
import { Check, Plus, Flag, X, Calendar, User, AlertCircle, Inbox, CheckCheck, Trash2, ListPlus, ListTodo } from 'lucide-react'
|
||||
import type { TodoItem } from '../../types'
|
||||
|
||||
import { katColor, taskInputStyle, type FilterType, type Member, type TaskFieldValues } from './todoListModel'
|
||||
@@ -14,6 +14,7 @@ import TodoTaskFields from './TodoTaskFields'
|
||||
import { usePluginViewContributions, PluginCardFooter } from '../Plugins/PluginContributions'
|
||||
import EmptyState from '../shared/EmptyState'
|
||||
import NameDialog from '../shared/NameDialog'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
||||
|
||||
/** The card the list and the detail pane sit in, the packing list's category card. */
|
||||
const CARD: CSSProperties = {
|
||||
@@ -265,17 +266,24 @@ export default function TodoListPanel({ tripId, items, addItemSignal = 0 }: { tr
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isAddingNew && !selectedItem && createPortal(
|
||||
{isAddingNew && !selectedItem && !isMobile && (
|
||||
<NewTaskPane
|
||||
variant="dialog"
|
||||
tripId={tripId}
|
||||
categories={categories}
|
||||
members={members}
|
||||
defaultCategory={typeof filter === 'string' && categories.includes(filter) ? filter : null}
|
||||
onCreated={(id) => { setIsAddingNew(false); setSelectedId(id) }}
|
||||
onClose={() => setIsAddingNew(false)}
|
||||
/>
|
||||
)}
|
||||
{isAddingNew && !selectedItem && isMobile && createPortal(
|
||||
<div role="presentation" onClick={e => { if (e.target === e.currentTarget) setIsAddingNew(false) }}
|
||||
className="trek-modal-backdrop"
|
||||
style={isMobile
|
||||
? { position: 'fixed', inset: 0, zIndex: 1000, background: 'rgba(0,0,0,0.4)', display: 'flex', justifyContent: 'center', alignItems: 'flex-end', paddingBottom: 'var(--bottom-nav-h)' }
|
||||
: { position: 'fixed', inset: 0, zIndex: 1000, background: 'rgba(15,23,42,0.5)', display: 'flex', justifyContent: 'center', alignItems: 'flex-start', paddingTop: 'calc(var(--nav-h) + 60px)', paddingBottom: 40 }}>
|
||||
<div style={isMobile
|
||||
? { width: '100%', maxHeight: '85vh', display: 'flex' }
|
||||
: { width: 'min(520px, 92vw)', maxHeight: 'calc(100vh - var(--nav-h) - 120px)', display: 'flex', boxShadow: '0 20px 60px rgba(0,0,0,0.25)', borderRadius: 16 }}>
|
||||
style={{ position: 'fixed', inset: 0, zIndex: 1000, background: 'rgba(0,0,0,0.4)', display: 'flex', justifyContent: 'center', alignItems: 'flex-end', paddingBottom: 'var(--bottom-nav-h)' }}>
|
||||
<div style={{ width: '100%', maxHeight: '85vh', display: 'flex' }}>
|
||||
<NewTaskPane
|
||||
variant={isMobile ? 'sheet' : 'dialog'}
|
||||
variant="sheet"
|
||||
tripId={tripId}
|
||||
categories={categories}
|
||||
members={members}
|
||||
@@ -291,6 +299,7 @@ export default function TodoListPanel({ tripId, items, addItemSignal = 0 }: { tr
|
||||
<NameDialog
|
||||
open={canEdit && addingCategory}
|
||||
title={t('todo.addCategory')}
|
||||
icon={ListPlus}
|
||||
placeholder={t('todo.newCategory')}
|
||||
confirmLabel={t('common.add')}
|
||||
value={newCategoryName}
|
||||
@@ -465,6 +474,11 @@ function NewTaskPane({ tripId, categories, members, defaultCategory, onCreated,
|
||||
setSaving(false)
|
||||
}
|
||||
|
||||
if (variant === 'dialog') return (
|
||||
<NewTaskDialog name={name} onName={setName} fields={fields} onFields={patch => setFields(f => ({ ...f, ...patch }))}
|
||||
categories={categories} members={members} saving={saving} onCreate={create} onClose={onClose} />
|
||||
)
|
||||
|
||||
return (
|
||||
<div role="region" aria-label={t('todo.newItem')} style={paneFrame(variant)}>
|
||||
<PaneHead title={t('todo.newItem')} onClose={onClose} />
|
||||
@@ -485,3 +499,48 @@ function NewTaskPane({ tripId, categories, members, defaultCategory, onCreated,
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** The new task on the desktop: named in the head band, its fields below, created from the footer. */
|
||||
function NewTaskDialog({ name, onName, fields, onFields, categories, members, saving, onCreate, onClose }: {
|
||||
name: string; onName: (name: string) => void
|
||||
fields: TaskFieldValues; onFields: (patch: Partial<TaskFieldValues>) => void
|
||||
categories: string[]; members: Member[]
|
||||
saving: boolean; onCreate: () => void; onClose: () => void
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const labelId = useId()
|
||||
return (
|
||||
<DialogShell
|
||||
onClose={onClose}
|
||||
labelledBy={labelId}
|
||||
header={(
|
||||
<DialogHeader
|
||||
tile={<DialogTile><ListTodo size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={onClose}
|
||||
eyebrow={t('todo.newItem')}
|
||||
titleInput={{
|
||||
value: name,
|
||||
onChange: onName,
|
||||
label: t('todo.newItem'),
|
||||
placeholder: t('todo.namePlaceholder'),
|
||||
autoFocus: true,
|
||||
onKeyDown: e => { if (e.key === 'Enter' && name.trim()) onCreate() },
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
footer={(
|
||||
<DialogFooter>
|
||||
<FooterSpacer />
|
||||
<DialogButton onClick={onClose}>{t('common.cancel')}</DialogButton>
|
||||
<DialogButton variant="primary" onClick={onCreate} disabled={!name.trim() || saving}>
|
||||
{saving ? '...' : t('todo.detail.create')}
|
||||
</DialogButton>
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
<TodoTaskFields values={fields} onChange={onFields} categories={categories} members={members} variant="dialog" />
|
||||
</DialogShell>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useState } from 'react'
|
||||
import { Flag, Plus, User } from 'lucide-react'
|
||||
import { Flag, ListPlus, Plus, User } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { avatarSrc } from '../../utils/avatarSrc'
|
||||
import CustomSelect from '../shared/CustomSelect'
|
||||
import { CustomDatePicker } from '../shared/CustomDateTimePicker'
|
||||
import NameDialog from '../shared/NameDialog'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { GRID_2, LABEL, TEXTAREA } from '../shared/dialogParts'
|
||||
import { PRIO_CONFIG, katColor, taskInputStyle, taskLabelClass, type Member, type TaskFieldValues } from './todoListModel'
|
||||
|
||||
interface TodoTaskFieldsProps {
|
||||
@@ -13,6 +15,8 @@ interface TodoTaskFieldsProps {
|
||||
categories: string[]
|
||||
members: Member[]
|
||||
canEdit?: boolean
|
||||
/** 'dialog' draws the fields like the planner's dialogs: small caps labels, list and due date side by side. */
|
||||
variant?: 'pane' | 'dialog'
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,11 +25,13 @@ interface TodoTaskFieldsProps {
|
||||
* segmented track, the list (a new one is named in a dialog), the due date and
|
||||
* who does it.
|
||||
*/
|
||||
export default function TodoTaskFields({ values, onChange, categories, members, canEdit = true }: TodoTaskFieldsProps) {
|
||||
export default function TodoTaskFields({ values, onChange, categories, members, canEdit = true, variant = 'pane' }: TodoTaskFieldsProps) {
|
||||
const { t } = useTranslation()
|
||||
const [namingList, setNamingList] = useState(false)
|
||||
const [listName, setListName] = useState('')
|
||||
const { desc, priority, category, dueDate, assignedUserId } = values
|
||||
const dialog = variant === 'dialog'
|
||||
const labelClass = dialog ? LABEL : taskLabelClass
|
||||
|
||||
const confirmList = () => {
|
||||
const name = listName.trim()
|
||||
@@ -35,17 +41,65 @@ export default function TodoTaskFields({ values, onChange, categories, members,
|
||||
setListName('')
|
||||
}
|
||||
|
||||
const listField = (
|
||||
<div>
|
||||
<label className={labelClass}>{t('todo.detail.category')}</label>
|
||||
<div style={{ display: 'flex', gap: 6 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<CustomSelect
|
||||
value={category}
|
||||
onChange={v => onChange({ category: String(v) })}
|
||||
options={[
|
||||
{ value: '', label: t('todo.noCategory') },
|
||||
...categories.map(c => ({
|
||||
value: c, label: c,
|
||||
icon: <span style={{ width: 8, height: 8, borderRadius: '50%', background: katColor(c, categories), display: 'inline-block' }} />,
|
||||
})),
|
||||
...(category && !categories.includes(category) ? [{
|
||||
value: category, label: `${category} (${t('todo.newCategoryLabel')})`,
|
||||
icon: <span style={{ width: 8, height: 8, borderRadius: '50%', background: katColor(category, categories), display: 'inline-block' }} />,
|
||||
}] : []),
|
||||
]}
|
||||
placeholder={t('todo.noCategory')}
|
||||
size="sm"
|
||||
disabled={!canEdit}
|
||||
/>
|
||||
</div>
|
||||
{canEdit && (
|
||||
<Tooltip label={t('todo.addCategory')}>
|
||||
<button type="button" onClick={() => setNamingList(true)} aria-label={t('todo.addCategory')}
|
||||
style={{ width: 36, flexShrink: 0, background: 'var(--bg-tertiary)', border: 'none', borderRadius: 10, cursor: 'pointer', color: 'var(--text-muted)', display: 'grid', placeItems: 'center' }}>
|
||||
<Plus size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
const dueField = (
|
||||
<div>
|
||||
<label className={labelClass}>{t('todo.detail.dueDate')}</label>
|
||||
<CustomDatePicker value={dueDate} onChange={v => onChange({ dueDate: v })} />
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<label className={taskLabelClass}>{t('todo.detail.description')}</label>
|
||||
<textarea value={desc} onChange={e => onChange({ desc: e.target.value })} disabled={!canEdit} rows={4}
|
||||
placeholder={t('todo.descriptionPlaceholder')}
|
||||
style={{ ...taskInputStyle, resize: 'vertical', minHeight: 84 }} />
|
||||
<label className={labelClass}>{t('todo.detail.description')}</label>
|
||||
{dialog ? (
|
||||
<textarea value={desc} onChange={e => onChange({ desc: e.target.value })} disabled={!canEdit} rows={3}
|
||||
placeholder={t('todo.descriptionPlaceholder')} className={TEXTAREA} />
|
||||
) : (
|
||||
<textarea value={desc} onChange={e => onChange({ desc: e.target.value })} disabled={!canEdit} rows={4}
|
||||
placeholder={t('todo.descriptionPlaceholder')}
|
||||
style={{ ...taskInputStyle, resize: 'vertical', minHeight: 84 }} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className={taskLabelClass}>{t('todo.detail.priority')}</label>
|
||||
<label className={labelClass}>{t('todo.detail.priority')}</label>
|
||||
<div style={{ display: 'flex', gap: 2, padding: 3, borderRadius: 11, background: 'var(--bg-tertiary)' }}>
|
||||
{[0, 1, 2, 3].map(p => {
|
||||
const cfg = PRIO_CONFIG[p]
|
||||
@@ -68,45 +122,10 @@ export default function TodoTaskFields({ values, onChange, categories, members,
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className={taskLabelClass}>{t('todo.detail.category')}</label>
|
||||
<div style={{ display: 'flex', gap: 6 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<CustomSelect
|
||||
value={category}
|
||||
onChange={v => onChange({ category: String(v) })}
|
||||
options={[
|
||||
{ value: '', label: t('todo.noCategory') },
|
||||
...categories.map(c => ({
|
||||
value: c, label: c,
|
||||
icon: <span style={{ width: 8, height: 8, borderRadius: '50%', background: katColor(c, categories), display: 'inline-block' }} />,
|
||||
})),
|
||||
...(category && !categories.includes(category) ? [{
|
||||
value: category, label: `${category} (${t('todo.newCategoryLabel')})`,
|
||||
icon: <span style={{ width: 8, height: 8, borderRadius: '50%', background: katColor(category, categories), display: 'inline-block' }} />,
|
||||
}] : []),
|
||||
]}
|
||||
placeholder={t('todo.noCategory')}
|
||||
size="sm"
|
||||
disabled={!canEdit}
|
||||
/>
|
||||
</div>
|
||||
{canEdit && (
|
||||
<button type="button" onClick={() => setNamingList(true)} title={t('todo.addCategory')} aria-label={t('todo.addCategory')}
|
||||
style={{ width: 36, flexShrink: 0, background: 'var(--bg-tertiary)', border: 'none', borderRadius: 10, cursor: 'pointer', color: 'var(--text-muted)', display: 'grid', placeItems: 'center' }}>
|
||||
<Plus size={14} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{dialog ? <div className={GRID_2}>{listField}{dueField}</div> : <>{listField}{dueField}</>}
|
||||
|
||||
<div>
|
||||
<label className={taskLabelClass}>{t('todo.detail.dueDate')}</label>
|
||||
<CustomDatePicker value={dueDate} onChange={v => onChange({ dueDate: v })} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className={taskLabelClass}>{t('todo.detail.assignedTo')}</label>
|
||||
<label className={labelClass}>{t('todo.detail.assignedTo')}</label>
|
||||
<CustomSelect
|
||||
value={String(assignedUserId ?? '')}
|
||||
onChange={v => onChange({ assignedUserId: v ? Number(v) : null })}
|
||||
@@ -133,6 +152,7 @@ export default function TodoTaskFields({ values, onChange, categories, members,
|
||||
<NameDialog
|
||||
open={namingList}
|
||||
title={t('todo.addCategory')}
|
||||
icon={ListPlus}
|
||||
placeholder={t('todo.newCategory')}
|
||||
confirmLabel={t('common.add')}
|
||||
value={listName}
|
||||
|
||||
Reference in New Issue
Block a user