From d8a9c5e12b18cb99f5f4e798ee00f43e8db32722 Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Tue, 20 Sep 2022 19:09:37 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=BE=20=D0=BE?= =?UTF-8?q?=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B5=D1=82=D0=B5?= =?UTF-8?q?=D0=BD=D1=86=D0=B8=D0=B9=20=D0=B8=20=D1=80=D0=B5=D1=81=D1=83?= =?UTF-8?q?=D1=80=D1=81=D0=BE=D0=B2=20=20#65=20#120?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit исправлен баг, что НЕ выводилось содержимое доверительного свойства, если нет ни одной галочки. Если нет галочек, значит, и доверительных свойств нет. Но пользователю это непонятно. Поэтому принято пока такое архитектурное решение, выводить содержимое без галочек. --- routers/web/repo/resource.go | 34 ++++++++++++++++++---------------- services/forms/repo_form.go | 4 ++-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/routers/web/repo/resource.go b/routers/web/repo/resource.go index 2499cc0d04..bcf7f76595 100644 --- a/routers/web/repo/resource.go +++ b/routers/web/repo/resource.go @@ -41,28 +41,30 @@ func GetRenderedTrustPropsWithSearchLinks(ctx *context.Context, repo interface{} } trustPropNamesMatches := regExp.FindAllStringSubmatch(trustProps, -1) - if trustPropNamesMatches == nil { - return "", err - } - var trustPropsWithSafeURLs = strings.Clone(trustProps) - var trustPropName string - var searchQS string + var transformedTrustProps string + if trustPropNamesMatches == nil { + transformedTrustProps = trustProps + } else { + transformedTrustProps = strings.Clone(trustProps) + var trustPropName string + var searchQS string - for _, trustPropNameMatches := range trustPropNamesMatches { - trustPropName = trustPropNameMatches[1] - searchQS = strings.ReplaceAll(trustPropName, " ", "+") - trustPropSubstitutionPattern := fmt.Sprintf( - `- [ ] %s [найти](/explore/%s?tab=&q=%s)`, - trustPropName, - strings.ToLower(fieldName), - searchQS) + for _, curTrustPropNameMatches := range trustPropNamesMatches { + trustPropName = curTrustPropNameMatches[1] + searchQS = strings.ReplaceAll(trustPropName, " ", "+") + trustPropSubstitutionPattern := fmt.Sprintf( + `- [ ] %s [найти](/explore/%s?tab=&q=%s)`, + trustPropName, + strings.ToLower(fieldName), + searchQS) - trustPropsWithSafeURLs = strings.Replace(trustPropsWithSafeURLs, trustPropNameMatches[0], trustPropSubstitutionPattern, -1) + transformedTrustProps = strings.Replace(transformedTrustProps, curTrustPropNameMatches[0], trustPropSubstitutionPattern, -1) + } } var renderedTrustPropsWithSafeURLs string - renderedTrustPropsWithSafeURLs, err = user.GetRenderedTextFieldByValue(ctx, repo, trustPropsWithSafeURLs) + renderedTrustPropsWithSafeURLs, err = user.GetRenderedTextFieldByValue(ctx, repo, transformedTrustProps) renderedTrustPropsWithTargetBlank := strings.ReplaceAll(renderedTrustPropsWithSafeURLs, "