{"version":3,"sources":["webpack:///./scripts/components/myServiceHistoryTable.js","webpack:///./scripts/helpers/ajaxTable.js"],"names":["component","momentModule","window","moment","$serviceHistoryTableElement","$","userStateManager","getUserProfileData","data","isNullUndefinedEmpty","ProfileInfo","apiProblemOccured","displayErrorMessage","parent","ServiceHistory","fullListing","serviceHistoryData","map","item","startDateFormatted","StartDate","format","endDateFormatted","EndDate","BGUName","BguType","Position","AjaxTable","slice","length","css","display","$el","headers","this","$thead","find","$tbody","render","arrRow","value","join","headerRow","html","rows","getRow","error"],"mappings":"qTAKO,IAAMA,EAAS,e,EAAA,G,EAAA,yBAAG,qHACM,wDADN,OACfC,EADe,OAErBC,OAAOC,OAASF,EAAY,QAEtBG,EAA8BC,EAAE,6BAEtCC,IAAiBC,oBAAmB,SAAUC,GAC1C,IAAKC,YAAqBD,EAAKE,aAAc,CACzC,GAAIF,GAAQA,EAAKG,kBAEb,YADAC,YAAoBR,EAA4BS,UAIpD,IAAKJ,YAAqBD,EAAKE,YAAYI,gBAAiB,CACxD,IAAMC,EAAcX,EAA4BI,KAAK,QAIjDQ,EAAqBR,EAAKE,YAAYI,eAAeG,KAAI,SAACC,GAC1D,IAAMC,EAAsBV,YAAqBS,EAAKE,WAA2D,IAA9CjB,OAAOe,EAAKE,WAAWC,OAAO,cAC3FC,EAAoBb,YAAqBS,EAAKK,SAAuD,IAA5CpB,OAAOe,EAAKK,SAASF,OAAO,cAE3F,MAAO,CAACH,EAAKM,QAASN,EAAKO,QAASP,EAAKQ,SAAUP,EAAoBG,MAGvEP,EACA,IAAIY,IAAUvB,EAA6BY,IAE3C,IAAIW,IAAUvB,EAA6BY,EAAmBY,MAAM,EAb5D,IAgBJZ,EAAmBa,OAhBf,GAiBJxB,EAAE,qDAAqDyB,IAAI,CACvDC,QAAS,gBAjCZ,0C,+KAAH,sD,4VCLDJ,E,WAOpB,WAAYK,EAAKxB,GAAoB,IAAdyB,EAAc,uDAAJ,GAAI,UACpCC,KAAKF,IAAMA,EACXE,KAAK1B,KAAOA,EACZ0B,KAAKD,QAAUA,EACfC,KAAKC,OAASD,KAAKF,IAAII,KAAK,SAC5BF,KAAKG,OAASH,KAAKF,IAAII,KAAK,SAC5BF,KAAKI,S,sDAGCC,GACN,sCAEIA,EAAOtB,KAAI,SAAAuB,GACZ,OAAOA,SAAkDA,EAAMX,OAAS,EAAjE,cAA4EW,EAA5E,yBACLC,KAAK,IAJV,yB,+BASQ,WACR,IACC,GAAIP,KAAKD,QAAQJ,OAAS,EAAG,CAC5B,IAAIa,EAAYR,KAAKD,QAAQhB,KAAI,SAAAC,GAAI,oBAAWA,EAAX,YAAwBuB,KAAK,IAClEP,KAAKC,OAAOQ,KAAKD,GAElB,IAAIE,EAAOV,KAAK1B,KAAKS,KAAI,SAAAC,GAAI,OAAI,EAAK2B,OAAO3B,MAAOuB,KAAK,IACzDP,KAAKG,OAAOM,KAAKC,GAChB,MAAOE,U","file":"9.570e13daa03cc82ca5b3.js","sourcesContent":["import AjaxTable from '../helpers/ajaxTable';\nimport { displayErrorMessage } from '../helpers/displayError';\nimport { isNullUndefinedEmpty } from '../helpers/helpers';\nimport userStateManager from '../helpers/stateManager';\n\nexport const component = async () => {\n const momentModule = await import('moment-mini');\n window.moment = momentModule.default;\n\n const $serviceHistoryTableElement = $('#my-service-history-table');\n\n userStateManager.getUserProfileData(function (data) {\n if (!isNullUndefinedEmpty(data.ProfileInfo)) {\n if (data && data.apiProblemOccured) {\n displayErrorMessage($serviceHistoryTableElement.parent());\n return;\n }\n\n if (!isNullUndefinedEmpty(data.ProfileInfo.ServiceHistory)) {\n const fullListing = $serviceHistoryTableElement.data('full');\n const max = 5;\n\n //Format data ready to map to table\n var serviceHistoryData = data.ProfileInfo.ServiceHistory.map((item) => {\n const startDateFormatted = !isNullUndefinedEmpty(item.StartDate) ? moment(item.StartDate).format('DD/MM/YYYY') : '-';\n const endDateFormatted = !isNullUndefinedEmpty(item.EndDate) ? moment(item.EndDate).format('DD/MM/YYYY') : '-';\n\n return [item.BGUName, item.BguType, item.Position, startDateFormatted, endDateFormatted];\n });\n\n if (fullListing) {\n new AjaxTable($serviceHistoryTableElement, serviceHistoryData);\n } else {\n new AjaxTable($serviceHistoryTableElement, serviceHistoryData.slice(0, max));\n\n //show a button if more than max\n if (serviceHistoryData.length > max) {\n $('.button-wrapper.my-service-history-button-wrapper').css({\n display: 'block',\n });\n }\n }\n }\n }\n });\n};\n","export default class AjaxTable {\n /**\n * Helper class to render a table body (optional column headers) after an AJAX call.\n * @param {Object} $el jQuery element\n * @param {Array.} data Array of strings within an array of rows. Keypair data should be mapped to an array of strings first!\n\t * @param {string[]} headers (Optional) specify the headers for each column. Use if headers are dynamic and not set via view.\n */\n\tconstructor($el, data, headers = []) {\n\t\tthis.$el = $el;\n\t\tthis.data = data;\n\t\tthis.headers = headers;\n\t\tthis.$thead = this.$el.find('thead');\n\t\tthis.$tbody = this.$el.find('tbody');\n\t\tthis.render();\n\t}\n\n\tgetRow(arrRow){\n\t\treturn `\n\t\t\t\n\t\t\t\t${arrRow.map(value => {\n\t\t\t\t\treturn value !== null && typeof value !== 'undefined' && value.length > 0 ? `${value}` : `-`\n\t\t\t\t}).join('')}\n\t\t\t\n\t\t`\n }\n\n\trender() {\n\t\ttry {\n\t\t\tif (this.headers.length > 0) {\n\t\t\t\tvar headerRow = this.headers.map(item => `${item}`).join('');\n\t\t\t\tthis.$thead.html(headerRow);\n\t\t\t}\n\t\t\tvar rows = this.data.map(item => this.getRow(item)).join('');\n\t\t\tthis.$tbody.html(rows);\n\t\t} catch (error) {\n\t\t\tconsole.error('There was an issue generating an Ajax Table', error);\n\t\t}\n\t}\n}\n\n"],"sourceRoot":""}