Add settings page and configurable network map types.
Let users define sector/circle labels and geometry per map type, choose a type when creating maps, and sync types through local backup and API migrations. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { localDb, DEFAULT_MAP_NAME } from '../db/localDb'
|
||||
import { generateId } from '../../lib/uuid'
|
||||
import { localNetworkMapTypeRepository } from './networkMapTypeRepository.local'
|
||||
|
||||
function nowIso() {
|
||||
return new Date().toISOString()
|
||||
@@ -9,6 +10,7 @@ function withDefaults(payload = {}) {
|
||||
return {
|
||||
name: '',
|
||||
description: '',
|
||||
mapTypeId: payload.mapTypeId || null,
|
||||
workspaceId: 'personal',
|
||||
...payload,
|
||||
}
|
||||
@@ -40,12 +42,14 @@ async function ensureDefaultMap() {
|
||||
const active = all.filter((m) => !m.deletedAt)
|
||||
if (active.length) return active.sort((a, b) => a.name.localeCompare(b.name, 'ru'))[0]
|
||||
|
||||
const defaultType = await localNetworkMapTypeRepository.getDefault()
|
||||
const ts = nowIso()
|
||||
const id = generateId()
|
||||
await localDb.networkMaps.put({
|
||||
id,
|
||||
name: DEFAULT_MAP_NAME,
|
||||
description: '',
|
||||
mapTypeId: defaultType?.id || null,
|
||||
workspaceId: 'personal',
|
||||
version: 1,
|
||||
createdAt: ts,
|
||||
@@ -75,8 +79,10 @@ export const localNetworkMapRepository = {
|
||||
},
|
||||
|
||||
async create(payload) {
|
||||
const defaultType = await localNetworkMapTypeRepository.getDefault()
|
||||
const ts = nowIso()
|
||||
const record = withDefaults(payload)
|
||||
if (!record.mapTypeId) record.mapTypeId = defaultType?.id || null
|
||||
const id = generateId()
|
||||
await localDb.networkMaps.put({
|
||||
...record,
|
||||
|
||||
Reference in New Issue
Block a user