Add edit issue
This commit is contained in:
parent
2c073afbec
commit
ffa59739b6
|
@ -18,23 +18,24 @@ var (
|
||||||
|
|
||||||
// Issue represents an issue or pull request of repository.
|
// Issue represents an issue or pull request of repository.
|
||||||
type Issue struct {
|
type Issue struct {
|
||||||
Id int64
|
Id int64
|
||||||
Index int64 // Index in one repository.
|
Index int64 // Index in one repository.
|
||||||
Name string
|
Name string
|
||||||
RepoId int64 `xorm:"index"`
|
RepoId int64 `xorm:"index"`
|
||||||
Repo *Repository `xorm:"-"`
|
Repo *Repository `xorm:"-"`
|
||||||
PosterId int64
|
PosterId int64
|
||||||
Poster *User `xorm:"-"`
|
Poster *User `xorm:"-"`
|
||||||
MilestoneId int64
|
MilestoneId int64
|
||||||
AssigneeId int64
|
AssigneeId int64
|
||||||
IsPull bool // Indicates whether is a pull request or not.
|
IsPull bool // Indicates whether is a pull request or not.
|
||||||
IsClosed bool
|
IsClosed bool
|
||||||
Labels string `xorm:"TEXT"`
|
Labels string `xorm:"TEXT"`
|
||||||
Mentions string `xorm:"TEXT"`
|
Mentions string `xorm:"TEXT"`
|
||||||
Content string `xorm:"TEXT"`
|
Content string `xorm:"TEXT"`
|
||||||
NumComments int
|
RenderedContent string `xorm:"-"`
|
||||||
Created time.Time `xorm:"created"`
|
NumComments int
|
||||||
Updated time.Time `xorm:"updated"`
|
Created time.Time `xorm:"created"`
|
||||||
|
Updated time.Time `xorm:"updated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssue creates new issue for repository.
|
// CreateIssue creates new issue for repository.
|
||||||
|
|
|
@ -152,7 +152,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
issue.Poster = u
|
issue.Poster = u
|
||||||
issue.Content = string(base.RenderMarkdown([]byte(issue.Content), ""))
|
issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), ""))
|
||||||
|
|
||||||
// Get comments.
|
// Get comments.
|
||||||
comments, err := models.GetIssueComments(issue.Id)
|
comments, err := models.GetIssueComments(issue.Id)
|
||||||
|
@ -216,8 +216,12 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Title"] = issue.Name
|
ctx.JSON(200, map[string]interface{}{
|
||||||
ctx.Data["Issue"] = issue
|
"ok": true,
|
||||||
|
"title": issue.Name,
|
||||||
|
"content": string(base.RenderMarkdown([]byte(issue.Content), "")),
|
||||||
|
"raw_content": issue.Content,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Comment(ctx *middleware.Context, params martini.Params) {
|
func Comment(ctx *middleware.Context, params martini.Params) {
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
{{template "repo/toolbar" .}}
|
{{template "repo/toolbar" .}}
|
||||||
<div id="body" class="container">
|
<div id="body" class="container">
|
||||||
<div id="issue">
|
<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="issue-head clearfix">
|
||||||
<div class="number pull-right">#{{.Issue.Index}}</div>
|
<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>
|
<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>
|
<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 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"/>
|
<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">
|
<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-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-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>
|
<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
|
<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
|
<span class="time">{{TimeSince .Issue.Created}}</span> · {{.Issue.NumComments}} comments
|
||||||
|
@ -24,13 +24,13 @@
|
||||||
<div class="panel panel-default issue-content">
|
<div class="panel panel-default issue-content">
|
||||||
<div class="panel-body markdown">
|
<div class="panel-body markdown">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{str2html .Issue.Content}}
|
{{str2html .Issue.RenderedContent}}
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
{{range .Comments}}
|
{{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>
|
<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="issue-content panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
|
Loading…
Reference in New Issue