lml-main
Version:
This is now a mono repository published into many standalone packages.
72 lines • 2.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const TrayActions = require("./tray");
const actions_1 = require("../../couriers/actions");
const actions_2 = require("../../jobs/actions");
exports.onKeyUpPress = () => (dispatch, getState) => {
const selectedTrayId = getState().tray.selectedTrayId;
const path = getPath();
switch (selectedTrayId) {
case 'jobs':
if (path !== '') {
dispatch(actions_2.activatePreviousJob());
}
break;
case 'couriers':
dispatch(actions_1.activatePreviousCourier());
}
};
exports.onKeyDownPress = () => (dispatch, getState) => {
const selectedTrayId = getState().tray.selectedTrayId;
const path = getPath();
switch (selectedTrayId) {
case 'jobs':
if (path !== '') {
dispatch(actions_2.activateNextJob());
}
break;
case 'couriers':
dispatch(actions_1.activateNextCourier());
}
};
exports.onKeyEnterPress = () => (dispatch, getState) => {
const selectedTrayId = getState().tray.selectedTrayId;
const path = getPath();
switch (selectedTrayId) {
case 'jobs':
if (path !== '') {
dispatch(actions_2.expandActiveJob());
}
break;
case 'couriers':
}
};
exports.onKeyLeftPress = () => (dispatch, getState) => {
dispatch(TrayActions.selectTrayToLeft());
afterLeftRightKeyPress(dispatch, getState);
};
exports.onKeyRightPress = () => (dispatch, getState) => {
dispatch(TrayActions.selectTrayToRight());
afterLeftRightKeyPress(dispatch, getState);
};
const afterLeftRightKeyPress = (dispatch, getState) => {
const selectedTrayId = getState().tray.selectedTrayId;
const path = getPath();
switch (selectedTrayId) {
case 'jobs':
if (path !== '') {
dispatch(actions_2.activateFirstJobIfNoneActive());
}
break;
case 'couriers':
dispatch(actions_1.activateFirstCourierIfNoneActive());
}
};
const getPath = () => {
let path = window.location.pathname;
if (path.substr(0, 1) === '/') {
path = path.substring(1);
}
return path;
};
//# sourceMappingURL=keyboard.js.map