/* API.JS PROVIDES CENTRALIZED METHODS FOR COMMUNICATING WITH SS-API CALLED BY CLIENT SIDE CONTROLLERS AND DIRECTIVES */ function getURIParameters() { if (!window.location.href.includes("?")) { return {};} var params = {}; window.location.href.split("?")[1].split("&").forEach(function(param) { var paramQuals = param.split("="); params[paramQuals[0]] = paramQuals[1]; }); return params; } function submitForm(_scope, _http, _rootScope, _formType, _requiredFields, _then) { if (_requiredFields.some((r) => { return _scope.details[r] == null || (typeof(_scope.details[r]) == "string" && _scope.details[r].length == 0); })) { _rootScope.$emit('showAlert', "Error
Please complete all required fields before sending", "danger"); } else { //Post against current page _http.post(window.location.href, _scope.details).then((json) => { if (json.status == 200) { _rootScope.$emit('showAlert', "Success
" + _formType + " sent successfully!", "success"); if(_then) { _then(); } } else { _rootScope.$emit('showAlert', "Error
Failed to send " + _formType, "danger"); } }); } } function orderRecordsByIdArray(_records, _ids) { var o = []; for(var i in _ids) { var record = _records.find((r) => { return r._id == _ids[i]; }); if (record) { o.push(record); } } return o; }