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

This commit is contained in:
Vanessa 2023-12-18 22:38:08 +08:00
commit 91f7d00730
4 changed files with 39 additions and 24 deletions

View file

@ -727,7 +727,7 @@ func (table *Table) FilterRows() {
rows := []*TableRow{}
for _, row := range table.Rows {
block := row.GetBlockValue()
if !block.IsInitialized && nil != block.Block && "" == block.Block.Content && block.IsDetached {
if nil != block && block.NotAffectFilter() {
rows = append(rows, row)
continue
}

View file

@ -54,6 +54,10 @@ type Value struct {
Rollup *ValueRollup `json:"rollup,omitempty"`
}
func (value *Value) NotAffectFilter() bool {
return !value.IsInitialized && nil != value.Block && "" == value.Block.Content && value.IsDetached
}
func (value *Value) String() string {
switch value.Type {
case KeyTypeBlock:

View file

@ -589,7 +589,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
keyValues := rows[row.ID]
ial := map[string]string{}
block := row.GetBlockValue()
if !block.IsDetached {
if nil != block && !block.IsDetached {
ial = GetBlockAttrsWithoutWaitWriting(row.ID)
}
content := renderTemplateCol(ial, cell.Value.Template.Content, keyValues)
@ -606,12 +606,11 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
case av.KeyTypeUpdated: // 渲染更新时间
ial := map[string]string{}
block := row.GetBlockValue()
if !block.IsDetached {
if nil != block && !block.IsDetached {
ial = GetBlockAttrsWithoutWaitWriting(row.ID)
}
updatedStr := ial["updated"]
if "" == updatedStr {
block := row.GetBlockValue()
if "" == updatedStr && nil != block {
cell.Value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
cell.Value.Updated.IsNotEmpty = true
} else {
@ -1114,22 +1113,24 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
viewable.SortRows()
if 0 < len(viewable.Rows) {
row := viewable.Rows[len(viewable.Rows)-1]
for _, filter := range view.Table.Filters {
for _, cell := range row.Cells {
if nil != cell.Value && cell.Value.KeyID == filter.Column {
if av.KeyTypeBlock == cell.ValueType {
blockValue.Block.Content = cell.Value.Block.Content
continue
}
row := GetLastSortRow(viewable.Rows)
if nil != row {
for _, filter := range view.Table.Filters {
for _, cell := range row.Cells {
if nil != cell.Value && cell.Value.KeyID == filter.Column {
if av.KeyTypeBlock == cell.ValueType {
blockValue.Block.Content = cell.Value.Block.Content
continue
}
newValue := cell.Value.Clone()
newValue.ID = ast.NewNodeID()
newValue.BlockID = blockID
newValue.IsDetached = operation.IsDetached
newValue.IsInitialized = false
values, _ := attrView.GetKeyValues(filter.Column)
values.Values = append(values.Values, newValue)
newValue := cell.Value.Clone()
newValue.ID = ast.NewNodeID()
newValue.BlockID = blockID
newValue.IsDetached = operation.IsDetached
newValue.IsInitialized = false
values, _ := attrView.GetKeyValues(filter.Column)
values.Values = append(values.Values, newValue)
}
}
}
}
@ -1178,6 +1179,17 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
return
}
func GetLastSortRow(rows []*av.TableRow) *av.TableRow {
for i := len(rows) - 1; i >= 0; i-- {
row := rows[i]
block := row.GetBlockValue()
if nil != block && !block.NotAffectFilter() {
return row
}
}
return nil
}
func (tx *Transaction) doRemoveAttrViewBlock(operation *Operation) (ret *TxErr) {
err := tx.removeAttributeViewBlock(operation)
if nil != err {

View file

@ -708,7 +708,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
keyValues := rows[row.ID]
ial := map[string]string{}
block := row.GetBlockValue()
if !block.IsDetached {
if nil != block && !block.IsDetached {
ial = cache.GetBlockIAL(row.ID)
if nil == ial {
ial = map[string]string{}
@ -728,15 +728,14 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
case av.KeyTypeUpdated: // 渲染更新时间
ial := map[string]string{}
block := row.GetBlockValue()
if !block.IsDetached {
if nil != block && !block.IsDetached {
ial = cache.GetBlockIAL(row.ID)
if nil == ial {
ial = map[string]string{}
}
}
updatedStr := ial["updated"]
if "" == updatedStr {
block := row.GetBlockValue()
if "" == updatedStr && nil != block {
cell.Value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
cell.Value.Updated.IsNotEmpty = true
} else {