Plate switching!
This commit is contained in:
parent
5be70675ee
commit
1b0be78e85
|
@ -1,12 +1,33 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
use yewdux::prelude::*;
|
||||||
|
|
||||||
|
use super::states::{MainState, NewTransferState};
|
||||||
use super::plates::plate_container::PlateContainer;
|
use super::plates::plate_container::PlateContainer;
|
||||||
use super::tree::Tree;
|
use super::tree::Tree;
|
||||||
use super::transfer_menu::TransferMenu;
|
use super::transfer_menu::TransferMenu;
|
||||||
use super::new_plate_dialog::NewPlateDialog;
|
use super::new_plate_dialog::NewPlateDialog;
|
||||||
|
|
||||||
|
use crate::data::plate_instances::PlateInstance;
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
pub fn MainWindow() -> Html {
|
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 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 = {
|
||||||
let new_plate_dialog_is_open = new_plate_dialog_is_open.clone();
|
let new_plate_dialog_is_open = new_plate_dialog_is_open.clone();
|
||||||
|
@ -25,7 +46,7 @@ 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={(24,16)} destination_dims={(24,16)}/>
|
<PlateContainer source_dims={source_dims} destination_dims={destination_dims}/>
|
||||||
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,25 +1,29 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yewdux::prelude::*;
|
|
||||||
use super::super::states::MainState;
|
|
||||||
|
|
||||||
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: (u8,u8),
|
pub source_dims: Option<(u8,u8)>,
|
||||||
pub destination_dims: (u8,u8)
|
pub destination_dims: Option<(u8,u8)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
pub fn PlateContainer(props: &PlateContainerProps) -> Html {
|
||||||
let (state, dispatch) = use_store::<MainState>();
|
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
<div class="plate_container">
|
<div class="plate_container">
|
||||||
<SourcePlate width={props.source_dims.0} height={props.source_dims.1} />
|
if let Some((w,h)) = props.source_dims {
|
||||||
<DestinationPlate width={props.destination_dims.0} height={props.destination_dims.1} />
|
<SourcePlate width={w} height={h} />
|
||||||
|
} else {
|
||||||
|
<h2>{"No Source Plate Selected"}</h2>
|
||||||
|
}
|
||||||
|
if let Some((w,h)) = props.destination_dims {
|
||||||
|
<DestinationPlate width={w} height={h} />
|
||||||
|
} else {
|
||||||
|
<h2>{"No Destination Plate Selected"}</h2>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use yewdux::prelude::*;
|
||||||
use crate::data::{plate_instances::PlateInstance, transfer::Transfer};
|
use crate::data::{plate_instances::PlateInstance, transfer::Transfer};
|
||||||
use crate::data::plate::*;
|
use crate::data::plate::*;
|
||||||
use crate::components::states::{MainState, NewTransferState};
|
use crate::components::states::{MainState, NewTransferState};
|
||||||
|
use crate::components::transfer_menu::RegionDisplay;
|
||||||
|
|
||||||
#[derive(PartialEq, Properties)]
|
#[derive(PartialEq, Properties)]
|
||||||
pub struct TreeProps {
|
pub struct TreeProps {
|
||||||
|
@ -57,7 +58,10 @@ pub fn Tree(props: &TreeProps) -> Html {
|
||||||
let li = target.and_then(|t| t.dyn_into::<HtmlElement>().ok());
|
let li = target.and_then(|t| t.dyn_into::<HtmlElement>().ok());
|
||||||
if let Some(li) = li {
|
if let Some(li) = li {
|
||||||
if let Ok(id) = u128::from_str_radix(li.id().as_str(), 10) {
|
if let Ok(id) = u128::from_str_radix(li.id().as_str(), 10) {
|
||||||
dispatch.reduce_mut(|state| state.source_id = Uuid::from_u128(id))
|
dispatch.reduce_mut(|state| {
|
||||||
|
state.source_region = RegionDisplay::default();
|
||||||
|
state.source_id = Uuid::from_u128(id);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -69,7 +73,10 @@ pub fn Tree(props: &TreeProps) -> Html {
|
||||||
let li = target.and_then(|t| t.dyn_into::<HtmlElement>().ok());
|
let li = target.and_then(|t| t.dyn_into::<HtmlElement>().ok());
|
||||||
if let Some(li) = li {
|
if let Some(li) = li {
|
||||||
if let Ok(id) = u128::from_str_radix(li.id().as_str(), 10) {
|
if let Ok(id) = u128::from_str_radix(li.id().as_str(), 10) {
|
||||||
dispatch.reduce_mut(|state| state.destination_id = Uuid::from_u128(id))
|
dispatch.reduce_mut(|state| {
|
||||||
|
state.destination_region = RegionDisplay::default();
|
||||||
|
state.destination_id = Uuid::from_u128(id);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -54,14 +54,14 @@ impl std::fmt::Display for PlateFormat {
|
||||||
impl PlateFormat {
|
impl PlateFormat {
|
||||||
pub fn size(&self) -> (u8, u8) {
|
pub fn size(&self) -> (u8, u8) {
|
||||||
match self {
|
match self {
|
||||||
PlateFormat::W6 => (2, 3),
|
PlateFormat::W6 => (3, 2),
|
||||||
PlateFormat::W12 => (3, 4),
|
PlateFormat::W12 => (4, 3),
|
||||||
PlateFormat::W24 => (4, 6),
|
PlateFormat::W24 => (6, 4),
|
||||||
PlateFormat::W48 => (6, 8),
|
PlateFormat::W48 => (8, 6),
|
||||||
PlateFormat::W96 => (8, 12),
|
PlateFormat::W96 => (12, 8),
|
||||||
PlateFormat::W384 => (16, 24),
|
PlateFormat::W384 => (24, 16),
|
||||||
PlateFormat::W1536 => (32, 48),
|
PlateFormat::W1536 => (48, 32),
|
||||||
PlateFormat::W3456 => (48, 72),
|
PlateFormat::W3456 => (72, 48),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue