From ffa59739b609ce00ce21344531f27d4003dfc688 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 29 Mar 2014 10:24:42 -0400 Subject: [PATCH] Add edit issue --- models/issue.go | 35 ++++++++++++++++++----------------- routers/repo/issue.go | 10 +++++++--- templates/issue/view.tmpl | 14 +++++++------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/models/issue.go b/models/issue.go index 39558ae225..9fd1b905a5 100644 --- a/models/issue.go +++ b/models/issue.go @@ -18,23 +18,24 @@ var ( // Issue represents an issue or pull request of repository. type Issue struct { - Id int64 - Index int64 // Index in one repository. - Name string - RepoId int64 `xorm:"index"` - Repo *Repository `xorm:"-"` - PosterId int64 - Poster *User `xorm:"-"` - MilestoneId int64 - AssigneeId int64 - IsPull bool // Indicates whether is a pull request or not. - IsClosed bool - Labels string `xorm:"TEXT"` - Mentions string `xorm:"TEXT"` - Content string `xorm:"TEXT"` - NumComments int - Created time.Time `xorm:"created"` - Updated time.Time `xorm:"updated"` + Id int64 + Index int64 // Index in one repository. + Name string + RepoId int64 `xorm:"index"` + Repo *Repository `xorm:"-"` + PosterId int64 + Poster *User `xorm:"-"` + MilestoneId int64 + AssigneeId int64 + IsPull bool // Indicates whether is a pull request or not. + IsClosed bool + Labels string `xorm:"TEXT"` + Mentions string `xorm:"TEXT"` + Content string `xorm:"TEXT"` + RenderedContent string `xorm:"-"` + NumComments int + Created time.Time `xorm:"created"` + Updated time.Time `xorm:"updated"` } // CreateIssue creates new issue for repository. diff --git a/routers/repo/issue.go b/routers/repo/issue.go index c89c8b5685..b38967f717 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -152,7 +152,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) { return } issue.Poster = u - issue.Content = string(base.RenderMarkdown([]byte(issue.Content), "")) + issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), "")) // Get comments. comments, err := models.GetIssueComments(issue.Id) @@ -216,8 +216,12 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat return } - ctx.Data["Title"] = issue.Name - ctx.Data["Issue"] = issue + ctx.JSON(200, map[string]interface{}{ + "ok": true, + "title": issue.Name, + "content": string(base.RenderMarkdown([]byte(issue.Content), "")), + "raw_content": issue.Content, + }) } func Comment(ctx *middleware.Context, params martini.Params) { diff --git a/templates/issue/view.tmpl b/templates/issue/view.tmpl index c357f5354c..c6f1444e46 100644 --- a/templates/issue/view.tmpl +++ b/templates/issue/view.tmpl @@ -4,17 +4,17 @@ {{template "repo/toolbar" .}}
-
+
#{{.Issue.Index}}

{{.Issue.Name}}

- - + +

Edit - + {{if .Issue.IsClosed}}Closed{{else}}Open{{end}} {{.Issue.Poster.Name}} opened this issue {{TimeSince .Issue.Created}} ยท {{.Issue.NumComments}} comments @@ -24,13 +24,13 @@

- {{str2html .Issue.Content}} + {{str2html .Issue.RenderedContent}}
- +
{{range .Comments}} -
+