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

This commit is contained in:
Vanessa 2023-10-27 23:10:10 +08:00
commit d08a0fc156
3 changed files with 62 additions and 1 deletions

View file

@ -415,6 +415,8 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
tableCell.Value = &av.Value{ID: tableCell.ID, KeyID: col.ID, BlockID: rowID, Type: av.KeyTypeUpdated}
}
treenode.FillAttributeViewTableCellNilValue(tableCell, rowID, col.ID)
tableRow.Cells = append(tableRow.Cells, tableCell)
}
ret.Rows = append(ret.Rows, &tableRow)

View file

@ -182,7 +182,7 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[s
continue
}
if "" == value {
if "" == strings.TrimSpace(value) {
node.RemoveIALAttr(name)
} else {
node.SetIALAttr(name, value)

View file

@ -663,6 +663,8 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
tableCell.Value = &av.Value{ID: tableCell.ID, KeyID: col.ID, BlockID: rowID, Type: av.KeyTypeUpdated}
}
FillAttributeViewTableCellNilValue(tableCell, rowID, col.ID)
tableRow.Cells = append(tableRow.Cells, tableCell)
}
ret.Rows = append(ret.Rows, &tableRow)
@ -722,6 +724,63 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
return
}
func FillAttributeViewTableCellNilValue(tableCell *av.TableCell, rowID, colID string) {
if nil == tableCell.Value {
tableCell.Value = &av.Value{ID: tableCell.ID, KeyID: colID, BlockID: rowID, Type: tableCell.ValueType}
}
tableCell.Value.Type = tableCell.ValueType
switch tableCell.ValueType {
case av.KeyTypeText:
if nil == tableCell.Value.Text {
tableCell.Value.Text = &av.ValueText{}
}
case av.KeyTypeNumber:
if nil == tableCell.Value.Number {
tableCell.Value.Number = &av.ValueNumber{}
}
case av.KeyTypeDate:
if nil == tableCell.Value.Date {
tableCell.Value.Date = &av.ValueDate{}
}
case av.KeyTypeSelect:
if 1 > len(tableCell.Value.MSelect) {
tableCell.Value.MSelect = []*av.ValueSelect{}
}
case av.KeyTypeMSelect:
if 1 > len(tableCell.Value.MSelect) {
tableCell.Value.MSelect = []*av.ValueSelect{}
}
case av.KeyTypeURL:
if nil == tableCell.Value.URL {
tableCell.Value.URL = &av.ValueURL{}
}
case av.KeyTypeEmail:
if nil == tableCell.Value.Email {
tableCell.Value.Email = &av.ValueEmail{}
}
case av.KeyTypePhone:
if nil == tableCell.Value.Phone {
tableCell.Value.Phone = &av.ValuePhone{}
}
case av.KeyTypeMAsset:
if 1 > len(tableCell.Value.MAsset) {
tableCell.Value.MAsset = []*av.ValueAsset{}
}
case av.KeyTypeTemplate:
if nil == tableCell.Value.Template {
tableCell.Value.Template = &av.ValueTemplate{}
}
case av.KeyTypeCreated:
if nil == tableCell.Value.Created {
tableCell.Value.Created = &av.ValueCreated{}
}
case av.KeyTypeUpdated:
if nil == tableCell.Value.Updated {
tableCell.Value.Updated = &av.ValueUpdated{}
}
}
}
func renderTemplateCol(ial map[string]string, tplContent string, rowValues []*av.KeyValues) string {
if "" == ial["id"] {
block := getRowBlockValue(rowValues)