{"version":3,"sources":["pages/CommunityRegionPage.js"],"names":["CommunityRegionPage","Init","communityRegionID","userHasAccessToDetails","showListings","mapModel","$","Common","InitEmail","d","OutletID","data","OutletServiceID","CategoryID","CouncilRegionID","FromName","val","FromEmail","Phone","Message","LoadPromotions","regionId","showDetails","addrTitle","fullCount","DataTable","scrollX","lengthChange","ordering","info","searching","paging","pageLength","pagingType","processing","serverSide","searchDelay","stateSave","language","emptyTable","zeroRecords","columns","title","className","ajax","callback","settings","s","search","value","p","start","url","draw","hasServiceChanges","is","getJSON","Total","a","recordsTotal","recordsFiltered","outletLookup","scrollToTable","animate","scrollTop","offset","top","Results","forEach","item","phone","addr","pstripped","Outlet","replace","length","DisplayAddress","Url","Suburb","services","SubResults","service","categoryName","Category","Name","serviceName","Service","DisplayName","openHours","OpenHours","popup","ServiceChanges","serviceChangeList","change","locationUrl","Nickname","locationAddr","outletID","compositeKey","entry","nickname","address","push","map","off","on","dataTable","api","reload","serviceChangeContent","this","find","empty","append","html","show","text","attr","modal","e","Page","ShowThinking","loadListings","Loaded","google","maps","event","addDomListener","window","mapOptions","center","LatLng","CentralLatitude","CentralLongitude","zoom","mapTypeId","MapTypeId","ROADMAP","Map","document","getElementById","KmlLayer","KmlLocation","setMap"],"mappings":"AAAA,IAAIA,qBAqMDA,sBAAwBA,oBAAsB,KADzBC,KAnCpB,SAAcC,EAAmBC,EAAwBC,EAAcC,GACnEC,EAAE,WAiBE,GAhBAC,OAAOC,UAAU,SAAUC,GACvB,MAAO,CACHC,SAAUD,EAAEE,KAAK,UACjBC,gBAAiBH,EAAEE,KAAK,WACxBE,WAAYJ,EAAEE,KAAK,YACnBG,gBAAiBL,EAAEE,KAAK,UACxBI,SAAUT,EAAE,aAAaU,MACzBC,UAAWX,EAAE,cAAcU,MAC3BE,MAAOZ,EAAE,cAAcU,MACvBG,QAASb,EAAE,gBAAgBU,SAGnCT,OAAOa,iBACHhB,GA9KZ,SAAsBiB,EAAUC,GAC5B,IAAIC,EAEAA,E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1FL,EAAE,yBAAyByG,KAAK,8BAA8BM,KAAK,OAAQ/G,EAAEwG,MAAMnG,KAAK,eACxFL,EAAE,yBAAyBgH,MAAM,eAI9Cb,GAAG,gBAAiB,SAAUc,EAAGzE,EAAUZ,GACtCA,GACAsF,KAAKC,aAAa,0BAG1BnH,EAAE,sCAAsC+G,KAAK,aAAc,sDAkBnDK,CAAaxH,EAAmBC,GAEhCE,EAASsH,OAAQ,CACjB,IAAIpB,EAYJqB,OAAOC,KAAKC,MAAMC,eAAeC,OAAQ,OAVzC,WACI,IAAIC,EAAa,CACbC,OAAQ,IAAIN,OAAOC,KAAKM,OAAO9H,EAAS+H,gBAAiB/H,EAASgI,kBAClEC,KAAM,GACNC,UAAWX,OAAOC,KAAKW,UAAUC,SAErClC,EAAM,IAAIqB,OAAOC,KAAKa,IAAIC,SAASC,eAAe,cAAeX,GACjD,IAAIL,OAAOC,KAAKgB,SAAS,CAAEzF,IAAK/C,EAASyI,YAAc,SACzDC,OAAOxC","file":"CommunityRegionPage.min.js","sourcesContent":["var CommunityRegionPage;\r\n(function (CommunityRegionPage) {\r\n function loadListings(regionId, showDetails) {\r\n var addrTitle;\r\n if (showDetails) {\r\n addrTitle = \"Address\";\r\n }\r\n else {\r\n addrTitle = \"Suburb\";\r\n }\r\n var fullCount = -1;\r\n $('#listings').DataTable({\r\n scrollX: true,\r\n lengthChange: false,\r\n ordering: false,\r\n info: true,\r\n searching: true,\r\n paging: true,\r\n pageLength: 20,\r\n pagingType: \"full_numbers\",\r\n processing: true,\r\n serverSide: true,\r\n searchDelay: 1500,\r\n stateSave: false,\r\n language: {\r\n emptyTable: \"No locations\",\r\n zeroRecords: \"No matching locations\"\r\n },\r\n //oLanguage: {\r\n // sSearch: \"Search by Location, Service, or Category:\"\r\n //},\r\n columns: [\r\n { title: \"Location\" },\r\n { title: addrTitle, className: \"\" },\r\n { title: \"Contact\", className: \"centered\" },\r\n { title: \"Service - Category\", className: \"services\" },\r\n ],\r\n ajax: function (data, callback, settings) {\r\n var s = data.search.value || \"-\";\r\n var p = (data.start / 20) + 1;\r\n var url = \"/api/search/regional/\" + regionId + \"/\" + s + \"/\" + p + \"/\" + data.draw;\r\n var hasServiceChanges = $('#service-changes-filter').is(':checked') == true ? 1 : 0;\r\n if ($('#ListingsWithinCouncilID').val() > 0) {\r\n url = \"/api/search/regioncouncil/\" + $('#ListingsWithinCouncilID').val() + \"/\" + s + \"/\" + p + \"/\" + data.draw + \"/\" + hasServiceChanges;\r\n }\r\n $.getJSON(url, function (d) {\r\n if (fullCount === -1) {\r\n fullCount = d.Total;\r\n }\r\n var a = { data: [], recordsTotal: fullCount, recordsFiltered: d.Total };\r\n // Object to track existing outlet entries by a composite key of OutletID and Phone\r\n var outletLookup = {};\r\n d.Results.forEach(function (item) {\r\n var phone, addr;\r\n phone = item.Outlet.Phone || \"\";\r\n var pstripped = phone.replace(/[^0-9]+/g, \"\");\r\n phone = pstripped.length === 0 ? \"\" : \"<a href='tel:\" + pstripped + \"'><span>\" + phone + \"</span></a>\";\r\n addr = \"<span>\" + item.Outlet.DisplayAddress + \"</span>\";\r\n if (!showDetails) {\r\n phone = \"<a href='\" + item.Url + \"' class='btn btn-small btn-blue'><span>Contact Us</span></a>\";\r\n addr = item.Outlet.Suburb;\r\n }\r\n var services = \"<ul>\"; // Start the unordered list\r\n item.SubResults.forEach(function (service) {\r\n var categoryName = service.Category.Name;\r\n if (!categoryName || categoryName.length < 1)\r\n categoryName = item.Category.Name;\r\n var serviceName = item.Service.DisplayName;\r\n if (!serviceName || serviceName.length < 1)\r\n serviceName = categoryName;\r\n var openHours = '';\r\n if (item.OpenHours && item.OpenHours !== null) {\r\n openHours = \"(\" + item.OpenHours + \") \";\r\n }\r\n var popup = '';\r\n if (item.ServiceChanges && item.ServiceChanges.length > 0) {\r\n var serviceChangeList = '<ul>';\r\n item.ServiceChanges.forEach(function (change) {\r\n serviceChangeList += \"<li>\" + change + \"</li>\";\r\n });\r\n serviceChangeList += '</ul>';\r\n var locationUrl = \"/Outlet/\" + item.Outlet.OutletID + \"/\" + item.Outlet.Nickname.replace(/[^a-zA-Z0-9]+/g, '_');\r\n var locationAddr = addr;\r\n if (showDetails) {\r\n locationAddr = item.Outlet.DisplayAddress;\r\n }\r\n popup = \"\\n <span class=\\\"service-change-popup\\\" data-toggle=\\\"tooltip\\\" data-placement=\\\"top\\\" title=\\\"This service has new changes. Click this icon to View\\\" data-service-link=\\\"\" + service.Url + \"\\\" data-outlet-url=\\\"\" + locationUrl + \"\\\" data-service-id=\\\"\" + item.OutletServiceID + \"\\\" data-service-name=\\\"\" + serviceName + \"\\\" data-service-category=\\\"\" + categoryName + \"\\\" data-location-name=\\\"\" + item.Outlet.Nickname + \"\\\" data-location-address=\\\"\" + locationAddr + \"\\\">\\n <i class=\\\"fa-solid fa-triangle-exclamation\\\" style=\\\"color: #C65010;\\\"></i>\\n <div class=\\\"popup-content\\\" style=\\\"display:none;\\\">\\n \" + serviceChangeList + \"\\n </div>\\n </span>\\n \\n \";\r\n }\r\n services += \"<li>\" + popup + openHours + \"<a href='\" + service.Url + \"'><span>\" + serviceName + \"</span></a><span> - \" + categoryName + \"</span></li>\";\r\n });\r\n services += \"</ul>\"; // Close the unordered list\r\n var outletID = item.Outlet.OutletID;\r\n var compositeKey = \"\" + outletID; // Create a composite key\r\n // Check if the outlet already exists in the lookup\r\n if (outletLookup[compositeKey]) {\r\n // If it exists, just append the new service to the existing services\r\n outletLookup[compositeKey].services += services;\r\n }\r\n else {\r\n var locationUrl = \"/Outlet/\" + item.Outlet.OutletID + \"/\" + item.Outlet.Nickname.replace(/[^a-zA-Z0-9]+/g, '_');\r\n // If it doesn't exist, create a new entry\r\n var entry = {\r\n nickname: \"<a href='\" + locationUrl + \"'><span>\" + item.Outlet.Nickname + \"</span></a>\",\r\n address: addr,\r\n phone: phone,\r\n services: services,\r\n outletID: outletID\r\n };\r\n outletLookup[compositeKey] = entry;\r\n a.data.push(entry);\r\n }\r\n });\r\n // Transform data for final output, if necessary\r\n a.data = a.data.map(function (entry) {\r\n return [\r\n \"<div>\" + entry.nickname + \"</div>\",\r\n \"<div>\" + entry.address + \"</div>\",\r\n \"<div>\" + entry.phone + \"</div>\",\r\n \"<div>\" + entry.services + \"</div>\",\r\n \"<div>\" + entry.outletID + \"</div>\"\r\n ];\r\n });\r\n callback(a);\r\n function scrollToTable() {\r\n $('html, body').animate({\r\n scrollTop: $('#listings-table').offset().top - 10\r\n }, 400);\r\n }\r\n scrollToTable();\r\n // this rebinds event listener everytime a request is completed to\r\n // prevent double scrollTop to the table\r\n $('#service-changes-filter').off('change').on('change', function () {\r\n // reload on filter change\r\n $('#listings').dataTable().api().ajax.reload();\r\n // and scroll\r\n scrollToTable();\r\n });\r\n $('#listings').off('click touchend').on('click touchend', '.service-change-popup', function () {\r\n var serviceChangeContent = $(this).find('.popup-content');\r\n if (serviceChangeContent && serviceChangeContent.length > 0) {\r\n $('#service-change-modal').find('.service-change-content-wrapper').empty();\r\n $('#service-change-modal').find('.service-change-content-wrapper').append(serviceChangeContent.html());\r\n $('#service-change-modal').find('.service-change-content-wrapper').find('.popup-content').show();\r\n }\r\n $('#service-change-modal').find('.service-change-location-name').text($(this).data('location-name'));\r\n $('#service-change-modal').find('.service-change-category').text($(this).data('service-category'));\r\n $('#service-change-modal').find('.service-change-service-name').text($(this).data('service-name'));\r\n $('#service-change-modal').find('.service-change-location-address').text($(this).data('location-address'));\r\n $('#service-change-modal').find('.service-change-service-link').attr('href', $(this).data('service-link'));\r\n $('#service-change-modal').find('.service-change-outlet-url').attr('href', $(this).data('outlet-url'));\r\n $('#service-change-modal').modal('show');\r\n });\r\n });\r\n }\r\n }).on('processing.dt', function (e, settings, processing) {\r\n if (processing) {\r\n Page.ShowThinking(\"#listings_processing\");\r\n }\r\n });\r\n $(\"#listings-table input[type=search]\").attr(\"aria-label\", \"Type to filter listings with matching search terms\");\r\n }\r\n function Init(communityRegionID, userHasAccessToDetails, showListings, mapModel) {\r\n $(function () {\r\n Common.InitEmail(function (d) {\r\n return {\r\n OutletID: d.data(\"outlet\"),\r\n OutletServiceID: d.data(\"service\"),\r\n CategoryID: d.data(\"category\"),\r\n CouncilRegionID: d.data(\"region\"),\r\n FromName: $(\"#txt-name\").val(),\r\n FromEmail: $(\"#txt-email\").val(),\r\n Phone: $(\"#txt-phone\").val(),\r\n Message: $(\"#txt-enquiry\").val()\r\n };\r\n });\r\n Common.LoadPromotions();\r\n if (showListings) {\r\n loadListings(communityRegionID, userHasAccessToDetails);\r\n }\r\n if (mapModel.Loaded) {\r\n var map;\r\n var boundaryLayer;\r\n function showMap() {\r\n var mapOptions = {\r\n center: new google.maps.LatLng(mapModel.CentralLatitude, mapModel.CentralLongitude),\r\n zoom: 12,\r\n mapTypeId: google.maps.MapTypeId.ROADMAP\r\n };\r\n map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);\r\n boundaryLayer = new google.maps.KmlLayer({ url: mapModel.KmlLocation + \"?x=0\" });\r\n boundaryLayer.setMap(map);\r\n }\r\n google.maps.event.addDomListener(window, 'load', showMap);\r\n }\r\n });\r\n }\r\n CommunityRegionPage.Init = Init;\r\n})(CommunityRegionPage || (CommunityRegionPage = {}));\r\n"]}