From 200e62a65e5c8e29bdb64b18c637079388215993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirko=20M=C3=A4licke?= Date: Thu, 27 Apr 2023 16:37:21 +0200 Subject: [PATCH 1/3] add segments to sidebar --- src/pages/DesktopPage.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pages/DesktopPage.tsx b/src/pages/DesktopPage.tsx index dcab8c0..15d583f 100644 --- a/src/pages/DesktopPage.tsx +++ b/src/pages/DesktopPage.tsx @@ -13,6 +13,8 @@ import { IonLabel, IonPage, IonRow, + IonSegment, + IonSegmentButton, IonTitle, IonToolbar, } from "@ionic/react"; @@ -21,7 +23,7 @@ import { closeCircleOutline, settingsOutline, } from "ionicons/icons"; -import React from "react"; +import React, { useState } from "react"; import InventoryList from "../components/InventoryList"; import MainMap from "../components/map-components/MainMapMaplibre"; import BaseLayerPopover from "../components/popover/BaseLayerPopover"; @@ -32,8 +34,12 @@ import FilterBarPopover from "../components/popover/RangeFilterPopover"; import MapButtonGroup from "../components/MapButtonGroup"; import ActiveMapSelectionButton from "../components/ActiveMapSelectionButton"; import VariableSelectionPopover from "../components/popover/VariableSelectionPopover"; +import SelectionList from "../components/SelectionList"; const DesktopPage: React.FC = () => { + // component state for rendering the correct sidebar + const [sidebarContent, setSidebarContent] = useState<'inventory' | 'selection'>('inventory') + return ( @@ -51,7 +57,15 @@ const DesktopPage: React.FC = () => {
- + setSidebarContent(e.target.value as 'inventory' | 'selection')}> + + Inventory + + + Selections + + + { sidebarContent === 'inventory' ? : }
From 84ff11c51914db6f83e6497f5948b0e8620da571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirko=20M=C3=A4licke?= Date: Thu, 27 Apr 2023 20:46:38 +0200 Subject: [PATCH 2/3] make extra component --- src/components/SelectionActionDetail.tsx | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/components/SelectionActionDetail.tsx diff --git a/src/components/SelectionActionDetail.tsx b/src/components/SelectionActionDetail.tsx new file mode 100644 index 0000000..7661acb --- /dev/null +++ b/src/components/SelectionActionDetail.tsx @@ -0,0 +1,65 @@ +import { IonBadge, IonButton, IonContent, IonIcon, IonInput, IonItem, IonLabel, IonPopover } from "@ionic/react" +import { trashOutline, eyeOutline, chevronForward, downloadOutline, checkmark } from "ionicons/icons" +import { useEffect, useState } from "react" + +import { InventorySelection } from "../context/inventory-selection.model" +import { useOffline } from "../context/offline" +import { useSelection } from "../context/selection" + +const SelectionActionDetail: React.FC<{selection: InventorySelection}> = ({ selection }) => { + // context to handle the name changes + const [currentTitle, setCurrentTitle] = useState('') + + // subscribe to the current active selection + const { activeSelection, setActiveSelection } = useSelection() + + // get some selection context functions + const { dropSelection, updateSelection } = useOffline() + + // add a handler to change the title + const onUpdateTitle = () => { + updateSelection({...selection, title: currentTitle}) + } + + useEffect(() => { + if (selection.title) { + setCurrentTitle(selection.title) + } + }, [selection]) + + return ( + + {selection.title} + {selection.treeIds.length} + { activeSelection?.selection.id === selection.id ? (<> + + + + + + + setCurrentTitle(e.target.value as string)} /> + + + + + + + + + dropSelection(selection.id)}> + + + + + + ) : ( + setActiveSelection(selection.id)}> + + + )} + + ) +} + +export default SelectionActionDetail \ No newline at end of file From 0b57edb307f711c2f35a782eac3decacee8ce724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirko=20M=C3=A4licke?= Date: Thu, 27 Apr 2023 20:46:43 +0200 Subject: [PATCH 3/3] add component to list --- src/components/SelectionList.tsx | 34 +++++++++++++------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/components/SelectionList.tsx b/src/components/SelectionList.tsx index 693a849..b13e82b 100644 --- a/src/components/SelectionList.tsx +++ b/src/components/SelectionList.tsx @@ -1,35 +1,29 @@ -import { IonBadge, IonButton, IonIcon, IonItem, IonLabel, IonList } from "@ionic/react" -import { trashOutline } from "ionicons/icons" +import { IonBadge, IonButton, IonContent, IonIcon, IonInput, IonItem, IonLabel, IonList, IonPopover } from "@ionic/react" +import { trashOutline, eyeOutline, chevronForward, downloadOutline, addCircleOutline, checkmark } from "ionicons/icons" import { useOffline } from "../context/offline" import { useSelection } from "../context/selection" +import SelectionActionDetail from "./SelectionActionDetail" const SelectionList: React.FC = () => { // load the selection-related functions from the offline context - // TODO: replace with data context, once implemented - const { createSelection, dropSelection } = useOffline() - const { selections } = useSelection() + const { createSelection } = useOffline() + const { selections, setActiveSelection } = useSelection() - // create random selection - DEBUG ONLY - const onCreateNewSelection = () => { - createSelection( - [42, 43, 44], - 'Deleopment Selection', - ) + // controller for adding new selections + const onNewSelection = () => { + createSelection([]).then(newSelection => { + setActiveSelection(newSelection.id) + }) } return ( {selections?.map((s) => ( - - {s.title} - {s.treeIds.length} - dropSelection(s.id)}> - - - + ))} - {/* NEW SELECTION */} - DELETE ALl + + + ) }