diff --git a/assets/js/hooks/Mapper/components/mapInterface/components/SystemLinkSignatureDialog/SystemLinkSignatureDialog.tsx b/assets/js/hooks/Mapper/components/mapInterface/components/SystemLinkSignatureDialog/SystemLinkSignatureDialog.tsx index ffd4212a..e30c7f81 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/components/SystemLinkSignatureDialog/SystemLinkSignatureDialog.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/components/SystemLinkSignatureDialog/SystemLinkSignatureDialog.tsx @@ -11,8 +11,9 @@ import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/ import { MULTI_DEST_WHS, ALL_DEST_TYPES_MAP, DEST_TYPES_MAP_MAP } from '@/hooks/Mapper/constants.ts'; import { SETTINGS_KEYS, SignatureSettingsType } from '@/hooks/Mapper/constants/signatures'; import { getSystemClassGroup } from '@/hooks/Mapper/components/map/helpers/getSystemClassGroup.ts'; -import { handleAutoBookmark } from '@/hooks/Mapper/helpers/bookmarkFormatHelper.ts'; +import { handleAutoBookmark, numberToLetters } from '@/hooks/Mapper/helpers/bookmarkFormatHelper.ts'; import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo'; +import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager.ts'; import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { CommandLinkSignatureToSystem, SignatureGroup, SystemSignature } from '@/hooks/Mapper/types'; import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts'; @@ -161,6 +162,77 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat }, }); + const systemAutoTag = userSettings?.system_auto_tag; + const systemCustomLabelName = userSettings?.system_custom_label_name; + + if (systemAutoTag || systemCustomLabelName) { + const info = parseSignatureCustomInfo(updatedSignature.custom_info); + const bIndex = info.bookmark_index ?? 0; + const startAtZero = userSettings?.bookmark_wormholes_start_at_zero; + const letter = numberToLetters(bIndex, startAtZero); + + const targetSystem = systems.find((s: any) => s.system_static_info?.solar_system_id === data.solar_system_target); + + if (targetSystem) { + if (systemAutoTag) { + let tagValue = ''; + switch (systemAutoTag) { + case 'index': + case 'chain_index': + tagValue = bIndex.toString(); + break; + case 'index_letter': + tagValue = letter; + break; + case 'chain_index_letters': + tagValue = info.bookmark_index_chained_letters === letter ? letter : bIndex.toString(); + break; + } + + if (tagValue) { + await outCommand({ + type: OutCommand.updateSystemTag, + data: { + system_id: targetSystem.id, + value: tagValue, + }, + }); + } + } + + if (systemCustomLabelName) { + let labelValue = ''; + switch (systemCustomLabelName) { + case 'index': + labelValue = bIndex.toString(); + break; + case 'index_letter': + labelValue = letter; + break; + case 'chain_index': + labelValue = info.bookmark_index_chained as string || bIndex.toString(); + break; + case 'chain_index_letters': + labelValue = info.bookmark_index_chained_letters as string || letter; + break; + } + + if (labelValue) { + const outLabel = new LabelsManager(targetSystem.labels ?? ''); + outLabel.updateCustomLabel(labelValue); + + await outCommand({ + type: OutCommand.updateSystemLabels, + data: { + system_id: targetSystem.id, + value: outLabel.toString(), + }, + }); + } + } + } + } + setVisible(false); }, [data, setVisible, userSettings, targetSystemClassGroup, systemSignatures, systems, wormholesData], diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/constants.ts b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/constants.ts index a9251f12..836e6b75 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/constants.ts +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/constants.ts @@ -10,8 +10,18 @@ export const DEFAULT_REMOTE_SETTINGS = { [UserSettingsRemoteProps.bookmark_wormholes_start_at_zero]: false, [UserSettingsRemoteProps.bookmark_auto_copy]: true, [UserSettingsRemoteProps.bookmark_auto_temp_name]: '', + [UserSettingsRemoteProps.system_auto_tag]: '', + [UserSettingsRemoteProps.system_custom_label_name]: '', }; +export const AUTO_FORMAT_OPTIONS = [ + { label: 'Disabled', value: '' }, + { label: 'Numeric index (1, 2, 3)', value: 'index' }, + { label: 'Letter index (A, B, C)', value: 'index_letter' }, + { label: 'Numeric chain (11, 12, 121)', value: 'chain_index' }, + { label: 'Letter chain (A, A1, A21)', value: 'chain_index_letters' }, +]; + export const UserSettingsRemoteList = [ UserSettingsRemoteProps.link_signature_on_splash, UserSettingsRemoteProps.select_on_spash, @@ -20,6 +30,8 @@ export const UserSettingsRemoteList = [ UserSettingsRemoteProps.bookmark_wormholes_start_at_zero, UserSettingsRemoteProps.bookmark_auto_copy, UserSettingsRemoteProps.bookmark_auto_temp_name, + UserSettingsRemoteProps.system_auto_tag, + UserSettingsRemoteProps.system_custom_label_name, ]; // export const COMMON_CHECKBOXES_PROPS: SettingsListItem[] = [ @@ -71,13 +83,19 @@ export const BOOKMARKS_SETTINGS_PROPS: SettingsListItem[] = [ prop: UserSettingsRemoteProps.bookmark_auto_temp_name, label: 'Auto-fill wormhole temporary name', type: 'dropdown', - options: [ - { label: 'Disabled', value: '' }, - { label: 'Numeric index (1, 2, 3)', value: 'index' }, - { label: 'Letter index (A, B, C)', value: 'index_letter' }, - { label: 'Numeric chain (11, 12, 121)', value: 'chain_index' }, - { label: 'Letter chain (A, A1, A21)', value: 'chain_index_letters' }, - ], + options: AUTO_FORMAT_OPTIONS, + }, + { + prop: UserSettingsRemoteProps.system_auto_tag, + label: 'Auto-tag jumped system', + type: 'dropdown', + options: AUTO_FORMAT_OPTIONS, + }, + { + prop: UserSettingsRemoteProps.system_custom_label_name, + label: 'Auto-label jumped system', + type: 'dropdown', + options: AUTO_FORMAT_OPTIONS, }, ]; diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/types.ts b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/types.ts index 37cae0d8..3fcd35ff 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/types.ts +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/types.ts @@ -8,6 +8,8 @@ export enum UserSettingsRemoteProps { bookmark_wormholes_start_at_zero = 'bookmark_wormholes_start_at_zero', bookmark_auto_copy = 'bookmark_auto_copy', bookmark_auto_temp_name = 'bookmark_auto_temp_name', + system_auto_tag = 'system_auto_tag', + system_custom_label_name = 'system_custom_label_name', } export type UserSettingsRemote = { @@ -18,6 +20,8 @@ export type UserSettingsRemote = { bookmark_wormholes_start_at_zero: boolean; bookmark_auto_copy: boolean; bookmark_auto_temp_name: string; + system_auto_tag: string; + system_custom_label_name: string; }; export type UserSettings = UserSettingsRemote & InterfaceStoredSettings; diff --git a/lib/wanderer_app/repositories/map_user_settings_repo.ex b/lib/wanderer_app/repositories/map_user_settings_repo.ex index 545daf06..6d023a5b 100644 --- a/lib/wanderer_app/repositories/map_user_settings_repo.ex +++ b/lib/wanderer_app/repositories/map_user_settings_repo.ex @@ -6,7 +6,9 @@ defmodule WandererApp.MapUserSettingsRepo do "link_signature_on_splash" => false, "delete_connection_with_sigs" => false, "primary_character_id" => nil, - "bookmark_name_format" => "" + "bookmark_name_format" => "", + "system_auto_tag" => "", + "system_custom_label_name" => "" } def get(map_id, user_id) do diff --git a/lib/wanderer_app_web/live/map/event_handlers/map_core_event_handler.ex b/lib/wanderer_app_web/live/map/event_handlers/map_core_event_handler.ex index e53199a2..acbd321c 100644 --- a/lib/wanderer_app_web/live/map/event_handlers/map_core_event_handler.ex +++ b/lib/wanderer_app_web/live/map/event_handlers/map_core_event_handler.ex @@ -239,7 +239,9 @@ defmodule WandererAppWeb.MapCoreEventHandler do "bookmark_name_format", "bookmark_wormholes_start_at_zero", "bookmark_auto_copy", - "bookmark_auto_temp_name" + "bookmark_auto_temp_name", + "system_auto_tag", + "system_custom_label_name" ]) |> Jason.encode!()