Esempio n. 1
0
func NewBug(p chan string, btype έντομο.Type) gui.Widget {
	attrs := append([]string{"title"}, bug.ListAttributes()...)
	fields := []gui.Widget{}
	b := btype.Create()
	for _, attr := range attrs {
		fields = append(fields, gui.Row(gui.Text(attr+":"), AttributeChooser(b, attr, WriteLater)))
	}
	maintext := gui.TextArea("")
	fields = append(fields, gui.Text("Comment:"))
	fields = append(fields, maintext)
	submit := gui.Button("Submit bug")
	go func() {
		mainstr := ""
		for {
			select {
			case mainstr = <-maintext.Changes():
				// Nothing to do...
			case _ = <-submit.Clicks():
				b.ScheduleChange(mainstr)
				b.FlushPending()
				p <- "/"
				return
			}
		}
	}()
	fields = append(fields, submit)
	return gui.Column(fields...)
}
Esempio n. 2
0
func BugPage(p chan string, btype έντομο.Type, bnum int) gui.Widget {
	bl, err := btype.List()
	if err != nil {
		return gui.Text("Error: " + err.String())
	}
	if bnum >= len(bl) {
		return gui.Text(fmt.Sprint("Error: no such ", btype, " as number ", bnum))
	}
	b := bl[bnum]
	cs, err := b.Comments()
	if err != nil {
		return gui.Text("Error: " + err.String())
	}
	attrs := []gui.Widget{}
	for attr := range b.Attributes {
		attrs = append(attrs, gui.Row(gui.Text(attr+":"), AttributeChooser(b, attr, WriteNow)))
	}
	newcomment := gui.TextArea("")
	attrs = append(attrs, gui.Text("New comment:"))
	attrs = append(attrs, newcomment)
	submit := gui.Button("Add comment")
	attrs = append(attrs, submit)
	go func() {
		commentstr := ""
		for {
			select {
			case commentstr = <-newcomment.Changes():
				fmt.Println("Got nice comment:", commentstr)
				// Nothing to do...
			case _ = <-submit.Clicks():
				fmt.Println("Got add comment pushed.")
				b.AddComment(commentstr)
				p <- "/" + string(btype) + "-" + fmt.Sprint(bnum)
				return
			}
		}
	}()
	var bugs []gui.Widget
	for _, c := range cs {
		if len(c.Text) > 0 {
			bugs = append(bugs, gui.Row(gui.Text(c.Author), gui.Text(c.Date)),
				gui.Markdown(c.Text))
		}
	}
	return gui.Column(append(attrs, gui.Table(transpose(bugs)))...)
}