mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	[UI] Sortable Tables Header By Click (#7980)
* [UI] Sortable Tables Header By Click * get rid of padding above header * restart CI * fix lint * convert getArrow JS to SortArrow go func * addopt SortArrow funct * suggestions from @silverwind - tablesort.js Co-authored-by: silverwind <me@silverwind.io> * Update web_src/js/features/tablesort.js Co-authored-by: silverwind <me@silverwind.io> * Update web_src/js/features/tablesort.js Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
		@@ -298,8 +298,30 @@ func NewFuncMap() []template.FuncMap {
 | 
			
		||||
			}
 | 
			
		||||
			return false
 | 
			
		||||
		},
 | 
			
		||||
		"svg": func(icon string, size int) template.HTML {
 | 
			
		||||
			return template.HTML(fmt.Sprintf(`<svg class="svg %s" width="%d" height="%d" aria-hidden="true"><use xlink:href="#%s" /></svg>`, icon, size, size, icon))
 | 
			
		||||
		"svg": SVG,
 | 
			
		||||
		"SortArrow": func(normSort, revSort, urlSort string, isDefault bool) template.HTML {
 | 
			
		||||
			// if needed
 | 
			
		||||
			if len(normSort) == 0 || len(urlSort) == 0 {
 | 
			
		||||
				return ""
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if len(urlSort) == 0 && isDefault {
 | 
			
		||||
				// if sort is sorted as default add arrow tho this table header
 | 
			
		||||
				if isDefault {
 | 
			
		||||
					return SVG("octicon-triangle-down", 16)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				// if sort arg is in url test if it correlates with column header sort arguments
 | 
			
		||||
				if urlSort == normSort {
 | 
			
		||||
					// the table is sorted with this header normal
 | 
			
		||||
					return SVG("octicon-triangle-down", 16)
 | 
			
		||||
				} else if urlSort == revSort {
 | 
			
		||||
					// the table is sorted with this header reverse
 | 
			
		||||
					return SVG("octicon-triangle-up", 16)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			// the table is NOT sorted with this header
 | 
			
		||||
			return ""
 | 
			
		||||
		},
 | 
			
		||||
	}}
 | 
			
		||||
}
 | 
			
		||||
@@ -410,6 +432,11 @@ func NewTextFuncMap() []texttmpl.FuncMap {
 | 
			
		||||
	}}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SVG render icons
 | 
			
		||||
func SVG(icon string, size int) template.HTML {
 | 
			
		||||
	return template.HTML(fmt.Sprintf(`<svg class="svg %s" width="%d" height="%d" aria-hidden="true"><use xlink:href="#%s" /></svg>`, icon, size, size, icon))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Safe render raw as HTML
 | 
			
		||||
func Safe(raw string) template.HTML {
 | 
			
		||||
	return template.HTML(raw)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user