Skip to content

Commit

Permalink
Merge pull request #141 from nfdi4plants/kevinf-patch-0.4.5
Browse files Browse the repository at this point in the history
Kevinf patch 0.4.5
  • Loading branch information
Freymaurer authored Mar 12, 2021
2 parents 6cd6caa + 5260a36 commit 9cad63e
Show file tree
Hide file tree
Showing 17 changed files with 164 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .assets/assets/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<Id>5d6f5462-3401-48ec-9406-d12882e9ad83</Id>
<Version>0.4.4</Version>
<Version>0.4.5</Version>
<ProviderName>Computational Systems Biology</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Swate"/>
Expand Down
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 0.4.5+b360273 (Released 2021-3-12)
* Additions:
* latest commit #b360273
* [[#d630a76](https://github.com/nfdi4plants/Swate/commit/d630a76445f1845bb93de9ae89bf1e983f81c51f)] Save darkmode as cookie and improve darkmode (Issue #134).
* Bugfixes:
* [[#b360273](https://github.com/nfdi4plants/Swate/commit/b36027369f60a612e2660ec3b8bfefb09cbe5664)] Fix bug, removing protocol groups if one column is not an ontology.
* [[#402a220](https://github.com/nfdi4plants/Swate/commit/402a220824ee69ebd1cb5e6f4ecd2ba4cf1627f7)] Fix pointer .json generator (Issue #139).

### 0.4.4+4ae3198 (Released 2021-3-11)
* Additions:
* latest commit #4ae3198
Expand Down
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<Id>5d6f5462-3401-48ec-9406-d12882e9ad83</Id>
<Version>0.4.4</Version>
<Version>0.4.5</Version>
<ProviderName>Computational Systems Biology</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Swate"/>
Expand Down
19 changes: 13 additions & 6 deletions src/Client/CustomComponents/AnnotationTableMissingWarning.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ let annotationTableMissingWarningComponent (model:Model) (dispatch: Msg-> unit)
Notification.notification [
Notification.Color IsWarning
Notification.Props [
Style [
BackgroundColor (if model.SiteStyleState.IsDarkMode = false then NFDIColors.Yellow.Base else model.SiteStyleState.ColorMode.ControlBackground)
Color model.SiteStyleState.ColorMode.Text
//yield! colorControlInArray model.SiteStyleState.ColorMode
]
]
] [
Notification.delete [ Props [
Expand All @@ -21,12 +26,14 @@ let annotationTableMissingWarningComponent (model:Model) (dispatch: Msg-> unit)
)
]] [ ]
Heading.h5 [] [str "Warning: No Annotation table found in worksheet"]
Text.p [] [
Field.div [] [
str "Your worksheet seems to contain no annotation table. You can create one by pressing the button below"
]
Button.buttonComponent
model.SiteStyleState.ColorMode
true
"create annotation table"
(fun _ -> CreateAnnotationTable (model.SiteStyleState.IsDarkMode) |> ExcelInterop |> dispatch )
Field.div [][
Button.buttonComponent
model.SiteStyleState.ColorMode
model.SiteStyleState.IsDarkMode
"create annotation table"
(fun _ -> CreateAnnotationTable model.SiteStyleState.IsDarkMode |> ExcelInterop |> dispatch )
]
]
8 changes: 6 additions & 2 deletions src/Client/CustomComponents/Button.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ open Fulma
open Fable.React
open Fable.React.Props

let buttonComponent (colorMode: ExcelColors.ColorMode) (isActive:bool) txt onClick =
let buttonComponent (colorMode: ExcelColors.ColorMode) (isDarkMode:bool) txt onClick =

Button.button [
if isDarkMode then
Button.Color IsWarning
Button.IsOutlined
else
Button.Props [Style [BackgroundColor colorMode.BodyForeground; Color colorMode.Text]]
Button.IsFullWidth
Button.Props [Style [BackgroundColor colorMode.BodyForeground; Color colorMode.Text]]
Button.OnClick onClick
][
str txt
Expand Down
19 changes: 16 additions & 3 deletions src/Client/CustomComponents/Navbar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let navbarShortCutIconList model dispatch =

let dropdownShortCutIconList model dispatch =
Table.table [
Table.Props [Style [ BackgroundColor model.SiteStyleState.ColorMode.ElementBackground; Color "white"; Cursor "default" ]]
Table.Props [Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground; Color "white"; Cursor "default" ]]
][
tbody [][
for icon in shortCutIconList model do
Expand All @@ -99,7 +99,11 @@ let dropdownShortCutIconList model dispatch =
td [][
let padding = "0.5rem"
Button.a [
Button.Props [ Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground; PaddingLeft padding; PaddingRight padding]]
Button.Props [ Style [
if model.SiteStyleState.IsDarkMode |> not then
BackgroundColor model.SiteStyleState.ColorMode.ElementBackground
PaddingLeft padding; PaddingRight padding
]]
Button.OnClick (fun _ ->
icon.Msg |> dispatch
)
Expand All @@ -121,9 +125,18 @@ let quickAccessDropdownElement model dispatch =
] [
div [Style [
Position PositionOptions.Relative
BackgroundColor model.SiteStyleState.ColorMode.ElementBackground
if model.SiteStyleState.IsDarkMode then
BorderColor model.SiteStyleState.ColorMode.ControlForeground
else
BorderColor model.SiteStyleState.ColorMode.Fade
]] [
Button.a [
Button.Props [Style [BackgroundColor model.SiteStyleState.ColorMode.ElementBackground; PaddingLeft "0"; PaddingRight "0"]]
Button.Props [Style [
if model.SiteStyleState.IsDarkMode |> not then
BackgroundColor model.SiteStyleState.ColorMode.ElementBackground
PaddingLeft "0"; PaddingRight "0"]
]
Button.Color Color.IsWhite
Button.IsInverted
][
Expand Down
4 changes: 2 additions & 2 deletions src/Client/CustomComponents/WarningModal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ let warningModal (model:Model) dispatch =
let msg = fun e -> model.WarningModal.Value.NextMsg |> dispatch
let closeMsg = fun e -> UpdateWarningModal None |> dispatch
let message = model.WarningModal.Value.ModalMessage
Modal.modal [ Modal.IsActive true ] [
Modal.modal [ Modal.IsActive true] [
Modal.background [
Props [ OnClick closeMsg ]
] [ ]
Notification.notification [
Notification.Props [Style [MaxWidth "80%"; MaxHeight "80%"; OverflowX OverflowOptions.Auto ]]
Notification.Props [Style [MaxWidth "80%"; MaxHeight "80%"; OverflowX OverflowOptions.Auto; yield! colorControlInArray model.SiteStyleState.ColorMode ]]
] [
Notification.delete [
Props [OnClick closeMsg]
Expand Down
56 changes: 36 additions & 20 deletions src/Client/Messages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,39 @@ and Msg =

open Routing

let initializeModel (pageOpt: Route option) = {
DebouncerState = Debouncer .create ()
PageState = PageState .init pageOpt
PersistentStorageState = PersistentStorageState .init ()
DevState = DevState .init ()
SiteStyleState = SiteStyleState .init ()
TermSearchState = TermSearchState .init ()
AdvancedSearchState = AdvancedSearchState .init ()
ExcelState = ExcelState .init ()
ApiState = ApiState .init ()
FilePickerState = FilePickerState .init ()
AddBuildingBlockState = AddBuildingBlockState .init ()
ValidationState = ValidationState .init ()
ProtocolInsertState = ProtocolInsertState .init ()
BuildingBlockDetailsState = BuildingBlockDetailsState .init ()
SettingsXmlState = SettingsXmlState .init ()
SettingsDataStewardState = SettingsDataStewardState .init ()
SettingsProtocolState = SettingsProtocolState .init ()
WarningModal = None
}
let initializeModel (pageOpt: Route option) =
let isDarkMode =
let cookies = Browser.Dom.document.cookie
let cookiesSplit = cookies.Split([|";"|], System.StringSplitOptions.RemoveEmptyEntries)
cookiesSplit
|> Array.tryFind (fun x -> x.StartsWith (Cookies.IsDarkMode.toCookieString + "="))
|> fun cookieOpt ->
if cookieOpt.IsSome then
cookieOpt.Value.Replace(Cookies.IsDarkMode.toCookieString + "=","")
|> fun cookie ->
match cookie with
| "false"| "False" -> false
| "true" | "True" -> true
| anyElse -> false
else
false
{
DebouncerState = Debouncer .create ()
PageState = PageState .init pageOpt
PersistentStorageState = PersistentStorageState .init ()
DevState = DevState .init ()
SiteStyleState = SiteStyleState .init (darkMode=isDarkMode)
TermSearchState = TermSearchState .init ()
AdvancedSearchState = AdvancedSearchState .init ()
ExcelState = ExcelState .init ()
ApiState = ApiState .init ()
FilePickerState = FilePickerState .init ()
AddBuildingBlockState = AddBuildingBlockState .init ()
ValidationState = ValidationState .init ()
ProtocolInsertState = ProtocolInsertState .init ()
BuildingBlockDetailsState = BuildingBlockDetailsState .init ()
SettingsXmlState = SettingsXmlState .init ()
SettingsDataStewardState = SettingsDataStewardState .init ()
SettingsProtocolState = SettingsProtocolState .init ()
WarningModal = None
}
18 changes: 15 additions & 3 deletions src/Client/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ open Shared
open Thoth.Elmish
open Routing

type Cookies =
| IsDarkMode

member this.toCookieString =
match this with
| IsDarkMode -> "isDarkmode"

static member ofString str =
match str with
| "isDarkmode" -> IsDarkMode
| anyElse -> failwith (sprintf "Cookie-Parser encountered unknown cookie name: %s" anyElse)

type LogItem =
| Debug of (System.DateTime*string)
| Info of (System.DateTime*string)
Expand Down Expand Up @@ -115,11 +127,11 @@ type SiteStyleState = {
IsDarkMode : bool
ColorMode : ExcelColors.ColorMode
} with
static member init () = {
static member init (?darkMode) = {
QuickAcessIconsShown = false
BurgerVisible = false
IsDarkMode = false
ColorMode = ExcelColors.colorfullMode
IsDarkMode = if darkMode.IsSome then darkMode.Value else false
ColorMode = if darkMode.IsSome && darkMode.Value = true then ExcelColors.darkMode else ExcelColors.colorfullMode
}

type DevState = {
Expand Down
39 changes: 19 additions & 20 deletions src/Client/OfficeInterop/HelperFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ let tryFindSpannedBuildingBlocks (currentProtocolGroup:Xml.GroupTypes.Protocol)
buildingBlocks
|> Array.tryFind (fun foundBuildingBlock ->
let isSameAccession =
if spannedBlock.TermAccession <> "" && foundBuildingBlock.MainColumn.Header.Value.Ontology.IsSome then
foundBuildingBlock.MainColumn.Header.Value.Ontology.Value.TermAccession = spannedBlock.TermAccession
if spannedBlock.TermAccession <> "" || foundBuildingBlock.MainColumn.Header.Value.Ontology.IsSome then
// As in the above only one option is that ontology is some we need a default in the next step.
// We default to an empty termaccession, as 'spannedBlock' MUST be <> "" to trigger the default
(Option.defaultValue (OntologyInfo.create "" "") foundBuildingBlock.MainColumn.Header.Value.Ontology).TermAccession = spannedBlock.TermAccession
else
false
true
foundBuildingBlock.MainColumn.Header.Value.Header = spannedBlock.ColumnName
&& isSameAccession
)
Expand Down Expand Up @@ -791,7 +793,7 @@ let updateRemoveSwateProtocolGroup (protocolGroup:Xml.GroupTypes.ProtocolGroup)
if remove then
filteredChildren
else
newProtocolGroupXml::filteredChildren
if filteredChildren.IsEmpty then [newProtocolGroupXml] else newProtocolGroupXml::filteredChildren
}
else
let initNewSwateTableXml =
Expand All @@ -815,15 +817,15 @@ let updateRemoveSwateProtocolGroup (protocolGroup:Xml.GroupTypes.ProtocolGroup)
Children = nextTableXml::filterPrevTableFromRootChildren
}

let removeSwateProtocolGroup (protocolGroup:Xml.GroupTypes.ProtocolGroup) (previousCompleteCustomXml:XmlElement) =
updateRemoveSwateProtocolGroup protocolGroup previousCompleteCustomXml true
//let removeSwateProtocolGroup (protocolGroup:Xml.GroupTypes.ProtocolGroup) (previousCompleteCustomXml:XmlElement) =
// updateRemoveSwateProtocolGroup protocolGroup previousCompleteCustomXml true

let updateSwateProtocolGroup (protocolGroup:Xml.GroupTypes.ProtocolGroup) (previousCompleteCustomXml:XmlElement) =
updateRemoveSwateProtocolGroup protocolGroup previousCompleteCustomXml false
//let updateSwateProtocolGroup (protocolGroup:Xml.GroupTypes.ProtocolGroup) (previousCompleteCustomXml:XmlElement) =
// updateRemoveSwateProtocolGroup protocolGroup previousCompleteCustomXml false

let replaceProtGroupByProtGroup protGroup1 protGroup2 (previousCompleteCustomXml:XmlElement) =
let removeProtGroup1 = removeSwateProtocolGroup protGroup1 previousCompleteCustomXml
let addProtGroup2 = updateSwateProtocolGroup protGroup2 removeProtGroup1
let removeProtGroup1 = updateRemoveSwateProtocolGroup protGroup1 previousCompleteCustomXml true
let addProtGroup2 = updateRemoveSwateProtocolGroup protGroup2 removeProtGroup1 false
addProtGroup2

/// Use the 'remove' parameter to remove any Swate protocol xml for the worksheet annotation table name combination in 'protocolGroup'
Expand All @@ -846,16 +848,16 @@ let updateRemoveSwateProtocol (protocol:Xml.GroupTypes.Protocol) (previousComple
if remove then
filteredProtocolChildren
else
protocol::filteredProtocolChildren
if filteredProtocolChildren.IsEmpty then [protocol] else protocol::filteredProtocolChildren
}

updateSwateProtocolGroup nextProtocolGroup previousCompleteCustomXml
updateRemoveSwateProtocolGroup nextProtocolGroup previousCompleteCustomXml false

let removeSwateProtocol (protocol:Xml.GroupTypes.Protocol) (previousCompleteCustomXml:XmlElement) =
updateRemoveSwateProtocol protocol previousCompleteCustomXml true
//let removeSwateProtocol (protocol:Xml.GroupTypes.Protocol) (previousCompleteCustomXml:XmlElement) =
// updateRemoveSwateProtocol protocol previousCompleteCustomXml true

let updateSwateProtocol (protocol:Xml.GroupTypes.Protocol) (previousCompleteCustomXml:XmlElement) =
updateRemoveSwateProtocol protocol previousCompleteCustomXml false
//let updateSwateProtocol (protocol:Xml.GroupTypes.Protocol) (previousCompleteCustomXml:XmlElement) =
// updateRemoveSwateProtocol protocol previousCompleteCustomXml false

let updateProtocolFromXml (protocol:Xml.GroupTypes.Protocol) (remove:bool) =
Excel.run(fun context ->
Expand All @@ -876,10 +878,7 @@ let updateProtocolFromXml (protocol:Xml.GroupTypes.Protocol) (remove:bool) =
let securityUpdateForProtocol = {protocol with AnnotationTable = AnnotationTable.create annotationTable activeSheet.name}

let nextCustomXml =
if remove then
removeSwateProtocol securityUpdateForProtocol xmlParsed
else
updateSwateProtocol securityUpdateForProtocol xmlParsed
updateRemoveSwateProtocol securityUpdateForProtocol xmlParsed remove

let nextCustomXmlString = nextCustomXml |> xmlElementToXmlString

Expand Down
8 changes: 4 additions & 4 deletions src/Client/OfficeInterop/OfficeInterop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ let updateProtocolGroupHeader () =

let getGroupHeaderIndicesForProtocol (buildingBlocks:BuildingBlock []) (protocol:Xml.GroupTypes.Protocol) =
let buildingBlockOpts = tryFindSpannedBuildingBlocks protocol buildingBlocks
// caluclate list of indices fro group blocks
// caluclate list of indices for group blocks
if buildingBlockOpts.IsSome then
let getStartAndEnd (mainColIndices:int list) =
let startInd = List.min mainColIndices
Expand Down Expand Up @@ -1855,9 +1855,9 @@ let removeXmlType(xmlType:XmlTypes) =
| ValidationType tableValidation ->
removeSwateValidation tableValidation xmlParsed
| GroupType protGroup ->
removeSwateProtocolGroup protGroup xmlParsed
updateRemoveSwateProtocolGroup protGroup xmlParsed true
| ProtocolType protocol ->
removeSwateProtocol protocol xmlParsed
updateRemoveSwateProtocol protocol xmlParsed true

let nextCustomXmlString = nextCustomXml |> OfficeInterop.HelperFunctions.xmlElementToXmlString

Expand Down Expand Up @@ -1941,7 +1941,7 @@ let createPointerJson() =
[
"name" , Fable.SimpleJson.JString ""
"version" , Fable.SimpleJson.JString ""
"author" , Fable.SimpleJson.JString ""
"author" , Fable.SimpleJson.JArray []
"description" , Fable.SimpleJson.JString ""
"docslink" , Fable.SimpleJson.JString ""
"tags" , Fable.SimpleJson.JArray []
Expand Down
Loading

0 comments on commit 9cad63e

Please sign in to comment.