Skip to content

Commit

Permalink
More fixes to metadata creation in excel
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Oct 31, 2024
1 parent 2dbca9d commit 659f2d9
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 118 deletions.
4 changes: 2 additions & 2 deletions build/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ let Run(db: bool) =
[ "server", dotnet [ "watch"; "run" ] serverPath
"client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "-e"; "fs.js"; "--run"; "npx"; "vite" ] clientPath
if db then
"database", dockerCompose ["-f"; dockerComposePath; "up"] __SOURCE_DIRECTORY__
"database", dockerCompose ["-f"; dockerComposePath; "up"; "-d"] __SOURCE_DIRECTORY__
] |> runParallel

//Target.create "officedebug" (fun config ->
Expand All @@ -344,7 +344,7 @@ let Run(db: bool) =
//)

Target.create "RunDB" (fun _ ->
run dockerCompose ["-f"; dockerComposePath; "up"] __SOURCE_DIRECTORY__
run dockerCompose ["-f"; dockerComposePath; "up"; "-d"] __SOURCE_DIRECTORY__
)

[<RequireQualifiedAccess>]
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

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

37 changes: 28 additions & 9 deletions src/Client/OfficeInterop/OfficeInterop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,7 @@ type OfficeInterop =
worksheets.items
|> Seq.tryFind (fun item ->
ArcTable.isTopLevelMetadataName item.name)

match worksheetTopLevelMetadata with
| Some worksheet when ArcAssay.isMetadataSheetName worksheet.name ->
let! assay = parseToTopLevelMetadata worksheet.name ArcAssay.fromMetadataCollection context
Expand Down Expand Up @@ -2496,22 +2496,37 @@ let deleteTopLevelMetadata () =
/// <param name="context"></param>
/// <param name="fsWorkSheet"></param>
/// <param name="seqOfSeqs"></param>
let private updateWorkSheet (context:RequestContext) (fsWorkSheet:FsWorksheet) (seqOfSeqs:seq<seq<string option>>) =
let private updateWorkSheet (context:RequestContext) (worksheetName: string) (seqOfSeqs:seq<seq<string option>>) =
promise {
let worksheet = context.workbook.worksheets.getItem(fsWorkSheet.Name)
let rowCount = seqOfSeqs |> Seq.length
let columnCount = seqOfSeqs |> Seq.map Seq.length |> Seq.max

let worksheet0 = context.workbook.worksheets.getItemOrNullObject(worksheetName)

let _ = worksheet0.load(U2.Case2 (ResizeArray[|"isNullObject"|]))
do! context.sync()

let worksheet =
if worksheet0.isNullObject then
context.workbook.worksheets.add(worksheetName)
else
worksheet0

do! context.sync()

let range = worksheet.getUsedRange true
let _ = range.load(propertyNames = U2.Case2 (ResizeArray["values"]))

do! context.sync().``then``(fun _ -> ())
do! context.sync()

range.values <- null

do! context.sync().``then``(fun _ -> ())
do! context.sync()

let range = worksheet.getRangeByIndexes(0, 0, fsWorkSheet.MaxRowIndex, fsWorkSheet.MaxColumnIndex)
let range = worksheet.getRangeByIndexes(0, 0, rowCount, columnCount)
let _ = range.load(propertyNames = U2.Case2 (ResizeArray["values"]))

do! context.sync().``then``(fun _ -> ())
do! context.sync()

let values = ExcelHelper.convertToResizeArrays(seqOfSeqs)

Expand All @@ -2520,7 +2535,9 @@ let private updateWorkSheet (context:RequestContext) (fsWorkSheet:FsWorksheet) (
range.format.autofitColumns()
range.format.autofitRows()

do! context.sync().``then``(fun _ -> ())
do! context.sync()

return worksheet
}

/// <summary>
Expand Down Expand Up @@ -2553,7 +2570,9 @@ let updateTopLevelMetadata (arcFiles: ArcFiles) =
let seqOfSeqs = Template.toMetadataCollection template
templateWorksheet, seqOfSeqs

do! updateWorkSheet context worksheet seqOfSeqs
let! updatedWorksheet = updateWorkSheet context worksheet.Name seqOfSeqs

updatedWorksheet.activate()

return [InteropLogging.Msg.create InteropLogging.Warning $"The worksheet {worksheet.Name} has been updated"]
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/SharedComponents/Metadata/Assay.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open Components.Forms
let Main(assay: ArcAssay, setArcAssay: ArcAssay -> unit, setDatamap: ArcAssay -> DataMap option -> unit) =
Bulma.section [
Generic.BoxedField
"Assay Metadata"
(Some "Assay Metadata")
None
[
FormComponents.TextInput (
Expand Down
2 changes: 1 addition & 1 deletion src/Client/SharedComponents/Metadata/DatamapConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ type DatamapConfig =
]
]
Generic.BoxedField
"Datamap"
(Some "Datamap")
desc
content
4 changes: 2 additions & 2 deletions src/Client/SharedComponents/Metadata/Generic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module Components.Generic
open Feliz.Bulma
open Feliz

let BoxedField (title: string) (description: string option) (content: ReactElement list) =
let BoxedField (title: string option) (description: string option) (content: ReactElement list) =
Bulma.field.div [
Bulma.box [
Bulma.block [
Bulma.content [
Html.h4 title
if title.IsSome then Html.h4 title.Value
if description.IsSome then
Html.p description.Value
]
Expand Down
2 changes: 1 addition & 1 deletion src/Client/SharedComponents/Metadata/Investigation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open Components.Forms
let Main(investigation: ArcInvestigation, setInvestigation: ArcInvestigation -> unit) =
Bulma.section [
Generic.BoxedField
"Investigation Metadata"
(Some "Investigation Metadata")
None
[
FormComponents.TextInput (
Expand Down
2 changes: 1 addition & 1 deletion src/Client/SharedComponents/Metadata/Study.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open System
let Main(study: ArcStudy, assignedAssays: ArcAssay list, setArcStudy: (ArcStudy * ArcAssay list) -> unit, setDatamap: ArcStudy -> DataMap option -> unit) =
Bulma.section [
Generic.BoxedField
"Study Metadata"
(Some "Study Metadata")
None
[
FormComponents.TextInput (
Expand Down
2 changes: 1 addition & 1 deletion src/Client/SharedComponents/Metadata/Template.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Components.Forms
let Main(template: Template, setTemplate: Template -> unit) =
Bulma.section [
Generic.BoxedField
"Template Metadata"
(Some "Template Metadata")
None
[
FormComponents.GUIDInput (
Expand Down
Loading

0 comments on commit 659f2d9

Please sign in to comment.