mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
fix(Core): Fixed modals auto-save on Enter.
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
import { Dialog } from 'primereact/dialog';
|
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
|
||||||
import { useCallback, useRef, useState } from 'react';
|
|
||||||
import { IconField } from 'primereact/iconfield';
|
|
||||||
import { AutoComplete } from 'primereact/autocomplete';
|
|
||||||
import { OutCommand, SearchSystemItem } from '@/hooks/Mapper/types';
|
|
||||||
import { SystemViewStandalone, WdButton, WHClassView, WHEffectView } from '@/hooks/Mapper/components/ui-kit';
|
import { SystemViewStandalone, WdButton, WHClassView, WHEffectView } from '@/hooks/Mapper/components/ui-kit';
|
||||||
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
|
import { OutCommand, SearchSystemItem } from '@/hooks/Mapper/types';
|
||||||
|
import { AutoComplete } from 'primereact/autocomplete';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { IconField } from 'primereact/iconfield';
|
||||||
|
import { useCallback, useRef, useState } from 'react';
|
||||||
import classes from './AddSystemDialog.module.scss';
|
import classes from './AddSystemDialog.module.scss';
|
||||||
|
|
||||||
import clsx from 'clsx';
|
|
||||||
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
|
import { isWormholeSpace } from '@/hooks/Mapper/components/map/helpers/isWormholeSpace.ts';
|
||||||
import { sortWHClasses } from '@/hooks/Mapper/helpers';
|
import { sortWHClasses } from '@/hooks/Mapper/helpers';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
export type SearchOnSubmitCallback = (item: SearchSystemItem) => void;
|
export type SearchOnSubmitCallback = (item: SearchSystemItem) => void;
|
||||||
|
|
||||||
@@ -115,90 +115,93 @@ export const AddSystemDialog = ({
|
|||||||
setVisible(false);
|
setVisible(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col gap-3 px-1.5">
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="flex flex-col gap-2 py-3.5">
|
<div className="flex flex-col gap-3 px-1.5">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-2 py-3.5">
|
||||||
<IconField>
|
<div className="flex flex-col gap-1">
|
||||||
<AutoComplete
|
<IconField>
|
||||||
ref={inputRef}
|
<AutoComplete
|
||||||
multiple
|
ref={inputRef}
|
||||||
showEmptyMessage
|
multiple
|
||||||
scrollHeight="300px"
|
showEmptyMessage
|
||||||
value={selectedItem}
|
scrollHeight="300px"
|
||||||
suggestions={filteredItems}
|
value={selectedItem}
|
||||||
completeMethod={searchItems}
|
suggestions={filteredItems}
|
||||||
onChange={e => {
|
completeMethod={searchItems}
|
||||||
setSelectedItem(e.value.length < 2 ? e.value : [e.value[e.value.length - 1]]);
|
onChange={e => {
|
||||||
}}
|
setSelectedItem(e.value.length < 2 ? e.value : [e.value[e.value.length - 1]]);
|
||||||
emptyMessage="Not found any system..."
|
}}
|
||||||
placeholder="Type here..."
|
emptyMessage="Not found any system..."
|
||||||
field="label"
|
placeholder="Type here..."
|
||||||
id="value"
|
field="label"
|
||||||
className="w-full"
|
id="value"
|
||||||
itemTemplate={(item: SearchSystemItem) => {
|
className="w-full"
|
||||||
const { security, system_class, effect_power, effect_name, statics } = item.system_static_info;
|
itemTemplate={(item: SearchSystemItem) => {
|
||||||
const sortedStatics = sortWHClasses(wormholesData, statics);
|
const { security, system_class, effect_power, effect_name, statics } = item.system_static_info;
|
||||||
const isWH = isWormholeSpace(system_class);
|
const sortedStatics = sortWHClasses(wormholesData, statics);
|
||||||
|
const isWH = isWormholeSpace(system_class);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx('flex gap-1.5', classes.SearchItem)}>
|
<div className={clsx('flex gap-1.5', classes.SearchItem)}>
|
||||||
<SystemViewStandalone
|
<SystemViewStandalone
|
||||||
security={security}
|
security={security}
|
||||||
system_class={system_class}
|
system_class={system_class}
|
||||||
solar_system_id={item.value}
|
solar_system_id={item.value}
|
||||||
class_title={item.class_title}
|
class_title={item.class_title}
|
||||||
solar_system_name={item.label}
|
solar_system_name={item.label}
|
||||||
region_name={item.region_name}
|
region_name={item.region_name}
|
||||||
/>
|
|
||||||
|
|
||||||
{effect_name && isWH && (
|
|
||||||
<WHEffectView
|
|
||||||
effectName={effect_name}
|
|
||||||
effectPower={effect_power}
|
|
||||||
className={classes.SearchItemEffect}
|
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
{isWH && (
|
{effect_name && isWH && (
|
||||||
<div className="flex gap-1 grow justify-between">
|
<WHEffectView
|
||||||
<div></div>
|
effectName={effect_name}
|
||||||
<div className="flex gap-1">
|
effectPower={effect_power}
|
||||||
{sortedStatics.map(x => (
|
className={classes.SearchItemEffect}
|
||||||
<WHClassView key={x} whClassName={x} />
|
/>
|
||||||
))}
|
)}
|
||||||
|
|
||||||
|
{isWH && (
|
||||||
|
<div className="flex gap-1 grow justify-between">
|
||||||
|
<div></div>
|
||||||
|
<div className="flex gap-1">
|
||||||
|
{sortedStatics.map(x => (
|
||||||
|
<WHClassView key={x} whClassName={x} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
}}
|
||||||
}}
|
selectedItemTemplate={(item: SearchSystemItem) => (
|
||||||
selectedItemTemplate={(item: SearchSystemItem) => (
|
<SystemViewStandalone
|
||||||
<SystemViewStandalone
|
security={item.system_static_info.security}
|
||||||
security={item.system_static_info.security}
|
system_class={item.system_static_info.system_class}
|
||||||
system_class={item.system_static_info.system_class}
|
solar_system_id={item.value}
|
||||||
solar_system_id={item.value}
|
class_title={item.class_title}
|
||||||
class_title={item.class_title}
|
solar_system_name={item.label}
|
||||||
solar_system_name={item.label}
|
region_name={item.region_name}
|
||||||
region_name={item.region_name}
|
/>
|
||||||
/>
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
</IconField>
|
||||||
</IconField>
|
|
||||||
|
|
||||||
<span className="text-[12px] text-stone-400 ml-1">*to search type at least 2 symbols.</span>
|
<span className="text-[12px] text-stone-400 ml-1">*to search type at least 2 symbols.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-2 justify-end">
|
||||||
|
<WdButton
|
||||||
|
type="submit"
|
||||||
|
onClick={handleSubmit}
|
||||||
|
outlined
|
||||||
|
disabled={!selectedItem || selectedItem.length !== 1}
|
||||||
|
size="small"
|
||||||
|
label="Submit"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
<div className="flex gap-2 justify-end">
|
|
||||||
<WdButton
|
|
||||||
onClick={handleSubmit}
|
|
||||||
outlined
|
|
||||||
disabled={!selectedItem || selectedItem.length !== 1}
|
|
||||||
size="small"
|
|
||||||
label="Submit"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { InputText } from 'primereact/inputtext';
|
import { TooltipPosition, WdButton, WdImageSize, WdImgButton } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { Dialog } from 'primereact/dialog';
|
|
||||||
import { getSystemById } from '@/hooks/Mapper/helpers';
|
import { getSystemById } from '@/hooks/Mapper/helpers';
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
||||||
import { OutCommand } from '@/hooks/Mapper/types';
|
import { OutCommand } from '@/hooks/Mapper/types';
|
||||||
import { IconField } from 'primereact/iconfield';
|
|
||||||
import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager.ts';
|
import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager.ts';
|
||||||
import { TooltipPosition, WdButton, WdImageSize, WdImgButton } from '@/hooks/Mapper/components/ui-kit';
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { IconField } from 'primereact/iconfield';
|
||||||
|
import { InputText } from 'primereact/inputtext';
|
||||||
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
interface SystemCustomLabelDialog {
|
interface SystemCustomLabelDialog {
|
||||||
systemId: string;
|
systemId: string;
|
||||||
@@ -125,7 +125,7 @@ export const SystemCustomLabelDialog = ({ systemId, visible, setVisible }: Syste
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-2 justify-end">
|
<div className="flex gap-2 justify-end">
|
||||||
<WdButton onClick={handleSave} outlined size="small" label="Save"></WdButton>
|
<WdButton type="submit" onClick={handleSave} outlined size="small" label="Save"></WdButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { InputTextarea } from 'primereact/inputtextarea';
|
import { SystemView, WdButton } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { Dialog } from 'primereact/dialog';
|
|
||||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||||
import { useCallback, useRef, useState } from 'react';
|
|
||||||
import { OutCommand } from '@/hooks/Mapper/types';
|
import { OutCommand } from '@/hooks/Mapper/types';
|
||||||
import { PingType } from '@/hooks/Mapper/types/ping.ts';
|
import { PingType } from '@/hooks/Mapper/types/ping.ts';
|
||||||
import { SystemView, WdButton } from '@/hooks/Mapper/components/ui-kit';
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { InputTextarea } from 'primereact/inputtextarea';
|
||||||
|
import { useCallback, useRef, useState } from 'react';
|
||||||
|
|
||||||
const PING_TITLES = {
|
const PING_TITLES = {
|
||||||
[PingType.Rally]: 'RALLY',
|
[PingType.Rally]: 'RALLY',
|
||||||
@@ -62,7 +62,7 @@ export const SystemPingDialog = ({ systemId, type, visible, setVisible }: System
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
draggable={false}
|
draggable={true}
|
||||||
style={{ width: '450px' }}
|
style={{ width: '450px' }}
|
||||||
onShow={onShow}
|
onShow={onShow}
|
||||||
onHide={() => {
|
onHide={() => {
|
||||||
@@ -91,7 +91,7 @@ export const SystemPingDialog = ({ systemId, type, visible, setVisible }: System
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-2 justify-end">
|
<div className="flex gap-2 justify-end">
|
||||||
<WdButton onClick={handleSave} size="small" severity="danger" label="Ping!" />
|
<WdButton type="submit" onClick={handleSave} size="small" severity="danger" label="Ping!" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Dialog } from 'primereact/dialog';
|
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
||||||
import { useRouteProvider } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx';
|
import { useRouteProvider } from '@/hooks/Mapper/components/mapInterface/widgets/RoutesWidget/RoutesProvider.tsx';
|
||||||
import { PrettySwitchbox } from '@/hooks/Mapper/components/mapRootContent/components/MapSettings/components';
|
import { PrettySwitchbox } from '@/hooks/Mapper/components/mapRootContent/components/MapSettings/components';
|
||||||
import { WdButton } from '@/hooks/Mapper/components/ui-kit';
|
import { WdButton } from '@/hooks/Mapper/components/ui-kit';
|
||||||
import { RoutesType } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
import { RoutesType } from '@/hooks/Mapper/mapRootProvider/types.ts';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
interface RoutesSettingsDialog {
|
interface RoutesSettingsDialog {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user