Skip to content

GO-3938 Add includeTime relation #2356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/block/editor/smartblock/detailsinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ func (sb *smartBlock) injectDerivedDetails(s *state.State, spaceID string, sbt s
sb.injectLinksDetails(s)
sb.injectMentions(s)
sb.updateBackLinks(s)

sb.deriveIncludeTime(s)
}

func (sb *smartBlock) deriveChatId(s *state.State) error {
Expand All @@ -219,6 +221,21 @@ func (sb *smartBlock) deriveChatId(s *state.State) error {
return nil
}

func (sb *smartBlock) deriveIncludeTime(s *state.State) {
if sb.Type() != smartblock.SmartBlockTypeRelation {
return
}
if s.Details().GetInt64(bundle.RelationKeyRelationFormat) != int64(model.RelationFormat_date) {
return
}
if s.LocalDetails().Has(bundle.RelationKeyIncludeTime) {
return
}
if bundle.IsSystemRelation(domain.RelationKey(s.Details().GetString(bundle.RelationKeyRelationKey))) {
s.SetDetailAndBundledRelation(bundle.RelationKeyIncludeTime, domain.Bool(true))
}
}

// resolveLayout adds resolvedLayout to local details of object. Priority:
// layout > recommendedLayout from type > current resolvedLayout > basic (fallback)
// resolveLayout also converts object from Note, i.e. adds Name and Title to state
Expand Down
16 changes: 15 additions & 1 deletion pkg/lib/bundle/relation.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
)

const RelationChecksum = "62a158a458a241cdf5b502bad800a109a8917ab9026826dd1274262c46b1f839"
const RelationChecksum = "7a2c93ce65a98c55d3b977eaf06de8cc5a40bacd68974a3bb1964b688038616a"
const (
RelationKeyTag domain.RelationKey = "tag"
RelationKeyCamera domain.RelationKey = "camera"
Expand Down Expand Up @@ -160,6 +160,7 @@ const (
RelationKeyAutoWidgetTargets domain.RelationKey = "autoWidgetTargets"
RelationKeyAutoWidgetDisabled domain.RelationKey = "autoWidgetDisabled"
RelationKeyPluralName domain.RelationKey = "pluralName"
RelationKeyIncludeTime domain.RelationKey = "includeTime"
)

var (
Expand Down Expand Up @@ -898,6 +899,19 @@ var (
ReadOnlyRelation: true,
Scope: model.Relation_type,
},
RelationKeyIncludeTime: {

DataSource: model.Relation_local,
Description: "Should time be shown for relation values with date format",
Format: model.RelationFormat_checkbox,
Hidden: true,
Id: "_brincludeTime",
Key: "includeTime",
Name: "IncludeTime",
ReadOnly: false,
ReadOnlyRelation: true,
Scope: model.Relation_type,
},
RelationKeyIngredients: {

DataSource: model.Relation_details,
Expand Down
10 changes: 10 additions & 0 deletions pkg/lib/bundle/relations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1535,5 +1535,15 @@
"name": "Plural name",
"readonly": false,
"source": "details"
},
{
"description": "Should time be shown for relation values with date format",
"format": "checkbox",
"hidden": true,
"key": "includeTime",
"maxCount": 0,
"name": "IncludeTime",
"readonly": false,
"source": "local"
}
]
Loading