mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
eea13b713d
commit
ee95f9bf6f
3 changed files with 61 additions and 46 deletions
|
|
@ -1039,8 +1039,14 @@ const renderRollup = (cellValue: IAVCellValue) => {
|
||||||
}
|
}
|
||||||
} else if (cellValue.type === "number") {
|
} else if (cellValue.type === "number") {
|
||||||
text = cellValue?.number.formattedContent || cellValue?.number.content.toString() || "";
|
text = cellValue?.number.formattedContent || cellValue?.number.content.toString() || "";
|
||||||
} else if (cellValue.type === "date") {
|
} else if (["date", "updated", "created"].includes(cellValue.type)) {
|
||||||
const dataValue = cellValue ? cellValue.date : null;
|
let dataValue = cellValue ? cellValue.date : null;
|
||||||
|
if (!dataValue) {
|
||||||
|
dataValue = cellValue.updated;
|
||||||
|
}
|
||||||
|
if (!dataValue) {
|
||||||
|
dataValue = cellValue.created;
|
||||||
|
}
|
||||||
if (dataValue.formattedContent) {
|
if (dataValue.formattedContent) {
|
||||||
text = dataValue.formattedContent;
|
text = dataValue.formattedContent;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1194,7 +1194,7 @@ func SearchAttributeViewNonRelationKey(avID, keyword string) (ret []*av.Key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, keyValues := range attrView.KeyValues {
|
for _, keyValues := range attrView.KeyValues {
|
||||||
if av.KeyTypeRelation != keyValues.Key.Type && av.KeyTypeRollup != keyValues.Key.Type && av.KeyTypeCreated != keyValues.Key.Type && av.KeyTypeUpdated != keyValues.Key.Type && av.KeyTypeLineNumber != keyValues.Key.Type {
|
if av.KeyTypeRelation != keyValues.Key.Type && av.KeyTypeRollup != keyValues.Key.Type && av.KeyTypeLineNumber != keyValues.Key.Type {
|
||||||
if strings.Contains(strings.ToLower(keyValues.Key.Name), strings.ToLower(keyword)) {
|
if strings.Contains(strings.ToLower(keyValues.Key.Name), strings.ToLower(keyword)) {
|
||||||
ret = append(ret, keyValues.Key)
|
ret = append(ret, keyValues.Key)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,6 +350,58 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case av.KeyTypeCreated: // 渲染创建时间
|
||||||
|
ial := map[string]string{}
|
||||||
|
block := item.GetBlockValue()
|
||||||
|
if nil != block {
|
||||||
|
ial = ials[block.Block.ID]
|
||||||
|
}
|
||||||
|
if nil == ial {
|
||||||
|
ial = map[string]string{}
|
||||||
|
}
|
||||||
|
id := itemID
|
||||||
|
if "" != ial["id"] {
|
||||||
|
id = ial["id"]
|
||||||
|
}
|
||||||
|
createdStr := id[:len("20060102150405")]
|
||||||
|
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
||||||
|
if nil == parseErr {
|
||||||
|
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
|
||||||
|
value.Created.IsNotEmpty = true
|
||||||
|
} else {
|
||||||
|
value.Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
|
||||||
|
}
|
||||||
|
case av.KeyTypeUpdated: // 渲染更新时间
|
||||||
|
ial := map[string]string{}
|
||||||
|
block := item.GetBlockValue()
|
||||||
|
if nil != block {
|
||||||
|
ial = ials[block.Block.ID]
|
||||||
|
}
|
||||||
|
if nil == ial {
|
||||||
|
ial = map[string]string{}
|
||||||
|
}
|
||||||
|
updatedStr := ial["updated"]
|
||||||
|
if "" == updatedStr && nil != block {
|
||||||
|
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
||||||
|
value.Updated.IsNotEmpty = true
|
||||||
|
} else {
|
||||||
|
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
|
||||||
|
if nil == parseErr {
|
||||||
|
value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
|
||||||
|
value.Updated.IsNotEmpty = true
|
||||||
|
} else {
|
||||||
|
value.Updated = av.NewFormattedValueUpdated(time.Now().UnixMilli(), 0, av.UpdatedFormatNone)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range collection.GetItems() {
|
||||||
|
for _, value := range item.GetValues() {
|
||||||
|
itemID := item.GetID()
|
||||||
|
|
||||||
|
switch value.Type {
|
||||||
case av.KeyTypeRollup: // 渲染汇总
|
case av.KeyTypeRollup: // 渲染汇总
|
||||||
rollupKey, _ := attrView.GetKey(value.KeyID)
|
rollupKey, _ := attrView.GetKey(value.KeyID)
|
||||||
if nil == rollupKey || nil == rollupKey.Rollup {
|
if nil == rollupKey || nil == rollupKey.Rollup {
|
||||||
|
|
@ -421,49 +473,6 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case av.KeyTypeCreated: // 渲染创建时间
|
|
||||||
ial := map[string]string{}
|
|
||||||
block := item.GetBlockValue()
|
|
||||||
if nil != block {
|
|
||||||
ial = ials[block.Block.ID]
|
|
||||||
}
|
|
||||||
if nil == ial {
|
|
||||||
ial = map[string]string{}
|
|
||||||
}
|
|
||||||
id := itemID
|
|
||||||
if "" != ial["id"] {
|
|
||||||
id = ial["id"]
|
|
||||||
}
|
|
||||||
createdStr := id[:len("20060102150405")]
|
|
||||||
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
|
|
||||||
if nil == parseErr {
|
|
||||||
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
|
|
||||||
value.Created.IsNotEmpty = true
|
|
||||||
} else {
|
|
||||||
value.Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
|
|
||||||
}
|
|
||||||
case av.KeyTypeUpdated: // 渲染更新时间
|
|
||||||
ial := map[string]string{}
|
|
||||||
block := item.GetBlockValue()
|
|
||||||
if nil != block {
|
|
||||||
ial = ials[block.Block.ID]
|
|
||||||
}
|
|
||||||
if nil == ial {
|
|
||||||
ial = map[string]string{}
|
|
||||||
}
|
|
||||||
updatedStr := ial["updated"]
|
|
||||||
if "" == updatedStr && nil != block {
|
|
||||||
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
|
|
||||||
value.Updated.IsNotEmpty = true
|
|
||||||
} else {
|
|
||||||
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
|
|
||||||
if nil == parseErr {
|
|
||||||
value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
|
|
||||||
value.Updated.IsNotEmpty = true
|
|
||||||
} else {
|
|
||||||
value.Updated = av.NewFormattedValueUpdated(time.Now().UnixMilli(), 0, av.UpdatedFormatNone)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue