Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature excel enable multiple templates #592

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b74953d
Create basic structure for adding multiple templates
Etschbeijer Dec 9, 2024
488a75b
Enable viewing of all selected templates
Etschbeijer Dec 10, 2024
dc3e485
Add minor refactoring
Etschbeijer Dec 11, 2024
41c76e6
Removed templateSelected
Etschbeijer Dec 12, 2024
1486fc6
Implement selectImportType
Etschbeijer Dec 12, 2024
57251b3
Enable import of multiple templates with add and join
Etschbeijer Dec 12, 2024
0fee87f
Enable adding and joining of templates
Etschbeijer Dec 13, 2024
8de6cb0
Enable merging of different cell types from template
Etschbeijer Dec 13, 2024
d726241
Implement import of multiple templates in swate alpha
Etschbeijer Dec 16, 2024
d43aae3
implement review changes
Etschbeijer Dec 17, 2024
a8e7eae
Simplify code
Etschbeijer Dec 17, 2024
ec72dc3
Implement regex fix
Etschbeijer Dec 17, 2024
500dc72
Reduce code duplication :fire:
Freymaurer Dec 17, 2024
c5739f1
Move selected box above template search
Etschbeijer Dec 17, 2024
7d14e3a
removed line
Etschbeijer Dec 17, 2024
5b22abf
Replace worksheet name with template name instead of table name
Etschbeijer Dec 18, 2024
f6aa09a
Add summaries
Etschbeijer Dec 18, 2024
f568dcd
implemented review changes
Etschbeijer Dec 18, 2024
4f0359c
Implement review changes
Etschbeijer Dec 19, 2024
31a0d13
Undo changes to pagestate
Etschbeijer Dec 19, 2024
286e7dc
Implement review changes
Etschbeijer Dec 19, 2024
02780e2
implement review requests
Etschbeijer Dec 20, 2024
2046195
Implement review changes
Etschbeijer Dec 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Client/Index.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let View (model : Model) (dispatch : Msg -> unit) =
prop.className "flex w-full overflow-auto h-screen"
prop.children [
Modals.ModalProvider.Main(model, dispatch)
match model.ProtocolState.IsHome, model.PersistentStorageState.Host with
match model.PageState.IsHome, model.PersistentStorageState.Host with
| false, _ ->
View.MainPageView.Main(model, dispatch)
| _, Some Swatehost.Excel ->
Expand Down
1 change: 1 addition & 0 deletions src/Client/Init.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ open Update

let initialModel =
{
PageState = PageState .init()
PersistentStorageState = PersistentStorageState .init()
DevState = DevState .init()
TermSearchState = TermSearch.Model .init()
Expand Down
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.ProtocolState.WidgetTypes = Routing.WidgetTypes.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
26 changes: 18 additions & 8 deletions src/Client/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ type PersistentStorageState = {
HasOntologiesLoaded = false
}

type PageState = {
SidebarPage : Routing.SidebarPage
MainPage: Routing.MainPage
} with
static member init () =
{
SidebarPage = SidebarPage.BuildingBlock
MainPage = MainPage.Default
}
member this.IsHome =
match this.MainPage with
| MainPage.Default -> true
| _ -> false

module FilePicker =
type Model = {
FileNames : (int*string) list
Expand Down Expand Up @@ -234,8 +248,7 @@ module Protocol =
// ------ Protocol from Database ------
TemplatesSelected : ARCtrl.Template list
Templates : ARCtrl.Template []
WidgetTypes : Routing.WidgetTypes
MainPage : Routing.MainPage
IsProtocolSearch : bool
} with
static member init () = {
// Client
Expand All @@ -244,13 +257,8 @@ module Protocol =
TemplatesSelected = []
// ------ Protocol from Database ------
Templates = [||]
WidgetTypes = WidgetTypes.BuildingBlock
MainPage = MainPage.Default
IsProtocolSearch = false
}
member this.IsHome =
match this.MainPage with
| MainPage.Default -> true
| _ -> false

type RequestBuildingBlockInfoStates =
| Inactive
Expand All @@ -263,6 +271,8 @@ type RequestBuildingBlockInfoStates =
| RequestDataBaseInformation -> "Search Database "

type Model = {
///PageState
PageState : PageState
///Data that needs to be persistent once loaded
PersistentStorageState : PersistentStorageState
///Error handling, Logging, etc.
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Pages/FilePicker/FilePickerView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let update (filePickerMsg:FilePicker.Msg) (state: FilePicker.Model) (model: Mode
let nextModel = {
model with
Model.FilePickerState.FileNames = fileNames |> List.mapi (fun i x -> i + 1, x)
Model.ProtocolState.WidgetTypes = Routing.WidgetTypes.FilePicker
Model.PageState.SidebarPage = Routing.SidebarPage.FilePicker
}
let nextCmd = UpdateModel nextModel|> Cmd.ofMsg
state, nextCmd
Expand Down
7 changes: 3 additions & 4 deletions src/Client/Pages/ProtocolTemplates/ProtocolSearch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ module private HelperProtocolSearch =
prop.children [
Html.ul [
Html.li [Html.a [
prop.onClick (fun _ -> UpdateModel {model with Model.ProtocolState.WidgetTypes = Routing.WidgetTypes.Protocol} |> dispatch)
prop.text (Routing.WidgetTypes.Protocol.AsStringRdbl)
prop.onClick (fun _ -> UpdateModel {model with Model.PageState.SidebarPage = Routing.SidebarPage.Protocol} |> dispatch)
prop.text (Routing.SidebarPage.Protocol.AsStringRdbl)
]]
Html.li [
prop.className "is-active"
prop.children (Html.a [
prop.onClick (fun _ -> UpdateModel {model with Model.ProtocolState.WidgetTypes = Routing.WidgetTypes.ProtocolSearch} |> dispatch)
prop.text (Routing.WidgetTypes.ProtocolSearch.AsStringRdbl)
prop.onClick (fun _ -> UpdateModel {model with Model.ProtocolState.IsProtocolSearch = true} |> dispatch)
])
]
]
Expand Down
6 changes: 3 additions & 3 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.ProtocolState.WidgetTypes = Routing.WidgetTypes.Protocol
Model.ProtocolState.IsProtocolSearch = false
Model.PageState.SidebarPage = Routing.SidebarPage.Protocol
}
state, Cmd.ofMsg (UpdateModel nextModel)
| AddProtocol prot ->
Expand All @@ -70,7 +70,7 @@ module Protocol =
let nextState = {
state with
TemplatesSelected = templates
WidgetTypes = Routing.WidgetTypes.ProtocolSearch
IsProtocolSearch = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not required, correct? As you would already be on the search screen? Remove it if it is not necessary to allow reusing this Msg in different logic approaches without switching to search view

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
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.ProtocolState.WidgetTypes = Routing.WidgetTypes.ProtocolSearch} |> dispatch)
prop.onClick(fun _ -> UpdateModel {model with Model.ProtocolState.IsProtocolSearch = true} |> dispatch)
button.primary
button.block
prop.text "Browse database"
Expand Down
6 changes: 1 addition & 5 deletions src/Client/Routing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ open Elmish.UrlParser
open Feliz

[<RequireQualifiedAccess>]
type WidgetTypes =
type SidebarPage =
| BuildingBlock
| TermSearch
| FilePicker
| Protocol
| ProtocolSearch
| JsonExport
| DataAnnotator

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

Expand All @@ -37,8 +35,6 @@ type WidgetTypes =
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
2 changes: 1 addition & 1 deletion src/Client/SharedComponents/NavbarBurger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type NavbarBurger =
[<ReactComponent>]
static member private Dropdown(isOpen, setIsOpen, model: Model.Model, dispatch) =

let navigateTo = fun (mainPage: Routing.MainPage) -> {model with Model.ProtocolState.MainPage = mainPage} |> Messages.UpdateModel |> dispatch
let navigateTo = fun (mainPage: Routing.MainPage) -> {model with Model.PageState.MainPage = mainPage} |> Messages.UpdateModel |> dispatch
Components.BaseDropdown.Main(
isOpen,
setIsOpen,
Expand Down
18 changes: 9 additions & 9 deletions src/Client/SidebarComponents/Tabs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ open Feliz.DaisyUI

type Tabs =

static member private NavigationTab (pageLink: Routing.WidgetTypes) (model:Model) (dispatch:Msg-> unit) =
let isActive = pageLink = model.ProtocolState.WidgetTypes
static member private NavigationTab (pageLink: Routing.SidebarPage) (model:Model) (dispatch:Msg-> unit) =
let isActive = pageLink = model.PageState.SidebarPage
Daisy.tab [
if isActive then tab.active
prop.className "navigation" // this class does not do anything, but disables <a> styling.
prop.onClick (fun e -> e.preventDefault(); UpdateModel { model with Model.ProtocolState.WidgetTypes = pageLink } |> dispatch)
prop.onClick (fun e -> e.preventDefault(); UpdateModel { model with Model.PageState.SidebarPage = pageLink } |> dispatch)
prop.children (pageLink.AsIcon())
]

Expand All @@ -25,11 +25,11 @@ type Tabs =
tabs.boxed
prop.className "w-full"
prop.children [
Tabs.NavigationTab Routing.WidgetTypes.BuildingBlock model dispatch
Tabs.NavigationTab Routing.WidgetTypes.TermSearch model dispatch
Tabs.NavigationTab Routing.WidgetTypes.Protocol model dispatch
Tabs.NavigationTab Routing.WidgetTypes.FilePicker model dispatch
Tabs.NavigationTab Routing.WidgetTypes.DataAnnotator model dispatch
Tabs.NavigationTab Routing.WidgetTypes.JsonExport model dispatch
Tabs.NavigationTab Routing.SidebarPage.BuildingBlock model dispatch
Tabs.NavigationTab Routing.SidebarPage.TermSearch model dispatch
Tabs.NavigationTab Routing.SidebarPage.Protocol model dispatch
Tabs.NavigationTab Routing.SidebarPage.FilePicker model dispatch
Tabs.NavigationTab Routing.SidebarPage.DataAnnotator model dispatch
Tabs.NavigationTab Routing.SidebarPage.JsonExport model dispatch
]
]
14 changes: 7 additions & 7 deletions src/Client/Views/MainPageViews.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open MainPageUtil
type MainPageView =

static member DrawerSideContentItem (model: Model.Model, route: Routing.MainPage, onclick) =
let isActive = model.ProtocolState.MainPage = route
let isActive = model.PageState.MainPage = route
Html.li [
prop.onClick onclick
prop.children [
Expand All @@ -35,7 +35,7 @@ type MainPageView =
prop.ariaLabel "Back to spreadsheet view"
button.link
button.sm
prop.onClick (fun _ -> UpdateModel {model with Model.ProtocolState.MainPage = Routing.MainPage.Default} |> dispatch)
prop.onClick (fun _ -> UpdateModel {model with Model.PageState.MainPage = Routing.MainPage.Default} |> dispatch)
prop.children [
Html.i [prop.className "fa-solid fa-arrow-left"]
Html.span "Back"
Expand All @@ -44,9 +44,9 @@ type MainPageView =
Html.ul [
prop.className "menu gap-y-1"
prop.children [
MainPageView.DrawerSideContentItem(model, Routing.MainPage.Settings, fun _ -> UpdateModel {model with Model.ProtocolState.MainPage = Routing.MainPage.Settings} |> dispatch)
MainPageView.DrawerSideContentItem(model, Routing.MainPage.About, fun _ -> UpdateModel {model with Model.ProtocolState.MainPage = Routing.MainPage.About} |> dispatch)
MainPageView.DrawerSideContentItem(model, Routing.MainPage.PrivacyPolicy, fun _ -> UpdateModel {model with Model.ProtocolState.MainPage = Routing.MainPage.PrivacyPolicy} |> dispatch)
MainPageView.DrawerSideContentItem(model, Routing.MainPage.Settings, fun _ -> UpdateModel {model with Model.PageState.MainPage = Routing.MainPage.Settings} |> dispatch)
MainPageView.DrawerSideContentItem(model, Routing.MainPage.About, fun _ -> UpdateModel {model with Model.PageState.MainPage = Routing.MainPage.About} |> dispatch)
MainPageView.DrawerSideContentItem(model, Routing.MainPage.PrivacyPolicy, fun _ -> UpdateModel {model with Model.PageState.MainPage = Routing.MainPage.PrivacyPolicy} |> dispatch)
]
]
]
Expand Down Expand Up @@ -78,7 +78,7 @@ type MainPageView =

Html.div [
prop.ariaLabel "logo"
prop.onClick (fun _ -> UpdateModel {model with Model.ProtocolState.MainPage = Routing.MainPage.Default} |> dispatch)
prop.onClick (fun _ -> UpdateModel {model with Model.PageState.MainPage = Routing.MainPage.Default} |> dispatch)
prop.className "cursor-pointer"
prop.children [
Html.img [
Expand All @@ -90,7 +90,7 @@ type MainPageView =
]

static member MainContent(model: Model.Model, dispatch) =
match model.ProtocolState.MainPage with
match model.PageState.MainPage with
| Routing.MainPage.Settings ->
Pages.Settings.Main(model, dispatch)
| Routing.MainPage.About ->
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.ProtocolState with
| {WidgetTypes = Routing.WidgetTypes.BuildingBlock } ->
BuildingBlock.Core.addBuildingBlockComponent model dispatch

| {WidgetTypes = Routing.WidgetTypes.TermSearch } ->
TermSearch.Main (model, dispatch)
if model.ProtocolState.IsProtocolSearch then
Protocol.SearchContainer.Main model dispatch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this if-else logic into the protocol view logic, do not handle this in sidebarview anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

else
match model.PageState with
| {SidebarPage = Routing.SidebarPage.BuildingBlock } ->
BuildingBlock.Core.addBuildingBlockComponent model dispatch

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

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

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

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

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

Expand Down
Loading