listing-customizations.go 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package basics
  2. import (
  3. "github.com/qor5/docs/docsrc/examples/e21_presents"
  4. "github.com/qor5/docs/docsrc/generated"
  5. "github.com/qor5/docs/docsrc/utils"
  6. . "github.com/theplant/docgo"
  7. "github.com/theplant/docgo/ch"
  8. . "github.com/theplant/htmlgo"
  9. )
  10. var ListingCustomizations = Doc(
  11. Markdown(`
  12. We get a default listing page with default columns, But default columns from database
  13. columns rarely fit the needs for any real application.
  14. `),
  15. utils.Anchor(H2(""), "Change List Columns and Component of Field"),
  16. Markdown(`
  17. Here is how do we change the columns of the list and how to we change the content display of a columns.
  18. `),
  19. ch.Code(generated.PresetsListingCustomizationFieldsSample).Language("go"),
  20. utils.Demo("Presets Listing Customization Fields", e21_presents.PresetsListingCustomizationFieldsPath+"/customers", "e21_presents/listing.go"),
  21. Markdown(`
  22. What we did with above code:
  23. - Added a new field to listing table that not exists on the struct ~Customer~
  24. - Define the listing display for the listing table by using the ~Td()~ and fetch the company data from a different table with associated column value
  25. - Link the company name in the listing to link the edit drawer of company
  26. - Limit the edit drawer field to only have ~Name~ and ~CompanyID~
  27. - Made the ~CompanyID~ field a vuetify ~VSelect~ component
  28. - Add companies as a new navigation item, that you can manage companies data
  29. - ~.SearchColumns("name", "email")~ configure the top navigation search box searches which columns with sql like operation
  30. `),
  31. utils.Anchor(H2(""), "Filters Panel"),
  32. Markdown(`
  33. Here we continue to add filters for the list
  34. `),
  35. ch.Code(generated.PresetsListingCustomizationFiltersSample).Language("go"),
  36. utils.Demo("Presets Listing Filters", e21_presents.PresetsListingCustomizationFiltersPath+"/customers", "e21_presents/listing.go"),
  37. Markdown(`
  38. ~FilterDataFunc~ of ~presets.ListingBuilder~ setup to have the filter menu or not.
  39. And how it will combine the sql conditions when doing query. the filter menu will
  40. change the url query strings with the filter values, and for date type in url query
  41. string it uses unix epoch int value. So the sql condition has to convert the database
  42. column data to unix epoch in order to compare with the value in url query string.
  43. Current we support these types
  44. - ~ItemTypeDate~: set it as a date filter item, which have many switches to support date and date range
  45. - ~ItemTypeNumber~: set it to a number filter item, which have switches to support number and number range
  46. - ~ItemTypeString~: set it to a string filter item, which have contains, and match exactly
  47. - ~ItemTypeSelect~: set it to a select filter item, which have a options of values for selection
  48. `),
  49. utils.Anchor(H2(""), "Filter Tabs"),
  50. Markdown(`
  51. Filter tabs is based on Filters configuration. But display as tabs above the list,
  52. You can think it as a short cut that used very frequently to filter something instead of
  53. use the pop up panel of filter.
  54. `),
  55. ch.Code(generated.PresetsListingCustomizationTabsSample).Language("go"),
  56. utils.Demo("Presets Listing Filter Tabs", e21_presents.PresetsListingCustomizationTabsPath+"/customers", "e21_presents/listing.go"),
  57. Markdown(`
  58. ~Query~ string name must be from the Filter's item configuration key field.
  59. `),
  60. utils.Anchor(H2(""), "Bulk Actions"),
  61. Markdown(`
  62. Bulk actions makes the list row show checkboxes, and you can select one or many rows,
  63. Later do an bulk update data for all of them.
  64. Here is how to use it:
  65. `),
  66. ch.Code(generated.PresetsListingCustomizationBulkActionsSample).Language("go"),
  67. utils.Demo("Presets Listing Bulk Actions", e21_presents.PresetsListingCustomizationBulkActionsPath+"/customers", "e21_presents/listing.go"),
  68. Markdown(`
  69. - ~ComponentFunc~ of the bulk action configure the component that will show to user to input after user clicked the bulk action button
  70. - ~UpdateFunc~ configure the logic that the bulk action execute
  71. `),
  72. ).Title("Listing Customizations").
  73. Slug("basics/listing-customizations")