Added submit button for changing ports.

This commit is contained in:
Giorgos Vyronos 2022-03-14 22:21:36 +00:00
parent f658ba9a59
commit 75c1a593bc
2 changed files with 34 additions and 25 deletions

View file

@ -512,8 +512,8 @@ let redefineCustomHW symbol =
let r,b,l,t = countsides symbol.APortOffsetsMap let r,b,l,t = countsides symbol.APortOffsetsMap
let maxRL = max r l let maxRL = max r l
let maxTB = max t b let maxTB = max t b
let heightNew = 100 //GridSize + GridSize * maxRL let heightNew = GridSize + GridSize * maxRL
let widthNew = max (maxname*2 + maxname*maxTB) (GridSize * 4) //maxname*2 + maxname*maxTB let widthNew = max (maxname*3 + maxname*maxTB) (GridSize * 4) //maxname*2 + maxname*maxTB
let newcompo = {symbol.Compo with H = heightNew} let newcompo = {symbol.Compo with H = heightNew}
let newcompo'= {newcompo with W = widthNew} let newcompo'= {newcompo with W = widthNew}
{symbol with Compo = newcompo'} {symbol with Compo = newcompo'}
@ -1372,9 +1372,7 @@ let update (msg : Msg) (model : Model): Model*Cmd<'a> =
| _ -> failwithf "Side not implemented" | _ -> failwithf "Side not implemented"
let symbol' = {tempsym with APortOffsetsMap = (changePortSide tempsym.APortOffsetsMap portName newSide tempsym)} let symbol' = {tempsym with APortOffsetsMap = (changePortSide tempsym.APortOffsetsMap portName newSide tempsym)}
//let symbol'' = {redefineCustomHW} ->
let symbol'' = redefineCustomHW symbol' let symbol'' = redefineCustomHW symbol'
//{symbol'' with map = redefineportmap}
let symbol''' = {symbol'' with APortOffsetsMap = redefineCustomPorts symbol'' symbol'.APortOffsetsMap} let symbol''' = {symbol'' with APortOffsetsMap = redefineCustomPorts symbol'' symbol'.APortOffsetsMap}
{ model with Symbols = Map.add sId symbol''' model.Symbols }, Cmd.none { model with Symbols = Map.add sId symbol''' model.Symbols }, Cmd.none

View file

@ -446,29 +446,40 @@ let viewSelectedComponent (model: ModelType.Model) dispatch : ReactElement =
let mutable portName = "" let mutable portName = ""
let mutable portSide = "" let mutable portSide = ""
let dropDown (available:bool) (name:string) (lst:string list): ReactElement = if allowedDescription then
if available then Field.div [] [
Field.div [] [ Label.label [] [ str "Port Movements" ]
Label.label [] [ str name ] p [ Style [ FontStyle "italic"; FontSize "12px"; LineHeight "1.1"]] [
Label.label [ ] str <| $"To change the location of the ports on the symbol:\n 1. Select the port to change its location.
[Select.select [] 2. Select the side of the Symbol on where the Port should be.\n 3. Press the Submit button to submit your changes.\n"]
[ select [(OnChange(fun option ->
match name with Label.label [] [ str "Port Selection" ]
| "Port" -> portName <- option.Value; if (portName <> "" && portSide <> "") then setComponentPortUpdate model sheetDispatch comp portName portSide; dispatch <| SetPopupDialogText (Some portName);dispatch (ReloadSelectedComponent model.LastUsedDialogWidth) else printf "Not yet" Label.label [ ]
| "Side" -> portSide <- option.Value; if (portName <> "" && portSide <> "") then setComponentPortUpdate model sheetDispatch comp portName portSide; dispatch <| SetPopupDialogText (Some portSide);dispatch (ReloadSelectedComponent model.LastUsedDialogWidth) else printf "Not yet" [Select.select []
| _ -> failwithf "Case not an option" [ select [(OnChange(fun option ->
))] portName <- option.Value;(printf "%A\n" option.Value)))]
([option [Value "";Selected true;Disabled true] [str ("Choose " + string name)]] @ List.map(fun value -> option [Value value] [str value]) lst) ([option [Value "";Selected true;Disabled true] [str ("Choose Port")]] @ List.map(fun value -> option [Value value] [str value]) portNameLst)
]
] ]
]
Label.label [] [ str "Side Selection" ]
Label.label [ ]
[Select.select []
[ select [(OnChange(fun option ->
portSide <- option.Value; (printf "%A\n" option.Value)))]
([option [Value "";Selected true;Disabled true] [str ("Choose Side")]] @ List.map(fun value -> option [Value value] [str value]) portSideLst)
]
]
Button.button [
Button.Color IsPrimary
Button.Props [ OnClick (fun _ -> (if (portName <> "" && portSide <> "") then setComponentPortUpdate model sheetDispatch comp portName portSide; dispatch <| SetPopupDialogText (Some (portName+" "+portSide));dispatch (ReloadSelectedComponent model.LastUsedDialogWidth)))]
] ]
else [ str "Submit" ]
Field.div [] [] ]
dropDown allowedDescription "Port" portNameLst else
dropDown allowedDescription "Side" portSideLst Field.div [] []
]
]
] ]
| _ -> div [] [ str "Select a component in the diagram to view or change its properties, for example number of bits." ] | _ -> div [] [ str "Select a component in the diagram to view or change its properties, for example number of bits." ]