Repository: Evertras/bubble-table
Pull request #153 (2023-10-09 05:35:24)

Fix some linting of filterapi example
Noticed that `cmd` was an ineffectual assignment for https://goreportcard.com/report/github.com/evertras/bubble-table report card, so took some time to fix that as well as a few other style changes while we're here to make it clearer.


Patch:
diff --git a/examples/filterapi/main.go b/examples/filterapi/main.go
index 66bd731..962a121 100644
--- a/examples/filterapi/main.go
+++ b/examples/filterapi/main.go
@@ -26,6 +26,7 @@ func NewModel() Model {
 		table.NewColumn(columnKeyAuthor, "Author", 13).WithFiltered(true),
 		table.NewColumn(columnKeyDescription, "Description", 50),
 	}
+
 	return Model{
 		table: table.
 			New(columns).
@@ -74,6 +75,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		// global
 		if msg.String() == "ctrl+c" {
 			cmds = append(cmds, tea.Quit)
+
 			return m, tea.Batch(cmds...)
 		}
 		// event to filter
@@ -81,9 +83,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			if msg.String() == "enter" {
 				m.filterTextInput.Blur()
 			} else {
-				m.filterTextInput, cmd = m.filterTextInput.Update(msg)
+				m.filterTextInput, _ = m.filterTextInput.Update(msg)
 			}
 			m.table = m.table.WithFilterInput(m.filterTextInput)
+
 			return m, tea.Batch(cmds...)
 		}
 
@@ -98,7 +101,6 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			m.table, cmd = m.table.Update(msg)
 			cmds = append(cmds, cmd)
 		}
-
 	}
 
 	return m, tea.Batch(cmds...)
@@ -108,7 +110,8 @@ func (m Model) View() string {
 	body := strings.Builder{}
 
 	body.WriteString("A filtered simple default table\n" +
-		"Currently filter by Title and Author, press / + letters to start filtering, and escape to clear filter.\nPress q or ctrl+c to quit\n\n")
+		"Currently filter by Title and Author, press / + letters to start filtering, and escape to clear filter.\n" +
+		"Press q or ctrl+c to quit\n\n")
 
 	body.WriteString(m.filterTextInput.View() + "\n")
 	body.WriteString(m.table.View())
diff --git a/table/query.go b/table/query.go
index 669915e..79da50f 100644
--- a/table/query.go
+++ b/table/query.go
@@ -80,6 +80,14 @@ func (m *Model) GetHeaderVisibility() bool {
 	return m.headerVisible
 }
 
+// GetFooterVisibility returns true if the footer has been set to
+// visible (default) or false if the footer has been set to hidden.
+// Note that even if the footer is visible it will only be rendered if
+// it has contents.
+func (m *Model) GetFooterVisibility() bool {
+	return m.footerVisible
+}
+
 // GetPaginationWrapping returns true if pagination wrapping is enabled, or false
 // if disabled.  If disabled, navigating through pages will stop at the first
 // and last pages.


Test patch:
diff --git a/table/query_test.go b/table/query_test.go
index 123948b..8de73fe 100644
--- a/table/query_test.go
+++ b/table/query_test.go
@@ -171,6 +171,16 @@ func TestGetHeaderVisibility(t *testing.T) {
 	assert.False(t, model.GetHeaderVisibility(), "Header was not set to hidden")
 }
 
+func TestGetFooterVisibility(t *testing.T) {
+	model := New([]Column{})
+
+	assert.True(t, model.GetFooterVisibility(), "Footer should be visible by default")
+
+	model = model.WithFooterVisibility(false)
+
+	assert.False(t, model.GetFooterVisibility(), "Footer was not set to hidden")
+}
+
 func TestGetPaginationWrapping(t *testing.T) {
 	model := New([]Column{})