Browse Source

:art: Improve database table view

Daniel 1 year ago
parent
commit
2843350737
3 changed files with 8 additions and 10 deletions
  1. 1 1
      kernel/av/table.go
  2. 4 5
      kernel/model/attribute_view.go
  3. 3 4
      kernel/treenode/node.go

+ 1 - 1
kernel/av/table.go

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

+ 4 - 5
kernel/model/attribute_view.go

@@ -589,7 +589,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
 				keyValues := rows[row.ID]
 				keyValues := rows[row.ID]
 				ial := map[string]string{}
 				ial := map[string]string{}
 				block := row.GetBlockValue()
 				block := row.GetBlockValue()
-				if !block.IsDetached {
+				if nil != block && !block.IsDetached {
 					ial = GetBlockAttrsWithoutWaitWriting(row.ID)
 					ial = GetBlockAttrsWithoutWaitWriting(row.ID)
 				}
 				}
 				content := renderTemplateCol(ial, cell.Value.Template.Content, keyValues)
 				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: // 渲染更新时间
 			case av.KeyTypeUpdated: // 渲染更新时间
 				ial := map[string]string{}
 				ial := map[string]string{}
 				block := row.GetBlockValue()
 				block := row.GetBlockValue()
-				if !block.IsDetached {
+				if nil != block && !block.IsDetached {
 					ial = GetBlockAttrsWithoutWaitWriting(row.ID)
 					ial = GetBlockAttrsWithoutWaitWriting(row.ID)
 				}
 				}
 				updatedStr := ial["updated"]
 				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 = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
 					cell.Value.Updated.IsNotEmpty = true
 					cell.Value.Updated.IsNotEmpty = true
 				} else {
 				} else {
@@ -1184,7 +1183,7 @@ func GetLastSortRow(rows []*av.TableRow) *av.TableRow {
 	for i := len(rows) - 1; i >= 0; i-- {
 	for i := len(rows) - 1; i >= 0; i-- {
 		row := rows[i]
 		row := rows[i]
 		block := row.GetBlockValue()
 		block := row.GetBlockValue()
-		if !block.NotAffectFilter() {
+		if nil != block && !block.NotAffectFilter() {
 			return row
 			return row
 		}
 		}
 	}
 	}

+ 3 - 4
kernel/treenode/node.go

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