mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
🎨 Adding row overwriting data after enabling filter in database https://github.com/siyuan-note/siyuan/issues/9395
This commit is contained in:
parent
210a3ac547
commit
65adab61c9
3 changed files with 25 additions and 17 deletions
|
|
@ -99,11 +99,12 @@ type KeySelectOption struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Value struct {
|
type Value struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
KeyID string `json:"keyID,omitempty"`
|
KeyID string `json:"keyID,omitempty"`
|
||||||
BlockID string `json:"blockID,omitempty"`
|
BlockID string `json:"blockID,omitempty"`
|
||||||
Type KeyType `json:"type,omitempty"`
|
Type KeyType `json:"type,omitempty"`
|
||||||
IsDetached bool `json:"isDetached,omitempty"`
|
IsDetached bool `json:"isDetached,omitempty"`
|
||||||
|
IsInitialized bool `json:"isInitialized,omitempty"`
|
||||||
|
|
||||||
Block *ValueBlock `json:"block,omitempty"`
|
Block *ValueBlock `json:"block,omitempty"`
|
||||||
Text *ValueText `json:"text,omitempty"`
|
Text *ValueText `json:"text,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -508,6 +508,16 @@ type TableRow struct {
|
||||||
Cells []*TableCell `json:"cells"`
|
Cells []*TableCell `json:"cells"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (row *TableRow) GetBlockValue() (ret *Value) {
|
||||||
|
for _, cell := range row.Cells {
|
||||||
|
if KeyTypeBlock == cell.ValueType {
|
||||||
|
ret = cell.Value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (table *Table) GetType() LayoutType {
|
func (table *Table) GetType() LayoutType {
|
||||||
return LayoutTypeTable
|
return LayoutTypeTable
|
||||||
}
|
}
|
||||||
|
|
@ -569,6 +579,12 @@ func (table *Table) FilterRows() {
|
||||||
|
|
||||||
rows := []*TableRow{}
|
rows := []*TableRow{}
|
||||||
for _, row := range table.Rows {
|
for _, row := range table.Rows {
|
||||||
|
block := row.GetBlockValue()
|
||||||
|
if !block.IsInitialized && nil != block.Block && "" == block.Block.Content && block.IsDetached {
|
||||||
|
rows = append(rows, row)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
pass := true
|
pass := true
|
||||||
for j, index := range colIndexes {
|
for j, index := range colIndexes {
|
||||||
operator := table.Filters[j].Operator
|
operator := table.Filters[j].Operator
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
||||||
ial := GetBlockAttrs(row.ID)
|
ial := GetBlockAttrs(row.ID)
|
||||||
updatedStr := ial["updated"]
|
updatedStr := ial["updated"]
|
||||||
if "" == updatedStr {
|
if "" == updatedStr {
|
||||||
block := getTableRowBlockValue(row)
|
block := row.GetBlockValue()
|
||||||
cell.Value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
cell.Value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
||||||
cell.Value.Updated.IsNotEmpty = true
|
cell.Value.Updated.IsNotEmpty = true
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -475,16 +475,6 @@ func getRowBlockValue(keyValues []*av.KeyValues) (ret *av.Value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTableRowBlockValue(row *av.TableRow) (ret *av.Value) {
|
|
||||||
for _, cell := range row.Cells {
|
|
||||||
if av.KeyTypeBlock == cell.ValueType {
|
|
||||||
ret = cell.Value
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tx *Transaction) doSetAttrViewName(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doSetAttrViewName(operation *Operation) (ret *TxErr) {
|
||||||
err := setAttributeViewName(operation)
|
err := setAttributeViewName(operation)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
@ -693,7 +683,7 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
|
||||||
content = getNodeRefText(node)
|
content = getNodeRefText(node)
|
||||||
}
|
}
|
||||||
now := time.Now().UnixMilli()
|
now := time.Now().UnixMilli()
|
||||||
value := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, IsDetached: operation.IsDetached, Block: &av.ValueBlock{ID: blockID, Content: content, Created: now, Updated: now}}
|
value := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, IsDetached: operation.IsDetached, IsInitialized: false, Block: &av.ValueBlock{ID: blockID, Content: content, Created: now, Updated: now}}
|
||||||
blockValues.Values = append(blockValues.Values, value)
|
blockValues.Values = append(blockValues.Values, value)
|
||||||
|
|
||||||
if !operation.IsDetached {
|
if !operation.IsDetached {
|
||||||
|
|
@ -1301,6 +1291,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
|
||||||
for _, v := range kv.Values {
|
for _, v := range kv.Values {
|
||||||
if rowID == v.Block.ID {
|
if rowID == v.Block.ID {
|
||||||
v.Block.Updated = time.Now().UnixMilli()
|
v.Block.Updated = time.Now().UnixMilli()
|
||||||
|
v.IsInitialized = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue