{"version":3,"file":"sm.portal.vm.electronicAddress.min.js","names":["jQuery","undefined","sm","window","portal","extend","vm","ElectronicAddressViewModel","self","this","hideDoNotContact","ko","observable","hideEffectiveLabelDisplay","custom","setCustomLocalizeKey","LoadModel","container","Payload","ListData","mapping","fromJS","EAddressTypeEntries","TypeEntries","DoNotContactReasons","AddressTimings","ElectronicAddressAssociations","Associations","LoadElectronicAddressModel","AssociationIDs","me","dateFormat","resources","portalResource","getValue","toUpperCase","electronicAddressEffectiveFrom","EffectiveFrom","moment","format","electronicAddressEffectiveTo","EffectiveTo","ID","Value","TypeEntryID","AddressTypeID","AddressTimingTypeID","DoNotContact","NoContactReasonID","removeAll","i","length","push","toString","AssociationNames","TypeEntryName","TypeEntryBusinessMeaningName","AddressTimingTypeName","DoNotContactReasonName","validatedObservable","AddressTypeName","observableArray","TypeEntryIconName","computed","smapi","access","ListItemModel","EffectiveLabelDisplay","utility","isNullOrEmpty","getResourceValue","EffectiveDisplay","DoNotContactAsYesNo","AssociationDisplay","display","isCustomized","callCustomization","ExtractATO","submitAddressObject","toJS","assocIDs","Array","Reset","min","params","message","constant","validate_MustBeNumeric_Key","max","number","required","validate_FieldRequired_Key","email","formatString","validate_ErrorInFormat0_Key","maxLength","validate_0CharactersOrLess_Key","smLocalDate","validate_MustBeADate_Key","smValidateEffectiveFromDate","validate_EffectiveBeginDate_Key","smValidateEffectiveToDate","validate_EffectiveEndDate_Key","ModelErrors","validation","group","IsVMValid"],"sources":["assets/js/viewmodels/community/sm.portal.vm.electronicAddress.js"],"mappings":"CAAA,SAAWA,EAAQC,GACf,IAAIC,EAAKC,OAAOD,GAAKC,OAAOD,IAAM,CAAC,OAIV,IAAdA,EAAGE,QACVJ,EAAOK,OAAOH,EAAI,CAAEE,OAAQ,CAAC,SAEL,IAAjBF,EAAGE,OAAOE,IACjBN,EAAOK,OAAOH,EAAGE,OAAQ,CAAEE,GAAI,CAAC,IA+VpCN,EAAOK,QAAO,EAAMH,EAAGE,OAAOE,GAA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E,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASU,gCAAiC,UAGnIvF,KAAKqC,oBAAoBzC,OAAO,CAC5B8E,IAAK,CACDC,QAAS,mBACTC,QAASnF,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASC,6BAE/DC,IAAK,CACDJ,OAAQ,mBACRC,QAASnF,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASC,6BAE/DE,OAAQ,CACJJ,QAASnF,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASC,+BAGnE9E,KAAKgD,sBAAsBpD,OAAO,CAC9B0F,UAAW,CACPX,OAAQ,IACRC,QAASnF,EAAGE,OAAOgE,QAAQyB,aAAa3F,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASU,gCAAiC,UAGnIvF,KAAKuC,kBAAkB3C,OAAO,CAC1B8E,IAAK,CACDC,QAAS,mBACTC,QAASnF,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASC,6BAE/DC,IAAK,CACDJ,OAAQ,mBACRC,QAASnF,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASC,6BAE/DE,OAAQ,CACJJ,QAASnF,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASC,+BAGnE9E,KAAKiD,uBAAuBrD,OAAO,CAC/B0F,UAAW,CACPX,OAAQ,IACRC,QAASnF,EAAGE,OAAOgE,QAAQyB,aAAa3F,EAAGE,OAAOgE,QAAQE,iBAAiBN,MAAMsB,SAASU,gCAAiC,UAKnIvF,KAAK8F,YAAc5F,GAAG6F,WAAWC,MAAMhG,MAIvCA,KAAKiG,UAAY,WACb,OAAiC,GAA7BjG,KAAK8F,cAAcpD,MAK3B,EAGO3C,CACX,GAMH,CA5WD,CA4WGR","ignoreList":[],"sourcesContent":["(function (jQuery, undefined) {\r\n var sm = window.sm = window.sm || {};\r\n var windowProxy;\r\n var actionQueue = [];\r\n\r\n if (typeof sm.portal === \"undefined\") {\r\n jQuery.extend(sm, { portal: {} });\r\n }\r\n if (typeof sm.portal.vm === \"undefined\") {\r\n jQuery.extend(sm.portal, { vm: {} });\r\n }\r\n\r\n // SUPPORTING MODEL\r\n // This model represents an Electronic Address\r\n function ElectronicAddressViewModel() {\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 sm.portal.vm.custom.setCustomLocalizeKey(self);\r\n\r\n this.LoadModel = function (container) {\r\n if (container.Payload.ListData) {\r\n ko.mapping.fromJS(container.Payload.ListData.EAddressTypeEntries, {}, this.TypeEntries);\r\n ko.mapping.fromJS(container.Payload.ListData.DoNotContactReasons, {}, this.DoNotContactReasons);\r\n ko.mapping.fromJS(container.Payload.ListData.AddressTimings, {}, this.AddressTimings);\r\n ko.mapping.fromJS(container.Payload.ListData.ElectronicAddressAssociations, {}, this.Associations);\r\n }\r\n };\r\n this.LoadElectronicAddressModel = function (container) {\r\n if (!container || !container.AssociationIDs) {\r\n if (this.me) {\r\n container = this.me;\r\n }\r\n }\r\n\r\n var dateFormat = sm.resources.portalResource.getValue('DateFormatExample').toUpperCase();\r\n var electronicAddressEffectiveFrom = container.EffectiveFrom ? moment(container.EffectiveFrom).format(dateFormat) : '';\r\n var electronicAddressEffectiveTo = container.EffectiveTo ? moment(container.EffectiveTo).format(dateFormat) : '';\r\n\r\n this.me = container;\r\n this.ID(container.ID);\r\n this.Value(container.Value);\r\n this.TypeEntryID(container.TypeEntryID);\r\n this.EffectiveFrom(electronicAddressEffectiveFrom);\r\n this.EffectiveTo(electronicAddressEffectiveTo);\r\n this.AddressTypeID(container.AddressTypeID);\r\n this.AddressTimingTypeID(container.AddressTimingTypeID);\r\n this.DoNotContact(container.DoNotContact);\r\n this.NoContactReasonID(container.NoContactReasonID);\r\n\r\n this.AssociationIDs.removeAll();\r\n for (var i = 0; i < container.AssociationIDs.length; i++) {\r\n this.AssociationIDs.push(container.AssociationIDs[i].toString());\r\n }\r\n\r\n this.AssociationNames.removeAll();\r\n for (var i = 0; i < container.AssociationNames.length; i++) {\r\n this.AssociationNames.push(container.AssociationNames[i]);\r\n }\r\n\r\n this.TypeEntryName(container.TypeEntryName);\r\n this.TypeEntryBusinessMeaningName(container.TypeEntryBusinessMeaningName);\r\n this.AddressTimingTypeName(container.AddressTimingTypeName);\r\n this.DoNotContactReasonName(container.DoNotContactReasonName);\r\n };\r\n\r\n this.ID = ko.validatedObservable();\r\n this.Value = ko.validatedObservable();\r\n this.TypeEntryID = ko.validatedObservable();\r\n this.TypeEntryName = ko.validatedObservable();\r\n this.TypeEntryBusinessMeaningName = ko.validatedObservable();\r\n this.EffectiveFrom = ko.validatedObservable();\r\n this.EffectiveTo = ko.validatedObservable();\r\n this.AddressTypeID = ko.validatedObservable();\r\n this.AddressTypeName = ko.validatedObservable();\r\n this.AddressTimingTypeID = ko.validatedObservable();\r\n this.AddressTimingTypeName = ko.validatedObservable();\r\n this.DoNotContact = ko.validatedObservable();\r\n this.NoContactReasonID = ko.validatedObservable();\r\n this.DoNotContactReasonName = ko.validatedObservable();\r\n this.AssociationIDs = ko.observableArray();\r\n this.AssociationNames = ko.observableArray();\r\n\r\n this.TypeEntryIconName = ko.computed(function () {\r\n var iconClass = 'icon ' + this.TypeEntryName() + 'MessageIcon';\r\n return iconClass;\r\n }, this);\r\n\r\n this.TypeEntries = ko.observableArray([new smapi.access.ListItemModel()]);\r\n this.Associations = ko.observableArray([new smapi.access.ListItemModel()]);\r\n this.DoNotContactReasons = ko.observableArray([new smapi.access.ListItemModel()]);\r\n this.AddressTimings = 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\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 self.isCustomized = sm.portal.vm.custom.callCustomization(\r\n \"ShowEditButtonForCustomEnvironment\"\r\n );\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateElectronicAddressProps', self);\r\n\r\n this.ExtractATO = function () {\r\n\r\n var submitAddressObject = ko.mapping.toJS(this);\r\n\r\n var electronicAddressEffectiveFrom = submitAddressObject.EffectiveFrom ? moment(submitAddressObject.EffectiveFrom, sm.resources.portalResource.getValue('DateFormatExample').toUpperCase()).format(\"MM/DD/YYYY\") : '';\r\n var electronicAddressEffectiveTo = submitAddressObject.EffectiveTo ? moment(submitAddressObject.EffectiveTo, sm.resources.portalResource.getValue('DateFormatExample').toUpperCase()).format(\"MM/DD/YYYY\") : '';\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\r\n ID: submitAddressObject.ID,\r\n Value: submitAddressObject.Value,\r\n TypeEntryID: submitAddressObject.TypeEntryID,\r\n EffectiveFrom: electronicAddressEffectiveFrom,\r\n EffectiveTo: electronicAddressEffectiveTo,\r\n AddressTypeID: submitAddressObject.AddressTypeID,\r\n AddressTimingTypeID: submitAddressObject.AddressTimingTypeID,\r\n DoNotContact: submitAddressObject.DoNotContact,\r\n NoContactReasonID: submitAddressObject.NoContactReasonID,\r\n AssociationIDs: assocIDs\r\n };\r\n\r\n return data;\r\n };\r\n this.Reset = function () {\r\n this.ID(0);\r\n this.Value('');\r\n this.TypeEntryID(undefined);\r\n this.EffectiveFrom('');\r\n this.EffectiveTo('');\r\n this.AddressTypeID(undefined);\r\n this.AddressTimingTypeID(undefined);\r\n this.DoNotContact(false);\r\n this.NoContactReasonID(undefined);\r\n\r\n this.TypeEntryName('');\r\n this.AddressTimingTypeName('');\r\n this.DoNotContactReasonName('');\r\n };\r\n\r\n sm.portal.vm.custom.callCustomization('UpdateValidationsElectronicAddress', self);\r\n /*** VALIDATION METHODS ***/\r\n this.ID.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 });\r\n this.Value.extend({\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key)\r\n },\r\n email: {\r\n message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_ErrorInFormat0_Key), 'Example@domain.com')\r\n },\r\n //TODO Add in Validation based on type\r\n //pattern: {\r\n // params: regex,\r\n // message: sm.portal.utility.formatString(sm.portal.utility.getResourceValue(smapi.constant.validate_ErrorInFormat0_Key), 'XXX')\r\n //},\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 });\r\n this.TypeEntryID.extend({\r\n min: {\r\n params: 1,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key)\r\n },\r\n max: {\r\n params: 9223372036854775807,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key)\r\n },\r\n number: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key)\r\n },\r\n required: {\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_FieldRequired_Key)\r\n }\r\n });\r\n this.TypeEntryName.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 });\r\n this.TypeEntryBusinessMeaningName.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 });\r\n if(sm.portal.utility.isNullOrEmpty(sm.portal.vm.custom.callCustomization('DisableDateValidation'))) {\r\n this.EffectiveFrom.extend({\r\n smLocalDate: {\r\n params: true,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeADate_Key)\r\n },\r\n smValidateEffectiveFromDate: {\r\n params: this.EffectiveTo,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_EffectiveBeginDate_Key)\r\n }\r\n });\r\n this.EffectiveTo.extend({\r\n smLocalDate: {\r\n params: true,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeADate_Key)\r\n },\r\n smValidateEffectiveToDate: {\r\n params: this.EffectiveFrom,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_EffectiveEndDate_Key)\r\n }\r\n });\r\n } else {\r\n this.EffectiveFrom.extend({\r\n smLocalDate: {\r\n params: true,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeADate_Key)\r\n }\r\n });\r\n this.EffectiveTo.extend({\r\n smLocalDate: {\r\n params: true,\r\n message: sm.portal.utility.getResourceValue(smapi.constant.validate_MustBeADate_Key)\r\n }\r\n });\r\n }\r\n this.AddressTypeID.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 });\r\n this.AddressTypeName.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 });\r\n this.AddressTimingTypeID.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 });\r\n this.AddressTimingTypeName.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 });\r\n this.NoContactReasonID.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 });\r\n this.DoNotContactReasonName.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 });\r\n\r\n // Set Model Grouping for validation\r\n this.ModelErrors = ko.validation.group(this);\r\n // Check if Model is valid \r\n // (will NOT validate attached models, unless we\r\n // init that in ui.js - currently it has performance problems)\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 /*** VALIDATION METHODS ***/\r\n\r\n return self;\r\n }\r\n\r\n jQuery.extend(true, sm.portal.vm, {\r\n ElectronicAddressViewModel: ElectronicAddressViewModel\r\n });\r\n\r\n})(jQuery);"]}