Commit 43afe52a authored by Eric's avatar Eric

[Update] pagination improve

parent d30a8024
......@@ -104,14 +104,6 @@
revision = "3ee7d812e62a0804a7d0a324e0249ca2db3476d3"
version = "v0.0.4"
[[projects]]
digest = "1:4a49346ca45376a2bba679ca0e83bec949d780d4e927931317904bad482943ec"
name = "github.com/mattn/go-sqlite3"
packages = ["."]
pruneopts = "UT"
revision = "c7c4067b79cc51e6dfdcef5c702e74b1e0fa7c75"
version = "v1.10.0"
[[projects]]
digest = "1:abcdbf03ca6ca13d3697e2186edc1f33863bbdac2b3a44dfa39015e8903f7409"
name = "github.com/olekukonko/tablewriter"
......@@ -180,7 +172,7 @@
[[projects]]
branch = "master"
digest = "1:ed3d25dee9c9d77611e5ce1bd3a5a078930e8efb31afac120ccb1fbba7ec08d1"
digest = "1:1a1855ef6bc1338dd3870260716214046cefd69855c5a5a772d44d2791478abc"
name = "golang.org/x/sys"
packages = [
"cpu",
......@@ -188,7 +180,7 @@
"windows",
]
pruneopts = "UT"
revision = "a5b02f93d862f065920dd6a40dddc66b60d0dec4"
revision = "3a4b5fb9f71f5874b2374ae059bc0e0bcb52e145"
[[projects]]
digest = "1:c805e517269b0ba4c21ded5836019ed7d16953d4026cb7d00041d039c7906be9"
......@@ -215,7 +207,6 @@
"github.com/jarcoal/httpmock",
"github.com/kr/pty",
"github.com/leonelquinteros/gotext",
"github.com/mattn/go-sqlite3",
"github.com/olekukonko/tablewriter",
"github.com/pkg/errors",
"github.com/pkg/sftp",
......
......@@ -166,12 +166,12 @@ func (p *AssetPagination) getColumnMaxSize() {
}
func (p *AssetPagination) PaginationState() []model.Asset {
if !p.page.HasNextPage() {
p.displayAssets()
return []model.Asset{}
}
for {
if p.page.CurrentPage() == 1 && p.page.GetPageSize() > len(p.currentData) {
p.displayAssets()
return []model.Asset{}
}
p.displayAssets()
p.displayTipsInfo()
line, err := p.term.ReadLine()
......@@ -202,18 +202,21 @@ func (p *AssetPagination) PaginationState() []model.Asset {
}
case "b":
return []model.Asset{}
default:
if indexID, err := strconv.Atoi(line); err == nil {
if indexID > 0 && indexID <= len(p.currentData) {
return []model.Asset{p.currentData[indexID-1]}
}
}
}
}
if indexID, err := strconv.Atoi(line); err == nil {
if indexID > 0 && indexID <= p.page.TotalCount() {
return []model.Asset{p.currentData[indexID-1]}
default:
if indexID, err := strconv.Atoi(line); err == nil {
if indexID > 0 && indexID <= len(p.currentData) {
return []model.Asset{p.currentData[indexID-1]}
}
}
}
if p.page.CurrentPage() == 1 && p.page.GetPageSize() > len(p.currentData) {
p.displayAssets()
return []model.Asset{}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment