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