1"use strict";(self.webpackChunkmsb=self.webpackChunkmsb||[]).push([[1411],{41411:(_,F,r)=>{r.r(F),r.d(F,{EnvelopeTemplateAddFieldsComponent:()=>S});var e=r(54438),a=r(89417),p=r(96697),u=r(7476),o=r(75141),b=r(85817),v=r(96106),R=r(32265),g=r(14823),C=r(53861);const E=(s,f)=>f.name,O=(s,f)=>f.level;function N(s,f){if(1&s&&(e.j41(0,"option",6),e.EFF(1),e.k0s()),2&s){const t=f.$implicit,l=e.XpG();e.Y8G("value",t.name),e.R7$(),e.SpI(" ",l.getRootFieldOptionLabel(t)," ")}}function I(s,f){if(1&s&&(e.j41(0,"option",6),e.EFF(1),e.k0s()),2&s){const t=f.$implicit,l=e.XpG().$implicit,i=e.XpG();e.Y8G("value",t.name),e.R7$(),e.SpI(" ",i.getRefFieldOptionLabel(t,l.level)," ")}}function L(s,f){if(1&s&&e.EFF(0),2&s){const t=e.XpG(2);e.SpI(" This field references: ",null==t.selectedFieldInfo?null:t.selectedFieldInfo.referenceTo," ")}}function T(s,f){if(1&s&&e.EFF(0),2&s){const t=e.XpG().$implicit,l=e.XpG();e.SpI(" This field references: ",null==l.referenceLevels[t.level-1].selectedField?null:l.referenceLevels[t.level-1].selectedField.referenceTo," ")}}function M(s,f){if(1&s&&(e.j41(0,"div",2)(1,"label",3),e.EFF(2),e.k0s(),e.j41(3,"div",4)(4,"select",16)(5,"option",11),e.EFF(6,"Select Reference Field"),e.k0s(),e.Z7z(7,I,2,2,"option",6,E),e.k0s(),e.nrm(9,"em",7),e.k0s(),e.j41(10,"small",17),e.DNE(11,L,1,1)(12,T,1,1),e.k0s()()),2&s){const t=f.$implicit,l=e.XpG();e.R7$(2),e.SpI(" Reference Field ",t.level>0?"(Level "+(t.level+1)+")":""," * "),e.R7$(2),e.Y8G("formControlName","referenceField_"+t.level)("disabled",!t.fields.length),e.BMQ("data-automation-id","referenceFieldSelect_"+t.level),e.R7$(3),e.Dyx(t.fields),e.R7$(4),e.vxM(0===t.level?11:null!=l.referenceLevels[t.level-1]&&null!=l.referenceLevels[t.level-1].selectedField&&l.referenceLevels[t.level-1].selectedField.referenceTo?12:-1)}}let S=(()=>{class s{constructor(t,l,i,n,c){this.formBuilder=t,this.service=l,this.spinner=i,this.toast=n,this.i18n=c,this.showMoreOptions=!1,this.fieldsData=(0,e.geq)([]),this.addedMergeFieldNames=(0,e.geq)([]),this.availableFields=(0,e.vPA)([]),this.externalName=(0,e.geq)(o.vS.OPPORTUNITY),this.referenceLevels=[],this.maxReferenceDepth=5,this.onSave=(0,e.CGW)(),this.onSaveAndNew=(0,e.CGW)(),this.onCancel=(0,e.CGW)()}ngOnInit(){this.initForm(),this.availableFields.set(this.fieldsData()||[])}getFieldDisplayText(t){return`${t.label} ${t?.referenceTo?"("+t?.referenceTo+") ":""}(${t.type})`}getRootFieldOptionLabel(t){return`${this.isRootFieldAdded(t)?"\u2713 ":"\xa0\xa0\xa0\xa0"}${this.getFieldDisplayText(t)}`}getRefFieldOptionLabel(t,l){return`${this.isRefFieldOptionAdded(t,l)?"\u2713 ":"\xa0\xa0\xa0\xa0"}${this.getFieldDisplayText(t)}`}isSaveDisabled(){if(!this.addFieldForm.valid)return!0;for(let t=0;t<this.referenceLevels.length;t++){const i=this.addFieldForm.get(`referenceField_${t}`);if(i&&!i.value)return!0}if(this.referenceLevels.length===this.maxReferenceDepth){const t=this.referenceLevels[this.maxReferenceDepth-1]?.selectedField;if(t&&t.type===o.NO.REFERENCE&&t.referenceTo)return!0}return!1}onCloseModal(){this.dialogRef.close(!1)}toggleMoreOptions(){this.showMoreOptions=!this.showMoreOptions}handleSave(){if(this.addFieldForm.valid){const t=this.addFieldForm.value;for(let d=0;d<this.referenceLevels.length;d++)if(!t[`referenceField_${d}`])return void this.dialogRef.close();const l=[],i=[];for(let d=0;d<this.referenceLevels.length;d++){const h=t[`referenceField_${d}`];h&&this.referenceLevels[d].selectedField&&(l.push(h),i.push(this.referenceLevels[d].selectedField))}const n={sourceObject:t.sourceObject,field:t.field,name:t.name,referenceFields:l?.length>0?l:[],fieldInfo:this.selectedFieldInfo,referenceFieldsInfo:i.length>0?i:[],allowWriteback:!!t.allowWriteback};new Set(this.addedMergeFieldNames()).has(this.selectedFieldInfo.name)?this.toast.show(this.i18n.transform("fieldAlreadyAddedLbl")+":"+this.selectedFieldInfo.name,u.lm.ERROR):this.dialogRef.close(n)}else console.warn("Form is invalid:",this.addFieldForm.errors)}loadExternalFields(){this.spinner.show(),this.service.getSfFieldsData(this.externalName(),!0).pipe((0,p.s)(1)).subscribe(t=>{this.spinner.hide(),this.fieldsData.set(t),this.availableFields.set(t||[])})}initForm(){this.addFieldForm=this.formBuilder.group({sourceObject:[this.externalName(),a.k0.required],allowWriteback:[!1,a.k0.required],field:["",a.k0.required],name:[{value:"",disabled:!0},a.k0.required]}),this.addFieldForm.get("sourceObject")?.valueChanges.subscribe(t=>{this.onSourceObjectChange(t)}
1),this.addFieldForm.get("field")?.valueChanges.subscribe(t=>{t&&this.onFieldChange(t)})}onSourceObjectChange(t){this.addFieldForm.get("field")?.setValue(""),this.addFieldForm.get("name")?.setValue(""),this.resetAllReferenceFields(),this.loadExternalFields()}onFieldChange(t){if(t&&this.availableFields().length>0){if(this.selectedFieldInfo=this.availableFields().find(l=>l.name===t)||this.availableFields()[0],this.selectedFieldInfo){const l=this.selectedFieldInfo.label;this.addFieldForm.get("name")?.setValue(l),this.resetAllReferenceFields(),(this.selectedFieldInfo.type===o.NO.REFERENCE||this.selectedFieldInfo.type===o.NO.CHILD_RELATIONSHIP)&&this.selectedFieldInfo.referenceTo&&this.loadReferenceFieldsForLevel(0,this.selectedFieldInfo.referenceTo),this.updateAllowWritebackState()}}else this.resetAllReferenceFields()}onReferenceFieldChange(t,l){if(l&&this.referenceLevels[t]){const i=this.referenceLevels[t].fields.find(n=>n.name===l);i&&(this.referenceLevels[t].selectedField=i,this.referenceLevels[t].selectedFieldName=l,this.updateFieldName(),this.removeReferenceLevelsAfter(t),(i.type===o.NO.REFERENCE||i.type===o.NO.CHILD_RELATIONSHIP)&&i.referenceTo&&t<this.maxReferenceDepth-1&&this.loadReferenceFieldsForLevel(t+1,i.referenceTo),i.type===o.NO.REFERENCE&&i.referenceTo&&t>=this.maxReferenceDepth-1&&this.toast.show(this.i18n.transform("cantSelectMoreThanFiveFieldsLbl"),u.lm.ERROR),this.updateAllowWritebackState())}else this.removeReferenceLevelsAfter(t-1),this.updateFieldName(),this.updateAllowWritebackState()}updateAllowWritebackState(){const t=this.addFieldForm.get("allowWriteback");if(!t)return;let l;if(this.selectedFieldInfo?.type===o.NO.CHILD_RELATIONSHIP)l=!1;else if(this.selectedFieldInfo?.type===o.NO.REFERENCE){const i=this.referenceLevels[0]?.selectedField;l=1===this.referenceLevels.length&&!!i&&i.type!==o.NO.REFERENCE&&i.type!==o.NO.CHILD_RELATIONSHIP}else l=!0;l?t.enable({emitEvent:!1}):(t.setValue(!1,{emitEvent:!1}),t.disable({emitEvent:!1}))}loadReferenceFieldsForLevel(t,l){l&&(this.spinner.show(),this.service.getSfFieldsData(l.toLowerCase(),!1).pipe((0,p.s)(1)).subscribe(i=>{for(this.spinner.hide();this.referenceLevels.length<=t;
1)this.referenceLevels.push({fields:[],selectedField:null,selectedFieldName:"",level:this.referenceLevels.length});this.referenceLevels[t].fields=i||[],this.referenceLevels[t].selectedField=null,this.referenceLevels[t].selectedFieldName="";const n=`referenceField_${t}`;this.addFieldForm.get(n)?this.addFieldForm.get(n)?.setValue(""):(this.addFieldForm.addControl(n,this.formBuilder.control("")),this.addFieldForm.get(n)?.valueChanges.subscribe(c=>{this.onReferenceFieldChange(t,c)}))}))}removeReferenceLevelsAfter(t){for(let l=t+1;l<this.referenceLevels.length;l++){const i=`referenceField_${l}`;this.addFieldForm.get(i)&&this.addFieldForm.removeControl(i)}this.referenceLevels=this.referenceLevels.slice(0,t+1)}resetAllReferenceFields(){for(let t=0;t<this.referenceLevels.length;t++){const l=`referenceField_${t}`;this.addFieldForm.get(l)&&this.addFieldForm.removeControl(l)}this.referenceLevels=[]}updateFieldName(){let t=[];if(this.selectedFieldInfo&&this.selectedFieldInfo.type!==o.NO.REFERENCE)t.push(this.selectedFieldInfo.label);else if(this.selectedFieldInfo&&this.selectedFieldInfo.type===o.NO.REFERENCE){const i=[...this.referenceLevels].reverse().find(n=>n.selectedField);i?.selectedField&&t.push(i.selectedField.label)}const l=t.join(".");this.addFieldForm.get("name")?.setValue(l)}isRootFieldAdded(t){const l=new Set(this.addedMergeFieldNames());if(l.has(t.name))return!0;const i=t.relationshipName;if((t.type===o.NO.REFERENCE||t.type===o.NO.CHILD_RELATIONSHIP)&&i)for(const n of l)if(n===i||n.startsWith(i+"."))return!0;return!1}isRefFieldOptionAdded(t,l){let i=null;if(!this.selectedFieldInfo?.relationshipName)return!1;{const c=[this.selectedFieldInfo.relationshipName];for(let d=0;d<l;d++){const m=this.referenceLevels[d]?.selectedField;if(!m)return!1;{const h=m.type===o.NO.REFERENCE?m.relationshipName||"":m.name;if(!h)return!1;c.push(h)}}i=c.join(".")}const n=new Set(this.addedMergeFieldNames());if(t.type===o.NO.REFERENCE||t.type===o.NO.CHILD_RELATIONSHIP){const c=t.type===o.NO.REFERENCE?t.relationshipName||"":t.name;if(!c)return!1;const d=`${i}.${c}`;for(const m of n)if(m===d||m.startsWith(d+"."))return!0;return!1}return n.has(`${i}.${t.name}`)}static{this.\u0275fac=function(l){return new(l||s)(e.rXU(a.ok),e.rXU(b.o),e.rXU(v.Dx),e.rXU(v.fw),e.rXU(R.$Z))}}static{this.\u0275cmp=e.VBU({type:s,selectors:[["ui-envelope-template-add-fields"]],inputs:{fieldsData:[1,"fieldsData"],addedMergeFieldNames:[1,"addedMergeFieldNames"],externalName:[1,"externalName"]},outputs:{fieldsData:"fieldsDataChange",addedMergeFieldNames:"addedMergeFieldNamesChange",externalName:"externalNameChange",onSave:"onSave",onSaveAndNew:"onSaveAndNew",onCancel:"onCancel"},decls:44,vars:33,consts:[[1,"envelope-template-add-fields","p-4"],[1,"d-flex","flex-column","h-100",3,"formGroup"],[1,"mb-3"],[1,"ui-label-underline","mb-3"],[1,"ui-form-select-wrapper","position-relative"],["formControlName","sourceObject","data-automation-id","sourceObjectSelect",1,"form-select","ui-form-control"],[3,"value"],[1,"fa","fa-chevron-down","ui-form-select-icon"],["for","allowWriteback",1,"ui-label-underline"],["type","checkbox","id","allowWriteback","formControlName","allowWriteback","data-automation-id","allowWritebackCheckbox",1,"ui-checkbox"],["formControlName","field","data-automation-id","fieldSelect",1,"form-select","ui-form-control"],["value",""],["type","text","formControlName","name","data-automation-id","nameInput","placeholder","Enter field name",1,"form-control","ui-form-control"],[1,"d-flex","align-items-center","justify-content-center","mt-auto"],["data-automation-id","btn-cancelOwnerSelection","type","button",1,"view-btn","border","border-dark","border-2","rounded-1",3,"click","matTooltip","matTooltipShowDelay"],["data-automation-id","btn-addSelectedContacts","type","button",1,"ui-btn-primary-fill","mx-2",3,"click","disabled","matTooltip","matTooltipShowDelay"],[1,"form-select","ui-form-control",3,"formControlName","disabled"],[1,"text-muted"]],template:function(l,i){if(1&l&&(e.j41(0,"div",0)(1,"form",1)(2,"div",2)(3,"label",3),e.EFF(4),e.nI1(5,"i18n"),e.k0s(),e.j41(6,"div",4)(7,"select",5)(8,"option",6),e.EFF(9),e.k0s()(),e.nrm(10,"em",7),e.k0s()(),e.j41(11,"div",2)(12,"label",8),e.EFF(13),e.nI1(14,"i18n"),e.k0s(),e.nrm(15,"input",9),e.k0s(),e.j41(16,"div",2)(17,"label",3),e.EFF(18),e.nI1(19,"i18n"),e.k0s(),e.j41(20,"div",4)(21,"select",10)(22,"option",11),e.EFF(23),e.nI1(24,"i18n"),e.k0s(),e.Z7z(25,N,2,2,"option",6,E),e.k0s(),e.nrm(27,"em",7),e.k0s()(),e.Z7z(28,M,13,5,"div",2,O),e.j41(30,"div",2)(31,"label",3),e.EFF(32),e.nI1(33,"i18n"),e.k0s(),e.nrm(34,"input",12),e.k0s(),e.j41(35,"div",13)(36,"button",14),e.nI1(37,"i18n"),e.bIt("click",function(){return i.onCloseModal()}),e.EFF(38),e.nI1(39,"i18n"),e.k0s(),e.j41(40,"button",15),e.nI1(41,"i18n"),e.bIt("click",function(){return i.handleSave()}),e.EFF(42),e.nI1(43,"i18n"),e.k0s()()()()),2&l){let n,c;e.R7$(),e.Y8G("formGroup",i.addFieldForm),e.R7$(3),e.SpI("",e.bMT(5,15,"sourceObjectLbl")," *"),e.R7$(4),e.Y8G("value",null==(n=i.addFieldForm.get("sourceObject"))?null:n.value),e.R7$(),e.SpI(" ",null==(c=i.addFieldForm.get("sourceObject"))?null:c.value," "),e.R7$(4),e.JRh(e.bMT(14,17,"Allow Writeback")),e.R7$(5),e.SpI("",e.bMT(19,19,"fieldLbl")," *"),e.R7$(5),e.JRh(e.bMT(24,21,"selectAnOptionLbl")),e.R7$(2),e.Dyx(i.availableFields()),e.R7$(3),e.Dyx(i.referenceLevels),e.R7$(4),e.JRh(e.bMT(33,23,"selectFieldNameLbl")),e.R7$(4),e.FS9("matTooltip",e.bMT(37,25,"cancelBtn")),e.Y8G("matTooltipShowDelay",1e3),e.R7$(2),e.SpI("",e.bMT(39,27,"cancelBtn")," "),e.R7$(2),e.FS9("matTooltip",e.bMT(41,29,"addRecipientTitle")),e.Y8G("disabled",i.isSaveDisabled())("matTooltipShowDelay",1e3),e.R7$(2),e.SpI(" ",e.bMT(43,31,"Save")," ")}},dependencies:[a.qT,a.xH,a.y7,a.me,a.Zm,a.wz,a.BC,a.cb,a.j4,a.JD,g.oV,C.$],styles:[".envelope-template-add-fields[_ngcontent-%COMP%]{height:500px;overflow-y:auto;display:flex;flex-direction:column}.envelope-template-add-fields[_ngcontent-%COMP%] form[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column}.envelope-template-add-fields[_ngcontent-%COMP%] .ui-form-select-wrapper[_ngcontent-%COMP%] .ui-form-select-icon[_ngcontent-%COMP%]{position:absolute;right:12px;top:50%;transform:translateY(-50%);pointer-events:none;color:#6c757d}.envelope-template-add-fields[_ngcontent-%COMP%] .ui-form-control[_ngcontent-%COMP%]:focus{border-color:#0d6efd;box-shadow:0 0 0 .2rem #0d6efd40}.envelope-template-add-fields[_ngcontent-%COMP%] .form-check-input[_ngcontent-%COMP%]:checked{background-color:#0d6efd;border-color:#0d6efd}.envelope-template-add-fields[_ngcontent-%COMP%] .btn-link[_ngcontent-%COMP%]{color:#0d6efd}.envelope-template-add-fields[_ngcontent-%COMP%] .btn-link[_ngcontent-%COMP%]:hover{color:#0a58ca}.envelope-template-add-fields[_ngcontent-%COMP%] .ui-checkbox[_ngcontent-%COMP%]:disabled{opacity:.5;background-color:#e9ecef;border-color:#ced4da;cursor:not-allowed;pointer-events:none}"]})}}return s})()},85817:(_,F,r)=>{r.d(F,{o:()=>e.o}
1);var e=r(32705)}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.