Use Badge as inner component in Tables
parent
5e9fe6c22e
commit
db09d00a43
|
@ -9,6 +9,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
import { VNode } from 'vue';
|
import { VNode } from 'vue';
|
||||||
|
import { BadgePassThroughOptions } from '../badge';
|
||||||
import { ComponentHooks } from '../basecomponent';
|
import { ComponentHooks } from '../basecomponent';
|
||||||
import { ButtonPassThroughOptions } from '../button';
|
import { ButtonPassThroughOptions } from '../button';
|
||||||
import { CheckboxPassThroughOptionType } from '../checkbox';
|
import { CheckboxPassThroughOptionType } from '../checkbox';
|
||||||
|
@ -154,11 +155,11 @@ export interface ColumnPassThroughOptions {
|
||||||
*/
|
*/
|
||||||
sortIcon?: ColumnPassThroughOptionType;
|
sortIcon?: ColumnPassThroughOptionType;
|
||||||
/**
|
/**
|
||||||
* Used to pass attributes to the sort badge's DOM element.
|
* Used to pass attributes to the Badge component.
|
||||||
*/
|
*/
|
||||||
sortBadge?: ColumnPassThroughOptionType;
|
pcSortBadge?: BadgePassThroughOptions;
|
||||||
/**
|
/**
|
||||||
* Used to pass attributes to the header checkbox's DOM element.
|
* Used to pass attributes to the Checkbox component.
|
||||||
*/
|
*/
|
||||||
pcHeaderCheckbox?: CheckboxPassThroughOptionType;
|
pcHeaderCheckbox?: CheckboxPassThroughOptionType;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<span v-if="columnProp('sortable')" v-bind="getColumnPT('sort')">
|
<span v-if="columnProp('sortable')" v-bind="getColumnPT('sort')">
|
||||||
<component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" :class="cx('sortIcon')" v-bind="getColumnPT('sorticon')" />
|
<component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" :class="cx('sortIcon')" v-bind="getColumnPT('sorticon')" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="isMultiSorted()" :class="cx('sortBadge')" v-bind="getColumnPT('sortBadge')">{{ getBadgeValue() }}</span>
|
<Badge v-if="isMultiSorted()" :class="cx('pcSortBadge')" v-bind="getColumnPT('pcSortBadge')" :value="getBadgeValue()" />
|
||||||
<DTHeaderCheckbox
|
<DTHeaderCheckbox
|
||||||
v-if="columnProp('selectionMode') === 'multiple' && filterDisplay !== 'row'"
|
v-if="columnProp('selectionMode') === 'multiple' && filterDisplay !== 'row'"
|
||||||
:checked="allRowsSelected"
|
:checked="allRowsSelected"
|
||||||
|
@ -84,6 +84,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Badge from 'primevue/badge';
|
||||||
import BaseComponent from 'primevue/basecomponent';
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import SortAltIcon from 'primevue/icons/sortalt';
|
import SortAltIcon from 'primevue/icons/sortalt';
|
||||||
import SortAmountDownIcon from 'primevue/icons/sortamountdown';
|
import SortAmountDownIcon from 'primevue/icons/sortamountdown';
|
||||||
|
@ -365,6 +366,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
Badge,
|
||||||
DTHeaderCheckbox: HeaderCheckbox,
|
DTHeaderCheckbox: HeaderCheckbox,
|
||||||
DTColumnFilter: ColumnFilter,
|
DTColumnFilter: ColumnFilter,
|
||||||
SortAltIcon: SortAltIcon,
|
SortAltIcon: SortAltIcon,
|
||||||
|
|
|
@ -22,7 +22,7 @@ export enum DataTableClasses {
|
||||||
columnHeaderContent = 'p-datatable-column-header-content',
|
columnHeaderContent = 'p-datatable-column-header-content',
|
||||||
columnTitle = 'p-datatable-column-title',
|
columnTitle = 'p-datatable-column-title',
|
||||||
sortIcon = 'p-datatable-sort-icon',
|
sortIcon = 'p-datatable-sort-icon',
|
||||||
sortBadge = 'p-datatable-sort-badge',
|
pcSortBadge = 'p-datatable-sort-badge',
|
||||||
filter = 'p-datatable-filter',
|
filter = 'p-datatable-filter',
|
||||||
filterElementContainer = 'p-datatable-filter-element-container',
|
filterElementContainer = 'p-datatable-filter-element-container',
|
||||||
pcColumnFilterButton = 'p-datatable-column-filter-button',
|
pcColumnFilterButton = 'p-datatable-column-filter-button',
|
||||||
|
|
|
@ -27,11 +27,9 @@ const theme = ({ dt }) => `
|
||||||
transition: color ${dt('transition.duration')};
|
transition: color ${dt('transition.duration')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-datatable-sort-badge {
|
.p-datatable-sort-badge.p-badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
|
||||||
border-radius: 50%;
|
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
min-width: 1rem;
|
min-width: 1rem;
|
||||||
line-height: 1rem;
|
line-height: 1rem;
|
||||||
|
@ -625,7 +623,7 @@ const classes = {
|
||||||
columnHeaderContent: 'p-datatable-column-header-content',
|
columnHeaderContent: 'p-datatable-column-header-content',
|
||||||
columnTitle: 'p-datatable-column-title',
|
columnTitle: 'p-datatable-column-title',
|
||||||
sortIcon: 'p-datatable-sort-icon',
|
sortIcon: 'p-datatable-sort-icon',
|
||||||
sortBadge: 'p-datatable-sort-badge',
|
pcSortBadge: 'p-datatable-sort-badge',
|
||||||
filter: ({ props }) => [
|
filter: ({ props }) => [
|
||||||
'p-datatable-filter',
|
'p-datatable-filter',
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,12 +20,13 @@
|
||||||
<span v-if="columnProp('sortable')" v-bind="getColumnPT('sort')">
|
<span v-if="columnProp('sortable')" v-bind="getColumnPT('sort')">
|
||||||
<component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" :class="cx('sortIcon')" v-bind="getColumnPT('sortIcon')" />
|
<component :is="(column.children && column.children.sorticon) || sortableColumnIcon" :sorted="sortState.sorted" :sortOrder="sortState.sortOrder" :class="cx('sortIcon')" v-bind="getColumnPT('sortIcon')" />
|
||||||
</span>
|
</span>
|
||||||
<span v-if="isMultiSorted()" :class="cx('sortBadge')" v-bind="getColumnPT('sortBadge')">{{ getMultiSortMetaIndex() + 1 }}</span>
|
<Badge v-if="isMultiSorted()" :class="cx('pcSortBadge')" v-bind="getColumnPT('pcSortBadge')" :value="getMultiSortMetaIndex() + 1" />
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Badge from 'primevue/badge';
|
||||||
import BaseComponent from 'primevue/basecomponent';
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import SortAltIcon from 'primevue/icons/sortalt';
|
import SortAltIcon from 'primevue/icons/sortalt';
|
||||||
import SortAmountDownIcon from 'primevue/icons/sortamountdown';
|
import SortAmountDownIcon from 'primevue/icons/sortamountdown';
|
||||||
|
@ -232,6 +233,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
Badge,
|
||||||
SortAltIcon: SortAltIcon,
|
SortAltIcon: SortAltIcon,
|
||||||
SortAmountUpAltIcon: SortAmountUpAltIcon,
|
SortAmountUpAltIcon: SortAmountUpAltIcon,
|
||||||
SortAmountDownIcon: SortAmountDownIcon
|
SortAmountDownIcon: SortAmountDownIcon
|
||||||
|
|
|
@ -22,7 +22,7 @@ export enum TreeTableClasses {
|
||||||
columnResizer = 'p-treetable-column-resizer',
|
columnResizer = 'p-treetable-column-resizer',
|
||||||
columnTitle = 'p-treetable-column-title',
|
columnTitle = 'p-treetable-column-title',
|
||||||
sortIcon = 'p-treetable-sort-icon',
|
sortIcon = 'p-treetable-sort-icon',
|
||||||
sortBadge = 'p-treetable-sort-badge',
|
pcSortBadge = 'p-treetable-sort-badge',
|
||||||
tbody = 'p-treetable-tbody',
|
tbody = 'p-treetable-tbody',
|
||||||
nodeToggleButton = 'p-treetable-node-toggle-button',
|
nodeToggleButton = 'p-treetable-node-toggle-button',
|
||||||
nodeToggleIcon = 'p-treetable-node-toggle-icon',
|
nodeToggleIcon = 'p-treetable-node-toggle-icon',
|
||||||
|
|
|
@ -27,11 +27,9 @@ const theme = ({ dt }) => `
|
||||||
transition: color ${dt('transition.duration')};
|
transition: color ${dt('transition.duration')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-treetable-sort-badge {
|
.p-treetable-sort-badge.p-badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
|
||||||
border-radius: 50%;
|
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
min-width: 1rem;
|
min-width: 1rem;
|
||||||
line-height: 1rem;
|
line-height: 1rem;
|
||||||
|
@ -465,7 +463,7 @@ const classes = {
|
||||||
columnHeaderContent: 'p-treetable-column-header-content',
|
columnHeaderContent: 'p-treetable-column-header-content',
|
||||||
columnTitle: 'p-treetable-column-title',
|
columnTitle: 'p-treetable-column-title',
|
||||||
sortIcon: 'p-treetable-sort-icon',
|
sortIcon: 'p-treetable-sort-icon',
|
||||||
sortBadge: 'p-treetable-sort-badge',
|
pcSortBadge: 'p-treetable-sort-badge',
|
||||||
tbody: 'p-treetable-tbody',
|
tbody: 'p-treetable-tbody',
|
||||||
row: ({ instance }) => [
|
row: ({ instance }) => [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue