Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 11, 2023
2 parents c1de5e1 + ccb6545 commit 30b0dd0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
46 changes: 43 additions & 3 deletions kernel/av/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func (value *Value) Compare(other *Value) int {
}

func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool {
if nil == value || nil == other {
return false
if nil == other {
return true
}

if nil != value.Block && nil != other.Block {
Expand All @@ -193,16 +193,34 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
if nil != value.Text && nil != other.Text {
switch operator {
case FilterOperatorIsEqual:
if "" == strings.TrimSpace(other.Text.Content) {
return true
}
return value.Text.Content == other.Text.Content
case FilterOperatorIsNotEqual:
if "" == strings.TrimSpace(other.Text.Content) {
return true
}
return value.Text.Content != other.Text.Content
case FilterOperatorContains:
if "" == strings.TrimSpace(other.Text.Content) {
return true
}
return strings.Contains(value.Text.Content, other.Text.Content)
case FilterOperatorDoesNotContain:
if "" == strings.TrimSpace(other.Text.Content) {
return true
}
return !strings.Contains(value.Text.Content, other.Text.Content)
case FilterOperatorStartsWith:
if "" == strings.TrimSpace(other.Text.Content) {
return true
}
return strings.HasPrefix(value.Text.Content, other.Text.Content)
case FilterOperatorEndsWith:
if "" == strings.TrimSpace(other.Text.Content) {
return true
}
return strings.HasSuffix(value.Text.Content, other.Text.Content)
case FilterOperatorIsEmpty:
return "" == strings.TrimSpace(value.Text.Content)
Expand All @@ -214,8 +232,14 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
if nil != value.Number && nil != other.Number {
switch operator {
case FilterOperatorIsEqual:
if !other.Number.IsNotEmpty {
return true
}
return value.Number.Content == other.Number.Content
case FilterOperatorIsNotEqual:
if !other.Number.IsNotEmpty {
return true
}
return value.Number.Content != other.Number.Content
case FilterOperatorIsGreater:
return value.Number.Content > other.Number.Content
Expand All @@ -235,8 +259,14 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
if nil != value.Date && nil != other.Date {
switch operator {
case FilterOperatorIsEqual:
if !other.Date.IsNotEmpty {
return true
}
return value.Date.Content == other.Date.Content
case FilterOperatorIsNotEqual:
if !other.Date.IsNotEmpty {
return true
}
return value.Date.Content != other.Date.Content
case FilterOperatorIsGreater:
return value.Date.Content > other.Date.Content
Expand Down Expand Up @@ -541,7 +571,17 @@ func (table *Table) FilterRows() {
for _, row := range table.Rows {
pass := true
for j, index := range colIndexes {
if !row.Cells[index].Value.CompareOperator(table.Filters[j].Value, table.Filters[j].Operator) {
operator := table.Filters[j].Operator

if nil == row.Cells[index].Value {
switch operator {
case FilterOperatorIsNotEmpty:
pass = false
}
break
}

if !row.Cells[index].Value.CompareOperator(table.Filters[j].Value, operator) {
pass = false
break
}
Expand Down
9 changes: 9 additions & 0 deletions kernel/model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,15 @@ func RenameAsset(oldPath, newName string) (err error) {
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
return
}

if gulu.File.IsExist(filepath.Join(util.DataDir, oldPath+".sya")) {
// Rename the .sya annotation file when renaming a PDF asset https://github.com/siyuan-note/siyuan/issues/9390
if err = filelock.Copy(filepath.Join(util.DataDir, oldPath+".sya"), filepath.Join(util.DataDir, newPath+".sya")); nil != err {
logging.LogErrorf("copy PDF annotation [%s] failed: %s", oldPath+".sya", err)
return
}
}

oldName := path.Base(oldPath)

notebooks, err := ListNotebooks()
Expand Down
12 changes: 10 additions & 2 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,16 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
bindBlockAv(tx, avID, rowID)
}

if nil != val.Block {
val.Block.Updated = time.Now().UnixMilli()
for _, kv := range attrView.KeyValues {
if av.KeyTypeBlock == kv.Key.Type {
for _, v := range kv.Values {
if rowID == v.Block.ID {
v.Block.Updated = time.Now().UnixMilli()
break
}
}
break
}
}

if err = av.SaveAttributeView(attrView); nil != err {
Expand Down

0 comments on commit 30b0dd0

Please sign in to comment.