add comment form UI

This commit is contained in:
Unknwon 2015-08-12 18:44:09 +08:00
parent b4c0b7b98b
commit ab2d0b3b44
9 changed files with 96 additions and 48 deletions

View file

@ -406,6 +406,10 @@ issues.open_title = Open
issues.closed_title = Closed
issues.num_comments = %d comments
issues.commented_at = commented at <a href="%s">%s</a>
issues.no_content = There is no content if this issue.
issues.close_issue = Close
issues.close_comment_issue = Close and comment
issues.create_comment = Comment
issues.label_title = Label name
issues.label_color = Label color
issues.label_count = %d labels

View file

@ -160,12 +160,9 @@ func (i *Issue) GetAssignee() (err error) {
return err
}
func (i *Issue) AfterDelete() {
_, err := DeleteAttachmentsByIssue(i.ID, true)
if err != nil {
log.Info("Could not delete files for issue #%d: %s", i.ID, err)
}
// ReadBy sets issue to be read by given user.
func (i *Issue) ReadBy(uid int64) error {
return UpdateIssueUserByRead(uid, i.ID)
}
// CreateIssue creates new issue with labels for repository.
@ -625,10 +622,9 @@ func UpdateIssueUserByAssignee(issueID, assigneeID int64) (err error) {
return sess.Commit()
}
// UpdateIssueUserPairByRead updates issue-user pair for reading.
func UpdateIssueUserPairByRead(uid, iid int64) error {
rawSql := "UPDATE `issue_user` SET is_read = ? WHERE uid = ? AND issue_id = ?"
_, err := x.Exec(rawSql, true, uid, iid)
// UpdateIssueUserByRead updates issue-user relation for reading.
func UpdateIssueUserByRead(uid, issueID int64) error {
_, err := x.Exec("UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID)
return err
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -121,9 +121,11 @@
@comment-avatar-width: 3em;
&.new.issue {
.comment.form {
.comment .avatar {
.comment {
.avatar {
width: @comment-avatar-width;
}
}
.content {
margin-left: 4em;
.markdown {
@ -137,6 +139,7 @@
overflow-x: auto;
}
}
}
}
&.view.issue {
@ -187,25 +190,19 @@
.markdown {
font-size: 14px;
}
.bottom.segment {
.no-content {
color: #767676;
font-style: italic;
}
> .bottom.segment {
background: #f3f4f5;
.ui.image {
max-height: 150px;
}
}
}
}
}
.ui.segment.metas {
margin-top: -3px;
}
}
.comment.form {
.ui.comments {
margin-top: -12px;
max-width: 750px!important;
}
.content {
.ui.form {
.field:first-child {
clear: none;
}
@ -218,13 +215,28 @@
height: 200px;
}
}
.dropzone {
width: 100%;
margin-bottom: 10px;
border: 2px dashed #0087F7;
box-shadow: none;
.dz-error-message {
top: 140px;
}
}
.ui.segment.metas {
margin-top: -3px;
}
}
.comment.form {
.ui.comments {
margin-top: -12px;
max-width: 100%;
}
.content {
.field:first-child {
clear: none;
}
.tab.segment {
border: none;
padding: 0;
padding-top: 10px;
}
textarea {
height: 200px;
}
}
}
@ -352,6 +364,18 @@
}
}
.ui.comments {
.dropzone {
width: 100%;
margin-bottom: 10px;
border: 2px dashed #0087F7;
box-shadow: none!important;
.dz-error-message {
top: 140px;
}
}
}
.settings .key.list {
.item:not(:first-child) {
border-top: 1px solid #eaeaea;

View file

@ -441,11 +441,11 @@ func ViewIssue(ctx *middleware.Context) {
}
if ctx.IsSigned {
// // Update issue-user.
// if err = models.UpdateIssueUserPairByRead(ctx.User.Id, issue.ID); err != nil {
// ctx.Handle(500, "UpdateIssueUserPairByRead: %v", err)
// return
// }
// Update issue-user.
if err = issue.ReadBy(ctx.User.Id); err != nil {
ctx.Handle(500, "ReadBy: %v", err)
return
}
if ctx.User.IsAdmin {
// labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID)

View file

@ -0,0 +1,16 @@
<div class="field">
<div class="ui top attached tabular menu">
<a class="active item" data-tab="write">{{.i18n.Tr "repo.release.write"}}</a>
<a class="item" data-tab="preview" data-url="/api/v1/markdown" data-context="{{.RepoLink}}">{{.i18n.Tr "repo.release.preview"}}</a>
</div>
<div class="ui bottom attached active tab segment" data-tab="write">
<textarea name="content"></textarea>
</div>
<div class="ui bottom attached tab segment markdown" data-tab="preview">
{{.i18n.Tr "repo.release.loading"}}
</div>
</div>
{{if .IsAttachmentEnabled}}
<div class="attachments"></div>
<div class="ui basic button dropzone" id="dropzone" data-upload-url="/issues/attachments" data-accepts="{{.AttachmentAllowedTypes}}" data-max-file="{{.AttachmentMaxFiles}}" data-max-size="2" data-default-message="{{.i18n.Tr "dropzone.default_message"}}" data-invalid-input-type="{{.i18n.Tr "dropzone.invalid_input_type"}}" data-file-too-big="{{.i18n.Tr "dropzone.file_too_big"}}" data-remove-file="{{.i18n.Tr "dropzone.remove_file"}}"></div>
{{end}}

View file

@ -15,22 +15,7 @@
<div class="field">
<input name="title" placeholder="{{.i18n.Tr "repo.milestones.title"}}" value="{{.title}}" autofocus required>
</div>
<div class="field">
<div class="ui top attached tabular menu">
<a class="active item" data-tab="write">{{.i18n.Tr "repo.release.write"}}</a>
<a class="item" data-tab="preview" data-url="/api/v1/markdown" data-context="{{.RepoLink}}">{{.i18n.Tr "repo.release.preview"}}</a>
</div>
<div class="ui bottom attached active tab segment" data-tab="write">
<textarea name="content"></textarea>
</div>
<div class="ui bottom attached tab segment markdown" data-tab="preview">
{{.i18n.Tr "repo.release.loading"}}
</div>
</div>
{{if .IsAttachmentEnabled}}
<div class="attachments"></div>
<div class="ui basic button dropzone" id="dropzone" data-upload-url="/issues/attachments" data-accepts="{{.AttachmentAllowedTypes}}" data-max-file="{{.AttachmentMaxFiles}}" data-max-size="2" data-default-message="{{.i18n.Tr "dropzone.default_message"}}" data-invalid-input-type="{{.i18n.Tr "dropzone.invalid_input_type"}}" data-file-too-big="{{.i18n.Tr "dropzone.file_too_big"}}" data-remove-file="{{.i18n.Tr "dropzone.remove_file"}}"></div>
{{end}}
{{template "repo/issue/comment_tab" .}}
<div class="text right">
<button class="ui green button">
{{.i18n.Tr "repo.issues.create"}}

View file

@ -32,19 +32,42 @@
</div>
</div>
<div class="ui attached segment markdown">
{{if .Issue.RenderedContent}}
{{.Issue.RenderedContent|Str2html}}
{{else}}
<span class="no-content">{{.i18n.Tr "repo.issues.no_content"}}</span>
{{end}}
</div>
{{if .Issue.Attachments}}
<div class="ui bottom attached segment">
<div class="ui small images">
{{range .Issue.Attachments}}
<a href="/attachments/{{.UUID}}"><img class="ui image" src="/attachments/{{.UUID}}"></a>
<a target="_blank" href="/attachments/{{.UUID}}"><img class="ui image" src="/attachments/{{.UUID}}"></a>
{{end}}
</div>
</div>
{{end}}
</div>
</div>
<div class="comment form">
<a class="avatar" href="{{.SignedUser.HomeLink}}">
<img src="{{.SignedUser.AvatarLink}}">
</a>
<div class="content">
<form class="ui segment form" action="{{.Link}}" method="post">
{{template "repo/issue/comment_tab" .}}
<div class="text right">
<div class="ui red basic button" data-close="{{.i18n.Tr "repo.issues.close_issue"}}" data-close-and-comment="{{.i18n.Tr "repo.issues.close_comment_issue"}}">
{{.i18n.Tr "repo.issues.close_issue"}}
</div>
<div class="ui green button">
{{.i18n.Tr "repo.issues.create_comment"}}
</div>
</div>
</form>
</div>
</div>
</ui>
</div>