|
@@ -605,10 +605,29 @@ func renderAttributeView(attrView *av.AttributeView, viewID string, page, pageSi
|
|
|
}
|
|
|
}
|
|
|
if 0 == v.Block.Updated {
|
|
|
- v.Block.Updated = currentTimeMillis
|
|
|
+ v.Block.Updated = v.Block.Created
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 补全值的创建时间和更新时间
|
|
|
+ for _, v := range kv.Values {
|
|
|
+ if "" == v.ID {
|
|
|
+ v.ID = ast.NewNodeID()
|
|
|
+ }
|
|
|
+
|
|
|
+ createdStr := v.ID[:len("20060102150405")]
|
|
|
+ created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
|
|
+ if nil == parseErr {
|
|
|
+ v.CreatedAt = created.UnixMilli()
|
|
|
+ } else {
|
|
|
+ v.CreatedAt = currentTimeMillis
|
|
|
+ }
|
|
|
+
|
|
|
+ if 0 == v.UpdatedAt {
|
|
|
+ v.UpdatedAt = v.CreatedAt
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
switch view.LayoutType {
|
|
@@ -1698,78 +1717,35 @@ func addAttributeViewBlock(avID, previousBlockID, blockID string, isDetached boo
|
|
|
content = getNodeRefText(node)
|
|
|
}
|
|
|
now := time.Now().UnixMilli()
|
|
|
- blockValue := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, IsDetached: isDetached, Block: &av.ValueBlock{ID: blockID, Content: content, Created: now, Updated: now}}
|
|
|
+ blockValue := &av.Value{
|
|
|
+ ID: ast.NewNodeID(),
|
|
|
+ KeyID: blockValues.Key.ID,
|
|
|
+ BlockID: blockID,
|
|
|
+ Type: av.KeyTypeBlock,
|
|
|
+ IsDetached: isDetached,
|
|
|
+ CreatedAt: now,
|
|
|
+ UpdatedAt: now,
|
|
|
+ Block: &av.ValueBlock{ID: blockID, Content: content, Created: now, Updated: now}}
|
|
|
blockValues.Values = append(blockValues.Values, blockValue)
|
|
|
|
|
|
- // 如果存在排序和过滤条件,则将排序和过滤条件应用到新添加的块上
|
|
|
+ // 如果存在过滤条件,则将过滤条件应用到新添加的块上
|
|
|
view, _ := attrView.GetCurrentView()
|
|
|
if nil != view && (0 < len(view.Table.Filters) || 0 < len(view.Table.Sorts)) {
|
|
|
viewable, _ := renderAttributeViewTable(attrView, view)
|
|
|
viewable.FilterRows(attrView)
|
|
|
- viewable.SortRows()
|
|
|
|
|
|
- affectKeyIDs := map[string]bool{}
|
|
|
- for _, f := range view.Table.Filters {
|
|
|
- affectKeyIDs[f.Column] = true
|
|
|
- }
|
|
|
- for _, s := range view.Table.Sorts {
|
|
|
- affectKeyIDs[s.Column] = true
|
|
|
- }
|
|
|
-
|
|
|
- addedValues := map[string]bool{}
|
|
|
- if 0 < len(viewable.Rows) {
|
|
|
- row := GetLastSortRow(viewable.Rows)
|
|
|
- if nil != row {
|
|
|
- for affectKeyID := range affectKeyIDs {
|
|
|
- for _, cell := range row.Cells {
|
|
|
- if nil != cell.Value && cell.Value.KeyID == affectKeyID {
|
|
|
- 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 = isDetached
|
|
|
- values, _ := attrView.GetKeyValues(affectKeyID)
|
|
|
- values.Values = append(values.Values, newValue)
|
|
|
- addedValues[affectKeyID] = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- notAddedValues := map[string]bool{}
|
|
|
- for affectKeyID := range affectKeyIDs {
|
|
|
- if !addedValues[affectKeyID] {
|
|
|
- notAddedValues[affectKeyID] = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if 0 < len(notAddedValues) {
|
|
|
- for _, filter := range view.Table.Filters {
|
|
|
- if !notAddedValues[filter.Column] {
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- for _, keyValues := range attrView.KeyValues {
|
|
|
- if keyValues.Key.ID == filter.Column {
|
|
|
- newValue := filter.GetAffectValue(keyValues.Key)
|
|
|
- newValue.ID = ast.NewNodeID()
|
|
|
- newValue.KeyID = keyValues.Key.ID
|
|
|
- newValue.BlockID = blockID
|
|
|
- newValue.IsDetached = isDetached
|
|
|
- keyValues.Values = append(keyValues.Values, newValue)
|
|
|
- break
|
|
|
- }
|
|
|
+ for _, filter := range view.Table.Filters {
|
|
|
+ for _, keyValues := range attrView.KeyValues {
|
|
|
+ if keyValues.Key.ID == filter.Column {
|
|
|
+ newValue := filter.GetAffectValue(keyValues.Key)
|
|
|
+ newValue.ID = ast.NewNodeID()
|
|
|
+ newValue.KeyID = keyValues.Key.ID
|
|
|
+ newValue.BlockID = blockID
|
|
|
+ newValue.IsDetached = isDetached
|
|
|
+ keyValues.Values = append(keyValues.Values, newValue)
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 仅使用上面的过滤条件计算受影响的值并插入兜底,受影响的排序条件不进行计算值插入
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1826,8 +1802,7 @@ func GetLastSortRow(rows []*av.TableRow) *av.TableRow {
|
|
|
row := rows[i]
|
|
|
blockVal := row.GetBlockValue()
|
|
|
if nil != blockVal {
|
|
|
- if nil != blockVal.Block && blockVal.Block.Created == blockVal.Block.Updated {
|
|
|
- // 说明是刚刚创建的块,跳过
|
|
|
+ if !blockVal.IsEdited() {
|
|
|
continue
|
|
|
}
|
|
|
return row
|