mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
feat: quality of life sweep from the feature discussions
Small requests from the discussions, each built end to end: planner and map (cycling mode, date first headings, clear a day, stay times per day, off-route stops, map lock, compact unplanned markers, pending stays, cable car, transit quick picks), places (location filter, category from OSM, open in maps, geo: link, image from an attachment, enrichment on file import, places near a pin, place name language, Amap first in China), lists and costs (packed counter, inherited sharing, Markdown to-dos, payment notes, bookings CSV, my plan PDF), sharing (unplanned places, travel only, without photos), journey (photo zoom, drafts, photo order, trip suggestion, day jump), atlas (region counter, region bucket list, places per country), vacay half company holidays, studio copy and paste plus the book's own layouts, and RESTORE_FROM_BACKUP for a first start restore.
This commit is contained in:
@@ -14,6 +14,27 @@ export interface AssignmentTimes {
|
||||
}
|
||||
|
||||
export const assignmentRepo = {
|
||||
/**
|
||||
* Empties a day (#2470). Offline the cached day loses its places right away and the
|
||||
* clear waits in the queue, where the server applies it to whatever the day holds on
|
||||
* replay, so a place added meanwhile by someone else goes with the rest.
|
||||
*/
|
||||
async clearDay(tripId: number | string, dayId: number): Promise<void> {
|
||||
if (!isEffectivelyOffline()) {
|
||||
await assignmentsApi.clearDay(tripId, dayId)
|
||||
await offlineDb.days.where('id').equals(dayId).modify(day => { day.assignments = [] })
|
||||
return
|
||||
}
|
||||
await offlineDb.transaction('rw', offlineDb.days, offlineDb.mutationQueue, async () => {
|
||||
await mutationQueue.enqueue({
|
||||
id: generateUUID(), tripId: Number(tripId), method: 'DELETE',
|
||||
url: `/trips/${tripId}/days/${dayId}/assignments`,
|
||||
body: undefined, resource: 'dayAssignments', entityId: dayId,
|
||||
})
|
||||
await offlineDb.days.where('id').equals(dayId).modify(day => { day.assignments = [] })
|
||||
})
|
||||
},
|
||||
|
||||
async setEndDay(tripId: number | string, assignment: Assignment, endDay: boolean): Promise<Assignment> {
|
||||
if (!isEffectivelyOffline()) {
|
||||
const saved = await saveAssignmentEndDay(tripId, assignment.id, { end_day: endDay })
|
||||
@@ -32,6 +53,25 @@ export const assignmentRepo = {
|
||||
return updated
|
||||
},
|
||||
|
||||
/** Takes a stop out of the day's route or puts it back (#2532), offline too. */
|
||||
async setRouteExcluded(tripId: number | string, assignment: Assignment, excluded: boolean): Promise<Assignment> {
|
||||
if (!isEffectivelyOffline()) {
|
||||
const saved = assignmentSchema.parse((await assignmentsApi.setRouteExcluded(tripId, assignment.id, excluded)).assignment)
|
||||
await cacheAssignment(saved)
|
||||
return saved
|
||||
}
|
||||
const updated = { ...assignment, route_excluded: excluded }
|
||||
await offlineDb.transaction('rw', offlineDb.days, offlineDb.mutationQueue, async () => {
|
||||
await mutationQueue.enqueue({
|
||||
id: generateUUID(), tripId: Number(tripId), method: 'PUT',
|
||||
url: `/trips/${tripId}/assignments/${assignment.id}/route`,
|
||||
body: { excluded }, resource: 'assignments', entityId: assignment.id,
|
||||
})
|
||||
await cacheAssignment(updated)
|
||||
})
|
||||
return updated
|
||||
},
|
||||
|
||||
/**
|
||||
* A visit's own Start and End, the pair the time route takes.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user