mirror of
https://github.com/supleed2/ELEC60015-HLP-CW.git
synced 2024-11-10 02:05:48 +00:00
Added submit button for changing ports.
This commit is contained in:
parent
f658ba9a59
commit
75c1a593bc
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
| "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"
|
|
||||||
| "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"
|
|
||||||
| _ -> failwithf "Case not an option"
|
|
||||||
))]
|
|
||||||
|
|
||||||
([option [Value "";Selected true;Disabled true] [str ("Choose " + string name)]] @ List.map(fun value -> option [Value value] [str value]) lst)
|
Label.label [] [ str "Port Selection" ]
|
||||||
]
|
Label.label [ ]
|
||||||
|
[Select.select []
|
||||||
|
[ select [(OnChange(fun option ->
|
||||||
|
portName <- option.Value;(printf "%A\n" option.Value)))]
|
||||||
|
|
||||||
|
([option [Value "";Selected true;Disabled true] [str ("Choose Port")]] @ List.map(fun value -> option [Value value] [str value]) portNameLst)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
else
|
Label.label [] [ str "Side Selection" ]
|
||||||
Field.div [] []
|
Label.label [ ]
|
||||||
dropDown allowedDescription "Port" portNameLst
|
[Select.select []
|
||||||
dropDown allowedDescription "Side" portSideLst
|
[ 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)))]
|
||||||
|
]
|
||||||
|
[ str "Submit" ]
|
||||||
|
]
|
||||||
|
else
|
||||||
|
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." ]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue