lml-main
Version:
This is now a mono repository published into many standalone packages.
66 lines • 4.98 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const variables_1 = require("../../../styles/variables");
const cosmo_ui_auth_1 = require("@lml/cosmo-ui-auth");
const selectors_1 = require("../../../allocation/selectors");
const cosmoui_1 = require("cosmoui");
const ts_utils_1 = require("@lml/ts-utils");
const react_redux_1 = require("react-redux");
const modals_1 = require("../../../allocation/actions/modals");
const modals_2 = require("../../../couriers/actions/modals");
const selectors_2 = require("../../../jobs/selectors");
const actions_1 = require("../../../booking/actions");
const actions_2 = require("../../../jobs/actions");
class JobActionBoxComponent extends React.Component {
constructor() {
super(...arguments);
this.setExpandedJob = ts_utils_1.mkNonPropagatingClick(() => this.props.expanded
? this.props.setJobCollapsed(this.props.job.refId)
: this.props.setJobExpanded(this.props.job.refId));
this.showOrHideDirections = ts_utils_1.mkNonPropagatingClick(() => this.props.showingDirections
? this.props.hideJobDirections(this.props.job.refId)
: this.props.showJobDirections(this.props.job.refId));
this.showJobDetails = ts_utils_1.mkNonPropagatingClick(() => this.props.showJobDetails(this.props.job.refId));
this.showCloneJobModal = ts_utils_1.mkNonPropagatingClick(() => this.props.showCloneJobModal(this.props.job.refId));
this.showEditJobModal = ts_utils_1.mkNonPropagatingClick(() => this.props.showEditJobModal(this.props.job.refId));
this.showDeallocationModal = ts_utils_1.mkNonPropagatingClick(() => this.props.showDeallocationModal(this.props.job));
this.showChangeJobStatusModal = ts_utils_1.mkNonPropagatingClick(() => this.props.showCourierActionModal(this.props.job.refId));
this.showReturnToDepotModal = ts_utils_1.mkNonPropagatingClick(() => this.props.showReturnToDepotModal(this.props.job.refId));
}
render() {
const { jobByStatus, job, active, expanded, allocated, } = this.props;
if (!active)
return null;
const expandIcon = expanded ? 'CollapseVertical' : 'ExpandVertical';
const expandTooltip = expanded ? 'Collapse' : 'Expand';
return (React.createElement(cosmoui_1.ActionBox, { hidden: !active },
React.createElement(cosmoui_1.ActionNode, { id: "expand-job-card-button", icon: expandIcon, tooltip: `${expandTooltip} job card`, onClick: this.setExpandedJob }),
React.createElement(cosmoui_1.ActionNode, { id: "show-job-directions-button", icon: "AB", tooltip: "Show on the map", onClick: this.showOrHideDirections }),
React.createElement(cosmoui_1.ActionNode, { id: "show-job-details-modal-button", icon: "Info", tooltip: "Job details", onClick: this.showJobDetails }),
React.createElement(cosmoui_1.ActionNode, { id: "show-edit-job-modal-button", icon: "EditJob", tooltip: "Edit job", onClick: this.showEditJobModal }),
React.createElement(cosmoui_1.ActionNode, { id: "show-clone-job-modal-button", icon: "DuplicateJob", tooltip: "Clone job", onClick: this.showCloneJobModal }),
selectors_2.isJobCurrentlyProcessed(jobByStatus) ? (React.createElement(cosmoui_1.ActionNode, { id: "show-return-to-depot-job-modal-button", icon: "Return", tooltip: "Return to depot", onClick: this.showReturnToDepotModal })) : null,
selectors_2.isJobCurrentlyProcessed(jobByStatus) ? (React.createElement(cosmoui_1.ActionNode, { id: "chagnge-job-status-button", icon: "JobStatus", tooltip: "Change job status", onClick: this.showChangeJobStatusModal })) : null,
selectors_1.canDeallocateJob(jobByStatus) ? (React.createElement(cosmoui_1.ActionNode, { id: "show-deallocate-modal-button", className: "frequency", icon: "Unallocate", tooltip: "Deallocate job", onClick: this.showDeallocationModal, iconProps: { fill: variables_1.default.danger } })) : null));
}
}
exports.JobActionBoxComponent = JobActionBoxComponent;
const mapStateToProps = (state, ownProps) => ({
username: cosmo_ui_auth_1.getUsername(state),
showingDirections: selectors_2.jobIsShowingDirections(state, ownProps.job.refId),
});
const mapActionsToProps = {
setJobExpanded: actions_2.setJobExpanded,
setJobCollapsed: actions_2.setJobCollapsed,
showJobDirections: actions_2.showJobDirections,
hideJobDirections: actions_2.hideJobDirections,
showDeallocationModal: modals_1.showDeallocationModal,
showJobDetails: actions_2.showJobDetails,
showCloneJobModal: actions_2.showCloneJobModal,
showEditJobModal: actions_2.showEditJobModal,
showCourierActionModal: modals_2.showCourierActionModal,
showReturnToDepotModal: actions_1.showReturnToDepotModal,
};
exports.JobActionBox = react_redux_1.connect(mapStateToProps, mapActionsToProps)(JobActionBoxComponent);
//# sourceMappingURL=job-action-box.js.map