mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 01:12:16 +00:00
fix(planner): place edit and delete controls follow place_edit, not day_edit
With places set to "Trip owner" a member who may edit days still saw Edit and Delete on a place in the day plan's context menu, the inspector's action row, its inline rename and the phone timeline's edit circle, and every one of them ended in the server's 403. The day plan gates the two entries on place_edit (taking a place off the day stays a day right), the inspector drops its edit, delete and update handlers without the right the way the places pool already does, the phone timeline offers the pencil only with it, and openPlaceEditor and handleDeletePlace guard like their siblings. Closes #2446
This commit is contained in:
@@ -43,6 +43,7 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) {
|
||||
const { t, trip, can } = planner
|
||||
const canEdit = can('day_edit', trip)
|
||||
const editing = shell.mode === 'edit' && canEdit
|
||||
const canEditPlaces = can('place_edit', trip)
|
||||
// Per-segment travel mode (#1281): tap a connector → pick the leg's mode.
|
||||
const legMenu = useContextMenu()
|
||||
const modeIcon = (key: string) => (key === 'walking' ? Footprints : key.startsWith('plugin:') ? Zap : Car)
|
||||
@@ -202,7 +203,7 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) {
|
||||
reorder={reorderFor(row.item)}
|
||||
drag={dragFor(row)}
|
||||
onOpen={() => openPlace(row.assignment)}
|
||||
onEdit={() => tl.editAssignment(row.assignment)}
|
||||
onEdit={canEditPlaces ? () => tl.editAssignment(row.assignment) : undefined}
|
||||
onRemove={() => tl.removeAssignment(row.assignment)}
|
||||
/>
|
||||
{dayScheduleFor('assignment', row.assignment.id)}
|
||||
|
||||
@@ -124,7 +124,7 @@ export function PlaceRow({ assignment, fullPlace, linkedReservations, chrome, re
|
||||
reorder: ReactNode
|
||||
drag?: RowDrag
|
||||
onOpen: () => void
|
||||
onEdit: () => void
|
||||
onEdit?: () => void
|
||||
onRemove: () => void
|
||||
}) {
|
||||
const { t } = chrome
|
||||
@@ -210,9 +210,11 @@ export function PlaceRow({ assignment, fullPlace, linkedReservations, chrome, re
|
||||
</div>
|
||||
{chrome.editing && (
|
||||
<span className="flex flex-none items-center gap-1.5">
|
||||
<ActionCircle label={t('common.edit')} onClick={onEdit}>
|
||||
<Pencil size={14} strokeWidth={2} />
|
||||
</ActionCircle>
|
||||
{onEdit && (
|
||||
<ActionCircle label={t('common.edit')} onClick={onEdit}>
|
||||
<Pencil size={14} strokeWidth={2} />
|
||||
</ActionCircle>
|
||||
)}
|
||||
<ActionCircle label={t('planner.removeFromDay')} onClick={onRemove}>
|
||||
<X size={14} strokeWidth={2} />
|
||||
</ActionCircle>
|
||||
|
||||
Reference in New Issue
Block a user