Remove deprecated dashboard pages and update vertical menu links for streamlined navigation
- Deleted unused pages for crop zoning, farm AI assistant, fertilization recommendation, irrigation recommendation, pest detection, plant simulator, soil data, and water data. - Updated the vertical menu to reflect the removal of these pages, ensuring a cleaner and more efficient user experience.
This commit is contained in:
@@ -19,6 +19,10 @@ type CropZoningMapProps = {
|
||||
onZoneClick?: (zone: ZoneFeatureProperties) => void
|
||||
optimizationKey?: number
|
||||
className?: string
|
||||
/** منطقهٔ اولیه از دیتای ماک؛ وقتی مقدار دارد نقشه فقط نمایشی است و کاربر نمیتواند منطقه را تغییر دهد */
|
||||
initialAreaGeoJson?: MapDrawGeoJSON | null
|
||||
/** غیرفعال کردن رسم و ویرایش منطقه توسط کاربر */
|
||||
readOnly?: boolean
|
||||
}
|
||||
|
||||
export default function CropZoningMap({
|
||||
@@ -29,7 +33,9 @@ export default function CropZoningMap({
|
||||
onAreaChange,
|
||||
onZoneClick,
|
||||
optimizationKey = 0,
|
||||
className = ''
|
||||
className = '',
|
||||
initialAreaGeoJson = null,
|
||||
readOnly = false
|
||||
}: CropZoningMapProps) {
|
||||
const mapRef = useRef<HTMLDivElement>(null)
|
||||
const mapInstanceRef = useRef<L.Map | null>(null)
|
||||
@@ -124,21 +130,22 @@ export default function CropZoningMap({
|
||||
const drawnItems = L.featureGroup().addTo(map)
|
||||
drawnItemsRef.current = drawnItems
|
||||
|
||||
const drawControl = new L.Control.Draw({
|
||||
position: 'topright',
|
||||
draw: {
|
||||
polygon: { shapeOptions: { color: '#3388ff' } },
|
||||
rectangle: { shapeOptions: { color: '#3388ff' } },
|
||||
circle: false,
|
||||
circlemarker: false,
|
||||
marker: false,
|
||||
polyline: false
|
||||
},
|
||||
edit: { featureGroup: drawnItems, remove: true }
|
||||
})
|
||||
|
||||
map.addControl(drawControl)
|
||||
drawControlRef.current = drawControl
|
||||
if (!readOnly) {
|
||||
const drawControl = new L.Control.Draw({
|
||||
position: 'topright',
|
||||
draw: {
|
||||
polygon: { shapeOptions: { color: '#3388ff' } },
|
||||
rectangle: { shapeOptions: { color: '#3388ff' } },
|
||||
circle: false,
|
||||
circlemarker: false,
|
||||
marker: false,
|
||||
polyline: false
|
||||
},
|
||||
edit: { featureGroup: drawnItems, remove: true }
|
||||
})
|
||||
map.addControl(drawControl)
|
||||
drawControlRef.current = drawControl
|
||||
}
|
||||
|
||||
const getGeoJsonFromDrawn = (): MapDrawGeoJSON => {
|
||||
const geojson = drawnItems.toGeoJSON()
|
||||
@@ -159,6 +166,12 @@ export default function CropZoningMap({
|
||||
}
|
||||
}
|
||||
|
||||
if (readOnly && initialAreaGeoJson && initialAreaGeoJson.geometry && (initialAreaGeoJson.geometry as { type: string }).type === 'Polygon') {
|
||||
drawnItems.clearLayers()
|
||||
L.geoJSON(initialAreaGeoJson as Feature<Polygon>).eachLayer((layer) => drawnItems.addLayer(layer))
|
||||
emitAndRender()
|
||||
}
|
||||
|
||||
const onCreated = (e: L.LeafletEvent) => {
|
||||
const event = e as L.DrawEvents.Created
|
||||
drawnItems.clearLayers()
|
||||
@@ -175,17 +188,23 @@ export default function CropZoningMap({
|
||||
}
|
||||
}
|
||||
|
||||
map.on(L.Draw.Event.CREATED, onCreated)
|
||||
map.on(L.Draw.Event.EDITED, onEdited)
|
||||
map.on(L.Draw.Event.DELETED, onDeleted)
|
||||
if (!readOnly) {
|
||||
map.on(L.Draw.Event.CREATED, onCreated)
|
||||
map.on(L.Draw.Event.EDITED, onEdited)
|
||||
map.on(L.Draw.Event.DELETED, onDeleted)
|
||||
}
|
||||
|
||||
mapInstanceRef.current = map
|
||||
|
||||
cleanupFn = () => {
|
||||
map.off(L.Draw.Event.CREATED, onCreated)
|
||||
map.off(L.Draw.Event.EDITED, onEdited)
|
||||
map.off(L.Draw.Event.DELETED, onDeleted)
|
||||
map.removeControl(drawControl)
|
||||
if (!readOnly) {
|
||||
map.off(L.Draw.Event.CREATED, onCreated)
|
||||
map.off(L.Draw.Event.EDITED, onEdited)
|
||||
map.off(L.Draw.Event.DELETED, onDeleted)
|
||||
if (drawControlRef.current) {
|
||||
map.removeControl(drawControlRef.current)
|
||||
}
|
||||
}
|
||||
if (zonesLayerRef.current) map.removeLayer(zonesLayerRef.current)
|
||||
map.remove()
|
||||
mapInstanceRef.current = null
|
||||
|
||||
Reference in New Issue
Block a user