ant-design-vue/components/table/filterDropdown.jsx

305 lines
9.4 KiB
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import Menu, { SubMenu, Item as MenuItem } from '../vc-menu';
import closest from 'dom-closest';
import classNames from 'classnames';
import shallowequal from 'shallowequal';
import Dropdown from '../dropdown';
import Icon from '../icon';
import Checkbox from '../checkbox';
import Radio from '../radio';
import FilterDropdownMenuWrapper from './FilterDropdownMenuWrapper';
import { FilterMenuProps } from './interface';
import { initDefaultProps, getOptionProps } from '../_util/props-util';
import { cloneElement } from '../_util/vnode';
import BaseMixin from '../_util/BaseMixin';
2018-03-30 14:00:55 +00:00
2019-01-12 03:33:27 +00:00
function stopPropagation(e) {
e.stopPropagation();
2018-12-11 12:59:23 +00:00
}
2018-03-30 14:00:55 +00:00
export default {
name: 'FilterMenu',
2019-02-01 09:23:00 +00:00
mixins: [BaseMixin],
2018-03-30 14:00:55 +00:00
props: initDefaultProps(FilterMenuProps, {
2019-01-12 03:33:27 +00:00
handleFilter() {},
2018-03-30 14:00:55 +00:00
column: {},
}),
2019-01-12 03:33:27 +00:00
data() {
const visible =
'filterDropdownVisible' in this.column ? this.column.filterDropdownVisible : false;
this.preProps = { ...getOptionProps(this) };
2018-03-30 14:00:55 +00:00
return {
sSelectedKeys: this.selectedKeys,
sKeyPathOfSelectedItem: {}, // 记录所有有选中子菜单的祖先菜单
sVisible: visible,
2019-01-12 03:33:27 +00:00
};
2018-03-30 14:00:55 +00:00
},
2018-04-01 08:50:31 +00:00
watch: {
2019-01-12 03:33:27 +00:00
_propsSymbol() {
const nextProps = getOptionProps(this);
const { column } = nextProps;
this.setNeverShown(column);
const newState = {};
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
/**
2019-01-12 03:33:27 +00:00
* if the state is visible the component should ignore updates on selectedKeys prop to avoid
* that the user selection is lost
* this happens frequently when a table is connected on some sort of realtime data
* Fixes https://github.com/ant-design/ant-design/issues/10289 and
* https://github.com/ant-design/ant-design/issues/10209
*/
if (
'selectedKeys' in nextProps &&
!shallowequal(this.preProps.selectedKeys, nextProps.selectedKeys)
) {
newState.sSelectedKeys = nextProps.selectedKeys;
2018-04-01 08:50:31 +00:00
}
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
if ('filterDropdownVisible' in column) {
2019-01-12 03:33:27 +00:00
newState.sVisible = column.filterDropdownVisible;
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
if (Object.keys(newState).length > 0) {
2019-01-12 03:33:27 +00:00
this.setState(newState);
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2019-01-12 03:33:27 +00:00
this.preProps = { ...nextProps };
2018-04-01 08:50:31 +00:00
},
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
// 'column.fixed': function (val) {
// this.setNeverShown(this.column)
// },
// column (val) {
// if ('filterDropdownVisible' in val) {
// this.sVisible = val.filterDropdownVisible
// }
// },
// selectedKeys (val) {
// this.sSelectedKeys = val
// },
2018-03-30 14:00:55 +00:00
},
2019-02-01 09:23:00 +00:00
mounted() {
const { column } = this;
this.$nextTick(() => {
this.setNeverShown(column);
});
},
2018-03-30 14:00:55 +00:00
methods: {
2019-01-12 03:33:27 +00:00
getDropdownVisible() {
return this.neverShown ? false : this.sVisible;
2018-12-11 12:59:23 +00:00
},
2019-01-12 03:33:27 +00:00
setNeverShown(column) {
const rootNode = this.$el;
const filterBelongToScrollBody = !!closest(rootNode, `.ant-table-scroll`);
2018-04-01 08:50:31 +00:00
if (filterBelongToScrollBody) {
// When fixed column have filters, there will be two dropdown menus
// Filter dropdown menu inside scroll body should never be shown
// To fix https://github.com/ant-design/ant-design/issues/5010 and
// https://github.com/ant-design/ant-design/issues/7909
2019-01-12 03:33:27 +00:00
this.neverShown = !!column.fixed;
2018-04-01 08:50:31 +00:00
}
},
2018-03-30 14:00:55 +00:00
2019-01-12 03:33:27 +00:00
setSelectedKeys({ selectedKeys }) {
this.setState({ sSelectedKeys: selectedKeys });
2018-04-01 08:50:31 +00:00
},
2018-03-30 14:00:55 +00:00
2019-01-12 03:33:27 +00:00
setVisible(visible) {
const { column } = this;
2018-04-01 08:50:31 +00:00
if (!('filterDropdownVisible' in column)) {
2019-01-12 03:33:27 +00:00
this.setState({ sVisible: visible });
2018-04-01 08:50:31 +00:00
}
if (column.onFilterDropdownVisibleChange) {
2019-01-12 03:33:27 +00:00
column.onFilterDropdownVisibleChange(visible);
2018-04-01 08:50:31 +00:00
}
},
2019-01-12 03:33:27 +00:00
handleClearFilters() {
this.setState(
{
sSelectedKeys: [],
},
this.handleConfirm,
);
2018-04-01 08:50:31 +00:00
},
2019-01-12 03:33:27 +00:00
handleConfirm() {
this.setVisible(false);
this.confirmFilter2();
2018-12-11 12:59:23 +00:00
// Call `setSelectedKeys` & `confirm` in the same time will make filter data not up to date
// https://github.com/ant-design/ant-design/issues/12284
2019-01-12 03:33:27 +00:00
this.$forceUpdate();
2018-12-11 12:59:23 +00:00
this.$nextTick(() => {
2019-01-12 03:33:27 +00:00
this.confirmFilter;
});
2018-04-01 08:50:31 +00:00
},
2019-01-12 03:33:27 +00:00
onVisibleChange(visible) {
this.setVisible(visible);
2018-04-01 08:50:31 +00:00
if (!visible) {
2019-01-12 03:33:27 +00:00
this.confirmFilter2();
2018-04-01 08:50:31 +00:00
}
},
2018-03-30 14:00:55 +00:00
2019-01-12 03:33:27 +00:00
confirmFilter2() {
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
if (!shallowequal(this.sSelectedKeys, this.selectedKeys)) {
2019-01-12 03:33:27 +00:00
this.confirmFilter(this.column, this.sSelectedKeys);
2018-03-30 14:00:55 +00:00
}
2018-04-01 08:50:31 +00:00
},
2019-01-12 03:33:27 +00:00
renderMenuItem(item) {
const { column } = this;
const { sSelectedKeys: selectedKeys } = this.$data;
const multiple = 'filterMultiple' in column ? column.filterMultiple : true;
2018-04-01 08:50:31 +00:00
const input = multiple ? (
2018-12-13 13:26:21 +00:00
<Checkbox checked={selectedKeys && selectedKeys.indexOf(item.value.toString()) >= 0} />
2018-04-01 08:50:31 +00:00
) : (
2018-12-13 13:26:21 +00:00
<Radio checked={selectedKeys && selectedKeys.indexOf(item.value.toString()) >= 0} />
2019-01-12 03:33:27 +00:00
);
2018-04-01 08:50:31 +00:00
return (
<MenuItem key={item.value}>
{input}
<span>{item.text}</span>
</MenuItem>
2019-01-12 03:33:27 +00:00
);
2018-04-01 08:50:31 +00:00
},
2019-01-12 03:33:27 +00:00
hasSubMenu() {
const {
column: { filters = [] },
} = this;
return filters.some(item => !!(item.children && item.children.length > 0));
2018-04-01 08:50:31 +00:00
},
2019-01-12 03:33:27 +00:00
renderMenus(items) {
2018-04-01 08:50:31 +00:00
return items.map(item => {
if (item.children && item.children.length > 0) {
2019-01-12 03:33:27 +00:00
const { sKeyPathOfSelectedItem } = this;
2018-04-01 08:50:31 +00:00
const containSelected = Object.keys(sKeyPathOfSelectedItem).some(
key => sKeyPathOfSelectedItem[key].indexOf(item.value) >= 0,
2019-01-12 03:33:27 +00:00
);
const subMenuCls = containSelected
? `${this.dropdownPrefixCls}-submenu-contain-selected`
: '';
2018-04-01 08:50:31 +00:00
return (
<SubMenu title={item.text} class={subMenuCls} key={item.value.toString()}>
{this.renderMenus(item.children)}
</SubMenu>
2019-01-12 03:33:27 +00:00
);
2018-04-01 08:50:31 +00:00
}
2019-01-12 03:33:27 +00:00
return this.renderMenuItem(item);
});
2018-04-01 08:50:31 +00:00
},
2019-01-12 03:33:27 +00:00
handleMenuItemClick(info) {
const { sSelectedKeys: selectedKeys } = this.$data;
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
if (!info.keyPath || info.keyPath.length <= 1) {
2019-01-12 03:33:27 +00:00
return;
2018-04-01 08:50:31 +00:00
}
2019-01-12 03:33:27 +00:00
const keyPathOfSelectedItem = this.sKeyPathOfSelectedItem;
2018-12-13 13:26:21 +00:00
if (selectedKeys && selectedKeys.indexOf(info.key) >= 0) {
2018-04-01 08:50:31 +00:00
// deselect SubMenu child
2019-01-12 03:33:27 +00:00
delete keyPathOfSelectedItem[info.key];
2018-04-01 08:50:31 +00:00
} else {
// select SubMenu child
2019-01-12 03:33:27 +00:00
keyPathOfSelectedItem[info.key] = info.keyPath;
2018-04-01 08:50:31 +00:00
}
2019-01-12 03:33:27 +00:00
this.setState({ keyPathOfSelectedItem });
2018-04-01 08:50:31 +00:00
},
2018-03-30 14:00:55 +00:00
2019-01-12 03:33:27 +00:00
renderFilterIcon() {
const { column, locale, prefixCls, selectedKeys } = this;
const filtered = selectedKeys && selectedKeys.length > 0;
let filterIcon = column.filterIcon;
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
if (typeof filterIcon === 'function') {
2019-01-12 03:33:27 +00:00
filterIcon = filterIcon(filtered, column);
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2018-12-11 12:59:23 +00:00
const dropdownIconClass = classNames({
2018-12-13 13:26:21 +00:00
[`${prefixCls}-selected`]: filtered,
2018-12-11 12:59:23 +00:00
[`${prefixCls}-open`]: this.getDropdownVisible(),
2019-01-12 03:33:27 +00:00
});
2018-03-30 14:00:55 +00:00
2019-01-12 03:33:27 +00:00
return filterIcon ? (
cloneElement(filterIcon, {
attrs: {
title: locale.filterTitle,
},
on: {
click: stopPropagation,
},
class: classNames(`${prefixCls}-icon`, dropdownIconClass),
})
) : (
<Icon
2018-12-11 12:59:23 +00:00
title={locale.filterTitle}
2019-01-12 03:33:27 +00:00
type="filter"
theme="filled"
2018-12-11 12:59:23 +00:00
class={dropdownIconClass}
onClick={stopPropagation}
/>
2019-01-12 03:33:27 +00:00
);
2018-04-01 08:50:31 +00:00
},
2018-03-30 14:00:55 +00:00
},
2018-04-01 08:50:31 +00:00
2019-01-12 03:33:27 +00:00
render() {
const { column, locale, prefixCls, dropdownPrefixCls, getPopupContainer } = this;
2018-03-30 14:00:55 +00:00
// default multiple selection in filter dropdown
2019-01-12 03:33:27 +00:00
const multiple = 'filterMultiple' in column ? column.filterMultiple : true;
2018-03-30 14:00:55 +00:00
const dropdownMenuClass = classNames({
[`${dropdownPrefixCls}-menu-without-submenu`]: !this.hasSubMenu(),
2019-01-12 03:33:27 +00:00
});
let { filterDropdown } = column;
2018-12-11 12:59:23 +00:00
if (filterDropdown instanceof Function) {
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
filterDropdown = filterDropdown({
prefixCls: `${dropdownPrefixCls}-custom`,
2019-01-12 03:33:27 +00:00
setSelectedKeys: selectedKeys => this.setSelectedKeys({ selectedKeys }),
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
selectedKeys: this.sSelectedKeys,
confirm: this.handleConfirm,
clearFilters: this.handleClearFilters,
filters: column.filters,
2019-01-12 03:33:27 +00:00
getPopupContainer: triggerNode => triggerNode.parentNode,
2019-01-06 10:11:50 +00:00
column,
2019-01-12 03:33:27 +00:00
});
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
const menus = filterDropdown ? (
2019-01-12 03:33:27 +00:00
<FilterDropdownMenuWrapper>{filterDropdown}</FilterDropdownMenuWrapper>
2018-03-30 14:00:55 +00:00
) : (
<FilterDropdownMenuWrapper class={`${prefixCls}-dropdown`}>
<Menu
multiple={multiple}
onClick={this.handleMenuItemClick}
prefixCls={`${dropdownPrefixCls}-menu`}
class={dropdownMenuClass}
onSelect={this.setSelectedKeys}
onDeselect={this.setSelectedKeys}
selectedKeys={this.sSelectedKeys}
2019-01-12 03:33:27 +00:00
getPopupContainer={triggerNode => triggerNode.parentNode}
2018-03-30 14:00:55 +00:00
>
{this.renderMenus(column.filters)}
</Menu>
<div class={`${prefixCls}-dropdown-btns`}>
2019-01-12 03:33:27 +00:00
<a class={`${prefixCls}-dropdown-link confirm`} onClick={this.handleConfirm}>
2018-03-30 14:00:55 +00:00
{locale.filterConfirm}
</a>
2019-01-12 03:33:27 +00:00
<a class={`${prefixCls}-dropdown-link clear`} onClick={this.handleClearFilters}>
2018-03-30 14:00:55 +00:00
{locale.filterReset}
</a>
</div>
</FilterDropdownMenuWrapper>
2019-01-12 03:33:27 +00:00
);
2018-03-30 14:00:55 +00:00
return (
<Dropdown
trigger={['click']}
2019-01-12 03:33:27 +00:00
placement="bottomRight"
2018-12-11 12:59:23 +00:00
visible={this.getDropdownVisible()}
2018-03-30 14:00:55 +00:00
onVisibleChange={this.onVisibleChange}
getPopupContainer={getPopupContainer}
forceRender
>
2019-01-12 03:33:27 +00:00
<template slot="overlay">{menus}</template>
2018-03-30 14:00:55 +00:00
{this.renderFilterIcon()}
</Dropdown>
2019-01-12 03:33:27 +00:00
);
2018-03-30 14:00:55 +00:00
},
2019-01-12 03:33:27 +00:00
};