columns

package
v1.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

templ: version: v0.3.1020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTimeSince

func FormatTimeSince(ctx context.Context, t time.Time, diffFrom time.Time) string

func TimeSinceColumn

func TimeSinceColumn[T attrs.Definer](label any, field string, hoverFormat ...string) list.ListColumn[T]

Types

type ListAction

type ListAction[T attrs.Definer] struct {
	Classname string
	Show      func(r *http.Request, defs attrs.Definitions, row T) bool
	Text      func(r *http.Request, defs attrs.Definitions, row T) string
	URL       func(r *http.Request, defs attrs.Definitions, row T) string
	Attrs     func(r *http.Request, defs attrs.Definitions, row T) templ.Attributes
}

func (*ListAction[T]) Component

func (l *ListAction[T]) Component(r *http.Request, defs attrs.Definitions, row T) templ.Component

func (*ListAction[T]) GetAttrs

func (l *ListAction[T]) GetAttrs(r *http.Request, defs attrs.Definitions, row T) templ.Attributes

func (*ListAction[T]) IsShown

func (l *ListAction[T]) IsShown(r *http.Request, defs attrs.Definitions, row T) bool

type ListActionsColumn

type ListActionsColumn[T attrs.Definer] struct {
	Heading func(c context.Context) string
	Actions []*ListAction[T]
}

func (*ListActionsColumn[T]) Attributes

func (l *ListActionsColumn[T]) Attributes(r *http.Request, defs attrs.Definitions, row T, colIndex, colCount int) map[string]any

func (*ListActionsColumn[T]) Component

func (l *ListActionsColumn[T]) Component(r *http.Request, defs attrs.Definitions, row T) templ.Component

func (*ListActionsColumn[T]) FieldName

func (l *ListActionsColumn[T]) FieldName() string

func (*ListActionsColumn[T]) Header

func (l *ListActionsColumn[T]) Header(r *http.Request) templ.Component

type SortableColumnBuilder

type SortableColumnBuilder[T attrs.Definer] struct {
	// if this is false, the builder will not add sorting capabilities
	// this might spare you some if else statements.
	CanSort bool
	// contains filtered or unexported fields
}

func NewSortableColumnBuilder

func NewSortableColumnBuilder[T attrs.Definer](model T, isSortField ...func(f attrs.FieldDefinition) bool) *SortableColumnBuilder[T]

func (*SortableColumnBuilder[T]) AddColumn

func (b *SortableColumnBuilder[T]) AddColumn(column any) list.ListColumn[T]

func (*SortableColumnBuilder[T]) IsSortable

func (b *SortableColumnBuilder[T]) IsSortable(field string) bool

func (*SortableColumnBuilder[T]) Sort

func (b *SortableColumnBuilder[T]) Sort(qs *queries.QuerySet[T], sortOrder []string) *queries.QuerySet[T]

type TimeInformation

type TimeInformation struct {
	Source  time.Time
	Years   int
	Months  int
	Days    int
	Hours   int
	Minutes int
	Seconds int
	Future  bool
}

func FormatTimeDifference

func FormatTimeDifference(ctx context.Context, t time.Time, diffFrom time.Time) ([]string, TimeInformation)

FormatTimeAgo formats the time difference nicely, e.g. "1 year, 2 months, 3 weeks ago"

func GetTimeDiffInformation

func GetTimeDiffInformation(t time.Time, diffFrom time.Time) (info TimeInformation)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL