Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
- add dynamic filter shortcuts to table #2195
Browse files Browse the repository at this point in the history
  • Loading branch information
siemiatj committed Apr 22, 2019
1 parent b31eb9c commit d52192f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/components/table/TableFilter.js
Expand Up @@ -8,6 +8,7 @@ import { topActionsRequest } from '../../api';
import { openModal } from '../../actions/WindowActions';
import Tooltips from '../tooltips/Tooltips';
import TableQuickInput from './TableQuickInput';
import { TableFilterContextShortcuts } from '../keyshortcuts';

class ActionButton extends Component {
static propTypes = {
Expand Down Expand Up @@ -84,6 +85,52 @@ class TableFilter extends Component {
}
};

handleClick = action => {
const { dispatch, docId } = this.props;

if (action.disabled) {
return;
}

dispatch(
openModal(
action.caption,
action.processId,
'process',
null,
null,
false,
null,
[docId],
null,
null,
null,
null
)
);
};

generateShortcuts = () => {
let { actions } = this.state;
const shortcutActions = [];

if (!actions) {
actions = [];
}

for (let i = 0; i < actions.length; i += 1) {
const action = actions[i];

shortcutActions.push({
name: `FILTER_ACTION_${i}`,
handler: () => this.handleClick(action),
shortcut: action.shortcut.replace('-', '+'),
});
}

return <TableFilterContextShortcuts shortcutActions={shortcutActions} />;
};

showTooltip = () => {
this.setState({
isTooltipShow: keymap.TOGGLE_QUICK_INPUT,
Expand Down Expand Up @@ -177,6 +224,7 @@ class TableFilter extends Component {
/>
))
: null}
{!isBatchEntry && actions.length ? this.generateShortcuts() : null}
</div>
{supportQuickInput &&
(isBatchEntry || fullScreen) &&
Expand Down

0 comments on commit d52192f

Please sign in to comment.