{"version":3,"file":"Link.min.js","sources":["EncompassWebServices/includes/DashboardItemTypes/Link.js"],"sourcesContent":["\"use strict\";\r\n\r\n(function () {\n let isEdit = false;\r\n const linkType = {\r\n showEditButton: true,\r\n itemFields: [\"URL\", \"Icon\", \"Color\", \"Description\", \"Display\"],\r\n addItem(createNewItemCallback) {\r\n isEdit = \"True\";\r\n InitLinkDialog(createNewItemCallback);\r\n },\r\n editItem(editTitle, itemFields, dashboardItem, editItemCallback) {\r\n isEdit = \"True\";\r\n InitLinkDialog(editItemCallback, itemFields);\r\n },\r\n async onLoaded(dashboardItem, itemFields) {\r\n const myRequest = new ECP.EC_Request(\"DashboardWidget_Link\");\r\n myRequest.SetReturnType(ECP.EC_ReturnType.Text);\r\n const dashboardItemID = dashboardItem.getAttribute(\"id\");\r\n myRequest.AddRequestVariable(\"DashboardItemID\", dashboardItemID);\r\n myRequest.AddRequestVariable(\"URL\", itemFields.URL);\r\n myRequest.AddRequestVariable(\"Icon\", itemFields.Icon);\r\n myRequest.AddRequestVariable(\"Color\", itemFields.Color);\r\n myRequest.AddRequestVariable(\"Description\", itemFields.Description);\r\n myRequest.AddRequestVariable(\"Display\", itemFields.Display);\r\n myRequest.AddRequestVariable(\"Edit\", isEdit);\r\n const html = await myRequest.Submit();\r\n\r\n dashboardItem.querySelector(\".content\").innerHTML = html;\r\n }\r\n };\r\n\r\n EWS.DashboardItemTypesManager.add(\"Link\", linkType);\r\n EWS.DashboardItemTypesManager.add(\"Tile Link\", linkType);\r\n}());\r\n\r\nlet color;\r\nlet title;\r\nlet description;\r\nlet icon;\r\nlet link;\r\nlet myDialog;\r\n\r\nasync function InitLinkDialog(callback, itemFields) {\r\n const myLinkDialogRequest = new ECP.EC_Request(\"DashboardWidget_LinkDialog\");\r\n\r\n myLinkDialogRequest.Submit().then((result) => {\n myDialog = ECP.Dialog.ShowDialog(result.title, result.content, {\r\n width: 500,\r\n cancelButtonTitle: result.cancel,\r\n confirmButtonTitle: result.insert,\r\n cancelButtonAction: () => {\r\n myDialog.querySelector(\"#ecp-dashboard-link-icon\").value = \"\";\r\n myDialog.querySelector(\"#ecp-dashboard-icon-color\").value = \"\";\r\n myDialog.querySelector(\"#ecp-dashboard-link\").value = \"\";\r\n\r\n myDialog.querySelector(\"#ecp-dashboard-link-title\").value = \"\";\r\n myDialog.querySelector(\"#ecp-dashboard-link-description\").value = \"\";\r\n\r\n myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelector(\".ecp-dashboard-link-icon-option\").style.color = \"#000\";\r\n myDialog.classList.remove(\"ecp-dashboard-link-icon-option-highlight\");\r\n },\r\n confirmButtonAction: () => {\r\n title = myDialog.querySelector(\"#ecp-dashboard-link-title\").value;\r\n description = myDialog.querySelector(\"#ecp-dashboard-link-description\").value;\r\n link = myDialog.querySelector(\"#ecp-dashboard-link\").value;\r\n const selected = myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelector(\".ecp-dashboard-link-icon-option-highlight\");\r\n\r\n if (!link) {\r\n LinkAlert(myDialog, EC_Fmt.Trn(\"Please Select a Link\"));\r\n myDialog.style.display = \"block\";\r\n return false;\r\n }\r\n\r\n if (!title) {\r\n LinkAlert(myDialog, EC_Fmt.Trn(\"Please Enter a Title\"));\r\n myDialog.style.display = \"block\";\r\n return false;\r\n }\r\n\r\n if (!selected || selected.length <= 0) {\r\n LinkAlert(myDialog, EC_Fmt.Trn(\"Please Select an Icon\"));\r\n myDialog.style.display = \"block\";\r\n return false;\r\n }\r\n\r\n selected.classList.remove(\"ecp-dashboard-link-icon-option-highlight\");\r\n\r\n color = EC_Fmt.Color(selected.style.color);\r\n icon = selected.getAttribute(\"icon\");\r\n\r\n callback(title, {\r\n URL: link,\r\n Icon: icon,\r\n Color: color,\r\n Description: description,\r\n Display: title\r\n });\r\n ECP.Dialog.CloseDialog(myDialog);\r\n return true;\r\n }\r\n });\r\n\r\n if (itemFields) {\r\n link = itemFields.URL;\r\n icon = itemFields.Icon;\r\n color = itemFields.Color;\r\n description = itemFields.Description;\r\n title = itemFields.Display;\r\n myDialog.querySelector(\"#ecp-dashboard-link\").value = link;\r\n myDialog.querySelector(\"#ecp-dashboard-link-title\").value = title;\r\n myDialog.querySelector(\"#ecp-dashboard-link-description\").value = description;\r\n myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelectorAll(\".ecp-dashboard-link-icon-option\").forEach((item) => {\r\n item.style.color = color;\r\n });\r\n\r\n const iconOption = myDialog.querySelector(`.ecp-dashboard-link-icon-list .ecp-dashboard-link-icon-option[icon='${icon}']`);\r\n iconOption.classList.add(\"ecp-dashboard-link-icon-option-highlight\");\r\n myDialog.querySelector(\"#ecp-dashboard-link-icon\").value = icon;\r\n\r\n setTimeout(() => {\r\n myDialog.querySelector(\".ecp-dashboard-link-icon-list\").scrollTop = iconOption.offsetTop - 40;\r\n }, 200);\r\n }\r\n\r\n myDialog.querySelectorAll(\".ecp-dashboard-icon-color-list .ecp-dashboard-icon-color-option\").forEach((item) => {\r\n item.addEventListener(\"click\", () => {\n const color = `#${item.getAttribute(\"color\")}`;\r\n\r\n myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelectorAll(\".ecp-dashboard-link-icon-option\").forEach((item) => {\r\n item.style.color = color;\r\n });\r\n });\r\n });\r\n\r\n myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelectorAll(\".ecp-dashboard-link-icon-option\").forEach((item) => {\r\n item.addEventListener(\"click\", () => {\n if (myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelector(\".ecp-dashboard-link-icon-option-highlight\")) {\r\n myDialog.querySelector(\".ecp-dashboard-link-icon-list\").querySelector(\".ecp-dashboard-link-icon-option-highlight\").classList.remove(\"ecp-dashboard-link-icon-option-highlight\");\r\n }\r\n\r\n item.classList.add(\"ecp-dashboard-link-icon-option-highlight\");\r\n\r\n myDialog.querySelector(\"#ecp-dashboard-link-icon\").value = item.getAttribute(\"icon\");\r\n myDialog.querySelector(\"#ecp-dashboard-icon-color\").value = EC_Fmt.Color(item.style.color);\r\n });\r\n });\r\n });\r\n}\r\n\r\nfunction LinkAlert(currentDialog, message) {\r\n const dialog = ECP.Dialog.Alert(message);\r\n\r\n dialog.style.zIndex = parseInt(currentDialog.style.zIndex) + 10;\r\n}\r\n"],"names":["let","isEdit","linkType","showEditButton","itemFields","addItem","createNewItemCallback","InitLinkDialog","editItem","editTitle","dashboardItem","editItemCallback","onLoaded","myRequest","ECP","EC_Request","SetReturnType","EC_ReturnType","Text","dashboardItemID","getAttribute","AddRequestVariable","URL","Icon","Color","Description","Display","html","await","Submit","querySelector","innerHTML","EWS","DashboardItemTypesManager","add","color","title","description","icon","link","myDialog","async","callback","myLinkDialogRequest","then","Dialog","ShowDialog","result","content","width","cancelButtonTitle","cancel","confirmButtonTitle","insert","cancelButtonAction","value","style","classList","remove","confirmButtonAction","selected","LinkAlert","EC_Fmt","Trn","display","length","CloseDialog","querySelectorAll","forEach","item","iconOption","setTimeout","scrollTop","offsetTop","addEventListener","currentDialog","message","dialog","Alert","zIndex","parseInt"],"mappings":"AAAA,cAEC,WACGA,IAAIC,EAAS,MACb,MAAMC,EAAW,CACbC,eAAgB,KAChBC,WAAY,CAAC,MAAO,OAAQ,QAAS,cAAe,WACpDC,QAAQC,GACJL,EAAS,OACTM,eAAeD,CAAqB,CACxC,EACAE,SAASC,EAAWL,EAAYM,EAAeC,GAC3CV,EAAS,OACTM,eAAeI,EAAkBP,CAAU,CAC/C,EACAQ,eAAeF,EAAeN,GAC1B,MAAMS,EAAY,IAAIC,IAAIC,WAAW,sBAAsB,EAC3DF,EAAUG,cAAcF,IAAIG,cAAcC,IAAI,EAC9C,MAAMC,EAAkBT,EAAcU,aAAa,IAAI,EACvDP,EAAUQ,mBAAmB,kBAAmBF,CAAe,EAC/DN,EAAUQ,mBAAmB,MAAOjB,EAAWkB,GAAG,EAClDT,EAAUQ,mBAAmB,OAAQjB,EAAWmB,IAAI,EACpDV,EAAUQ,mBAAmB,QAASjB,EAAWoB,KAAK,EACtDX,EAAU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