|
|
@@ -476,6 +476,54 @@ func (e edit) update(msg tea.Msg) (widget, tea.Cmd) {
|
|
|
return e, tea.Batch(cmds...)
|
|
|
}
|
|
|
|
|
|
+// render cmd for create widget
|
|
|
+func (e edit) render() tea.Msg {
|
|
|
+ if e.err != nil {
|
|
|
+ return fmt.Sprintf("failed to create issue... %s", e.err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ borderStyle := lipgloss.NewStyle().
|
|
|
+ BorderForeground(lipgloss.Color("8")).
|
|
|
+ BorderStyle(lipgloss.NormalBorder()).
|
|
|
+ Margin(1).
|
|
|
+ Padding(0, 1)
|
|
|
+
|
|
|
+ ulStyle := lipgloss.NewStyle().Underline(true)
|
|
|
+
|
|
|
+ var output string
|
|
|
+ for _, field := range e.inputFields {
|
|
|
+ output = output + fmt.Sprintf(
|
|
|
+ "\n%s:%s",
|
|
|
+ field.title,
|
|
|
+ borderStyle.Render(field.input.View()),
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ output = strings.TrimLeft(output, "\n")
|
|
|
+
|
|
|
+ if e.selected < len(e.inputFields) {
|
|
|
+ output = output + borderStyle.Render("press enter to submit...")
|
|
|
+ } else if e.selected == len(e.inputFields) {
|
|
|
+ output = output + borderStyle.Render(ulStyle.Render("press enter to submit..."))
|
|
|
+ } else if e.selected == len(e.inputFields)+1 {
|
|
|
+ confirmPrompt := fmt.Sprintf(
|
|
|
+ "create issue titled \"%s\"?\n\n%s",
|
|
|
+ ulStyle.Render(e.inputFields[0].input.Value()),
|
|
|
+ ulStyle.Render("press enter to write description..."),
|
|
|
+ )
|
|
|
+ output = output + borderStyle.Render(confirmPrompt)
|
|
|
+ }
|
|
|
+
|
|
|
+ return output
|
|
|
+}
|
|
|
+
|
|
|
+// keyhelp cmd for create widget
|
|
|
+func (e edit) keyhelp() string {
|
|
|
+ var output string
|
|
|
+ output = output + "tab/shift+tab: down/up\t\tenter: input value\n\nesc: reset\t\tctrl+c: quit"
|
|
|
+ return output
|
|
|
+}
|
|
|
+
|
|
|
// A tea.Cmd to translate createIssueObject.inputs to a new Issue object
|
|
|
func (e edit) createIssueObject() tea.Msg {
|
|
|
data := make(map[string]string)
|
|
|
@@ -533,6 +581,17 @@ func (e edit) createIssueObject() tea.Msg {
|
|
|
// Wraps a tea.Cmd function, passes an initialized Issue to WriteIssue()
|
|
|
func (e edit) write(issue Issue) tea.Cmd {
|
|
|
return func() tea.Msg {
|
|
|
+ if e.existing {
|
|
|
+ err := issue.Tags.CleanDisk(issue, false)
|
|
|
+ if err != nil {
|
|
|
+ return writeResult(err)
|
|
|
+ }
|
|
|
+ err = issue.Blockedby.CleanDisk(issue, false)
|
|
|
+ if err != nil {
|
|
|
+ return writeResult(err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
result, err := WriteIssue(issue, true)
|
|
|
if err != nil {
|
|
|
return writeResult(err)
|
|
|
@@ -577,54 +636,6 @@ func (e edit) editExistingDescription(issue Issue) tea.Cmd {
|
|
|
return func() tea.Msg { return editorResult{issue: issue, err: err} }
|
|
|
}
|
|
|
|
|
|
-// render cmd for create widget
|
|
|
-func (e edit) render() tea.Msg {
|
|
|
- if e.err != nil {
|
|
|
- return fmt.Sprintf("failed to create issue... %s", e.err.Error())
|
|
|
- }
|
|
|
-
|
|
|
- borderStyle := lipgloss.NewStyle().
|
|
|
- BorderForeground(lipgloss.Color("8")).
|
|
|
- BorderStyle(lipgloss.NormalBorder()).
|
|
|
- Margin(1).
|
|
|
- Padding(0, 1)
|
|
|
-
|
|
|
- ulStyle := lipgloss.NewStyle().Underline(true)
|
|
|
-
|
|
|
- var output string
|
|
|
- for _, field := range e.inputFields {
|
|
|
- output = output + fmt.Sprintf(
|
|
|
- "\n%s:%s",
|
|
|
- field.title,
|
|
|
- borderStyle.Render(field.input.View()),
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- output = strings.TrimLeft(output, "\n")
|
|
|
-
|
|
|
- if e.selected < len(e.inputFields) {
|
|
|
- output = output + borderStyle.Render("press enter to submit...")
|
|
|
- } else if e.selected == len(e.inputFields) {
|
|
|
- output = output + borderStyle.Render(ulStyle.Render("press enter to submit..."))
|
|
|
- } else if e.selected == len(e.inputFields)+1 {
|
|
|
- confirmPrompt := fmt.Sprintf(
|
|
|
- "create issue titled \"%s\"?\n\n%s",
|
|
|
- ulStyle.Render(e.inputFields[0].input.Value()),
|
|
|
- ulStyle.Render("press enter to write description..."),
|
|
|
- )
|
|
|
- output = output + borderStyle.Render(confirmPrompt)
|
|
|
- }
|
|
|
-
|
|
|
- return output
|
|
|
-}
|
|
|
-
|
|
|
-// keyhelp cmd for create widget
|
|
|
-func (e edit) keyhelp() string {
|
|
|
- var output string
|
|
|
- output = output + "tab/shift+tab: down/up\t\tenter: input value\n\nesc: reset\t\tctrl+c: quit"
|
|
|
- return output
|
|
|
-}
|
|
|
-
|
|
|
// -------- Issue widget definitions ------------------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
@@ -645,17 +656,6 @@ func (i Issue) update(msg tea.Msg) (widget, tea.Cmd) {
|
|
|
return i, tea.Batch(cmds...)
|
|
|
}
|
|
|
|
|
|
-func (i Issue) edit() tea.Msg { return newEditWidget(i.Path) }
|
|
|
-
|
|
|
-func (i Issue) back() tea.Msg {
|
|
|
- remainder, _ := filepath.Split(i.Path)
|
|
|
- remainder = strings.TrimRight(remainder, "/")
|
|
|
- if len(remainder) == 0 {
|
|
|
- return nil
|
|
|
- }
|
|
|
- return loadPath(remainder)
|
|
|
-}
|
|
|
-
|
|
|
// render cmd for Issue widget
|
|
|
func (i Issue) render() tea.Msg {
|
|
|
var output string
|
|
|
@@ -688,7 +688,7 @@ func (i Issue) render() tea.Msg {
|
|
|
var blockersString string // placeholder for variadic styling
|
|
|
if len(i.Blockedby.Fields) > 0 {
|
|
|
blockersString = blockersString + "\nBlockedby:\n"
|
|
|
- blockersString = blockersString + variadicDataStyle.Render(fmt.Sprintf("%s", blockedby))
|
|
|
+ blockersString = blockersString + variadicDataStyle.Render("%s", blockedby)
|
|
|
blockersString = variadicMarginStyle.Render(blockersString)
|
|
|
}
|
|
|
output = output + blockersString
|
|
|
@@ -712,6 +712,17 @@ func (i Issue) keyhelp() string {
|
|
|
return output
|
|
|
}
|
|
|
|
|
|
+func (i Issue) edit() tea.Msg { return newEditWidget(i.Path) }
|
|
|
+
|
|
|
+func (i Issue) back() tea.Msg {
|
|
|
+ remainder, _ := filepath.Split(i.Path)
|
|
|
+ remainder = strings.TrimRight(remainder, "/")
|
|
|
+ if len(remainder) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return loadPath(remainder)
|
|
|
+}
|
|
|
+
|
|
|
// -------- IssueCollection widget definitions --------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
@@ -756,10 +767,6 @@ func (ic IssueCollection) update(msg tea.Msg) (widget, tea.Cmd) {
|
|
|
return ic, nil
|
|
|
}
|
|
|
|
|
|
-func (ic IssueCollection) sendLoad() tea.Msg { return loadPath(ic.Path) }
|
|
|
-
|
|
|
-func (ic IssueCollection) edit() tea.Msg { return newEditWidget(ic.Path) }
|
|
|
-
|
|
|
// render cmd for IssueCollection widget
|
|
|
func (ic IssueCollection) render() tea.Msg {
|
|
|
var output string
|
|
|
@@ -794,6 +801,10 @@ func (ic IssueCollection) keyhelp() string {
|
|
|
return output
|
|
|
}
|
|
|
|
|
|
+func (ic IssueCollection) sendLoad() tea.Msg { return loadPath(ic.Path) }
|
|
|
+
|
|
|
+func (ic IssueCollection) edit() tea.Msg { return newEditWidget(ic.Path) }
|
|
|
+
|
|
|
// -------- setTitle widget definitions ---------------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
@@ -821,11 +832,6 @@ func (w setTitle) update(msg tea.Msg) (widget, tea.Cmd) {
|
|
|
return w, tea.Batch(cmds...)
|
|
|
}
|
|
|
|
|
|
-func (w setTitle) create() tea.Msg {
|
|
|
- w.Path = filepath.Join(w.Path, parseHumanToPath(w.name))
|
|
|
- return newEditWidget(w.Path)
|
|
|
-}
|
|
|
-
|
|
|
func (w setTitle) render() tea.Msg {
|
|
|
var header string
|
|
|
if len(w.Path) == 0 {
|
|
|
@@ -838,6 +844,11 @@ func (w setTitle) render() tea.Msg {
|
|
|
|
|
|
func (w setTitle) keyhelp() string { return "enter: submit" }
|
|
|
|
|
|
+func (w setTitle) create() tea.Msg {
|
|
|
+ w.Path = filepath.Join(w.Path, parseHumanToPath(w.name))
|
|
|
+ return newEditWidget(w.Path)
|
|
|
+}
|
|
|
+
|
|
|
// -------- confirmDelete widget definitions ----------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|