Skip to content

Commit

Permalink
Implement review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Etschbeijer committed Dec 19, 2024
1 parent 31a0d13 commit 286e7dc
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
7 changes: 4 additions & 3 deletions src/Client/MainComponents/Widgets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,10 @@ type Widget =

let content =
let switchContent =
if model.ProtocolState.TemplatesSelected.Length > 0 && model.PageState.SidebarPage = Routing.SidebarPage.Protocol then
insertContent()
else selectContent()
if model.ProtocolState.TemplatesSelected.Length > 0 && not model.ProtocolState.IsProtocolSearch then
insertContent ()
else
selectContent ()
Html.div [
prop.className "flex flex-col gap-4 @container/templateWidget"
prop.children switchContent
Expand Down
2 changes: 2 additions & 0 deletions src/Client/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ module Protocol =
// ------ Protocol from Database ------
TemplatesSelected : ARCtrl.Template list
Templates : ARCtrl.Template []
IsProtocolSearch : bool
} with
static member init () = {
// Client
Expand All @@ -256,6 +257,7 @@ module Protocol =
TemplatesSelected = []
// ------ Protocol from Database ------
Templates = [||]
IsProtocolSearch = false
}

type RequestBuildingBlockInfoStates =
Expand Down
3 changes: 1 addition & 2 deletions src/Client/Pages/ProtocolTemplates/ProtocolSearch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ module private HelperProtocolSearch =
Html.li [
prop.className "is-active"
prop.children (Html.a [
prop.onClick (fun _ -> UpdateModel {model with Model.PageState.SidebarPage = Routing.SidebarPage.ProtocolSearch} |> dispatch)
prop.text (Routing.SidebarPage.ProtocolSearch.AsStringRdbl)
prop.onClick (fun _ -> UpdateModel {model with Model.ProtocolState.IsProtocolSearch = true} |> dispatch)
])
]
]
Expand Down
5 changes: 3 additions & 2 deletions src/Client/Pages/ProtocolTemplates/ProtocolState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ module Protocol =
}
nextState, Cmd.none
| SelectProtocols prots ->
log "SelectProtocols"
let nextModel = {
model with
Model.ProtocolState.TemplatesSelected = prots
Model.PageState.SidebarPage = Routing.SidebarPage.Protocol
Model.ProtocolState.IsProtocolSearch = false
Model.PageState.SidebarPage = Routing.SidebarPage.Protocol
}
state, Cmd.ofMsg (UpdateModel nextModel)
| AddProtocol prot ->
Expand All @@ -70,6 +70,7 @@ module Protocol =
let nextState = {
state with
TemplatesSelected = templates
IsProtocolSearch = true
}
nextState, Cmd.none
| ProtocolIncreaseTimesUsed templateId ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type SelectiveTemplateFromDB =
/// <param name="dispatch"></param>
static member ToProtocolSearchElement(model: Model) dispatch =
Daisy.button.button [
prop.onClick(fun _ -> UpdateModel {model with Model.PageState.SidebarPage = Routing.SidebarPage.ProtocolSearch} |> dispatch)
prop.onClick(fun _ -> UpdateModel {model with Model.ProtocolState.IsProtocolSearch = true} |> dispatch)
button.primary
button.block
prop.text "Browse database"
Expand Down
4 changes: 0 additions & 4 deletions src/Client/Routing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type SidebarPage =
| TermSearch
| FilePicker
| Protocol
| ProtocolSearch
| JsonExport
| DataAnnotator

Expand All @@ -19,7 +18,6 @@ type SidebarPage =
| TermSearch -> "Terms"
| FilePicker -> "File Picker"
| Protocol -> "Templates"
| ProtocolSearch -> "Template Search"
| JsonExport -> "Json Export"
| DataAnnotator -> "Data Annotator"

Expand All @@ -37,8 +35,6 @@ type SidebarPage =
createElem [ Html.i [prop.className "fa-solid fa-circle-plus" ]; Html.i [prop.className "fa-solid fa-table-columns" ]]
| Protocol ->
createElem [ Html.i [prop.className "fa-solid fa-circle-plus" ];Html.i [prop.className "fa-solid fa-table" ]]
| ProtocolSearch ->
createElem [ Html.i [prop.className "fa-solid fa-table" ]; Html.i [prop.className "fa-solid fa-magnifying-glass" ]]
| JsonExport ->
createElem [ Html.i [prop.className "fa-solid fa-file-export" ]]
| FilePicker ->
Expand Down
32 changes: 16 additions & 16 deletions src/Client/Views/SidebarView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ type SidebarView =
Html.div [
prop.className "grow overflow-y-auto"
prop.children [
match model.PageState with
| {SidebarPage = Routing.SidebarPage.BuildingBlock } ->
BuildingBlock.Core.addBuildingBlockComponent model dispatch

| {SidebarPage = Routing.SidebarPage.TermSearch } ->
TermSearch.Main (model, dispatch)
if model.ProtocolState.IsProtocolSearch then
Protocol.SearchContainer.Main model dispatch
else
match model.PageState with
| {SidebarPage = Routing.SidebarPage.BuildingBlock } ->
BuildingBlock.Core.addBuildingBlockComponent model dispatch

| {SidebarPage = Routing.SidebarPage.FilePicker } ->
FilePicker.filePickerComponent model dispatch
| {SidebarPage = Routing.SidebarPage.TermSearch } ->
TermSearch.Main (model, dispatch)

| {SidebarPage = Routing.SidebarPage.Protocol } ->
Protocol.Templates.Main (model, dispatch)
| {SidebarPage = Routing.SidebarPage.FilePicker } ->
FilePicker.filePickerComponent model dispatch

| {SidebarPage = Routing.SidebarPage.DataAnnotator } ->
Pages.DataAnnotator.Main(model, dispatch)
| {SidebarPage = Routing.SidebarPage.Protocol } ->
Protocol.Templates.Main (model, dispatch)

| {SidebarPage = Routing.SidebarPage.JsonExport } ->
JsonExporter.Core.FileExporter.Main(model, dispatch)
| {SidebarPage = Routing.SidebarPage.DataAnnotator } ->
Pages.DataAnnotator.Main(model, dispatch)

| {SidebarPage = Routing.SidebarPage.ProtocolSearch } ->
Protocol.SearchContainer.Main model dispatch
| {SidebarPage = Routing.SidebarPage.JsonExport } ->
JsonExporter.Core.FileExporter.Main(model, dispatch)
]
]

Expand Down

0 comments on commit 286e7dc

Please sign in to comment.