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 comment column to normal swate with manually adaptable name #633

Merged
merged 4 commits into from
Feb 14, 2025
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
1 change: 1 addition & 0 deletions src/Client/Messages.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module BuildingBlock =
| UpdateHeaderArg of U2<OntologyAnnotation,IOType> option
| UpdateBodyCellType of CompositeCellDiscriminate
| UpdateBodyArg of U2<string, OntologyAnnotation> option
| UpdateCommentHeader of string

module Protocol =

Expand Down
2 changes: 2 additions & 0 deletions src/Client/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ module BuildingBlock =
HeaderArg : U2<OntologyAnnotation,IOType> option
BodyCellType : CompositeCellDiscriminate
BodyArg : U2<string, OntologyAnnotation> option
CommentHeader : string
} with
static member init () = {
HeaderCellType = CompositeHeaderDiscriminate.Parameter
HeaderArg = None
BodyCellType = CompositeCellDiscriminate.Term
BodyArg = None
CommentHeader = ""
}

member this.TryHeaderOA() =
Expand Down
3 changes: 3 additions & 0 deletions src/Client/Pages/BuildingBlock/BuildingBlockView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ let update (addBuildingBlockMsg:BuildingBlock.Msg) (state: BuildingBlock.Model)
| UpdateBodyArg next ->
let nextState = { state with BodyArg = next }
nextState, Cmd.none
| UpdateCommentHeader header ->
let nextState = { state with CommentHeader = header }
nextState, Cmd.none
| UpdateHeaderArg next ->
let nextState = { state with HeaderArg = next}
nextState, Cmd.none
Expand Down
11 changes: 9 additions & 2 deletions src/Client/Pages/BuildingBlock/Dropdown.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ let FreeTextInputElement(onSubmit: string -> unit) =
module private DropdownElements =

let divider = Daisy.divider [prop.className "mx-2 my-0"]
let private annotationsPrinciplesLink = Html.a [prop.href Swate.Components.Shared.URLs.AnnotationPrinciplesUrl; prop.target.blank; prop.className "ml-auto link-info"; prop.text "info"]
let private annotationsPrinciplesLink =
Html.a [
prop.href "#"
prop.onClick (fun _ -> Browser.Dom.window.``open``(Swate.Components.Shared.URLs.AnnotationPrinciplesUrl, "_blank") |> ignore)
prop.className "ml-auto link-info"
prop.text "info"
]

let createSubBuildingBlockDropdownLink (state:BuildingBlockUIState) setState (subpage: Model.BuildingBlock.DropdownPage) =
Html.li [
Expand Down Expand Up @@ -122,7 +128,7 @@ module private DropdownElements =
CompositeHeaderDiscriminate.Factor |> createBuildingBlockDropdownItem model dispatch setState close
CompositeHeaderDiscriminate.Characteristic |> createBuildingBlockDropdownItem model dispatch setState close
CompositeHeaderDiscriminate.Component |> createBuildingBlockDropdownItem model dispatch setState close
Model.BuildingBlock.DropdownPage.More |> createSubBuildingBlockDropdownLink state setState
Model.BuildingBlock.DropdownPage.More |> createSubBuildingBlockDropdownLink state setState
divider
DropdownPage.IOTypes CompositeHeaderDiscriminate.Output |> createSubBuildingBlockDropdownLink state setState
DropdownContentInfoFooter setState false
Expand All @@ -131,6 +137,7 @@ module private DropdownElements =
/// Protocol Type subpage for dropdown
let dropdownContentProtocolTypeColumns state setState close (model:Model) dispatch =
React.fragment [
CompositeHeaderDiscriminate.Comment |> createBuildingBlockDropdownItem model dispatch setState close
CompositeHeaderDiscriminate.Date |> createBuildingBlockDropdownItem model dispatch setState close
CompositeHeaderDiscriminate.Performer |> createBuildingBlockDropdownItem model dispatch setState close
CompositeHeaderDiscriminate.ProtocolDescription |> createBuildingBlockDropdownItem model dispatch setState close
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Pages/BuildingBlock/Helper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let createCompositeHeaderFromState (state: BuildingBlock.Model) =
| CompositeHeaderDiscriminate.Date -> CompositeHeader.Date
| CompositeHeaderDiscriminate.Input -> CompositeHeader.Input <| getIOType()
| CompositeHeaderDiscriminate.Output -> CompositeHeader.Output <| getIOType()
| CompositeHeaderDiscriminate.Comment -> failwith "Comment header type is not yet implemented"
| CompositeHeaderDiscriminate.Comment -> CompositeHeader.Comment state.CommentHeader
| CompositeHeaderDiscriminate.Freetext -> failwith "Freetext header type is not yet implemented"

let tryCreateCompositeCellFromState (state: BuildingBlock.Model) =
Expand Down
12 changes: 10 additions & 2 deletions src/Client/Pages/BuildingBlock/SearchComponent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ let private SearchBuildingBlockHeaderElement (ui: BuildingBlockUIState, setUi, m
// Dropdown building block type choice
Dropdown.Main(ui, setUi, model, dispatch)
// Term search field
if state.HeaderCellType.HasOA() then
if state.HeaderCellType = CompositeHeaderDiscriminate.Comment then
Daisy.input [
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing prop.defaultValue

prop.readOnly false
prop.valueOrDefault (model.AddBuildingBlockState.CommentHeader)
prop.placeholder (CompositeHeaderDiscriminate.Comment.ToString())
prop.onChange (fun (ev:string) ->
BuildingBlock.UpdateCommentHeader ev |> BuildingBlockMsg |> dispatch)
]
elif state.HeaderCellType.HasOA() then
let setter (oaOpt: Swate.Components.Term option) =
let case = oaOpt |> Option.map (fun oa -> OntologyAnnotation.fromTerm >> U2.Case1 <| oa)
BuildingBlock.UpdateHeaderArg case |> BuildingBlockMsg |> dispatch
Expand Down Expand Up @@ -161,7 +169,7 @@ let private AddBuildingBlockButton (model: Model) dispatch =
prop.onClick (fun _ ->
let bodyCells =
if body.IsSome then // create as many body cells as there are rows in the active table
let rowCount = System.Math.Max(1,model.SpreadsheetModel.ActiveTable.RowCount)
let rowCount = System.Math.Max(1, model.SpreadsheetModel.ActiveTable.RowCount)
Array.init rowCount (fun _ -> body.Value.Copy())
else
Array.empty
Expand Down
1 change: 0 additions & 1 deletion src/Client/Pages/TermSearch/TermSearchView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ let Main (model:Model, dispatch) =
}
|> Some
| _ -> None

SidebarComponents.SidebarLayout.Container [
SidebarComponents.SidebarLayout.Header "Ontology term search"

Expand Down
Loading