summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-10-26 13:25:45 +0200
committerNikolaus Gotsche <n@softwarefools.com>2018-10-26 13:25:45 +0200
commitd06db7af6014e8498672899218a05adf36ab1aa3 (patch)
tree1e960093c848ad166beb4a5125655e53b04066de
parentab0058448abc0f51d0165c0278bdd4878a3f4d13 (diff)
Final Framing and Multichoice beatification
-rw-r--r--config.go13
-rw-r--r--interact.go8
-rw-r--r--sqlite.go15
-rw-r--r--texify.go2
-rw-r--r--utils.go3
5 files changed, 25 insertions, 16 deletions
diff --git a/config.go b/config.go
index 72b56eb..1db87a9 100644
--- a/config.go
+++ b/config.go
@@ -77,9 +77,10 @@ func initConf() {
func makeNewTOML(gibts bool) {
if gibts {
- fmt.Println("Editing Configuration File\nPress [Enter] to keep the Current setting")
+ fmt.Println(frame("Editing Configuration File",true))
+ fmt.Println(nli,"Press [Enter] to keep the Current setting")
} else {
- fmt.Println("\nMaking new Configuration File")
+ fmt.Println(frame("Making new Configuration File",true))
//Examplenames Coming soon
n := ""
file, err := homedir.Expand("~/.mywork.db")
@@ -112,7 +113,7 @@ func makeNewTOML(gibts bool) {
panic(err)
} else {
//fmt.Println("Conffile:\n",buf.String())
- fmt.Println("\nWriting Configuration File")
+ fmt.Println(frame("Writing Configuration File",false))
err = ioutil.WriteFile(conffile, buf.Bytes(), 0644)
checkErr(err)
}
@@ -123,10 +124,12 @@ func makeNewTOML(gibts bool) {
func showConfig() {
buf := new(bytes.Buffer)
err := toml.NewEncoder(buf).Encode(config)
+ bufarr := String2StringArray(buf.String(),"\n")
if err != nil {
panic(err)
} else {
- fmt.Println("Configuration:\n", buf.String())
- //fmt.Println(config)
+ fmt.Println(frame("Configuration:",true))
+ fmt.Println(StrLines(bufarr,nli))
+ fmt.Println(frame("",false))
}
}
diff --git a/interact.go b/interact.go
index f61b398..06892ed 100644
--- a/interact.go
+++ b/interact.go
@@ -213,7 +213,7 @@ func interact(fulldb bool) {
}
} else {
tids := getTaskIds()
- selids, lids := getTaskList(tids, false)
+ selids, lids := GetTaskList(tids, false,false)
choice := c.MultiChoice(lids, "Select a Task to Edit")
if choice > -1 {
deleteTask(selids[choice])
@@ -275,7 +275,7 @@ func interact(fulldb bool) {
}
} else {
tids := getTaskIds()
- selids, lids := getTaskList(tids, false)
+ selids, lids := GetTaskList(tids, false,false)
choice := c.MultiChoice(lids, "Select a Task to Edit")
//c.Println(tids)
//c.Println(selids)
@@ -544,7 +544,7 @@ func interact(fulldb bool) {
bill can be deleted and a new selection made.`,
Func: func(c *ishell.Context) {
nix := []int{0}
- ids, str := getTaskList(nix, true)
+ ids, str := GetTaskList(nix, true,true)
choices := c.Checklist(str,
"Which Tasks should be charged in the new bill ?",
nil)
@@ -624,7 +624,7 @@ func interact(fulldb bool) {
resttasks := GetSelectedTasks(restids)
rcount, rhours, _ := AnalyzeTasks(resttasks)
- rids, rstr := getTaskList(restids, false)
+ rids, rstr := GetTaskList(restids, false,false)
qu := "Select Tasks to Group as Billitem"
restinfo = fmt.Sprintf("%v Tasks Left, Total %.2f(h)\n%s", rcount, rhours, qu)
pre := fmt.Sprintf("%s%s%s", fullbillinfo, sep, restinfo)
diff --git a/sqlite.go b/sqlite.go
index 5c082fe..68ce3f1 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -286,7 +286,7 @@ func newTask(resume bool) {
task = getInterInput(sli+"Specify Task: ")
if task == "" {
nm,st := GetTaskSums(currproject.id)
- ch := Multichoice("What Task should be resumed?",st)
+ ch := Multichoice("What Task should be restarted?",st)
task = nm[ch]
bonus = line("xxx",true)
}
@@ -406,8 +406,8 @@ func loadBills(in []int) (out []bill) {
}
func strings2items(tasks, times, hours, moneys string) (out []billitem) {
- ta := string2StringArray(tasks, ";")
- ti := string2StringArray(times, ";")
+ ta := String2StringArray(tasks, ";")
+ ti := String2StringArray(times, ";")
ho := string2FloatArray(hours, ";")
mo := string2FloatArray(moneys, ";")
for i, _ := range ta {
@@ -794,8 +794,10 @@ func getProjectList(in []int) ([]int, []string) {
}
return outids, outstr
}
-
-func getTaskList(in []int, showcust bool) ([]int, []string) {
+// Returns two Lists of Task ids and corresponding strings for Multichoice selection.
+// Depending on showcust the name of the customer will be displayed too
+// Depending on exclude Tasks of project 0 will be in the Return Lists
+func GetTaskList(in []int, showcust,exclude bool) ([]int, []string) {
var outids []int
var outstr []string
lastpr := 0
@@ -809,6 +811,9 @@ func getTaskList(in []int, showcust bool) ([]int, []string) {
//rows,err := db.Query("SELECT id, project, start, stop, task FROM timetable WHERE stop != '1791-09-30 19:07' AND checkout = 0 AND id IN ? ORDER BY project DESC, stop DESC",in)
if len(in) == 1 && in[0] == 0 {
rows, err = db.Query("SELECT id, project, start, stop, task FROM timetable WHERE stop != '1791-09-30 19:07' AND checkout = 0 ORDER BY project DESC, stop DESC")
+ if exclude {
+ rows, err = db.Query("SELECT id, project, start, stop, task FROM timetable WHERE stop != '1791-09-30 19:07' AND checkout = 0 AND project != 0 ORDER BY project DESC, stop DESC")
+ }
} //else{
// rows,err = db.Query("SELECT id, project, start, stop, task FROM timetable WHERE stop != '1791-09-30 19:07' AND checkout = 0 AND id IN ? ORDER BY project DESC, stop DESC",in)
//}
diff --git a/texify.go b/texify.go
index 358047a..ffa0fba 100644
--- a/texify.go
+++ b/texify.go
@@ -55,7 +55,7 @@ type Data struct {
func billTemplate(billdata bill, cust customer) Filenames {
billid := billdata.id
custr, cuzip, cucity, cucou := "", "", "", ""
- addr := string2StringArray(cust.address, ";")
+ addr := String2StringArray(cust.address, ";")
for i, a := range addr {
switch i {
case 0:
diff --git a/utils.go b/utils.go
index ec0802b..03ef940 100644
--- a/utils.go
+++ b/utils.go
@@ -220,7 +220,8 @@ func string2FloatArray(in string, delim string) (out []float64) {
return
}
-func string2StringArray(in string, delim string) (out []string) {
+// Takes a String and Cuts it into []string elements by delim
+func String2StringArray(in string, delim string) (out []string) {
read := strings.Split(in, delim)
for _, s := range read {
out = append(out, s)