mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 12:53:57 +01:00
finish create issue with milestone and assignee
This commit is contained in:
parent
09a1b2a1f5
commit
75aff60c90
13 changed files with 275 additions and 206 deletions
|
@ -376,6 +376,8 @@ issues.new.clear_milestone = Clear milestone
|
|||
issues.new.open_milestone = Open Milestones
|
||||
issues.new.closed_milestone = Closed Milestones
|
||||
issues.new.assignee = Assignee
|
||||
issues.new.clear_assignee = Clear assignee
|
||||
issues.new.no_assignee = No assignee
|
||||
issues.create = Create Issue
|
||||
issues.new_label = New Label
|
||||
issues.new_label_placeholder = Label name...
|
||||
|
|
215
models/issue.go
215
models/issue.go
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/Unknwon/com"
|
||||
"github.com/go-xorm/xorm"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
@ -59,10 +60,23 @@ func (i *Issue) AfterSet(colName string, _ xorm.Cell) {
|
|||
var err error
|
||||
switch colName {
|
||||
case "milestone_id":
|
||||
if i.MilestoneID == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.Milestone, err = GetMilestoneByID(i.MilestoneID)
|
||||
if err != nil {
|
||||
log.Error(3, "GetMilestoneById: %v", err)
|
||||
}
|
||||
case "assignee_id":
|
||||
if i.AssigneeID == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
i.Assignee, err = GetUserByID(i.AssigneeID)
|
||||
if err != nil {
|
||||
log.Error(3, "GetUserByID: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +134,7 @@ func (i *Issue) RemoveLabel(labelID int64) error {
|
|||
}
|
||||
|
||||
func (i *Issue) GetAssignee() (err error) {
|
||||
if i.AssigneeID == 0 {
|
||||
if i.AssigneeID == 0 || i.Assignee != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -145,7 +159,7 @@ func (i *Issue) AfterDelete() {
|
|||
}
|
||||
|
||||
// CreateIssue creates new issue with labels for repository.
|
||||
func NewIssue(issue *Issue, labelIDs []int64) (err error) {
|
||||
func NewIssue(repo *Repository, issue *Issue, labelIDs []int64) (err error) {
|
||||
sess := x.NewSession()
|
||||
defer sessionRelease(sess)
|
||||
if err = sess.Begin(); err != nil {
|
||||
|
@ -170,6 +184,10 @@ func NewIssue(issue *Issue, labelIDs []int64) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
if err = newIssueUsers(sess, repo, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
}
|
||||
|
||||
|
@ -221,7 +239,7 @@ func GetIssueById(id int64) (*Issue, error) {
|
|||
}
|
||||
|
||||
// Issues returns a list of issues by given conditions.
|
||||
func Issues(uid, assigneeID, repoID, posterID, milestoneID int64, page int, isClosed, isMention bool, labelIds, sortType string) ([]*Issue, error) {
|
||||
func Issues(uid, assigneeID, repoID, posterID, milestoneID int64, page int, isClosed, isMention bool, labels, sortType string) ([]*Issue, error) {
|
||||
sess := x.Limit(setting.IssuePagingNum, (page-1)*setting.IssuePagingNum)
|
||||
|
||||
if repoID > 0 {
|
||||
|
@ -240,14 +258,6 @@ func Issues(uid, assigneeID, repoID, posterID, milestoneID int64, page int, isCl
|
|||
sess.And("issue.milestone_id=?", milestoneID)
|
||||
}
|
||||
|
||||
if len(labelIds) > 0 {
|
||||
for _, label := range strings.Split(labelIds, ",") {
|
||||
if com.StrTo(label).MustInt() > 0 {
|
||||
sess.And("label_ids like ?", "%$"+label+"|%")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch sortType {
|
||||
case "oldest":
|
||||
sess.Asc("created")
|
||||
|
@ -265,10 +275,26 @@ func Issues(uid, assigneeID, repoID, posterID, milestoneID int64, page int, isCl
|
|||
sess.Desc("created")
|
||||
}
|
||||
|
||||
labelIDs := base.StringsToInt64s(strings.Split(labels, ","))
|
||||
if len(labelIDs) > 0 {
|
||||
validJoin := false
|
||||
queryStr := "issue.id=issue_label.issue_id"
|
||||
for _, id := range labelIDs {
|
||||
if id == 0 {
|
||||
continue
|
||||
}
|
||||
validJoin = true
|
||||
queryStr += " AND issue_label.label_id=" + com.ToStr(id)
|
||||
}
|
||||
if validJoin {
|
||||
sess.Join("INNER", "issue_label", queryStr)
|
||||
}
|
||||
}
|
||||
|
||||
if isMention {
|
||||
queryStr := "issue.id = issue_user.issue_id AND issue_user.is_mentioned=1"
|
||||
queryStr := "issue.id=issue_user.issue_id AND issue_user.is_mentioned=1"
|
||||
if uid > 0 {
|
||||
queryStr += " AND issue_user.uid = " + com.ToStr(uid)
|
||||
queryStr += " AND issue_user.uid=" + com.ToStr(uid)
|
||||
}
|
||||
sess.Join("INNER", "issue_user", queryStr)
|
||||
}
|
||||
|
@ -299,11 +325,11 @@ func GetIssueCountByPoster(uid, rid int64, isClosed bool) int64 {
|
|||
|
||||
// IssueUser represents an issue-user relation.
|
||||
type IssueUser struct {
|
||||
Id int64
|
||||
Uid int64 `xorm:"INDEX"` // User ID.
|
||||
IssueId int64
|
||||
RepoId int64 `xorm:"INDEX"`
|
||||
MilestoneId int64
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
UID int64 `xorm:"uid INDEX"` // User ID.
|
||||
IssueID int64
|
||||
RepoID int64 `xorm:"INDEX"`
|
||||
MilestoneID int64
|
||||
IsRead bool
|
||||
IsAssigned bool
|
||||
IsMentioned bool
|
||||
|
@ -312,59 +338,62 @@ type IssueUser struct {
|
|||
}
|
||||
|
||||
// FIXME: organization
|
||||
// NewIssueUserPairs adds new issue-user pairs for new issue of repository.
|
||||
func NewIssueUserPairs(repo *Repository, issue *Issue) error {
|
||||
users, err := repo.GetCollaborators()
|
||||
func newIssueUsers(e *xorm.Session, repo *Repository, issue *Issue) error {
|
||||
users, err := repo.GetAssignees()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
iu := &IssueUser{
|
||||
IssueId: issue.ID,
|
||||
RepoId: repo.ID,
|
||||
IssueID: issue.ID,
|
||||
RepoID: repo.ID,
|
||||
}
|
||||
|
||||
// Poster can be anyone.
|
||||
isNeedAddPoster := true
|
||||
for _, u := range users {
|
||||
iu.Id = 0
|
||||
iu.Uid = u.Id
|
||||
iu.IsPoster = iu.Uid == issue.PosterID
|
||||
iu.ID = 0
|
||||
iu.UID = u.Id
|
||||
iu.IsPoster = iu.UID == issue.PosterID
|
||||
if isNeedAddPoster && iu.IsPoster {
|
||||
isNeedAddPoster = false
|
||||
}
|
||||
iu.IsAssigned = iu.Uid == issue.AssigneeID
|
||||
if _, err = x.Insert(iu); err != nil {
|
||||
iu.IsAssigned = iu.UID == issue.AssigneeID
|
||||
if _, err = e.Insert(iu); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if isNeedAddPoster {
|
||||
iu.Id = 0
|
||||
iu.Uid = issue.PosterID
|
||||
iu.ID = 0
|
||||
iu.UID = issue.PosterID
|
||||
iu.IsPoster = true
|
||||
iu.IsAssigned = iu.Uid == issue.AssigneeID
|
||||
if _, err = x.Insert(iu); err != nil {
|
||||
if _, err = e.Insert(iu); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Add owner's as well.
|
||||
if repo.OwnerID != issue.PosterID {
|
||||
iu.Id = 0
|
||||
iu.Uid = repo.OwnerID
|
||||
iu.IsAssigned = iu.Uid == issue.AssigneeID
|
||||
if _, err = x.Insert(iu); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewIssueUsers adds new issue-user relations for new issue of repository.
|
||||
func NewIssueUsers(repo *Repository, issue *Issue) (err error) {
|
||||
sess := x.NewSession()
|
||||
defer sessionRelease(sess)
|
||||
if err = sess.Begin(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = newIssueUsers(sess, repo, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
}
|
||||
|
||||
// PairsContains returns true when pairs list contains given issue.
|
||||
func PairsContains(ius []*IssueUser, issueId, uid int64) int {
|
||||
for i := range ius {
|
||||
if ius[i].IssueId == issueId &&
|
||||
ius[i].Uid == uid {
|
||||
if ius[i].IssueID == issueId &&
|
||||
ius[i].UID == uid {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +403,7 @@ func PairsContains(ius []*IssueUser, issueId, uid int64) int {
|
|||
// GetIssueUserPairs returns issue-user pairs by given repository and user.
|
||||
func GetIssueUserPairs(rid, uid int64, isClosed bool) ([]*IssueUser, error) {
|
||||
ius := make([]*IssueUser, 0, 10)
|
||||
err := x.Where("is_closed=?", isClosed).Find(&ius, &IssueUser{RepoId: rid, Uid: uid})
|
||||
err := x.Where("is_closed=?", isClosed).Find(&ius, &IssueUser{RepoID: rid, UID: uid})
|
||||
return ius, err
|
||||
}
|
||||
|
||||
|
@ -437,50 +466,58 @@ const (
|
|||
FM_MENTION
|
||||
)
|
||||
|
||||
func parseCountResult(results []map[string][]byte) int64 {
|
||||
if len(results) == 0 {
|
||||
return 0
|
||||
}
|
||||
for _, result := range results[0] {
|
||||
return com.StrTo(string(result)).MustInt64()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// GetIssueStats returns issue statistic information by given conditions.
|
||||
func GetIssueStats(repoID, uid, labelID, milestoneID int64, isShowClosed bool, filterMode int) *IssueStats {
|
||||
stats := &IssueStats{}
|
||||
issue := new(Issue)
|
||||
// issue := new(Issue)
|
||||
|
||||
queryStr := "issue.repo_id=? AND issue.is_closed=?"
|
||||
queryStr := "SELECT COUNT(*) FROM `issue` "
|
||||
if labelID > 0 {
|
||||
queryStr += " AND issue.label_ids like '%$" + com.ToStr(labelID) + "|%'"
|
||||
queryStr += "INNER JOIN `issue_label` ON `issue`.id=`issue_label`.issue_id AND `issue_label`.label_id=" + com.ToStr(labelID)
|
||||
}
|
||||
|
||||
baseCond := " WHERE issue.repo_id=? AND issue.is_closed=?"
|
||||
if milestoneID > 0 {
|
||||
queryStr += " AND milestone_id=" + com.ToStr(milestoneID)
|
||||
baseCond += " AND issue.milestone_id=" + com.ToStr(milestoneID)
|
||||
}
|
||||
switch filterMode {
|
||||
case FM_ALL:
|
||||
stats.OpenCount, _ = x.Where(queryStr, repoID, false).Count(issue)
|
||||
stats.ClosedCount, _ = x.Where(queryStr, repoID, true).Count(issue)
|
||||
return stats
|
||||
resutls, _ := x.Query(queryStr+baseCond, repoID, false)
|
||||
stats.OpenCount = parseCountResult(resutls)
|
||||
resutls, _ = x.Query(queryStr+baseCond, repoID, true)
|
||||
stats.ClosedCount = parseCountResult(resutls)
|
||||
|
||||
case FM_ASSIGN:
|
||||
queryStr += " AND assignee_id=?"
|
||||
stats.OpenCount, _ = x.Where(queryStr, repoID, false, uid).Count(issue)
|
||||
stats.ClosedCount, _ = x.Where(queryStr, repoID, true, uid).Count(issue)
|
||||
return stats
|
||||
baseCond += " AND assignee_id=?"
|
||||
resutls, _ := x.Query(queryStr+baseCond, repoID, false, uid)
|
||||
stats.OpenCount = parseCountResult(resutls)
|
||||
resutls, _ = x.Query(queryStr+baseCond, repoID, true, uid)
|
||||
stats.ClosedCount = parseCountResult(resutls)
|
||||
|
||||
case FM_CREATE:
|
||||
queryStr += " AND poster_id=?"
|
||||
stats.OpenCount, _ = x.Where(queryStr, repoID, false, uid).Count(issue)
|
||||
stats.ClosedCount, _ = x.Where(queryStr, repoID, true, uid).Count(issue)
|
||||
return stats
|
||||
baseCond += " AND poster_id=?"
|
||||
resutls, _ := x.Query(queryStr+baseCond, repoID, false, uid)
|
||||
stats.OpenCount = parseCountResult(resutls)
|
||||
resutls, _ = x.Query(queryStr+baseCond, repoID, true, uid)
|
||||
stats.ClosedCount = parseCountResult(resutls)
|
||||
|
||||
case FM_MENTION:
|
||||
queryStr += " AND uid=? AND is_mentioned=?"
|
||||
if labelID > 0 {
|
||||
stats.OpenCount, _ = x.Where(queryStr, repoID, false, uid, true).
|
||||
Join("INNER", "issue", "issue.id = issue_id").Count(new(IssueUser))
|
||||
stats.ClosedCount, _ = x.Where(queryStr, repoID, true, uid, true).
|
||||
Join("INNER", "issue", "issue.id = issue_id").Count(new(IssueUser))
|
||||
return stats
|
||||
}
|
||||
|
||||
queryStr = strings.Replace(queryStr, "issue.", "", 2)
|
||||
stats.OpenCount, _ = x.Where(queryStr, repoID, false, uid, true).Count(new(IssueUser))
|
||||
stats.ClosedCount, _ = x.Where(queryStr, repoID, true, uid, true).Count(new(IssueUser))
|
||||
return stats
|
||||
queryStr += " INNER JOIN `issue_user` ON `issue`.id=`issue_user`.issue_id"
|
||||
baseCond += " AND `issue_user`.uid=? AND `issue_user`.is_mentioned=?"
|
||||
resutls, _ := x.Query(queryStr+baseCond, repoID, false, uid, true)
|
||||
stats.OpenCount = parseCountResult(resutls)
|
||||
resutls, _ = x.Query(queryStr+baseCond, repoID, true, uid, true)
|
||||
stats.ClosedCount = parseCountResult(resutls)
|
||||
}
|
||||
return stats
|
||||
}
|
||||
|
@ -511,22 +548,34 @@ func UpdateIssueUserPairsByStatus(iid int64, isClosed bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// UpdateIssueUserPairByAssignee updates issue-user pair for assigning.
|
||||
func UpdateIssueUserPairByAssignee(aid, iid int64) error {
|
||||
rawSql := "UPDATE `issue_user` SET is_assigned = ? WHERE issue_id = ?"
|
||||
if _, err := x.Exec(rawSql, false, iid); err != nil {
|
||||
func updateIssueUserByAssignee(e *xorm.Session, issueID, assigneeID int64) (err error) {
|
||||
if _, err = e.Exec("UPDATE `issue_user` SET is_assigned=? WHERE issue_id=?", false, issueID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Assignee ID equals to 0 means clear assignee.
|
||||
if aid == 0 {
|
||||
if assigneeID == 0 {
|
||||
return nil
|
||||
}
|
||||
rawSql = "UPDATE `issue_user` SET is_assigned = ? WHERE uid = ? AND issue_id = ?"
|
||||
_, err := x.Exec(rawSql, true, aid, iid)
|
||||
_, err = e.Exec("UPDATE `issue_user` SET is_assigned=? WHERE uid=? AND issue_id=?", true, assigneeID, issueID)
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateIssueUserByAssignee updates issue-user relation for assignee.
|
||||
func UpdateIssueUserByAssignee(issueID, assigneeID int64) (err error) {
|
||||
sess := x.NewSession()
|
||||
defer sessionRelease(sess)
|
||||
if err = sess.Begin(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = updateIssueUserByAssignee(sess, issueID, assigneeID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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 = ?"
|
||||
|
@ -537,7 +586,7 @@ func UpdateIssueUserPairByRead(uid, iid int64) error {
|
|||
// UpdateIssueUserPairsByMentions updates issue-user pairs by mentioning.
|
||||
func UpdateIssueUserPairsByMentions(uids []int64, iid int64) error {
|
||||
for _, uid := range uids {
|
||||
iu := &IssueUser{Uid: uid, IssueId: iid}
|
||||
iu := &IssueUser{UID: uid, IssueID: iid}
|
||||
has, err := x.Get(iu)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -545,7 +594,7 @@ func UpdateIssueUserPairsByMentions(uids []int64, iid int64) error {
|
|||
|
||||
iu.IsMentioned = true
|
||||
if has {
|
||||
_, err = x.Id(iu.Id).AllCols().Update(iu)
|
||||
_, err = x.Id(iu.ID).AllCols().Update(iu)
|
||||
} else {
|
||||
_, err = x.Insert(iu)
|
||||
}
|
||||
|
|
|
@ -177,6 +177,43 @@ func (repo *Repository) GetOwner() (err error) {
|
|||
return repo.getOwner(x)
|
||||
}
|
||||
|
||||
// GetAssignees returns all users that have write access of repository.
|
||||
func (repo *Repository) GetAssignees() (_ []*User, err error) {
|
||||
if err = repo.GetOwner(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accesses := make([]*Access, 0, 10)
|
||||
if err = x.Where("repo_id=? AND mode>=?", repo.ID, ACCESS_MODE_WRITE).Find(&accesses); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users := make([]*User, 0, len(accesses)+1) // Just waste 1 unit does not matter.
|
||||
if !repo.Owner.IsOrganization() {
|
||||
users = append(users, repo.Owner)
|
||||
}
|
||||
|
||||
var u *User
|
||||
for i := range accesses {
|
||||
u, err = GetUserByID(accesses[i].UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
users = append(users, u)
|
||||
}
|
||||
return users, nil
|
||||
}
|
||||
|
||||
// GetAssigneeByID returns the user that has write access of repository by given ID.
|
||||
func (repo *Repository) GetAssigneeByID(userID int64) (*User, error) {
|
||||
return GetAssigneeByID(repo, userID)
|
||||
}
|
||||
|
||||
// GetMilestoneByID returns the milestone belongs to repository by given ID.
|
||||
func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error) {
|
||||
return GetRepoMilestoneByID(repo.ID, milestoneID)
|
||||
}
|
||||
|
||||
func (repo *Repository) GetMirror() (err error) {
|
||||
repo.Mirror, err = GetMirror(repo.ID)
|
||||
return err
|
||||
|
@ -876,7 +913,7 @@ func DeleteRepository(uid, repoID int64, userName string) error {
|
|||
return err
|
||||
} else if _, err = sess.Delete(&Mirror{RepoID: repoID}); err != nil {
|
||||
return err
|
||||
} else if _, err = sess.Delete(&IssueUser{RepoId: repoID}); err != nil {
|
||||
} else if _, err = sess.Delete(&IssueUser{RepoID: repoID}); err != nil {
|
||||
return err
|
||||
} else if _, err = sess.Delete(&Milestone{RepoID: repoID}); err != nil {
|
||||
return err
|
||||
|
|
|
@ -602,6 +602,17 @@ func GetUserByID(id int64) (*User, error) {
|
|||
return getUserByID(x, id)
|
||||
}
|
||||
|
||||
// GetAssigneeByID returns the user with write access of repository by given ID.
|
||||
func GetAssigneeByID(repo *Repository, userID int64) (*User, error) {
|
||||
has, err := HasAccess(&User{Id: userID}, repo, ACCESS_MODE_WRITE)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, ErrUserNotExist{userID, ""}
|
||||
}
|
||||
return GetUserByID(userID)
|
||||
}
|
||||
|
||||
// GetUserByName returns user by given name.
|
||||
func GetUserByName(name string) (*User, error) {
|
||||
if len(name) == 0 {
|
||||
|
|
File diff suppressed because one or more lines are too long
2
public/css/gogs.min.css
vendored
2
public/css/gogs.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -65,29 +65,42 @@ function initCommentForm() {
|
|||
$($(this).parent().data('id')).val('');
|
||||
});
|
||||
|
||||
var $milestone_menu = $('.select-milestone .menu');
|
||||
var $milestone_list = $('.ui.select-milestone.list')
|
||||
// Milestones
|
||||
$milestone_menu.find('.item:not(.no-select)').click(function () {
|
||||
$(this).parent().find('.item').each(function () {
|
||||
$(this).removeClass('selected active')
|
||||
});
|
||||
function selectItem(select_id, input_id) {
|
||||
var $menu = $(select_id + ' .menu');
|
||||
var $list = $('.ui' + select_id + '.list')
|
||||
$menu.find('.item:not(.no-select)').click(function () {
|
||||
$(this).parent().find('.item').each(function () {
|
||||
$(this).removeClass('selected active')
|
||||
});
|
||||
|
||||
$(this).addClass('selected active');
|
||||
$milestone_list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' +
|
||||
$(this).text() + '</a>');
|
||||
$('.ui.select-milestone.list .no-select').addClass('hide');
|
||||
$('#milestone_id').val($(this).data('id'));
|
||||
});
|
||||
$milestone_menu.find('.no-select.item').click(function () {
|
||||
$(this).parent().find('.item:not(.no-select)').each(function () {
|
||||
$(this).removeClass('selected active')
|
||||
$(this).addClass('selected active');
|
||||
switch (input_id) {
|
||||
case '#milestone_id':
|
||||
$list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' +
|
||||
$(this).text() + '</a>');
|
||||
break;
|
||||
case '#assignee_id':
|
||||
$list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' +
|
||||
'<img class="ui avatar image" src=' + $(this).data('avatar') + '>' +
|
||||
$(this).text() + '</a>');
|
||||
}
|
||||
$('.ui' + select_id + '.list .no-select').addClass('hide');
|
||||
$(input_id).val($(this).data('id'));
|
||||
});
|
||||
$menu.find('.no-select.item').click(function () {
|
||||
$(this).parent().find('.item:not(.no-select)').each(function () {
|
||||
$(this).removeClass('selected active')
|
||||
});
|
||||
|
||||
$milestone_list.find('.selected').html('');
|
||||
$milestone_list.find('.no-select').removeClass('hide');
|
||||
$('#milestone_id').val('');
|
||||
});
|
||||
$list.find('.selected').html('');
|
||||
$list.find('.no-select').removeClass('hide');
|
||||
$(input_id).val('');
|
||||
});
|
||||
}
|
||||
|
||||
// Milestone and assignee
|
||||
selectItem('.select-milestone', '#milestone_id');
|
||||
selectItem('.select-assignee', '#assignee_id');
|
||||
}
|
||||
|
||||
function initInstall() {
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
overflow-x: auto;
|
||||
}
|
||||
.ui.list {
|
||||
.ui.avatar.image {
|
||||
border-radius: 0;
|
||||
}
|
||||
.hide {
|
||||
display: none!important;
|
||||
}
|
||||
|
@ -109,6 +112,9 @@
|
|||
color: #000!important;
|
||||
}
|
||||
}
|
||||
.assignee {
|
||||
margin-top: -5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,18 +202,13 @@ func NewIssue(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// ctx.Data["AssigneeID"] = 0
|
||||
// ctx.Data["Assignees"], err = repo.GetCollaborators()
|
||||
ctx.Data["Assignees"], err = repo.GetAssignees()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetAssignees: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// us, err := repo.GetCollaborators()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "GetCollaborators", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// ctx.Data["Collaborators"] = us
|
||||
|
||||
ctx.HTML(200, ISSUE_NEW)
|
||||
}
|
||||
|
||||
|
@ -227,6 +222,7 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
|||
repo = ctx.Repo.Repository
|
||||
labelIDs []int64
|
||||
milestoneID int64
|
||||
assigneeID int64
|
||||
)
|
||||
if ctx.User.IsAdmin {
|
||||
// Check labels.
|
||||
|
@ -260,12 +256,26 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
|||
ctx.Handle(500, "GetMilestones: %v", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Milestone"], err = models.GetRepoMilestoneByID(repo.ID, milestoneID)
|
||||
ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetRepoMilestoneByID: %v", err)
|
||||
ctx.Handle(500, "GetMilestoneByID: %v", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["milestone_id"] = milestoneID
|
||||
|
||||
// Check assignee.
|
||||
assigneeID = form.AssigneeID
|
||||
ctx.Data["Assignees"], err = repo.GetAssignees()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetAssignees: %v", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Assignee"], err = repo.GetAssigneeByID(assigneeID)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetAssigneeByID: %v", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["assignee_id"] = assigneeID
|
||||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
|
@ -279,13 +289,10 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
|||
Name: form.Title,
|
||||
PosterID: ctx.User.Id,
|
||||
MilestoneID: milestoneID,
|
||||
// AssigneeID: form.AssigneeID,
|
||||
Content: form.Content,
|
||||
AssigneeID: assigneeID,
|
||||
Content: form.Content,
|
||||
}
|
||||
if err := models.NewIssue(issue, labelIDs); err != nil {
|
||||
ctx.Handle(500, "NewIssue", err)
|
||||
return
|
||||
} else if err := models.NewIssueUserPairs(repo, issue); err != nil {
|
||||
if err := models.NewIssue(repo, issue, labelIDs); err != nil {
|
||||
ctx.Handle(500, "NewIssue", err)
|
||||
return
|
||||
}
|
||||
|
@ -294,71 +301,6 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
|||
}
|
||||
|
||||
func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
||||
// send := func(status int, data interface{}, err error) {
|
||||
// if err != nil {
|
||||
// log.Error(4, "issue.CreateIssuePost(?): %s", err)
|
||||
|
||||
// ctx.JSON(status, map[string]interface{}{
|
||||
// "ok": false,
|
||||
// "status": status,
|
||||
// "error": err.Error(),
|
||||
// })
|
||||
// } else {
|
||||
// ctx.JSON(status, map[string]interface{}{
|
||||
// "ok": true,
|
||||
// "status": status,
|
||||
// "data": data,
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
|
||||
// var err error
|
||||
// // Get all milestones.
|
||||
// _, err = models.GetMilestones(ctx.Repo.Repository.ID, -1, false)
|
||||
// if err != nil {
|
||||
// send(500, nil, err)
|
||||
// return
|
||||
// }
|
||||
// _, err = models.GetMilestones(ctx.Repo.Repository.ID, -1, true)
|
||||
// if err != nil {
|
||||
// send(500, nil, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// _, err = ctx.Repo.Repository.GetCollaborators()
|
||||
// if err != nil {
|
||||
// send(500, nil, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// if ctx.HasError() {
|
||||
// send(400, nil, errors.New(ctx.Flash.ErrorMsg))
|
||||
// return
|
||||
// }
|
||||
|
||||
// // Only collaborators can assign.
|
||||
// if !ctx.Repo.IsOwner() {
|
||||
// form.AssigneeId = 0
|
||||
// }
|
||||
// issue := &models.Issue{
|
||||
// RepoID: ctx.Repo.Repository.ID,
|
||||
// Index: int64(ctx.Repo.Repository.NumIssues) + 1,
|
||||
// Name: form.IssueName,
|
||||
// PosterID: ctx.User.Id,
|
||||
// MilestoneID: form.MilestoneId,
|
||||
// AssigneeID: form.AssigneeId,
|
||||
// LabelIds: form.Labels,
|
||||
// Content: form.Content,
|
||||
// }
|
||||
// if err := models.NewIssue(issue); err != nil {
|
||||
// send(500, nil, err)
|
||||
// return
|
||||
// } else if err := models.NewIssueUserPairs(ctx.Repo.Repository, issue.ID, ctx.Repo.Owner.Id,
|
||||
// ctx.User.Id, form.AssigneeId); err != nil {
|
||||
// send(500, nil, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// if setting.AttachmentEnabled {
|
||||
// uploadFiles(ctx, issue.ID, 0)
|
||||
// }
|
||||
|
@ -743,7 +685,7 @@ func UpdateAssignee(ctx *middleware.Context) {
|
|||
aid := com.StrTo(ctx.Query("assigneeid")).MustInt64()
|
||||
// Not check for invalid assignee id and give responsibility to owners.
|
||||
issue.AssigneeID = aid
|
||||
if err = models.UpdateIssueUserPairByAssignee(aid, issue.ID); err != nil {
|
||||
if err = models.UpdateIssueUserByAssignee(issue.ID, aid); err != nil {
|
||||
ctx.Handle(500, "UpdateIssueUserPairByAssignee: %v", err)
|
||||
return
|
||||
} else if err = models.UpdateIssue(issue); err != nil {
|
||||
|
|
|
@ -339,13 +339,13 @@ func Issues(ctx *middleware.Context) {
|
|||
|
||||
issues := make([]*models.Issue, len(ius))
|
||||
for i := range ius {
|
||||
issues[i], err = models.GetIssueById(ius[i].IssueId)
|
||||
issues[i], err = models.GetIssueById(ius[i].IssueID)
|
||||
if err != nil {
|
||||
if err == models.ErrIssueNotExist {
|
||||
log.Warn("user.Issues(GetIssueById #%d): issue not exist", ius[i].IssueId)
|
||||
log.Warn("user.Issues(GetIssueById #%d): issue not exist", ius[i].IssueID)
|
||||
continue
|
||||
} else {
|
||||
ctx.Handle(500, fmt.Sprintf("user.Issues(GetIssueById #%d)", ius[i].IssueId), err)
|
||||
ctx.Handle(500, fmt.Sprintf("user.Issues(GetIssueById #%d)", ius[i].IssueID), err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,11 +87,14 @@
|
|||
<p class="desc">
|
||||
{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.Name|Str2html}}
|
||||
{{if .Milestone}}
|
||||
{{with .Milestone}}
|
||||
<a class="milestone" href="{{$.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.ID}}">
|
||||
<span class="octicon octicon-milestone"></span> {{.Name}}
|
||||
<a class="milestone" href="{{$.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.Milestone.ID}}">
|
||||
<span class="octicon octicon-milestone"></span> {{.Milestone.Name}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{if .Assignee}}
|
||||
<a class="ui right assignee poping up" href="{{.Assignee.HomeLink}}" data-content="{{.Assignee.Name}}" data-variation="inverted" data-position="left center">
|
||||
<img class="ui avatar image" src="{{.Assignee.AvatarLink}}">
|
||||
</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</p>
|
||||
</li>
|
||||
|
|
|
@ -101,23 +101,29 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="ui divider"></div>
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div class="ui {{if not .Assignees}}disabled{{end}} dropdown jump item">
|
||||
<input id="assignee_id" name="assignee_id" type="hidden" value="{{.assignee_id}}">
|
||||
<div class="ui {{if not .Assignees}}disabled{{end}} jump select-assignee dropdown">
|
||||
<span class="text">
|
||||
<strong>{{.i18n.Tr "repo.issues.new.assignee"}}</strong>
|
||||
<span class="octicon octicon-gear"></span>
|
||||
</span>
|
||||
<div class="menu">
|
||||
<div class="item">{{.i18n.Tr "repo.issues.new.clear_assignee"}}</a>
|
||||
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_assignee"}}</div>
|
||||
{{range .Assignees}}
|
||||
<a class="item" href="#"><span class="octicon {{if eq .ID $.AssigneeID}}octicon-check{{end}}"></span> {{.Name}}</a>
|
||||
<div class="item" data-id="{{.Id}}" data-href="{{.HomeLink}}" data-avatar="{{.AvatarLink}}"><img src="{{.AvatarLink}}"> {{.Name}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui list">
|
||||
<span class="item">filter_label_no_select</span>
|
||||
</div> -->
|
||||
<div class="ui select-assignee list">
|
||||
<span class="no-select item {{if .Assignee}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_assignee"}}</span>
|
||||
<div class="selected">
|
||||
{{if .Assignee}}
|
||||
<a class="item" href="{{.Assignee.HomeLink}}"><img class="ui avatar image" src="{{.Assignee.AvatarLink}}"> {{.Assignee.Name}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<li><a href="{{AppSubUrl}}/issues?type=created_by&repoid={{.RepoId}}&state={{.State}}" class="radius{{if eq .ViewType "created_by"}} active{{end}}">Created by you <strong class="pull-right">{{.IssueStats.CreateCount}}</strong></a></li>
|
||||
<li><hr/></li>
|
||||
{{range .Repos}}
|
||||
<li><a href="{{AppSubUrl}}/issues?type={{$.ViewType}}{{if eq $.RepoId .Id}}{{else}}&repoid={{.Id}}{{end}}&state={{$.State}}" class="radius{{if eq $.RepoId .Id}} active{{end}}">{{$.SignedUser.Name}}/{{.Name}} <strong class="pull-right">{{if $.IsShowClosed}}{{.NumClosedIssues}}{{else}}{{.NumOpenIssues}}{{end}}</strong></a></li>
|
||||
<li><a href="{{AppSubUrl}}/issues?type={{$.ViewType}}{{if eq $.RepoId .ID}}{{else}}&repoid={{.ID}}{{end}}&state={{$.State}}" class="radius{{if eq $.RepoId .ID}} active{{end}}">{{$.SignedUser.Name}}/{{.Name}} <strong class="pull-right">{{if $.IsShowClosed}}{{.NumClosedIssues}}{{else}}{{.NumOpenIssues}}{{end}}</strong></a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue