// fetchElements returns template items of a given class
fetchElements returns template items of a given class
// fetchElements returns template items of a given class
func (c *CmdConfigure) fetchElements(deviceCategory DeviceCategory) []templates.Template {
	var items []templates.Template
	for _, tmpl := range templates.ByClass(DeviceCategories[deviceCategory].class.String()) {
		if len(tmpl.Params) == 0 || len(tmpl.Description) == 0 {
			continue
		}
		if deviceCategory == DeviceCategoryGuidedSetup {
			if tmpl.GuidedSetup.Enable {
				items = append(items, tmpl)
			}
		} else {
			if len(DeviceCategories[deviceCategory].categoryFilter) == 0 ||
				c.paramChoiceContains(tmpl.Params, templates.ParamUsage, DeviceCategories[deviceCategory].categoryFilter.String()) {
				items = append(items, tmpl)
			}
		}
	}
	sort.Slice(items[:], func(i, j int) bool {
		if items[i].Generic && !items[j].Generic {
			return false
		}
		if !items[i].Generic && items[j].Generic {
			return true
		}
		return strings.ToLower(items[i].Description) < strings.ToLower(items[j].Description)
	})
	return items
}
func ( c * CmdConfigure ) fetchElements ( deviceCategory DeviceCategory ) [ ] templates . Template { var items [ ] templates . Template for _ , tmpl := range templates . ByClass ( DeviceCategories [ deviceCategory ] . class . String ( ) ) { if len ( tmpl . Params ) == 0 || len ( tmpl . Description ) == 0 { continue } if deviceCategory == DeviceCategoryGuidedSetup { if tmpl . GuidedSetup . Enable { items = append ( items , tmpl ) } } else { if len ( DeviceCategories [ deviceCategory ] . categoryFilter ) == 0 || c . paramChoiceContains ( tmpl . Params , templates . ParamUsage , DeviceCategories [ deviceCategory ] . categoryFilter . String ( ) ) { items = append ( items , tmpl ) } } } sort . Slice ( items [ : ] , func ( i , j int ) bool { if items [ i ] . Generic && ! items [ j ] . Generic { return false } if ! items [ i ] . Generic && items [ j ] . Generic { return true } return strings . ToLower ( items [ i ] . Description ) < strings . ToLower ( items [ j ] . Description ) } ) return items }
fetchElements returns template items of a given class
fetchElements returns template items of a given class
// sort generic templates to the bottom