Skip to content

Commit

Permalink
Add Unit Column when selecting a unit for a term (Issue #48). Add opt…
Browse files Browse the repository at this point in the history
…ion to fill hidden cols according to main column (Issue #67).  Add input assist to delete hidden col cells onChange of main col (Issue #68).
  • Loading branch information
Freymaurer committed Dec 2, 2020
1 parent 13f3639 commit 5abee29
Show file tree
Hide file tree
Showing 22 changed files with 1,770 additions and 690 deletions.
9 changes: 4 additions & 5 deletions src/Client/Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module Server =
|> Remoting.buildProxy<IAnnotatorAPIv1>

let initializeAddIn () =
OfficeInterop.Office.onReady()
OfficeInterop.Types.Office.onReady()


// defines the initial state and initial command (= side-effect) of the application
let init (pageOpt: Routing.Route option) : Model * Cmd<Msg> =
Expand Down Expand Up @@ -127,9 +127,8 @@ let view (model : Model) (dispatch : Msg -> unit) =

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

// ]
//]

#if DEBUG
open Elmish.Debug
Expand Down
6 changes: 5 additions & 1 deletion src/Client/Client.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
<Compile Include="Routing.fs" />
<Compile Include="ExcelColors.fs" />
<Compile Include="OfficeJS.fs" />
<Compile Include="OfficeInterop.fs" />
<Compile Include="OfficeInterop\Types.fs" />
<Compile Include="OfficeInterop\Regex.fs" />
<Compile Include="OfficeInterop\HelperFunctions.fs" />
<Compile Include="OfficeInterop\EventHandlers.fs" />
<Compile Include="OfficeInterop\OfficeInterop.fs" />
<Compile Include="Api.fs" />
<Compile Include="Model.fs" />
<Compile Include="Messages.fs" />
Expand Down
4 changes: 2 additions & 2 deletions src/Client/CustomComponents/AutocompleteSearch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ with

AdvancedSearchLinkText = "Can't find the unit you are looking for?"
OnInputChangeMsg = (SearchUnitTermTextChange >> AddBuildingBlock)
OnSuggestionSelect = (fun sugg -> sugg.Name |> UnitTermSuggestionUsed |> AddBuildingBlock)
OnSuggestionSelect = (fun sugg -> (sugg.Name,sugg.Accession) |> UnitTermSuggestionUsed |> AddBuildingBlock)

HasAdvancedSearch = true
OnAdvancedSearch = (fun sugg -> sugg.Name |> UnitTermSuggestionUsed |> AddBuildingBlock)
OnAdvancedSearch = (fun sugg -> (sugg.Name,sugg.Accession) |> UnitTermSuggestionUsed |> AddBuildingBlock)
}

static member ofAddBuildingBlockState (state:AddBuildingBlockState) : AutocompleteParameters<DbDomain.Term> = {
Expand Down
46 changes: 38 additions & 8 deletions src/Client/CustomComponents/Navbar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ let navbarComponent (model : Model) (dispatch : Msg -> unit) =
Navbar.Item.a [Navbar.Item.Props [Props.Href "https://csb.bio.uni-kl.de/"]] [
img [Props.Src "../assets/CSB_Logo.png"]
]
Navbar.Item.a [Navbar.Item.Props [Title "Add New Annotation Table"; Style [ Color model.SiteStyleState.ColorMode.Text]]] [
Button.a [
Button.Props [Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground]]
Button.OnClick (fun _ ->
(fun (allNames) ->
CreateAnnotationTable (allNames,model.SiteStyleState.IsDarkMode))
|> PipeCreateAnnotationTableInfo
|> ExcelInterop
|> dispatch
)
Button.Color Color.IsWhite
Button.IsInverted
] [
Fa.span [Fa.Solid.Plus][]
Fa.span [Fa.Solid.Table][]
]
]
Navbar.Item.a [Navbar.Item.Props [Title "Autoformat Table"; Style [ Color model.SiteStyleState.ColorMode.Text]]] [
Button.a [
Button.Props [Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground]]
Expand All @@ -26,21 +43,34 @@ let navbarComponent (model : Model) (dispatch : Msg -> unit) =
Fa.i [Fa.Solid.SyncAlt][]
]
]
Navbar.Item.a [Navbar.Item.Props [Title "Add New Annotation Table"; Style [ Color model.SiteStyleState.ColorMode.Text]]] [
Navbar.Item.a [Navbar.Item.Props [Title "Toggle Reference Column Input Assist"; Style [ Color model.SiteStyleState.ColorMode.Text]]] [
Button.a [
Button.Props [Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground]]
Button.OnClick (fun _ ->
(fun (allNames) ->
CreateAnnotationTable (allNames,model.SiteStyleState.IsDarkMode))
|> PipeCreateAnnotationTableInfo
|> ExcelInterop
|> dispatch
ToggleEventHandler |> ExcelInterop |> dispatch
)
Button.Color Color.IsWhite
Button.IsInverted
] [
Fa.span [Fa.Solid.Plus][]
Fa.span [Fa.Solid.Table][]
Fa.span [Fa.Solid.Edit][]
Fa.span [
Fa.Solid.Sync
if model.ExcelState.TablesHaveAutoEditHandler then Fa.Spin
][]
]
]
Navbar.Item.a [Navbar.Item.Props [Title "Fill Reference Columns"; Style [ Color model.SiteStyleState.ColorMode.Text]]] [
Button.a [
Button.Props [Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground]]
Button.OnClick (fun _ ->
PipeActiveAnnotationTable FillHiddenColsRequest |> ExcelInterop |> dispatch
)
Button.Color Color.IsWhite
Button.IsInverted
] [
Fa.span [Fa.Solid.EyeSlash][]
span [][str model.ExcelState.FillHiddenColsStateStore.toReadableString]
Fa.span [Fa.Solid.Pen][]
]
]
Navbar.burger [ Navbar.Burger.IsActive model.SiteStyleState.BurgerVisible
Expand Down
35 changes: 28 additions & 7 deletions src/Client/Messages.fs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
module Messages

open Elmish
open Thoth.Elmish

open Shared

open ExcelColors
open OfficeInterop
open OfficeInterop.Types.SwateInteropTypes
open Model
open Elmish
open Thoth.Elmish

type ExcelInteropMsg =
| PipeActiveAnnotationTable of (TryFindAnnoTableResult -> ExcelInteropMsg)
/// This is used to pipe (all table names * active annotation table option) to 'CreateAnnotationTable'. This is necessary to generate a new annotation table name.
/// This is used to pipe (all table names []) to a ExcelInteropMsg.
/// This is used to generate a new annotation table name.
| PipeCreateAnnotationTableInfo of (string [] -> ExcelInteropMsg)
| Initialized of (string*string)
| SyncContext of activeAnnotationTable:TryFindAnnoTableResult*string
| InSync of string
| TryExcel
| FillSelection of activeAnnotationTable:TryFindAnnoTableResult * string * (DbDomain.Term option)
| AddColumn of activeAnnotationTable:TryFindAnnoTableResult * colname:string * formatString:string
| AddColumn of activeAnnotationTable:TryFindAnnoTableResult * colname:string * format:(string*string option) option
| FormatColumn of activeAnnotationTable:TryFindAnnoTableResult * colname:string * formatString:string * prevmsg:string
/// This message does not need the active annotation table as `PipeCreateAnnotationTableInfo` checks if any annotationtables exist in the active worksheet, and if so, errors.
| CreateAnnotationTable of allTableNames:string [] * isDark:bool
Expand All @@ -25,6 +28,17 @@ type ExcelInteropMsg =
| GetParentTerm of activeAnnotationTable:TryFindAnnoTableResult
| AutoFitTable of activeAnnotationTable:TryFindAnnoTableResult
| GetTableRepresentation of activeAnnotationTable:TryFindAnnoTableResult
//
| ToggleEventHandler
| UpdateTablesHaveAutoEditHandler
//
| FillHiddenColsRequest of activeAnnotationTable:TryFindAnnoTableResult
| FillHiddenColumns of tableName:string*InsertTerm []
| UpdateFillHiddenColsState of FillHiddenColsState
// Development
| TryExcel
| TryExcel2
//| ExcelSubscriptionMsg of OfficeInterop.Types.Subscription.Msg

type TermSearchMsg =
| ToggleSearchByParentOntology
Expand Down Expand Up @@ -61,6 +75,10 @@ type ApiRequestMsg =
| GetNewUnitTermSuggestions of string
| GetNewAdvancedTermSearchResults of AdvancedTermSearchOptions
| FetchAllOntologies
/// This function is used to search for all values found in the table main columns.
/// InsertTerm [] is created by officeInterop and passed to server for db search.
| SearchForInsertTermsRequest of tableName:string*InsertTerm []
//
| GetAppVersion

type ApiResponseMsg =
Expand All @@ -69,6 +87,8 @@ type ApiResponseMsg =
| BuildingBlockNameSuggestionsResponse of DbDomain.Term []
| UnitTermSuggestionResponse of DbDomain.Term []
| FetchAllOntologiesResponse of DbDomain.Ontology []
| SearchForInsertTermsResponse of tableName:string*InsertTerm []
//
| GetAppVersionResponse of string

type ApiMsg =
Expand Down Expand Up @@ -98,7 +118,7 @@ type AddBuildingBlockMsg =
| NewBuildingBlockNameSuggestions of DbDomain.Term []

| SearchUnitTermTextChange of string
| UnitTermSuggestionUsed of string
| UnitTermSuggestionUsed of unitName:string*unitAccession:string
| NewUnitTermSuggestions of DbDomain.Term []
| ToggleBuildingBlockHasUnit

Expand All @@ -109,7 +129,7 @@ type ValidationMsg =
| UpdateValidationFormat of (ValidationFormat*ValidationFormat)

// OfficeInterop
| StoreTableRepresentationFromOfficeInterop of msg:string * OfficeInterop.ColumnRepresentation []
| StoreTableRepresentationFromOfficeInterop of msg:string * OfficeInterop.Types.SwateInteropTypes.ColumnRepresentation []

type Msg =
| Bounce of (System.TimeSpan*string*Msg)
Expand All @@ -125,6 +145,7 @@ type Msg =
| AddBuildingBlock of AddBuildingBlockMsg
| Validation of ValidationMsg
| UpdatePageState of Routing.Route option
| Batch of seq<Msg>
| DoNothing

/// This function is used to easily pipe a message into `PipeActiveAnnotationTable`. This is designed for a message with (x1) other params.
Expand Down
44 changes: 34 additions & 10 deletions src/Client/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ open Shared
open Thoth.Elmish
open Routing

open OfficeInterop.Types.SwateInteropTypes

type LogItem =
| Debug of (System.DateTime*string)
| Info of (System.DateTime*string)
Expand Down Expand Up @@ -34,10 +36,10 @@ type LogItem =

static member ofStringNow (level:string) (message: string) =
match level with
| "Debug" -> Debug(System.DateTime.UtcNow,message)
| "Info" -> Info (System.DateTime.UtcNow,message)
| "Error" -> Error(System.DateTime.UtcNow,message)
| _ -> Error(System.DateTime.UtcNow,"wut?")
| "Debug"| "debug" -> Debug(System.DateTime.UtcNow,message)
| "Info" | "info" -> Info (System.DateTime.UtcNow,message)
| "Error" | "error" -> Error(System.DateTime.UtcNow,message)
| others -> Error(System.DateTime.UtcNow,sprintf "Swate found an unexpected log identifier: %s" others)

type TermSearchMode =
| Simple
Expand Down Expand Up @@ -140,15 +142,31 @@ type PersistentStorageState = {
HasOntologiesLoaded = false
}

type FillHiddenColsState =
| Inactive
| ExcelCheckHiddenCols
| ServerSearchDatabase
| ExcelWriteFoundTerms
member this.toReadableString =
match this with
| Inactive -> ""
| ExcelCheckHiddenCols -> "Check Hidden Cols"
| ServerSearchDatabase -> "Search Database"
| ExcelWriteFoundTerms -> "Write Terms"

type ExcelState = {
Host : string
Platform : string
HasAnnotationTable : bool
Host : string
Platform : string
HasAnnotationTable : bool
TablesHaveAutoEditHandler : bool
FillHiddenColsStateStore : FillHiddenColsState
} with
static member init () = {
Host = ""
Platform = ""
HasAnnotationTable = false
TablesHaveAutoEditHandler = false
FillHiddenColsStateStore = Inactive
}

type ApiCallStatus =
Expand Down Expand Up @@ -198,6 +216,8 @@ type FilePickerState = {
FileNames = []
}


/// If this is changed, see also OfficeInterop.Types.ColumnCoreNames
type AnnotationBuildingBlockType =
| NoneSelected
| Parameter
Expand Down Expand Up @@ -264,6 +284,7 @@ type AnnotationBuildingBlock = {
| Characteristics -> sprintf "Characteristics [%s]" block.Name
| Sample -> "Sample Name"
| Data -> "Data File Name"
| Source -> "Source Name"
| _ -> ""


Expand All @@ -280,7 +301,10 @@ type AddBuildingBlockState = {
UnitTermSuggestions : DbDomain.Term []
HasUnitTermSuggestionsLoading : bool
ShowUnitTermSuggestions : bool
UnitFormat : string
/// This entry determines if the current UnitTermSearchText is a real term or if it is a customly typed unit.
/// If UnitTermSearchTextHasTermID.IsSome then the string is the Term.Accession else it is customely typed.
/// This is necessary to store the information about the Term.Accession for TAN in the unit columns.
UnitTermSearchTextHasTermAccession : string option

} with
static member init () = {
Expand All @@ -296,7 +320,7 @@ type AddBuildingBlockState = {
UnitTermSuggestions = [||]
HasUnitTermSuggestionsLoading = false
ShowUnitTermSuggestions = false
UnitFormat = ""
UnitTermSearchTextHasTermAccession = None
}

/// User can define what kind of input a column should have
Expand Down Expand Up @@ -330,7 +354,7 @@ type ValidationFormat = {

/// Validation scheme for Table
type ValidationState = {
TableRepresentation : OfficeInterop.ColumnRepresentation []
TableRepresentation : OfficeInterop.Types.SwateInteropTypes.ColumnRepresentation []
TableValidationScheme : ValidationFormat []
// Client view related
DisplayedOptionsId : int option
Expand Down
Loading

0 comments on commit 5abee29

Please sign in to comment.