Skip to content

Commit

Permalink
fix: table error modal not being focused
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerojas26 committed Jul 10, 2024
1 parent 275a101 commit f14d255
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions components/Home.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ func (home *Home) subscribeToTreeChanges() {
home.TabbedPane.AppendTab(tableName, table)
}

table.FetchRecords()
table.FetchRecords(func() {
home.focusLeftWrapper()
})

home.focusRightWrapper()
if table.state.error == "" {
home.focusRightWrapper()
}

app.App.ForceDraw()
}
Expand Down Expand Up @@ -202,7 +206,7 @@ func (home *Home) rightWrapperInputCapture(event *tcell.EventKey) *tcell.EventKe

if ((table.Menu != nil && table.Menu.GetSelectedOption() == 1) || table.Menu == nil) && !table.Pagination.GetIsFirstPage() && !table.GetIsLoading() {
table.Pagination.SetOffset(table.Pagination.GetOffset() - table.Pagination.GetLimit())
table.FetchRecords()
table.FetchRecords(nil)

}

Expand All @@ -216,7 +220,7 @@ func (home *Home) rightWrapperInputCapture(event *tcell.EventKey) *tcell.EventKe

if ((table.Menu != nil && table.Menu.GetSelectedOption() == 1) || table.Menu == nil) && !table.Pagination.GetIsLastPage() && !table.GetIsLoading() {
table.Pagination.SetOffset(table.Pagination.GetOffset() + table.Pagination.GetLimit())
table.FetchRecords()
table.FetchRecords(nil)
}
}
}
Expand Down Expand Up @@ -287,7 +291,7 @@ func (home *Home) homeInputCapture(event *tcell.EventKey) *tcell.EventKey {
home.ListOfDbChanges = []models.DbDmlChange{}
home.ListOfDbInserts = []models.DbInsert{}

table.FetchRecords()
table.FetchRecords(nil)
home.Tree.ForceRemoveHighlight()

}
Expand Down
8 changes: 4 additions & 4 deletions components/ResultsTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (table *ResultsTable) subscribeToFilterChanges() {
switch stateChange.Key {
case "Filter":
if stateChange.Value != "" {
rows := table.FetchRecords()
rows := table.FetchRecords(nil)

if len(rows) > 1 {
table.Menu.SetSelectedOption(1)
Expand All @@ -591,7 +591,7 @@ func (table *ResultsTable) subscribeToFilterChanges() {
}

} else {
table.FetchRecords()
table.FetchRecords(nil)

table.SetInputCapture(table.tableInputCapture)
App.SetFocus(table)
Expand Down Expand Up @@ -863,7 +863,7 @@ func (table *ResultsTable) SetSortedBy(column string, direction string) {
}
}

func (table *ResultsTable) FetchRecords() [][]string {
func (table *ResultsTable) FetchRecords(onError func()) [][]string {
tableName := table.GetDBReference()

table.SetLoading(true)
Expand All @@ -877,7 +877,7 @@ func (table *ResultsTable) FetchRecords() [][]string {
records, totalRecords, err := table.DBDriver.GetRecords(tableName, where, sort, table.Pagination.GetOffset(), table.Pagination.GetLimit())

if err != nil {
table.SetError(err.Error(), nil)
table.SetError(err.Error(), onError)
table.SetLoading(false)
} else {
if table.GetIsFiltering() {
Expand Down

0 comments on commit f14d255

Please sign in to comment.