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 replace table name with template name #586

Merged
merged 23 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bffed7f
Enable selection of terms to import into excel
Etschbeijer Nov 27, 2024
2aa0ddf
Fix error in swate alpha
Etschbeijer Nov 28, 2024
b179a4a
Move basic modal element creation methods into separat file
Etschbeijer Nov 28, 2024
b46fc28
Replace existing TemplateFromDB with Modal
Etschbeijer Nov 28, 2024
04a2cb7
Add usage of selected columns to swate alpha
Etschbeijer Nov 29, 2024
12d4d78
Adapt box layout
Etschbeijer Dec 2, 2024
450cda8
Enable column selection and import type selection for templates and j…
Etschbeijer Dec 3, 2024
c2064a5
update layout
Etschbeijer Dec 3, 2024
4d11c9a
Improve layout by adding gaps
Etschbeijer Dec 3, 2024
2cf7798
Adapted Cehckbox height
Etschbeijer Dec 3, 2024
ace120f
Apply review changes
Etschbeijer Dec 3, 2024
849b155
Implemente review changes
Etschbeijer Dec 3, 2024
869ade6
Implemented review suggestions
Etschbeijer Dec 3, 2024
ca0a1d4
Implement review changes
Etschbeijer Dec 3, 2024
6ddefa4
Implement review changes
Etschbeijer Dec 3, 2024
5feb2b1
Implement review changes
Etschbeijer Dec 4, 2024
65c36e8
Enable the addition of names in excel
Etschbeijer Dec 4, 2024
9cf7d21
Enable usage of selectedColumns in swate alpha
Etschbeijer Dec 4, 2024
88edd04
Rename Method to origin
Etschbeijer Dec 4, 2024
95dcf24
Enable naming of radioGroup to enable usage in swate alpha
Etschbeijer Dec 4, 2024
76e4422
Merge branch 'Feature_Excel_EnableSelectionOfImportedTermsForTemplate…
Etschbeijer Dec 5, 2024
463a70c
Updated takeover templatename for excel
Etschbeijer Dec 5, 2024
e4d42d8
Rename table in swate alpha
Etschbeijer Dec 5, 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
3 changes: 2 additions & 1 deletion src/Client/Client.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="Messages.fs" />
<Compile Include="ARCitect\Interop.fs" />
<Compile Include="ARCitect\ARCitect.fs" />
<Compile Include="Modals\ModalElements.fs" />
<Compile Include="Modals\Util.fs" />
<Compile Include="Modals\ContextMenus\Util.fs" />
<Compile Include="Modals\ContextMenus\Base.fs" />
Expand Down Expand Up @@ -90,7 +91,7 @@
<Compile Include="Pages\ProtocolTemplates\ProtocolState.fs" />
<Compile Include="Pages\ProtocolTemplates\ProtocolSearchViewComponent.fs" />
<Compile Include="Pages\ProtocolTemplates\ProtocolSearch.fs" />
<Compile Include="Pages\ProtocolTemplates\TemplateFromDB.fs" />
<Compile Include="Pages\ProtocolTemplates\SelectiveTemplateFromDB.fs" />
<Compile Include="Pages\ProtocolTemplates\TemplateFromFile.fs" />
<Compile Include="Pages\ProtocolTemplates\ProtocolView.fs" />
<Compile Include="Pages\FilePicker\FilePickerView.fs" />
Expand Down
1 change: 1 addition & 0 deletions src/Client/GenericComponents.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module DaisyUiExtensions =
static member active = prop.className "modal-open"

type Components =

static member DeleteButton(?children, ?props) =
Daisy.button.button [
button.square
Expand Down
7 changes: 7 additions & 0 deletions src/Client/Helper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module Helper

open Fable.Core

open System

let log (a) = Browser.Dom.console.log a

let logw (a) = Browser.Dom.console.warn a
Expand Down Expand Up @@ -121,6 +123,11 @@ let throttleAndDebounce(fn: 'a -> unit, timespan: int) =
timespan
id <- Some timeoutId

let charsToRemove = " -/\()[]{}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Regex.Replace with "\s"


//Regex is incapable to remove the whitespaces
let removeChars (stripChars:string) (text:string) =
text.Split(stripChars.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) |> String.Concat

type Clipboard =
abstract member writeText: string -> JS.Promise<unit>
Expand Down
49 changes: 45 additions & 4 deletions src/Client/MainComponents/Widgets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ open Feliz
open Feliz.DaisyUI
open Browser.Types
open LocalStorage.Widgets
open Modals
open Types.TableImport
open Types.JsonImport

module private InitExtensions =

Expand Down Expand Up @@ -212,6 +215,13 @@ type Widget =
static member Templates (model: Model, dispatch, rmv: MouseEvent -> unit) =
let templates, setTemplates = React.useState(model.ProtocolState.Templates)
let config, setConfig = React.useState(TemplateFilterConfig.init)
let selectedColumnsLength =
if model.ProtocolState.TemplateSelected.IsSome then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Option.map |> Option.defaltValue

model.ProtocolState.TemplateSelected.Value.Table.Columns.Length
else 0
let selectedColumns, setSelectedColumns = React.useState(SelectedColumns.init selectedColumnsLength)
let importTypeState, setImportTypeState = React.useState(SelectiveImportModalState.init)
let useTemplateName, setUseTemplateName = React.useState(AdaptTableName.init)
let filteredTemplates = Protocol.Search.filterTemplates (templates, config)
React.useEffectOnce(fun _ -> Messages.Protocol.GetAllProtocolsRequest |> Messages.ProtocolMsg |> dispatch)
React.useEffect((fun _ -> setTemplates model.ProtocolState.Templates), [|box model.ProtocolState.Templates|])
Expand All @@ -222,13 +232,44 @@ type Widget =
]
let insertContent() =
[
Html.div [
Protocol.TemplateFromDB.addFromDBToTableButton model dispatch
]
Html.div [
prop.style [style.maxHeight (length.px 350); style.overflow.auto]
prop.children [
Protocol.TemplateFromDB.displaySelectedProtocolEle model dispatch
SidebarComponents.SidebarLayout.LogicContainer [
Html.div [
SelectiveTemplateFromDBModal.ToProtocolSearchElement model dispatch
]
if model.ProtocolState.TemplateSelected.IsSome then
Html.div [
SelectiveImportModal.RadioPluginsBox(
"Import Type",
"fa-solid fa-cog",
importTypeState.ImportType,
"importType ",
[|
ARCtrl.TableJoinOptions.Headers, " Column Headers";
ARCtrl.TableJoinOptions.WithUnit, " ..With Units";
ARCtrl.TableJoinOptions.WithValues, " ..With Values";
|],
fun importType -> {importTypeState with ImportType = importType} |> setImportTypeState
)
]
Html.div [
ModalElements.Box(
"Rename Table",
"fa-solid fa-cog",
SelectiveTemplateFromDBModal.CheckBoxForTakeOverTemplateName(useTemplateName, setUseTemplateName, model.ProtocolState.TemplateSelected.Value.Name))
]
Html.div [
ModalElements.Box(
model.ProtocolState.TemplateSelected.Value.Name,
"",
SelectiveTemplateFromDBModal.displaySelectedProtocolElements(model, selectedColumns, setSelectedColumns, dispatch, false))
]
Html.div [
SelectiveTemplateFromDBModal.AddFromDBToTableButton model selectedColumns importTypeState useTemplateName.TemplateName dispatch
]
]
]
]
]
Expand Down
108 changes: 108 additions & 0 deletions src/Client/Modals/ModalElements.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
namespace Modals

open Feliz
open Feliz.DaisyUI
open Model
open Messages
open Shared
open Types.TableImport

open ARCtrl
open JsonImport
open Components
open Fable.React.Helpers

type ModalElements =

static member Button(text: string, onClickAction, buttonInput, ?isDisabled: bool) =
let isDisabled = defaultArg isDisabled false
Daisy.button.a [
button.success
button.wide
if isDisabled then
button.error
prop.disabled isDisabled
prop.onClick (fun _ -> onClickAction buttonInput)

prop.text text
]

static member RadioPlugin(radioGroup: string, txt: string, isChecked, onChange: bool -> unit, ?isDisabled: bool) =
let isDisabled = defaultArg isDisabled false
Daisy.formControl [
Daisy.label [
prop.className [
"cursor-pointer transition-colors"
if isDisabled then
"!cursor-not-allowed"
else
"hover:bg-base-300"
]
prop.children [
Daisy.radio [
prop.disabled isDisabled
radio.xs
prop.name radioGroup
prop.isChecked isChecked
prop.onChange onChange
]
Html.span [
prop.className "text-sm"
prop.text txt
]
]
]
]

static member Box(title: string, icon: string, content: ReactElement, ?className: string list) =
Html.div [
prop.className [
"rounded shadow p-2 flex flex-col gap-2 border"
if className.IsSome then
className.Value |> String.concat " "
]
prop.children [
Html.h3 [
prop.className "font-semibold gap-2 flex flex-row items-center"
prop.children [
Html.i [prop.className icon]
Html.span title
]
]
content
]
]

static member BoxWithChildren(children: ReactElement list, ?title: string, ?icon: string, ?className: string list) =
Html.div [
prop.className [
"rounded shadow p-2 flex flex-col gap-2 border"
if className.IsSome then
className.Value |> String.concat " "
]
prop.children [
Html.h3 [
prop.className "font-semibold gap-2 flex flex-row items-center"
if icon.IsSome || title.IsSome then
prop.children [
if icon.IsSome then
Html.i [prop.className icon.Value]
if title.IsSome then
Html.span title.Value
]
prop.children children
]
]
]

static member SelectorButton<'a when 'a : equality> (targetselector: 'a, selector: 'a, setSelector: 'a -> unit, ?isDisabled) =
Daisy.button.button [
join.item
if isDisabled.IsSome then
prop.disabled isDisabled.Value
prop.style [style.flexGrow 1]
if (targetselector = selector) then
button.primary
prop.onClick (fun _ -> setSelector targetselector)
prop.text (string targetselector)
]
Loading
Loading