lml-main
Version:
This is now a mono repository published into many standalone packages.
74 lines • 4.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const lodash_1 = require("lodash");
const cosmoui_1 = require("cosmoui");
class JobDetailsFeatureBar extends cosmoui_1.StylableComponent {
render() {
const { job } = this.props;
const serviceCode = lodash_1.get(job, 'metadata.service.code', '');
const servicePriority = lodash_1.get(job, 'metadata.priority', '');
const collectionSLA = lodash_1.get(lodash_1.find(job.stops, { type: 'collection' }), 'metadata.sla', '');
const deliverySLA = lodash_1.get(lodash_1.find(job.stops, { type: 'delivery' }), 'metadata.sla', '');
const jobType = lodash_1.get(job, 'metadata.jobType', '');
const items = lodash_1.get(job, 'metadata.items', -1);
const weight = lodash_1.get(job, 'metadata.weight', -1);
const units = lodash_1.get(job, 'metadata.valueReference', '');
const distance = lodash_1.get(job, 'metadata.distance', -1);
const itemsText = items >= 0 ? `${items} items` : '';
const weightText = weight >= 0 ? `${weight} kg` : '';
return (React.createElement(cosmoui_1.Row, { direction: "column", grow: 1 },
React.createElement(cosmoui_1.FeatureBar, { name: "jobDetailsServiceFeatureBar", id: "job-details-service-feature-bar" },
serviceCode.length > 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { style: this.barHeadingStyles(), text: serviceCode.toUpperCase() }),
servicePriority.length > 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { tagText: servicePriority.toUpperCase() }),
(servicePriority.length > 0 || serviceCode.length > 0) &&
(collectionSLA.length > 0 || deliverySLA.length > 0) &&
React.createElement(cosmoui_1.FeatureBarItem, null,
React.createElement("div", { style: this.separatorStyles() })),
collectionSLA.length > 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { icon: React.createElement(cosmoui_1.Icon, Object.assign({ icon: "Collection" }, this.iconProps())), text: `Coll. SLA - ${collectionSLA}` }),
deliverySLA.length > 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { icon: React.createElement(cosmoui_1.Icon, Object.assign({ icon: "Delivery" }, this.iconProps())), text: `Deliv. SLA - ${deliverySLA}` })),
React.createElement(cosmoui_1.FeatureBar, { style: this.jobBarStyles(), name: "jobDetailsJobFeatureBar", id: "job-details-job-units-bar" },
jobType.length > 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { style: this.barHeadingStyles(), text: jobType.toUpperCase() }),
jobType.length > 0 &&
React.createElement(cosmoui_1.FeatureBarItem, null,
React.createElement("div", { style: this.separatorStyles() })),
(items >= 0 || weight >= 0) &&
React.createElement(cosmoui_1.FeatureBarItem, { icon: React.createElement(cosmoui_1.Icon, Object.assign({ icon: "Job" }, this.iconProps())), text: `${itemsText}${items >= 0 && weight >= 0 ? ' - ' : ''}${weightText}` }),
units.length >= 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { icon: React.createElement(cosmoui_1.Icon, Object.assign({ icon: "Units" }, this.iconProps())), text: `${units} units` }),
distance >= 0 &&
React.createElement(cosmoui_1.FeatureBarItem, { icon: React.createElement(cosmoui_1.Icon, Object.assign({ icon: "AB" }, this.iconProps())), text: `${distance} km` }))));
}
iconProps() {
return {
size: 16,
style: {
marginRight: '6px',
},
};
}
barHeadingStyles() {
return {
fontWeight: 'bold',
color: 'black',
};
}
separatorStyles() {
return {
borderLeft: `1px solid ${this.gray(700)}`,
height: '16px',
};
}
jobBarStyles() {
return {
marginTop: '6px',
};
}
}
exports.JobDetailsFeatureBar = JobDetailsFeatureBar;
//# sourceMappingURL=job-details-feature-bar.js.map