mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-05 07:01:48 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
67370745b2
commit
d05010a71f
5 changed files with 73 additions and 25 deletions
|
|
@ -189,6 +189,26 @@ type View struct {
|
|||
Gallery *LayoutGallery `json:"gallery,omitempty"` // 画廊布局
|
||||
}
|
||||
|
||||
func (view *View) GetFilters() (ret []*ViewFilter) {
|
||||
switch view.LayoutType {
|
||||
case LayoutTypeTable:
|
||||
return view.Table.Filters
|
||||
case LayoutTypeGallery:
|
||||
return view.Gallery.Filters
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (view *View) GetSorts() (ret []*ViewSort) {
|
||||
switch view.LayoutType {
|
||||
case LayoutTypeTable:
|
||||
return view.Table.Sorts
|
||||
case LayoutTypeGallery:
|
||||
return view.Gallery.Sorts
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// LayoutType 描述了视图布局类型。
|
||||
type LayoutType string
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ type Item interface {
|
|||
// GetValues 返回项目的所有字段值。
|
||||
GetValues() []*Value
|
||||
|
||||
// GetValue 返回指定键 ID 的字段值。
|
||||
GetValue(keyID string) (ret *Value)
|
||||
|
||||
// GetID 返回项目的 ID。
|
||||
GetID() string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,16 @@ func (card *GalleryCard) GetValues() (ret []*Value) {
|
|||
return
|
||||
}
|
||||
|
||||
func (card *GalleryCard) GetValue(keyID string) (ret *Value) {
|
||||
for _, value := range card.Values {
|
||||
if nil != value.Value && keyID == value.Value.KeyID {
|
||||
ret = value.Value
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (gallery *Gallery) GetItems() (ret []Item) {
|
||||
ret = []Item{}
|
||||
for _, card := range gallery.Cards {
|
||||
|
|
|
|||
|
|
@ -91,16 +91,6 @@ type TableCell struct {
|
|||
BgColor string `json:"bgColor"` // 单元格背景颜色
|
||||
}
|
||||
|
||||
func (row *TableRow) GetValue(keyID string) (ret *Value) {
|
||||
for _, cell := range row.Cells {
|
||||
if nil != cell.Value && keyID == cell.Value.KeyID {
|
||||
ret = cell.Value
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (table *Table) GetColumn(id string) *TableColumn {
|
||||
for _, column := range table.Columns {
|
||||
if column.ID == id {
|
||||
|
|
@ -134,6 +124,16 @@ func (row *TableRow) GetValues() (ret []*Value) {
|
|||
return
|
||||
}
|
||||
|
||||
func (row *TableRow) GetValue(keyID string) (ret *Value) {
|
||||
for _, cell := range row.Cells {
|
||||
if nil != cell.Value && keyID == cell.Value.KeyID {
|
||||
ret = cell.Value
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (table *Table) GetItems() (ret []Item) {
|
||||
ret = []Item{}
|
||||
for _, row := range table.Rows {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue