{"version":3,"sources":["../LuV.LUMAS.Services/scripts/controls/customerProjectsAggregationController.ts"],"names":["CustomerProjectsAggregationController","prototype","config","options","this","productCode","productName","hideSearchBox","templateUrl","templateHelperService","getTemplateUrl","itemTemplateUrl","passthrough","preRepeatFunction","origin","window","location","protocol","hostname","port","luPoBaseUrl","PortalConfig","publishedDocumentsSearchQueryTemplate","publishedDocumentsTypeProperty","publishedDocumentsProjectKeyProperty","query","hiddenTaxonomyListQueryBase","webAbsoluteUrl","_lumasContext","listTitle","showList","linkTitle","linkUrl","search","_this","isError","errorMessage","resultItems","length","isLoading","headers","content-type","accept","X-RequestDigest","document","getElementById","getAttribute","$http","method","url","then","data","parseCustomerProjectItems","d","results","err","status","termRetrieveFields","coreApplicationField","partField","filterTexts","_i","_a","item","_b","termRetrieveFields_1","termFieldData","filter","TermGuid","indexOf","push","queries","queryTextBase","queryText","splice","taxonomyHiddenListWhereClauseCount","join","$q","all","map","q","responses","taxonomyHiddenList","i","response","apply","termRetrieveFields_2","termRetrieveField","taxElement","find","elem","IdForTerm","searchQuery","replace","searchOptions","spSearchOptions_1","SearchOptions","setRowLimit","setSelectPropertiesMap","type","projectKey","setRequestDigest","searchService","projectDocSearchResults","projectDocRowIndex","rows","projectDocSearchResult","resultItemIndex","resultItem","title","statusDate5","statusDate6","projectDocUrl","finally","$log","log","items","parsedResults","_","forEach","FileRef","Title","specifier","lpSpecifier","specifierId","ID","segment","lpSegment","lpSegmentCode","segmentId","projectStatusText","stoppedDate","lpProjectStoppedDate","statusDate1","lpStatus1Date","statusDate2","lpStatus2Date","statusDate3","lpStatus3Date","statusDate4","lpStatus4Date","lpStatus5Date","lpStatus6Date","lpApplication","lpPart","getGlobalVariable","variableName","$window","openLuPoBasePopup","id","siteRelativeUrl","self","EnsureScriptFunc","ExecuteOrDelayUntilScriptLoaded","SP","UI","ModalDialog","ShowPopupDialog","concatWithoutDuplicates","arr1","arr2","angular","isArray","concat","a","some","b","cleanSearchTerm","searchTerm","defaultTerm","trim","$inject","$scope","helpers","customerProjects","CustomerProjectsAggregationHelper","arrayOfPages","vm","exports","getMasterDataUrl","projectUrl","prepareForRepeat","projectStatus","projectStatusDate","Date","order","ProjectStatus","text","getFullYear","Commercialized","Expired","Material specified","Sample sent","Offer sent","Inquiry received","n/a","Project stopped"],"mappings":"qLA4BA,IAAAA,GA4BCA,EAAAC,UAAAC,OAAA,SAAOC,GACNC,KAAKD,QAAQE,YAAcF,EAAQE,YACnCD,KAAKD,QAAQG,YAAcH,EAAQG,YACnCF,KAAKD,QAAQI,eAAgB,EAC7BH,KAAKD,QAAQK,YAAcJ,KAAKK,sBAAsBC,eAAeP,EAAQK,aAAeJ,KAAKD,QAAQK,aACzGJ,KAAKD,QAAQQ,gBAAkBP,KAAKK,sBAAsBC,eAAeP,EAAQQ,iBAAmBP,KAAKD,QAAQQ,iBACjHP,KAAKD,QAAQS,YAAcT,EAAQS,YACnCR,KAAKD,QAAQU,kBAAoBV,EAAQU,kBACzC,IAAIC,EAASC,OAAOC,SAASF,OAASC,OAAOC,SAASF,OACpDC,OAAOC,SAASC,SAAW,KAAOF,OAAOC,SAASE,UAAYH,OAAOC,SAASG,KAAO,IAAMJ,OAAOC,SAASG,KAAO,IACpHf,KAAKD,QAAQiB,YAAcN,EAASC,OAAW,GAAEM,aAAa,gBAC9DjB,KAAKD,QAAQmB,sCAAwCP,OAAW,GAAEM,aAAa,6CAC/EjB,KAAKD,QAAQoB,+BAAiCR,OAAW,GAAEM,aAAa,8CACxEjB,KAAKD,QAAQqB,qCAAuCT,OAAW,GAAEM,aAAa,qDAC9EjB,KAAKD,QAAQsB,MAAQrB,KAAKD,QAAQiB,YAAcjB,EAAQsB,MACxDrB,KAAKD,QAAQuB,4BAA8BZ,EAASC,OAAW,GAAEM,aAAa,gBAAkBlB,EAAQuB,4BACxGtB,KAAKuB,eAAiBvB,KAAKwB,cAAcD,eACzCvB,KAAKD,QAAQ0B,UAAY1B,EAAQ0B,UACjCzB,KAAKD,QAAQ2B,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ChBvH,EAAKwH,kBAAoBxH,EAAKsE,aAG9BtE,EAAKwH,kBAAoB,IAAIC,KAAK,GAEnCzH,EAAK0H,MAAQV,EAAkCW,cAAcJ,GAAeG,MAC5E1H,EAAKmE,kBAAoB6C,EAAkCW,cAAcJ,GAAeK,KACnE,OAAjBL,IACHvH,EAAKmE,mBAAqB,KAAO,IAAIsD,KAAKzH,EAAKwH,mBAAmBK,cAAgB,KAKpF,OAAOxE,GAtFM2D,EAAAW,cAAgB,CAC7BG,eAAkB,CACjBJ,MAAO,EACPE,KAAM,sBAEPG,QAAW,CACVL,MAAO,EACPE,KAAM,gBAEPI,qBAAsB,CACrBN,MAAO,EACPE,KAAM,2BAEPK,cAAe,CACdP,MAAO,EACPE,KAAM,qBAEPM,aAAc,CACbR,MAAO,EACPE,KAAM,mBAEPO,mBAAoB,CACnBT,MAAO,EACPE,KAAM,wBAEPQ,MAAO,CACNV,MAAO,KACPE,KAAM,OAEPS,kBAAmB,CAClBX,MAAO,KACPE,KAAM,oBAyDTZ,GA1FA,SAAAA,KAAaG,EAAAH,kCAAAA","file":"customerProjectsAggregationController.js","sourcesContent":["import * as _ from 'lodash';\r\nimport * as angular from 'angular';\r\nimport '../polyfills';\r\nimport { SearchOptions } from '../spext/services/spSearchOptions';\r\nimport { SearchService } from '../spext/services/spSearchService';\r\nimport { TemplateHelperService } from 'helpers/templateHelperService';\r\n\r\ninterface ICustomerProjectsAggregationConfig {\r\n\tproductCode: string,\r\n\tproductName: string,\r\n\thideSearchBox: boolean,\r\n\titemTemplateUrl: string,\r\n\ttemplateUrl: string,\r\n\tpassthrough: any,\r\n\thelpers: any,\r\n\tpreRepeatFunction: any,\r\n\tluPoBaseUrl : string,\r\n\tpublishedDocumentsSearchQueryTemplate : string,\r\n\tpublishedDocumentsProjectKeyProperty: string,\r\n\tpublishedDocumentsTypeProperty: string,\r\n\tquery: string,\r\n\thiddenTaxonomyListQueryBase: string,\r\n\tlistTitle: string,\r\n\tshowList: boolean,\r\n\tlinkUrl: string,\r\n\tlinkTitle: string\r\n}\r\n\r\nexport class CustomerProjectsAggregationController {\r\n\r\n\tpublic options = {\r\n\t\titemTemplateUrl: ``,\r\n\t\ttemplateUrl: ``,\r\n\t\tpassthrough: {},\r\n\t\thelpers: { 'customerProjects': new CustomerProjectsAggregationHelper() },\r\n\t\tpreRepeatFunction: function (items) { return items; },\r\n\t\tlistTitle: ``,\r\n\t\tshowList: false\r\n\t} as ICustomerProjectsAggregationConfig;\r\n\r\n\tresultItems: any[] = [];\r\n\tisLoading: boolean = false;\r\n\tisError: boolean = false;\r\n\terrorMessage: string;\r\n\tarrayOfPages: any[] = [];\r\n\twebAbsoluteUrl: string;\r\n\r\n\tprivate coreApplicationField = 'lpApplication';\r\n\tprivate partField = 'lpPart';\r\n\tprivate taxonomyHiddenListWhereClauseCount = 10;\r\n\r\n\tstatic $inject = ['$http', '$log', '$scope', '$window', '$q', '_lumasContext', 'templateHelperService', 'searchService'];\r\n\tconstructor(private $http, private $log, private $scope: any, private $window: any, private $q: angular.IQService, private _lumasContext: any, private templateHelperService: TemplateHelperService, private searchService: SearchService) {\r\n\t\t$scope.vm = this;\r\n\t}\r\n\r\n\tconfig(options: ICustomerProjectsAggregationConfig) {\r\n\t\tthis.options.productCode = options.productCode;\r\n\t\tthis.options.productName = options.productName;\r\n\t\tthis.options.hideSearchBox = true;\r\n\t\tthis.options.templateUrl = this.templateHelperService.getTemplateUrl(options.templateUrl || this.options.templateUrl);\r\n\t\tthis.options.itemTemplateUrl = this.templateHelperService.getTemplateUrl(options.itemTemplateUrl || this.options.itemTemplateUrl);\r\n\t\tthis.options.passthrough = options.passthrough;\r\n\t\tthis.options.preRepeatFunction = options.preRepeatFunction;\r\n\t\tvar origin = window.location.origin ? window.location.origin :\r\n\t\t\t(window.location.protocol + \"//\" + window.location.hostname + (window.location.port ? ':' + window.location.port : ''));\r\n\t\tthis.options.luPoBaseUrl = origin + window['Ll'].PortalConfig['LuPoBase Url'];\r\n\t\tthis.options.publishedDocumentsSearchQueryTemplate = window['Ll'].PortalConfig['LuPoBase published documents search query'];\r\n\t\tthis.options.publishedDocumentsTypeProperty = window['Ll'].PortalConfig['LuPoBase published documents type property'];\r\n\t\tthis.options.publishedDocumentsProjectKeyProperty = window['Ll'].PortalConfig['LuPoBase published documents project key property'];\r\n\t\tthis.options.query = this.options.luPoBaseUrl + options.query;\r\n\t\tthis.options.hiddenTaxonomyListQueryBase = origin + window['Ll'].PortalConfig['LuPoBase Url'] + options.hiddenTaxonomyListQueryBase;\r\n\t\tthis.webAbsoluteUrl = this._lumasContext.webAbsoluteUrl;\r\n\t\tthis.options.listTitle = options.listTitle;\r\n\t\tthis.options.showList = options.showList;\r\n\t\tthis.options.linkTitle = 'Lupobase';\r\n\t\tthis.options.linkUrl = window['Ll'].PortalConfig['LuPoBase link URL']\r\n\t\tthis.search();\r\n\t}\r\n\r\n\tsearch() {\r\n\t\tvar self = this;\r\n\r\n\t\tif (window['usernotauthorizedforlupobase']) {\r\n\t\t\tthis.isError = true;\r\n\t\t\tthis.errorMessage = 'Sorry, you don\\'t have permissions to read LuPoBase';\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis.isError = false;\r\n\t\tif (this.resultItems.length == 0) {\r\n\t\t\tthis.isLoading = true;\r\n\t\t}\r\n\r\n\t\tvar headers = {\r\n\t\t\t'content-type': 'application/json;odata=verbose',\r\n\t\t\t'accept': 'application/json;odata=verbose',\r\n\t\t\t'X-RequestDigest': document.getElementById('__REQUESTDIGEST').getAttribute('value')\r\n\t\t};\r\n\r\n\t\t//postquery doc at https://msdn.microsoft.com/en-us/library/office/jj163876.aspx\r\n\t\t//getting started with postquery at https://rmanimaran.wordpress.com/2014/10/15/sharepoint-2013-rest-api-search-using-http-post/\r\n\t\tthis.$http({\r\n\t\t\tmethod: 'GET',\r\n\t\t\turl: this.options.query,\r\n\t\t\theaders: headers\r\n\t\t})\r\n\t\t.then((data) => {\r\n\t\t\tthis.resultItems = CustomerProjectsAggregationController.parseCustomerProjectItems(data.data.d.results);\r\n\t\t\treturn this.resultItems;\r\n\t\t}, err => {\r\n\t\t\tthis.isError = true;\r\n\t\t\tif (err.status == 401) {\r\n\t\t\t\tthis.errorMessage = 'Sorry, you don\\'t have permissions to read LuPoBase';\r\n\t\t\t\twindow['usernotauthorizedforlupobase'] = true;\r\n\t\t\t}\r\n\r\n\t\t\treturn null;\r\n\t\t})\r\n\t\t.then((data) => {\r\n\t\t\tif(!data)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tvar termRetrieveFields = [this.coreApplicationField, this.partField];\r\n\t\t\tvar filterTexts = [];\r\n\t\t\t// retrieving term ids\r\n\t\t\tfor(var item of this.resultItems)\r\n\t\t\t{\r\n\t\t\t\tfor(var termRetrieveField of termRetrieveFields) {\r\n\t\t\t\t\tvar termFieldData = item[termRetrieveField];\r\n\t\t\t\t\tif(!termFieldData)\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\tvar itemTermId = termFieldData.TermGuid;\r\n\t\t\t\t\tvar filter = 'IdForTerm eq \\'' + itemTermId + '\\'';\r\n\t\t\t\t\tif(filterTexts.indexOf(filter) == -1) {\r\n\t\t\t\t\t\tfilterTexts.push(filter);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tvar queries = [];\r\n\t\t\tvar queryTextBase = this.options.hiddenTaxonomyListQueryBase + '&$filter=';\r\n\t\t\twhile(filterTexts.length > 0) {\r\n\t\t\t\tvar reducedFilterTexts = filterTexts.splice(0, filterTexts.length > this.taxonomyHiddenListWhereClauseCount ? this.taxonomyHiddenListWhereClauseCount : filterTexts.length);\r\n\t\t\t\tvar queryText = queryTextBase + reducedFilterTexts.join(' or ');\r\n\t\t\t\tqueries.push(queryText)\r\n\t\t\t}\r\n\r\n\t\t\treturn this.$q.all(queries.map(q => {\r\n\t\t\t\treturn this.$http({\r\n\t\t\t\t\tmethod: 'GET',\r\n\t\t\t\t\turl: q,\r\n\t\t\t\t\theaders: headers\r\n\t\t\t\t});\r\n\t\t\t})).then((responses) => {\r\n\t\t\t\t// merging the responses\r\n\t\t\t\tvar taxonomyHiddenList = [];\r\n\t\t\t\tfor(var i = 0; i < responses.length; i++) {\r\n\t\t\t\t\tvar response = responses[i];\r\n\r\n\t\t\t\t\t// i love web requests ❤\r\n\t\t\t\t\tif(response && response.data && response.data.d && response.data.d.results) {\r\n\t\t\t\t\t\ttaxonomyHiddenList.push.apply(taxonomyHiddenList, response.data.d.results);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn taxonomyHiddenList;\r\n\t\t\t});\r\n\t\t})\r\n\t\t.then((taxonomyHiddenList) => {\r\n\t\t\tvar defaultTermLanguageId = '1033';\r\n\t\t\t\r\n\t\t\tvar data = taxonomyHiddenList;\r\n\t\t\tvar termRetrieveFields = [this.coreApplicationField, this.partField];\r\n\t\t\tfor(var termRetrieveField of termRetrieveFields) {\r\n\t\t\t\tfor(var item of this.resultItems) {\r\n\t\t\t\t\tvar termFieldData = item[termRetrieveField];\r\n\t\t\t\t\tif(!termFieldData)\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\r\n\t\t\t\t\tvar taxElement = data.find((elem) => {\r\n\t\t\t\t\t\treturn elem.IdForTerm == termFieldData.TermGuid;\r\n\t\t\t\t\t});\r\n\t\t\t\t\titem[termRetrieveField + 'Title'] = taxElement['Term' + defaultTermLanguageId];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t\t.then(()=>{\r\n\t\t\tvar resultItemProjectDocCalls = [];\r\n\t\t\tvar searchQueryTemplate = this.options.publishedDocumentsSearchQueryTemplate;\r\n\t\t\tvar searchQuery = searchQueryTemplate.replace(\"{materialSapId}\", this.options.productCode);\r\n\r\n\t\t\tconst searchOptions = new SearchOptions();\r\n\t\t\tsearchOptions.setRowLimit(999);\r\n\t\t\tsearchOptions.setSelectPropertiesMap([{ 'url': 'Path' }, { 'type': this.options.publishedDocumentsTypeProperty }, { 'projectKey': this.options.publishedDocumentsProjectKeyProperty }]);\r\n\t\t\tsearchOptions.setRequestDigest(document.getElementById('__REQUESTDIGEST').getAttribute('value'));\r\n\r\n\t\t\treturn this.searchService.search(searchQuery, searchOptions);\r\n\t\t})\r\n\t\t.then((projectDocSearchResults)=>{\r\n\t\t\tfor (var projectDocRowIndex in projectDocSearchResults.rows) {\r\n\t\t\t\tvar projectDocSearchResult = projectDocSearchResults.rows[projectDocRowIndex];\r\n\t\t\t\tvar projectKey = projectDocSearchResult.projectKey;\r\n\t\t\t\tvar type = projectDocSearchResult.type;\r\n\t\t\t\tvar url = projectDocSearchResult.url;\r\n\t\t\t\tfor (var resultItemIndex in this.resultItems) {\r\n\t\t\t\t\tvar resultItem = this.resultItems[resultItemIndex];\r\n\t\t\t\t\tif ((resultItem.title != null && resultItem.title.indexOf(projectKey) == 0) || (projectKey != null && projectKey.indexOf(resultItem.title) == 0)) {\r\n\t\t\t\t\t\tif (type == \"Case Study\" && (resultItem.statusDate5 || resultItem.statusDate6)) {\r\n\t\t\t\t\t\t\tresultItem.projectDocUrl = url;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if (type == \"Project Report\" && !resultItem.projectDocUrl) {\r\n\t\t\t\t\t\t\tresultItem.projectDocUrl = url;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t\t.finally(() => {\r\n\t\t\tthis.isLoading = false;\r\n\t\t});;\r\n\r\n\t\tthis.$log.log(`[listAggregation] getting: ${this.options.query}`);\r\n\t}\r\n\r\n\tprivate static parseCustomerProjectItems(items: any[]) {\r\n\t\tvar parsedResults = [];\r\n\t\tif (items != null && items.length > 0) {\r\n\t\t\t_.forEach(items, (item) => {\r\n\t\t\t\tparsedResults.push({\r\n\t\t\t\t\turl: item.FileRef,\r\n\t\t\t\t\ttitle: item.Title,\r\n\t\t\t\t\tspecifier: item.lpSpecifier != null ? item.lpSpecifier.Title : '',\r\n\t\t\t\t\tspecifierId: item.lpSpecifier != null ? item.lpSpecifier.ID : 0,\r\n\t\t\t\t\tsegment: item.lpSegment != null ? item.lpSegment.lpSegmentCode : '',\r\n\t\t\t\t\tsegmentId: item.lpSegment != null ? item.lpSegment.ID : 0,\r\n\t\t\t\t\tprojectStatusText: '',\r\n\t\t\t\t\tstoppedDate: item.lpProjectStoppedDate,\r\n\t\t\t\t\tstatusDate1: item.lpStatus1Date,\r\n\t\t\t\t\tstatusDate2: item.lpStatus2Date,\r\n\t\t\t\t\tstatusDate3: item.lpStatus3Date,\r\n\t\t\t\t\tstatusDate4: item.lpStatus4Date,\r\n\t\t\t\t\tstatusDate5: item.lpStatus5Date,\r\n\t\t\t\t\tstatusDate6: item.lpStatus6Date,\r\n\t\t\t\t\tlpApplication: item.lpApplication,\r\n\t\t\t\t\tlpPart: item.lpPart\r\n\t\t\t\t})\r\n\t\t\t});\r\n\t\t}\r\n\t\treturn parsedResults;\r\n\t}\r\n\r\n\tgetGlobalVariable(variableName: string) {\r\n\t\treturn this.$window[variableName];\r\n\t}\r\n\r\n\topenLuPoBasePopup(type: string, id: number) {\r\n\t\tvar siteRelativeUrl = '';\r\n\t\tswitch (type) {\r\n\t\t\tcase 'segment':\r\n\t\t\t\tsiteRelativeUrl = '/Lists/segments/DispForm.aspx?ID=' + id;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'specifier':\r\n\t\t\t\tsiteRelativeUrl = '/Lists/customers/DispForm.aspx?ID=' + id;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\treturn;\r\n\t\t}\r\n\t\tvar self = this;\r\n\t\tEnsureScriptFunc('sp.ui.dialog.js');\r\n\t\tExecuteOrDelayUntilScriptLoaded(function () {\r\n\t\t\tSP.UI.ModalDialog.ShowPopupDialog(self.options.luPoBaseUrl + siteRelativeUrl);\r\n\t\t}, 'sp.ui.dialog.js');\r\n\t}\r\n\r\n\tprivate static concatWithoutDuplicates(arr1: any[], arr2: any[]) {\r\n\t\tif (!angular.isArray(arr1) || !angular.isArray(arr2)) {\r\n\t\t\treturn arr1 || arr2;\r\n\t\t}\r\n\t\treturn arr1.concat(arr2.filter((a) => {\r\n\t\t\treturn !arr1.some((b) => { return a === b; })\r\n\t\t}));\r\n\t}\r\n\r\n\tprivate static cleanSearchTerm(searchTerm: string, defaultTerm: string) {\r\n\t\treturn ((searchTerm || ``).trim() || defaultTerm).replace(/[*\\s]*$/, `*`);\r\n\t}\r\n}\r\n\r\nexport class CustomerProjectsAggregationHelper {\r\n\r\n\tpublic static ProjectStatus = {\r\n\t\t'Commercialized': {\r\n\t\t\torder: 1,\r\n\t\t\ttext: 'V - Commercialized'\r\n\t\t},\r\n\t\t'Expired': {\r\n\t\t\torder: 2,\r\n\t\t\ttext: 'VI - Expired'\r\n\t\t},\r\n\t\t'Material specified': {\r\n\t\t\torder: 3,\r\n\t\t\ttext: 'IV - Material specified'\r\n\t\t},\r\n\t\t'Sample sent': {\r\n\t\t\torder: 4,\r\n\t\t\ttext: 'III - Sample sent'\r\n\t\t},\r\n\t\t'Offer sent': {\r\n\t\t\torder: 5,\r\n\t\t\ttext: 'II - Offer sent'\r\n\t\t},\r\n\t\t'Inquiry received': {\r\n\t\t\torder: 6,\r\n\t\t\ttext: 'I - Inquiry received'\r\n\t\t},\r\n\t\t'n/a': {\r\n\t\t\torder: 9998,\r\n\t\t\ttext: 'N/A'\r\n\t\t},\r\n\t\t'Project stopped': {\r\n\t\t\torder: 9999,\r\n\t\t\ttext: 'Project stopped'\r\n\t\t}\r\n\t}\r\n\r\n\tgetMasterDataUrl(projectUrl: string) {\r\n\t\treturn projectUrl.replace(/-\\d{2}.aspx$/g, '.aspx');\r\n\t}\r\n\r\n\tprepareForRepeat(items: any[]) {\r\n\t\tif (!items || items.length <= 0)\r\n\t\t\treturn items;\r\n\r\n\t\tfor (var i = 0; i < items.length; i++) {\r\n\t\t\tvar item = items[i];\r\n\t\t\tvar projectStatus = 'n/a';\r\n\r\n\t\t\tif (item.stoppedDate) {\r\n\t\t\t\tprojectStatus = 'Project stopped';\r\n\t\t\t\titem.projectStatusDate = item.stoppedDate;\r\n\t\t\t}\r\n\t\t\telse if (item.statusDate6) {\r\n\t\t\t\tprojectStatus = 'Expired';\r\n\t\t\t\titem.projectStatusDate = item.statusDate6;\r\n\t\t\t}\r\n\t\t\telse if (item.statusDate5) {\r\n\t\t\t\tprojectStatus = 'Commercialized';\r\n\t\t\t\titem.projectStatusDate = item.statusDate5;\r\n\t\t\t}\r\n\t\t\telse if (item.statusDate4) {\r\n\t\t\t\tprojectStatus = 'Material specified';\r\n\t\t\t\titem.projectStatusDate = item.statusDate4;\r\n\t\t\t}\r\n\t\t\telse if (item.statusDate3) {\r\n\t\t\t\tprojectStatus = 'Sample sent';\r\n\t\t\t\titem.projectStatusDate = item.statusDate3;\r\n\t\t\t}\r\n\t\t\telse if (item.statusDate2) {\r\n\t\t\t\tprojectStatus = 'Offer sent';\r\n\t\t\t\titem.projectStatusDate = item.statusDate2;\r\n\t\t\t}\r\n\t\t\telse if (item.statusDate1) {\r\n\t\t\t\tprojectStatus = 'Inquiry received';\r\n\t\t\t\titem.projectStatusDate = item.statusDate1;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\titem.projectStatusDate = new Date(0);\r\n\t\t\t}\r\n\t\t\titem.order = CustomerProjectsAggregationHelper.ProjectStatus[projectStatus].order;\r\n\t\t\titem.projectStatusText = CustomerProjectsAggregationHelper.ProjectStatus[projectStatus].text;\r\n\t\t\tif (projectStatus != 'n/a') {\r\n\t\t\t\titem.projectStatusText += ' (' + new Date(item.projectStatusDate).getFullYear() + ')';\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\treturn items;\r\n\t}\r\n}"]}