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
|
||||
}
|
||||
|
||||
// CalQueryString calculates query string in issue/pulls list
|
||||
func (label *Label) CalQueryString(query []string) {
|
||||
// LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked
|
||||
func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []string) {
|
||||
var labelQuerySlice []string
|
||||
labelSelected := false
|
||||
labelID := fmt.Sprint(label.ID)
|
||||
for _, s := range query {
|
||||
for _, s := range currentSelectedLabels {
|
||||
if s == labelID {
|
||||
labelSelected = true
|
||||
} else if s != "" {
|
||||
|
|
|
|||
|
|
@ -71,17 +71,17 @@ func RetrieveLabels(ctx *context.Context) {
|
|||
ctx.Data["SortType"] = ctx.Query("sort")
|
||||
}
|
||||
|
||||
// RetreveLabelsAndCalQueryString calculate query string when filtering issues/pulls
|
||||
func RetreveLabelsAndCalQueryString(ctx *context.Context) {
|
||||
// RetrieveLabelsAndLoadSelectedLabels calculate query string when filtering issues/pulls
|
||||
func RetrieveLabelsAndLoadSelectedLabels(ctx *context.Context) {
|
||||
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"))
|
||||
if err != nil {
|
||||
ctx.ServerError("RetreveLabelsAndCalQueryString.GetLabels", err)
|
||||
ctx.ServerError("RetrieveLabelsAndLoadSelectedLabels.GetLabels", err)
|
||||
return
|
||||
}
|
||||
selectLabelsSlice := strings.Split(ctx.Query("labels"), ",")
|
||||
selectLabels := strings.Split(ctx.Query("labels"), ",")
|
||||
for _, l := range labels {
|
||||
l.CalOpenIssues()
|
||||
l.CalQueryString(selectLabelsSlice)
|
||||
l.LoadSelectedLabelsAfterClick(selectLabels)
|
||||
}
|
||||
ctx.Data["Labels"] = labels
|
||||
ctx.Data["NumLabels"] = len(labels)
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
|
||||
m.Group("/:username/:reponame", 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("/labels/", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.RetrieveLabels, repo.Labels)
|
||||
m.Get("/milestones", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.Milestones)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user