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.closed_title = Closed
issues.num_comments = %d comments issues.num_comments = %d comments
issues.commented_at = commented at <a href="%s">%s</a> 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_title = Label name
issues.label_color = Label color issues.label_color = Label color
issues.label_count = %d labels issues.label_count = %d labels

View file

@ -160,12 +160,9 @@ func (i *Issue) GetAssignee() (err error) {
return err return err
} }
func (i *Issue) AfterDelete() { // ReadBy sets issue to be read by given user.
_, err := DeleteAttachmentsByIssue(i.ID, true) func (i *Issue) ReadBy(uid int64) error {
return UpdateIssueUserByRead(uid, i.ID)
if err != nil {
log.Info("Could not delete files for issue #%d: %s", i.ID, err)
}
} }
// CreateIssue creates new issue with labels for repository. // CreateIssue creates new issue with labels for repository.
@ -625,10 +622,9 @@ func UpdateIssueUserByAssignee(issueID, assigneeID int64) (err error) {
return sess.Commit() return sess.Commit()
} }
// UpdateIssueUserPairByRead updates issue-user pair for reading. // UpdateIssueUserByRead updates issue-user relation for reading.
func UpdateIssueUserPairByRead(uid, iid int64) error { func UpdateIssueUserByRead(uid, issueID int64) error {
rawSql := "UPDATE `issue_user` SET is_read = ? WHERE uid = ? AND issue_id = ?" _, err := x.Exec("UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID)
_, err := x.Exec(rawSql, true, uid, iid)
return err 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; @comment-avatar-width: 3em;
&.new.issue { &.new.issue {
.comment.form { .comment.form {
.comment .avatar { .comment {
.avatar {
width: @comment-avatar-width; width: @comment-avatar-width;
} }
}
.content { .content {
margin-left: 4em; margin-left: 4em;
.markdown { .markdown {
@ -137,6 +139,7 @@
overflow-x: auto; overflow-x: auto;
} }
} }
} }
} }
&.view.issue { &.view.issue {
@ -187,25 +190,19 @@
.markdown { .markdown {
font-size: 14px; font-size: 14px;
} }
.bottom.segment { .no-content {
color: #767676;
font-style: italic;
}
> .bottom.segment {
background: #f3f4f5; background: #f3f4f5;
.ui.image { .ui.image {
max-height: 150px; max-height: 150px;
} }
} }
} }
}
} .ui.form {
.ui.segment.metas {
margin-top: -3px;
}
}
.comment.form {
.ui.comments {
margin-top: -12px;
max-width: 750px!important;
}
.content {
.field:first-child { .field:first-child {
clear: none; clear: none;
} }
@ -218,13 +215,28 @@
height: 200px; height: 200px;
} }
} }
.dropzone { }
width: 100%; }
margin-bottom: 10px; .ui.segment.metas {
border: 2px dashed #0087F7; margin-top: -3px;
box-shadow: none; }
.dz-error-message { }
top: 140px; .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 { .settings .key.list {
.item:not(:first-child) { .item:not(:first-child) {
border-top: 1px solid #eaeaea; border-top: 1px solid #eaeaea;

View file

@ -441,11 +441,11 @@ func ViewIssue(ctx *middleware.Context) {
} }
if ctx.IsSigned { if ctx.IsSigned {
// // Update issue-user. // Update issue-user.
// if err = models.UpdateIssueUserPairByRead(ctx.User.Id, issue.ID); err != nil { if err = issue.ReadBy(ctx.User.Id); err != nil {
// ctx.Handle(500, "UpdateIssueUserPairByRead: %v", err) ctx.Handle(500, "ReadBy: %v", err)
// return return
// } }
if ctx.User.IsAdmin { if ctx.User.IsAdmin {
// labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID) // 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"> <div class="field">
<input name="title" placeholder="{{.i18n.Tr "repo.milestones.title"}}" value="{{.title}}" autofocus required> <input name="title" placeholder="{{.i18n.Tr "repo.milestones.title"}}" value="{{.title}}" autofocus required>
</div> </div>
<div class="field"> {{template "repo/issue/comment_tab" .}}
<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}}
<div class="text right"> <div class="text right">
<button class="ui green button"> <button class="ui green button">
{{.i18n.Tr "repo.issues.create"}} {{.i18n.Tr "repo.issues.create"}}

View file

@ -32,19 +32,42 @@
</div> </div>
</div> </div>
<div class="ui attached segment markdown"> <div class="ui attached segment markdown">
{{if .Issue.RenderedContent}}
{{.Issue.RenderedContent|Str2html}} {{.Issue.RenderedContent|Str2html}}
{{else}}
<span class="no-content">{{.i18n.Tr "repo.issues.no_content"}}</span>
{{end}}
</div> </div>
{{if .Issue.Attachments}} {{if .Issue.Attachments}}
<div class="ui bottom attached segment"> <div class="ui bottom attached segment">
<div class="ui small images"> <div class="ui small images">
{{range .Issue.Attachments}} {{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}} {{end}}
</div> </div>
</div> </div>
{{end}} {{end}}
</div> </div>
</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> </ui>
</div> </div>