{"version":3,"file":"sm.portal.vm.mailingAddress.min.js","names":["$","undefined","sm","window","portal","extend","vm","MailingAddressViewModel","_fromMyProfile","self","this","hideDoNotContact","ko","observable","hideEffectiveLabelDisplay","hideStreetSuffixID","BuildingNameText","CityText","MunicipalityText","PostalCodeText","PermanentMailingAddressFields","HideCoreFieldsMailingAddress","CountriesUpdated","UpdatedAddressField","PermanentAddressText","HidePermanentAddText","data","fromMyProfile","custom","callCustomization","setCustomLocalizeKey","LoadModel","container","isMobileReady","utility","isNullOrEmpty","Payload","ListData","AllCountry","mapping","fromJS","Countries","MailingAddressAssociations","Associations","DoNotContactReasons","GoverningDistrict","StreetSuffix","SystemCountry","cusData","customData","UpdateAddressTemplates","IsMobileReady","AllCountryTemplates","convertedGoverningDistrictData","map","item","Text","Description","Value","ID","FilterField1Name","FilterField1Value","CountryID","convertedStreetSuffixData","Name","UpdateAddressTemplatesAjax","event","originalEvent","SelectedCountryID","blockUI","url","encodeURI","_baseApiUri","formatString","defaultTemplate","AjaxGet","onSuccess","textStatus","jqXHR","initialData","availableTemplates","AvailableTemplates","selectedTemplateID","SelectedTemplateID","previousSelectedTemplateID","PreviousSelectedTemplateID","forEach","element","DefaultSiteTemplate","IsObsolete","BusinessMeaningName","customInitData","OnError","exception","page","application","modelErrorHandler","complete","jqXhr","target","focus","unblockUI","LoadAddressModel","address","AssociationIDs","me","AddressID","AddressGID","GID","AddressUnitNumber","UnitNumber","AddressFloor","Floor","AddressBuildingName","BuildingName","AddressStreetNumber","StreetNumber","AddressStreetAddress","StreetAddress","AddressStreetName","StreetName","AddressStreetDirection","StreetDirection","AddressStreetSuffixName","StreetSuffixName","AddressPostOfficeBoxNumber","PostOfficeBoxNumber","AddressMunicipality","Municipality","AddressStreetSuffixID","StreetSuffixID","AddressCity","City","AddressCounty","County","AddressCareOf","CareOf","AddressMiscellaneous1","Miscellaneous1","AddressMiscellaneous2","Miscellaneous2","AddressMiscellaneous3","Miscellaneous3","AddressAddressLine1","Address1","AddressAddressLine2","Address2","AddressAddressLine3","Address3","AddressPostalCode","PostalCode","AddressCountryID","AddressTemplateID","MailingAddressTemplateID","customDataAddressModel","StateID","AddressGoverningDistrictName","GoverningDistrictName","AddressGoverningDistrictID","encodedAddress","HTMLValue","AddressHtmlValue","replace","AddressTextValue","TextValue","removeAll","i","length","push","toString","AssociationNames","dateFormat","resources","portalResource","getValue","toUpperCase","mailingAddressEffectiveFrom","EffectiveFrom","moment","format","mailingAddressEffectiveTo","EffectiveTo","DoNotContact","NoContactReasonID","LoadAddressModelFromAddressModel","setType","type","Type","LoadAddressForPayment","validatedObservable","FullObjectValidation","observableArray","useMailingAddress","smapi","access","ListItemModel","EffectiveLabelDisplay","computed","getResourceValue","EffectiveDisplay","DoNotContactAsYesNo","AssociationDisplay","display","AddressTemplateCountryViewModel","Fields","SelectedCountryGID","SelectedTemplate","SelectedCountryText","results","selectedCountryID","Templates","isUKFeatureEnabled","res","CutomParams","AvailableGoverningDistricts","Array","matchID","currGovDistrict","AvailableStreetSuffixes","currSuffix","SelectedTemplateBMN","BMN","subscribe","newValue","newValueUpdated","LoadMailingTemplate","each","k","country","customParams","oldValue","countryID","templateID","templates","grep","a","initAddressLookup","that","triggerFieldInput","prevAll","attr","triggerBoundFieldName","numberOfCharactersNeededToTriggerTheLookup","LookupTriggerFieldsWithRequiredCharacters","mailingAddressTemplateIDForLookupUpdate","mailingAddressTemplateIDForLookup","autocomplete","delay","minLength","source","request","response","sourceUrl","term","ajax","dataType","contentType","headers","processData","crossDomain","xhrFields","withCredentials","success","Status","addressData","sort","b","label","errorMessage","errorDetail","console","log","error","viewModel","HandleError","select","ui","Id","fieldName","fieldValue","Sid","change","tooltipLabel","FieldTypeRequiredForTemplate","required","fields","field","jQuery","FieldTypeBMN","FieldIsRequired","ExtractATO","submitAddressObject","toJS","assocIDs","Reset","message","constant","validate_FieldRequired_Key","onlyIf","maxLength","params","validate_0CharactersOrLess_Key","min","validate_MustBeNumeric_Key","max","number","isValid","numericOrAlphanumerica","ukPostcode","toLowerCase","iePostcode","caPostcode","ModelErrors","validation","group","IsVMValid","Completed"],"sources":["assets/js/viewmodels/community/sm.portal.vm.mailingAddress.js"],"mappings":"CAAA,SAAWA,EAAGC,GACV,IAAIC,EAAKC,OAAOD,GAAKC,OAAOD,IAAM,CAAC,OAEV,IAAdA,EAAGE,QACVJ,EAAEK,OAAOH,EAAI,CAAEE,OAAQ,CAAC,SAEA,IAAjBF,EAAGE,OAAOE,IACjBN,EAAEK,OAAOH,EAAGE,OAAQ,CAAEE,GAAI,CAAC,IAowC/BN,EAAEK,QAAO,EAAMH,EAAGE,OAAOE,GAAI,CACzBC,wBA/vCJ,SAAiCC,GAG7B,IAAIC,EAAOC,KACXD,EAAKE,iBAAmBC,GAAGC,YAAW,GACtCJ,EAAKK,0BAA4BF,GAAGC,YAAW,GAC/CJ,EAAKM,mBAAqBH,GAAGC,YAAW,GAExCJ,EAAKO,iBAAmBJ,GAAGC,WAAW,uBACtCJ,EAAKQ,SAAWL,GAAGC,WAAW,eAC9BJ,EAAKS,iBAAmBN,GAAGC,WAAW,uBACtCJ,EAAKU,eAAiBP,GAAGC,WAAW,qBACpCJ,EAAKW,8BAAgCR,GAAGC,YAAW,GACnDH,KAAKW,6BAA+BT,GAAGC,YAAW,GAClDH,KAAKY,iBAAmBV,GAAGC,WAAW,IACtCH,KAAKa,oBAAsBX,GAAGC,WAAW,IACzCH,KAAKc,qBAAuBZ,GAAGC,WAAW,IAC1CH,KAAKe,qBAAwBb,GAAGC,YAAW,GAE3C,IAAIa,EAAO,CACPjB,KAAMA,EACNkB,cAAenB,GAsuCnB,OAnuCAN,EAAGE,OAAOE,GAAGsB,OAAOC,kBAAkB,kBAAmBH,GACzDxB,EAAGE,OAAOE,GAAGsB,OAAOE,qBAAqBrB,GAGzCC,KAAKqB,UAAY,SAAUC,EAAWC,GA2BlC,GAzBI/B,EAAGE,OAAO8B,QAAQC,cAAcF,KAChCA,GAAgB,GAIhBD,EAAUI,QAAQC,WACb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H,sBAAsBiL,YAAczS,EAAKkR,6BAA6B,2CACzJ,KAGRjR,KAAKmG,kBAAkBxG,OAAO,CAC1BsS,UAAW,CACPC,OAAQ,GACRL,QAASrS,EAAGE,OAAO8B,QAAQuC,aAAavE,EAAGE,OAAO8B,QAAQoK,iBAAiBL,MAAMuG,SAASK,gCAAiC,OAE/HjB,SAAU,CACNW,QAASrS,EAAGE,OAAO8B,QAAQoK,iBAAiBL,MAAMuG,SAASC,4BAC3DC,OAAQ,WACJ,OAAOjS,EAAKkR,6BAA6B,qCAC7C,KAIRjR,KAAK8S,YAAc5S,GAAG6S,WAAWC,MAAMhT,MACvCA,KAAKiT,UAAY,WACb,OAAiC,GAA7BjT,KAAK8S,cAAcjJ,MAK3B,EACA7J,KAAKkT,UAAYhT,GAAGyL,UAAS,WAEzB,OADkB3L,KAAKiT,WAG3B,GAAGjT,MAGID,CACX,GAMH,CA/wCD,CA+wCGsR","ignoreList":[],"sourcesContent":["(function ($, undefined) {\r\n var sm = window.sm = window.sm || {};\r\n\r\n if (typeof sm.portal === \"undefined\") {\r\n $.extend(sm, { portal: {} });\r\n }\r\n if (typeof sm.portal.vm === \"undefined\") {\r\n $.extend(sm.portal, { vm: {} });\r\n }\r\n\r\n // PRIMARY MODEL\r\n // This model represents a Mailing Address and our standard Form Templates.\r\n // This may be referenced by a property another view model.\r\n function MailingAddressViewModel(_fromMyProfile) {\r\n\r\n // Self-Identification\r\n var self = this;\r\n self.hideDoNotContact = ko.observable(false);\r\n self.hideEffectiveLabelDisplay = ko.observable(false);\r\n self.hideStreetSuffixID = ko.observable(false);\r\n\r\n self.BuildingNameText = ko.observable('MA_ALL_BuildingName');\r\n self.CityText = ko.observable('MA_ALL_City');\r\n self.MunicipalityText = ko.observable('MA_ALL_Municipality');\r\n self.PostalCodeText = ko.observable('MA_ALL_PostalCode');\r\n self.PermanentMailingAddressFields = ko.observable(false);\r\n this.HideCoreFieldsMailingAddress = ko.observable(false);\r\n this.CountriesUpdated = ko.observable('');\r\n this.UpdatedAddressField = ko.observable('');\r\n this.PermanentAddressText = ko.observable('');\r\n this.HidePermanentAddText = ko.observable(false);\r\n \r\n var data = {\r\n self: self,\r\n fromMyProfile: _fromMyProfile\r\n }\r\n\r\n sm.portal.vm.custom.callCustomization('MyProfileCustom', data)\r\n sm.portal.vm.custom.setCustomLocalizeKey(self);\r\n\r\n // Loading Methods\r\n this.LoadModel = function (container, isMobileReady) {\r\n\r\n if (sm.portal.utility.isNullOrEmpty(isMobileReady)) {\r\n isMobileReady = false;\r\n }\r\n\r\n // List Data\r\n if (container.Payload.ListData) {\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.ListData.AllCountry)) {\r\n ko.mapping.fromJS(container.Payload.ListData.AllCountry, {}, this.Countries);\r\n sm.portal.vm.custom.callCustomization('UpdateAllCountryList', container.Payload.ListData.AllCountry);\r\n }\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.ListData.MailingAddressAssociations)) {\r\n ko.mapping.fromJS(container.Payload.ListData.MailingAddressAssociations, {}, this.Associations);\r\n }\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.ListData.DoNotContactReasons)) {\r\n ko.mapping.fromJS(container.Payload.ListData.DoNotContactReasons, {}, this.DoNotContactReasons);\r\n }\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.ListData.GoverningDistrict)) {\r\n ko.mapping.fromJS(container.Payload.ListData.GoverningDistrict, {}, this.GoverningDistrict);\r\n }\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.ListData.StreetSuffix)) {\r\n ko.mapping.fromJS(container.Payload.ListData.StreetSuffix, {}, this.StreetSuffix);\r\n }\r\n }\r\n\r\n // System Country\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.SystemCountry)) {\r\n this.SystemCountry(ko.mapping.fromJS(container.Payload.SystemCountry));\r\n var cusData = {\r\n self: self,\r\n container: container\r\n } \r\n sm.portal.vm.custom.callCustomization('SetCountryCode',cusData);\r\n }\r\n\r\n var customData = {\r\n self: self,\r\n container: container\r\n }\r\n sm.portal.vm.custom.callCustomization('AllCountryTemplates', customData);\r\n this.UpdateAddressTemplates(container);\r\n\r\n // Mobile Flag\r\n this.IsMobileReady(isMobileReady);\r\n };\r\n\r\n sm.portal.vm.custom.callCustomization('SetType',self);\r\n\r\n this.UpdateAddressTemplates = function(container){\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.AllCountryTemplates)) {\r\n ko.mapping.fromJS(container.Payload.AllCountryTemplates, {}, this.AllCountryTemplates);\r\n }\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.GoverningDistrict)) {\r\n var convertedGoverningDistrictData = container.Payload.GoverningDistrict.map(function(item) {\r\n return { Text: item.Description, Value: item.ID, FilterField1Name: 'CountryID', FilterField1Value: item.CountryID };\r\n });\r\n ko.mapping.fromJS(convertedGoverningDistrictData, {}, this.GoverningDistrict);\r\n }\r\n if (!sm.portal.utility.isNullOrEmpty(container.Payload.StreetSuffix)) {\r\n var convertedStreetSuffixData = container.Payload.StreetSuffix.map(function(item) {\r\n return { Text: item.Name, Value: item.ID, FilterField1Name: 'CountryID', FilterField1Value: item.CountryID };\r\n });\r\n ko.mapping.fromJS(convertedStreetSuffixData, {}, this.StreetSuffix);\r\n }\r\n };\r\n\r\n this.UpdateAddressTemplatesAjax = function (data, event) {\r\n // Call Api for new options\r\n if (event.originalEvent) {\r\n if (!sm.portal.utility.isNullOrEmpty(self.SelectedCountryID())) {\r\n $.blockUI();\r\n\r\n var url = encodeURI(_baseApiUri + sm.portal.utility.formatString('api/StudentPortal/CountryTemplates?countryId={0}', self.SelectedCountryID()));\r\n var defaultTemplate = false;\r\n\r\n sm.portal.utility.AjaxGet(\r\n url,\r\n onSuccess = function (data, textStatus, jqXHR) {\r\n self.UpdateAddressTemplates(data);\r\n\r\n var initialData = {\r\n availableTemplates: self.AvailableTemplates,\r\n selectedTemplateID: self.SelectedTemplateID,\r\n previousSelectedTemplateID: self.PreviousSelectedTemplateID\r\n }\r\n if (self.PreviousSelectedTemplateID == undefined && self.SelectedTemplateID()) {\r\n self.PreviousSelectedTemplateID = self.SelectedTemplateID();\r\n }\r\n else {\r\n if (self.AvailableTemplates()) {\r\n self.AvailableTemplates().forEach(function (element) {\r\n if (element.DefaultSiteTemplate() && element.IsObsolete() == false) {\r\n self.SelectedTemplateID(element.ID());\r\n\r\n defaultTemplate = true;\r\n\r\n }\r\n else if (element.BusinessMeaningName() == \"MailAddressTemplate.AllFields\" && !element.IsObsolete() && !defaultTemplate ) {\r\n\r\n self.SelectedTemplateID(element.ID());\r\n }\r\n else if (element.BusinessMeaningName() == \"MailAddressTemplate.Simple\" && !element.IsObsolete() && !defaultTemplate) {\r\n self.SelectedTemplateID(element.ID());\r\n }\r\n });\r\n\r\n }\r\n self.PreviousSelectedTemplateID = self.SelectedTemplateID();\r\n }\r\n\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateAddressFields', initialData,\r\n function () {\r\n //if (self.AvailableTemplates()) {\r\n // self.AvailableTemplates().forEach(function (element) {\r\n // if (element.Name() == \"US Default\" || element.Name() == \"UK Default\") {\r\n // self.SelectedTemplateID(element.ID());\r\n // usDefault = false;\r\n // }\r\n // else if (element.DefaultSiteTemplate() && usDefault) {\r\n // self.SelectedTemplateID(element.ID());\r\n // }\r\n // });\r\n // self.PreviousSelectedTemplateID = self.SelectedTemplateID();\r\n //}\r\n }\r\n \r\n );\r\n \r\n var customInitData = {\r\n self: self,\r\n data: data\r\n }\r\n sm.portal.vm.custom.callCustomization('UpdateMailingTemplateID', customInitData);\r\n sm.portal.vm.custom.callCustomization('SetCountryCode', customInitData);\r\n },\r\n OnError = function (jqXHR, exception) {\r\n sm.portal.page.application.modelErrorHandler(self, jqXHR);\r\n },\r\n complete = function (jqXhr, textStatus) {\r\n if (event && event.target) {\r\n event.target.focus();\r\n }\r\n }\r\n );\r\n $.unblockUI();\r\n }\r\n }\r\n };\r\n\r\n this.LoadAddressModel = function (address) {\r\n if (!address || !address.AssociationIDs) {\r\n if (this.me) {\r\n address = this.me;\r\n }\r\n }\r\n this.me = address;\r\n // Base Properties\r\n this.AddressID(address.ID);\r\n this.AddressGID(address.GID);\r\n\r\n this.AddressUnitNumber(address.UnitNumber);\r\n this.AddressFloor(address.Floor);\r\n this.AddressBuildingName(address.BuildingName);\r\n this.AddressStreetNumber(address.StreetNumber);\r\n this.AddressStreetAddress(address.StreetAddress);\r\n this.AddressStreetName(address.StreetName);\r\n this.AddressStreetDirection(address.StreetDirection);\r\n this.AddressStreetSuffixName(address.StreetSuffixName);\r\n this.AddressPostOfficeBoxNumber(address.PostOfficeBoxNumber);\r\n this.AddressMunicipality(address.Municipality);\r\n this.AddressStreetSuffixID(address.StreetSuffixID);\r\n this.AddressCity(address.City);\r\n this.AddressCounty(address.County);\r\n this.AddressCareOf(address.CareOf);\r\n this.AddressMiscellaneous1(address.Miscellaneous1);\r\n this.AddressMiscellaneous2(address.Miscellaneous2);\r\n this.AddressMiscellaneous3(address.Miscellaneous3);\r\n this.AddressAddressLine1(address.Address1);\r\n this.AddressAddressLine2(address.Address2);\r\n this.AddressAddressLine3(address.Address3);\r\n this.AddressPostalCode(address.PostalCode);\r\n\r\n this.AddressCountryID(address.CountryID);\r\n this.AddressTemplateID(address.MailingAddressTemplateID);\r\n\r\n var customDataAddressModel = {\r\n self: self,\r\n address: address\r\n }\r\n\r\n sm.portal.vm.custom.callCustomization('AddressModelAdditionalProps',customDataAddressModel)\r\n \r\n if (!sm.portal.utility.isNullOrEmpty(address.StateID))\r\n this.AddressGoverningDistrictID(address.StateID);\r\n else\r\n this.AddressGoverningDistrictName(address.GoverningDistrictName);\r\n\r\n var cusData = {\r\n self: self,\r\n address: address\r\n }\r\n sm.portal.vm.custom.callCustomization('AddressHTMLVal', cusData, function(){\r\n var encodedAddress = address.HTMLValue;\r\n if (!sm.portal.utility.isNullOrEmpty(encodedAddress)) {\r\n self.AddressHtmlValue(encodedAddress.replace(/</g, '<').replace(/>/g, '>'));\r\n } else {\r\n self.AddressHtmlValue('');\r\n }\r\n })\r\n this.AddressTextValue(address.TextValue);\r\n\r\n this.AssociationIDs.removeAll();\r\n for (var i = 0; i < address.AssociationIDs.length; i++) {\r\n this.AssociationIDs.push(address.AssociationIDs[i].toString());\r\n }\r\n\r\n this.AssociationNames.removeAll();\r\n for (var i = 0; i < address.AssociationNames.length; i++) {\r\n this.AssociationNames.push(address.AssociationNames[i]);\r\n }\r\n\r\n var dateFormat = sm.resources.portalResource.getValue('DateFormatExample').toUpperCase();\r\n var mailingAddressEffectiveFrom = address.EffectiveFrom ? moment(address.EffectiveFrom).format(dateFormat) : '';\r\n var mailingAddressEffectiveTo = address.EffectiveTo ? moment(address.EffectiveTo).format(dateFormat) : '';\r\n\r\n this.EffectiveFrom(mailingAddressEffectiveFrom);\r\n this.EffectiveTo(mailingAddressEffectiveTo);\r\n this.DoNotContact(address.DoNotContact);\r\n this.NoContactReasonID(address.NoContactReasonID);\r\n var customData = {\r\n self: self,\r\n address: address\r\n }\r\n var eventData = {\r\n originalEvent: true\r\n }\r\n if (this.AddressCountryID()) {\r\n this.SelectedCountryID(this.AddressCountryID());\r\n this.UpdateAddressTemplatesAjax(null, eventData);\r\n\r\n }\r\n sm.portal.vm.custom.callCustomization('UpdateCountryCode', customData);\r\n };\r\n\r\n this.LoadAddressModelFromAddressModel = function (address) {\r\n\r\n // Base Properties\r\n this.AddressID(address.AddressID());\r\n this.AddressGID(address.AddressGID());\r\n\r\n // These are named exactly like the types with addres at the start\r\n this.AddressUnitNumber(address.AddressUnitNumber());\r\n this.AddressFloor(address.AddressFloor());\r\n this.AddressBuildingName(address.AddressBuildingName());\r\n this.AddressStreetNumber(address.AddressStreetNumber());\r\n this.AddressStreetAddress(address.AddressStreetAddress());\r\n this.AddressStreetName(address.AddressStreetName());\r\n this.AddressStreetDirection(address.AddressStreetDirection());\r\n this.AddressStreetSuffixName(address.AddressStreetSuffixName());\r\n this.AddressPostOfficeBoxNumber(address.AddressPostOfficeBoxNumber());\r\n this.AddressMunicipality(address.AddressMunicipality());\r\n this.AddressGoverningDistrictName(address.AddressGoverningDistrictName());\r\n this.AddressStreetSuffixID(address.AddressStreetSuffixID());\r\n this.AddressCity(address.AddressCity());\r\n this.AddressCounty(address.AddressCounty());\r\n this.AddressCareOf(address.AddressCareOf());\r\n this.AddressMiscellaneous1(address.AddressMiscellaneous1());\r\n this.AddressMiscellaneous2(address.AddressMiscellaneous2());\r\n this.AddressMiscellaneous3(address.AddressMiscellaneous3());\r\n this.AddressPostalCode(address.AddressPostalCode());\r\n this.AddressCountryID(address.AddressCountryID());\r\n this.AddressTemplateID(address.AddressTemplateID());\r\n this.AddressAddressLine1(address.AddressAddressLine1());\r\n this.AddressAddressLine2(address.AddressAddressLine2());\r\n this.AddressAddressLine3(address.AddressAddressLine3());\r\n\r\n var data = {\r\n self:self,\r\n address:address\r\n }\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateLoadAddressModelProps',data);\r\n\r\n var encodedAddress = address.AddressHtmlValue();\r\n if (!sm.portal.utility.isNullOrEmpty(encodedAddress)) {\r\n this.AddressHtmlValue(encodedAddress.replace(/</g, '<').replace(/>/g, '>'));\r\n } else {\r\n this.AddressHtmlValue('');\r\n }\r\n this.AddressTextValue(address.AddressTextValue);\r\n\r\n this.AssociationIDs.removeAll();\r\n for (var i = 0; i < address.AssociationIDs().length; i++) {\r\n this.AssociationIDs.push(address.AssociationIDs()[i].toString());\r\n }\r\n\r\n this.AssociationNames.removeAll();\r\n for (var i = 0; i < address.AssociationNames().length; i++) {\r\n this.AssociationNames.push(address.AssociationNames()[i]);\r\n }\r\n\r\n var dateFormat = sm.resources.portalResource.getValue('DateFormatExample').toUpperCase();\r\n var mailingAddressEffectiveFrom = address.EffectiveFrom ? moment(address.EffectiveFrom).format(dateFormat) : '';\r\n var mailingAddressEffectiveTo = address.EffectiveTo ? moment(address.EffectiveTo).format(dateFormat) : '';\r\n\r\n this.EffectiveFrom(mailingAddressEffectiveFrom);\r\n this.EffectiveTo(mailingAddressEffectiveTo);\r\n this.DoNotContact(address.DoNotContact());\r\n this.SelectedCountryID(address.SelectedCountryID());\r\n this.SelectedTemplateID(address.SelectedTemplateID());\r\n\r\n this.AddressGoverningDistrictID(address.AddressGoverningDistrictID());\r\n this.DoNotContact(address.DoNotContact);\r\n this.NoContactReasonID(address.NoContactReasonID);\r\n };\r\n\r\n this.setType = function (type) {\r\n self.Type(type);\r\n };\r\n\r\n this.LoadAddressForPayment = function (address) {\r\n\r\n var encodedAddress = address.AddressHtmlValue();\r\n if (!sm.portal.utility.isNullOrEmpty(encodedAddress)) {\r\n this.AddressHtmlValue(encodedAddress.replace(/</g, '<').replace(/>/g, '>'));\r\n } else {\r\n this.AddressHtmlValue('');\r\n }\r\n this.AddressTextValue(address.AddressTextValue);\r\n };\r\n\r\n // Primary Address Properties\r\n this.AddressID = ko.observable();\r\n this.AddressGID = ko.observable();\r\n this.Type = ko.observable();\r\n\r\n // Field Mapped with their name as Address and the Type Name\r\n this.AddressCountryID = ko.validatedObservable();\r\n this.AddressUnitNumber = ko.validatedObservable();\r\n this.AddressFloor = ko.validatedObservable();\r\n this.AddressBuildingName = ko.validatedObservable();\r\n this.AddressStreetNumber = ko.validatedObservable();\r\n this.AddressStreetAddress = ko.validatedObservable();\r\n this.AddressStreetName = ko.validatedObservable();\r\n this.AddressStreetDirection = ko.validatedObservable();\r\n this.AddressStreetSuffixName = ko.validatedObservable();\r\n this.AddressPostOfficeBoxNumber = ko.validatedObservable();\r\n this.AddressMunicipality = ko.validatedObservable();\r\n this.AddressStreetSuffixID = ko.validatedObservable();\r\n this.AddressGoverningDistrictName = ko.validatedObservable();\r\n this.AddressGoverningDistrictID = ko.validatedObservable(); // Also known as STATEID\r\n this.AddressCity = ko.validatedObservable();\r\n this.AddressCounty = ko.validatedObservable();\r\n this.AddressCareOf = ko.validatedObservable();\r\n this.AddressMiscellaneous1 = ko.validatedObservable();\r\n this.AddressMiscellaneous2 = ko.validatedObservable();\r\n this.AddressMiscellaneous3 = ko.validatedObservable();\r\n this.AddressPostalCode = ko.validatedObservable();\r\n this.AddressAddressLine1 = ko.validatedObservable();\r\n this.AddressAddressLine2 = ko.validatedObservable();\r\n this.AddressAddressLine3 = ko.validatedObservable();\r\n this.FullObjectValidation = ko.observable(true);\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateFieldMapAddressprops',self);\r\n\r\n this.AddressHtmlValue = ko.observable();\r\n this.AddressTextValue = ko.observable();\r\n this.AddressTemplateID = ko.observable();\r\n this.AssociationIDs = ko.observableArray();\r\n this.AssociationNames = ko.observableArray();\r\n this.useMailingAddress = ko.observable('checked');\r\n\r\n // Effective Dates\r\n this.EffectiveFrom = ko.observable();\r\n this.EffectiveTo = ko.observable();\r\n this.DoNotContact = ko.observable();\r\n this.NoContactReasonID = ko.observable();\r\n this.DoNotContactReasons = ko.observableArray([new smapi.access.ListItemModel()]);\r\n\r\n this.EffectiveLabelDisplay = ko.computed(function () {\r\n\r\n if (sm.portal.utility.isNullOrEmpty(this.EffectiveFrom()) && !sm.portal.utility.isNullOrEmpty(this.EffectiveTo())) {\r\n return sm.portal.utility.getResourceValue('EffectiveTill');\r\n }\r\n return sm.portal.utility.getResourceValue('EffectiveFrom');\r\n\r\n }, this);\r\n this.EffectiveDisplay = ko.computed(function () {\r\n var dateFormat = sm.resources.portalResource.getValue('DateFormatExample').toUpperCase();\r\n\r\n if (!sm.portal.utility.isNullOrEmpty(this.EffectiveFrom()) && !sm.portal.utility.isNullOrEmpty(this.EffectiveTo())) {\r\n // Return full FROM..TO.. string\r\n return this.EffectiveFrom() + \" to \" + this.EffectiveTo();\r\n } else if (!sm.portal.utility.isNullOrEmpty(this.EffectiveFrom()) && sm.portal.utility.isNullOrEmpty(this.EffectiveTo())) {\r\n // Return FROM...\r\n return this.EffectiveFrom();\r\n } else if (sm.portal.utility.isNullOrEmpty(this.EffectiveFrom()) && !sm.portal.utility.isNullOrEmpty(this.EffectiveTo())) {\r\n return this.EffectiveTo();\r\n }\r\n return \"\";\r\n\r\n }, this);\r\n\r\n this.DoNotContactAsYesNo = ko.computed(function () {\r\n if (this.DoNotContact()) {\r\n return sm.portal.utility.getResourceValue('Yes');\r\n }\r\n return sm.portal.utility.getResourceValue('No');\r\n }, this);\r\n this.AssociationDisplay = ko.computed(function () {\r\n\r\n var display = '';\r\n for (var i = 0; i < this.AssociationNames().length; i++) {\r\n if (display == '') {\r\n display = this.AssociationNames()[i];\r\n } else {\r\n display += ', ' + this.AssociationNames()[i];\r\n }\r\n }\r\n return display;\r\n\r\n }, this);\r\n\r\n // Mailing Address List Values\r\n this.GoverningDistrict = ko.observableArray([new smapi.access.ListItemModel()]);\r\n this.StreetSuffix = ko.observableArray([new smapi.access.ListItemModel()]);\r\n this.Countries = ko.observableArray([new smapi.access.ListItemModel()]);\r\n this.Associations = ko.observableArray([new smapi.access.ListItemModel()]);\r\n sm.portal.vm.custom.callCustomization('CountriesReorderedComputed', self);\r\n\r\n // The Current System Country\r\n this.SystemCountry = ko.observable(new sm.portal.vm.AddressTemplateCountryViewModel());\r\n\r\n // Mixed Country and Template List\r\n this.AllCountryTemplates = ko.observableArray([new sm.portal.vm.AddressTemplateCountryViewModel()]);\r\n this.Fields = ko.observableArray([]);\r\n // Current Selected Options\r\n this.IsMobileReady = ko.observable();\r\n this.SelectedCountryID = ko.validatedObservable();\r\n this.SelectedCountryGID = ko.validatedObservable();\r\n this.SelectedTemplateID = ko.validatedObservable();\r\n this.SelectedTemplate = ko.observable();\r\n this.PreviousSelectedTemplateID = undefined;\r\n this.SelectedCountryText = ko.observable();\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateUKProperty', self);\r\n\r\n this.AvailableTemplates = ko.computed(function () {\r\n var results;// = null;\r\n if (this.SelectedCountryID() == undefined || this.SelectedCountryID() == null) {\r\n results = null;\r\n } else {\r\n var selectedCountryID = this.SelectedCountryID();\r\n for (var i = 0; i < this.AllCountryTemplates().length; i++) {\r\n if (this.AllCountryTemplates()[i].ID() == selectedCountryID) {\r\n results = this.AllCountryTemplates()[i].Templates();\r\n break;\r\n }\r\n }\r\n }\r\n if(!sm.portal.utility.isUKFeatureEnabled()){\r\n var res = sm.portal.vm.custom.callCustomization('UpdateAvailableTemplates', results);\r\n if (!sm.portal.utility.isNullOrEmpty(res)) {\r\n results = res;\r\n }\r\n }\r\n var CutomParams = {\r\n self: self,\r\n results: results\r\n }\r\n sm.portal.vm.custom.callCustomization('UpdateglobalIntuitiveLookup', CutomParams);\r\n return results;\r\n }, this);\r\n\r\n this.AvailableGoverningDistricts = ko.computed(function () {\r\n\r\n var results = Array();\r\n if (sm.portal.utility.isNullOrEmpty(this.SelectedCountryID())) {\r\n results = null;\r\n } else {\r\n var matchID = this.SelectedCountryID();\r\n for (var i = 0; i < this.GoverningDistrict().length; i++) {\r\n var currGovDistrict = this.GoverningDistrict()[i];\r\n if (!sm.portal.utility.isNullOrEmpty(currGovDistrict)) {\r\n if (currGovDistrict.FilterField1Value() == matchID) {\r\n results.push(currGovDistrict);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return results;\r\n\r\n }, this);\r\n this.AvailableStreetSuffixes = ko.computed(function () {\r\n\r\n var results = Array();\r\n if (sm.portal.utility.isNullOrEmpty(this.SelectedCountryID())) {\r\n results = null;\r\n } else {\r\n\r\n var matchID = this.SelectedCountryID();\r\n for (var i = 0; i < this.StreetSuffix().length; i++) {\r\n var currSuffix = this.StreetSuffix()[i];\r\n if (!sm.portal.utility.isNullOrEmpty(currSuffix)) {\r\n if (currSuffix.FilterField1Value() == matchID) {\r\n results.push(currSuffix);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return results;\r\n\r\n }, this);\r\n this.SelectedTemplateBMN = ko.computed(function () {\r\n var BMN = 'NoTemplate';\r\n\r\n if (this.SelectedTemplate() != undefined && this.SelectedTemplate() != null) {\r\n if (this.SelectedTemplate().BusinessMeaningName().length > 0) {\r\n BMN = this.SelectedTemplate().BusinessMeaningName();\r\n }\r\n }\r\n\r\n return BMN;\r\n }, this);\r\n\r\n // Subscriptions\r\n this.SelectedTemplateID.subscribe(function (newValue) {\r\n var newValueUpdated = sm.portal.vm.custom.callCustomization('UpdateSelectedTemplateIDSubscribe', newValue);\r\n if(!sm.portal.utility.isNullOrEmpty(newValueUpdated)){\r\n newValue = newValueUpdated;\r\n }\r\n this.LoadMailingTemplate(this.SelectedCountryID(), newValue);\r\n }, this);\r\n this.SelectedCountryID.subscribe(function (newValue) {\r\n\r\n $.each(this.Countries(), function (k, country) {\r\n if (country.ID() == newValue) {\r\n self.SelectedCountryText(country.Text());\r\n var customParams = {\r\n self: self,\r\n newValue: newValue\r\n }\r\n sm.portal.vm.custom.callCustomization('UpdateLoadMailingnewValue', customParams);\r\n return;\r\n }\r\n });\r\n\r\n this.LoadMailingTemplate(newValue, this.SelectedTemplateID());\r\n }, this);\r\n this.SelectedCountryID.subscribe(function (oldValue) {\r\n this.PreviousSelectedTemplateID = this.SelectedTemplateID();\r\n }, this, \"beforeChange\");\r\n\r\n // Functions\r\n this.LoadMailingTemplate = function (countryID, templateID) {\r\n\r\n var countries = null;\r\n var country = null;\r\n var templates = null;\r\n\r\n var customReturn = sm.portal.vm.custom.callCustomization('UpdateLoadMailingTemplate', self, function(){\r\n return false;\r\n });\r\n\r\n if (customReturn) return;\r\n \r\n if (this.AllCountryTemplates().length > 0) {\r\n\r\n countries = this.AllCountryTemplates();\r\n\r\n this.AllCountryTemplates().forEach(function (element) {\r\n if (element.ID() == countryID) {\r\n country = element;\r\n }\r\n });\r\n\r\n if (country != null && country.Templates().length > 0) {\r\n self.SelectedCountryGID(country.GID());\r\n // Match Template (could have multiple matches - but shouldn't)\r\n templates = $.grep(country.Templates(), function (a) {\r\n return a.ID() == templateID;\r\n });\r\n }\r\n\r\n if (templates != null && templates.length > 0) {\r\n // Save Template Data\r\n this.SelectedTemplate(templates[0]);\r\n this.Fields = templates[0];\r\n var customData = {\r\n self: self,\r\n templates: templates\r\n }\r\n sm.portal.vm.custom.callCustomization('UpdateSelectedTemplateID', customData)\r\n this.initAddressLookup();\r\n }\r\n else {\r\n // Set blank template to force the Display to hide the fields\r\n // and show the \"You must select a tempalte and country\" message\r\n this.SelectedTemplate(null);\r\n }\r\n }\r\n };\r\n\r\n this.initAddressLookup = function () {\r\n var that = this;\r\n if (!that.SelectedTemplate()) {\r\n return;\r\n }\r\n // attach an autocomplete to the Trigger fields input\r\n $('.field.mailingAddress p[data-is-lookup-trigger-field]').each(function () {\r\n // if (ko.dataFor(this) !== that) return;\r\n var triggerFieldInput = $(this).prevAll('input');\r\n triggerFieldInput.attr('placeholder', sm.portal.utility.getResourceValue('TypeToSearch'))\r\n var triggerBoundFieldName = triggerFieldInput.attr('id');\r\n var numberOfCharactersNeededToTriggerTheLookup = that.SelectedTemplate().LookupTriggerFieldsWithRequiredCharacters[triggerBoundFieldName];\r\n var mailingAddressTemplateIDForLookupUpdate = sm.portal.vm.custom.callCustomization('MailingAddressTemplateIDForLookupUpdate', self);\r\n var mailingAddressTemplateIDForLookup = that.SelectedTemplateID();\r\n if(!sm.portal.utility.isNullOrEmpty(mailingAddressTemplateIDForLookupUpdate)){\r\n mailingAddressTemplateIDForLookup = mailingAddressTemplateIDForLookupUpdate;\r\n }\r\n $(triggerFieldInput).autocomplete({\r\n delay: 0,\r\n minLength: numberOfCharactersNeededToTriggerTheLookup,\r\n source: function (request, response) {\r\n var sourceUrl = _baseApiUri + 'api/MailingAddress/AddressLookup/?mailingAddressTemplateID=' + mailingAddressTemplateIDForLookup + \"&triggerFieldName=\" + triggerBoundFieldName + \"&triggerValue=\" + request.term + \"&maxLabelLength=80\";\r\n $.ajax({\r\n url: sourceUrl,\r\n type: 'GET',\r\n dataType: 'json',\r\n contentType: 'application/json; charset=utf-8',\r\n headers: {\r\n \"x-api-version\": '1'\r\n },\r\n processData: false,\r\n crossDomain: true,\r\n xhrFields: {\r\n withCredentials: true\r\n },\r\n success: function (data, textStatus, jqXHR) {\r\n if (data.Status == \"success\" && data.Payload != undefined) {\r\n if (data.Payload.addressData != undefined && data.Payload.addressData.length > 0) {\r\n data.Payload.addressData.sort(function (a, b) { return (a.label > b.label) ? 1 : ((b.label > a.label) ? -1 : 0); });\r\n response(data.Payload.addressData);\r\n }\r\n else if (data.Payload.errorMessage != undefined && data.Payload.errorDetail != undefined) {\r\n console.log('Error in address lookup: ' + data.Payload.errorMessage);\r\n console.log('Detail of error in address lookup: ' + data.Payload.errorDetail);\r\n }\r\n }\r\n else {\r\n console.log('Error in getting address lookup, data.Status = ' + data.Status);\r\n }\r\n },\r\n error: function (jqXHR, exception) {\r\n viewModel.HandleError(exception);\r\n }\r\n });\r\n },\r\n select: function (event, ui) {\r\n if (ui.item.Id != null && ui.item.Id != \"\") {\r\n var sourceUrl = _baseApiUri + 'api/MailingAddress/IndividualAddressLookup/?mailingAddressTemplateID=' + mailingAddressTemplateIDForLookup + \"&triggerFieldName=\" + triggerBoundFieldName + \"&id=\" + ui.item.Id;\r\n $.ajax({\r\n url: sourceUrl,\r\n type: 'GET',\r\n dataType: 'json',\r\n contentType: \"application/json; charset=utf-8\",\r\n headers: {\r\n \"x-api-version\": '1'\r\n },\r\n processData: false,\r\n crossDomain: true,\r\n success: function (data, textStatus, jqXHR) {\r\n if (data.Status == \"success\" && data.Payload.addressData != undefined) {\r\n ui.item = data.Payload.addressData;\r\n for (fieldName in ui.item) {\r\n var fieldValue = ui.item[fieldName];\r\n if (fieldValue != undefined && that[\"Address\" + fieldName] != undefined) {\r\n that[\"Address\" + fieldName](fieldValue);\r\n }\r\n }\r\n return false;\r\n }\r\n else if (data.errorMessage != undefined && data.errorDetail != undefined) {\r\n console.log('Error in individual address lookup: ' + data.Payload.errorMessage);\r\n console.log('Detail of error in individual address lookup: ' + data.Payload.errorDetail);\r\n\r\n }\r\n },\r\n error: function (jqXHR, exception) {\r\n viewModel.HandleError(exception);\r\n }\r\n });\r\n }\r\n else if (ui.item.Sid != null && ui.item.Sid != \"\") {\r\n var sourceUrl = _baseApiUri + 'api/MailingAddress/AddressLookupBySID/?mailingAddressTemplateID=' + mailingAddressTemplateIDForLookup + \"&triggerFieldName=\" + \"Sid\" + \"&sid=\" + ui.item.Sid;\r\n $.ajax({\r\n url: sourceUrl,\r\n type: 'GET',\r\n dataType: 'json',\r\n contentType: \"application/json; charset=utf-8\",\r\n headers: {\r\n \"x-api-version\": '1'\r\n },\r\n processData: false,\r\n crossDomain: true,\r\n success: function (data, textStatus, jqXHR) {\r\n self.AddressPostalCode('');\r\n if (data.Status == \"success\" && data.Payload.addressData != undefined) {\r\n ui.item = data.Payload.addressData;\r\n for (fieldName in ui.item) {\r\n var fieldValue = ui.item[fieldName];\r\n if (fieldValue != undefined && that[\"Address\" + fieldName] != undefined) {\r\n that[\"Address\" + fieldName](fieldValue);\r\n }\r\n }\r\n return false;\r\n }\r\n else if (data.errorMessage != undefined && data.errorDetail != undefined) {\r\n console.log('Error in individual address lookup: ' + data.Payload.errorMessage);\r\n console.log('Detail of error in individual address lookup: ' + data.Payload.errorDetail);\r\n\r\n }\r\n },\r\n error: function (jqXHR, exception) {\r\n viewModel.HandleError(exception);\r\n }\r\n });\r\n }\r\n else {\r\n // update the other address fields from the selected Address Lookup item\r\n for (fieldName in ui.item) {\r\n var fieldValue = ui.item[fieldName];\r\n if (fieldValue != undefined && that[\"Address\" + fieldName] != undefined) {\r\n that[\"Address\" + fieldName](fieldValue);\r\n }\r\n }\r\n return false;\r\n }\r\n },\r\n change: function (event, ui) {\r\n\r\n },\r\n focus: function (event, ui) {\r\n // set tooltipLabel in title attribute to display tooltip\r\n $(\".ui-autocomplete > li\").attr(\"title\", ui.item.tooltipLabel);\r\n return false;\r\n }\r\n });\r\n });\r\n };\r\n\r\n this.FieldTypeRequiredForTemplate = function (BMN) {\r\n var required = false;\r\n if (this.SelectedTemplate() != undefined && this.SelectedTemplate() != null) {\r\n var fields = this.SelectedTemplate().Fields();\r\n if (fields != null && fields.length > 0) {\r\n var field = jQuery.grep(fields, function (a) {\r\n return a.FieldTypeBMN() == BMN;\r\n });\r\n if (field != null && field.length > 0) {\r\n if (field[0].FieldIsRequired && field[0].FieldIsRequired()) {\r\n required = true;\r\n }\r\n }\r\n }\r\n }\r\n return required;\r\n };\r\n this.ExtractATO = function () {\r\n\r\n var submitAddressObject = ko.mapping.toJS(this);\r\n\r\n var assocIDs = Array();\r\n for (var i = 0; i < submitAddressObject.AssociationIDs.length; i++) {\r\n assocIDs.push(submitAddressObject.AssociationIDs[i]);\r\n }\r\n\r\n var data = {\r\n UnitNumber: submitAddressObject.AddressUnitNumber,\r\n Floor: submitAddressObject.AddressFloor,\r\n BuildingName: submitAddressObject.AddressBuildingName,\r\n StreetNumber: submitAddressObject.AddressStreetNumber,\r\n StreetName: submitAddressObject.AddressStreetName,\r\n StreetAddress: submitAddressObject.AddressStreetAddress,\r\n StreetDirection: submitAddressObject.AddressStreetDirection,\r\n StreetSuffixName: submitAddressObject.AddressStreetSuffixName,\r\n PostOfficeBoxNumber: submitAddressObject.AddressPostOfficeBoxNumber,\r\n Municipality: submitAddressObject.AddressMunicipality,\r\n StreetSuffixID: submitAddressObject.AddressStreetSuffixID,\r\n GoverningDistrictName: submitAddressObject.AddressGoverningDistrictName,\r\n StateID: submitAddressObject.AddressGoverningDistrictID,\r\n City: submitAddressObject.AddressCity,\r\n County: submitAddressObject.AddressCounty,\r\n CareOf: submitAddressObject.AddressCareOf,\r\n PostalCode: submitAddressObject.AddressPostalCode,\r\n CountryID: submitAddressObject.SelectedCountryID,\r\n MailingAddressTemplateID: submitAddressObject.SelectedTemplateID,\r\n Miscellaneous1: submitAddressObject.AddressMiscellaneous1,\r\n Miscellaneous2: submitAddressObject.AddressMiscellaneous2,\r\n Miscellaneous3: submitAddressObject.AddressMiscellaneous3,\r\n HTMLValue: submitAddressObject.AddressHtmlValue,\r\n TextValue: submitAddressObject.AddressTextValue,\r\n EffectiveFrom: submitAddressObject.EffectiveFrom,\r\n EffectiveTo: submitAddressObject.EffectiveTo,\r\n DoNotContact: submitAddressObject.DoNotContact,\r\n NoContactReasonID: submitAddressObject.NoContactReasonID,\r\n ID: submitAddressObject.AddressID,\r\n GID: submitAddressObject.AddressGID,\r\n Address1: submitAddressObject.AddressAddressLine1,\r\n Address2: submitAddressObject.AddressAddressLine2,\r\n Address3: submitAddressObject.AddressAddressLine3,\r\n AssociationIDs: assocIDs\r\n };\r\n var customData = {\r\n data: data,\r\n submitAddressObject: submitAddressObject\r\n }\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateATOMailingData', customData);\r\n return data;\r\n };\r\n this.Reset = function () {\r\n this.AddressID(0);\r\n this.AddressGID('');\r\n\r\n this.AddressUnitNumber('');\r\n this.AddressFloor('');\r\n this.AddressBuildingName('');\r\n this.AddressStreetNumber('');\r\n this.AddressStreetAddress('');\r\n this.AddressStreetName('');\r\n this.AddressStreetDirection('');\r\n this.AddressStreetSuffixName('');\r\n this.AddressPostOfficeBoxNumber('');\r\n this.AddressMunicipality('');\r\n this.AddressGoverningDistrictName('');\r\n this.AddressStreetSuffixID(0);\r\n this.AddressGoverningDistrictID(0);\r\n this.AddressCity('');\r\n this.AddressCounty('');\r\n this.AddressCareOf('');\r\n this.AddressMiscellaneous1('');\r\n this.AddressMiscellaneous2('');\r\n this.AddressMiscellaneous3('');\r\n this.AddressPostalCode('');\r\n this.AddressCountryID(0);\r\n this.AddressTemplateID(0);\r\n\r\n this.AddressAddressLine1('');\r\n this.AddressAddressLine2('');\r\n this.AddressAddressLine3('');\r\n\r\n this.AddressMiscellaneous1('');\r\n this.AddressMiscellaneous2('');\r\n this.AddressMiscellaneous3('');\r\n\r\n this.AddressHtmlValue('');\r\n this.AddressTextValue('');\r\n\r\n this.SelectedCountryID(undefined);\r\n this.SelectedTemplateID(undefined);\r\n this.SelectedTemplate(undefined);\r\n\r\n this.EffectiveFrom('');\r\n this.EffectiveTo('');\r\n this.DoNotContact(false);\r\n this.NoContactReasonID(undefined);\r\n };\r\n \r\n sm.portal.vm.custom.callCustomization('UpdateIsPostCodeRequired',self);\r\n\r\n sm.portal.vm.custom.callCustomization('OverrideMailingAddressValidation',self)\r\n /*** VALIDATION METHODS ***/\r\n this.SelectedCountryID.extend({\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FullObjectValidation();\r\n }\r\n }\r\n });\r\n this.SelectedTemplateID.extend({\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FullObjectValidation();\r\n }\r\n }\r\n });\r\n this.AddressAddressLine1.extend({\r\n maxLength: {\r\n params: 80,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '80')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.AddressLine1');\r\n }\r\n }\r\n });\r\n this.AddressAddressLine2.extend({\r\n maxLength: {\r\n params: 80,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '80')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.AddressLine2');\r\n }\r\n }\r\n });\r\n this.AddressAddressLine3.extend({\r\n maxLength: {\r\n params: 80,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '80')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.AddressLine3');\r\n }\r\n }\r\n });\r\n this.AddressBuildingName.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.BuildingName');\r\n }\r\n }\r\n });\r\n this.AddressCareOf.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.CareOf');\r\n }\r\n }\r\n });\r\n this.AddressCity.extend({\r\n maxLength: {\r\n params: 60,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '60')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.City');\r\n }\r\n }\r\n });\r\n this.AddressCounty.extend({\r\n maxLength: {\r\n params: 60,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '60')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.County');\r\n }\r\n }\r\n });\r\n this.AddressCountryID.extend({\r\n min: {\r\n params: -9223372036854775808,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n max: {\r\n params: 9223372036854775807,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n number: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return sm.portal.utility.isNullOrEmpty(self.SelectedCountryID()) && self.FieldTypeRequiredForTemplate('MailingAddressFieldType.CountryID');\r\n }\r\n }\r\n });\r\n this.AddressFloor.extend({\r\n maxLength: {\r\n params: 20,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '20')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.Floor');\r\n }\r\n }\r\n });\r\n this.AddressGoverningDistrictID.extend({\r\n min: {\r\n params: -9223372036854775808,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n max: {\r\n params: 9223372036854775807,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n number: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return (sm.portal.utility.isNullOrEmpty(self.AddressGoverningDistrictName()) || !self.AddressGoverningDistrictName.isValid()) && self.FieldTypeRequiredForTemplate('MailingAddressFieldType.GoverningDistrictID');\r\n }\r\n }\r\n });\r\n this.AddressGoverningDistrictName.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return (sm.portal.utility.isNullOrEmpty(self.AddressGoverningDistrictID()) || !self.AddressGoverningDistrictID.isValid()) && self.FieldTypeRequiredForTemplate('MailingAddressFieldType.GoverningDistrictName');\r\n }\r\n }\r\n });\r\n this.AddressMiscellaneous1.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.Miscellaneous1');\r\n }\r\n }\r\n });\r\n this.AddressMiscellaneous2.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.Miscellaneous2');\r\n }\r\n }\r\n });\r\n this.AddressMiscellaneous3.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.Miscellaneous3');\r\n }\r\n }\r\n });\r\n this.AddressMunicipality.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.Municipality');\r\n }\r\n }\r\n });\r\n this.AddressPostalCode.extend({\r\n maxLength: {\r\n params: 10,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '10')\r\n },\r\n numericOrAlphanumerica: {\r\n params: { SelectedCountryGID: self.SelectedCountryGID }\r\n },\r\n ukPostcode: {\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.PostalCode') && (!sm.portal.utility.isNullOrEmpty(self.SelectedCountryText())) &&\r\n (self.SelectedCountryText().toLowerCase() == 'united kingdom' ||\r\n self.SelectedCountryText().toLowerCase() == 'england' ||\r\n self.SelectedCountryText().toLowerCase() == 'scotland' ||\r\n self.SelectedCountryText().toLowerCase() == 'wales' ||\r\n self.SelectedCountryText().toLowerCase() == 'northern ireland' ||\r\n self.SelectedCountryText().toLowerCase() == 'united kingdom, not otherwise specified');\r\n }\r\n },\r\n iePostcode: {\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.PostalCode') && (!sm.portal.utility.isNullOrEmpty(self.SelectedCountryText())) &&\r\n (self.SelectedCountryText().toLowerCase() == 'ireland');\r\n }\r\n },\r\n caPostcode: {\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.PostalCode') && (!sm.portal.utility.isNullOrEmpty(self.SelectedCountryText())) &&\r\n (self.SelectedCountryText().toLowerCase() == 'canada');\r\n }\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.PostalCode');\r\n }\r\n }\r\n });\r\n this.AddressPostOfficeBoxNumber.extend({\r\n number: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n maxLength: {\r\n params: 20,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '20')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.PostOfficeBoxNumber');\r\n }\r\n }\r\n });\r\n this.AddressStreetDirection.extend({\r\n maxLength: {\r\n params: 50,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '50')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.StreetDirection');\r\n }\r\n }\r\n });\r\n this.AddressStreetName.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.StreetName');\r\n }\r\n }\r\n });\r\n this.AddressStreetAddress.extend({\r\n maxLength: {\r\n params: 100,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '100')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.StreetAddress');\r\n }\r\n }\r\n });\r\n this.AddressStreetNumber.extend({\r\n maxLength: {\r\n params: 20,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '20')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.StreetNumber');\r\n }\r\n }\r\n });\r\n this.AddressStreetSuffixID.extend({\r\n min: {\r\n params: -9223372036854775808,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n max: {\r\n params: 9223372036854775807,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n number: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeNumeric_Key)\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return (sm.portal.utility.isNullOrEmpty(self.AddressStreetSuffixName()) || !self.AddressStreetSuffixName.isValid()) && self.FieldTypeRequiredForTemplate('MailingAddressFieldType.StreetSuffixID');\r\n }\r\n }\r\n });\r\n this.AddressStreetSuffixName.extend({\r\n maxLength: {\r\n params: 50,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '50')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return (sm.portal.utility.isNullOrEmpty(self.AddressStreetSuffixID()) || !self.AddressStreetSuffixID.isValid()) && self.FieldTypeRequiredForTemplate('MailingAddressFieldType.StreetSuffixName');\r\n }\r\n }\r\n });\r\n this.AddressUnitNumber.extend({\r\n maxLength: {\r\n params: 20,\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_0CharactersOrLess_Key), '20')\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key),\r\n onlyIf: function () {\r\n return self.FieldTypeRequiredForTemplate('MailingAddressFieldType.UnitNumber');\r\n }\r\n }\r\n });\r\n\r\n this.ModelErrors = ko.validation.group(this);\r\n this.IsVMValid = function () {\r\n if (this.ModelErrors().length == 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n };\r\n this.Completed = ko.computed(function () {\r\n var isCompleted = this.IsVMValid();\r\n return isCompleted;\r\n\r\n }, this);\r\n /*** VALIDATION METHODS ***/\r\n\r\n return self;\r\n }\r\n\r\n $.extend(true, sm.portal.vm, {\r\n MailingAddressViewModel: MailingAddressViewModel\r\n });\r\n\r\n})(jQuery);"]}