{"version":3,"sources":["Honeywell.ClientModel.FloatingToolKit.ts"],"names":["FloatingToolKit","binderElement","this","BinderElement","prototype","checkInfo","displayInfoList","il","Honeywell_ClientModel_MainHelper_1","MainHelper","floatingKits","ListName","loadInfo","loadBinderQuantity","loadBinder","listname","qry","languageQuery","dataService","Honeywell_ClientModel_DataService_1","DataService","dataPromise","getListItems","then","listItemsToArray","templatePromise","Honeywell_ClientModel_TemplateService_1","TemplateService","getTemplate","Q","all","renderList","catch","handleError","values","length","items","template","$","show","data","Items","resx","userLanguageTerms","document","getElementById","innerHTML","reason","html","exports","on","e","bind","toolKit"],"mappings":"yOAKA,IAAAA,GAAA,WAGI,QAAAA,GAAYC,GACRC,KAAKC,cAAgBF,EA6E7B,MA1EID,GAAAI,UAAAC,UAAA,WACI,GAAIC,IAAkB,CACtB,KAAK,GAAIC,KAAMC,GAAAC,WAAWC,aACtB,GAA6C,oBAAzCF,EAAAC,WAAWC,aAAaH,GAAII,SAAgC,CAC5DL,GAAkB,CAClB,OAIR,GAAIA,EAGA,MAAOJ,MAAKU,SAAS,oBAM7BZ,EAAAI,UAAAS,mBAAA,WACIL,EAAAC,WAAWK,YAAW,IAM1Bd,EAAAI,UAAAQ,SAAA,SAASG,GACL,GAAIC,GAAM,yFAA2FR,EAAAC,WAAWQ,cAAgB,yBAC5HC,EAAc,GAAIC,GAAAC,aAAY,EAAML,EAAU,kBAAmB,SAAWC,EAAM,kCAElFK,EAAcH,EAAYI,eAAeC,KAAKL,EAAYM,kBAE1DC,EAAkB,GAAIC,GAAAC,gBAAgB,wBAAwBC,aAMlE,OAAOC,GAAEC,KAAUT,EAAaI,IAAkBF,KAAKrB,KAAK6B,YAAYC,MAAM9B,KAAK+B,cAMvFjC,EAAAI,UAAA2B,WAAA,SAAWG,GAEP,GAAIA,EAAOC,OAAS,EAChB,KAAM,+BAGV,IAAIC,GAAgBF,EAAO,GAEvBG,EAAWH,EAAO,EAClBE,GAAMD,OAAS,GACfG,EAAE,oBAAoBC,MAM1B,IAAIC,IACAC,MAAOL,EACPM,KAAMlC,EAAAC,WAAWkC,kBAMrB,OAFAC,UAASC,eAAe,qBAAqBC,UAAYT,EAASG,GAE3DN,GAGXlC,EAAAI,UAAA6B,YAAA,SAAYc,GACRT,EAAE,sBAAsBU,KAAK,6BAA+BD,EAAS,UAG7E/C,IAjFaiD,GAAAjD,gBAAAA,EAmFbsC,EAAEM,UAAUM,GAAG,kBAAmB,SAAUC,GACxC,GAAIC,GAAOR,SAASC,eAAe,kBAC/BQ,EAAU,GAAIrD,GAAgBoD,EAClCC,GAAQxC,qBACRwC,EAAQhD","file":"Honeywell.ClientModel.FloatingToolKit.js","sourcesContent":["///\r\nimport {MainHelper} from \"./Honeywell.ClientModel.MainHelper\";\r\nimport {DataService} from \"./Honeywell.ClientModel.DataService\";\r\nimport {TemplateService} from \"./Honeywell.ClientModel.TemplateService\";\r\nimport * as Q from \"q\";\r\nexport class FloatingToolKit {\r\n BinderElement: HTMLElement;\r\n\r\n constructor(binderElement: HTMLElement) {\r\n this.BinderElement = binderElement;\r\n }\r\n\r\n checkInfo() {\r\n var displayInfoList = false;\r\n for (var il in MainHelper.floatingKits) {\r\n if (MainHelper.floatingKits[il].ListName === 'InformationList') {\r\n displayInfoList = false;//MainHelper.floatingKits[il].IsActive;\r\n break;\r\n }\r\n }\r\n\r\n if (displayInfoList) {\r\n //Methods that create promise must return promise.\r\n //Otherwise it will not work correctly\r\n return this.loadInfo('InformationList');\r\n }\r\n }\r\n\r\n\r\n\r\n loadBinderQuantity() {\r\n MainHelper.loadBinder(true);\r\n }\r\n\r\n /**\r\n * This methods loads info. and also applies template\r\n */\r\n loadInfo(listname: string) {\r\n var qry = \"1\" + MainHelper.languageQuery + \"\";\r\n var dataService = new DataService(true, listname, 'InformationList', \"\" + qry + \"99\");\r\n //Getting the promise for data coming from SharePoint list), then converting to the array of Model objects\r\n var dataPromise = dataService.getListItems().then(dataService.listItemsToArray);\r\n //Getting the second promise, for the template\r\n var templatePromise = new TemplateService(\"tpl_Information.html\").getTemplate();\r\n //When both requests are done, execute renderList(). In case of any error call handleError.\r\n //Please note, that Q.all expects an array of the elements of the same type, \r\n //and for this reason I have to explicitly cast the type to any.\r\n //This makes me sad. Maybe there is a better way.\r\n //We must return this Promise, otherwise downstream methods will be broken.\r\n return Q.all([dataPromise, templatePromise]).then(this.renderList).catch(this.handleError);\r\n }\r\n\r\n /**\r\n * I re-implemented this method to be synchronous.\r\n */\r\n renderList(values: any[]) {\r\n //The array contains two elements.\r\n if (values.length < 2) {\r\n throw \"Too few elements in the array\";\r\n }\r\n //The first element is the result of the first promise, in our case an array of model objects\r\n var items = values[0];\r\n //The second element is the result of the second promise, in our case a string.\r\n var template = values[1];\r\n if (items.length > 0) {\r\n $('#js-load-info-li').show();\r\n //Should we return here?\r\n // return values;\r\n }\r\n\r\n // I like object literal syntax, but that's just a matter of style\r\n var data = {\r\n Items: items,\r\n resx: MainHelper.userLanguageTerms\r\n }\r\n //Compile calling here rather than inside the template service\r\n //Applying the template\r\n document.getElementById('js-drawer-content').innerHTML = template(data);\r\n //We must return here, otherwise the downstream methods will be broken\r\n return values;\r\n }\r\n\r\n handleError(reason: string) {\r\n $('#js-drawer-content').html(\"

Failed To Load on page\" + reason + \"

\");\r\n }\r\n\r\n}\r\n\r\n$(document).on('SPContextLoaded', function (e) {\r\n var bind = document.getElementById('js-load-binder');\r\n var toolKit = new FloatingToolKit(bind);\r\n toolKit.loadBinderQuantity();\r\n toolKit.checkInfo();\r\n\r\n\r\n});"]}