Skip to content

Commit

Permalink
Move selected box above template search
Browse files Browse the repository at this point in the history
  • Loading branch information
Etschbeijer committed Dec 17, 2024
1 parent 500dc72 commit c5739f1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 42 deletions.
1 change: 1 addition & 0 deletions src/Client/MainComponents/Widgets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ type Widget =
let selectContent() =
[
Protocol.Search.FileSortElement(model, config, setConfig, "@md/templateWidget:grid-cols-3")
ModalElements.Box("Selected Templates", "fa-solid fa-cog", Search.SelectedTemplatesElement model dispatch)
Protocol.Search.Component (filteredTemplates, model, dispatch, length.px 350)
]
let insertContent() =
Expand Down
6 changes: 3 additions & 3 deletions src/Client/Modals/SelectiveImportModal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ type SelectiveImportModal =
)

[<ReactComponent>]
static member TableImport(tableIndex: int, table0: ArcTable, state: SelectiveImportModalState, addTableImport: int -> bool -> unit, rmvTableImport: int -> unit, selectedColumns, setSelectedColumns, ?templateName, ?radioGroup) =
static member TableImport(tableIndex: int, table0: ArcTable, state: SelectiveImportModalState, addTableImport: int -> bool -> unit, rmvTableImport: int -> unit, selectedColumns, setSelectedColumns, ?templateName) =
let name = defaultArg templateName table0.Name
let radioGroup = defaultArg radioGroup ""
let radioGroup = "radioGroup_" + radioGroup
let guid = React.useMemo(fun () -> System.Guid.NewGuid().ToString())
let radioGroup = "radioGroup_" + guid
let import = state.ImportTables |> List.tryFind (fun it -> it.Index = tableIndex)
let isActive = import.IsSome
let isDisabled = state.ImportMetadata
Expand Down
2 changes: 2 additions & 0 deletions src/Client/Pages/ProtocolTemplates/ProtocolSearch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open Model
open Messages
open Feliz
open Feliz.DaisyUI
open Modals

module private HelperProtocolSearch =

Expand Down Expand Up @@ -58,6 +59,7 @@ type SearchContainer =
prop.children [
Protocol.Search.InfoField()
Protocol.Search.FileSortElement(model, config, setConfig)
ModalElements.Box("Selected Templates", "fa-solid fa-cog", Search.SelectedTemplatesElement model dispatch)
Protocol.Search.Component (filteredTemplates, model, dispatch)
]
]
Expand Down
78 changes: 40 additions & 38 deletions src/Client/Pages/ProtocolTemplates/ProtocolSearchViewComponent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,46 @@ type Search =
]
]

static member private displayTemplateNames model =
Html.div [
prop.className "flex gap-2"
prop.children [
let names = List.rev model.ProtocolState.TemplatesSelected |> List.map (fun template -> template.Name)
for i in 0..names.Length-1 do
Html.div [ yield! [prop.text $"\"{names.[i]}\""]]
]
]
static member private selectTemplatesButton model dispatch =
Html.div [
prop.className "flex justify-center gap-2"
prop.children [
Daisy.button.a [
button.sm
prop.onClick (fun _ ->
SelectProtocols model.ProtocolState.TemplatesSelected |> ProtocolMsg |> dispatch
)
button.wide
if model.ProtocolState.TemplatesSelected.Length > 0 then
button.success
else
button.disabled
prop.text "Select templates"
]
]
]
static member SelectedTemplatesElement model dispatch =
Html.div [
prop.style [style.overflowX.auto; style.marginBottom (length.rem 1)]
prop.children [
Html.div [
prop.children [
Search.displayTemplateNames model
]
]
Search.selectTemplatesButton model dispatch
]
]

[<ReactComponent>]
static member Component (templates, model: Model, dispatch, ?maxheight: Styles.ICssUnit) =
let maxheight = defaultArg maxheight (length.px 600)
Expand Down Expand Up @@ -603,43 +643,5 @@ type Search =
]
]
]
let names =
Html.div [
prop.className "flex gap-2"
prop.children [
let names = List.rev model.ProtocolState.TemplatesSelected |> List.map (fun template -> template.Name)
for i in 0..names.Length-1 do
Html.div [ yield! [prop.text $"\"{names.[i]}\""]]
]
]
let button =
Html.div [
prop.className "flex justify-center gap-2"
prop.children [
Daisy.button.a [
button.sm
prop.onClick (fun _ ->
SelectProtocols model.ProtocolState.TemplatesSelected |> ProtocolMsg |> dispatch
)
button.wide
button.success
prop.text "Select templates"
]
]
]
let element =
Html.div [
prop.style [style.overflowX.auto; style.marginBottom (length.rem 1)]
prop.children [
Html.div [
prop.children [
names
]
]
button
]
]
if model.ProtocolState.TemplatesSelected.Length > 0 then
ModalElements.Box("Selected Templates", "fa-solid fa-cog", element)
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type SelectiveTemplateFromDB =
let templates = model.ProtocolState.TemplatesSelected
for templateIndex in 0..templates.Length-1 do
let template = templates.[templateIndex]
SelectiveImportModal.TableImport(templateIndex, template.Table, importTypeState, addTableImport, rmvTableImport, importTypeState, setImportTypeState, template.Name, template.Name)
SelectiveImportModal.TableImport(templateIndex, template.Table, importTypeState, addTableImport, rmvTableImport, importTypeState, setImportTypeState, template.Name)
Html.div [
SelectiveTemplateFromDB.AddTemplatesFromDBToTableButton "Add templates" model importTypeState dispatch
]
Expand Down

0 comments on commit c5739f1

Please sign in to comment.