-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b3417c
commit a9ee66a
Showing
9 changed files
with
309 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package operators | ||
|
||
import ( | ||
htmx "github.com/zeiss/fiber-htmx" | ||
"github.com/zeiss/fiber-htmx/components/buttons" | ||
"github.com/zeiss/fiber-htmx/components/forms" | ||
"github.com/zeiss/fiber-htmx/components/tables" | ||
"github.com/zeiss/typhoon/internal/api/models" | ||
) | ||
|
||
// OperatorsTableProps ... | ||
type OperatorsTableProps struct { | ||
Operators []*models.Operator | ||
Offset int | ||
Limit int | ||
Total int | ||
} | ||
|
||
// OperatorsTable ... | ||
func OperatorsTable(props OperatorsTableProps, children ...htmx.Node) htmx.Node { | ||
return htmx.Div( | ||
htmx.ClassNames{ | ||
"bg-base-100": true, | ||
"m-4": true, | ||
}, | ||
|
||
tables.Table( | ||
tables.TableProps[*models.Operator]{ | ||
ID: "operators-tables", | ||
Columns: []tables.ColumnDef[*models.Operator]{ | ||
{ | ||
ID: "id", | ||
AccessorKey: "id", | ||
Header: func(p tables.TableProps[*models.Operator]) htmx.Node { | ||
return htmx.Th(htmx.Text("ID")) | ||
}, | ||
Cell: func(p tables.TableProps[*models.Operator], row *models.Operator) htmx.Node { | ||
return htmx.Td( | ||
htmx.Text(row.ID.String()), | ||
) | ||
}, | ||
}, | ||
{ | ||
ID: "name", | ||
AccessorKey: "name", | ||
Header: func(p tables.TableProps[*models.Operator]) htmx.Node { | ||
return htmx.Th(htmx.Text("Name")) | ||
}, | ||
Cell: func(p tables.TableProps[*models.Operator], row *models.Operator) htmx.Node { | ||
return htmx.Td( | ||
// links.Link( | ||
// links.LinkProps{ | ||
// Href: fmt.Sprintf("/%s/profiles/%s", props.Team.Slug, row.ID.String()), | ||
// }, | ||
// htmx.Text(row.Name), | ||
// ), | ||
) | ||
}, | ||
}, | ||
{ | ||
Header: func(p tables.TableProps[*models.Operator]) htmx.Node { | ||
return nil | ||
}, | ||
Cell: func(p tables.TableProps[*models.Operator], row *models.Operator) htmx.Node { | ||
return htmx.Td( | ||
buttons.Button( | ||
buttons.ButtonProps{ | ||
ClassNames: htmx.ClassNames{ | ||
"btn-square": true, | ||
}, | ||
}, | ||
|
||
// htmx.HxDelete(fmt.Sprintf("/%s/profiles/%s", props.Team.Slug, row.ID.String())), | ||
// htmx.HxTarget("closest <tr />"), | ||
// htmx.HxConfirm("Are you sure you want to delete this profile?"), | ||
// icons.TrashOutline( | ||
// icons.IconProps{}, | ||
// ), | ||
), | ||
) | ||
}, | ||
}, | ||
}, | ||
Rows: tables.NewRows(props.Operators), | ||
Toolbar: tables.TableToolbar( | ||
tables.TableToolbarProps[*models.Operator]{ | ||
ClassName: htmx.ClassNames{ | ||
"flex": true, | ||
"items-center": true, | ||
"justify-between": true, | ||
"px-5": true, | ||
"pt-5": true, | ||
}, | ||
}, | ||
htmx.Div( | ||
htmx.ClassNames{ | ||
"inline-flex": true, | ||
"items-center": true, | ||
"gap-3": true, | ||
}, | ||
forms.TextInputBordered( | ||
forms.TextInputProps{ | ||
Placeholder: "Search ...", | ||
}, | ||
), | ||
), | ||
htmx.A( | ||
htmx.Href("/operators/new"), | ||
buttons.Outline( | ||
buttons.ButtonProps{ | ||
ClassNames: htmx.ClassNames{ | ||
"btn-sm": true, | ||
}, | ||
}, | ||
htmx.Text("Create Operator"), | ||
), | ||
), | ||
), | ||
// Pagination: ProfileListTablePaginationComponent( | ||
// ProfileListTablePaginationProps{ | ||
// Limit: props.Limit, | ||
// Offset: props.Offset, | ||
// Total: props.Total, | ||
// Target: "profiles-tables", | ||
// Team: props.Team, | ||
// }, | ||
// ), | ||
}, | ||
), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.