Skip to content

Commit

Permalink
Fix bug not finding the correct selected building block (Issue #121).
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Mar 1, 2021
1 parent 183a80c commit ba4f238
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 51 deletions.
24 changes: 14 additions & 10 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
### 0.4.0+5118778 (Released 2021-2-25)
### 0.4.0+183a80c (Released 2021-3-1)
* Additions:
* latest commit #5118778
* [[#5118778](https://github.com/nfdi4plants/Swate/commit/5118778e38a95a1e71e7a80488fd2a5e9fd63715)] Rename validation to checklist
* [[#f61793a](https://github.com/nfdi4plants/Swate/commit/f61793a949250ffa05d34ebbc19c8fa2fba4fb3b)] Refactor PipeActiveTable logic :hammer:
* latest commit #183a80c
* [[#24950d1](https://github.com/nfdi4plants/Swate/commit/24950d160548a04e080b7bd283a699b611a116a6)] Minor visual updates
* [[#183a80c](https://github.com/nfdi4plants/Swate/commit/183a80c31f823ad56706459dacc631fd2da0becb)] Update dropdown navbar quick access.
* [[#4b818db](https://github.com/nfdi4plants/Swate/commit/4b818db47d9662964be0515075945a3fa4b3261c)] Add Advanced custom xml settings (Issue #111).
* [[#d7cce09](https://github.com/nfdi4plants/Swate/commit/d7cce0939cfdd1212e8ea1e4f12863d77280d50e)] Add link to nfdi4pso issues (Issue #99).
* [[#848acf7](https://github.com/nfdi4plants/Swate/commit/848acf7092daf70a9f8ae6f129b58751cfe14191)] Add "Update unit" functionality (Issue #110).
* [[#5118778](https://github.com/nfdi4plants/Swate/commit/5118778e38a95a1e71e7a80488fd2a5e9fd63715)] Rename validation to checklist
* [[#58b58a4](https://github.com/nfdi4plants/Swate/commit/58b58a42eef1ee08f63059ae2e971e74f8d29b15)] Add drop down for quick access icons
* [[#3778ebc](https://github.com/nfdi4plants/Swate/commit/3778ebc951857295234d2c6d12bacce27bf29fd6)] Add copy to clipboard to term search for vertical term insert (Issue #118).
* [[#eff46ae](https://github.com/nfdi4plants/Swate/commit/eff46aec41e4f0eb529d7f37ac789f352c85f5b4)] Restructure CustomXml :hammer::boom:
* [[#f8741ab](https://github.com/nfdi4plants/Swate/commit/f8741abf7442558dafb049dad7c96f963eaf8485)] Adjust custom validation xml.
* [[#2d816fc](https://github.com/nfdi4plants/Swate/commit/2d816fc2a07ff96250da6d79c2784350e96d885c)] Improve Userfeedback for show building block info.
* [[#05ec1c4](https://github.com/nfdi4plants/Swate/commit/05ec1c4ec4e7634ba91a7f319f3f99bc31d68ee9)] Made file picker Drag'n'Drop lines thicker (Issue #112).
* [[#7760257](https://github.com/nfdi4plants/Swate/commit/7760257839839a03641ba5172d46fe77d97353dc)] Improve addition of validation importance (Issue #113).
* [[#44d9277](https://github.com/nfdi4plants/Swate/commit/44d9277901a8cb617bca1b78be679c12b4fc362b)] Add option to show all child terms (Issue #114).
* [[#80c6235](https://github.com/nfdi4plants/Swate/commit/80c6235759e13263316e4c8f60b9d0f5eb7bc947)] Improve term search search speed.
* [[#19a2f73](https://github.com/nfdi4plants/Swate/commit/19a2f739688a4819cf3275de348d41afa1351fc3)] Add button to display building block information (Issue #96).
* [[#746ecf4](https://github.com/nfdi4plants/Swate/commit/746ecf4c3036f3c68b92d4d74c37118e491f83c1)] Redo autocomplete search on double click.
* [[#454ccd7](https://github.com/nfdi4plants/Swate/commit/454ccd7368e61ff5b669b197c5cd3d0ade7b1c6b)] Add database template logic (Issue #10, #107) :sparkles:
* [[#19a2f73](https://github.com/nfdi4plants/Swate/commit/19a2f739688a4819cf3275de348d41afa1351fc3)] Add button to display building block information (Issue #96).
* [[#71801ff](https://github.com/nfdi4plants/Swate/commit/71801ff2e558834ed5bb413d8b62d2f7eea48419)] Add 'Remove Building Block' button (Issue #102).
* [[#80c6235](https://github.com/nfdi4plants/Swate/commit/80c6235759e13263316e4c8f60b9d0f5eb7bc947)] Improve term search search speed.
* [[#7760257](https://github.com/nfdi4plants/Swate/commit/7760257839839a03641ba5172d46fe77d97353dc)] Improve addition of validation importance (Issue #113).
* Bugfixes:
* [[#41e298d](https://github.com/nfdi4plants/Swate/commit/41e298d4369d320331b50c7d08494567daac7004)] Fix updating protocol group header bug if split too often (Issue #120).
* [[#01d5cf5](https://github.com/nfdi4plants/Swate/commit/01d5cf5db6152ca16d8fa765c80fd9034d8c9f8e)] Fix protocol group headers not correctly removed bug (Issue #119).

### 0.3.1+cbc655c (Released 2021-2-12)
* Additions:
Expand Down
2 changes: 0 additions & 2 deletions src/Client/CustomComponents/Navbar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ let quickAccessDropdownElement model dispatch =
div [
Class "arrow_box"
Style [
//Width "150px"
//Left "-69px"
Display (if model.SiteStyleState.QuickAcessIconsShown then DisplayOptions.Block else DisplayOptions.None)
Position PositionOptions.Absolute
ZIndex "20"
Expand Down
31 changes: 24 additions & 7 deletions src/Client/OfficeInterop/HelperFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,17 @@ module BuildingBlockTypes =
context.sync().``then``( fun _ ->

if selectedRange.columnCount <> 1. then
failwith "To add a unit please select a single column"
failwith "To use this function please select a single column"

let errorMsg = "To use this function please select a single column of a Swate table."

let newSelectedColIndex =
// recalculate the selected range index based on table
let diff = selectedRange.columnIndex - annoHeaderRange.columnIndex
// if index is smaller 0 it is outside of table range
if diff <= 0. then 0.
if diff < 0. then failwith errorMsg
// if index is bigger than columnCount-1 then it is outside of tableRange
elif diff >= annoHeaderRange.columnCount-1. then annoHeaderRange.columnCount-1.
elif diff > annoHeaderRange.columnCount-1. then failwith errorMsg
else diff

/// Sort all columns into building blocks.
Expand Down Expand Up @@ -517,9 +519,22 @@ module BuildingBlockTypes =
Shared.SearchTermI.create colIndices searchString termAccession None rowIndices

let private sortHeaderToSearchTerm (buildingBlock:BuildingBlock) =
let searchString = buildingBlock.MainColumn.Header.Value.Ontology.Value.Name
let termAccession = buildingBlock.MainColumn.Header.Value.Ontology.Value.TermAccession
let colIndices = [|buildingBlock.MainColumn.Index; buildingBlock.TSR.Value.Index; buildingBlock.TAN.Value.Index|]
let isOntologyTerm = buildingBlock.MainColumn.Header.Value.Ontology.IsSome
let searchString =
if isOntologyTerm then
buildingBlock.MainColumn.Header.Value.Ontology.Value.Name
else
buildingBlock.MainColumn.Header.Value.Header
let termAccession =
if isOntologyTerm then
buildingBlock.MainColumn.Header.Value.Ontology.Value.TermAccession
else
""
let colIndices = [|
buildingBlock.MainColumn.Index;
if buildingBlock.TSR.IsSome then buildingBlock.TSR.Value.Index;
if buildingBlock.TAN.IsSome then buildingBlock.TAN.Value.Index
|]
let rowIndices = buildingBlock.MainColumn.Cells |> Array.map (fun x -> x.Index)
Shared.SearchTermI.create colIndices searchString termAccession None rowIndices

Expand Down Expand Up @@ -548,7 +563,9 @@ module BuildingBlockTypes =
| _ -> failwith (sprintf "Encountered unknown reference column pattern. Building block (%s) can only contain both TSR and TAN or none." buildingBlock.MainColumn.Header.Value.Header)

let sortBuildingBlockToSearchTerm (buildingBlock:BuildingBlock) =
[|yield! sortBuildingBlockValuesToSearchTerm buildingBlock; sortHeaderToSearchTerm buildingBlock|]
let bbValuesToSearchTerm = sortBuildingBlockValuesToSearchTerm buildingBlock
let bbHeaderToSearchTerm = sortHeaderToSearchTerm buildingBlock
[|yield! bbValuesToSearchTerm; bbHeaderToSearchTerm|]

let sortBuildingBlocksValuesToSearchTerm (buildingBlocks:BuildingBlock []) =

Expand Down
35 changes: 8 additions & 27 deletions src/Client/OfficeInterop/OfficeInterop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,31 +1568,12 @@ let addUnitToExistingBuildingBlock (format:string option,unitAccessionOpt:string
// Ref. 2
let annoHeaderRange, annoBodyRange = BuildingBlockTypes.getBuildingBlocksPreSync context annotationTable

let! selectedBuildingBlock =
BuildingBlockTypes.findSelectedBuildingBlock selectedRange annoHeaderRange annoBodyRange context

let! res = context.sync().``then``( fun _ ->

if selectedRange.columnCount <> 1. then
failwith "To add a unit please select a single column"

let newSelectedColIndex =
// recalculate the selected range index based on table
let diff = selectedRange.columnIndex - annoHeaderRange.columnIndex
// if index is smaller 0 it is outside of table range
if diff <= 0. then 0.
// if index is bigger than columnCount-1 then it is outside of tableRange
elif diff >= annoHeaderRange.columnCount-1. then annoHeaderRange.columnCount-1.
else diff

/// Sort all columns into building blocks.
let buildingBlocks =
getBuildingBlocks annoHeaderRange annoBodyRange

/// find building block with the closest main column index from left
let findLeftClosestBuildingBlock =
buildingBlocks
|> Array.filter (fun x -> x.MainColumn.Index <= int newSelectedColIndex)
|> Array.minBy (fun x -> Math.Abs(x.MainColumn.Index - int newSelectedColIndex))

if findLeftClosestBuildingBlock.TAN.IsNone || findLeftClosestBuildingBlock.TSR.IsNone then
if selectedBuildingBlock.TAN.IsNone || selectedBuildingBlock.TSR.IsNone then
failwith (
sprintf
"Swate can only add a unit to columns of the type: %s, %s, %s."
Expand All @@ -1611,12 +1592,12 @@ let addUnitToExistingBuildingBlock (format:string option,unitAccessionOpt:string
|> Array.map string

let unitColumnResult =
if findLeftClosestBuildingBlock.Unit.IsSome then
updateUnitColumns allColHeaders annoHeaderRange (float findLeftClosestBuildingBlock.MainColumn.Index) format unitAccessionOpt
if selectedBuildingBlock.Unit.IsSome then
updateUnitColumns allColHeaders annoHeaderRange (float selectedBuildingBlock.MainColumn.Index) format unitAccessionOpt
else
createUnitColumns allColHeaders table (float findLeftClosestBuildingBlock.MainColumn.Index) (int tableRange.rowCount) format unitAccessionOpt
createUnitColumns allColHeaders table (float selectedBuildingBlock.MainColumn.Index) (int tableRange.rowCount) format unitAccessionOpt

let maincolName = findLeftClosestBuildingBlock.MainColumn.Header.Value.Header
let maincolName = selectedBuildingBlock.MainColumn.Header.Value.Header

/// If unit block was added then return some msg information
//let unitColCreationMsg = if unitColumnResult.IsSome then fst unitColumnResult.Value else ""
Expand Down
6 changes: 3 additions & 3 deletions src/Client/Update.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,8 @@ let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> =
PageState = nextPageState
}
nextModel, nextCmd
/// does not work due to office.js ->
/// https://stackoverflow.com/questions/42642863/office-js-nullifies-browser-history-functions-breaking-history-usage
// does not work due to office.js ->
// https://stackoverflow.com/questions/42642863/office-js-nullifies-browser-history-functions-breaking-history-usage
//| Navigate route ->
// currentModel, Navigation.newUrl (Routing.Route.toRouteUrl route)
| Bounce (delay, bounceId, msgToBounce) ->
Expand All @@ -1699,7 +1699,7 @@ let update (msg : Msg) (currentModel : Model) : Model * Cmd<Msg> =
DebouncerState = debouncerModel
}

nextModel,Cmd.batch [Cmd.map DebouncerSelfMsg debouncerCmd]
nextModel,Cmd.map DebouncerSelfMsg debouncerCmd

| DebouncerSelfMsg debouncerMsg ->
let nextDebouncerState, debouncerCmd =
Expand Down
4 changes: 2 additions & 2 deletions src/Server/Version.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ open System.Reflection

[<assembly: AssemblyTitleAttribute("SWATE")>]
[<assembly: AssemblyVersionAttribute("0.4.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","25/02/2021")>]
[<assembly: AssemblyMetadataAttribute("ReleaseDate","01/03/2021")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "SWATE"
let [<Literal>] AssemblyVersion = "0.4.0"
let [<Literal>] AssemblyMetadata_ReleaseDate = "25/02/2021"
let [<Literal>] AssemblyMetadata_ReleaseDate = "01/03/2021"

0 comments on commit ba4f238

Please sign in to comment.