@coveops/abi 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coveops/abi",
3
3
  "description": "Abi project",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.js",
@@ -26,6 +26,6 @@
26
26
  "rollup-plugin-dotenv": "0.4.1",
27
27
  "rollup-plugin-html": "0.2.1"
28
28
  },
29
- "author": "",
29
+ "author": "hsingh@coveo.com",
30
30
  "license": "ISC"
31
31
  }
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { Component, h, Element, State, Host } from "@stencil/core";
3
+ import { LogClickEventActionCreatorPayload, loadGenericAnalyticsActions } from '@coveo/headless';
3
4
  import { resultContext, Bindings, initializeBindings } from "@coveo/atomic";
4
5
 
5
6
  import {
@@ -28,14 +29,24 @@ export class FaqPopupComponent {
28
29
  this.bindings = await initializeBindings(this.host);
29
30
  this.result = await resultContext(this.host);
30
31
  this.modalElement = this.bindings?.interfaceElement.querySelector('#faq-modal');
31
- console.log("this.result", this.result, this.modalElement, this.bindings)
32
+
32
33
  } catch (error) {
33
34
  console.error(error);
34
35
  this.host.remove();
35
36
  }
36
37
  }
37
- private openFAQModal() {
38
38
 
39
+
40
+
41
+ private openFAQModal(result: Result) {
42
+ if(this.bindings){
43
+ const { logClickEvent } = loadGenericAnalyticsActions (this.bindings.engine);
44
+ const logClickPayload : LogClickEventActionCreatorPayload= {
45
+ evt: 'documentQuickview',
46
+ result: result,
47
+ }
48
+ this.bindings.engine.dispatch(logClickEvent(logClickPayload))
49
+ }
39
50
  this.modalElement.source = this.host;
40
51
  this.modalElement.querySelector('[slot=header]').children[0].innerHTML = 'Question: ' + (this.result?.title || '');
41
52
  // Get the body slot
@@ -94,7 +105,7 @@ export class FaqPopupComponent {
94
105
  }
95
106
 
96
107
  return (
97
- <Host className="clickable-host" onClick={() => this.openFAQModal()}>
108
+ <Host className="clickable-host" onClick={() => this.openFAQModal(this.result!)}>
98
109
  {this.result.title}
99
110
  </Host>
100
111
  );
@@ -70,7 +70,7 @@
70
70
  }
71
71
  </style>
72
72
  <atomic-hosted-page>
73
- <atomic-search-interface fields-to-include='[
73
+ <atomic-search-interface id="search" fields-to-include='[
74
74
  "sfcaseid", "sfppcustomlinkcpplinkurlc", "sfcaseppstatus", "sfcaseppstatusc", "sfcasestatus",
75
75
  "sfppcustomlinkcppiconc", "sfcasenumber", "sfcaseppprocessc", "sfppleaveabsencecppactiontypec",
76
76
  "sfppleaveabsencecppactionreasonc", "sfppleaveabsencecppenddatecfq", "sfppleaveabsencecppenddatecfy",
@@ -1 +0,0 @@
1
- import{r as t,h as s,g as i,H as o}from"./p-0ae1e588.js";import{b as e,c as n,i as a}from"./p-4da5a336.js";class c extends Error{constructor(t){super(`The "${t}" element must be the child of an "atomic-result" element.`)}}const l=class{constructor(s){t(this,s),this.closeFAQModal=()=>{this.modalElement.setAttribute("is-open","false"),this.modalElement.querySelector("#btn-done").removeEventListener("click",this.closeFAQModal)}}async connectedCallback(){var t,s;try{this.bindings=await a(this.host),this.result=await(s=this.host,new Promise(((t,i)=>{const o=e("atomic/resolveResult",(s=>t(s)));s.dispatchEvent(o),n(s,"atomic-result")||i(new c(s.nodeName.toLowerCase()))}))),this.modalElement=null===(t=this.bindings)||void 0===t?void 0:t.interfaceElement.querySelector("#faq-modal"),console.log("this.result",this.result,this.modalElement,this.bindings)}catch(t){console.error(t),this.host.remove()}}openFAQModal(){var t,s,i,o;this.modalElement.source=this.host,this.modalElement.querySelector("[slot=header]").children[0].innerHTML="Question: "+((null===(t=this.result)||void 0===t?void 0:t.title)||"");const e=this.modalElement.querySelector("[slot=body]");e.innerHTML="";const n=document.createElement("div");n.style.display="flex",n.style.gap="16px";const a=document.createElement("div");a.innerText="Answer:",n.appendChild(a);const c=(null===(s=this.result)||void 0===s?void 0:s.raw.answer)||"",l=document.createElement("div");l.innerHTML=c,n.appendChild(l),e.appendChild(n);const h=document.createElement("div");h.innerHTML="Category: "+((null===(i=this.result)||void 0===i?void 0:i.raw.category)||""),e.appendChild(h);const r=document.createElement("div"),d=(null===(o=this.result)||void 0===o?void 0:o.raw.newmoreinfo)||"";r.innerHTML=`Link: <a href="${d}" target="_blank">${d}</a>`,e.appendChild(r),this.modalElement.querySelector("#faq-modal-close").addEventListener("click",this.closeFAQModal),this.modalElement.setAttribute("is-open","true")}render(){if(this.result)return s(o,{className:"clickable-host",onClick:()=>this.openFAQModal()},this.result.title)}get host(){return i(this)}};l.style="b{color:var(--atomic-primary)}";export{l as faq_popup_component}