Give plate components their instance
This commit is contained in:
parent
6e8c1eff55
commit
0414ddba3a
|
@ -15,18 +15,12 @@ pub fn MainWindow() -> Html {
|
||||||
let (main_state, main_dispatch) = use_store::<MainState>();
|
let (main_state, main_dispatch) = use_store::<MainState>();
|
||||||
let (selection_state, selection_dispatch) = use_store::<NewTransferState>();
|
let (selection_state, selection_dispatch) = use_store::<NewTransferState>();
|
||||||
|
|
||||||
let source_plate_instance = main_state.source_plates.iter()
|
let source_plate_instance: Option<PlateInstance> = main_state.source_plates.iter()
|
||||||
.find(|spi| {spi.get_uuid() == selection_state.source_id});
|
.find(|spi| {spi.get_uuid() == selection_state.source_id})
|
||||||
let source_dims = match source_plate_instance {
|
.cloned();
|
||||||
Some(spi) => Some(spi.plate.size()),
|
let destination_plate_instance: Option<PlateInstance> = main_state.destination_plates.iter()
|
||||||
None => None,
|
.find(|dpi| {dpi.get_uuid() == selection_state.destination_id})
|
||||||
};
|
.cloned();
|
||||||
let destination_plate_instance = main_state.destination_plates.iter()
|
|
||||||
.find(|dpi| {dpi.get_uuid() == selection_state.destination_id});
|
|
||||||
let destination_dims = match destination_plate_instance {
|
|
||||||
Some(dpi) => Some(dpi.plate.size()),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let new_plate_dialog_is_open = use_state_eq(|| false);
|
let new_plate_dialog_is_open = use_state_eq(|| false);
|
||||||
let new_plate_dialog_callback = {
|
let new_plate_dialog_callback = {
|
||||||
|
@ -46,7 +40,8 @@ pub fn MainWindow() -> Html {
|
||||||
<div class="main_container">
|
<div class="main_container">
|
||||||
<Tree open_new_plate_callback={open_new_plate_dialog_callback}/>
|
<Tree open_new_plate_callback={open_new_plate_dialog_callback}/>
|
||||||
<TransferMenu />
|
<TransferMenu />
|
||||||
<PlateContainer source_dims={source_dims} destination_dims={destination_dims}/>
|
<PlateContainer source_dims={source_plate_instance}
|
||||||
|
destination_dims={destination_plate_instance}/>
|
||||||
if {*new_plate_dialog_is_open} {
|
if {*new_plate_dialog_is_open} {
|
||||||
<NewPlateDialog close_callback={new_plate_dialog_callback}/>
|
<NewPlateDialog close_callback={new_plate_dialog_callback}/>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yewdux::prelude::*;
|
use yewdux::prelude::*;
|
||||||
use std::intrinsics::discriminant_value;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use crate::data::plate_instances::PlateInstance;
|
||||||
|
|
||||||
use super::super::states::NewTransferState;
|
use super::super::states::NewTransferState;
|
||||||
use super::super::transfer_menu::RegionDisplay;
|
use super::super::transfer_menu::RegionDisplay;
|
||||||
|
|
||||||
#[derive(Properties, PartialEq)]
|
#[derive(Properties, PartialEq)]
|
||||||
pub struct DestinationPlateProps {
|
pub struct DestinationPlateProps {
|
||||||
pub width: u8,
|
pub plate: PlateInstance,
|
||||||
pub height: u8,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
|
@ -80,8 +80,8 @@ pub fn DestinationPlate(props: &DestinationPlateProps) -> Html {
|
||||||
|
|
||||||
let mouseleave_callback = Callback::clone(&mouseup_callback);
|
let mouseleave_callback = Callback::clone(&mouseup_callback);
|
||||||
|
|
||||||
let rows = (1..=props.height).map(|i| {
|
let rows = (1..=props.plate.plate.size().1).map(|i| {
|
||||||
let row = (1..=props.width).map(|j| {
|
let row = (1..=props.plate.plate.size().0).map(|j| {
|
||||||
html! {
|
html! {
|
||||||
<DestPlateCell i={i} j={j}
|
<DestPlateCell i={i} j={j}
|
||||||
selected={super::source_plate::in_rect(*m_start.clone(), *m_end.clone(), (i,j))}
|
selected={super::source_plate::in_rect(*m_start.clone(), *m_end.clone(), (i,j))}
|
||||||
|
|
|
@ -1,26 +1,34 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
|
use crate::data::plate_instances::PlateInstance;
|
||||||
|
|
||||||
use super::source_plate::SourcePlate;
|
use super::source_plate::SourcePlate;
|
||||||
use super::destination_plate::DestinationPlate;
|
use super::destination_plate::DestinationPlate;
|
||||||
|
|
||||||
#[derive(Properties, PartialEq)]
|
#[derive(Properties, PartialEq)]
|
||||||
pub struct PlateContainerProps {
|
pub struct PlateContainerProps {
|
||||||
pub source_dims: Option<(u8,u8)>,
|
pub source_dims: Option<PlateInstance>,
|
||||||
pub destination_dims: Option<(u8,u8)>,
|
pub destination_dims: Option<PlateInstance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
||||||
html! {
|
html! {
|
||||||
<div class="plate_container">
|
<div class="plate_container">
|
||||||
if let Some((w,h)) = props.source_dims {
|
if let Some(spi) = props.source_dims.clone() {
|
||||||
<SourcePlate width={w} height={h} />
|
<div>
|
||||||
|
<h2>{spi.name.clone()}</h2>
|
||||||
|
<SourcePlate plate={spi} />
|
||||||
|
</div>
|
||||||
} else {
|
} else {
|
||||||
<h2>{"No Source Plate Selected"}</h2>
|
<h2>{"No Source Plate Selected"}</h2>
|
||||||
}
|
}
|
||||||
if let Some((w,h)) = props.destination_dims {
|
if let Some(dpi) = props.destination_dims.clone() {
|
||||||
<DestinationPlate width={w} height={h} />
|
<div>
|
||||||
|
<h2>{dpi.name.clone()}</h2>
|
||||||
|
<DestinationPlate plate={dpi} />
|
||||||
|
</div>
|
||||||
} else {
|
} else {
|
||||||
<h2>{"No Destination Plate Selected"}</h2>
|
<h2>{"No Destination Plate Selected"}</h2>
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,15 @@ use yew::prelude::*;
|
||||||
use yewdux::prelude::*;
|
use yewdux::prelude::*;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use crate::data::plate_instances::PlateInstance;
|
||||||
|
use crate::data::transfer_region::TransferRegion;
|
||||||
|
|
||||||
use super::super::states::NewTransferState;
|
use super::super::states::NewTransferState;
|
||||||
use super::super::transfer_menu::RegionDisplay;
|
use super::super::transfer_menu::RegionDisplay;
|
||||||
|
|
||||||
#[derive(PartialEq, Properties)]
|
#[derive(PartialEq, Properties)]
|
||||||
pub struct SourcePlateProps {
|
pub struct SourcePlateProps {
|
||||||
pub width: u8,
|
pub plate: PlateInstance,
|
||||||
pub height: u8,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
|
@ -79,8 +81,8 @@ pub fn SourcePlate(props: &SourcePlateProps) -> Html {
|
||||||
|
|
||||||
let mouseleave_callback = Callback::clone(&mouseup_callback);
|
let mouseleave_callback = Callback::clone(&mouseup_callback);
|
||||||
|
|
||||||
let rows = (1..=props.height).map(|i| {
|
let rows = (1..=props.plate.plate.size().1).map(|i| {
|
||||||
let row = (1..=props.width).map(|j| {
|
let row = (1..=props.plate.plate.size().0).map(|j| {
|
||||||
html! {
|
html! {
|
||||||
<SourcePlateCell i={i} j={j}
|
<SourcePlateCell i={i} j={j}
|
||||||
selected={in_rect(*m_start.clone(), *m_end.clone(), (i,j))}
|
selected={in_rect(*m_start.clone(), *m_end.clone(), (i,j))}
|
||||||
|
|
Loading…
Reference in New Issue