Skip to content

Commit

Permalink
Merge pull request #29 from IdlePhysicist/develop
Browse files Browse the repository at this point in the history
Notes field, and cview
  • Loading branch information
IdlePhysicist authored Sep 15, 2020
2 parents 801eee1 + a8bb0fe commit cf9f5df
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 99 deletions.
12 changes: 3 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
module github.com/idlephysicist/cave-logger

go 1.13
go 1.14

require (
github.com/bvinc/go-sqlite-lite v0.6.1
github.com/gdamore/tcell v1.2.0
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b
github.com/sirupsen/logrus v1.4.2
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gitlab.com/tslocum/cview v1.4.9-0.20200901224443-f35f86924a49
)
54 changes: 19 additions & 35 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,56 +1,40 @@
github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/bvinc/go-sqlite-lite v0.6.1 h1:JU8Rz5YAOZQiU3WEulKF084wfXpytRiqD2IaW2QjPz4=
github.com/bvinc/go-sqlite-lite v0.6.1/go.mod h1:2GiE60NUdb0aNhDdY+LXgrqAVDpi2Ijc6dB6ZMp9x6s=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.1.2/go.mod h1:h3kq4HO9l2On+V9ed8w8ewqQEmGCSSHOgQ+2h8uzurE=
github.com/gdamore/tcell v1.2.0 h1:ikixzsxc8K8o3V2/CEmyoEW8mJZaNYQQ3NP3VIQdUe4=
github.com/gdamore/tcell v1.2.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
github.com/gdamore/tcell/v2 v2.0.0-dev/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b h1:j9fvrLkgzxR1S/ZWI6fbw8hjNxU5/lxnVXBX2tuYGVA=
github.com/gdamore/tcell/v2 v2.0.0-dev.0.20200831155531-da485f47343b/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 h1:d2Z5U4d3fenPRFFweaMCogbXiRywM5kgYtu20/hol3M=
github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk=
github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44 h1:XKCbzPvK4/BbMXoMJOkYP2ANxiAEO0HM1xn6psSbXxY=
github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a h1:6u2QDDcKdeFhyHT/srxPDzLfDJqwKTgy1v+3209LYBY=
gitlab.com/tslocum/cbind v0.1.2-0.20200826214515-b5f2c6a8711a/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6xdeeI=
gitlab.com/tslocum/cview v1.4.9-0.20200901224443-f35f86924a49 h1:BQCW6LMs3qK/j0ZIyD3EF9AUsS1RZs9SvuDPdPkEqmw=
gitlab.com/tslocum/cview v1.4.9-0.20200901224443-f35f86924a49/go.mod h1:yC/rMZkRxbKb6kUvnRyVjNEpb7ZREKG0ynEMHJq+Sgo=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 h1:wYqz/tQaWUgGKyx+B/rssSE6wkIKdY5Ee6ryOmzarIg=
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a h1:i47hUS795cOydZI4AwJQCKXOr4BvxzvikwDoDtHhP2Y=
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
32 changes: 16 additions & 16 deletions internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (db *Database) AddTrip(date, location, names, notes string) error {
return nil
}

func (db *Database) AddLocation(name, region, country string, srt bool) error {
query := `INSERT INTO locations (name, region, country, srt) VALUES (?,?,?,?)`
func (db *Database) AddLocation(name, region, country, notes string, srt bool) error {
query := `INSERT INTO locations (name, region, country, srt, notes) VALUES (?,?,?,?,?)`
params := []interface{}{name, region, country, srt}

if err := db.conn.Begin(); err != nil {
Expand All @@ -113,8 +113,8 @@ func (db *Database) AddLocation(name, region, country string, srt bool) error {
return nil
}

func (db *Database) AddPerson(name, club string) error {
query := `INSERT INTO people (name, club) VALUES (?,?)`
func (db *Database) AddPerson(name, club, notes string) error {
query := `INSERT INTO people (name, club, notes) VALUES (?,?,?)`
params := []interface{}{name, club}

if err := db.conn.Begin(); err != nil {
Expand Down Expand Up @@ -353,7 +353,8 @@ func (db *Database) GetPerson(personID string) (*model.Caver, error) {
SELECT COUNT(1)
FROM trip_groups
WHERE trip_groups.caverid = people.id
) AS 'count'
) AS 'count',
people.notes AS 'notes'
FROM people
WHERE people.id = ?`

Expand All @@ -378,7 +379,7 @@ func (db *Database) GetPerson(personID string) (*model.Caver, error) {
break
}

err = result.Scan(&person.ID, &person.Name, &person.Club, &person.Count)
err = result.Scan(&person.ID, &person.Name, &person.Club, &person.Count, &person.Notes)
if err != nil {
db.log.Error(err)
return people[0], err
Expand Down Expand Up @@ -491,7 +492,8 @@ func (db *Database) GetLocation(caveID string) (*model.Cave, error) {
SELECT COUNT(1)
FROM trips
WHERE trips.caveid = locations.id
) AS 'visits'
) AS 'visits',
locations.notes AS 'notes'
FROM locations
WHERE id = ?`
result, err := db.conn.Prepare(query, caveID)
Expand All @@ -503,8 +505,6 @@ func (db *Database) GetLocation(caveID string) (*model.Cave, error) {

caves := make([]*model.Cave, 0)
for {
//var caverIDstr string
//var stamp int64
var cave model.Cave

rowExists, err := result.Step()
Expand All @@ -517,7 +517,7 @@ func (db *Database) GetLocation(caveID string) (*model.Cave, error) {
break
}

err = result.Scan(&cave.ID, &cave.Name, &cave.Region, &cave.Country, &cave.SRT, &cave.Visits)
err = result.Scan(&cave.ID, &cave.Name, &cave.Region, &cave.Country, &cave.SRT, &cave.Visits, &cave.Notes)
if err != nil {
db.log.Error(err)
return caves[0], err
Expand Down Expand Up @@ -671,9 +671,9 @@ func (db *Database) ModifyTrip(id, date, location, names, notes string) error {
return nil
}

func (db *Database) ModifyPerson(id, name, club string) error {
query := `UPDATE people SET name = ?, club = ? WHERE id = ?`
params := []interface{}{name, club, id}
func (db *Database) ModifyPerson(id, name, club, notes string) error {
query := `UPDATE people SET name = ?, club = ?, notes = ? WHERE id = ?`
params := []interface{}{name, club, notes, id}

if err := db.conn.Begin(); err != nil {
return err
Expand All @@ -698,9 +698,9 @@ func (db *Database) ModifyPerson(id, name, club string) error {
return nil
}

func (db *Database) ModifyLocation(id, name, region, country string, srt bool) error {
query := `UPDATE locations SET name = ?, region = ?, country = ?, srt = ? WHERE id = ?`
params := []interface{}{name, region, country, srt, id}
func (db *Database) ModifyLocation(id, name, region, country, notes string, srt bool) error {
query := `UPDATE locations SET name = ?, region = ?, country = ?, srt = ?, notes = ? WHERE id = ?`
params := []interface{}{name, region, country, srt, notes, id}

if err := db.conn.Begin(); err != nil {
return err
Expand Down
7 changes: 5 additions & 2 deletions internal/gui/cavers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"time"

"github.com/gdamore/tcell"
"github.com/rivo/tview"
"github.com/gdamore/tcell/v2"
tview "gitlab.com/tslocum/cview"

"github.com/idlephysicist/cave-logger/internal/model"
)
Expand Down Expand Up @@ -38,6 +38,9 @@ func (c *cavers) setKeybinding(g *Gui) {
g.setGlobalKeybinding(event)

switch event.Key() {
case tcell.KeyEnter:
g.state.navigate.update("detail")
g.inspectCaver()
case tcell.KeyCtrlR:
c.setEntries(g)
}
Expand Down
7 changes: 5 additions & 2 deletions internal/gui/caves.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"time"

"github.com/gdamore/tcell"
"github.com/rivo/tview"
"github.com/gdamore/tcell/v2"
tview "gitlab.com/tslocum/cview"

"github.com/idlephysicist/cave-logger/internal/model"
)
Expand Down Expand Up @@ -38,6 +38,9 @@ func (c *caves) setKeybinding(g *Gui) {
g.setGlobalKeybinding(event)

switch event.Key() {
case tcell.KeyEnter:
g.state.navigate.update("detail")
g.inspectCave()
case tcell.KeyCtrlR:
c.setEntries(g)
}
Expand Down
18 changes: 13 additions & 5 deletions internal/gui/cud.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
"strings"

"github.com/rivo/tview"
tview "gitlab.com/tslocum/cview"
)

var inputWidth = 70
Expand Down Expand Up @@ -108,7 +108,8 @@ func (g *Gui) createLocationForm() {
AddInputField("Name", "", inputWidth, nil, nil).
AddFormItem(regionField).
AddFormItem(countryField).
AddCheckbox("SRT", false, nil).
AddCheckBox("SRT", "", false, nil).
AddInputField("Notes", "", inputWidth, nil, nil).
AddButton("Add", func() {
g.createLocation(form)
}).
Expand All @@ -124,7 +125,8 @@ func (g *Gui) createLocation(form *tview.Form) {
form.GetFormItemByLabel("Name").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Region").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Country").(*tview.InputField).GetText(),
form.GetFormItemByLabel("SRT").(*tview.Checkbox).IsChecked(),
form.GetFormItemByLabel("Notes").(*tview.InputField).GetText(),
form.GetFormItemByLabel("SRT").(*tview.CheckBox).IsChecked(),
)
if err != nil { // NOTE: Needs fixing
g.warning(err.Error(), `form`, []string{`OK`}, func() {return})
Expand Down Expand Up @@ -161,6 +163,7 @@ func (g *Gui) createPersonForm() {
form.
AddInputField("Name", "", inputWidth, nil, nil).
AddFormItem(clubField).
AddInputField("Notes", "", inputWidth, nil, nil).
AddButton("Add", func() {
g.createPerson(form)
}).
Expand All @@ -175,6 +178,7 @@ func (g *Gui) createPerson(form *tview.Form) {
err := g.db.AddPerson(
form.GetFormItemByLabel("Name").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Club").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Notes").(*tview.InputField).GetText(),
)
if err != nil { // NOTE: Needs fixing
g.warning(err.Error(), `form`, []string{`OK`}, func() {return})
Expand Down Expand Up @@ -283,6 +287,7 @@ func (g *Gui) modifyPersonForm() {
form.
AddInputField("Name", selectedPerson.Name, inputWidth, nil, nil).
AddFormItem(clubField).
AddInputField("Notes", selectedPerson.Notes, inputWidth, nil, nil).
AddButton("Apply", func() {
g.modifyPerson(selectedPerson.ID, form)
}).
Expand All @@ -298,6 +303,7 @@ func (g *Gui) modifyPerson(id string, form *tview.Form) {
id,
form.GetFormItemByLabel("Name").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Club").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Notes").(*tview.InputField).GetText(),
)
if err != nil {
g.warning(err.Error(), `form`, []string{`OK`}, func() {return})
Expand Down Expand Up @@ -358,7 +364,8 @@ func (g *Gui) modifyLocationForm() {
AddInputField("Name", selectedLocation.Name, inputWidth, nil, nil).
AddFormItem(regionField).
AddFormItem(countryField).
AddCheckbox("SRT", selectedLocation.SRT, nil).
AddCheckBox("SRT", "", selectedLocation.SRT, nil).
AddInputField("Notes", selectedLocation.Notes, inputWidth, nil, nil).
AddButton("Apply", func() {
g.modifyLocation(selectedLocation.ID, form)
}).
Expand All @@ -375,7 +382,8 @@ func (g *Gui) modifyLocation(id string, form *tview.Form) {
form.GetFormItemByLabel("Name").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Region").(*tview.InputField).GetText(),
form.GetFormItemByLabel("Country").(*tview.InputField).GetText(),
form.GetFormItemByLabel("SRT").(*tview.Checkbox).IsChecked(),
form.GetFormItemByLabel("Notes").(*tview.InputField).GetText(),
form.GetFormItemByLabel("SRT").(*tview.CheckBox).IsChecked(),
)
if err != nil {
g.warning(err.Error(), `form`, []string{`OK`}, func() {return})
Expand Down
4 changes: 2 additions & 2 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"
"strings"

"github.com/rivo/tview"
"github.com/gdamore/tcell"
tview "gitlab.com/tslocum/cview"
"github.com/gdamore/tcell/v2"

"github.com/idlephysicist/cave-logger/internal/db"
"github.com/idlephysicist/cave-logger/internal/model"
Expand Down
32 changes: 16 additions & 16 deletions internal/gui/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package gui
import (
"fmt"

"github.com/rivo/tview"
"github.com/gdamore/tcell"
tview "gitlab.com/tslocum/cview"
"github.com/gdamore/tcell/v2"

"github.com/idlephysicist/cave-logger/internal/model"
)

var inspectorFormat = map[string]string{
`trips` : "\tDate: %s\n\tCave: %s\n\tCavers: %s\n\tNotes: %s",
`cavers`: "\tName: %s\n\tClub: %s\n\tCount: %d",
`caves` : "\tName: %s\n\tRegion: %s\n\tCountry: %s\n\tSRT: %v\n\tVisits: %d",
`cavers`: "\tName: %s\n\tClub: %s\n\tCount: %d\n\tNotes: %s",
`caves` : "\tName: %s\n\tRegion: %s\n\tCountry: %s\n\tSRT: %s\n\tVisits: %d\n\tNotes: %s",
}

func (g *Gui) displayInspect(data, page string) {
Expand Down Expand Up @@ -51,40 +51,40 @@ func (g *Gui) inspectTrip() {
g.displayInspect(g.formatTrip(trip), "trips")
}

/*func (g *Gui) inspectCave() {
func (g *Gui) inspectCave() {
selected := g.selectedLocation()

cave, err := g.db.GetLocation(selected.ID)
if err != nil {
return
}

g.inspectorPanel().setEntry(g.formatCave(cave))
g.displayInspect(g.formatCave(cave), "caves")
}

func (g *Gui) inspectPerson() {
func (g *Gui) inspectCaver() {
selected := g.selectedPerson()

caver, err := g.db.GetPerson(selected.ID)
if err != nil {
return
}

g.inspectorPanel().setEntry(g.formatPerson(caver))
}*/
g.displayInspect(g.formatPerson(caver), "cavers")
}

//
// Formatting Functions
//
func (g *Gui) formatTrip(trip *model.Log) string {
return fmt.Sprintf(inspectorFormat[`trips`], trip.Date, trip.Cave, trip.Names, trip.Notes)
func (g *Gui) formatTrip(t *model.Log) string {
return fmt.Sprintf(inspectorFormat[`trips`], t.Date, t.Cave, t.Names, t.Notes)
}

/*func (g *Gui) formatCave(l *model.Cave) string {
return fmt.Sprintf(inspectorFormat[`caves`], l.Name, l.Region, l.Country, l.SRT, l.Visits)
func (g *Gui) formatCave(c *model.Cave) string {
return fmt.Sprintf(inspectorFormat[`caves`], c.Name, c.Region, c.Country, yesOrNo(c.SRT), c.Visits, c.Notes)
}

func (g *Gui) formatPerson(p *model.Caver) string {
return fmt.Sprintf(inspectorFormat[`cavers`], p.Name, p.Club, p.Count)
}*/
func (g *Gui) formatPerson(c *model.Caver) string {
return fmt.Sprintf(inspectorFormat[`cavers`], c.Name, c.Club, c.Count, c.Notes)
}

Loading

0 comments on commit cf9f5df

Please sign in to comment.