Skip to content

Commit 77ad0cf

Browse files
committed
Fixed bugs on msetup
1 parent a2334f5 commit 77ad0cf

File tree

11 files changed

+159
-164
lines changed

11 files changed

+159
-164
lines changed

.mock/disease_mock.xlsb

6.48 KB
Binary file not shown.

.mock/~$disease_mock.xlsb

-165 Bytes
Binary file not shown.

automate/codes/update_files.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ update_master_setup <- function(tag = "mock") {
9898
}
9999

100100
# copy the mock file for development
101-
update_designer(tag = "mock")
102-
update_setup(tag = "mock")
101+
# update_designer(tag = "mock")
102+
# update_setup(tag = "mock")
103103
update_master_setup(tag = "mock")

ribbons/ribbon_icons/Thumbs.db

0 Bytes
Binary file not shown.
-214 KB
Binary file not shown.

src/msetup-codes/classes/CustomTable.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ End Type
2424

2525
Private this As TCustomTable
2626
Private Const CLASSNAME As String = "ICustomTable"
27-
Private Const NBROWSADD As Long = 5 'Number of Rows to add when resizing
27+
Private Const NBROWSADD As Long = 10 'Number of Rows to add when resizing
2828
Private Const TABTRANSLATIONS As String = "Tab_Translations"
2929
Private Const TABEXPORT As String = "Tab_Export"
3030

src/msetup-codes/classes/Disease.cls

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ Private Sub Add(ByVal disName As String, _
265265
message:=trads.TranslatedValue("errLang")
266266

267267
'Add the listObject for the disease
268-
269-
.Cells(4, 2).Value = trads.TranslatedValue("varName")
270-
.Cells(4, 3).Value = trads.TranslatedValue("varLabel")
271-
.Cells(4, 4).Value = trads.TranslatedValue("varChoice")
272-
.Cells(4, 5).Value = trads.TranslatedValue("choiceVal")
273-
.Cells(4, 6).Value = trads.TranslatedValue("varStatus")
274-
'.Cells(4, 7).Value = trads.TranslatedValue("varVis")
268+
.Cells(4, 2).Value = trads.TranslatedValue("varOrder")
269+
.Cells(4, 3).Value = trads.TranslatedValue("varSection")
270+
.Cells(4, 4).Value = trads.TranslatedValue("varName")
271+
.Cells(4, 5).Value = trads.TranslatedValue("varLabel")
272+
.Cells(4, 6).Value = trads.TranslatedValue("varChoice")
273+
.Cells(4, 7).Value = trads.TranslatedValue("choiceVal")
274+
.Cells(4, 8).Value = trads.TranslatedValue("varStatus")
275275

276276
'Validation for variable Name
277277
With .Cells(5, 2).Validation
@@ -321,7 +321,7 @@ Private Sub Add(ByVal disName As String, _
321321
' alertType:= "error", _
322322
' message:=selectValue
323323
' 'Creating the listObject
324-
Set loRng = .Range(.Cells(4, 2), .Cells(5, 6))
324+
Set loRng = .Range(.Cells(4, 2), .Cells(15, 8))
325325
.ListObjects.Add(xlSrcRange, loRng, , xlYes).Name = TABTAG & nbDis
326326
End With
327327

@@ -494,11 +494,12 @@ Private Sub ExportDisease(ByVal disName As String)
494494
FormatSheet outwb.Worksheets("Dictionary")
495495
Set sh = outwb.Worksheets("Dictionary")
496496

497-
sh.Cells(1, 1).Value = "Variable Name"
498-
sh.Cells(1, 2).Value = "Main Label"
499-
sh.Cells(1, 3).Value = "Control"
500-
sh.Cells(1, 4).Value = "Status"
501-
sh.Cells(1, 5).Value = "Visibility"
497+
sh.Cells(1, 1).Value = "Variable Order"
498+
sh.Cells(1, 2).Value = "Variable Section"
499+
sh.Cells(1, 3).Value = "Variable Name"
500+
sh.Cells(1, 4).Value = "Main Label"
501+
sh.Cells(1, 5).Value = "Control"
502+
sh.Cells(1, 6).Value = "Status"
502503

503504
Set cellRng = disWksh.Cells(5, 2)
504505
counter = 2
@@ -508,17 +509,18 @@ Private Sub ExportDisease(ByVal disName As String)
508509
sh.Cells(counter, 1).Value = cellRng.Value
509510
sh.Cells(counter, 2).Value = cellRng.Offset(, 1).Value
510511
sh.Cells(counter, 3).Value = cellRng.Offset(, 2).Value
511-
'The third offset is for choices values separated with a |
512+
sh.Cells(counter, 4).Value = cellRng.Offset(, 3).Value
513+
sh.Cells(counter, 5).Value = cellRng.Offset(, 4).Value
514+
'The third offset is for choices values separated with a |
512515
'Status and visibility (status has only two values: Core, non core)
513516
'visibility has only three values (always show, optional show, optional hidden)
514-
sh.Cells(counter, 4).Value = cellRng.Offset(, 4).Value
515-
sh.Cells(counter, 5).Value = cellRng.Offset(, 5).Value
517+
sh.Cells(counter, 6).Value = cellRng.Offset(, 6).Value
516518

517519
'The third column is the control column in the dictionary worksheet (choice Name)
518-
choiName = sh.Cells(counter, 3).Value
520+
choiName = sh.Cells(counter, 5).Value
519521
listCols.Clear
520522
'Those are the translated values of the choices
521-
listCols.Items = Split(cellRng.Offset(, 4).Value, DEFAULTCHOICESEPARATOR)
523+
listCols.Items = Split(cellRng.Offset(, 5).Value, DEFAULTCHOICESEPARATOR)
522524
choiObj.AddChoice choiName, listCols
523525

524526
'Loop over
@@ -835,22 +837,22 @@ Private Sub ExportForMigration()
835837
Set Lo = disWksh.ListObjects(1)
836838
Set LoRng = Lo.Range
837839

838-
With sh
839-
lastColumn = .Cells(3, .Columns.Count).End(xlToLeft).Column + 2
840-
'Remove 1 when adding to take in account the whole plage of the range
841-
Set outLoRng = .Range(.Cells(3, lastColumn), _
842-
.Cells(2 + LoRng.Rows.Count, lastColumn + LoRng.Columns.Count - 1))
843-
outLoRng.Value = LoRng.Value
844-
.ListObjects.Add(xlSrcRange, outLoRng, , xlYes).Name = Lo.Name
845-
846-
'Add the language, the disease tag
847-
.Cells(2, lastColumn).Value = disWksh.Name
848-
.Cells(2, lastColumn + 1).Value = disWksh.Cells(2, 2).Value
849-
.Cells(2, lastColumn + 2).Value = disWksh.Cells(2, 3).Value
850-
851-
FormatRange .Range(.Cells(2, lastColumn), .Cells(2, lastColumn + 2)), _
852-
fontColor:=RGB(178, 190, 181)
853-
End With
840+
' With sh
841+
' lastColumn = .Cells(3, .Columns.Count).End(xlToLeft).Column + 2
842+
' 'Remove 1 when adding to take in account the whole plage of the range
843+
' Set outLoRng = .Range(.Cells(3, lastColumn), _
844+
' .Cells(2 + LoRng.Rows.Count, lastColumn + LoRng.Columns.Count - 1))
845+
' outLoRng.Value = LoRng.Value
846+
' .ListObjects.Add(xlSrcRange, outLoRng, , xlYes).Name = Lo.Name
847+
848+
' 'Add the language, the disease tag
849+
' .Cells(2, lastColumn).Value = disWksh.Name
850+
' .Cells(2, lastColumn + 1).Value = disWksh.Cells(2, 2).Value
851+
' .Cells(2, lastColumn + 2).Value = disWksh.Cells(2, 3).Value
852+
853+
' FormatRange .Range(.Cells(2, lastColumn), .Cells(2, lastColumn + 2)), _
854+
' fontColor:=RGB(178, 190, 181)
855+
' End With
854856
Next
855857

856858
'Save the workbook to the corresponding filePath
@@ -864,7 +866,6 @@ Private Sub ExportForMigration()
864866
ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
865867
Application.DisplayAlerts = prevAlert
866868
outwb.Close saveChanges:=False
867-
868869
End Sub
869870

870871

src/msetup-codes/modules/EventsGlobal.bas

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Public Sub checkUpdateStatus(ByVal sh As Worksheet, ByVal Target As Range)
5858

5959
If sh.Name = "Variables" Then
6060
Set Lo = sh.ListObjects(1)
61-
If Not (Intersect(Target, Lo.ListColumns(3).Range) Is Nothing) Then
61+
If (Target.Column = Lo.ListColumns(3).Column) Then
6262
'Test if Default choices has been modified
6363
Set pass = Passwords.Create(wb.Worksheets(PASSSHEETNAME))
6464
Set ribSh = wb.Worksheets(RIBBONTRADSHEET)
@@ -131,7 +131,7 @@ Public Sub UpdateDiseaseSheet(ByVal disSh As Worksheet, ByVal Target As Range)
131131
If Not (Intersect(Target, disSh.Cells(2, 2)) Is Nothing) Then Set tradRng = Lo.DataBodyRange
132132

133133
'Update Variable label, status, choice and Default choice
134-
If Not (Intersect(Target, Lo.ListColumns(1).Range) Is Nothing) Then Set tradRng = Target
134+
If Not (Intersect(Target, Lo.ListColumns(3).Range) Is Nothing) Then Set tradRng = Target
135135

136136

137137
'Update translation elements
@@ -158,7 +158,7 @@ Public Sub UpdateDiseaseSheet(ByVal disSh As Worksheet, ByVal Target As Range)
158158
End If
159159

160160
'Update Categories
161-
If Not (Intersect(Target, Lo.ListColumns(3).Range) Is Nothing) Then
161+
If Not (Intersect(Target, Lo.ListColumns(5).Range) Is Nothing) Then
162162
For counter = 1 To Target.Rows.Count
163163
choiValue = Target.Value
164164
Target.Cells(counter, 2).Value = choiObj.PasteTranslatedCategories(choiValue, trads)
@@ -167,23 +167,23 @@ Public Sub UpdateDiseaseSheet(ByVal disSh As Worksheet, ByVal Target As Range)
167167

168168

169169
'For core variables, update the visibility to always visible if possible
170-
If Not (Intersect(Target, Lo.ListColumns(5).Range) Is Nothing) Then
171-
For counter = 1 To Target.Rows.Count
172-
If Target.Cells(counter, 1).Value = ribTrads.TranslatedValue("coreVar") Then
173-
On Error Resume Next
174-
Target.Cells(counter, 2).Value = ribTrads.TranslatedValue("alwaysVis")
175-
Target.Cells(counter, 2).Font.Color = RGB(59, 8, 145)
176-
Target.Cells(counter, 2).Font.Italic = True
177-
On Error GoTo 0
178-
Else
179-
On Error Resume Next
180-
Target.Cells(counter, 2).ClearContents
181-
Target.Cells(counter, 2).Font.Color = vbBlack
182-
Target.Cells(counter, 2).Font.Italic = False
183-
On Error GoTo 0
184-
End If
185-
Next
186-
End If
170+
' If Not (Intersect(Target, Lo.ListColumns(5).Range) Is Nothing) Then
171+
' For counter = 1 To Target.Rows.Count
172+
' If Target.Cells(counter, 1).Value = ribTrads.TranslatedValue("coreVar") Then
173+
' On Error Resume Next
174+
' Target.Cells(counter, 2).Value = ribTrads.TranslatedValue("alwaysVis")
175+
' Target.Cells(counter, 2).Font.Color = RGB(59, 8, 145)
176+
' Target.Cells(counter, 2).Font.Italic = True
177+
' On Error GoTo 0
178+
' Else
179+
' On Error Resume Next
180+
' Target.Cells(counter, 2).ClearContents
181+
' Target.Cells(counter, 2).Font.Color = vbBlack
182+
' Target.Cells(counter, 2).Font.Italic = False
183+
' On Error GoTo 0
184+
' End If
185+
' Next
186+
' End If
187187

188188
pass.Protect dissh
189189
End Sub

src/msetup-codes/modules/EventsRibbon.bas

Lines changed: 3 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Attribute clickFilters.VB_Description = "Callback for btnFilt onAction: clear al
143143
NotBusyApp
144144
End Sub
145145

146-
'Translation worksheet =========================================================
146+
'Translation worksheet =======================================================================================
147147

148148
'@Description("Callback for editLang onChange: Add a language to translation table")
149149
'@EntryPoint
@@ -206,7 +206,7 @@ Attribute clickUpdateTranslate.VB_Description = "Callback for btnTransUp onActio
206206
CleanUpdateColumns
207207
UpdateWatchedValues
208208
NotBusyApp
209-
MsgBox "Done!"
209+
MsgBox trads.TransalatedValue("done")
210210
End Sub
211211

212212
Private Sub CleanUpdateColumns()
@@ -441,93 +441,4 @@ Attribute clickLangChange.VB_Description = "Callback for langDrop onAction: Chan
441441
ExitLang:
442442
NotBusyApp
443443
Application.EnableEvents = True
444-
End Sub
445-
446-
447-
448-
Public Sub TranslateWbElmts(ByVal langId As String)
449-
450-
Dim wb As Workbook
451-
Dim pass As IPasswords
452-
Dim drop As IDropdownLists
453-
Dim sh As Worksheet
454-
Dim hRng As Range
455-
Dim trads As ITranslation
456-
Dim selectValue As String
457-
458-
Set wb = ThisWorkbook
459-
Set pass = Passwords.Create(wb.Worksheets(PASSSHEETNAME))
460-
Set trads = Translation.Create(wb.Worksheets(TRADTABLESHEET).ListObjects(1), langId)
461-
Set drop = DropdownLists.Create(wb.Worksheets(DROPSHEET))
462-
selectValue = trads.TranslatedValue("selectValue")
463-
464-
For Each sh In wb.Worksheets
465-
466-
'Update elements in the disease worksheet
467-
If sh.Cells(2, 4).Value = "DISSHEET" Then
468-
pass.UnProtect sh
469-
470-
'Change the headers to the corresponding language
471-
Set hRng = sh.ListObjects(1).HeaderRowRange
472-
hRng.Cells(1, 1).Value = trads.TranslatedValue("varSection")
473-
hRng.Cells(1, 2).Value = trads.TranslatedValue("varName")
474-
hRng.Cells(1, 3).Value = trads.TranslatedValue("varLabel")
475-
hRng.Cells(1, 4).Value = trads.TranslatedValue("varOrder")
476-
hRng.Cells(1, 5).Value = trads.TranslatedValue("varChoice")
477-
hRng.Cells(1, 6).Value = trads.TranslatedValue("choiceVal")
478-
hRng.Cells(1, 7).Value = trads.TranslatedValue("varStatus")
479-
480-
481-
'Change the dropdown values for the columns status and visibility
482-
With sh.ListObjects(1)
483-
484-
'variable status
485-
drop.SetValidation cellRng:=.ListColumns(5).DataBdoyRange, _
486-
listName:="__var_status_" & LCase(langId), _
487-
alertType:="error", _
488-
message:=selectValue
489-
490-
'variable visibility
491-
drop.SetValidation cellRng:=.ListColumns(6).DataBodyRange, _
492-
listName:="__var_status_" & LCase(langId), _
493-
alertType:="error", message:=selectValue
494-
End With
495-
496-
pass.Protect sh
497-
498-
'Update columns in the variable worksheet
499-
500-
ElseIf sh.Name = "Variables" Then
501-
502-
503-
Set hRng = sh.ListObjects(1).HeaderRowRange
504-
505-
pass.UnProtect sh
506-
507-
hRng.Cells(1, 1).Value = trads.TranslatedValue("varName")
508-
hRng.Cells(1, 2).Value = trads.TranslatedValue("varLabel")
509-
hRng.Cells(1, 3).Value = trads.TranslatedValue("defChoice")
510-
hRng.Cells(1, 4).Value = trads.TranslatedValue("choiceVal")
511-
hRng.Cells(1, 5).Value = trads.TranslatedValue("defStatus")
512-
hRng.Cells(1, 6).Value = trads.TranslatedValue("comments")
513-
514-
'Variable status validation
515-
pass.Protect sh
516-
517-
ElseIf sh.Name = "Choices" Then
518-
519-
Set hRng = sh.ListObjects(1).HeaderRowRange
520-
521-
pass.UnProtect sh
522-
523-
hRng.Cells(1, 1).Value = trads.TranslatedValue("listName")
524-
hRng.Cells(1, 2).Value = trads.TranslatedValue("orderingList")
525-
hRng.Cells(1, 3).Value = trads.TranslatedValue("longLabel")
526-
hRng.Cells(1, 4).Value = trads.TranslatedValue("shortLabel")
527-
528-
529-
pass.Protect sh
530-
End If
531-
532-
Next
533-
End Sub
444+
End Sub

src/msetup-codes/modules/Exports.bas

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Public Sub ExportForMigration()
9393
Dim outwb As Workbook
9494

9595
BusyApp
96-
On Error GoTo ExitExport
96+
'On Error GoTo ExitExport
9797

9898
InitializeTrads
9999

@@ -126,17 +126,6 @@ Public Sub ImportFlatFile()
126126

127127

128128

129-
Set lstSheets = New BetterArray
130-
Set io = OSFiles.Create
131-
132-
'Load the corresponding file for import
133-
134-
135-
'Import translation, Choices, and variables
136-
lstSheets.Push
137-
138-
139-
140129

141130

142131

0 commit comments

Comments
 (0)