rename some variables and functions
This commit is contained in:
parent
01252ba2fd
commit
5d800446e5
|
|
@ -78,12 +78,12 @@ func (label *Label) CalOpenIssues() {
|
||||||
label.NumOpenIssues = label.NumIssues - label.NumClosedIssues
|
label.NumOpenIssues = label.NumIssues - label.NumClosedIssues
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalQueryString calculates query string in issue/pulls list
|
// LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked
|
||||||
func (label *Label) CalQueryString(query []string) {
|
func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []string) {
|
||||||
var labelQuerySlice []string
|
var labelQuerySlice []string
|
||||||
labelSelected := false
|
labelSelected := false
|
||||||
labelID := fmt.Sprint(label.ID)
|
labelID := fmt.Sprint(label.ID)
|
||||||
for _, s := range query {
|
for _, s := range currentSelectedLabels {
|
||||||
if s == labelID {
|
if s == labelID {
|
||||||
labelSelected = true
|
labelSelected = true
|
||||||
} else if s != "" {
|
} else if s != "" {
|
||||||
|
|
|
||||||
|
|
@ -71,17 +71,17 @@ func RetrieveLabels(ctx *context.Context) {
|
||||||
ctx.Data["SortType"] = ctx.Query("sort")
|
ctx.Data["SortType"] = ctx.Query("sort")
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetreveLabelsAndCalQueryString calculate query string when filtering issues/pulls
|
// RetrieveLabelsAndLoadSelectedLabels calculate query string when filtering issues/pulls
|
||||||
func RetreveLabelsAndCalQueryString(ctx *context.Context) {
|
func RetrieveLabelsAndLoadSelectedLabels(ctx *context.Context) {
|
||||||
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
|
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("RetreveLabelsAndCalQueryString.GetLabels", err)
|
ctx.ServerError("RetrieveLabelsAndLoadSelectedLabels.GetLabels", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
selectLabelsSlice := strings.Split(ctx.Query("labels"), ",")
|
selectLabels := strings.Split(ctx.Query("labels"), ",")
|
||||||
for _, l := range labels {
|
for _, l := range labels {
|
||||||
l.CalOpenIssues()
|
l.CalOpenIssues()
|
||||||
l.CalQueryString(selectLabelsSlice)
|
l.LoadSelectedLabelsAfterClick(selectLabels)
|
||||||
}
|
}
|
||||||
ctx.Data["Labels"] = labels
|
ctx.Data["Labels"] = labels
|
||||||
ctx.Data["NumLabels"] = len(labels)
|
ctx.Data["NumLabels"] = len(labels)
|
||||||
|
|
|
||||||
|
|
@ -585,7 +585,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
|
|
||||||
m.Group("/:username/:reponame", func() {
|
m.Group("/:username/:reponame", func() {
|
||||||
m.Group("", func() {
|
m.Group("", func() {
|
||||||
m.Get("/^:type(issues|pulls)$", repo.RetreveLabelsAndCalQueryString, repo.Issues)
|
m.Get("/^:type(issues|pulls)$", repo.RetrieveLabelsAndLoadSelectedLabels, repo.Issues)
|
||||||
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
|
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
|
||||||
m.Get("/labels/", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.RetrieveLabels, repo.Labels)
|
m.Get("/labels/", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.RetrieveLabels, repo.Labels)
|
||||||
m.Get("/milestones", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.Milestones)
|
m.Get("/milestones", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.Milestones)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user