From 470d36a0af2fb2f088db1ae2799f94568a49655c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Otter?= Date: Sun, 16 Jun 2024 14:05:14 +0200 Subject: [PATCH 1/6] Find and Select via TableRows --- webapp/containers/data/cntBackups.xojo_code | 14 +++++------- webapp/containers/data/cntDatabases.xojo_code | 14 +++++------- webapp/containers/data/cntSchedules.xojo_code | 14 +++++------- .../data/cntTablesIndexes.xojo_code | 18 +++++++-------- .../information/cntClients.xojo_code | 14 +++++------- .../security/cntEnginePreferences.xojo_code | 22 +++++++++---------- .../containers/security/cntGroups.xojo_code | 14 +++++------- .../security/cntPrivileges.xojo_code | 22 +++++++++---------- webapp/containers/security/cntUsers.xojo_code | 14 +++++------- webapp/containers/server/cntPlugins.xojo_code | 14 +++++------- 10 files changed, 70 insertions(+), 90 deletions(-) diff --git a/webapp/containers/data/cntBackups.xojo_code b/webapp/containers/data/cntBackups.xojo_code index 8e68a1c..4ccb037 100644 --- a/webapp/containers/data/cntBackups.xojo_code +++ b/webapp/containers/data/cntBackups.xojo_code @@ -802,14 +802,12 @@ End esSelectAfterReload = "" Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("timestamp", "-").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("timestamp", "-").StringValue <> sSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) Then Me.Table.SelectedRowIndex = -1 diff --git a/webapp/containers/data/cntDatabases.xojo_code b/webapp/containers/data/cntDatabases.xojo_code index 42f27d8..823e887 100644 --- a/webapp/containers/data/cntDatabases.xojo_code +++ b/webapp/containers/data/cntDatabases.xojo_code @@ -1146,14 +1146,12 @@ End esSelectAfterReload = "" Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("databasename", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("databasename", "").StringValue <> sSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) Then Me.Table.SelectedRowIndex = -1 diff --git a/webapp/containers/data/cntSchedules.xojo_code b/webapp/containers/data/cntSchedules.xojo_code index ea7fe48..fd31103 100644 --- a/webapp/containers/data/cntSchedules.xojo_code +++ b/webapp/containers/data/cntSchedules.xojo_code @@ -934,14 +934,12 @@ End esSelectAfterReload = "" Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("schedname", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("schedname", "").StringValue <> sSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) Then Me.Table.SelectedRowIndex = -1 diff --git a/webapp/containers/data/cntTablesIndexes.xojo_code b/webapp/containers/data/cntTablesIndexes.xojo_code index 31082e4..e88debe 100644 --- a/webapp/containers/data/cntTablesIndexes.xojo_code +++ b/webapp/containers/data/cntTablesIndexes.xojo_code @@ -786,16 +786,14 @@ End edictSelectAfterReload = Nil Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("type", "").StringValue = sSelectAfterReload.Lookup("type", "-").StringValue) And _ - (rowTag.Lookup("name", "").StringValue = sSelectAfterReload.Lookup("name", "-").StringValue) Then - - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("type", "").StringValue = sSelectAfterReload.Lookup("type", "-").StringValue) And _ + (tableRow.Lookup("name", "").StringValue = sSelectAfterReload.Lookup("name", "-").StringValue) Then + + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop End If Next diff --git a/webapp/containers/information/cntClients.xojo_code b/webapp/containers/information/cntClients.xojo_code index b1024d7..c7c11f3 100644 --- a/webapp/containers/information/cntClients.xojo_code +++ b/webapp/containers/information/cntClients.xojo_code @@ -386,14 +386,12 @@ End eiSelectAfterReload = -1 Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("id", "").IntegerValue <> iSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("id", "").IntegerValue <> iSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) Then Me.Table.SelectedRowIndex = -1 diff --git a/webapp/containers/security/cntEnginePreferences.xojo_code b/webapp/containers/security/cntEnginePreferences.xojo_code index 34eef63..9cb5691 100644 --- a/webapp/containers/security/cntEnginePreferences.xojo_code +++ b/webapp/containers/security/cntEnginePreferences.xojo_code @@ -790,18 +790,16 @@ End edictSelectAfterReload = Nil Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If(rowTag.Lookup("engine", "").StringValue = sSelectAfterReload.Lookup("engine", "-").StringValue) And _ - (rowTag.Lookup("groupname", "").StringValue = sSelectAfterReload.Lookup("groupname", "-").StringValue) And _ - (rowTag.Lookup("databasename", "").StringValue = sSelectAfterReload.Lookup("databasename", "-").StringValue) And _ - (rowTag.Lookup("key", "").StringValue = sSelectAfterReload.Lookup("key", "-").StringValue) Then - - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If(tableRow.Lookup("engine", "").StringValue = sSelectAfterReload.Lookup("engine", "-").StringValue) And _ + (tableRow.Lookup("groupname", "").StringValue = sSelectAfterReload.Lookup("groupname", "-").StringValue) And _ + (tableRow.Lookup("databasename", "").StringValue = sSelectAfterReload.Lookup("databasename", "-").StringValue) And _ + (tableRow.Lookup("key", "").StringValue = sSelectAfterReload.Lookup("key", "-").StringValue) Then + + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop End If Next diff --git a/webapp/containers/security/cntGroups.xojo_code b/webapp/containers/security/cntGroups.xojo_code index a633352..87383c5 100644 --- a/webapp/containers/security/cntGroups.xojo_code +++ b/webapp/containers/security/cntGroups.xojo_code @@ -536,14 +536,12 @@ End esSelectAfterReload = "" Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("groupname", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("groupname", "").StringValue <> sSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) Then Me.Table.SelectedRowIndex = -1 diff --git a/webapp/containers/security/cntPrivileges.xojo_code b/webapp/containers/security/cntPrivileges.xojo_code index 0e8d451..9f35e3a 100644 --- a/webapp/containers/security/cntPrivileges.xojo_code +++ b/webapp/containers/security/cntPrivileges.xojo_code @@ -766,18 +766,16 @@ End edictSelectAfterReload = Nil Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("groupname", "").StringValue = sSelectAfterReload.Lookup("groupname", "-").StringValue) And _ - (rowTag.Lookup("privilege", "").StringValue = sSelectAfterReload.Lookup("privilege", "-").StringValue) And _ - (rowTag.Lookup("databasename", "").StringValue = sSelectAfterReload.Lookup("databasename", "-").StringValue) And _ - (rowTag.Lookup("tablename", "").StringValue = sSelectAfterReload.Lookup("tablename", "-").StringValue) Then - - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("groupname", "").StringValue = sSelectAfterReload.Lookup("groupname", "-").StringValue) And _ + (tableRow.Lookup("privilege", "").StringValue = sSelectAfterReload.Lookup("privilege", "-").StringValue) And _ + (tableRow.Lookup("databasename", "").StringValue = sSelectAfterReload.Lookup("databasename", "-").StringValue) And _ + (tableRow.Lookup("tablename", "").StringValue = sSelectAfterReload.Lookup("tablename", "-").StringValue) Then + + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop End If Next diff --git a/webapp/containers/security/cntUsers.xojo_code b/webapp/containers/security/cntUsers.xojo_code index 7aaae56..a056c60 100644 --- a/webapp/containers/security/cntUsers.xojo_code +++ b/webapp/containers/security/cntUsers.xojo_code @@ -890,14 +890,12 @@ End esSelectAfterReload = "" Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("username", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("username", "").StringValue <> sSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) Then Me.Table.SelectedRowIndex = -1 diff --git a/webapp/containers/server/cntPlugins.xojo_code b/webapp/containers/server/cntPlugins.xojo_code index 53d7982..eba48c2 100644 --- a/webapp/containers/server/cntPlugins.xojo_code +++ b/webapp/containers/server/cntPlugins.xojo_code @@ -212,14 +212,12 @@ End esSelectAfterReload = "" Var bFound As Boolean = False - For i As Integer = Me.Table.LastRowIndex DownTo 0 - Var rowTag As Dictionary = Me.Table.RowTagAt(i) - If (rowTag IsA Dictionary) Then - If (rowTag.Lookup("name", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If + For i As Integer = Me.TableRows.LastIndex DownTo 0 + Var tableRow As Dictionary = Me.TableRows(i) + If (tableRow.Lookup("name", "").StringValue <> sSelectAfterReload) Then Continue + Me.Table.SelectedRowIndex = i + bFound = True + Exit 'Loop Next If (Not bFound) And (Me.TableRows <> Nil) And (Me.TableRows.LastIndex >= 0) And (Me.Table.RowCount > 0) Then From bae2868d4a1e4b7aac53a38f490598b80ff92b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Otter?= Date: Sun, 16 Jun 2024 16:37:03 +0200 Subject: [PATCH 2/6] Refactor: TableRowFindAndSelect --- .../base/cntDatasourceBase.xojo_code | 29 +++++++++++++++++++ webapp/containers/data/cntBackups.xojo_code | 14 ++++----- webapp/containers/data/cntDatabases.xojo_code | 14 ++++----- webapp/containers/data/cntSchedules.xojo_code | 14 ++++----- .../data/cntTablesIndexes.xojo_code | 18 ++++-------- .../information/cntClients.xojo_code | 16 ++++------ .../security/cntEnginePreferences.xojo_code | 24 ++++++--------- .../containers/security/cntGroups.xojo_code | 16 ++++------ .../security/cntPrivileges.xojo_code | 24 ++++++--------- webapp/containers/security/cntUsers.xojo_code | 16 ++++------ webapp/containers/server/cntPlugins.xojo_code | 12 ++------ 11 files changed, 89 insertions(+), 108 deletions(-) diff --git a/webapp/containers/base/cntDatasourceBase.xojo_code b/webapp/containers/base/cntDatasourceBase.xojo_code index bff45a5..417b16f 100644 --- a/webapp/containers/base/cntDatasourceBase.xojo_code +++ b/webapp/containers/base/cntDatasourceBase.xojo_code @@ -439,6 +439,35 @@ Implements WebDataSource End Sub #tag EndMethod + #tag Method, Flags = &h1 + Protected Function TableRowFindAndSelect(findByFields As Dictionary) As Boolean + If (Me.TableRows = Nil) Or (Me.TableRows.LastIndex < 0) Then Return False + If (findByFields = Nil) Or (findByFields.KeyCount < 1) Then Return False + + Var tableRow As Dictionary + Var bAllFieldsFound As Boolean + For i As Integer = Me.TableRows.LastIndex DownTo 0 + tableRow = Me.TableRows(i) + + bAllFieldsFound = True + For Each field As Variant In findByFields.Keys + If (tableRow.Lookup(field.StringValue, "").StringValue <> findByFields.Value(field).StringValue) Then + bAllFieldsFound = False + Exit 'Loop matching Fields + End If + Next + + If (Not bAllFieldsFound) Then Continue 'searching next Table Row + + Me.Table.SelectedRowIndex = i + Return True + Next + + Return False + + End Function + #tag EndMethod + #tag Method, Flags = &h21 Private Function UnsortedPrimaryKeys() As Integer() // Part of the WebDataSource interface. diff --git a/webapp/containers/data/cntBackups.xojo_code b/webapp/containers/data/cntBackups.xojo_code index 4ccb037..3029621 100644 --- a/webapp/containers/data/cntBackups.xojo_code +++ b/webapp/containers/data/cntBackups.xojo_code @@ -801,16 +801,12 @@ End Var sSelectAfterReload As String = esSelectAfterReload esSelectAfterReload = "" - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("timestamp", "-").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next + Var findByFields As New Dictionary + findByFields.Value("timestamp") = sSelectAfterReload - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/data/cntDatabases.xojo_code b/webapp/containers/data/cntDatabases.xojo_code index 823e887..2078d88 100644 --- a/webapp/containers/data/cntDatabases.xojo_code +++ b/webapp/containers/data/cntDatabases.xojo_code @@ -1145,16 +1145,12 @@ End Var sSelectAfterReload As String = esSelectAfterReload esSelectAfterReload = "" - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("databasename", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next + Var findByFields As New Dictionary + findByFields.Value("databasename") = sSelectAfterReload - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/data/cntSchedules.xojo_code b/webapp/containers/data/cntSchedules.xojo_code index fd31103..2b13697 100644 --- a/webapp/containers/data/cntSchedules.xojo_code +++ b/webapp/containers/data/cntSchedules.xojo_code @@ -933,16 +933,12 @@ End Var sSelectAfterReload As String = esSelectAfterReload esSelectAfterReload = "" - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("schedname", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next + Var findByFields As New Dictionary + findByFields.Value("schedname") = sSelectAfterReload - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/data/cntTablesIndexes.xojo_code b/webapp/containers/data/cntTablesIndexes.xojo_code index e88debe..5267810 100644 --- a/webapp/containers/data/cntTablesIndexes.xojo_code +++ b/webapp/containers/data/cntTablesIndexes.xojo_code @@ -785,19 +785,13 @@ End Var sSelectAfterReload As Dictionary = edictSelectAfterReload edictSelectAfterReload = Nil - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("type", "").StringValue = sSelectAfterReload.Lookup("type", "-").StringValue) And _ - (tableRow.Lookup("name", "").StringValue = sSelectAfterReload.Lookup("name", "-").StringValue) Then - - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If - Next + Var findByFields As New Dictionary + findByFields.Value("type") = sSelectAfterReload.Lookup("type", "-").StringValue + findByFields.Value("name") = sSelectAfterReload.Lookup("name", "-").StringValue - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/information/cntClients.xojo_code b/webapp/containers/information/cntClients.xojo_code index c7c11f3..2fe4d02 100644 --- a/webapp/containers/information/cntClients.xojo_code +++ b/webapp/containers/information/cntClients.xojo_code @@ -385,16 +385,12 @@ End Var iSelectAfterReload As Integer = eiSelectAfterReload eiSelectAfterReload = -1 - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("id", "").IntegerValue <> iSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next + Var findByFields As New Dictionary + findByFields.Value("id") = iSelectAfterReload - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() @@ -432,7 +428,7 @@ End #tag Events btnRefresh #tag Event Sub Pressed() - Self.TableLoad() + Self.RefreshInfos() End Sub #tag EndEvent diff --git a/webapp/containers/security/cntEnginePreferences.xojo_code b/webapp/containers/security/cntEnginePreferences.xojo_code index 9cb5691..155c4d2 100644 --- a/webapp/containers/security/cntEnginePreferences.xojo_code +++ b/webapp/containers/security/cntEnginePreferences.xojo_code @@ -789,21 +789,15 @@ End Var sSelectAfterReload As Dictionary = edictSelectAfterReload edictSelectAfterReload = Nil - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If(tableRow.Lookup("engine", "").StringValue = sSelectAfterReload.Lookup("engine", "-").StringValue) And _ - (tableRow.Lookup("groupname", "").StringValue = sSelectAfterReload.Lookup("groupname", "-").StringValue) And _ - (tableRow.Lookup("databasename", "").StringValue = sSelectAfterReload.Lookup("databasename", "-").StringValue) And _ - (tableRow.Lookup("key", "").StringValue = sSelectAfterReload.Lookup("key", "-").StringValue) Then - - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If - Next - - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + Var findByFields As New Dictionary + findByFields.Value("engine") = sSelectAfterReload.Lookup("engine", "-").StringValue + findByFields.Value("groupname") = sSelectAfterReload.Lookup("groupname", "-").StringValue + findByFields.Value("databasename") = sSelectAfterReload.Lookup("databasename", "-").StringValue + findByFields.Value("key") = sSelectAfterReload.Lookup("key", "-").StringValue + + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/security/cntGroups.xojo_code b/webapp/containers/security/cntGroups.xojo_code index 87383c5..e23ba18 100644 --- a/webapp/containers/security/cntGroups.xojo_code +++ b/webapp/containers/security/cntGroups.xojo_code @@ -535,16 +535,12 @@ End Var sSelectAfterReload As String = esSelectAfterReload esSelectAfterReload = "" - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("groupname", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next - - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + Var findByFields As New Dictionary + findByFields.Value("groupname") = sSelectAfterReload + + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/security/cntPrivileges.xojo_code b/webapp/containers/security/cntPrivileges.xojo_code index 9f35e3a..8c61354 100644 --- a/webapp/containers/security/cntPrivileges.xojo_code +++ b/webapp/containers/security/cntPrivileges.xojo_code @@ -765,21 +765,15 @@ End Var sSelectAfterReload As Dictionary = edictSelectAfterReload edictSelectAfterReload = Nil - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("groupname", "").StringValue = sSelectAfterReload.Lookup("groupname", "-").StringValue) And _ - (tableRow.Lookup("privilege", "").StringValue = sSelectAfterReload.Lookup("privilege", "-").StringValue) And _ - (tableRow.Lookup("databasename", "").StringValue = sSelectAfterReload.Lookup("databasename", "-").StringValue) And _ - (tableRow.Lookup("tablename", "").StringValue = sSelectAfterReload.Lookup("tablename", "-").StringValue) Then - - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - End If - Next - - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + Var findByFields As New Dictionary + findByFields.Value("groupname") = sSelectAfterReload.Lookup("groupname", "-").StringValue + findByFields.Value("privilege") = sSelectAfterReload.Lookup("privilege", "-").StringValue + findByFields.Value("databasename") = sSelectAfterReload.Lookup("databasename", "-").StringValue + findByFields.Value("tablename") = sSelectAfterReload.Lookup("tablename", "-").StringValue + + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/security/cntUsers.xojo_code b/webapp/containers/security/cntUsers.xojo_code index a056c60..66f54b9 100644 --- a/webapp/containers/security/cntUsers.xojo_code +++ b/webapp/containers/security/cntUsers.xojo_code @@ -889,16 +889,12 @@ End Var sSelectAfterReload As String = esSelectAfterReload esSelectAfterReload = "" - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("username", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next - - If (Not bFound) Then Me.Table.SelectedRowIndex = -1 + Var findByFields As New Dictionary + findByFields.Value("username") = sSelectAfterReload + + If (Not Me.TableRowFindAndSelect(findByFields)) Then + Me.Table.SelectedRowIndex = -1 + End If Me.RefreshButtons() diff --git a/webapp/containers/server/cntPlugins.xojo_code b/webapp/containers/server/cntPlugins.xojo_code index eba48c2..b59eec6 100644 --- a/webapp/containers/server/cntPlugins.xojo_code +++ b/webapp/containers/server/cntPlugins.xojo_code @@ -211,16 +211,10 @@ End Var sSelectAfterReload As String = esSelectAfterReload esSelectAfterReload = "" - Var bFound As Boolean = False - For i As Integer = Me.TableRows.LastIndex DownTo 0 - Var tableRow As Dictionary = Me.TableRows(i) - If (tableRow.Lookup("name", "").StringValue <> sSelectAfterReload) Then Continue - Me.Table.SelectedRowIndex = i - bFound = True - Exit 'Loop - Next + Var findByFields As New Dictionary + findByFields.Value("name") = sSelectAfterReload - If (Not bFound) And (Me.TableRows <> Nil) And (Me.TableRows.LastIndex >= 0) And (Me.Table.RowCount > 0) Then + If (Not Me.TableRowFindAndSelect(findByFields)) And (Me.TableRows.LastIndex >= 0) And (Me.Table.RowCount > 0) Then Me.Table.SelectedRowIndex = 0 End If From 50b29d9e872f5d45e79892efcaffb9f7f702312a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Otter?= Date: Thu, 20 Jun 2024 22:00:40 +0200 Subject: [PATCH 3/6] Get RowTag via TableRows --- webapp/containers/base/cntDatasourceBase.xojo_code | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webapp/containers/base/cntDatasourceBase.xojo_code b/webapp/containers/base/cntDatasourceBase.xojo_code index 417b16f..5f4b30a 100644 --- a/webapp/containers/base/cntDatasourceBase.xojo_code +++ b/webapp/containers/base/cntDatasourceBase.xojo_code @@ -54,9 +54,9 @@ Implements WebDataSource If (Me.Table = Nil) Then Return Nil Var rowIndex As Integer = Me.Table.SelectedRowIndex - If (rowIndex < 0) Then Return Nil + If (rowIndex < 0) Or (rowIndex > Me.TableRows.LastIndex) Then Return Nil - Return Me.Table.RowTagAt(rowIndex) + Return Me.TableRows(rowIndex).Lookup("rowtag", Nil) End Function #tag EndMethod @@ -198,7 +198,6 @@ Implements WebDataSource Var row As New WebListBoxRowData row.PrimaryKey = Me.TableRows(i).Lookup("id", -1).IntegerValue - row.Tag = dictRow For Each col As DatasourceColumn In Me.Columns Var colData As Variant = Me.TableRowColumnData(col, dictRow) @@ -227,6 +226,8 @@ Implements WebDataSource End Select Next + dictRow.Value("rowtag") = dictRowTag + row.Tag = dictRowTag rows.Add(row) From c70161b6cc9e50766d5c9efa52493a4838c59af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Otter?= Date: Fri, 21 Jun 2024 22:12:07 +0200 Subject: [PATCH 4/6] Workaround: WebDataSource 0/1 based PrimaryKey --- webapp/containers/base/cntDatasourceBase.xojo_code | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/containers/base/cntDatasourceBase.xojo_code b/webapp/containers/base/cntDatasourceBase.xojo_code index 5f4b30a..4051029 100644 --- a/webapp/containers/base/cntDatasourceBase.xojo_code +++ b/webapp/containers/base/cntDatasourceBase.xojo_code @@ -72,7 +72,11 @@ Implements WebDataSource If (rs <> Nil) Then If (rs.RowCount > 0) Then Var bIdFromRowset As Boolean = False - Var id As Integer = 1 + #If (XojoVersion >= 2024.02) Then + Var id As Integer = 0 + #Else + Var id As Integer = 1 + #EndIf Var bFilteredOut As Boolean Var bSearchFilterShowRow As Boolean rs.MoveToFirstRow From 01249ed800737a293b42d745a993e7b5df50c207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Otter?= Date: Sat, 22 Jun 2024 23:09:54 +0200 Subject: [PATCH 5/6] Update Note DebugMemoryIssues --- webapp/main/LoginPage.xojo_code | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/webapp/main/LoginPage.xojo_code b/webapp/main/LoginPage.xojo_code index 64c1b82..ef7e99c 100644 --- a/webapp/main/LoginPage.xojo_code +++ b/webapp/main/LoginPage.xojo_code @@ -29,6 +29,7 @@ Begin WebPage LoginPage _ImplicitInstance= False _mDesignHeight = 0 _mDesignWidth = 0 + _mName = "" _mPanelIndex = -1 Begin WebRectangle rectLogin BackgroundColor = &cFFFFFF @@ -584,7 +585,7 @@ Begin WebPage LoginPage Enabled = True Height = 32 Index = -2147483648 - Indicator = "" + Indicator = 0 Left = 372 LockBottom = False LockedInPosition= True @@ -598,6 +599,7 @@ Begin WebPage LoginPage SVGColor = &c00000000 SVGData = "" TabIndex = 15 + TabPanelIndex = 0 TabStop = True Tooltip = "" Top = 440 @@ -634,8 +636,6 @@ Begin WebPage LoginPage Period = 50 RunMode = 0 Scope = 2 - TabIndex = 15 - TabStop = True _mPanelIndex = -1 End End @@ -929,7 +929,13 @@ End #tag Note, Name = DebugMemoryIssues - Place this in the Run Event of a WebThread (Location: Browser). + 1. Add a WebLabel + - Name: labMemory + - Multiline: True + 2. Add a WebTimer + - Location: Browser + 3. Copy and Paste the code below to the Run Event of the WebTimer + It'll show the count of instances. ***** From 37899adbc7ee61ee71030f128c6a9cedece7b05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Otter?= Date: Thu, 27 Jun 2024 17:21:09 +0200 Subject: [PATCH 6/6] Remove Workaround for Xojo 2024r2 PreReleases --- webapp/containers/base/cntDatasourceBase.xojo_code | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/webapp/containers/base/cntDatasourceBase.xojo_code b/webapp/containers/base/cntDatasourceBase.xojo_code index 4051029..5f4b30a 100644 --- a/webapp/containers/base/cntDatasourceBase.xojo_code +++ b/webapp/containers/base/cntDatasourceBase.xojo_code @@ -72,11 +72,7 @@ Implements WebDataSource If (rs <> Nil) Then If (rs.RowCount > 0) Then Var bIdFromRowset As Boolean = False - #If (XojoVersion >= 2024.02) Then - Var id As Integer = 0 - #Else - Var id As Integer = 1 - #EndIf + Var id As Integer = 1 Var bFilteredOut As Boolean Var bSearchFilterShowRow As Boolean rs.MoveToFirstRow