DataTable: new `filterButtonProp` property
parent
1cbaf36aa0
commit
a0c3e47afd
|
@ -273,6 +273,17 @@ export default {
|
||||||
filterInputProps: {
|
filterInputProps: {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
filterButtonProps: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {
|
||||||
|
addRule: { severity: 'info', text: true, size: 'small' },
|
||||||
|
removeRule: { severity: 'danger', text: true, size: 'small' },
|
||||||
|
apply: { size: 'small' },
|
||||||
|
clear: { outlined: true, size: 'small' }
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: DataTableStyle,
|
style: DataTableStyle,
|
||||||
|
|
|
@ -94,9 +94,7 @@
|
||||||
@click="removeConstraint(i)"
|
@click="removeConstraint(i)"
|
||||||
:label="removeRuleButtonLabel"
|
:label="removeRuleButtonLabel"
|
||||||
:unstyled="unstyled"
|
:unstyled="unstyled"
|
||||||
text
|
v-bind="filterButtonProps.removeRule"
|
||||||
severity="danger"
|
|
||||||
size="small"
|
|
||||||
:pt="getColumnPT('filterRemoveButton')"
|
:pt="getColumnPT('filterRemoveButton')"
|
||||||
>
|
>
|
||||||
<template #icon="iconProps">
|
<template #icon="iconProps">
|
||||||
|
@ -114,9 +112,7 @@
|
||||||
:class="cx('filterAddRuleButton')"
|
:class="cx('filterAddRuleButton')"
|
||||||
@click="addConstraint()"
|
@click="addConstraint()"
|
||||||
:unstyled="unstyled"
|
:unstyled="unstyled"
|
||||||
text
|
v-bind="filterButtonProps.addRule"
|
||||||
severity="info"
|
|
||||||
size="small"
|
|
||||||
:pt="getColumnPT('filterAddRuleButton')"
|
:pt="getColumnPT('filterAddRuleButton')"
|
||||||
>
|
>
|
||||||
<template #icon="iconProps">
|
<template #icon="iconProps">
|
||||||
|
@ -132,13 +128,21 @@
|
||||||
:label="clearButtonLabel"
|
:label="clearButtonLabel"
|
||||||
@click="clearFilter"
|
@click="clearFilter"
|
||||||
:unstyled="unstyled"
|
:unstyled="unstyled"
|
||||||
size="small"
|
v-bind="filterButtonProps.clear"
|
||||||
outlined
|
|
||||||
:pt="getColumnPT('filterClearButton')"
|
:pt="getColumnPT('filterClearButton')"
|
||||||
></CFButton>
|
></CFButton>
|
||||||
<component v-else :is="filterClearTemplate" :field="field" :filterModel="filters[field]" :filterCallback="clearFilter" />
|
<component v-else :is="filterClearTemplate" :field="field" :filterModel="filters[field]" :filterCallback="clearFilter" />
|
||||||
<template v-if="showApplyButton">
|
<template v-if="showApplyButton">
|
||||||
<CFButton v-if="!filterApplyTemplate" type="button" :class="cx('filterApplyButton')" :label="applyButtonLabel" @click="applyFilter()" :unstyled="unstyled" size="small" :pt="getColumnPT('filterApplyButton')"></CFButton>
|
<CFButton
|
||||||
|
v-if="!filterApplyTemplate"
|
||||||
|
type="button"
|
||||||
|
:class="cx('filterApplyButton')"
|
||||||
|
:label="applyButtonLabel"
|
||||||
|
@click="applyFilter()"
|
||||||
|
:unstyled="unstyled"
|
||||||
|
v-bind="filterButtonProps.apply"
|
||||||
|
:pt="getColumnPT('filterApplyButton')"
|
||||||
|
></CFButton>
|
||||||
<component v-else :is="filterApplyTemplate" :field="field" :filterModel="filters[field]" :filterCallback="applyFilter" />
|
<component v-else :is="filterApplyTemplate" :field="field" :filterModel="filters[field]" :filterCallback="applyFilter" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -275,6 +279,10 @@ export default {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
filterButtonProps: {
|
||||||
|
type: null,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
column: null
|
column: null
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
import { InputHTMLAttributes, TableHTMLAttributes, TransitionProps, VNode } from 'vue';
|
import { InputHTMLAttributes, TableHTMLAttributes, TransitionProps, VNode } from 'vue';
|
||||||
import { ComponentHooks } from '../basecomponent';
|
import { ComponentHooks } from '../basecomponent';
|
||||||
|
import { ButtonProps } from '../button';
|
||||||
import { ColumnPassThroughOptionType } from '../column';
|
import { ColumnPassThroughOptionType } from '../column';
|
||||||
import { ColumnGroupPassThroughOptionType } from '../columngroup';
|
import { ColumnGroupPassThroughOptionType } from '../columngroup';
|
||||||
import { PaginatorPassThroughOptionType } from '../paginator';
|
import { PaginatorPassThroughOptionType } from '../paginator';
|
||||||
|
@ -159,6 +160,28 @@ export interface DataTableExportCSVOptions {
|
||||||
selectionOnly: boolean;
|
selectionOnly: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom datatable filter button props options.
|
||||||
|
*/
|
||||||
|
export interface DataTableFilterButtonPropsOptions {
|
||||||
|
/**
|
||||||
|
* Add rule button props
|
||||||
|
*/
|
||||||
|
addRule: ButtonProps | undefined;
|
||||||
|
/**
|
||||||
|
* Remove rule button props
|
||||||
|
*/
|
||||||
|
removeRule: ButtonProps | undefined;
|
||||||
|
/**
|
||||||
|
* Apply button props
|
||||||
|
*/
|
||||||
|
apply: ButtonProps | undefined;
|
||||||
|
/**
|
||||||
|
* Apply button props
|
||||||
|
*/
|
||||||
|
clear: ButtonProps | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom sort event.
|
* Custom sort event.
|
||||||
* @see {@link DataTableEmits.sort}
|
* @see {@link DataTableEmits.sort}
|
||||||
|
@ -1130,6 +1153,16 @@ export interface DataTableProps {
|
||||||
* Used to pass all properties of the HTMLInputElement to the focusable filter input element inside the component.
|
* Used to pass all properties of the HTMLInputElement to the focusable filter input element inside the component.
|
||||||
*/
|
*/
|
||||||
filterInputProps?: InputHTMLAttributes | undefined;
|
filterInputProps?: InputHTMLAttributes | undefined;
|
||||||
|
/**
|
||||||
|
* Used to pass all filter button property object
|
||||||
|
* @defaultValue {
|
||||||
|
addRule: { severity: 'info', text: true, size: 'small' },
|
||||||
|
removeRule: { severity: 'danger', text: true, size: 'small' },
|
||||||
|
apply: { size: 'small' },
|
||||||
|
clear: { outlined: true, size: 'small' }
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
filterButtonProps?: DataTableFilterButtonPropsOptions | undefined;
|
||||||
/**
|
/**
|
||||||
* Used to pass attributes to DOM elements inside the component.
|
* Used to pass attributes to DOM elements inside the component.
|
||||||
* @type {DataTablePassThroughOptions}
|
* @type {DataTablePassThroughOptions}
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
:filters="d_filters"
|
:filters="d_filters"
|
||||||
:filtersStore="filters"
|
:filtersStore="filters"
|
||||||
:filterDisplay="filterDisplay"
|
:filterDisplay="filterDisplay"
|
||||||
|
:filterButtonProps="headerFilterButtonProps"
|
||||||
:filterInputProps="filterInputProps"
|
:filterInputProps="filterInputProps"
|
||||||
:first="d_first"
|
:first="d_first"
|
||||||
@column-click="onColumnHeaderClick($event)"
|
@column-click="onColumnHeaderClick($event)"
|
||||||
|
@ -2069,6 +2070,17 @@ export default {
|
||||||
groupRowSortField() {
|
groupRowSortField() {
|
||||||
return this.sortMode === 'single' ? this.sortField : this.d_groupRowsSortMeta ? this.d_groupRowsSortMeta.field : null;
|
return this.sortMode === 'single' ? this.sortField : this.d_groupRowsSortMeta ? this.d_groupRowsSortMeta.field : null;
|
||||||
},
|
},
|
||||||
|
headerFilterButtonProps() {
|
||||||
|
return {
|
||||||
|
...{
|
||||||
|
addRule: { severity: 'info', text: true, size: 'small' },
|
||||||
|
removeRule: { severity: 'danger', text: true, size: 'small' },
|
||||||
|
apply: { size: 'small' },
|
||||||
|
clear: { outlined: true, size: 'small' }
|
||||||
|
},
|
||||||
|
...this.filterButtonProps
|
||||||
|
};
|
||||||
|
},
|
||||||
virtualScrollerDisabled() {
|
virtualScrollerDisabled() {
|
||||||
return ObjectUtils.isEmpty(this.virtualScrollerOptions) || !this.scrollable;
|
return ObjectUtils.isEmpty(this.virtualScrollerOptions) || !this.scrollable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
:filters="filters"
|
:filters="filters"
|
||||||
:filtersStore="filtersStore"
|
:filtersStore="filtersStore"
|
||||||
:filterInputProps="filterInputProps"
|
:filterInputProps="filterInputProps"
|
||||||
|
:filterButtonProps="filterButtonProps"
|
||||||
@filter-change="$emit('filter-change', $event)"
|
@filter-change="$emit('filter-change', $event)"
|
||||||
@filter-apply="$emit('filter-apply')"
|
@filter-apply="$emit('filter-apply')"
|
||||||
:filterMenuStyle="columnProp('filterMenuStyle')"
|
:filterMenuStyle="columnProp('filterMenuStyle')"
|
||||||
|
@ -182,6 +183,10 @@ export default {
|
||||||
filterInputProps: {
|
filterInputProps: {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
filterButtonProps: {
|
||||||
|
type: null,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
:filterDisplay="filterDisplay"
|
:filterDisplay="filterDisplay"
|
||||||
:filtersStore="filtersStore"
|
:filtersStore="filtersStore"
|
||||||
:filterInputProps="filterInputProps"
|
:filterInputProps="filterInputProps"
|
||||||
|
:filterButtonProps="filterButtonProps"
|
||||||
:first="first"
|
:first="first"
|
||||||
@filter-change="$emit('filter-change', $event)"
|
@filter-change="$emit('filter-change', $event)"
|
||||||
@filter-apply="$emit('filter-apply')"
|
@filter-apply="$emit('filter-apply')"
|
||||||
|
@ -69,6 +70,7 @@
|
||||||
:filters="filters"
|
:filters="filters"
|
||||||
:filtersStore="filtersStore"
|
:filtersStore="filtersStore"
|
||||||
:filterInputProps="filterInputProps"
|
:filterInputProps="filterInputProps"
|
||||||
|
:filterButtonProps="filterButtonProps"
|
||||||
@filter-change="$emit('filter-change', $event)"
|
@filter-change="$emit('filter-change', $event)"
|
||||||
@filter-apply="$emit('filter-apply')"
|
@filter-apply="$emit('filter-apply')"
|
||||||
:filterMenuStyle="columnProp(col, 'filterMenuStyle')"
|
:filterMenuStyle="columnProp(col, 'filterMenuStyle')"
|
||||||
|
@ -231,6 +233,10 @@ export default {
|
||||||
filterInputProps: {
|
filterInputProps: {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
filterButtonProps: {
|
||||||
|
type: null,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
|
|
Loading…
Reference in New Issue