Skip to content

Commit

Permalink
Merge pull request #8821 from N-thony/column_summary_bug
Browse files Browse the repository at this point in the history
Bug fixes in General Summary Dialogue
  • Loading branch information
conlooptechnologies authored Feb 29, 2024
2 parents 302a751 + d986fe2 commit 97a46f1
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions instat/sdgCalculationsSummmary.vb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ Public Class sdgCalculationsSummmary

ucrManipulations.lstAvailableData.View = View.List

ucrCalcSummary.ucrReceiverForCalculation.bAttachedToPrimaryDataFrame = False

'temp until working
ucrCalcSummary.ucrSaveResultInto.Visible = False
'ucrCalcSummary.ucrTryModelling.Visible = False
Expand Down Expand Up @@ -345,16 +343,18 @@ Public Class sdgCalculationsSummmary

Private Sub ucrCalcSummary_SelectionChanged() Handles ucrCalcSummary.SelectionChanged
If {"Calculation", "Summary"}.Contains(ucrInputType.GetText()) Then
Dim strExpression As String = ucrCalcSummary.ucrReceiverForCalculation.GetText()
If Not ucrCalcSummary.ucrReceiverForCalculation.IsEmpty Then
clsCalculationFunction.AddParameter("function_exp", Chr(34) & ucrCalcSummary.ucrReceiverForCalculation.GetText() & Chr(34))
clsCalculationFunction.AddParameter("function_exp", Chr(34) & strExpression & Chr(34))
Else
clsCalculationFunction.RemoveParameterByName("function_exp")
End If

If Not ucrCalcSummary.ucrSelectorForCalculations.CurrentReceiver.IsEmpty Then
clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList(
ucrCalcSummary.ucrSelectorForCalculations.CurrentReceiver.GetVariableNamesList(bWithQuotes:=False),
ucrCalcSummary.ucrSelectorForCalculations))
If ucrCalcSummary.ucrSelectorForCalculations.lstAvailableVariable.Items.Count > 0 AndAlso
Not ucrCalcSummary.ucrReceiverForCalculation.IsEmpty Then
Dim lstItems As String() = ucrCalcSummary.ucrSelectorForCalculations.lstAvailableVariable.Items.Cast(Of ListViewItem)().Select(Function(item) item.Text).ToArray()
Dim strSelectedVariables As String() = lstItems.Where(Function(variable) strExpression.Contains(variable)).ToArray()
clsCalculationFunction.AddParameter("calculated_from", CreateCalcFromList(strSelectedVariables, ucrCalcSummary.ucrSelectorForCalculations))
Else
clsCalculationFunction.RemoveParameterByName("calculated_from")
End If
Expand All @@ -374,14 +374,23 @@ Public Class sdgCalculationsSummmary

'Need to do this instead of with RFunctions because the calculated_from list can have multiple items with the same label
Private Function CreateCalcFromList(lstVariables As String(), ucrCurrentSelector As ucrSelectorByDataFrame) As String

If lstVariables Is Nothing Then
Return ""
End If

Dim strCalcFromList As String

strCalcFromList = "list("
For i = 0 To lstVariables.Count - 1
If i > 0 Then
strCalcFromList = strCalcFromList & ","
Dim strDataName As String = lstVariables(i)
If Not String.IsNullOrEmpty(strDataName) Then
If i > 0 Then
strCalcFromList = strCalcFromList & ","
End If

strCalcFromList = strCalcFromList & ucrCurrentSelector.strCurrentDataFrame & " = " & Chr(34) & strDataName & Chr(34)
End If
strCalcFromList = strCalcFromList & ucrCurrentSelector.strCurrentDataFrame & " = " & Chr(34) & lstVariables(i) & Chr(34)
Next
strCalcFromList = strCalcFromList & ")"
Return strCalcFromList
Expand Down

0 comments on commit 97a46f1

Please sign in to comment.