lml-main
Version:
This is now a mono repository published into many standalone packages.
35 lines • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var redux_observable_1 = require("redux-observable");
var cosmoui_1 = require("cosmoui");
var actions_1 = require("../actions");
var JOB_INCIDENT_DESC_MAX_CHARS = 35;
exports.fetchJobIncidentCodesSuccess = function (action$, store) {
return action$.ofType(actions_1.FETCH_JOB_INCIDENT_CODES.SUCCESS)
.map(function (action) {
var _a = action.result, impacts = _a.impacts, reasons = _a.reasons;
var impactsWithLabels = impacts
.map(function (c) { return (tslib_1.__assign({}, c, { label: exports.mkJobIncidentLabel(c) })); });
var reasonsWithLabels = reasons
.map(function (c) { return (tslib_1.__assign({}, c, { label: exports.mkJobIncidentLabel(c) })); });
return actions_1.setJobIncidentCodes(impactsWithLabels, reasonsWithLabels);
});
};
exports.fetchJobIncidentCodesError = function (action$, store) {
return action$.ofType(actions_1.FETCH_JOB_INCIDENT_CODES.ERROR)
.mapTo(cosmoui_1.notificationError('There was a problem fetching the job incident codes. Please refresh.'));
};
/**
* Make a pretty label for the incident list dropdown
*
* @param code
*/
exports.mkJobIncidentLabel = function (code) {
var desc = code.description.length > JOB_INCIDENT_DESC_MAX_CHARS
? code.description.slice(0, JOB_INCIDENT_DESC_MAX_CHARS - 3) + "..."
: code.description;
return code.code + ": " + desc;
};
exports.fetchJobIncidentCodesEpics = redux_observable_1.combineEpics(exports.fetchJobIncidentCodesSuccess, exports.fetchJobIncidentCodesError);
//# sourceMappingURL=fetch-job-incident-codes.js.map