Documentation
¶
Overview ¶
Package av 包含了属性视图(Attribute View)相关的实现。
Index ¶
- Constants
- Variables
- func BatchUpsertBlockRel(nodes []*ast.Node)
- func Calc(viewable Viewable, attrView *AttributeView)
- func Filter(viewable Viewable, attrView *AttributeView, ...)
- func GetAttributeViewDataPath(avID string) (ret string)
- func GetAttributeViewI18n(key string) string
- func GetAttributeViewName(avID string) (ret string, err error)
- func GetAttributeViewNameByPath(avJSONPath string) (ret string, err error)
- func GetBlockRels() (ret map[string][]string)
- func GetSrcAvIDs(destAvID string) []string
- func IsAttributeViewExist(avID string) bool
- func IsMirror(avID string) bool
- func MSelectExistOption(mSelect []*ValueSelect, opt string) bool
- func NewTableViewWithBlockKey(blockKeyID string) (view *View, blockKey, selectKey *Key)
- func RemoveAvRel(srcAvID, destAvID string)
- func RemoveBlockRel(avID, blockID string, existBlockTree func(string) bool) (ret bool)
- func Round(val float64, precision int) float64
- func RoundDown(val float64, precision int) float64
- func RoundUp(val float64, precision int) float64
- func SaveAttributeView(av *AttributeView) (err error)
- func Sort(viewable Viewable, attrView *AttributeView)
- func UpgradeSpec(av *AttributeView)
- func UpsertAvBackRel(srcAvID, destAvID string)
- func UpsertBlockRel(avID, blockID string) (ret bool)
- type AssetType
- type AttributeView
- func (av *AttributeView) Clone() (ret *AttributeView)
- func (av *AttributeView) ExistBoundBlock(nodeID string) bool
- func (av *AttributeView) GetBlockKey() (ret *Key)
- func (av *AttributeView) GetBlockKeyValues() (ret *KeyValues)
- func (av *AttributeView) GetBlockValue(itemID string) (ret *Value)
- func (av *AttributeView) GetBlockValueByBoundID(nodeID string) *Value
- func (av *AttributeView) GetCurrentView(viewID string) (ret *View, err error)
- func (av *AttributeView) GetKey(keyID string) (ret *Key, err error)
- func (av *AttributeView) GetKeyValues(keyID string) (ret *KeyValues, err error)
- func (av *AttributeView) GetValue(keyID, itemID string) (ret *Value)
- func (av *AttributeView) GetView(viewID string) (ret *View)
- type BaseField
- type BaseInstance
- func (baseInstance *BaseInstance) GetFilters() []*ViewFilter
- func (baseInstance *BaseInstance) GetGroupCalc() *GroupCalc
- func (baseInstance *BaseInstance) GetGroupHidden() int
- func (baseInstance *BaseInstance) GetID() string
- func (baseInstance *BaseInstance) GetSorts() []*ViewSort
- func (baseInstance *BaseInstance) SetGroupCalc(group *GroupCalc)
- func (baseInstance *BaseInstance) SetGroupFolded(folded bool)
- func (baseInstance *BaseInstance) SetGroupHidden(hidden int)
- func (baseInstance *BaseInstance) SetGroups(viewables []Viewable)
- type BaseInstanceField
- func (baseInstanceField *BaseInstanceField) GetCalc() *FieldCalc
- func (baseInstanceField *BaseInstanceField) GetID() string
- func (baseInstanceField *BaseInstanceField) GetNumberFormat() NumberFormat
- func (baseInstanceField *BaseInstanceField) GetType() KeyType
- func (baseInstanceField *BaseInstanceField) SetCalc(calc *FieldCalc)
- type BaseLayout
- type BaseValue
- type CalcOperator
- type CardAspectRatio
- type CardSize
- type Collection
- type CoverFrom
- type CreatedFormat
- type Date
- type DateFormat
- type Field
- type FieldCalc
- type FilterOperator
- type FilterQuantifier
- type Gallery
- func (gallery *Gallery) CountItems() int
- func (gallery *Gallery) GetField(id string) (ret Field, fieldIndex int)
- func (gallery *Gallery) GetFields() (ret []Field)
- func (gallery *Gallery) GetItems() (ret []Item)
- func (gallery *Gallery) GetType() LayoutType
- func (gallery *Gallery) GetValue(itemID, keyID string) (ret *Value)
- func (gallery *Gallery) SetItems(items []Item)
- type GalleryCard
- type GalleryField
- type GalleryFieldValue
- type GroupCalc
- type GroupMethod
- type GroupOrder
- type GroupRange
- type Item
- type Key
- type KeyType
- type KeyValues
- type LayoutGallery
- type LayoutTable
- type LayoutType
- type NumberFormat
- type Relation
- type RelativeDate
- type RelativeDateDirection
- type RelativeDateUnit
- type Rollup
- type RollupCalc
- type SelectOption
- type SortOrder
- type Table
- func (table *Table) CountItems() int
- func (table *Table) GetColumn(id string) *TableColumn
- func (table *Table) GetField(id string) (ret Field, fieldIndex int)
- func (table *Table) GetFields() (ret []Field)
- func (table *Table) GetItems() (ret []Item)
- func (*Table) GetType() LayoutType
- func (table *Table) GetValue(itemID, keyID string) (ret *Value)
- func (table *Table) SetItems(items []Item)
- type TableCell
- type TableColumn
- type TableRow
- type UpdatedFormat
- type Value
- func (value *Value) Clone() (ret *Value)
- func (value *Value) Compare(other *Value, attrView *AttributeView) int
- func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID string, ...) bool
- func (value *Value) GetValByType(typ KeyType) (ret interface{})
- func (value *Value) IsBlank() bool
- func (value *Value) IsEdited() bool
- func (value *Value) IsEmpty() bool
- func (value *Value) SetUpdatedAt(mills int64)
- func (value *Value) SetValByType(typ KeyType, val interface{})
- func (value *Value) String(format bool) string
- func (value *Value) ToJSONString() string
- type ValueAsset
- type ValueBlock
- type ValueCheckbox
- type ValueCreated
- type ValueDate
- type ValueEmail
- type ValueNumber
- type ValuePhone
- type ValueRelation
- type ValueRollup
- type ValueSelect
- type ValueTemplate
- type ValueText
- type ValueURL
- type ValueUpdated
- type View
- type ViewFilter
- type ViewGalleryCardField
- type ViewGroup
- type ViewSort
- type ViewTableColumn
- type Viewable
Constants ¶
const ( NodeAttrNameAvs = "custom-avs" // 用于标记块所属的属性视图,逗号分隔 av id NodeAttrView = "custom-sy-av-view" // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443 NodeAttrViewStaticText = "custom-sy-av-s-text" // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049 NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔 )
const ( RelativeDateUnitDay = iota RelativeDateUnitWeek RelativeDateUnitMonth RelativeDateUnitYear )
const ( RelativeDateDirectionBefore = -1 RelativeDateDirectionThis = 0 RelativeDateDirectionAfter = 1 )
const ( GroupOrderAsc = iota // 升序 GroupOrderDesc // 降序 GroupOrderMan // 手动排序 GroupOrderSelectOption // 同选择的选项排序(仅单选和多选字段适用) https://github.com/siyuan-note/siyuan/issues/15500 )
const ( AssetTypeFile = "file" AssetTypeImage = "image" )
const CheckboxCheckedStr = "√"
const (
ViewDefaultPageSize = 50 // 视图默认分页大小
)
Variables ¶
var ( ErrViewNotFound = errors.New("view not found") ErrKeyNotFound = errors.New("key not found") ErrWrongLayoutType = errors.New("wrong layout type") )
var (
AttributeViewBlocksLock = sync.Mutex{}
)
Functions ¶
func BatchUpsertBlockRel ¶
func Calc ¶
func Calc(viewable Viewable, attrView *AttributeView)
func Filter ¶
func Filter(viewable Viewable, attrView *AttributeView, rollupFurtherCollections map[string]Collection, cachedAttrViews map[string]*AttributeView)
func GetAttributeViewI18n ¶
func GetAttributeViewName ¶
func GetBlockRels ¶
func GetSrcAvIDs ¶
func IsAttributeViewExist ¶
func MSelectExistOption ¶
func MSelectExistOption(mSelect []*ValueSelect, opt string) bool
func RemoveAvRel ¶
func RemoveAvRel(srcAvID, destAvID string)
func RemoveBlockRel ¶
func SaveAttributeView ¶
func SaveAttributeView(av *AttributeView) (err error)
func Sort ¶
func Sort(viewable Viewable, attrView *AttributeView)
func UpgradeSpec ¶
func UpgradeSpec(av *AttributeView)
func UpsertAvBackRel ¶
func UpsertAvBackRel(srcAvID, destAvID string)
func UpsertBlockRel ¶
Types ¶
type AttributeView ¶
type AttributeView struct { Spec int `json:"spec"` // 格式版本 ID string `json:"id"` // 属性视图 ID Name string `json:"name"` // 属性视图名称 KeyValues []*KeyValues `json:"keyValues"` // 属性视图属性键值 KeyIDs []string `json:"keyIDs"` // 属性视图属性键 ID,用于排序 ViewID string `json:"viewID"` // 当前视图 ID Views []*View `json:"views"` // 视图 RenderedViewables map[string]Viewable `json:"-"` // 已经渲染好的视图 }
AttributeView 描述了属性视图的结构。
func NewAttributeView ¶
func NewAttributeView(id string) (ret *AttributeView)
func ParseAttributeView ¶
func ParseAttributeView(avID string) (ret *AttributeView, err error)
func (*AttributeView) Clone ¶
func (av *AttributeView) Clone() (ret *AttributeView)
func (*AttributeView) ExistBoundBlock ¶
func (av *AttributeView) ExistBoundBlock(nodeID string) bool
func (*AttributeView) GetBlockKey ¶
func (av *AttributeView) GetBlockKey() (ret *Key)
func (*AttributeView) GetBlockKeyValues ¶
func (av *AttributeView) GetBlockKeyValues() (ret *KeyValues)
func (*AttributeView) GetBlockValue ¶
func (av *AttributeView) GetBlockValue(itemID string) (ret *Value)
func (*AttributeView) GetBlockValueByBoundID ¶
func (av *AttributeView) GetBlockValueByBoundID(nodeID string) *Value
func (*AttributeView) GetCurrentView ¶
func (av *AttributeView) GetCurrentView(viewID string) (ret *View, err error)
func (*AttributeView) GetKeyValues ¶
func (av *AttributeView) GetKeyValues(keyID string) (ret *KeyValues, err error)
func (*AttributeView) GetValue ¶
func (av *AttributeView) GetValue(keyID, itemID string) (ret *Value)
func (*AttributeView) GetView ¶
func (av *AttributeView) GetView(viewID string) (ret *View)
type BaseField ¶
type BaseField struct { ID string `json:"id"` // 字段 ID Wrap bool `json:"wrap"` // 是否换行 Hidden bool `json:"hidden"` // 是否隐藏 Desc string `json:"desc,omitempty"` // 字段描述 Calc *FieldCalc `json:"calc,omitempty"` // 计算规则 }
BaseField 描述了字段的基础结构。
type BaseInstance ¶
type BaseInstance struct { ID string `json:"id"` // ID Icon string `json:"icon"` // 图标 Name string `json:"name"` // 名称 Desc string `json:"desc"` // 描述 HideAttrViewName bool `json:"hideAttrViewName"` // 是否隐藏属性视图名称 Filters []*ViewFilter `json:"filters"` // 过滤规则 Sorts []*ViewSort `json:"sorts"` // 排序规则 Group *ViewGroup `json:"group"` // 分组规则 PageSize int `json:"pageSize"` // 每页项目数 ShowIcon bool `json:"showIcon"` // 是否显示字段图标 WrapField bool `json:"wrapField"` // 是否换行字段内容 GroupKey *Key `json:"groupKey,omitempty"` // 分组字段 GroupValue *Value `json:"groupValue,omitempty"` // 分组值 Groups []Viewable `json:"groups,omitempty"` // 分组实例列表 GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则和结果 GroupFolded bool `json:"groupFolded"` // 分组是否折叠 GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏 }
BaseInstance 描述了实例的基础结构。
func NewViewBaseInstance ¶
func NewViewBaseInstance(view *View) *BaseInstance
func (*BaseInstance) GetFilters ¶
func (baseInstance *BaseInstance) GetFilters() []*ViewFilter
func (*BaseInstance) GetGroupCalc ¶
func (baseInstance *BaseInstance) GetGroupCalc() *GroupCalc
func (*BaseInstance) GetGroupHidden ¶
func (baseInstance *BaseInstance) GetGroupHidden() int
func (*BaseInstance) GetID ¶
func (baseInstance *BaseInstance) GetID() string
func (*BaseInstance) GetSorts ¶
func (baseInstance *BaseInstance) GetSorts() []*ViewSort
func (*BaseInstance) SetGroupCalc ¶
func (baseInstance *BaseInstance) SetGroupCalc(group *GroupCalc)
func (*BaseInstance) SetGroupFolded ¶
func (baseInstance *BaseInstance) SetGroupFolded(folded bool)
func (*BaseInstance) SetGroupHidden ¶
func (baseInstance *BaseInstance) SetGroupHidden(hidden int)
func (*BaseInstance) SetGroups ¶
func (baseInstance *BaseInstance) SetGroups(viewables []Viewable)
type BaseInstanceField ¶
type BaseInstanceField struct { ID string `json:"id"` // ID Name string `json:"name"` // 名称 Type KeyType `json:"type"` // 类型 Icon string `json:"icon"` // 图标 Wrap bool `json:"wrap"` // 是否换行 Hidden bool `json:"hidden"` // 是否隐藏 Desc string `json:"desc"` // 描述 Calc *FieldCalc `json:"calc"` // 计算规则和结果 Options []*SelectOption `json:"options,omitempty"` // 选项列表 NumberFormat NumberFormat `json:"numberFormat"` // 数字字段格式化 Template string `json:"template"` // 模板字段内容 Relation *Relation `json:"relation,omitempty"` // 关联字段 Rollup *Rollup `json:"rollup,omitempty"` // 汇总字段 Date *Date `json:"date,omitempty"` // 日期设置 }
BaseInstanceField 描述了实例字段的基础结构。
func (*BaseInstanceField) GetCalc ¶
func (baseInstanceField *BaseInstanceField) GetCalc() *FieldCalc
func (*BaseInstanceField) GetID ¶
func (baseInstanceField *BaseInstanceField) GetID() string
func (*BaseInstanceField) GetNumberFormat ¶
func (baseInstanceField *BaseInstanceField) GetNumberFormat() NumberFormat
func (*BaseInstanceField) GetType ¶
func (baseInstanceField *BaseInstanceField) GetType() KeyType
func (*BaseInstanceField) SetCalc ¶
func (baseInstanceField *BaseInstanceField) SetCalc(calc *FieldCalc)
type BaseLayout ¶
type BaseLayout struct { Spec int `json:"spec"` // 布局格式版本 ID string `json:"id"` // 布局 ID ShowIcon bool `json:"showIcon"` // 是否显示字段图标 WrapField bool `json:"wrapField"` // 是否换行字段内容 //Deprecated Filters []*ViewFilter `json:"filters,omitempty"` // 过滤规则 //Deprecated Sorts []*ViewSort `json:"sorts,omitempty"` // 排序规则 //Deprecated PageSize int `json:"pageSize,omitempty"` // 每页条目数 }
BaseLayout 描述了布局的基础结构。
type BaseValue ¶
type BaseValue struct { ID string `json:"id"` // 字段值 ID Value *Value `json:"value"` // 字段值 ValueType KeyType `json:"valueType"` // 字段值类型 }
BaseValue 描述了字段值的基础结构。
type CalcOperator ¶
type CalcOperator string
const ( CalcOperatorNone CalcOperator = "" CalcOperatorCountAll CalcOperator = "Count all" CalcOperatorCountValues CalcOperator = "Count values" CalcOperatorCountUniqueValues CalcOperator = "Count unique values" CalcOperatorCountEmpty CalcOperator = "Count empty" CalcOperatorCountNotEmpty CalcOperator = "Count not empty" CalcOperatorPercentEmpty CalcOperator = "Percent empty" CalcOperatorPercentNotEmpty CalcOperator = "Percent not empty" CalcOperatorPercentUniqueValues CalcOperator = "Percent unique values" CalcOperatorSum CalcOperator = "Sum" CalcOperatorAverage CalcOperator = "Average" CalcOperatorMedian CalcOperator = "Median" CalcOperatorMin CalcOperator = "Min" CalcOperatorMax CalcOperator = "Max" CalcOperatorRange CalcOperator = "Range" CalcOperatorEarliest CalcOperator = "Earliest" CalcOperatorLatest CalcOperator = "Latest" CalcOperatorChecked CalcOperator = "Checked" CalcOperatorUnchecked CalcOperator = "Unchecked" CalcOperatorPercentChecked CalcOperator = "Percent checked" CalcOperatorPercentUnchecked CalcOperator = "Percent unchecked" )
type CardAspectRatio ¶
type CardAspectRatio int
const ( CardAspectRatio16_9 CardAspectRatio = iota // 16:9 CardAspectRatio9_16 // 9:16 CardAspectRatio4_3 // 4:3 CardAspectRatio3_4 // 3:4 CardAspectRatio3_2 // 3:2 CardAspectRatio2_3 // 2:3 CardAspectRatio1_1 // 1:1 )
type Collection ¶
type Collection interface { // GetItems 返回集合中的所有项目。 GetItems() (ret []Item) // SetItems 设置集合中的项目。 SetItems(items []Item) // CountItems 返回集合中的项目数量。 CountItems() int // GetFields 返回集合的所有字段。 GetFields() []Field // GetField 返回指定 ID 的字段。 GetField(id string) (ret Field, fieldIndex int) // GetValue 返回指定项目 ID 和键 ID 的字段值。 GetValue(itemID, keyID string) (ret *Value) // GetSorts 返回集合的排序规则。 GetSorts() []*ViewSort // GetFilters 返回集合的过滤规则。 GetFilters() []*ViewFilter }
Collection 描述了一个集合的接口。 集合可以是表格、卡片等,包含多个项目。
type CreatedFormat ¶
type CreatedFormat string
const ( CreatedFormatNone CreatedFormat = "" // 2006-01-02 15:04 CreatedFormatDuration CreatedFormat = "duration" )
type Date ¶
type Date struct {
AutoFillNow bool `json:"autoFillNow"` // 是否自动填充当前时间 The database date field supports filling the current time by default https://github.com/siyuan-note/siyuan/issues/10823
}
type DateFormat ¶
type DateFormat string
const ( DateFormatNone DateFormat = "" DateFormatDuration DateFormat = "duration" )
type Field ¶
type Field interface { // GetID 返回字段的 ID。 GetID() string // GetType 返回字段的类型。 GetType() KeyType // GetCalc 返回字段的计算规则和结果。 GetCalc() *FieldCalc // SetCalc 设置字段的计算规则和结果。 SetCalc(*FieldCalc) // GetNumberFormat 返回数字字段的格式化设置。 GetNumberFormat() NumberFormat }
Field 描述了一个字段的接口。
type FieldCalc ¶
type FieldCalc struct { Operator CalcOperator `json:"operator"` // 计算操作符 Result *Value `json:"result"` // 计算结果 }
FieldCalc 描述了字段计算操作和结果的结构。
type FilterOperator ¶
type FilterOperator string
const ( FilterOperatorIsEqual FilterOperator = "=" FilterOperatorIsNotEqual FilterOperator = "!=" FilterOperatorIsGreater FilterOperator = ">" FilterOperatorIsGreaterOrEqual FilterOperator = ">=" FilterOperatorIsLess FilterOperator = "<" FilterOperatorIsLessOrEqual FilterOperator = "<=" FilterOperatorContains FilterOperator = "Contains" FilterOperatorDoesNotContain FilterOperator = "Does not contains" FilterOperatorIsEmpty FilterOperator = "Is empty" FilterOperatorIsNotEmpty FilterOperator = "Is not empty" FilterOperatorStartsWith FilterOperator = "Starts with" FilterOperatorEndsWith FilterOperator = "Ends with" FilterOperatorIsBetween FilterOperator = "Is between" FilterOperatorIsTrue FilterOperator = "Is true" FilterOperatorIsFalse FilterOperator = "Is false" )
type FilterQuantifier ¶
type FilterQuantifier string
const ( FilterQuantifierUndefined FilterQuantifier = "" // 等同于 Any FilterQuantifierAny FilterQuantifier = "Any" FilterQuantifierAll FilterQuantifier = "All" FilterQuantifierNone FilterQuantifier = "None" )
type Gallery ¶
type Gallery struct { *BaseInstance CoverFrom CoverFrom `json:"coverFrom"` // 封面来源 CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 CoverFromAssetField 时有效 CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比 CardSize CardSize `json:"cardSize"` // 卡片大小 FitImage bool `json:"fitImage"` // 是否适应封面图片大小 DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称 Fields []*GalleryField `json:"fields"` // 卡片字段 Cards []*GalleryCard `json:"cards"` // 卡片 CardCount int `json:"cardCount"` // 总卡片数 }
Gallery 描述了卡片视图实例的结构。
func (*Gallery) CountItems ¶
func (*Gallery) GetType ¶
func (gallery *Gallery) GetType() LayoutType
type GalleryCard ¶
type GalleryCard struct { ID string `json:"id"` // 卡片 ID Values []*GalleryFieldValue `json:"values"` // 卡片字段值 CoverURL string `json:"coverURL"` // 卡片封面超链接 CoverContent string `json:"coverContent"` // 卡片封面文本内容 }
GalleryCard 描述了卡片实例的结构。
func (*GalleryCard) GetBlockValue ¶
func (card *GalleryCard) GetBlockValue() (ret *Value)
func (*GalleryCard) GetID ¶
func (card *GalleryCard) GetID() string
func (*GalleryCard) GetValue ¶
func (card *GalleryCard) GetValue(keyID string) (ret *Value)
func (*GalleryCard) GetValues ¶
func (card *GalleryCard) GetValues() (ret []*Value)
type GalleryFieldValue ¶
type GalleryFieldValue struct {
*BaseValue
}
GalleryFieldValue 描述了卡片字段实例值的结构。
type GroupCalc ¶
type GroupCalc struct { Field string `json:"field"` // 字段 ID FieldCalc *FieldCalc `json:"calc"` // 计算规则和结果 }
GroupCalc 描述了分组计算规则和结果的结构。
type GroupMethod ¶
type GroupMethod int
GroupMethod 描述了分组方式。
const ( GroupMethodValue GroupMethod = iota // 按值分组 GroupMethodRangeNum // 按数字范围分组 GroupMethodDateRelative // 按相对日期分组 GroupMethodDateDay // 按天日期分组 GroupMethodDateWeek // 按周日期分组 GroupMethodDateMonth // 按月日期分组 GroupMethodDateYear // 按年日期分组 )
type GroupRange ¶
type GroupRange struct { NumStart float64 `json:"numStart"` // 数字范围起始值 NumEnd float64 `json:"numEnd"` // 数字范围结束值 NumStep float64 `json:"numStep"` // 数字范围步长 }
GroupRange 描述了分组范围的结构。
type Item ¶
type Item interface { // GetBlockValue 返回主键的值。 GetBlockValue() *Value // GetValues 返回项目的所有字段值。 GetValues() []*Value // GetValue 返回指定键 ID 的字段值。 GetValue(keyID string) (ret *Value) // GetID 返回项目的 ID。 GetID() string }
Item 描述了一个项目的接口。 项目可以是表格行、卡片等。
type Key ¶
type Key struct { ID string `json:"id"` // 字段 ID Name string `json:"name"` // 字段名 Type KeyType `json:"type"` // 字段类型 Icon string `json:"icon"` // 字段图标 Desc string `json:"desc"` // 字段描述 // 单选/多选 Options []*SelectOption `json:"options,omitempty"` // 选项列表 // 数字 NumberFormat NumberFormat `json:"numberFormat"` // 列数字格式化 // 模板 Template string `json:"template"` // 模板内容 // 关联 Relation *Relation `json:"relation,omitempty"` // 关联信息 // 汇总 Rollup *Rollup `json:"rollup,omitempty"` // 汇总信息 // 日期 Date *Date `json:"date,omitempty"` // 日期设置 }
Key 描述了属性视图属性字段的基础结构。
func (*Key) GetOption ¶
func (k *Key) GetOption(name string) (ret *SelectOption)
type KeyType ¶
type KeyType string
KeyType 描述了属性视图属性字段的类型。
const ( KeyTypeBlock KeyType = "block" // 主键 KeyTypeText KeyType = "text" // 文本 KeyTypeNumber KeyType = "number" // 数字 KeyTypeDate KeyType = "date" // 日期 KeyTypeSelect KeyType = "select" // 单选 KeyTypeMSelect KeyType = "mSelect" // 多选 KeyTypeURL KeyType = "url" // URL KeyTypeEmail KeyType = "email" // Email KeyTypePhone KeyType = "phone" // 电话 KeyTypeMAsset KeyType = "mAsset" // 资源 KeyTypeTemplate KeyType = "template" // 模板 KeyTypeCreated KeyType = "created" // 创建时间 KeyTypeUpdated KeyType = "updated" // 更新时间 KeyTypeCheckbox KeyType = "checkbox" // 复选框 KeyTypeRelation KeyType = "relation" // 关联 KeyTypeRollup KeyType = "rollup" // 汇总 KeyTypeLineNumber KeyType = "lineNumber" // 行号 )
type KeyValues ¶
type KeyValues struct { Key *Key `json:"key"` // 属性视图属性键 Values []*Value `json:"values,omitempty"` // 属性视图属性值列表 }
KeyValues 描述了属性视图属性键值列表的结构。
func (*KeyValues) GetBlockValue ¶
type LayoutGallery ¶
type LayoutGallery struct { *BaseLayout CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段 CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效 CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比 CardSize CardSize `json:"cardSize"` // 卡片大小,0:小卡片,1:中卡片,2:大卡片 FitImage bool `json:"fitImage"` // 是否适应封面图片大小 DisplayFieldName bool `json:"displayFieldName"` // 是否显示字段名称 CardFields []*ViewGalleryCardField `json:"fields"` // 卡片字段 // TODO CardIDs 字段已经废弃,计划于 2026 年 6 月 30 日后删除 https://github.com/siyuan-note/siyuan/issues/15194 //Deprecated CardIDs []string `json:"cardIds"` // 卡片 ID,用于自定义排序 }
LayoutGallery 描述了卡片布局的结构。
func NewLayoutGallery ¶
func NewLayoutGallery() *LayoutGallery
type LayoutTable ¶
type LayoutTable struct { *BaseLayout Columns []*ViewTableColumn `json:"columns"` // 表格列 // TODO RowIDs 字段已经废弃,计划于 2026 年 6 月 30 日后删除 https://github.com/siyuan-note/siyuan/issues/15194 //Deprecated RowIDs []string `json:"rowIds"` // 行 ID,用于自定义排序 }
LayoutTable 描述了表格布局的结构。
func NewLayoutTable ¶
func NewLayoutTable() *LayoutTable
type LayoutType ¶
type LayoutType string
LayoutType 描述了视图布局类型。
const ( LayoutTypeTable LayoutType = "table" // 属性视图类型 - 表格 LayoutTypeGallery LayoutType = "gallery" // 属性视图类型 - 卡片 )
type NumberFormat ¶
type NumberFormat string
const ( NumberFormatNone NumberFormat = "" NumberFormatCommas NumberFormat = "commas" NumberFormatPercent NumberFormat = "percent" NumberFormatUSD NumberFormat = "USD" // 美元 NumberFormatCNY NumberFormat = "CNY" // 人民币 NumberFormatEUR NumberFormat = "EUR" // 欧元 NumberFormatGBP NumberFormat = "GBP" // 英镑 NumberFormatJPY NumberFormat = "JPY" // 日元 NumberFormatRUB NumberFormat = "RUB" // 卢布 NumberFormatINR NumberFormat = "INR" // 卢比 NumberFormatKRW NumberFormat = "KRW" // 韩元 NumberFormatCAD NumberFormat = "CAD" // 加拿大元 NumberFormatCHF NumberFormat = "CHF" // 瑞士法郎 NumberFormatTHB NumberFormat = "THB" // 泰铢 NumberFormatAUD NumberFormat = "AUD" // 澳大利亚元 NumberFormatHKD NumberFormat = "HKD" // 港币 NumberFormatTWD NumberFormat = "TWD" // 新台币 NumberFormatMOP NumberFormat = "MOP" // 澳门币 NumberFormatSGD NumberFormat = "SGD" // 新加坡元 NumberFormatNZD NumberFormat = "NZD" // 新西兰元 )
type RelativeDate ¶
type RelativeDate struct { Count int `json:"count"` // 数量 Unit RelativeDateUnit `json:"unit"` // 单位:0 天、1 周、2 月、3 年 Direction RelativeDateDirection `json:"direction"` // 方向:-1 前、0 当前、1 后 }
type RelativeDateDirection ¶
type RelativeDateDirection int
type RelativeDateUnit ¶
type RelativeDateUnit int
type Rollup ¶
type Rollup struct { RelationKeyID string `json:"relationKeyID"` // 关联字段 ID KeyID string `json:"keyID"` // 目标字段 ID Calc *RollupCalc `json:"calc"` // 计算方式 }
type RollupCalc ¶
type RollupCalc struct { Operator CalcOperator `json:"operator"` Result *Value `json:"result"` }
type SelectOption ¶
type Table ¶
type Table struct { *BaseInstance Columns []*TableColumn `json:"columns"` // 表格列 Rows []*TableRow `json:"rows"` // 表格行 RowCount int `json:"rowCount"` // 表格总行数 }
Table 描述了表格视图实例的结构。
func (*Table) CountItems ¶
func (*Table) GetColumn ¶
func (table *Table) GetColumn(id string) *TableColumn
func (*Table) GetType ¶
func (*Table) GetType() LayoutType
type TableCell ¶
type TableCell struct { *BaseValue Color string `json:"color"` // 单元格颜色 BgColor string `json:"bgColor"` // 单元格背景颜色 }
TableCell 描述了表格实例单元格的结构。
type TableColumn ¶
type TableColumn struct { *BaseInstanceField Pin bool `json:"pin"` // 是否固定 Width string `json:"width"` // 列宽度 }
TableColumn 描述了表格实例列的结构。
type UpdatedFormat ¶
type UpdatedFormat string
const ( UpdatedFormatNone UpdatedFormat = "" // 2006-01-02 15:04 UpdatedFormatDuration UpdatedFormat = "duration" )
type Value ¶
type Value struct { ID string `json:"id,omitempty"` KeyID string `json:"keyID,omitempty"` // 字段 ID BlockID string `json:"blockID,omitempty"` // 项目 ID Type KeyType `json:"type,omitempty"` // 字段类型 IsDetached bool `json:"isDetached,omitempty"` // 是否为非绑定块,注意这个字段只能在主键(KeyTypeBlock)上使用,其他类型的值不要使用 CreatedAt int64 `json:"createdAt,omitempty"` UpdatedAt int64 `json:"updatedAt,omitempty"` Block *ValueBlock `json:"block,omitempty"` Text *ValueText `json:"text,omitempty"` Number *ValueNumber `json:"number,omitempty"` Date *ValueDate `json:"date,omitempty"` MSelect []*ValueSelect `json:"mSelect,omitempty"` URL *ValueURL `json:"url,omitempty"` Email *ValueEmail `json:"email,omitempty"` Phone *ValuePhone `json:"phone,omitempty"` MAsset []*ValueAsset `json:"mAsset,omitempty"` Template *ValueTemplate `json:"template,omitempty"` Created *ValueCreated `json:"created,omitempty"` Updated *ValueUpdated `json:"updated,omitempty"` Checkbox *ValueCheckbox `json:"checkbox,omitempty"` Relation *ValueRelation `json:"relation,omitempty"` Rollup *ValueRollup `json:"rollup,omitempty"` }
func GetKeyBlockValue ¶
func (*Value) Filter ¶
func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID string, rollupFurtherCollections map[string]Collection, cachedAttrViews map[string]*AttributeView) bool
func (*Value) GetValByType ¶
func (*Value) SetUpdatedAt ¶
func (*Value) SetValByType ¶
func (*Value) ToJSONString ¶
type ValueAsset ¶
type ValueBlock ¶
type ValueCheckbox ¶
type ValueCheckbox struct {
Checked bool `json:"checked"`
}
type ValueCreated ¶
type ValueCreated struct { Content int64 `json:"content"` IsNotEmpty bool `json:"isNotEmpty"` Content2 int64 `json:"content2"` IsNotEmpty2 bool `json:"isNotEmpty2"` FormattedContent string `json:"formattedContent"` }
func NewFormattedValueCreated ¶
func NewFormattedValueCreated(content, content2 int64, format CreatedFormat) (ret *ValueCreated)
type ValueDate ¶
type ValueDate struct { Content int64 `json:"content"` IsNotEmpty bool `json:"isNotEmpty"` HasEndDate bool `json:"hasEndDate"` IsNotTime bool `json:"isNotTime"` Content2 int64 `json:"content2"` IsNotEmpty2 bool `json:"isNotEmpty2"` FormattedContent string `json:"formattedContent"` }
func NewFormattedValueDate ¶
func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime, hasEndDate bool) (ret *ValueDate)
type ValueEmail ¶
type ValueEmail struct {
Content string `json:"content"`
}
type ValueNumber ¶
type ValueNumber struct { Content float64 `json:"content"` IsNotEmpty bool `json:"isNotEmpty"` Format NumberFormat `json:"format"` FormattedContent string `json:"formattedContent"` }
func NewFormattedValueNumber ¶
func NewFormattedValueNumber(content float64, format NumberFormat) (ret *ValueNumber)
func (*ValueNumber) FormatNumber ¶
func (number *ValueNumber) FormatNumber()
type ValuePhone ¶
type ValuePhone struct {
Content string `json:"content"`
}
type ValueRelation ¶
type ValueRollup ¶
type ValueRollup struct {
Contents []*Value `json:"contents"`
}
func (*ValueRollup) BuildContents ¶
func (r *ValueRollup) BuildContents(keyValues []*KeyValues, destKey *Key, relationVal *Value, calc *RollupCalc, furtherCollection Collection)
type ValueSelect ¶
type ValueTemplate ¶
type ValueTemplate struct {
Content string `json:"content"`
}
type ValueUpdated ¶
type ValueUpdated struct { Content int64 `json:"content"` IsNotEmpty bool `json:"isNotEmpty"` Content2 int64 `json:"content2"` IsNotEmpty2 bool `json:"isNotEmpty2"` FormattedContent string `json:"formattedContent"` }
func NewFormattedValueUpdated ¶
func NewFormattedValueUpdated(content, content2 int64, format UpdatedFormat) (ret *ValueUpdated)
type View ¶
type View struct { ID string `json:"id"` // 视图 ID Icon string `json:"icon"` // 视图图标 Name string `json:"name"` // 视图名称 HideAttrViewName bool `json:"hideAttrViewName"` // 是否隐藏属性视图名称 Desc string `json:"desc"` // 视图描述 Filters []*ViewFilter `json:"filters,omitempty"` // 过滤规则 Sorts []*ViewSort `json:"sorts,omitempty"` // 排序规则 PageSize int `json:"pageSize"` // 每页条目数 LayoutType LayoutType `json:"type"` // 当前布局类型 Table *LayoutTable `json:"table,omitempty"` // 表格布局 Gallery *LayoutGallery `json:"gallery,omitempty"` // 卡片布局 ItemIDs []string `json:"itemIds,omitempty"` // 项目 ID 列表,用于维护所有项目 Group *ViewGroup `json:"group,omitempty"` // 分组规则 GroupCreated int64 `json:"groupCreated"` // 分组生成时间戳 Groups []*View `json:"groups,omitempty"` // 分组视图列表 GroupItemIDs []string `json:"groupItemIds"` // 分组项目 ID 列表,用于维护分组中的所有项目 GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则 GroupKey *Key `json:"groupKey,omitempty"` // 分组字段 GroupVal *Value `json:"groupVal,omitempty"` // 分组值 GroupFolded bool `json:"groupFolded"` // 分组是否折叠 GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏 GroupSort int `json:"groupSort"` // 分组排序值,用于手动排序 }
View 描述了视图的结构。
func NewGalleryView ¶
func NewGalleryView() (ret *View)
func NewTableView ¶
func NewTableView() (ret *View)
func (*View) GetGroupByGroupValue ¶
GetGroupByGroupValue 获取指定分组值的分组视图。
func (*View) GetGroupByID ¶
GetGroupByID 获取指定分组 ID 的分组视图。
func (*View) GetGroupKey ¶
func (view *View) GetGroupKey(attrView *AttributeView) (ret *Key)
GetGroupKey 获取分组视图的分组字段。
func (*View) RemoveGroupByID ¶
RemoveGroupByID 从分组视图列表中移除指定 ID 的分组视图。
type ViewFilter ¶
type ViewFilter struct { Column string `json:"column"` // 列(字段)ID Qualifier FilterQuantifier `json:"quantifier,omitempty"` // 量词 Operator FilterOperator `json:"operator"` // 操作符 Value *Value `json:"value"` // 过滤值 RelativeDate *RelativeDate `json:"relativeDate,omitempty"` // 相对时间 RelativeDate2 *RelativeDate `json:"relativeDate2,omitempty"` // 第二个相对时间,用于某些操作符,比如 FilterOperatorIsBetween }
ViewFilter 描述了视图过滤规则的结构。
func (*ViewFilter) GetAffectValue ¶
func (filter *ViewFilter) GetAffectValue(key *Key, addingBlockID string) (ret *Value)
type ViewGalleryCardField ¶
type ViewGalleryCardField struct {
*BaseField
}
ViewGalleryCardField 描述了卡片字段的结构。
type ViewGroup ¶
type ViewGroup struct { Field string `json:"field"` // 分组字段 ID Method GroupMethod `json:"method"` // 分组方式 Range *GroupRange `json:"range,omitempty"` // 分组范围 Order GroupOrder `json:"order"` // 分组排序规则 HideEmpty bool `json:"hideEmpty"` // 是否隐藏空分组 }
ViewGroup 描述了视图分组规则的结构。
type ViewSort ¶
type ViewSort struct { Column string `json:"column"` // 列(字段)ID Order SortOrder `json:"order"` // 排序顺序 }
ViewSort 描述了视图排序规则的结构。
type ViewTableColumn ¶
type ViewTableColumn struct { *BaseField Pin bool `json:"pin"` // 是否固定 Width string `json:"width"` // 列宽度 Calc *FieldCalc `json:"calc,omitempty"` // 计算规则 }
ViewTableColumn 描述了表格列的结构。
type Viewable ¶
type Viewable interface { // GetType 获取视图的布局类型。 GetType() LayoutType // GetID 获取视图的 ID。 GetID() string // SetGroups 设置视图分组列表。 SetGroups(viewables []Viewable) // SetGroupCalc 设置视图分组计算规则和结果。 SetGroupCalc(group *GroupCalc) // GetGroupCalc 获取视图分组计算规则和结果。 GetGroupCalc() *GroupCalc // SetGroupFolded 设置分组是否折叠。 SetGroupFolded(folded bool) // GetGroupHidden 获取分组是否隐藏。 // hidden 0:显示,1:空白隐藏,2:手动隐藏 GetGroupHidden() int // SetGroupHidden 设置分组是否隐藏。 // hidden 0:显示,1:空白隐藏,2:手动隐藏 SetGroupHidden(hidden int) }
Viewable 描述了视图的接口。