Skip to content

Commit

Permalink
fix(ktableview): hide-toolbar prop [KHCP-13110]
Browse files Browse the repository at this point in the history
  • Loading branch information
portikM committed Sep 25, 2024
1 parent 30c615e commit edff6b0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 0 additions & 4 deletions docs/components/table-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ Set this to `false` to disable ability to sort.

Set this to `true` to hide pagination when the table record count is less than or equal to the page size. Defaults to `false`.

### hideToolbar

Prop for hiding toolbar. Useful when elements provided in the toolbar are not actionable (for example, when toolbar contains filter controls, however the fetcher returns no results as there are no records to filter by).

## Events

### state
Expand Down
4 changes: 4 additions & 0 deletions docs/components/table-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ A boolean to hide table headers. Only recomended when used in nested table. Refe

A boolean to disable some of the table features like column visibility, column resizing, bulk actions and hide toolbar element in nested tables. Refer to [Expandable Rows](#expandable-rows) section documentation for more details. Defaults to `false`.

### hideToolbar

Prop for hiding toolbar. Useful when elements provided in the toolbar are not actionable (for example, when toolbar contains filter controls, however the fetcher returns no results as there are no records to filter by).

## States

### Empty
Expand Down
3 changes: 2 additions & 1 deletion src/components/KTableData/KTableData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:hide-headers="hideHeaders"
:hide-pagination="hidePagination || !showPagination"
:hide-pagination-when-optional="hidePaginationWhenOptional"
:hide-toolbar="hideToolbar"
:loading="loading || isTableLoading"
:max-height="maxHeight"
:nested="nested"
Expand Down Expand Up @@ -200,6 +201,7 @@ const props = withDefaults(defineProps<TableDataProps>(), {
hideHeaders: false,
nested: false,
hidePaginationWhenOptional: false,
hideToolbar: false,
/**
* KTableData props defaults
*/
Expand All @@ -210,7 +212,6 @@ const props = withDefaults(defineProps<TableDataProps>(), {
initialFetcherParams: () => ({}),
clientSort: false,
sortable: true,
hideToolbar: false,
})
const slots = useSlots()
Expand Down
3 changes: 2 additions & 1 deletion src/components/KTableView/KTableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ const props = withDefaults(defineProps<TableViewProps>(), {
hideHeaders: false,
nested: false,
hidePaginationWhenOptional: true,
hideToolbar: false,
/**
* KTableData props defaults
*/
Expand Down Expand Up @@ -493,7 +494,7 @@ const isScrolledHorizontally = ref<boolean>(false)
const sortColumnKey = ref('')
const sortColumnOrder = ref<SortColumnOrder>('desc')
const isClickable = ref(false)
const hasToolbarSlot = computed((): boolean => !props.nested && (!!slots.toolbar || hasColumnVisibilityMenu.value || showBulkActionsToolbar.value))
const hasToolbarSlot = computed((): boolean => !props.hideToolbar && !props.nested && (!!slots.toolbar || hasColumnVisibilityMenu.value || showBulkActionsToolbar.value))
const isActionsDropdownHovered = ref<boolean>(false)
const tableWrapperStyles = computed((): Record<string, string> => ({
maxHeight: getSizeFromString(props.maxHeight),
Expand Down
5 changes: 4 additions & 1 deletion src/types/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ interface TablePropsShared {
* A boolean to hide pagination when total table records number is less than or equal to page size
*/
hidePaginationWhenOptional?: boolean
/**
* A prop for hiding the toolbar
*/
hideToolbar?: boolean
}

export interface TableViewProps extends TablePropsShared {
Expand All @@ -232,7 +236,6 @@ export interface TableDataProps extends TablePropsShared {
sortHandlerFunction?: (param: SortHandlerFunctionParam) => Record<string, any>[]
sortable?: boolean
hidePaginationWhenOptional?: boolean
hideToolbar?: boolean
}

export interface TableDataFetcherParams {
Expand Down

0 comments on commit edff6b0

Please sign in to comment.