Browse Source

Убрано ограничение при заполнении компетенций и ресурсов #65 #120

исправлен баг, что НЕ выводилось содержимое доверительного свойства,
если нет ни одной галочки.
Если нет галочек, значит, и доверительных свойств нет. Но пользователю это непонятно.
Поэтому принято пока такое архитектурное решение, выводить содержимое без галочек.
pull/120/head
Artur Galyamov 2 years ago
parent
commit
d8a9c5e12b
  1. 34
      routers/web/repo/resource.go
  2. 4
      services/forms/repo_form.go

34
routers/web/repo/resource.go

@ -41,28 +41,30 @@ func GetRenderedTrustPropsWithSearchLinks(ctx *context.Context, repo interface{}
} }
trustPropNamesMatches := regExp.FindAllStringSubmatch(trustProps, -1) trustPropNamesMatches := regExp.FindAllStringSubmatch(trustProps, -1)
if trustPropNamesMatches == nil {
return "", err
}
var trustPropsWithSafeURLs = strings.Clone(trustProps) var transformedTrustProps string
var trustPropName string if trustPropNamesMatches == nil {
var searchQS string transformedTrustProps = trustProps
} else {
transformedTrustProps = strings.Clone(trustProps)
var trustPropName string
var searchQS string
for _, trustPropNameMatches := range trustPropNamesMatches { for _, curTrustPropNameMatches := range trustPropNamesMatches {
trustPropName = trustPropNameMatches[1] trustPropName = curTrustPropNameMatches[1]
searchQS = strings.ReplaceAll(trustPropName, " ", "+") searchQS = strings.ReplaceAll(trustPropName, " ", "+")
trustPropSubstitutionPattern := fmt.Sprintf( trustPropSubstitutionPattern := fmt.Sprintf(
`- [ ] %s [найти](/explore/%s?tab=&q=%s)`, `- [ ] %s [найти](/explore/%s?tab=&q=%s)`,
trustPropName, trustPropName,
strings.ToLower(fieldName), strings.ToLower(fieldName),
searchQS) searchQS)
trustPropsWithSafeURLs = strings.Replace(trustPropsWithSafeURLs, trustPropNameMatches[0], trustPropSubstitutionPattern, -1) transformedTrustProps = strings.Replace(transformedTrustProps, curTrustPropNameMatches[0], trustPropSubstitutionPattern, -1)
}
} }
var renderedTrustPropsWithSafeURLs string var renderedTrustPropsWithSafeURLs string
renderedTrustPropsWithSafeURLs, err = user.GetRenderedTextFieldByValue(ctx, repo, trustPropsWithSafeURLs) renderedTrustPropsWithSafeURLs, err = user.GetRenderedTextFieldByValue(ctx, repo, transformedTrustProps)
renderedTrustPropsWithTargetBlank := strings.ReplaceAll(renderedTrustPropsWithSafeURLs, "<a", "<a target='blank'") renderedTrustPropsWithTargetBlank := strings.ReplaceAll(renderedTrustPropsWithSafeURLs, "<a", "<a target='blank'")
return renderedTrustPropsWithTargetBlank, err return renderedTrustPropsWithTargetBlank, err
} }

4
services/forms/repo_form.go

@ -115,8 +115,8 @@ func ParseRemoteAddr(remoteAddr, authUsername, authPassword string) (string, err
type RepoSettingForm struct { type RepoSettingForm struct {
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"` RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
Description string `binding:"MaxSize(255)"` Description string `binding:"MaxSize(255)"`
Resources string `binding:"MaxSize(1024)"` Resources string
Competences string `binding:"MaxSize(1024)"` Competences string
Website string `binding:"ValidUrl;MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"`
LocationCoordinates string `binding:"MaxSize(1024)"` LocationCoordinates string `binding:"MaxSize(1024)"`
Interval string Interval string

Loading…
Cancel
Save