Implemented custom type DependencyType
Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
parent
2c5a743df8
commit
29aafb3ef8
|
|
@ -21,9 +21,11 @@ type IssueDependency struct {
|
|||
}
|
||||
|
||||
// Define Dependency Type Constants
|
||||
type DependencyType int
|
||||
|
||||
const (
|
||||
DependencyTypeBlockedBy int64 = 1
|
||||
DependencyTypeBlocking int64 = 2
|
||||
DependencyTypeBlockedBy DependencyType = iota
|
||||
DependencyTypeBlocking
|
||||
)
|
||||
|
||||
// CreateIssueDependency creates a new dependency for an issue
|
||||
|
|
@ -66,7 +68,7 @@ func CreateIssueDependency(user *User, issue, dep *Issue) (exists bool, err erro
|
|||
}
|
||||
|
||||
// RemoveIssueDependency removes a dependency from an issue
|
||||
func RemoveIssueDependency(user *User, issue *Issue, dep *Issue, depType int64) (err error) {
|
||||
func RemoveIssueDependency(user *User, issue *Issue, dep *Issue, depType DependencyType) (err error) {
|
||||
sess := x.NewSession()
|
||||
|
||||
// Check if it exists
|
||||
|
|
@ -78,18 +80,20 @@ func RemoveIssueDependency(user *User, issue *Issue, dep *Issue, depType int64)
|
|||
// If it exists, remove it, otherwise show an error message
|
||||
if exists {
|
||||
|
||||
if depType == DependencyTypeBlockedBy {
|
||||
_, err := x.Delete(&IssueDependency{IssueID: issue.ID, DependencyID: dep.ID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var issueDepToDelete IssueDependency
|
||||
|
||||
switch depType {
|
||||
case DependencyTypeBlockedBy:
|
||||
issueDepToDelete = IssueDependency{IssueID: issue.ID, DependencyID: dep.ID}
|
||||
case DependencyTypeBlocking:
|
||||
issueDepToDelete = IssueDependency{IssueID: dep.ID, DependencyID: issue.ID}
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
if depType == DependencyTypeBlocking {
|
||||
_, err := x.Delete(&IssueDependency{IssueID: dep.ID, DependencyID: issue.ID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := x.Delete(&issueDepToDelete)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add comment referencing the removed dependency
|
||||
|
|
|
|||
|
|
@ -29,16 +29,18 @@ func RemoveDependency(c *context.Context) {
|
|||
}
|
||||
|
||||
// Dependency Type
|
||||
// Types: 1 = blockedBy, 2 = blocking
|
||||
depType, err := strconv.ParseInt(c.Req.PostForm.Get("dependencyType"), 10, 64)
|
||||
if err != nil {
|
||||
c.Handle(http.StatusInternalServerError, "GetDependecyType", err)
|
||||
return
|
||||
}
|
||||
depTypeStr := c.Req.PostForm.Get("dependencyType")
|
||||
|
||||
if depType != models.DependencyTypeBlockedBy && depType != models.DependencyTypeBlocking {
|
||||
c.Handle(http.StatusBadRequest, "GetDependecyType", nil)
|
||||
return
|
||||
var depType models.DependencyType
|
||||
|
||||
switch depTypeStr {
|
||||
case "blockedBy":
|
||||
depType = models.DependencyTypeBlockedBy
|
||||
case "blocking":
|
||||
depType = models.DependencyTypeBlocking
|
||||
default:
|
||||
c.Handle(http.StatusBadRequest, "GetDependecyType", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Dependency
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@
|
|||
{{range .BlockedByDependencies}}
|
||||
<div class="item">
|
||||
<div class="right floated content">
|
||||
<a class="delete-dependency-button" onclick="deleteDependencyModal({{.Issue.ID}}, 1);">
|
||||
<a class="delete-dependency-button" onclick="deleteDependencyModal({{.Issue.ID}}, 'blockedBy');">
|
||||
<i class="delete icon text red"></i>
|
||||
</a>
|
||||
{{if .IsClosed}}
|
||||
|
|
@ -241,7 +241,7 @@
|
|||
{{range .BlockingDependencies}}
|
||||
<div class="item">
|
||||
<div class="right floated content">
|
||||
<a class="delete-dependency-button" onclick="deleteDependencyModal({{.Issue.ID}}, 2);">
|
||||
<a class="delete-dependency-button" onclick="deleteDependencyModal({{.Issue.ID}}, 'blocking');">
|
||||
<i class="delete icon text red"></i>
|
||||
</a>
|
||||
{{if .IsClosed}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user