]> source.dussan.org Git - gitea.git/commitdiff
Add edit issue
authorUnknown <joe2010xtmf@163.com>
Sat, 29 Mar 2014 14:24:42 +0000 (10:24 -0400)
committerUnknown <joe2010xtmf@163.com>
Sat, 29 Mar 2014 14:24:42 +0000 (10:24 -0400)
models/issue.go
routers/repo/issue.go
templates/issue/view.tmpl

index 39558ae2250a6f5a02acd7560e069b64f9afe678..9fd1b905a5852000fb8e78174563bac9419368c7 100644 (file)
@@ -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.
index c89c8b5685938e4950689b6c6097d18de7001565..b38967f717e3eb9af29bdf192f4ed1b5313635d9 100644 (file)
@@ -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) {
index c357f5354ca7d318e8fc112fcec92256c4555470..c6f1444e46362ec411c067f7cf1850214406354f 100644 (file)
@@ -4,17 +4,17 @@
 {{template "repo/toolbar" .}}
 <div id="body" class="container">
     <div id="issue">
-        <div id="issue-{issue.id}" class="issue-whole issue-is-opening">
+        <div id="issue-{{.Issue.Id}}" class="issue-whole issue-is-opening">
             <div class="issue-head clearfix">
                 <div class="number pull-right">#{{.Issue.Index}}</div>
                 <a class="author pull-left" href="/user/{{.Issue.Poster.Name}}"><img class="avatar" src="{{.Issue.Poster.AvatarLink}}" alt="" width="30"/></a>
                 <h1 class="title pull-left">{{.Issue.Name}}</h1>
-                <input id="issue-edit-title" class="form-control input-lg pull-left hidden" type="text" value="{issue.title}" data-ajax-rel="issue-edit-save" data-ajax-val="val" data-ajax-field="title"/>
-                <input type="hidden" value="{issue.id}" data-ajax-rel="issue-edit-save" data-ajax-val="val" data-ajax-field="issue_id"/>
+                <input id="issue-edit-title" class="form-control input-lg pull-left hidden" type="text" value="{{.Issue.Name}}" data-ajax-rel="issue-edit-save" data-ajax-val="val" data-ajax-field="title"/>
+                <input type="hidden" value="{{.Issue.Id}}" data-ajax-rel="issue-edit-save" data-ajax-val="val" data-ajax-field="issue_id"/>
                 <p class="info pull-left">
                     <a class="btn btn-default pull-right issue-edit" href="#" id="issue-edit-btn">Edit</a>
                     <a class="btn btn-danger pull-right issue-edit-cancel hidden" href="#">Cancel</a>
-                    <a class="btn btn-primary pull-right issue-edit-save hidden" href="#" data-ajax="{issue.edit.save.link}" data-ajax-name="issue-edit-save" data-ajax-method="post">Save</a>
+                    <a class="btn btn-primary pull-right issue-edit-save hidden" href="#" data-ajax="/{{.RepositoryLink}}/issues/{{.Issue.Index}}" data-ajax-name="issue-edit-save" data-ajax-method="post">Save</a>
                     <span class="status label label-{{if .Issue.IsClosed}}danger{{else}}success{{end}}">{{if .Issue.IsClosed}}Closed{{else}}Open{{end}}</span>
                     <a href="/user/{{.Issue.Poster.Name}}" class="author"><strong>{{.Issue.Poster.Name}}</strong></a> opened this issue
                     <span class="time">{{TimeSince .Issue.Created}}</span> ยท {{.Issue.NumComments}} comments
                <div class="panel panel-default issue-content">
                    <div class="panel-body markdown">
                        <div class="content">
-                           {{str2html .Issue.Content}}
+                           {{str2html .Issue.RenderedContent}}
                        </div>
-                       <textarea class="form-control hidden" name="content" id="issue-edit-content" rows="10" data-ajax-rel="issue-edit-save" data-ajax-val="val" data-ajax-field="content">{issue.content}</textarea>
+                       <textarea class="form-control hidden" name="content" id="issue-edit-content" rows="10" data-ajax-rel="issue-edit-save" data-ajax-val="val" data-ajax-field="content">{{.Issue.Content}}</textarea>
                    </div>
                </div>
                {{range .Comments}}
-               <div class="issue-child" id="issue-comment-{issue.comment.id}">
+               <div class="issue-child" id="issue-comment-{{.Id}}">
                    <a class="user pull-left" href="/user/{{.Poster.Name}}"><img class="avatar" src="{{.Poster.AvatarLink}}" alt=""/></a>
                    <div class="issue-content panel panel-default">
                        <div class="panel-heading">