@nyaruka/temba-components 0.47.1 → 0.48.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{c5dc6c86.js → 260fc44e.js} +255 -370
  3. package/dist/index.js +255 -370
  4. package/dist/sw.js +1 -1
  5. package/dist/sw.js.map +1 -1
  6. package/dist/templates/components-body.html +1 -1
  7. package/dist/templates/components-head.html +1 -1
  8. package/out-tsc/src/contacts/ContactChat.js +2 -0
  9. package/out-tsc/src/contacts/ContactChat.js.map +1 -1
  10. package/out-tsc/src/contacts/ContactDetails.js +96 -318
  11. package/out-tsc/src/contacts/ContactDetails.js.map +1 -1
  12. package/out-tsc/src/contacts/ContactTickets.js +5 -0
  13. package/out-tsc/src/contacts/ContactTickets.js.map +1 -1
  14. package/out-tsc/src/contacts/events.js +4 -0
  15. package/out-tsc/src/contacts/events.js.map +1 -1
  16. package/out-tsc/src/interfaces.js +1 -0
  17. package/out-tsc/src/interfaces.js.map +1 -1
  18. package/out-tsc/src/tabpane/TabPane.js +18 -4
  19. package/out-tsc/src/tabpane/TabPane.js.map +1 -1
  20. package/out-tsc/src/vectoricon/index.js +1 -0
  21. package/out-tsc/src/vectoricon/index.js.map +1 -1
  22. package/out-tsc/test/temba-contact-details.test.js +19 -8
  23. package/out-tsc/test/temba-contact-details.test.js.map +1 -1
  24. package/out-tsc/test/temba-contact-tickets.test.js +2 -1
  25. package/out-tsc/test/temba-contact-tickets.test.js.map +1 -1
  26. package/package.json +1 -1
  27. package/screenshots/truth/contacts/details.png +0 -0
  28. package/screenshots/truth/contacts/tickets-assignment.png +0 -0
  29. package/screenshots/truth/contacts/tickets.png +0 -0
  30. package/src/contacts/ContactChat.ts +2 -1
  31. package/src/contacts/ContactDetails.ts +98 -320
  32. package/src/contacts/ContactTickets.ts +7 -1
  33. package/src/contacts/events.ts +4 -0
  34. package/src/interfaces.ts +1 -0
  35. package/src/tabpane/TabPane.ts +19 -4
  36. package/src/vectoricon/index.ts +1 -0
  37. package/test/temba-contact-details.test.ts +35 -8
  38. package/test/temba-contact-tickets.test.ts +2 -0
package/dist/sw.js CHANGED
@@ -1,2 +1,2 @@
1
- if(!self.define){let e,t={};const o=(o,n)=>(o=new URL(o+".js",n).href,t[o]||new Promise((t=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=t,document.head.appendChild(e)}else e=o,importScripts(o),t()})).then((()=>{let e=t[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e})));self.define=(n,s)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(t[i])return;let r={};const c=e=>o(e,i),l={module:{uri:i},exports:r,require:c};t[i]=Promise.all(n.map((e=>l[e]||c(e)))).then((e=>(s(...e),r)))}}define(["./workbox-919adfb7"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"c5dc6c86.js",revision:"2b5ef027b7713274a4d505973792c290"},{url:"templates/components-body.html",revision:"c1e51f9b84aca0c63c2ab08c3d8ef1a0"},{url:"templates/components-head.html",revision:"f511b87d2303fdd35406541abd0eb4d0"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute("polyfills/*.js",new e.CacheFirst,"GET")}));
1
+ if(!self.define){let e,t={};const o=(o,n)=>(o=new URL(o+".js",n).href,t[o]||new Promise((t=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=t,document.head.appendChild(e)}else e=o,importScripts(o),t()})).then((()=>{let e=t[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e})));self.define=(n,s)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(t[i])return;let r={};const l=e=>o(e,i),c={module:{uri:i},exports:r,require:l};t[i]=Promise.all(n.map((e=>c[e]||l(e)))).then((e=>(s(...e),r)))}}define(["./workbox-919adfb7"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"260fc44e.js",revision:"22e401ce64e194aca201dfa590f96898"},{url:"templates/components-body.html",revision:"91f752be69c57af0ab6d86e3fee69bda"},{url:"templates/components-head.html",revision:"55926ee7e56ab94cedde25c5df99baa3"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute("polyfills/*.js",new e.CacheFirst,"GET")}));
2
2
  //# sourceMappingURL=sw.js.map
package/dist/sw.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sw.js","sources":["../../../../../tmp/2cdacda589fceb78eac1177ac7400559/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"c5dc6c86.js\",\n \"revision\": \"2b5ef027b7713274a4d505973792c290\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"c1e51f9b84aca0c63c2ab08c3d8ef1a0\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"f511b87d2303fdd35406541abd0eb4d0\"\n }\n], {});\n\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"/index.html\")));\n\n\nworkbox_routing_registerRoute(\"polyfills/*.js\", new workbox_strategies_CacheFirst(), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","url","revision","workbox","registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","workbox_strategies_CacheFirst"],"mappings":"0nBAwBAA,KAAKC,cAELC,EAAAA,eAQAC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,cACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,qCAEb,CAAE,GAEwBC,EAAAC,cAAC,IAAIC,EAAAA,gBAAgCC,EAAAA,wBAA2C,iBAGhFH,EAAAC,cAAC,iBAAkB,IAAIG,aAAiC"}
1
+ {"version":3,"file":"sw.js","sources":["../../../../../tmp/2bba64f6c3c60b2f57653b5aca41fbec/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"260fc44e.js\",\n \"revision\": \"22e401ce64e194aca201dfa590f96898\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"91f752be69c57af0ab6d86e3fee69bda\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"55926ee7e56ab94cedde25c5df99baa3\"\n }\n], {});\n\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"/index.html\")));\n\n\nworkbox_routing_registerRoute(\"polyfills/*.js\", new workbox_strategies_CacheFirst(), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","url","revision","workbox","registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","workbox_strategies_CacheFirst"],"mappings":"0nBAwBAA,KAAKC,cAELC,EAAAA,eAQAC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,cACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,qCAEb,CAAE,GAEwBC,EAAAC,cAAC,IAAIC,EAAAA,gBAAgCC,EAAAA,wBAA2C,iBAGhFH,EAAAC,cAAC,iBAAkB,IAAIG,aAAiC"}
@@ -1 +1 @@
1
- <script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/c5dc6c86.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.47.1"</script>
1
+ <script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/260fc44e.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.48.0"</script>
@@ -1 +1 @@
1
- <link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/c5dc6c86.js" crossorigin="anonymous">
1
+ <link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/260fc44e.js" crossorigin="anonymous">
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { css, html } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
+ import { CustomEventType } from '../interfaces';
4
5
  import { COOKIE_KEYS, getCookieBoolean, postJSON } from '../utils';
5
6
  import { ContactStoreElement } from './ContactStoreElement';
6
7
  const DEFAULT_REFRESH = 10000;
@@ -163,6 +164,7 @@ export class ContactChat extends ContactStoreElement {
163
164
  if (response.status < 400) {
164
165
  compose.reset();
165
166
  this.refresh(true);
167
+ this.fireCustomEvent(CustomEventType.MessageSent, { msg: payload });
166
168
  }
167
169
  else if (response.status < 500) {
168
170
  if (response.json.text &&
@@ -1 +1 @@
1
- {"version":3,"file":"ContactChat.js","sourceRoot":"","sources":["../../../src/contacts/ContactChat.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,WAAY,SAAQ,mBAAmB;IAC3C,MAAM,KAA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;gCAMiB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;;WAG/C,CAAC;IACV,CAAC;CACF;AA1MC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;+CAC7B;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACgB;AAG3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACE;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAChB","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { Contact, Ticket } from '../interfaces';\nimport { COOKIE_KEYS, getCookieBoolean, postJSON } from '../utils';\nimport { ContactHistory } from './ContactHistory';\nimport { ContactStoreElement } from './ContactStoreElement';\nimport { Compose } from '../compose/Compose';\n\nconst DEFAULT_REFRESH = 10000;\n\nexport class ContactChat extends ContactStoreElement {\n public static get styles() {\n return css`\n .left-pane {\n box-shadow: -13px 10px 7px 14px rgba(0, 0, 0, 0);\n transition: box-shadow 600ms linear;\n }\n\n .left-pane.open {\n z-index: 1000;\n }\n\n :host {\n flex-grow: 1;\n display: flex;\n flex-direction: row;\n min-height: 0;\n border-radius: var(--curvature);\n }\n\n .chat-wrapper {\n display: flex;\n flex-grow: 1;\n flex-direction: column;\n overflow: hidden;\n min-height: 0;\n border-radius: var(--curvature);\n }\n\n temba-contact-history {\n border-bottom: 3px solid #e1e1e1;\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n\n .chatbox {\n background: rgb(242, 242, 242);\n padding: 1em;\n display: flex;\n flex-direction: column;\n z-index: 3;\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n }\n\n .chatbox.full {\n border-bottom-right-radius: 0 !important;\n }\n\n .closed-footer {\n padding: 1em;\n background: #f2f2f2;\n border-top: 3px solid #e1e1e1;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n a {\n color: var(--color-link-primary);\n }\n\n a:hover {\n text-decoration: underline;\n color: var(--color-link-primary-hover);\n }\n\n temba-button#reopen-button {\n --button-y: 1px;\n --button-x: 12px;\n }\n\n temba-completion {\n --widget-box-shadow: none;\n --color-widget-border: transparent;\n --widget-box-shadow-focused: none;\n --color-focus: transparent;\n --color-widget-bg-focused: transparent;\n }\n `;\n }\n\n @property({ type: String, attribute: 'ticket' })\n ticketUUID: string;\n\n @property({ type: String })\n contactsEndpoint = '/api/v2/contacts.json';\n\n @property({ type: String })\n currentNote = '';\n\n @property({ type: Boolean })\n showDetails = true;\n\n @property({ type: Boolean })\n monitor = false;\n\n @property({ type: Object })\n currentTicket: Ticket = null;\n\n @property({ type: Object })\n currentContact: Contact = null;\n\n @property({ type: String })\n agent = '';\n\n // http promise to monitor for completeness\n public httpComplete: Promise<void>;\n\n constructor() {\n super();\n this.showDetails = getCookieBoolean(COOKIE_KEYS.TICKET_SHOW_DETAILS);\n }\n\n refreshInterval = null;\n\n public connectedCallback() {\n super.connectedCallback();\n if (this.monitor) {\n this.refreshInterval = setInterval(() => {\n if (this.currentTicket && this.currentTicket.closed_on) {\n return;\n }\n this.refresh();\n }, DEFAULT_REFRESH);\n }\n }\n\n public disconnectedCallback() {\n if (this.refreshInterval) {\n clearInterval(this.refreshInterval);\n }\n }\n\n public getContactHistory(): ContactHistory {\n return this.shadowRoot.querySelector(\n 'temba-contact-history'\n ) as ContactHistory;\n }\n\n public refresh(scrollToBottom = false): void {\n const contactHistory = this.getContactHistory();\n if (contactHistory) {\n if (scrollToBottom) {\n contactHistory.scrollToBottom();\n }\n contactHistory.refresh();\n // super.refresh();\n }\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if we don't have an endpoint infer one\n if (\n changedProperties.has('data') ||\n changedProperties.has('currentContact')\n ) {\n this.currentContact = this.data;\n }\n }\n\n private handleSend(evt: CustomEvent) {\n const buttonName = evt.detail.name;\n if (buttonName === 'Send') {\n const payload = {\n contact: this.currentContact.uuid,\n };\n const compose = evt.currentTarget as Compose;\n if (compose) {\n const text = compose.currentText;\n if (text && text.length > 0) {\n payload['text'] = text;\n }\n const attachments = compose.currentAttachments;\n if (attachments && attachments.length > 0) {\n const attachment_uuids = attachments.map(\n attachment => attachment.uuid\n );\n payload['attachments'] = attachment_uuids;\n }\n }\n if (this.currentTicket) {\n payload['ticket'] = this.currentTicket.uuid;\n }\n\n const genericError = buttonName + ' failed, please try again.';\n\n postJSON(`/api/v2/messages.json`, payload)\n .then(response => {\n if (response.status < 400) {\n compose.reset();\n this.refresh(true);\n } else if (response.status < 500) {\n if (\n response.json.text &&\n response.json.text.eng &&\n response.json.text.eng.length > 0\n ) {\n compose.buttonError =\n 'Text must have no more than 640 characters.';\n } else if (\n response.json.attachments &&\n response.json.attachments.eng &&\n response.json.attachments.eng.length > 0\n ) {\n compose.buttonError =\n 'Attachments must have no more than 10 files.';\n } else {\n compose.buttonError = genericError;\n }\n } else {\n compose.buttonError = genericError;\n }\n })\n .catch(error => {\n console.error(error);\n compose.buttonError = genericError;\n });\n }\n }\n\n public render(): TemplateResult {\n const contactHistory = this.currentContact\n ? this.getTembaContactHistory()\n : null;\n const chatbox = this.currentContact ? this.getTembaChatbox() : null;\n\n const contactHistoryAndChatbox = html`<div\n style=\"flex-grow: 1; margin-right: 0em; display:flex; flex-direction:row; min-height: 0;\"\n class=\"left-pane ${this.showDetails ? 'open' : ''}\"\n >\n <div class=\"chat-wrapper\">${contactHistory} ${chatbox}</div>\n </div>`;\n return html`${contactHistoryAndChatbox}`;\n }\n\n private getTembaContactHistory(): TemplateResult {\n return html` <temba-contact-history\n .uuid=${this.currentContact.uuid}\n .contact=${this.currentContact}\n .ticket=${this.currentTicket ? this.currentTicket.uuid : null}\n .endDate=${this.currentTicket ? this.currentTicket.closed_on : null}\n .agent=${this.agent}\n >\n </temba-contact-history>`;\n }\n\n private getTembaChatbox(): TemplateResult {\n if (this.currentTicket) {\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n if (!this.currentTicket.closed_on) {\n //chatbox for active contacts with an open ticket\n return this.getChatbox();\n } else {\n return null;\n }\n }\n }\n\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n //chatbox for active contacts\n return this.getChatbox();\n }\n }\n\n private getChatbox(): TemplateResult {\n return html`<div class=\"chatbox\">\n <temba-compose\n chatbox\n attachments\n counter\n button\n @temba-button-clicked=${this.handleSend.bind(this)}\n >\n </temba-compose>\n </div>`;\n }\n}\n"]}
1
+ {"version":3,"file":"ContactChat.js","sourceRoot":"","sources":["../../../src/contacts/ContactChat.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAW,eAAe,EAAU,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,WAAY,SAAQ,mBAAmB;IAC3C,MAAM,KAAK,MAAM;QACtB,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;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IAEO,UAAU;QAChB,OAAO,IAAI,CAAA;;;;;;gCAMiB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;;WAG/C,CAAC;IACV,CAAC;CACF;AA3MC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;+CAC7B;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACgB;AAG3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACE;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAChB","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { Contact, CustomEventType, Ticket } from '../interfaces';\nimport { COOKIE_KEYS, getCookieBoolean, postJSON } from '../utils';\nimport { ContactHistory } from './ContactHistory';\nimport { ContactStoreElement } from './ContactStoreElement';\nimport { Compose } from '../compose/Compose';\n\nconst DEFAULT_REFRESH = 10000;\n\nexport class ContactChat extends ContactStoreElement {\n public static get styles() {\n return css`\n .left-pane {\n box-shadow: -13px 10px 7px 14px rgba(0, 0, 0, 0);\n transition: box-shadow 600ms linear;\n }\n\n .left-pane.open {\n z-index: 1000;\n }\n\n :host {\n flex-grow: 1;\n display: flex;\n flex-direction: row;\n min-height: 0;\n border-radius: var(--curvature);\n }\n\n .chat-wrapper {\n display: flex;\n flex-grow: 1;\n flex-direction: column;\n overflow: hidden;\n min-height: 0;\n border-radius: var(--curvature);\n }\n\n temba-contact-history {\n border-bottom: 3px solid #e1e1e1;\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n\n .chatbox {\n background: rgb(242, 242, 242);\n padding: 1em;\n display: flex;\n flex-direction: column;\n z-index: 3;\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n }\n\n .chatbox.full {\n border-bottom-right-radius: 0 !important;\n }\n\n .closed-footer {\n padding: 1em;\n background: #f2f2f2;\n border-top: 3px solid #e1e1e1;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n a {\n color: var(--color-link-primary);\n }\n\n a:hover {\n text-decoration: underline;\n color: var(--color-link-primary-hover);\n }\n\n temba-button#reopen-button {\n --button-y: 1px;\n --button-x: 12px;\n }\n\n temba-completion {\n --widget-box-shadow: none;\n --color-widget-border: transparent;\n --widget-box-shadow-focused: none;\n --color-focus: transparent;\n --color-widget-bg-focused: transparent;\n }\n `;\n }\n\n @property({ type: String, attribute: 'ticket' })\n ticketUUID: string;\n\n @property({ type: String })\n contactsEndpoint = '/api/v2/contacts.json';\n\n @property({ type: String })\n currentNote = '';\n\n @property({ type: Boolean })\n showDetails = true;\n\n @property({ type: Boolean })\n monitor = false;\n\n @property({ type: Object })\n currentTicket: Ticket = null;\n\n @property({ type: Object })\n currentContact: Contact = null;\n\n @property({ type: String })\n agent = '';\n\n // http promise to monitor for completeness\n public httpComplete: Promise<void>;\n\n constructor() {\n super();\n this.showDetails = getCookieBoolean(COOKIE_KEYS.TICKET_SHOW_DETAILS);\n }\n\n refreshInterval = null;\n\n public connectedCallback() {\n super.connectedCallback();\n if (this.monitor) {\n this.refreshInterval = setInterval(() => {\n if (this.currentTicket && this.currentTicket.closed_on) {\n return;\n }\n this.refresh();\n }, DEFAULT_REFRESH);\n }\n }\n\n public disconnectedCallback() {\n if (this.refreshInterval) {\n clearInterval(this.refreshInterval);\n }\n }\n\n public getContactHistory(): ContactHistory {\n return this.shadowRoot.querySelector(\n 'temba-contact-history'\n ) as ContactHistory;\n }\n\n public refresh(scrollToBottom = false): void {\n const contactHistory = this.getContactHistory();\n if (contactHistory) {\n if (scrollToBottom) {\n contactHistory.scrollToBottom();\n }\n contactHistory.refresh();\n // super.refresh();\n }\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if we don't have an endpoint infer one\n if (\n changedProperties.has('data') ||\n changedProperties.has('currentContact')\n ) {\n this.currentContact = this.data;\n }\n }\n\n private handleSend(evt: CustomEvent) {\n const buttonName = evt.detail.name;\n if (buttonName === 'Send') {\n const payload = {\n contact: this.currentContact.uuid,\n };\n const compose = evt.currentTarget as Compose;\n if (compose) {\n const text = compose.currentText;\n if (text && text.length > 0) {\n payload['text'] = text;\n }\n const attachments = compose.currentAttachments;\n if (attachments && attachments.length > 0) {\n const attachment_uuids = attachments.map(\n attachment => attachment.uuid\n );\n payload['attachments'] = attachment_uuids;\n }\n }\n if (this.currentTicket) {\n payload['ticket'] = this.currentTicket.uuid;\n }\n\n const genericError = buttonName + ' failed, please try again.';\n\n postJSON(`/api/v2/messages.json`, payload)\n .then(response => {\n if (response.status < 400) {\n compose.reset();\n this.refresh(true);\n this.fireCustomEvent(CustomEventType.MessageSent, { msg: payload });\n } else if (response.status < 500) {\n if (\n response.json.text &&\n response.json.text.eng &&\n response.json.text.eng.length > 0\n ) {\n compose.buttonError =\n 'Text must have no more than 640 characters.';\n } else if (\n response.json.attachments &&\n response.json.attachments.eng &&\n response.json.attachments.eng.length > 0\n ) {\n compose.buttonError =\n 'Attachments must have no more than 10 files.';\n } else {\n compose.buttonError = genericError;\n }\n } else {\n compose.buttonError = genericError;\n }\n })\n .catch(error => {\n console.error(error);\n compose.buttonError = genericError;\n });\n }\n }\n\n public render(): TemplateResult {\n const contactHistory = this.currentContact\n ? this.getTembaContactHistory()\n : null;\n const chatbox = this.currentContact ? this.getTembaChatbox() : null;\n\n const contactHistoryAndChatbox = html`<div\n style=\"flex-grow: 1; margin-right: 0em; display:flex; flex-direction:row; min-height: 0;\"\n class=\"left-pane ${this.showDetails ? 'open' : ''}\"\n >\n <div class=\"chat-wrapper\">${contactHistory} ${chatbox}</div>\n </div>`;\n return html`${contactHistoryAndChatbox}`;\n }\n\n private getTembaContactHistory(): TemplateResult {\n return html` <temba-contact-history\n .uuid=${this.currentContact.uuid}\n .contact=${this.currentContact}\n .ticket=${this.currentTicket ? this.currentTicket.uuid : null}\n .endDate=${this.currentTicket ? this.currentTicket.closed_on : null}\n .agent=${this.agent}\n >\n </temba-contact-history>`;\n }\n\n private getTembaChatbox(): TemplateResult {\n if (this.currentTicket) {\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n if (!this.currentTicket.closed_on) {\n //chatbox for active contacts with an open ticket\n return this.getChatbox();\n } else {\n return null;\n }\n }\n }\n\n if (this.currentContact && this.currentContact.status !== 'active') {\n //no chatbox for archived, blocked, or stopped contacts\n return null;\n } else {\n //chatbox for active contacts\n return this.getChatbox();\n }\n }\n\n private getChatbox(): TemplateResult {\n return html`<div class=\"chatbox\">\n <temba-compose\n chatbox\n attachments\n counter\n button\n @temba-button-clicked=${this.handleSend.bind(this)}\n >\n </temba-compose>\n </div>`;\n }\n}\n"]}
@@ -1,343 +1,121 @@
1
- import { __decorate } from "tslib";
2
1
  import { css, html } from 'lit';
3
- import { property } from 'lit/decorators.js';
4
- import { RapidElement } from '../RapidElement';
5
- import { isDate, timeSince, truncate } from '../utils';
6
- import { BODY_SNIPPET_LENGTH, fetchContact } from './helpers';
2
+ import { ContactStoreElement } from './ContactStoreElement';
7
3
  import { Icon } from '../vectoricon';
8
- export class ContactDetails extends RapidElement {
9
- constructor() {
10
- super(...arguments);
11
- this.flow = null;
12
- // the fields with values for this contact
13
- this.fields = [];
14
- this.expandFields = false;
15
- this.expandBody = false;
16
- this.showGroups = false;
17
- this.showFlows = false;
18
- this.ticket = null;
19
- }
4
+ import { capitalize } from '../utils';
5
+ const STATUS = {
6
+ active: 'Active',
7
+ blocked: 'Blocked',
8
+ stopped: 'Stopped',
9
+ archived: 'Archived',
10
+ };
11
+ const SCHEMES = {
12
+ tel: 'Phone',
13
+ whatsapp: 'WhatsApp',
14
+ fcm: 'Firebase Cloud Messaging',
15
+ twitter: 'Twitter',
16
+ };
17
+ export class ContactDetails extends ContactStoreElement {
20
18
  static get styles() {
21
19
  return css `
22
- :host {
23
- background: #f9f9f9;
24
- display: block;
25
- height: 100%;
26
- position: relative;
27
- overflow: hidden;
28
- -webkit-mask-image: -webkit-radial-gradient(white, black);
29
- }
30
-
31
- .contact {
32
- display: flex;
33
- flex-direction: column;
34
- align-items: stretch;
35
- height: 100%;
36
- }
37
-
38
- .wrapper {
39
- padding: 0em 1em;
40
- flex-grow: 1;
20
+ .urn {
41
21
  display: flex;
42
- flex-direction: column;
43
- }
44
-
45
- a {
46
- color: var(--color-link-primary);
47
- }
48
-
49
- .field-links {
50
- font-size: 0.8em;
51
- }
52
-
53
- .contact > .name {
54
- font-size: 1.2em;
55
- font-weight: 400;
56
- padding: 0.5em 0.75em;
57
- padding-right: 1em;
22
+ padding: 0.4em 1em 0.8em 1em;
23
+ border-bottom: 1px solid #e6e6e6;
24
+ margin-bottom: 0.5em;
58
25
  }
59
26
 
60
- .group-label temba-icon {
61
- display: inline-block;
62
- fill: var(--color-text-dark);
63
- margin-bottom: -2px;
64
- margin-right: 4px;
27
+ .urn .path {
28
+ margin-left: 0.2em;
65
29
  }
66
30
 
67
- .group-label {
68
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),
69
- 0 1px 2px 0 rgba(0, 0, 0, 0.06);
70
- line-height: 1.25;
71
- text-decoration: none;
72
- cursor: default;
73
- padding-left: 0.5rem;
74
- padding-right: 0.5rem;
75
- padding-top: 0.25rem;
76
- padding-bottom: 0.25rem;
77
- display: inline-block;
78
- font-size: 0.75rem;
79
- font-weight: 400;
80
- border-radius: 9999px;
81
- background-color: #f1f1f1;
82
- color: rgba(0, 0, 0, 0.5);
83
- letter-spacing: 0.025em;
84
- white-space: nowrap;
85
- text-align: center;
86
- user-select: none;
87
- -webkit-user-select: none;
88
- margin-right: 0.75em;
89
- margin-bottom: 0.75em;
31
+ .wrapper {
32
+ padding-top: 0em;
90
33
  }
91
34
 
92
35
  .groups {
93
- margin-top: 0.55em;
94
- padding: 0px 0.75em;
95
- margin-bottom: 0.3em;
96
- }
97
-
98
- .start-flow {
36
+ padding: 0.4em 0.5em 0.6em 0.5em;
37
+ border-bottom: 1px solid #e6e6e6;
38
+ margin-bottom: 0.4em;
99
39
  }
100
-
101
- .actions {
102
- margin-top: 16px;
103
- border: 0px solid #ddd;
104
- border-radius: var(--curvature);
105
- padding: 0px;
40
+ .group {
41
+ margin-right: 0.7em;
42
+ margin-bottom: 0.7em;
106
43
  }
107
44
 
108
- .fields-wrapper {
109
- background: #fff;
110
- overflow: hidden;
111
- margin: 0em -1em;
112
-
113
- display: flex;
114
- align-items: stretch;
115
- flex-direction: column;
116
- transition: all 300ms linear;
117
- }
118
-
119
- .fields-wrapper.expanded {
120
- flex-grow: 2;
121
- }
122
-
123
- .body-wrapper {
124
- overflow: hidden;
125
- }
126
-
127
- .body {
128
- max-height: 200px;
129
- overflow-y: auto;
130
- }
131
-
132
- .fields {
133
- padding: 1em;
134
- overflow-y: auto;
135
- }
136
-
137
- .fields-wrapper.expanded .fields {
138
- flex-grow: 1;
139
- height: 0px;
140
- }
141
-
142
- .field {
143
- border-radius: var(--curvature);
144
-
145
- display: flex;
146
- flex-direction: column;
147
- margin-bottom: 0.3em;
148
- }
149
-
150
- .field .name {
151
- margin-right: 8px;
152
- font-weight: 400;
153
- color: #666;
154
- font-size: 0.9em;
155
- word-break: break-word;
156
- }
157
- .field .value {
45
+ .label {
158
46
  font-size: 0.8em;
159
- word-break: break-word;
160
- }
161
-
162
- temba-button {
163
- margin-top: 5px;
164
- display: block;
165
- --button-y: 0;
47
+ color: rgb(136, 136, 136);
48
+ margin-left: 0.5em;
49
+ margin-bottom: 0.4em;
166
50
  }
167
51
  `;
168
52
  }
169
- updated(changes) {
170
- super.updated(changes);
171
- if (changes.has('contact')) {
172
- const store = document.querySelector('temba-store');
173
- if (this.contact && this.contact.fields) {
174
- this.fields = Object.keys(this.contact.fields).filter((key) => {
175
- const hasField = !!this.contact.fields[key];
176
- return hasField && store.getContactField(key).featured;
177
- });
178
- this.contact.groups.forEach((group) => {
179
- group.is_dynamic = store.isDynamicGroup(group.uuid);
180
- });
181
- this.contact.groups.sort((a, b) => {
182
- if (a.is_dynamic) {
183
- return -1;
184
- }
185
- if (b.is_dynamic) {
186
- return 1;
187
- }
188
- return a.name.localeCompare(b.name);
189
- });
190
- }
191
- }
192
- if (changes.has('endpoint')) {
193
- this.flow = null;
194
- this.expandFields = false;
195
- fetchContact(this.endpoint).then((contact) => {
196
- this.contact = contact;
197
- });
198
- }
199
- }
200
- handleFlowChanged(evt) {
201
- this.flow = evt.detail.selected;
202
- }
203
- handleToggleFields() {
204
- this.expandFields = !this.expandFields;
205
- }
206
- handleExpandBody() {
207
- this.expandBody = true;
208
- }
209
- handleHideBody() {
210
- this.expandBody = false;
211
- }
53
+ // Not sure if we want to include name here or not, so hold onto this for the moment
54
+ // ${this.data.name ? html`<temba-contact-field name="Name" value=${this.data.name} disabled></temba-contact-field>`:null}
212
55
  render() {
213
- const store = document.querySelector('temba-store');
214
- let body = this.ticket ? this.ticket.body : null;
215
- const showBodyToggle = body ? body.length > BODY_SNIPPET_LENGTH : false;
216
- if (!this.expandBody &&
217
- this.ticket &&
218
- this.ticket.body.length > BODY_SNIPPET_LENGTH) {
219
- body = truncate(this.ticket.body, BODY_SNIPPET_LENGTH);
56
+ if (!this.data) {
57
+ return;
220
58
  }
221
- if (this.contact) {
222
- return html `<div class="contact">
223
- ${this.ticket
224
- ? html `<div class="name">${this.name || this.contact.name}</div>`
225
- : null}
226
- ${this.showGroups && !this.ticket
227
- ? html `<div class="groups">
228
- ${this.contact.groups.map((group) => {
229
- return html `
230
- <div
231
- onclick="goto(event)"
232
- href="/contact/filter/${group.uuid}/"
233
- class="group-label"
234
- style="cursor:pointer"
235
- >
236
- ${group.is_dynamic
237
- ? html `<temba-icon
238
- name="${Icon.group_smart}"
239
- ></temba-icon>`
240
- : null}${group.name}
241
- </div>
242
- `;
243
- })}
244
- </div>`
245
- : html ``}
246
-
247
- <div class="wrapper">
248
- ${body
249
- ? html `<div class="body-wrapper">
250
- <div class="body">${body}</div>
251
- <div class="field-links">
252
- ${showBodyToggle
253
- ? !this.expandBody
254
- ? html `<a href="#" @click="${this.handleExpandBody}"
255
- >more</a
256
- >`
257
- : html `<a href="#" @click="${this.handleHideBody}"
258
- >less</a
259
- >`
260
- : null}
261
- </div>
262
- </div>`
263
- : null}
264
- ${this.fields.length > 0
265
- ? html ` <div
266
- class="fields-wrapper ${this.expandFields ? 'expanded' : ''}"
59
+ const lang = this.store.getLanguageName(this.data.language);
60
+ return html `
61
+ <div class="wrapper">
62
+ ${this.data.groups.length > 0
63
+ ? html ` <div class="groups">
64
+ <div class="label">Groups</div>
65
+ ${this.data.groups.map(group => {
66
+ return html `<temba-label
67
+ class="group"
68
+ onclick="goto(event)"
69
+ href="/contact/filter/${group.uuid}/"
70
+ icon=${group.is_dynamic ? Icon.group_smart : Icon.group}
71
+ clickable
72
+ shadow
267
73
  >
268
- <div class="fields">
269
- ${this.fields
270
- .slice(0, this.expandFields ? 255 : 3)
271
- .map((key) => {
272
- let value = this.contact.fields[key];
273
- if (value) {
274
- if (isDate(value)) {
275
- value = timeSince(new Date(value));
276
- }
277
- return html `<div class="field">
278
- <div class="name">
279
- ${store.getContactField(key).label}
280
- </div>
281
- <div class="value">${value}</div>
282
- </div>`;
283
- }
284
- })}
285
- </div>
286
- </div>
287
- <div style="display:flex;">
288
- <div style="flex-grow:1"></div>
289
- <div style="margin-right:1em;margin-top:-0.5em">
290
- ${this.fields.length > 3
291
- ? html `<temba-icon
292
- name="${this.expandFields
293
- ? Icon.arrow_up
294
- : Icon.arrow_down}"
295
- @click=${this.handleToggleFields}
296
- animateChange="spin"
297
- circled
298
- clickable
299
- ></temba-icon>`
300
- : null}
301
- </div>
302
- </div>`
303
- : null}
304
- <div style="flex-grow:1"></div>
305
- </div>
306
- </div>`;
307
- }
74
+ ${group.name}
75
+ </temba-label>`;
76
+ })}
77
+ </div>`
78
+ : null}
79
+ ${this.data.urns.map(urn => {
80
+ const parts = urn.split(':');
81
+ let scheme = SCHEMES[parts[0]];
82
+ if (!scheme) {
83
+ scheme = capitalize(parts[0]);
84
+ }
85
+ return html `<temba-contact-field
86
+ name=${scheme}
87
+ value=${parts[1]}
88
+ disabled
89
+ ></temba-contact-field>`;
90
+ })}
91
+
92
+ <temba-contact-field
93
+ name="Status"
94
+ value=${STATUS[this.data.status]}
95
+ disabled
96
+ ></temba-contact-field>
97
+ ${lang
98
+ ? html `<temba-contact-field
99
+ name="Language"
100
+ value=${lang}
101
+ disabled
102
+ ></temba-contact-field>`
103
+ : null}
104
+
105
+ <temba-contact-field
106
+ name="Created"
107
+ value=${this.data.created_on}
108
+ type="datetime"
109
+ disabled
110
+ ></temba-contact-field>
111
+ <temba-contact-field
112
+ name="Last Seen"
113
+ value=${this.data.last_seen_on}
114
+ type="datetime"
115
+ disabled
116
+ ></temba-contact-field>
117
+ </div>
118
+ `;
308
119
  }
309
120
  }
310
- __decorate([
311
- property({ type: String })
312
- ], ContactDetails.prototype, "name", void 0);
313
- __decorate([
314
- property({ type: String })
315
- ], ContactDetails.prototype, "uuid", void 0);
316
- __decorate([
317
- property({ type: Object })
318
- ], ContactDetails.prototype, "contact", void 0);
319
- __decorate([
320
- property({ attribute: false })
321
- ], ContactDetails.prototype, "flow", void 0);
322
- __decorate([
323
- property({ type: Array })
324
- ], ContactDetails.prototype, "fields", void 0);
325
- __decorate([
326
- property({ type: String })
327
- ], ContactDetails.prototype, "endpoint", void 0);
328
- __decorate([
329
- property({ type: Boolean })
330
- ], ContactDetails.prototype, "expandFields", void 0);
331
- __decorate([
332
- property({ type: Boolean })
333
- ], ContactDetails.prototype, "expandBody", void 0);
334
- __decorate([
335
- property({ type: Boolean })
336
- ], ContactDetails.prototype, "showGroups", void 0);
337
- __decorate([
338
- property({ type: Boolean })
339
- ], ContactDetails.prototype, "showFlows", void 0);
340
- __decorate([
341
- property({ type: Object })
342
- ], ContactDetails.prototype, "ticket", void 0);
343
121
  //# sourceMappingURL=ContactDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContactDetails.js","sourceRoot":"","sources":["../../../src/contacts/ContactDetails.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,OAAO,cAAe,SAAQ,YAAY;IAAhD;;QAkKE,SAAI,GAAQ,IAAI,CAAC;QAEjB,0CAA0C;QAE1C,WAAM,GAAa,EAAE,CAAC;QAMtB,iBAAY,GAAG,KAAK,CAAC;QAGrB,eAAU,GAAG,KAAK,CAAC;QAGnB,eAAU,GAAG,KAAK,CAAC;QAGnB,cAAS,GAAG,KAAK,CAAC;QAGlB,WAAM,GAAW,IAAI,CAAC;IA2JxB,CAAC;IAlVC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACL","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { Contact, Group, Ticket } from '../interfaces';\nimport { RapidElement } from '../RapidElement';\nimport { isDate, timeSince, truncate } from '../utils';\nimport { Store } from '../store/Store';\nimport { BODY_SNIPPET_LENGTH, fetchContact } from './helpers';\nimport { Icon } from '../vectoricon';\n\nexport class ContactDetails extends RapidElement {\n static get styles() {\n return css`\n :host {\n background: #f9f9f9;\n display: block;\n height: 100%;\n position: relative;\n overflow: hidden;\n -webkit-mask-image: -webkit-radial-gradient(white, black);\n }\n\n .contact {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n height: 100%;\n }\n\n .wrapper {\n padding: 0em 1em;\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n }\n\n a {\n color: var(--color-link-primary);\n }\n\n .field-links {\n font-size: 0.8em;\n }\n\n .contact > .name {\n font-size: 1.2em;\n font-weight: 400;\n padding: 0.5em 0.75em;\n padding-right: 1em;\n }\n\n .group-label temba-icon {\n display: inline-block;\n fill: var(--color-text-dark);\n margin-bottom: -2px;\n margin-right: 4px;\n }\n\n .group-label {\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),\n 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n line-height: 1.25;\n text-decoration: none;\n cursor: default;\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n display: inline-block;\n font-size: 0.75rem;\n font-weight: 400;\n border-radius: 9999px;\n background-color: #f1f1f1;\n color: rgba(0, 0, 0, 0.5);\n letter-spacing: 0.025em;\n white-space: nowrap;\n text-align: center;\n user-select: none;\n -webkit-user-select: none;\n margin-right: 0.75em;\n margin-bottom: 0.75em;\n }\n\n .groups {\n margin-top: 0.55em;\n padding: 0px 0.75em;\n margin-bottom: 0.3em;\n }\n\n .start-flow {\n }\n\n .actions {\n margin-top: 16px;\n border: 0px solid #ddd;\n border-radius: var(--curvature);\n padding: 0px;\n }\n\n .fields-wrapper {\n background: #fff;\n overflow: hidden;\n margin: 0em -1em;\n\n display: flex;\n align-items: stretch;\n flex-direction: column;\n transition: all 300ms linear;\n }\n\n .fields-wrapper.expanded {\n flex-grow: 2;\n }\n\n .body-wrapper {\n overflow: hidden;\n }\n\n .body {\n max-height: 200px;\n overflow-y: auto;\n }\n\n .fields {\n padding: 1em;\n overflow-y: auto;\n }\n\n .fields-wrapper.expanded .fields {\n flex-grow: 1;\n height: 0px;\n }\n\n .field {\n border-radius: var(--curvature);\n\n display: flex;\n flex-direction: column;\n margin-bottom: 0.3em;\n }\n\n .field .name {\n margin-right: 8px;\n font-weight: 400;\n color: #666;\n font-size: 0.9em;\n word-break: break-word;\n }\n .field .value {\n font-size: 0.8em;\n word-break: break-word;\n }\n\n temba-button {\n margin-top: 5px;\n display: block;\n --button-y: 0;\n }\n `;\n }\n\n // optional display name\n @property({ type: String })\n name: string;\n\n @property({ type: String })\n uuid: string;\n\n @property({ type: Object })\n contact: Contact;\n\n @property({ attribute: false })\n flow: any = null;\n\n // the fields with values for this contact\n @property({ type: Array })\n fields: string[] = [];\n\n @property({ type: String })\n endpoint: string;\n\n @property({ type: Boolean })\n expandFields = false;\n\n @property({ type: Boolean })\n expandBody = false;\n\n @property({ type: Boolean })\n showGroups = false;\n\n @property({ type: Boolean })\n showFlows = false;\n\n @property({ type: Object })\n ticket: Ticket = null;\n\n public updated(changes: Map<string, any>) {\n super.updated(changes);\n\n if (changes.has('contact')) {\n const store: Store = document.querySelector('temba-store');\n if (this.contact && this.contact.fields) {\n this.fields = Object.keys(this.contact.fields).filter((key: string) => {\n const hasField = !!this.contact.fields[key];\n return hasField && store.getContactField(key).featured;\n });\n\n this.contact.groups.forEach((group: Group) => {\n group.is_dynamic = store.isDynamicGroup(group.uuid);\n });\n\n this.contact.groups.sort((a: Group, b: Group) => {\n if (a.is_dynamic) {\n return -1;\n }\n if (b.is_dynamic) {\n return 1;\n }\n return a.name.localeCompare(b.name);\n });\n }\n }\n\n if (changes.has('endpoint')) {\n this.flow = null;\n this.expandFields = false;\n fetchContact(this.endpoint).then((contact: Contact) => {\n this.contact = contact;\n });\n }\n }\n\n private handleFlowChanged(evt: CustomEvent) {\n this.flow = evt.detail.selected as any;\n }\n\n private handleToggleFields(): void {\n this.expandFields = !this.expandFields;\n }\n\n private handleExpandBody(): void {\n this.expandBody = true;\n }\n\n private handleHideBody(): void {\n this.expandBody = false;\n }\n\n public render(): TemplateResult {\n const store: Store = document.querySelector('temba-store');\n\n let body = this.ticket ? this.ticket.body : null;\n const showBodyToggle = body ? body.length > BODY_SNIPPET_LENGTH : false;\n if (\n !this.expandBody &&\n this.ticket &&\n this.ticket.body.length > BODY_SNIPPET_LENGTH\n ) {\n body = truncate(this.ticket.body, BODY_SNIPPET_LENGTH);\n }\n\n if (this.contact) {\n return html`<div class=\"contact\">\n ${this.ticket\n ? html`<div class=\"name\">${this.name || this.contact.name}</div>`\n : null}\n ${this.showGroups && !this.ticket\n ? html`<div class=\"groups\">\n ${this.contact.groups.map((group: Group) => {\n return html`\n <div\n onclick=\"goto(event)\"\n href=\"/contact/filter/${group.uuid}/\"\n class=\"group-label\"\n style=\"cursor:pointer\"\n >\n ${group.is_dynamic\n ? html`<temba-icon\n name=\"${Icon.group_smart}\"\n ></temba-icon>`\n : null}${group.name}\n </div>\n `;\n })}\n </div>`\n : html``}\n\n <div class=\"wrapper\">\n ${body\n ? html`<div class=\"body-wrapper\">\n <div class=\"body\">${body}</div>\n <div class=\"field-links\">\n ${showBodyToggle\n ? !this.expandBody\n ? html`<a href=\"#\" @click=\"${this.handleExpandBody}\"\n >more</a\n >`\n : html`<a href=\"#\" @click=\"${this.handleHideBody}\"\n >less</a\n >`\n : null}\n </div>\n </div>`\n : null}\n ${this.fields.length > 0\n ? html` <div\n class=\"fields-wrapper ${this.expandFields ? 'expanded' : ''}\"\n >\n <div class=\"fields\">\n ${this.fields\n .slice(0, this.expandFields ? 255 : 3)\n .map((key: string) => {\n let value = this.contact.fields[key];\n if (value) {\n if (isDate(value)) {\n value = timeSince(new Date(value));\n }\n return html`<div class=\"field\">\n <div class=\"name\">\n ${store.getContactField(key).label}\n </div>\n <div class=\"value\">${value}</div>\n </div>`;\n }\n })}\n </div>\n </div>\n <div style=\"display:flex;\">\n <div style=\"flex-grow:1\"></div>\n <div style=\"margin-right:1em;margin-top:-0.5em\">\n ${this.fields.length > 3\n ? html`<temba-icon\n name=\"${this.expandFields\n ? Icon.arrow_up\n : Icon.arrow_down}\"\n @click=${this.handleToggleFields}\n animateChange=\"spin\"\n circled\n clickable\n ></temba-icon>`\n : null}\n </div>\n </div>`\n : null}\n <div style=\"flex-grow:1\"></div>\n </div>\n </div>`;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ContactDetails.js","sourceRoot":"","sources":["../../../src/contacts/ContactDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,OAAO,GAAG;IACd,GAAG,EAAE,OAAO;IACZ,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,0BAA0B;IAC/B,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,MAAM,OAAO,cAAe,SAAQ,mBAAmB;IACrD,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;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AAI;;;;kBAIE,IAAI,CAAC,IAAI,CAAC,UAAU;;;;;;kBAMpB,IAAI,CAAC,IAAI,CAAC,YAAY;;;;;KAKnC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { ContactStoreElement } from './ContactStoreElement';\nimport { Icon } from '../vectoricon';\nimport { capitalize } from '../utils';\n\nconst STATUS = {\n active: 'Active',\n blocked: 'Blocked',\n stopped: 'Stopped',\n archived: 'Archived',\n};\n\nconst SCHEMES = {\n tel: 'Phone',\n whatsapp: 'WhatsApp',\n fcm: 'Firebase Cloud Messaging',\n twitter: 'Twitter',\n};\n\nexport class ContactDetails extends ContactStoreElement {\n static get styles() {\n return css`\n .urn {\n display: flex;\n padding: 0.4em 1em 0.8em 1em;\n border-bottom: 1px solid #e6e6e6;\n margin-bottom: 0.5em;\n }\n\n .urn .path {\n margin-left: 0.2em;\n }\n\n .wrapper {\n padding-top: 0em;\n }\n\n .groups {\n padding: 0.4em 0.5em 0.6em 0.5em;\n border-bottom: 1px solid #e6e6e6;\n margin-bottom: 0.4em;\n }\n .group {\n margin-right: 0.7em;\n margin-bottom: 0.7em;\n }\n\n .label {\n font-size: 0.8em;\n color: rgb(136, 136, 136);\n margin-left: 0.5em;\n margin-bottom: 0.4em;\n }\n `;\n }\n\n // Not sure if we want to include name here or not, so hold onto this for the moment\n // ${this.data.name ? html`<temba-contact-field name=\"Name\" value=${this.data.name} disabled></temba-contact-field>`:null}\n\n public render(): TemplateResult {\n if (!this.data) {\n return;\n }\n\n const lang = this.store.getLanguageName(this.data.language);\n\n return html`\n <div class=\"wrapper\">\n ${this.data.groups.length > 0\n ? html` <div class=\"groups\">\n <div class=\"label\">Groups</div>\n ${this.data.groups.map(group => {\n return html`<temba-label\n class=\"group\"\n onclick=\"goto(event)\"\n href=\"/contact/filter/${group.uuid}/\"\n icon=${group.is_dynamic ? Icon.group_smart : Icon.group}\n clickable\n shadow\n >\n ${group.name}\n </temba-label>`;\n })}\n </div>`\n : null}\n ${this.data.urns.map(urn => {\n const parts = urn.split(':');\n let scheme = SCHEMES[parts[0]];\n if (!scheme) {\n scheme = capitalize(parts[0] as any);\n }\n return html`<temba-contact-field\n name=${scheme}\n value=${parts[1]}\n disabled\n ></temba-contact-field>`;\n })}\n\n <temba-contact-field\n name=\"Status\"\n value=${STATUS[this.data.status]}\n disabled\n ></temba-contact-field>\n ${lang\n ? html`<temba-contact-field\n name=\"Language\"\n value=${lang}\n disabled\n ></temba-contact-field>`\n : null}\n\n <temba-contact-field\n name=\"Created\"\n value=${this.data.created_on}\n type=\"datetime\"\n disabled\n ></temba-contact-field>\n <temba-contact-field\n name=\"Last Seen\"\n value=${this.data.last_seen_on}\n type=\"datetime\"\n disabled\n ></temba-contact-field>\n </div>\n `;\n }\n}\n"]}
@@ -212,6 +212,11 @@ export class ContactTickets extends StoreElement {
212
212
  });
213
213
  }
214
214
  handleTicketAssignment(uuid, email) {
215
+ // if its already assigned to use, it's a noop
216
+ const ticket = this.data.find(ticket => ticket.uuid === uuid);
217
+ if (ticket.assignee && ticket.assignee.email === email) {
218
+ return;
219
+ }
215
220
  postJSON(`/api/v2/ticket_actions.json`, {
216
221
  tickets: [uuid],
217
222
  action: 'assign',