From a2942c01e0478ef41432bb4a626cfecc0c3e48fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20L=C3=B3pez=20=28inkel=29?= Date: Sun, 8 Oct 2023 19:52:27 -0300 Subject: [PATCH] Add Model.GetFooterVisibility function This is analog to the GetHeaderVisibility function. Note that it only reports if the footer should be visible, but if it has no contents it won't be rendered. --- table/query.go | 8 ++++++++ table/query_test.go | 10 ++++++++++ 2 files changed, 18 insertions(+) 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. 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{})