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

Add is_a directed search functionality to term search #34

Merged
merged 13 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20,796 changes: 20,796 additions & 0 deletions .db/mysql-dump/SwateDB.sql

Large diffs are not rendered by default.

155,604 changes: 0 additions & 155,604 deletions .db/mysql-dump/db.sql

This file was deleted.

2 changes: 1 addition & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Target.create "LocalConnectionStringSetup" (fun conf ->
]
[
(Path.combine __SOURCE_DIRECTORY__ ".db/docker-compose.yml")
(Path.combine __SOURCE_DIRECTORY__ "src/Server/Server.fs")
(Path.combine __SOURCE_DIRECTORY__ "src/Server/DevelopmentConnectionString.fs")
]

Trace.trace msg
Expand Down
70 changes: 20 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"react": "^16.10.2",
"react-dom": "^16.10.2",
"remotedev": "^0.2.9",
"resolve-url-loader": "^3.1.0",
"resolve-url-loader": "^3.1.2",
"sass": "^1.27.0",
"sass-loader": "^9.0.3",
"selfsigned": "^1.10.8",
Expand Down
8 changes: 8 additions & 0 deletions src/Client/AuxFunctions.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module AuxFunctions

open System.Text.RegularExpressions

let (|Regex|_|) pattern input =
let m = Regex.Match(input, pattern)
if m.Success then Some(m.Value)
else None
58 changes: 30 additions & 28 deletions src/Client/Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,22 @@ let init (pageOpt: Routing.Page option) : Model * Cmd<Msg> =
let view (model : Model) (dispatch : Msg -> unit) =

match model.PageState.CurrentPage with
| Routing.Page.TermSearch ->
| Routing.Page.AddBuildingBlock ->
BaseView.baseViewComponent model dispatch [
TermSearchView.termSearchComponent model dispatch
AddBuildingBlockView.addBuildingBlockComponent model dispatch
] [
str "Footer content"
AddBuildingBlockView.addBuildingBlockFooterComponent model dispatch
]

| Routing.Page.AddBuildingBlock ->

| Routing.Page.TermSearch ->
BaseView.baseViewComponent model dispatch [
AddBuildingBlockView.addBuildingBlockComponent model dispatch
TermSearchView.termSearchComponent model dispatch
] [
AddBuildingBlockView.addBuildingBlockFooterComponent model dispatch
str "Footer content"
]


| Routing.Page.FilePicker ->
BaseView.baseViewComponent model dispatch [
FilePickerView.filePickerComponent model dispatch
Expand All @@ -93,28 +95,28 @@ let view (model : Model) (dispatch : Msg -> unit) =
| Routing.Page.Home ->
div [] [str "soos"]

| _ ->
div [ Style [MinHeight "100vh"; BackgroundColor model.SiteStyleState.ColorMode.BodyBackground; Color model.SiteStyleState.ColorMode.Text;]
] [
Container.container [Container.IsFluid] [
br []
br []
Button.buttonComponent model.SiteStyleState.ColorMode true "make a test db insert xd" (fun _ -> ((sprintf "Me am test %A" (System.Guid.NewGuid())),"1","Me is testerino",System.DateTime.UtcNow,"MEEEMuser") |> TestOntologyInsert |> Request |> Api|> dispatch)
Button.buttonComponent model.SiteStyleState.ColorMode true "idk man=(" (fun _ -> TryExcel |> ExcelInterop |> dispatch)
Button.buttonComponent model.SiteStyleState.ColorMode true "create annoation table" (fun _ -> model.SiteStyleState.IsDarkMode |> CreateAnnotationTable |> ExcelInterop |> dispatch)
Button.buttonComponent model.SiteStyleState.ColorMode true "Log table metadata" (fun _ -> LogTableMetadata |> Dev |> dispatch)
Button.buttonComponent model.SiteStyleState.ColorMode true "Log table metadata" (fun _ -> LogTableMetadata |> Dev |> dispatch)

Footer.footer [ Props [ExcelColors.colorControl model.SiteStyleState.ColorMode]] [
Content.content [
Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Left)]
Content.Props [ExcelColors.colorControl model.SiteStyleState.ColorMode]
][

]
]
]
]
//| _ ->
// div [ Style [MinHeight "100vh"; BackgroundColor model.SiteStyleState.ColorMode.BodyBackground; Color model.SiteStyleState.ColorMode.Text;]
// ] [
// Container.container [Container.IsFluid] [
// br []
// br []
// Button.buttonComponent model.SiteStyleState.ColorMode true "make a test db insert xd" (fun _ -> ((sprintf "Me am test %A" (System.Guid.NewGuid())),"1","Me is testerino",System.DateTime.UtcNow,"MEEEMuser") |> TestOntologyInsert |> Request |> Api|> dispatch)
// Button.buttonComponent model.SiteStyleState.ColorMode true "idk man=(" (fun _ -> TryExcel |> ExcelInterop |> dispatch)
// Button.buttonComponent model.SiteStyleState.ColorMode true "create annoation table" (fun _ -> model.SiteStyleState.IsDarkMode |> CreateAnnotationTable |> ExcelInterop |> dispatch)
// Button.buttonComponent model.SiteStyleState.ColorMode true "Log table metadata" (fun _ -> LogTableMetadata |> Dev |> dispatch)
// Button.buttonComponent model.SiteStyleState.ColorMode true "Log table metadata" (fun _ -> LogTableMetadata |> Dev |> dispatch)

// Footer.footer [ Props [ExcelColors.colorControl model.SiteStyleState.ColorMode]] [
// Content.content [
// Content.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Left)]
// Content.Props [ExcelColors.colorControl model.SiteStyleState.ColorMode]
// ][

// ]
// ]
// ]
//]

#if DEBUG
open Elmish.Debug
Expand Down
1 change: 1 addition & 0 deletions src/Client/Client.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<None Include="paket.references" />
<None Include="style.scss" />
<Compile Include="Version.fs" />
<Compile Include="AuxFunctions.fs" />
<Compile Include="Routing.fs" />
<Compile Include="ExcelColors.fs" />
<Compile Include="OfficeJS.fs" />
Expand Down
6 changes: 3 additions & 3 deletions src/Client/CustomComponents/AdvancedSearch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let createOntologyDropdownItem (model:Model) (dispatch:Msg -> unit) (ont: DbDoma
Dropdown.Item.Props [
TabIndex 0
OnClick (fun _ -> ont |> OntologySuggestionUsed |> AdvancedSearch |> dispatch)
OnKeyDown (fun k -> if (int k.keyCode) = 13 then ont |> OntologySuggestionUsed |> AdvancedSearch |> dispatch)
OnKeyDown (fun k -> if k.key = "Enter" then ont |> OntologySuggestionUsed |> AdvancedSearch |> dispatch)
colorControl model.SiteStyleState.ColorMode
]

Expand Down Expand Up @@ -72,7 +72,7 @@ let createAdvancedTermSearchResultRows (model:Model) (dispatch: Msg -> unit) (su
let advancedTermSearchComponent (model:Model) (dispatch: Msg -> unit) =
form [
OnSubmit (fun e -> e.preventDefault())
OnKeyDown (fun k -> if (int k.keyCode) = 13 then k.preventDefault())
OnKeyDown (fun k -> if k.key = "Enter" then k.preventDefault())
] [
Field.div [] [
Label.label [Label.Props [Style [Color model.SiteStyleState.ColorMode.Accent]]] [ str "Ontology"]
Expand Down Expand Up @@ -261,7 +261,7 @@ let advancedSearchModal (model:Model) (id:string) (dispatch: Msg -> unit) (resul
Modal.Card.foot [] [
form [
OnSubmit (fun e -> e.preventDefault())
OnKeyDown (fun k -> if (int k.keyCode) = 13 then k.preventDefault())
OnKeyDown (fun k -> if k.key = "Enter" then k.preventDefault())
] [
Field.div [Field.HasAddons;Field.IsExpanded] [
Control.div [Control.IsExpanded] [
Expand Down
82 changes: 67 additions & 15 deletions src/Client/CustomComponents/AutocompleteSearch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ with
DropDownIsLoading = state.HasSuggestionsLoading

OnInputChangeMsg = (SearchTermTextChange >> TermSearch )
OnSuggestionSelect = (fun (term:DbDomain.Term) -> term.Name |> TermSuggestionUsed |> TermSearch)
OnSuggestionSelect = (fun (term:DbDomain.Term) -> term |> TermSuggestionUsed |> TermSearch)

HasAdvancedSearch = true
AdvancedSearchLinkText = "Cant find the Term you are looking for?"
OnAdvancedSearch = (fun (term:DbDomain.Term) -> term.Name |> TermSuggestionUsed |> TermSearch )
OnAdvancedSearch = (fun (term:DbDomain.Term) -> term |> TermSuggestionUsed |> TermSearch )
}

static member ofAddBuildingBlockUnitState (state:AddBuildingBlockState) : AutocompleteParameters<DbDomain.Term> = {
Expand Down Expand Up @@ -123,7 +123,7 @@ let createAutocompleteSuggestions
|> Array.map (fun sugg ->
tr [
OnClick (fun _ -> sugg.Data |> autocompleteParams.OnSuggestionSelect |> dispatch)
OnKeyDown (fun k -> if (int k.keyCode) = 13 then sugg.Data |> autocompleteParams.OnSuggestionSelect |> dispatch)
OnKeyDown (fun k -> if k.key = "Enter" then sugg.Data |> autocompleteParams.OnSuggestionSelect |> dispatch)
TabIndex 0
colorControl colorMode
Class "suggestion"
Expand Down Expand Up @@ -201,19 +201,71 @@ let autocompleteTermSearchComponent
=
Control.div [Control.IsExpanded] [
AdvancedSearch.advancedSearchModal model autocompleteParams.Id dispatch autocompleteParams.OnAdvancedSearch
Input.input [ Input.Placeholder inputPlaceholderText
match inputSize with
| Some size -> Input.Size size
| _ -> ()
Input.Props [
ExcelColors.colorControl colorMode
//OnFocus (fun e -> alert "focusout")
//OnBlur (fun e -> alert "focusin")
]
Input.OnChange (fun e -> e.Value |> autocompleteParams.OnInputChangeMsg |> dispatch)
Input.Value autocompleteParams.StateBinding
Input.input [
Input.Placeholder inputPlaceholderText
match inputSize with
| Some size -> Input.Size size
| _ -> ()
Input.Props [
ExcelColors.colorControl colorMode
//OnFocus (fun e -> alert "focusout")
//OnBlur (fun e -> alert "focusin")
]
Input.OnChange (fun e -> e.Value |> autocompleteParams.OnInputChangeMsg |> dispatch)
Input.Value autocompleteParams.StateBinding

]
]
autocompleteDropdownComponent
dispatch
colorMode
autocompleteParams.DropDownIsVisible
autocompleteParams.DropDownIsLoading
(createAutocompleteSuggestions dispatch colorMode autocompleteParams)
]

let autocompleteTermSearchComponentOfParentOntology
(dispatch: Msg -> unit)
(colorMode:ColorMode)
(model:Model)
(inputPlaceholderText : string)
(inputSize : ISize option)
(autocompleteParams : AutocompleteParameters<DbDomain.Term>)

=
let parentOntologyNotificationElement =
Control.p [][
Button.button [
Button.IsStatic true
match inputSize with
| Some size -> Button.Size size
| _ -> ()
] [str (sprintf "%A" model.TermSearchState.ParentOntology.Value)]
]

Control.div [Control.IsExpanded] [
AdvancedSearch.advancedSearchModal model autocompleteParams.Id dispatch autocompleteParams.OnAdvancedSearch
Field.div [Field.HasAddons][
if model.TermSearchState.ParentOntology.IsSome && model.TermSearchState.SearchByParentOntology then parentOntologyNotificationElement
Control.p [Control.IsExpanded][
Input.input [
Input.Placeholder inputPlaceholderText
match inputSize with
| Some size -> Input.Size size
| _ -> ()
Input.Props [
ExcelColors.colorControl colorMode
//OnFocus (fun e -> alert "focusout")
//OnBlur (fun e -> alert "focusin")
OnFocus (fun e ->
//GenericLog ("Info","FOCUSED!") |> Dev |> dispatch
GetParentTerm |> ExcelInterop |> dispatch
)
]
Input.OnChange (fun e -> e.Value |> autocompleteParams.OnInputChangeMsg |> dispatch)
Input.Value autocompleteParams.StateBinding
]
]
]
autocompleteDropdownComponent
dispatch
colorMode
Expand Down
10 changes: 7 additions & 3 deletions src/Client/Messages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ type ExcelInteropMsg =
| SyncContext of string
| InSync of string
| TryExcel
| FillSelection of string
| FillSelection of string * (DbDomain.Term option)
| AddColumn of colname:string * formatString:string
| FormatColumn of colname:string * formatString:string
| FormatColumn of colname:string * cloind:float * formatString:string
| CreateAnnotationTable of bool
| AnnotationtableCreated of string
| AnnotationTableExists of bool
| GetParentTerm

type TermSearchMsg =
| ToggleSearchByParentOntology
| SearchTermTextChange of string
| TermSuggestionUsed of string
| TermSuggestionUsed of DbDomain.Term
| NewSuggestions of DbDomain.Term []
| StoreParentOntologyFromOfficeInterop of obj option

type AdvancedSearchMsg =
| ResetAdvancedSearchState
Expand All @@ -44,6 +47,7 @@ type DevMsg =
type ApiRequestMsg =
| TestOntologyInsert of (string*string*string*System.DateTime*string)
| GetNewTermSuggestions of string
| GetNewTermSuggestionsByParentTerm of string*string
| GetNewBuildingBlockNameSuggestions of string
| GetNewUnitTermSuggestions of string
| GetNewAdvancedTermSearchResults of AdvancedTermSearchOptions
Expand Down
Loading