@mytec: iter9 ready for test
This commit is contained in:
@@ -11,10 +11,13 @@ export default function BatchEdit({ onBatchApplied }: BatchEditProps) {
|
||||
const selectedSiteIds = useSitesStore((s) => s.selectedSiteIds);
|
||||
const batchUpdateHeight = useSitesStore((s) => s.batchUpdateHeight);
|
||||
const batchSetHeight = useSitesStore((s) => s.batchSetHeight);
|
||||
const batchAdjustAzimuth = useSitesStore((s) => s.batchAdjustAzimuth);
|
||||
const batchSetAzimuth = useSitesStore((s) => s.batchSetAzimuth);
|
||||
const clearSelection = useSitesStore((s) => s.clearSelection);
|
||||
const addToast = useToastStore((s) => s.addToast);
|
||||
|
||||
const [customHeight, setCustomHeight] = useState('');
|
||||
const [customAzimuth, setCustomAzimuth] = useState('');
|
||||
|
||||
if (selectedSiteIds.length === 0) return null;
|
||||
|
||||
@@ -23,7 +26,7 @@ export default function BatchEdit({ onBatchApplied }: BatchEditProps) {
|
||||
await batchUpdateHeight(delta);
|
||||
onBatchApplied?.(ids);
|
||||
addToast(
|
||||
`Updated ${ids.length} site(s) by ${delta > 0 ? '+' : ''}${delta}m`,
|
||||
`Updated ${ids.length} site(s) height by ${delta > 0 ? '+' : ''}${delta}m`,
|
||||
'success'
|
||||
);
|
||||
};
|
||||
@@ -41,6 +44,29 @@ export default function BatchEdit({ onBatchApplied }: BatchEditProps) {
|
||||
setCustomHeight('');
|
||||
};
|
||||
|
||||
const handleAdjustAzimuth = async (delta: number) => {
|
||||
const ids = [...selectedSiteIds];
|
||||
await batchAdjustAzimuth(delta);
|
||||
onBatchApplied?.(ids);
|
||||
addToast(
|
||||
`Rotated ${ids.length} site(s) by ${delta > 0 ? '+' : ''}${delta}°`,
|
||||
'success'
|
||||
);
|
||||
};
|
||||
|
||||
const handleSetAzimuth = async () => {
|
||||
const az = parseInt(customAzimuth, 10);
|
||||
if (isNaN(az) || az < 0 || az > 359) {
|
||||
addToast('Azimuth must be between 0-359°', 'error');
|
||||
return;
|
||||
}
|
||||
const ids = [...selectedSiteIds];
|
||||
await batchSetAzimuth(az);
|
||||
onBatchApplied?.(ids);
|
||||
addToast(`Set ${ids.length} site(s) azimuth to ${az}°`, 'success');
|
||||
setCustomAzimuth('');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3 space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -99,6 +125,73 @@ export default function BatchEdit({ onBatchApplied }: BatchEditProps) {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Adjust azimuth */}
|
||||
<div>
|
||||
<label className="text-xs font-medium text-gray-700 dark:text-gray-300 mb-1.5 block">
|
||||
Adjust Azimuth:
|
||||
</label>
|
||||
<div className="flex gap-1 flex-wrap">
|
||||
<Button size="sm" variant="secondary" onClick={() => handleAdjustAzimuth(-90)}>
|
||||
-90°
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" onClick={() => handleAdjustAzimuth(-45)}>
|
||||
-45°
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" onClick={() => handleAdjustAzimuth(-10)}>
|
||||
-10°
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" onClick={() => handleAdjustAzimuth(10)}>
|
||||
+10°
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" onClick={() => handleAdjustAzimuth(45)}>
|
||||
+45°
|
||||
</Button>
|
||||
<Button size="sm" variant="secondary" onClick={() => handleAdjustAzimuth(90)}>
|
||||
+90°
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Set exact azimuth */}
|
||||
<div>
|
||||
<label className="text-xs font-medium text-gray-700 dark:text-gray-300 mb-1.5 block">
|
||||
Set Azimuth:
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={359}
|
||||
value={customAzimuth}
|
||||
onChange={(e) => setCustomAzimuth(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleSetAzimuth()}
|
||||
placeholder="0-359°"
|
||||
className="flex-1 px-3 py-1.5 border border-gray-300 dark:border-dark-border dark:bg-dark-bg dark:text-dark-text rounded-md text-sm
|
||||
focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
const ids = [...selectedSiteIds];
|
||||
batchSetAzimuth(0).then(() => {
|
||||
onBatchApplied?.(ids);
|
||||
addToast(`Set ${ids.length} site(s) to North (0°)`, 'success');
|
||||
});
|
||||
}}
|
||||
>
|
||||
N 0°
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleSetAzimuth}
|
||||
disabled={!customAzimuth}
|
||||
>
|
||||
Apply
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user