Skip to content

Commit

Permalink
Merge pull request #135 from nfdi4plants/kevinf-patch-0.4.2
Browse files Browse the repository at this point in the history
Kevinf patch 0.4.2
  • Loading branch information
Freymaurer authored Mar 9, 2021
2 parents 748dc2b + c687822 commit 116c0c3
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 131 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.1</Version>
<Version>0.4.2</Version>
<ProviderName>Computational Systems Biology</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Swate"/>
Expand Down
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.4.2+ae04aa5 (Released 2021-3-9)
* Additions:
* latest commit #ae04aa5
* Bugfixes:
* [[#ae04aa5](https://github.com/nfdi4plants/Swate/commit/ae04aa51261e614d0c422f03d646e1a76d664501)] Stabilize protocol insert against bugs :bug:

### 0.4.1+d75743c (Released 2021-3-8)
* Additions:
* latest commit #d75743c
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.1</Version>
<Version>0.4.2</Version>
<ProviderName>Computational Systems Biology</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Swate"/>
Expand Down
132 changes: 82 additions & 50 deletions src/Client/OfficeInterop/HelperFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,70 +129,102 @@ let findNewIdForUnit (allColHeaders:string []) (format:string option) (unitAcces
int
loopingCheck 1

let createUnitColumns (allColHeaders:string []) (annotationTable:Table) newBaseColIndex rowCount (format:string option) (unitAccessionOpt:string option) =
let createUnitColumns (annotationTableName:string) newBaseColIndex rowCount (format:string option) (unitAccessionOpt:string option) =
let col = createEmptyMatrixForTables 1 rowCount ""
if format.IsSome then
Excel.run(fun context ->
let sheet = context.workbook.worksheets.getActiveWorksheet()
let annotationTable = sheet.tables.getItem(annotationTableName)
let annoHeaderRange = annotationTable.getHeaderRowRange()
let _ = annoHeaderRange.load(U2.Case2 (ResizeArray[|"values";"columnIndex"; "columnCount"; "rowIndex"|]))

let newUnitId = findNewIdForUnit allColHeaders format unitAccessionOpt

/// create unit main column
let createdUnitCol1 =
annotationTable.columns.add(
index = newBaseColIndex+3.,
values = U4.Case1 col,
name = sprintf "Unit %s" (unitColAttributes format.Value unitAccessionOpt newUnitId)
)
context.sync().``then``(fun e ->
printfn "1"
let headerVals = annoHeaderRange.values.[0] |> Array.ofSeq

let allColHeaders =
headerVals
|> Array.choose id
|> Array.map string

printfn "2"
let newUnitId = findNewIdForUnit allColHeaders format unitAccessionOpt

/// create unit main column
let createdUnitCol1 =
annotationTable.columns.add(
index = newBaseColIndex+3.,
values = U4.Case1 col,
name = sprintf "Unit %s" (unitColAttributes format.Value unitAccessionOpt newUnitId)
)

/// create unit TSR
let createdUnitCol2 =
annotationTable.columns.add(
index = newBaseColIndex+4.,
values = U4.Case1 col,
name = sprintf "Term Source REF %s" (unitColAttributes format.Value unitAccessionOpt newUnitId)
)
/// create unit TSR
let createdUnitCol2 =
annotationTable.columns.add(
index = newBaseColIndex+4.,
values = U4.Case1 col,
name = sprintf "Term Source REF %s" (unitColAttributes format.Value unitAccessionOpt newUnitId)
)

/// create unit TAN
let createdUnitCol3 =
annotationTable.columns.add(
index = newBaseColIndex+5.,
values = U4.Case1 col,
name = sprintf "Term Accession Number %s" (unitColAttributes format.Value unitAccessionOpt newUnitId)
/// create unit TAN
let createdUnitCol3 =
annotationTable.columns.add(
index = newBaseColIndex+5.,
values = U4.Case1 col,
name = sprintf "Term Accession Number %s" (unitColAttributes format.Value unitAccessionOpt newUnitId)
)
printfn "3"
Some (
sprintf " Added specified unit: %s" (format.Value),
sprintf "0.00 \"%s\"" (format.Value)
)
)

Some (
sprintf " Added specified unit: %s" (format.Value),
sprintf "0.00 \"%s\"" (format.Value)
)

else
None
promise {return None}

let updateUnitColumns (allColHeaders:string []) (annoHeaderRange:Excel.Range) newBaseColIndex (format:string option) (unitAccessionOpt:string option) =
let updateUnitColumns (annotationTableName:string) newBaseColIndex (format:string option) (unitAccessionOpt:string option) =
let col v= createValueMatrix 1 1 v
if format.IsSome then
Excel.run(fun context ->
let sheet = context.workbook.worksheets.getActiveWorksheet()
let annotationTable = sheet.tables.getItem(annotationTableName)
let annoHeaderRange = annotationTable.getHeaderRowRange()
let _ = annoHeaderRange.load(U2.Case2 (ResizeArray[|"values";"columnIndex"; "columnCount"; "rowIndex"|]))

let newUnitId = findNewIdForUnit allColHeaders format unitAccessionOpt

/// create unit main column
let updateUnitCol1 =
annoHeaderRange.getColumn(newBaseColIndex+3.)
|> fun c1 -> c1.values <- sprintf "Unit %s" (unitColAttributes format.Value unitAccessionOpt newUnitId) |> col

/// create unit TSR
let createdUnitCol2 =
annoHeaderRange.getColumn(newBaseColIndex+4.)
|> fun c2 -> c2.values <- sprintf "Term Source REF %s" (unitColAttributes format.Value unitAccessionOpt newUnitId) |> col

/// create unit TAN
let createdUnitCol3 =
annoHeaderRange.getColumn(newBaseColIndex+5.)
|> fun c3 -> c3.values <- sprintf "Term Accession Number %s" (unitColAttributes format.Value unitAccessionOpt newUnitId) |> col

Some (
sprintf " Added specified unit: %s" (format.Value),
sprintf "0.00 \"%s\"" (format.Value)
context.sync().``then``(fun e ->
let headerVals = annoHeaderRange.values.[0] |> Array.ofSeq

let allColHeaders =
headerVals
|> Array.choose id
|> Array.map string
let newUnitId = findNewIdForUnit allColHeaders format unitAccessionOpt

/// create unit main column
let updateUnitCol1 =
annoHeaderRange.getColumn(newBaseColIndex+3.)
|> fun c1 -> c1.values <- sprintf "Unit %s" (unitColAttributes format.Value unitAccessionOpt newUnitId) |> col

/// create unit TSR
let createdUnitCol2 =
annoHeaderRange.getColumn(newBaseColIndex+4.)
|> fun c2 -> c2.values <- sprintf "Term Source REF %s" (unitColAttributes format.Value unitAccessionOpt newUnitId) |> col

/// create unit TAN
let createdUnitCol3 =
annoHeaderRange.getColumn(newBaseColIndex+5.)
|> fun c3 -> c3.values <- sprintf "Term Accession Number %s" (unitColAttributes format.Value unitAccessionOpt newUnitId) |> col

Some (
sprintf " Added specified unit: %s" (format.Value),
sprintf "0.00 \"%s\"" (format.Value)
)
)
)
else
None
promise {return None}

/// Swaps 'Rows with column values' to 'Columns with row values'.
let viewRowsByColumns (rows:ResizeArray<ResizeArray<'a>>) =
Expand Down
Loading

0 comments on commit 116c0c3

Please sign in to comment.