mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-08 01:38:50 +01:00
🎨 Supports multiple views for the database https://github.com/siyuan-note/siyuan/issues/9751
This commit is contained in:
parent
5b22276435
commit
e6a84f9e14
1 changed files with 11 additions and 19 deletions
|
|
@ -23,6 +23,7 @@ import (
|
|||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -747,27 +748,18 @@ func (av *AttributeView) GetBlockKey() (ret *Key) {
|
|||
return
|
||||
}
|
||||
|
||||
func (av *AttributeView) GetDuplicateViewName(masterViewName string) string {
|
||||
count := 1
|
||||
ret := masterViewName + " (" + strconv.Itoa(count) + ")"
|
||||
|
||||
existViewByName := func(name string) bool {
|
||||
for _, v := range av.Views {
|
||||
if v.Name == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
func (av *AttributeView) GetDuplicateViewName(masterViewName string) (ret string) {
|
||||
ret = masterViewName + " (1)"
|
||||
r := regexp.MustCompile("^(.*) \\((\\d+)\\)$")
|
||||
m := r.FindStringSubmatch(masterViewName)
|
||||
if nil == m || 3 > len(m) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < 32; i++ {
|
||||
if !existViewByName(ret) {
|
||||
return ret
|
||||
}
|
||||
count++
|
||||
ret = masterViewName + " (" + strconv.Itoa(count) + ")"
|
||||
}
|
||||
return ret
|
||||
num, _ := strconv.Atoi(m[2])
|
||||
num++
|
||||
ret = fmt.Sprintf("%s (%d)", m[1], num)
|
||||
return
|
||||
}
|
||||
|
||||
func GetAttributeViewDataPath(avID string) (ret string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue