More work
This commit is contained in:
@@ -421,7 +421,12 @@ func (s *ScreenHome) cliSendStatus(args ...string) bool {
|
||||
}
|
||||
|
||||
func (s *ScreenHome) updatePdsListing() {
|
||||
s.pdsListing.SetTitle(fmt.Sprintf("─ %s (%s)", s.activePds.AtId.String(), s.activePds.Did.String()))
|
||||
isAuth := s.r.Auth.HasAuth(s.activePds.Did)
|
||||
auth := '🔒'
|
||||
if isAuth {
|
||||
auth = '🔓'
|
||||
}
|
||||
s.pdsListing.SetTitle(fmt.Sprintf("%c %s (%s)", auth, s.activePds.AtId.String(), s.activePds.Did.String()))
|
||||
s.pdsListing.Clear()
|
||||
nsidList := s.activePds.NSIDStringList()
|
||||
var tree []*wd.TreeNode
|
||||
@@ -472,6 +477,15 @@ func (s *ScreenHome) selectPdsListingEntry(tn *wd.TreeNode) bool {
|
||||
}
|
||||
|
||||
func (s *ScreenHome) changePdsList(tn *wd.TreeNode) bool {
|
||||
auth := s.r.Auth.HasAuth(s.activePds.Did)
|
||||
if auth {
|
||||
if tn.Depth() == 0 {
|
||||
s.pdsListing.SetHintText("(A)dd New Record")
|
||||
} else {
|
||||
s.pdsListing.SetHintText("(A)dd New Record; (D)elete Record")
|
||||
}
|
||||
}
|
||||
|
||||
upd := s.updateJsonView(tn)
|
||||
upd = s.updateStatusPathBlock(tn)
|
||||
return upd
|
||||
@@ -483,6 +497,7 @@ func (s *ScreenHome) updateStatusPathBlock(tn *wd.TreeNode) bool {
|
||||
|
||||
func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
|
||||
// TODO: Update JSON View
|
||||
auth := s.r.Auth.HasAuth(s.activePds.Did)
|
||||
if tn.Depth() == 0 {
|
||||
nsid, err := syntax.ParseNSID(tn.Value())
|
||||
if err != nil {
|
||||
@@ -491,9 +506,13 @@ func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
|
||||
}
|
||||
recordIds := s.activePds.GetRecordIdsFor(nsid)
|
||||
s.jsonContent.SetValue(recordIds)
|
||||
s.jsonContent.SetEditable(false)
|
||||
// We don't set the jsonContent to editable, but allow creation of
|
||||
// new objects
|
||||
return true
|
||||
} else {
|
||||
s.jsonContent.SetValue(s.activePds.Records[tn.Value()])
|
||||
s.jsonContent.SetEditable(auth)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -593,19 +612,20 @@ func (s *ScreenHome) deleteCurrentRecord() bool {
|
||||
if len(tnPath) != 2 {
|
||||
return false
|
||||
}
|
||||
//tnLabelPath := tn.GetLabelPath()
|
||||
tnLabelPath := tn.GetLabelPath()
|
||||
nsid, err := syntax.ParseNSID(tnPath[0])
|
||||
if err != nil {
|
||||
s.Log("error parsing NSID from %s: %w", tnPath[0], err)
|
||||
return false
|
||||
}
|
||||
rkey := tnPath[1]
|
||||
/*
|
||||
if err := s.r.DeleteRecord(s.activePds.Did, nsid, rkey); err != nil {
|
||||
s.Log("error deleting record: %w", err)
|
||||
}
|
||||
/*
|
||||
*/
|
||||
s.alert.SetTitle("Confirm Deletion")
|
||||
s.alert.SetMessage(fmt.Sprintf("Are you sure you want to delete this record?\n%s %s\nThis cannot be undone.", tnLabelPath[0], tnLabelPath[1]))
|
||||
s.alert.SetMessage(fmt.Sprintf("Are you sure you want to delete this record?\n%s: %s\nThis cannot be undone.", tnLabelPath[0], tnLabelPath[1]))
|
||||
s.alert.SetVisible(true)
|
||||
s.alert.SetActive(true)
|
||||
s.alert.SetOkPressed(func() bool {
|
||||
@@ -619,6 +639,7 @@ func (s *ScreenHome) deleteCurrentRecord() bool {
|
||||
s.alert.SetActive(false)
|
||||
return true
|
||||
})
|
||||
*/
|
||||
s.alert.SetPos(w.Coord{X: s.w / 4, Y: s.h / 4})
|
||||
s.alert.HandleResize(w.Coord{X: s.w / 4, Y: s.h / 4}.ResizeEvent())
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -167,7 +167,10 @@ func (w *JsonContent) Draw(screen tcell.Screen) {
|
||||
|
||||
if w.editable {
|
||||
var key, val string
|
||||
|
||||
pts := strings.Split(txt, ":")
|
||||
if len(pts) == 2 {
|
||||
key, val = pts[0], pts[1]
|
||||
}
|
||||
wh.DrawText(w.x, y, key, st.Dim(dim).Bold(!dim), screen)
|
||||
st = st.Reverse(true)
|
||||
wh.DrawText(w.x, y, val, st.Dim(dim).Bold(!dim), screen)
|
||||
|
||||
@@ -40,6 +40,8 @@ type TreeBrowser struct {
|
||||
searching bool
|
||||
searchStr string
|
||||
|
||||
hintText string
|
||||
|
||||
logger func(string, ...any)
|
||||
|
||||
m sync.Mutex
|
||||
@@ -160,6 +162,13 @@ func (w *TreeBrowser) Draw(screen tcell.Screen) {
|
||||
th.BorderFilled(x, y, x+w.w, y+w.h, w.border, dS, screen)
|
||||
}
|
||||
}
|
||||
if w.hintText != "" {
|
||||
if brdSz == 0 {
|
||||
brdSz = 1
|
||||
}
|
||||
|
||||
wh.DrawText(x+1, y+w.h, w.hintText, dS, screen)
|
||||
}
|
||||
x, y = x+1, y+1
|
||||
h := w.h - brdSz
|
||||
ln := len(w.list)
|
||||
@@ -487,6 +496,9 @@ func (w *TreeBrowser) getCurrentLine() string {
|
||||
return w.list[w.cursor]
|
||||
}
|
||||
|
||||
func (w *TreeBrowser) SetHintText(txt string) { w.hintText = txt }
|
||||
func (w *TreeBrowser) ClearHintText(txt string) { w.hintText = "" }
|
||||
|
||||
/*
|
||||
* Tree Node
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user