当前位置: 首页>>代码示例>>Golang>>正文


Golang MetaData.WildcardSelector方法代码示例

本文整理汇总了Golang中github.com/ungerik/go-start/model.MetaData.WildcardSelector方法的典型用法代码示例。如果您正苦于以下问题:Golang MetaData.WildcardSelector方法的具体用法?Golang MetaData.WildcardSelector怎么用?Golang MetaData.WildcardSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ungerik/go-start/model.MetaData的用法示例。


在下文中一共展示了MetaData.WildcardSelector方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: IsFieldHidden

func (self *Form) IsFieldHidden(metaData *model.MetaData) bool {
	if metaData.BoolAttrib("hidden") {
		return true
	}
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.HiddenFields) || utils.StringIn(wildcardSelector, self.HiddenFields)
}
开发者ID:sedzinreri,项目名称:go-start,代码行数:8,代码来源:form.go

示例2: IsFieldDisabled

func (self *Form) IsFieldDisabled(metaData *model.MetaData) bool {
	if metaData.BoolAttrib("disabled") {
		return true
	}
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.DisabledFields) || utils.StringIn(wildcardSelector, self.DisabledFields)
}
开发者ID:sedzinreri,项目名称:go-start,代码行数:8,代码来源:form.go

示例3: IsFieldRequired

func (self *Form) IsFieldRequired(metaData *model.MetaData) bool {
	if val, ok := metaData.ModelValue(); ok && val.Required(metaData) {
		return true
	}
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.RequiredFields) || utils.StringIn(wildcardSelector, self.RequiredFields)
}
开发者ID:sedzinreri,项目名称:go-start,代码行数:8,代码来源:form.go

示例4: IsFieldExcluded

// IsFieldExcluded returns weather a field will be excluded from the form.
// Fields will be excluded, if their selector matches one in Form.ExcludedFields
// or if a matching Authenticator from Form.ModelFieldAuth returns false.
// A field is also excluded when its parent field is excluded.
// This function is not restricted to model.Value, it works with all struct fields.
// This way a whole sub struct an be excluded by adding its selector to Form.ExcludedFields.
func (self *Form) IsFieldExcluded(field *model.MetaData, ctx *Context) bool {
	if field.Parent == nil {
		return false // can't exclude root
	}
	if self.IsFieldExcluded(field.Parent, ctx) || field.SelectorsMatch(self.ExcludedFields) {
		return true
	}
	if len(self.ModelFieldAuth) > 0 {
		auth, hasAuth := self.ModelFieldAuth[field.Selector()]
		if !hasAuth {
			auth, hasAuth = self.ModelFieldAuth[field.WildcardSelector()]
		}
		if hasAuth {
			ok, err := auth.Authenticate(ctx)
			if err != nil {
				fmt.Println("Error in view.Form.IsFieldExcluded(): " + err.Error())
			}
			if !ok {
				return true
			}
		}
	}
	if len(Config.NamedAuthenticators) > 0 {
		if authAttrib, ok := field.Attrib(StructTagKey, "auth"); ok {
			for _, name := range strings.Split(authAttrib, ",") {
				// if multi := strings.Split(name, "+"); len(multi) > 1 {
				// 	// Needs to pass all sub-Authenticators
				// 	for _, name := range multi {
				// 		if auth, ok := NamedAuthenticator(name); ok {
				// 			ok, err := auth.Authenticate(response)
				// 			if err != nil {
				// 				fmt.Println("Error in view.Form.IsFieldExcluded(): " + err.Error())
				// 			}
				// 			if !ok {
				// 				return true
				// 			}
				// 		}
				// 	}
				// } else {
				if auth, ok := NamedAuthenticator(name); ok {
					ok, err := auth.Authenticate(ctx)
					if ok {
						// Only needs to pass one Authenticator
						return false
					}
					if err != nil {
						log.Println("Error in view.Form.IsFieldExcluded(): " + err.Error())
					}
				}
				// }
			}
			// No Authenticators passed, thus exclude
			return true
		}
	}
	return false
}
开发者ID:SohoStudio,项目名称:go-start,代码行数:63,代码来源:form.go

示例5: GetFieldDescription

func (self *Form) GetFieldDescription(metaData *model.MetaData) string {
	selector := metaData.Selector()
	if desc, ok := self.FieldDescriptions[selector]; ok {
		return desc
	}
	wildcardSelector := metaData.WildcardSelector()
	if desc, ok := self.FieldDescriptions[wildcardSelector]; ok {
		return desc
	}
	if desc, ok := metaData.Attrib(StructTagKey, "description"); ok {
		return desc
	}
	return ""
}
开发者ID:SohoStudio,项目名称:go-start,代码行数:14,代码来源:form.go

示例6: FieldLabel

// FieldLabel returns a label for a form field generated from metaData.
// It creates the label from the names or label tags of metaData and
// all its parents, starting with the root parent, concanated with a space
// character.
func (self *Form) FieldLabel(metaData *model.MetaData) string {
	selector := metaData.Selector()
	if label, ok := self.Labels[selector]; ok {
		return label
	}
	wildcardSelector := metaData.WildcardSelector()
	if label, ok := self.Labels[wildcardSelector]; ok {
		return label
	}
	var buf bytes.Buffer
	for _, m := range metaData.Path()[1:] {
		if buf.Len() > 0 {
			buf.WriteByte(' ')
		}
		buf.WriteString(self.DirectFieldLabel(m))
	}
	return buf.String()
}
开发者ID:SohoStudio,项目名称:go-start,代码行数:22,代码来源:form.go

示例7: GetInputSize

func (self *Form) GetInputSize(metaData *model.MetaData) int {
	selector := metaData.Selector()
	if size, ok := self.InputSizes[selector]; ok {
		return size
	}
	wildcardSelector := metaData.WildcardSelector()
	if size, ok := self.InputSizes[wildcardSelector]; ok {
		return size
	}
	if sizeStr, ok := metaData.Attrib("size"); ok {
		size, _ := strconv.Atoi(sizeStr)
		return size
	}
	layout := self.GetLayout()
	if layout != nil {
		return layout.GetDefaultInputSize(metaData)
	}
	return 0
}
开发者ID:sedzinreri,项目名称:go-start,代码行数:19,代码来源:form.go

示例8: GetInputSize

func (self *Form) GetInputSize(metaData *model.MetaData) int {
	selector := metaData.Selector()
	if size, ok := self.InputSizes[selector]; ok {
		return size
	}
	wildcardSelector := metaData.WildcardSelector()
	if size, ok := self.InputSizes[wildcardSelector]; ok {
		return size
	}
	if sizeStr, ok := metaData.Attrib(StructTagKey, "size"); ok {
		size, err := strconv.Atoi(sizeStr)
		if err != nil {
			panic("Error in Form.GetInputSize(): " + err.Error())
		}
		return size
	}
	layout := self.GetLayout()
	if layout != nil {
		return layout.GetDefaultInputSize(metaData)
	}
	return 0
}
开发者ID:SohoStudio,项目名称:go-start,代码行数:22,代码来源:form.go

示例9: Supports

func (self *MongoRefController) Supports(metaData *model.MetaData, form *Form) bool {
	_, ok := metaData.Value.Addr().Interface().(*mongo.Ref)
	return ok && (self.RefSelector == "" || self.RefSelector == metaData.Selector() || self.RefSelector == metaData.WildcardSelector())
}
开发者ID:prinsmike,项目名称:go-start,代码行数:4,代码来源:formfieldcontrollers.go

示例10: IsFieldExcluded

func (self *Form) IsFieldExcluded(metaData *model.MetaData) bool {
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.ExcludedFields) || utils.StringIn(wildcardSelector, self.ExcludedFields)
}
开发者ID:sedzinreri,项目名称:go-start,代码行数:5,代码来源:form.go


注:本文中的github.com/ungerik/go-start/model.MetaData.WildcardSelector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。