{"version":3,"file":"PrivateDocument.min.js","sources":["EncompassWebServices/includes/DashboardItemTypes/PrivateDocument.js"],"sourcesContent":["\"use strict\";\r\n\r\n(function () {\r\n const option = {\r\n showEditButton: true,\r\n itemFields: [\"DocumentID\", \"IsShowDownload\"],\r\n addItem(createNewItemCallback) {\r\n EWS.Document.Select(\"Image,HTML,PDF,Excel\", (document, title, documentType, showDownloadButton) => {\r\n createNewItemCallback(title, {\r\n DocumentID: document,\r\n IsShowDownload: showDownloadButton\r\n });\r\n });\r\n },\r\n editItem(title, itemFields, dashboardItem, editItemCallback) {\r\n // Task 606021: CRM - Remove 3rd party JS/CSS libraries (including jQuery) from Encompass by 1/1/2020\r\n ECP.Tools.Ajax(`api?APICommand=Document_GetFileTypeByDocumentID&DocumentID=${itemFields.DocumentID}`, {\r\n method: \"GET\"\r\n }).then((response) => {\r\n response.json().then((result) => {\r\n let isHtml = false;\r\n\r\n if (result.FileType.toLowerCase() === \"html\" || result.FileType.toLowerCase() === \"htm\") {\r\n isHtml = true;\r\n }\r\n\r\n // to do: ajax get extension\r\n if (isHtml) {\r\n EWS.Document.Edit(parseInt(itemFields.DocumentID),\r\n (document, docTitle) => {\r\n editItemCallback(docTitle,\r\n {\r\n DocumentID: document,\r\n IsShowDownload: \"false\"\r\n });\r\n },\r\n title);\r\n } else {\r\n EWS.Document.Select(\"Image,HTML,PDF,Excel\",\r\n (document, docTitle, documentType, showDownloadButton) => {\r\n editItemCallback(docTitle,\r\n {\r\n DocumentID: document,\r\n IsShowDownload: showDownloadButton\r\n });\r\n },\r\n itemFields.DocumentID,\r\n title,\r\n itemFields.IsShowDownload);\r\n }\r\n });\r\n });\r\n },\r\n createViewButtons(dashboardItem) {\r\n const buttons = [];\r\n\r\n if ((dashboardItem.getAttribute(\"item-type\") === \"PrivateDocument\" || dashboardItem.getAttribute(\"item-type\") === \"Private Document\") && dashboardItem.getAttribute(\"data-itemfield-isshowdownload\") === \"true\") {\r\n const documentId = dashboardItem.getAttribute(\"data-itemfield-documentid\");\r\n if (!EC_Fmt.isNull(documentId)) {\r\n buttons.push(EC_Fmt.HtmlStrToElement(` `));\r\n }\r\n }\r\n\r\n const downloadIcon = dashboardItem.querySelector(\".ews-icon-download\");\r\n\r\n if (downloadIcon) {\r\n downloadIcon.parentElement.removeChild(downloadIcon);\r\n }\r\n\r\n return buttons;\r\n }\r\n };\r\n\r\n EWS.DashboardItemTypesManager.add(\"PrivateDocument\", option);\r\n EWS.DashboardItemTypesManager.add(\"Private Document\", option);\r\n}());\r\n"],"names":["option","showEditButton","itemFields","addItem","createNewItemCallback","EWS","Document","Select","document","title","documentType","showDownloadButton","DocumentID","IsShowDownload","editItem","dashboardItem","editItemCallback","ECP","Tools","Ajax","method","then","response","json","let","isHtml","result","FileType","toLowerCase","Edit","parseInt","docTitle","createViewButtons","buttons","getAttribute","documentId","EC_Fmt","isNull","push","HtmlStrToElement","downloadIcon","querySelector","parentElement","removeChild","DashboardItemTypesManager","add"],"mappings":"AAAA,cAEC,WACG,MAAMA,EAAS,CACXC,eAAgB,KAChBC,WAAY,CAAC,aAAc,kBAC3BC,QAAQC,GACJC,IAAIC,SAASC,OAAO,uBAAwB,CAACC,EAAUC,EAAOC,EAAcC,KACxEP,EAAsBK,EAAO,CACzBG,WAAYJ,EACZK,eAAgBF,CACpB,CAAC,CACL,CAAC,CACL,EACAG,SAASL,EAAOP,EAAYa,EAAeC,GAEvCC,IAAIC,MAAMC,mEAAmEjB,EAAWU,aAAc,CAClGQ,OAAQ,KACZ,CAAC,EAAEC,KAAK,IACJC,EAASC,KAAK,EAAEF,KAAK,IACjBG,IAAIC,EAAS,MAEb,GAAIC,EAAOC,SAASC,YAAY,IAAM,QAAUF,EAAOC,SAASC,YAAY,IAAM,MAAO,CACrFH,EAAS,IACb,CAGA,GAAIA,EAAQ,CACRpB,IAAIC,SAASuB,KAAKC,SAAS5B,EAAWU,UAAU,EAC5C,CAACJ,EAAUuB,KACPf,EAAiBe,EACb,CACInB,WAAYJ,EACZK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