{"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","DefaultCountryTemplate","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,IAovC/BN,EAAEK,QAAO,EAAMH,EAAGE,OAAOE,GAAI,CACzBC,wBA/uCJ,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,GAstCnB,OAntCAN,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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3DC,OAAQ,WACJ,OAAQzS,EAAGE,OAAO8B,QAAQC,cAAc1B,EAAKyH,2BAA6BzH,EAAKyH,sBAAsBiL,YAAc1S,EAAKmR,6BAA6B,2CACzJ,KAGRlR,KAAKoG,kBAAkBzG,OAAO,CAC1BuS,UAAW,CACPC,OAAQ,GACRL,QAAStS,EAAGE,OAAO8B,QAAQuC,aAAavE,EAAGE,OAAO8B,QAAQqK,iBAAiBL,MAAMuG,SAASK,gCAAiC,OAE/HjB,SAAU,CACNW,QAAStS,EAAGE,OAAO8B,QAAQqK,iBAAiBL,MAAMuG,SAASC,4BAC3DC,OAAQ,WACJ,OAAOlS,EAAKmR,6BAA6B,qCAC7C,KAIRlR,KAAK+S,YAAc7S,GAAG8S,WAAWC,MAAMjT,MACvCA,KAAKkT,UAAY,WACb,OAAiC,GAA7BlT,KAAK+S,cAAcjJ,MAK3B,EACA9J,KAAKmT,UAAYjT,GAAG0L,UAAS,WAEzB,OADkB5L,KAAKkT,WAG3B,GAAGlT,MAGID,CACX,GAMH,CA/vCD,CA+vCGuR","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.DefaultCountryTemplate() && 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 defaultTemplate = true;\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 sm.portal.vm.custom.callCustomization('UpdateAddressFields', initialData);\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);"]}