Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-09-06 10:22:29 +08:00
commit 4767e399e2
5 changed files with 18 additions and 16 deletions

View file

@ -104,6 +104,10 @@ export const objEquals = (a: any, b: any): boolean => {
}; };
export const duplicateNameAddOne = (name:string) => { export const duplicateNameAddOne = (name:string) => {
if (!name) {
return "";
}
const nameMatch = name.match(/^(.*) \((\d+)\)$/); const nameMatch = name.match(/^(.*) \((\d+)\)$/);
if (nameMatch) { if (nameMatch) {
name = `${nameMatch[1]} (${parseInt(nameMatch[2]) + 1})`; name = `${nameMatch[1]} (${parseInt(nameMatch[2]) + 1})`;

View file

@ -193,19 +193,8 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s
switch filter.Qualifier { switch filter.Qualifier {
case FilterQuantifierUndefined, FilterQuantifierAny: case FilterQuantifierUndefined, FilterQuantifierAny:
for _, content := range value.Rollup.Contents { for _, content := range value.Rollup.Contents {
switch filter.Operator { if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
case FilterOperatorContains: return true
if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
return true
}
case FilterOperatorDoesNotContain:
if !content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
return false
}
default:
if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
return true
}
} }
} }
case FilterQuantifierAll: case FilterQuantifierAll:

View file

@ -1094,7 +1094,9 @@ func DuplicateDatabaseBlock(avID string) (newAvID, newBlockID string, err error)
return return
} }
newAv.Name = oldAv.Name + " (Duplicated " + time.Now().Format("2006-01-02 15:04:05") + ")" if "" != newAv.Name {
newAv.Name = oldAv.Name + " (Duplicated " + time.Now().Format("2006-01-02 15:04:05") + ")"
}
for _, keyValues := range newAv.KeyValues { for _, keyValues := range newAv.KeyValues {
if nil != keyValues.Key.Relation && keyValues.Key.Relation.IsTwoWay { if nil != keyValues.Key.Relation && keyValues.Key.Relation.IsTwoWay {

View file

@ -43,7 +43,7 @@ import (
func resetTree(tree *parse.Tree, titleSuffix string, removeAvBinding bool) { func resetTree(tree *parse.Tree, titleSuffix string, removeAvBinding bool) {
tree.ID = ast.NewNodeID() tree.ID = ast.NewNodeID()
tree.Root.ID = tree.ID tree.Root.ID = tree.ID
title := tree.Root.IALAttr("title")
if "" != titleSuffix { if "" != titleSuffix {
if t, parseErr := time.Parse("20060102150405", util.TimeFromID(tree.ID)); nil == parseErr { if t, parseErr := time.Parse("20060102150405", util.TimeFromID(tree.ID)); nil == parseErr {
titleSuffix += " " + t.Format("2006-01-02 15:04:05") titleSuffix += " " + t.Format("2006-01-02 15:04:05")
@ -52,9 +52,12 @@ func resetTree(tree *parse.Tree, titleSuffix string, removeAvBinding bool) {
} }
titleSuffix = "(" + titleSuffix + ")" titleSuffix = "(" + titleSuffix + ")"
titleSuffix = " " + titleSuffix titleSuffix = " " + titleSuffix
if Conf.language(16) == title {
titleSuffix = ""
}
} }
tree.Root.SetIALAttr("id", tree.ID) tree.Root.SetIALAttr("id", tree.ID)
tree.Root.SetIALAttr("title", tree.Root.IALAttr("title")+titleSuffix) tree.Root.SetIALAttr("title", title+titleSuffix)
tree.Root.RemoveIALAttr("scroll") tree.Root.RemoveIALAttr("scroll")
p := path.Join(path.Dir(tree.Path), tree.ID) + ".sy" p := path.Join(path.Dir(tree.Path), tree.ID) + ".sy"
tree.Path = p tree.Path = p

View file

@ -34,6 +34,10 @@ func init() {
} }
func GetDuplicateName(master string) (ret string) { func GetDuplicateName(master string) (ret string) {
if "" == master {
return
}
ret = master + " (1)" ret = master + " (1)"
r := regexp.MustCompile("^(.*) \\((\\d+)\\)$") r := regexp.MustCompile("^(.*) \\((\\d+)\\)$")
m := r.FindStringSubmatch(master) m := r.FindStringSubmatch(master)