@verdocs/web-sdk 5.0.14 → 5.0.15

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.
@@ -108,6 +108,9 @@ export class VerdocsTemplateRoles {
108
108
  const renumberRequests = [];
109
109
  Object.entries(sortableRoles).forEach(([targetSeq, roles]) => {
110
110
  roles.forEach((role, index) => {
111
+ if (!role) {
112
+ return;
113
+ }
111
114
  console.log('Evaluating role 1', index, role);
112
115
  console.log('Evaluating role 2', role.name, role.sequence, role.order);
113
116
  const targetOrder = +index + 1;
@@ -1 +1 @@
1
- {"version":3,"file":"verdocs-template-roles.js","sourceRoot":"","sources":["../../../../src/components/templates/verdocs-template-roles/verdocs-template-roles.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAC,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAoB,kBAAkB,EAAE,eAAe,EAAC,MAAM,iBAAiB,CAAC;AACvI,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,0BAA0B,CAAC;AAE/C,MAAM,YAAY,GAChB,myCAAmyC,CAAC;AAEtyC,MAAM,QAAQ,GAAG,mOAAmO,CAAC;AAErP,MAAM,UAAU,GACd,qWAAqW,CAAC;AAExW,MAAM,YAAY,GAAG,yVAAyV,CAAC;AAE/W,MAAM,MAAM,GAAG,sRAAsR,CAAC;AAEtS;;GAEG;AAMH,MAAM,OAAO,oBAAoB;;QACvB,uBAAkB,GAAG,IAAI,CAAC;wBAQE,eAAe,CAAC,UAAU,EAAE;0BAKnC,EAAE;iCAuBa,IAAI;sBAC9B,IAAI;wBAEF,KAAK;uBACN,IAAI;wBACe,IAAI;;IAE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AAO,EAAE,GAAG,EAAE;;wBACZ,MAAA,QAAQ,CAAC,cAAc,CAAC,4BAA4B,CAAC,0CAAE,MAAM,EAAE,CAAC;wBAChE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;oBAChC,CAAC,EACD,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;wBAC9B,+EAA+E;wBAC/E,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;wBACnC,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI,CAAC,EAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAAC,CAAC,CAAC;oBAClI,CAAC,GACD,CACiB,CACtB,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import Sortable from 'sortablejs';\nimport {Component, h, Element, Event, EventEmitter, Host, Prop, State} from '@stencil/core';\nimport {createTemplateRole, formatFullName, getTemplate, IRole, ITemplate, updateTemplateRole, VerdocsEndpoint} from '@verdocs/js-sdk';\nimport {SDKError} from '../../../utils/errors';\nimport {Store} from '../../../utils/Datastore';\n\nconst settingsIcon =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"20\" width=\"20\" fill=\"#00000089\"><path d=\"m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z\"/></svg>';\n\nconst plusIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" viewBox=\"0 0 24 24\" strokeWidth={1.5} stroke=\"currentColor\"><path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z\" /></svg>`;\n\nconst iconSigner =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" width=\"24\"><path d=\"m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z\"/></svg>';\n\nconst iconApprover = `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" width=\"24\"><path fill-rule=\"evenodd\" d=\"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z\" clip-rule=\"evenodd\" /></svg>`;\n\nconst iconCC = `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" width=\"24\"><path d=\"M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z\" /><path d=\"M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z\" /></svg>`;\n\n/**\n * Display an edit form that allows the user to adjust a template's roles and workflow.\n */\n@Component({\n tag: 'verdocs-template-roles',\n styleUrl: 'verdocs-template-roles.scss',\n shadow: false,\n})\nexport class VerdocsTemplateRoles {\n private templateListenerId = null;\n\n @Element()\n el: HTMLElement;\n\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = VerdocsEndpoint.getDefault();\n\n /**\n * The template ID to edit.\n */\n @Prop() templateId: string = '';\n\n /**\n * Event fired when the user clicks to proceed.\n */\n @Event({composed: true}) next: EventEmitter;\n\n /**\n * Event fired when the step is cancelled. This is called exit to avoid conflicts with the JS-reserved \"cancel\" event name.\n */\n @Event({composed: true}) exit: EventEmitter;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n /**\n * Event fired when the template is updated in any way. May be used for tasks such as cache invalidation or reporting to other systems.\n */\n @Event({composed: true}) rolesUpdated: EventEmitter<{endpoint: VerdocsEndpoint; templateId: string; event: 'added' | 'deleted' | 'updated'; roles: IRole[]}>;\n\n @State() showingRoleDialog: string | null = null;\n @State() sender = null;\n\n @State() dragging = false;\n @State() loading = true;\n @State() template: ITemplate | null = null;\n\n disconnectedCallback() {\n this.unlistenToTemplate();\n }\n\n async listenToTemplate() {\n console.log('[ROLES] Loading template', this.templateId);\n this.unlistenToTemplate();\n Store.subscribe(\n 'templates',\n this.templateId,\n () => getTemplate(this.endpoint, this.templateId),\n false,\n (template: ITemplate) => {\n console.log('[ROLES] Template Updated', template);\n this.template = template;\n this.loading = false;\n },\n );\n }\n\n unlistenToTemplate() {\n if (this.templateListenerId) {\n Store.store.delListener(this.templateListenerId);\n this.templateListenerId = null;\n }\n }\n\n async componentWillLoad() {\n try {\n this.endpoint.loadSession();\n\n if (!this.templateId) {\n console.log(`[ROLES] Missing required template ID ${this.templateId}`);\n return;\n }\n\n if (!this.endpoint.session) {\n console.log('[ROLES] Unable to start builder session, must be authenticated');\n return;\n }\n\n this.listenToTemplate();\n } catch (e) {\n console.log('[FIELDS] Error with preview session', e);\n this.sdkError?.emit(new SDKError(e.message, e.response?.status, e.response?.data));\n }\n }\n\n componentDidRender() {\n // Existing sequence numbers\n const sequenceNumbers = this.getSequenceNumbers();\n (sequenceNumbers || []).forEach(sequence => {\n const el = document.getElementById(`verdocs-roles-sequence-${sequence}`);\n if (el) {\n new Sortable(el, {\n group: 'roles',\n animation: 150,\n dragoverBubble: true,\n filter: '.no-drag',\n onEnd: this.handleMoveEnd.bind(this),\n onChoose: () => (this.dragging = true),\n onUnchoose: () => (this.dragging = false),\n });\n }\n });\n\n const el = document.getElementById(`verdocs-roles-sequence-${sequenceNumbers.length + 1}`);\n if (el) {\n new Sortable(el, {\n group: 'roles',\n animation: 150,\n dragoverBubble: true,\n filter: '.no-drag',\n onEnd: this.handleMoveEnd.bind(this),\n onChoose: () => (this.dragging = true),\n onUnchoose: () => (this.dragging = false),\n });\n }\n }\n\n handleMoveEnd(evt) {\n const fromSeq = +evt.from.id.split('-').pop();\n const toSeq = +evt.to.id.split('-').pop();\n const fromIndex = +evt.oldIndex + 1;\n const toIndex = +evt.newIndex + 1;\n\n // console.log(`Move from ${fromSeq}:${fromIndex} to ${toSeq}:${toIndex}`, evt.item);\n\n const sortableRoles: Record<number, IRole[]> = {};\n const sequenceNumbers = this.getSequenceNumbers();\n sequenceNumbers.forEach(sequence => {\n sortableRoles[sequence] = JSON.parse(JSON.stringify(this.getRolesAtSequence(sequence)));\n });\n\n // We might be adding a new sequence number now. Make sure we have an array to drop\n // the record into.\n sortableRoles[sequenceNumbers.length + 1] = [];\n\n const role = sortableRoles[fromSeq].splice(fromIndex - 1, 1)[0];\n sortableRoles[toSeq].splice(toIndex - 1, 0, role);\n\n const renumberRequests = [];\n Object.entries(sortableRoles).forEach(([targetSeq, roles]) => {\n roles.forEach((role, index) => {\n console.log('Evaluating role 1', index, role);\n console.log('Evaluating role 2', role.name, role.sequence, role.order);\n const targetOrder = +index + 1;\n if (role.sequence !== +targetSeq || role.order !== targetOrder) {\n role.sequence = +targetSeq;\n role.order = targetOrder;\n renumberRequests.push(\n updateTemplateRole(this.endpoint, this.templateId, role.name, {sequence: +targetSeq, order: targetOrder})\n .then(r => console.log('[ROLES] Updated role', role.name, r))\n .catch(e => console.log('[ROLES] Error updating role', e)),\n );\n }\n });\n });\n\n // When renumbering, we don't try to update the store for every individual item\n // changing. We just do it once at the end.\n console.log(`[ROLES] Awaiting ${renumberRequests.length} renumber requests`, renumberRequests);\n return Promise.all(renumberRequests).then(async () => {\n const newTemplate = JSON.parse(JSON.stringify(this.template));\n newTemplate.roles = Object.keys(sortableRoles).reduce((acc, seq) => acc.concat(sortableRoles[seq]), []);\n await Store.getTemplate(this.endpoint, this.templateId, true);\n // Store.updateTemplate(this.templateId, newTemplate);\n });\n }\n\n handleCancel() {\n this.exit?.emit();\n }\n\n handleSubmit() {\n this.next?.emit();\n }\n\n getSortedRoles() {\n // NOTE: This mutates the source array but that's OK because everything that touches\n // it will want the same thing done.\n return (this.template?.roles || []).sort((a, b) => {\n return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;\n });\n }\n\n getSequenceNumbers() {\n const sequenceNumbers = (this.template?.roles || []).map(role => role.sequence);\n const deduped = [...new Set(sequenceNumbers)];\n deduped.sort((a, b) => a - b);\n return deduped;\n }\n\n getRoleNames() {\n const roles = this.getSortedRoles();\n return roles.map(role => role.name);\n }\n\n getRolesAtSequence(sequence: number) {\n // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.\n // See https://github.com/ionic-team/stencil-store/issues/23\n return (this.template?.roles || []).filter(role => role && role.sequence === sequence);\n }\n\n // When the user drags a role around, we handle placement \"between\" items by assigning it a half-order number\n // e.g. 1.5 to place it between items 1 and 2, 0.5 to place it at the beginning, or last+0.5 to place it at the end.\n // Then we re-sort the list of roles and renumber them.\n async renumberTemplateRoles() {\n const sortableRoles: Record<string, IRole[]> = {};\n const renumberRequests = [];\n const sequenceNumbers = this.getSequenceNumbers();\n\n console.log('Sorting sequences', sequenceNumbers);\n\n (sequenceNumbers || []).forEach(targetSeq => {\n (sortableRoles[targetSeq] || []).forEach((role, targetOrderMinusOne) => {\n const targetOrder = +targetOrderMinusOne + 1;\n if (role.sequence !== +targetSeq || role.order !== targetOrder) {\n console.log('[ROLES] Updating role', role.name, 'from', role.sequence, role.order, 'to', targetSeq, targetOrder);\n role.sequence = +targetSeq;\n role.order = targetOrder;\n renumberRequests.push(\n updateTemplateRole(this.endpoint, this.templateId, role.name, {sequence: +targetSeq, order: targetOrder})\n .then(r => console.log('[ROLES] Updated role', role.name, r))\n .catch(e => console.log('[ROLES] Error updating role', e)),\n );\n }\n });\n });\n\n console.log('Sortable Roles', sortableRoles);\n\n console.log(`[ROLES] Awaiting ${renumberRequests.length} renumber requests`);\n await Promise.all(renumberRequests).then(async () => {\n // When renumbering, we don't try to update the store for every individual item\n // changing. We just do it once at the end.\n const newTemplate = JSON.parse(JSON.stringify(this.template));\n newTemplate.roles = Object.keys(sortableRoles).reduce((acc, seq) => acc.concat(sortableRoles[seq]), []);\n console.log(\n '[ROLES] Done renumbering',\n newTemplate.roles.map(r => ({name: r.name, sequence: r.sequence, order: r.order})),\n );\n Store.updateTemplate(this.templateId, newTemplate);\n // TODO: Explore race condition in reordering roles\n // this.template = await Store.getTemplate(this.endpoint, this.templateId, true);\n });\n\n this.rolesUpdated?.emit({event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles()});\n }\n\n // Look for name conflicts, because they're UGC and can be anything, regardless of order.\n getNextRoleName() {\n let name = '';\n let nextNumber = (this.template?.roles || []).length;\n do {\n nextNumber++;\n name = `Recipient ${nextNumber}`;\n } while (!name || (this.template?.roles || []).some(role => role && role.name === name));\n\n return name;\n }\n\n callCreateRole(name: string, sequence: number, order: number) {\n console.log('[ROLES] Will create role', {name, sequence, order});\n createTemplateRole(this.endpoint, this.templateId, {\n template_id: this.templateId,\n name,\n sequence,\n message: '',\n order,\n full_name: null,\n first_name: '',\n last_name: '',\n email: '',\n phone: '',\n type: 'signer',\n delegator: false,\n kba_method: null,\n })\n .then(async role => {\n console.log('[ROLES] Created role', role);\n // const newTemplate = JSON.parse(JSON.stringify(this.template));\n // newTemplate.roles.push(role);\n // TODO: Verify this immediately triggers a self-update\n console.log('Updating template in data store');\n await Store.getTemplate(this.endpoint, this.templateId, true);\n // Store.updateTemplate(this.templateId, newTemplate);\n // This will re-sort the roles and renumbers them via server calls if necessary\n // await this.renumberTemplateRoles();\n this.rolesUpdated?.emit({event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles()});\n })\n .catch(e => {\n console.log('[ROLES] Error creating role', e);\n });\n }\n\n handleAddRole(e: any, sequence: number) {\n e.stopPropagation();\n const order = this.getRolesAtSequence(sequence).length + 1;\n const name = this.getNextRoleName();\n this.callCreateRole(name, sequence, order);\n }\n\n handleAddStep(e: any, sequence: number) {\n e.stopPropagation();\n\n const order = 1;\n const name = this.getNextRoleName();\n this.callCreateRole(name, sequence, order);\n }\n\n render() {\n if (!this.endpoint.session) {\n return (\n <Host>\n <verdocs-component-error message=\"You must be authenticated to use this module.\" />\n </Host>\n );\n }\n\n if (this.loading || !this.template) {\n return (\n <Host class=\"loading\">\n <verdocs-loader />\n </Host>\n );\n }\n\n console.log(\n '[ROLES] Rendering',\n this.template.roles.map(r => ({name: r.name, sequence: r.sequence, order: r.order})),\n );\n\n const roleNames = this.getRoleNames();\n const sequences = this.getSequenceNumbers();\n\n console.log('Rendering sequences', sequences, roleNames);\n\n // style={{backgroundColor: getRGBA(getRoleIndex(this.template, role.name))}}\n return (\n <Host class={{dragging: this.dragging}}>\n <form onSubmit={e => e.preventDefault()} onClick={e => e.stopPropagation()} autocomplete=\"off\">\n <h5>Roles and Workflow</h5>\n\n <div class=\"roles\">\n {sequences.map(sequence => (\n <div class=\"sequence\">\n <div class=\"sequence-label no-drag\">{sequence}.</div>\n\n <div class=\"sequence-roles\" id={`verdocs-roles-sequence-${sequence}`} data-sequence={sequence}>\n {this.getRolesAtSequence(sequence).map(role => {\n const unknown = !role.email || !role.first_name || !role.last_name;\n return unknown ? (\n <div class=\"role\" data-rolename={role.name} data-sequence={sequence} data-order={role.order}>\n <div class=\"role-name\">{role.name}</div>\n <div class=\"icons\">\n <div class=\"gear-button\" innerHTML={settingsIcon} onClick={() => (this.showingRoleDialog = role.name)} aria-role=\"button\" />\n <span class=\"type-icon\" innerHTML={role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover} />\n </div>\n </div>\n ) : (\n <div\n class=\"role\"\n // style={{borderColor: getRGBA(getRoleIndex(this.template, role.name))}}\n data-rolename={role.name}\n data-sequence={sequence}\n data-order={role.order}\n >\n <div class=\"role-name\">{formatFullName(role)}</div>\n <div class=\"icons\">\n <div class=\"gear-button\" innerHTML={settingsIcon} onClick={() => (this.showingRoleDialog = role.name)} aria-role=\"button\" />\n <span class=\"type-icon\" innerHTML={role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover} />\n </div>\n </div>\n );\n })}\n </div>\n\n <button class=\"add-role no-drag\" innerHTML={plusIcon} onClick={e => this.handleAddRole(e, sequence)} />\n </div>\n ))}\n\n <div class=\"sequence add-sequence\">\n <div class=\"sequence-label no-drag\">{sequences.length + 1}.</div>\n\n <div class=\"sequence-roles\" id={`verdocs-roles-sequence-${sequences.length + 1}`} data-sequence={sequences.length + 1}>\n {/*<div class=\"role-name add-step-label\">Add Step.</div>*/}\n </div>\n\n <button class=\"add-role no-drag\" innerHTML={plusIcon} onClick={e => this.handleAddRole(e, sequences.length + 1)} />\n </div>\n </div>\n\n {roleNames.length < 1 && (\n <div class=\"empty\">\n You must add at least one Role before proceeding.\n <br /> Click the <span innerHTML={plusIcon} /> Add button above to get started.\n </div>\n )}\n\n <div class=\"buttons\">\n <div class=\"flex-fill\" />\n\n <verdocs-button variant=\"outline\" label=\"Cancel\" size=\"small\" onClick={() => this.handleCancel()} />\n <verdocs-button label=\"OK\" size=\"small\" onClick={() => this.handleSubmit()} disabled={roleNames.length < 1} />\n </div>\n </form>\n\n {this.showingRoleDialog && (\n <verdocs-menu-panel onClose={() => (this.showingRoleDialog = null)}>\n <verdocs-template-role-properties\n endpoint={this.endpoint}\n templateId={this.templateId}\n roleName={this.showingRoleDialog}\n onClose={() => {\n document.getElementById('verdocs-menu-panel-overlay')?.remove();\n this.showingRoleDialog = null;\n }}\n onDelete={async () => {\n this.showingRoleDialog = null;\n // This will re-sort the roles and renumbers them via server calls if necessary\n await this.renumberTemplateRoles();\n this.rolesUpdated?.emit({event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles()});\n }}\n />\n </verdocs-menu-panel>\n )}\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"verdocs-template-roles.js","sourceRoot":"","sources":["../../../../src/components/templates/verdocs-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SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAAC,CAAC,CAAC;oBAClI,CAAC,GACD,CACiB,CACtB,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import Sortable from 'sortablejs';\nimport {Component, h, Element, Event, EventEmitter, Host, Prop, State} from '@stencil/core';\nimport {createTemplateRole, formatFullName, getTemplate, IRole, ITemplate, updateTemplateRole, VerdocsEndpoint} from '@verdocs/js-sdk';\nimport {SDKError} from '../../../utils/errors';\nimport {Store} from '../../../utils/Datastore';\n\nconst settingsIcon =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"20\" width=\"20\" fill=\"#00000089\"><path d=\"m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z\"/></svg>';\n\nconst plusIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" viewBox=\"0 0 24 24\" strokeWidth={1.5} stroke=\"currentColor\"><path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z\" /></svg>`;\n\nconst iconSigner =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" width=\"24\"><path d=\"m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z\"/></svg>';\n\nconst iconApprover = `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" width=\"24\"><path fill-rule=\"evenodd\" d=\"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z\" clip-rule=\"evenodd\" /></svg>`;\n\nconst iconCC = `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" width=\"24\"><path d=\"M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z\" /><path d=\"M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z\" /></svg>`;\n\n/**\n * Display an edit form that allows the user to adjust a template's roles and workflow.\n */\n@Component({\n tag: 'verdocs-template-roles',\n styleUrl: 'verdocs-template-roles.scss',\n shadow: false,\n})\nexport class VerdocsTemplateRoles {\n private templateListenerId = null;\n\n @Element()\n el: HTMLElement;\n\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = VerdocsEndpoint.getDefault();\n\n /**\n * The template ID to edit.\n */\n @Prop() templateId: string = '';\n\n /**\n * Event fired when the user clicks to proceed.\n */\n @Event({composed: true}) next: EventEmitter;\n\n /**\n * Event fired when the step is cancelled. This is called exit to avoid conflicts with the JS-reserved \"cancel\" event name.\n */\n @Event({composed: true}) exit: EventEmitter;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n /**\n * Event fired when the template is updated in any way. May be used for tasks such as cache invalidation or reporting to other systems.\n */\n @Event({composed: true}) rolesUpdated: EventEmitter<{endpoint: VerdocsEndpoint; templateId: string; event: 'added' | 'deleted' | 'updated'; roles: IRole[]}>;\n\n @State() showingRoleDialog: string | null = null;\n @State() sender = null;\n\n @State() dragging = false;\n @State() loading = true;\n @State() template: ITemplate | null = null;\n\n disconnectedCallback() {\n this.unlistenToTemplate();\n }\n\n async listenToTemplate() {\n console.log('[ROLES] Loading template', this.templateId);\n this.unlistenToTemplate();\n Store.subscribe(\n 'templates',\n this.templateId,\n () => getTemplate(this.endpoint, this.templateId),\n false,\n (template: ITemplate) => {\n console.log('[ROLES] Template Updated', template);\n this.template = template;\n this.loading = false;\n },\n );\n }\n\n unlistenToTemplate() {\n if (this.templateListenerId) {\n Store.store.delListener(this.templateListenerId);\n this.templateListenerId = null;\n }\n }\n\n async componentWillLoad() {\n try {\n this.endpoint.loadSession();\n\n if (!this.templateId) {\n console.log(`[ROLES] Missing required template ID ${this.templateId}`);\n return;\n }\n\n if (!this.endpoint.session) {\n console.log('[ROLES] Unable to start builder session, must be authenticated');\n return;\n }\n\n this.listenToTemplate();\n } catch (e) {\n console.log('[FIELDS] Error with preview session', e);\n this.sdkError?.emit(new SDKError(e.message, e.response?.status, e.response?.data));\n }\n }\n\n componentDidRender() {\n // Existing sequence numbers\n const sequenceNumbers = this.getSequenceNumbers();\n (sequenceNumbers || []).forEach(sequence => {\n const el = document.getElementById(`verdocs-roles-sequence-${sequence}`);\n if (el) {\n new Sortable(el, {\n group: 'roles',\n animation: 150,\n dragoverBubble: true,\n filter: '.no-drag',\n onEnd: this.handleMoveEnd.bind(this),\n onChoose: () => (this.dragging = true),\n onUnchoose: () => (this.dragging = false),\n });\n }\n });\n\n const el = document.getElementById(`verdocs-roles-sequence-${sequenceNumbers.length + 1}`);\n if (el) {\n new Sortable(el, {\n group: 'roles',\n animation: 150,\n dragoverBubble: true,\n filter: '.no-drag',\n onEnd: this.handleMoveEnd.bind(this),\n onChoose: () => (this.dragging = true),\n onUnchoose: () => (this.dragging = false),\n });\n }\n }\n\n handleMoveEnd(evt) {\n const fromSeq = +evt.from.id.split('-').pop();\n const toSeq = +evt.to.id.split('-').pop();\n const fromIndex = +evt.oldIndex + 1;\n const toIndex = +evt.newIndex + 1;\n\n // console.log(`Move from ${fromSeq}:${fromIndex} to ${toSeq}:${toIndex}`, evt.item);\n\n const sortableRoles: Record<number, IRole[]> = {};\n const sequenceNumbers = this.getSequenceNumbers();\n sequenceNumbers.forEach(sequence => {\n sortableRoles[sequence] = JSON.parse(JSON.stringify(this.getRolesAtSequence(sequence)));\n });\n\n // We might be adding a new sequence number now. Make sure we have an array to drop\n // the record into.\n sortableRoles[sequenceNumbers.length + 1] = [];\n\n const role = sortableRoles[fromSeq].splice(fromIndex - 1, 1)[0];\n sortableRoles[toSeq].splice(toIndex - 1, 0, role);\n\n const renumberRequests = [];\n Object.entries(sortableRoles).forEach(([targetSeq, roles]) => {\n roles.forEach((role, index) => {\n if (!role) {\n return;\n }\n\n console.log('Evaluating role 1', index, role);\n console.log('Evaluating role 2', role.name, role.sequence, role.order);\n const targetOrder = +index + 1;\n if (role.sequence !== +targetSeq || role.order !== targetOrder) {\n role.sequence = +targetSeq;\n role.order = targetOrder;\n renumberRequests.push(\n updateTemplateRole(this.endpoint, this.templateId, role.name, {sequence: +targetSeq, order: targetOrder})\n .then(r => console.log('[ROLES] Updated role', role.name, r))\n .catch(e => console.log('[ROLES] Error updating role', e)),\n );\n }\n });\n });\n\n // When renumbering, we don't try to update the store for every individual item\n // changing. We just do it once at the end.\n console.log(`[ROLES] Awaiting ${renumberRequests.length} renumber requests`, renumberRequests);\n return Promise.all(renumberRequests).then(async () => {\n const newTemplate = JSON.parse(JSON.stringify(this.template));\n newTemplate.roles = Object.keys(sortableRoles).reduce((acc, seq) => acc.concat(sortableRoles[seq]), []);\n await Store.getTemplate(this.endpoint, this.templateId, true);\n // Store.updateTemplate(this.templateId, newTemplate);\n });\n }\n\n handleCancel() {\n this.exit?.emit();\n }\n\n handleSubmit() {\n this.next?.emit();\n }\n\n getSortedRoles() {\n // NOTE: This mutates the source array but that's OK because everything that touches\n // it will want the same thing done.\n return (this.template?.roles || []).sort((a, b) => {\n return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;\n });\n }\n\n getSequenceNumbers() {\n const sequenceNumbers = (this.template?.roles || []).map(role => role.sequence);\n const deduped = [...new Set(sequenceNumbers)];\n deduped.sort((a, b) => a - b);\n return deduped;\n }\n\n getRoleNames() {\n const roles = this.getSortedRoles();\n return roles.map(role => role.name);\n }\n\n getRolesAtSequence(sequence: number) {\n // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.\n // See https://github.com/ionic-team/stencil-store/issues/23\n return (this.template?.roles || []).filter(role => role && role.sequence === sequence);\n }\n\n // When the user drags a role around, we handle placement \"between\" items by assigning it a half-order number\n // e.g. 1.5 to place it between items 1 and 2, 0.5 to place it at the beginning, or last+0.5 to place it at the end.\n // Then we re-sort the list of roles and renumber them.\n async renumberTemplateRoles() {\n const sortableRoles: Record<string, IRole[]> = {};\n const renumberRequests = [];\n const sequenceNumbers = this.getSequenceNumbers();\n\n console.log('Sorting sequences', sequenceNumbers);\n\n (sequenceNumbers || []).forEach(targetSeq => {\n (sortableRoles[targetSeq] || []).forEach((role, targetOrderMinusOne) => {\n const targetOrder = +targetOrderMinusOne + 1;\n if (role.sequence !== +targetSeq || role.order !== targetOrder) {\n console.log('[ROLES] Updating role', role.name, 'from', role.sequence, role.order, 'to', targetSeq, targetOrder);\n role.sequence = +targetSeq;\n role.order = targetOrder;\n renumberRequests.push(\n updateTemplateRole(this.endpoint, this.templateId, role.name, {sequence: +targetSeq, order: targetOrder})\n .then(r => console.log('[ROLES] Updated role', role.name, r))\n .catch(e => console.log('[ROLES] Error updating role', e)),\n );\n }\n });\n });\n\n console.log('Sortable Roles', sortableRoles);\n\n console.log(`[ROLES] Awaiting ${renumberRequests.length} renumber requests`);\n await Promise.all(renumberRequests).then(async () => {\n // When renumbering, we don't try to update the store for every individual item\n // changing. We just do it once at the end.\n const newTemplate = JSON.parse(JSON.stringify(this.template));\n newTemplate.roles = Object.keys(sortableRoles).reduce((acc, seq) => acc.concat(sortableRoles[seq]), []);\n console.log(\n '[ROLES] Done renumbering',\n newTemplate.roles.map(r => ({name: r.name, sequence: r.sequence, order: r.order})),\n );\n Store.updateTemplate(this.templateId, newTemplate);\n // TODO: Explore race condition in reordering roles\n // this.template = await Store.getTemplate(this.endpoint, this.templateId, true);\n });\n\n this.rolesUpdated?.emit({event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles()});\n }\n\n // Look for name conflicts, because they're UGC and can be anything, regardless of order.\n getNextRoleName() {\n let name = '';\n let nextNumber = (this.template?.roles || []).length;\n do {\n nextNumber++;\n name = `Recipient ${nextNumber}`;\n } while (!name || (this.template?.roles || []).some(role => role && role.name === name));\n\n return name;\n }\n\n callCreateRole(name: string, sequence: number, order: number) {\n console.log('[ROLES] Will create role', {name, sequence, order});\n createTemplateRole(this.endpoint, this.templateId, {\n template_id: this.templateId,\n name,\n sequence,\n message: '',\n order,\n full_name: null,\n first_name: '',\n last_name: '',\n email: '',\n phone: '',\n type: 'signer',\n delegator: false,\n kba_method: null,\n })\n .then(async role => {\n console.log('[ROLES] Created role', role);\n // const newTemplate = JSON.parse(JSON.stringify(this.template));\n // newTemplate.roles.push(role);\n // TODO: Verify this immediately triggers a self-update\n console.log('Updating template in data store');\n await Store.getTemplate(this.endpoint, this.templateId, true);\n // Store.updateTemplate(this.templateId, newTemplate);\n // This will re-sort the roles and renumbers them via server calls if necessary\n // await this.renumberTemplateRoles();\n this.rolesUpdated?.emit({event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles()});\n })\n .catch(e => {\n console.log('[ROLES] Error creating role', e);\n });\n }\n\n handleAddRole(e: any, sequence: number) {\n e.stopPropagation();\n const order = this.getRolesAtSequence(sequence).length + 1;\n const name = this.getNextRoleName();\n this.callCreateRole(name, sequence, order);\n }\n\n handleAddStep(e: any, sequence: number) {\n e.stopPropagation();\n\n const order = 1;\n const name = this.getNextRoleName();\n this.callCreateRole(name, sequence, order);\n }\n\n render() {\n if (!this.endpoint.session) {\n return (\n <Host>\n <verdocs-component-error message=\"You must be authenticated to use this module.\" />\n </Host>\n );\n }\n\n if (this.loading || !this.template) {\n return (\n <Host class=\"loading\">\n <verdocs-loader />\n </Host>\n );\n }\n\n console.log(\n '[ROLES] Rendering',\n this.template.roles.map(r => ({name: r.name, sequence: r.sequence, order: r.order})),\n );\n\n const roleNames = this.getRoleNames();\n const sequences = this.getSequenceNumbers();\n\n console.log('Rendering sequences', sequences, roleNames);\n\n // style={{backgroundColor: getRGBA(getRoleIndex(this.template, role.name))}}\n return (\n <Host class={{dragging: this.dragging}}>\n <form onSubmit={e => e.preventDefault()} onClick={e => e.stopPropagation()} autocomplete=\"off\">\n <h5>Roles and Workflow</h5>\n\n <div class=\"roles\">\n {sequences.map(sequence => (\n <div class=\"sequence\">\n <div class=\"sequence-label no-drag\">{sequence}.</div>\n\n <div class=\"sequence-roles\" id={`verdocs-roles-sequence-${sequence}`} data-sequence={sequence}>\n {this.getRolesAtSequence(sequence).map(role => {\n const unknown = !role.email || !role.first_name || !role.last_name;\n return unknown ? (\n <div class=\"role\" data-rolename={role.name} data-sequence={sequence} data-order={role.order}>\n <div class=\"role-name\">{role.name}</div>\n <div class=\"icons\">\n <div class=\"gear-button\" innerHTML={settingsIcon} onClick={() => (this.showingRoleDialog = role.name)} aria-role=\"button\" />\n <span class=\"type-icon\" innerHTML={role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover} />\n </div>\n </div>\n ) : (\n <div\n class=\"role\"\n // style={{borderColor: getRGBA(getRoleIndex(this.template, role.name))}}\n data-rolename={role.name}\n data-sequence={sequence}\n data-order={role.order}\n >\n <div class=\"role-name\">{formatFullName(role)}</div>\n <div class=\"icons\">\n <div class=\"gear-button\" innerHTML={settingsIcon} onClick={() => (this.showingRoleDialog = role.name)} aria-role=\"button\" />\n <span class=\"type-icon\" innerHTML={role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover} />\n </div>\n </div>\n );\n })}\n </div>\n\n <button class=\"add-role no-drag\" innerHTML={plusIcon} onClick={e => this.handleAddRole(e, sequence)} />\n </div>\n ))}\n\n <div class=\"sequence add-sequence\">\n <div class=\"sequence-label no-drag\">{sequences.length + 1}.</div>\n\n <div class=\"sequence-roles\" id={`verdocs-roles-sequence-${sequences.length + 1}`} data-sequence={sequences.length + 1}>\n {/*<div class=\"role-name add-step-label\">Add Step.</div>*/}\n </div>\n\n <button class=\"add-role no-drag\" innerHTML={plusIcon} onClick={e => this.handleAddRole(e, sequences.length + 1)} />\n </div>\n </div>\n\n {roleNames.length < 1 && (\n <div class=\"empty\">\n You must add at least one Role before proceeding.\n <br /> Click the <span innerHTML={plusIcon} /> Add button above to get started.\n </div>\n )}\n\n <div class=\"buttons\">\n <div class=\"flex-fill\" />\n\n <verdocs-button variant=\"outline\" label=\"Cancel\" size=\"small\" onClick={() => this.handleCancel()} />\n <verdocs-button label=\"OK\" size=\"small\" onClick={() => this.handleSubmit()} disabled={roleNames.length < 1} />\n </div>\n </form>\n\n {this.showingRoleDialog && (\n <verdocs-menu-panel onClose={() => (this.showingRoleDialog = null)}>\n <verdocs-template-role-properties\n endpoint={this.endpoint}\n templateId={this.templateId}\n roleName={this.showingRoleDialog}\n onClose={() => {\n document.getElementById('verdocs-menu-panel-overlay')?.remove();\n this.showingRoleDialog = null;\n }}\n onDelete={async () => {\n this.showingRoleDialog = null;\n // This will re-sort the roles and renumbers them via server calls if necessary\n await this.renumberTemplateRoles();\n this.rolesUpdated?.emit({event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles()});\n }}\n />\n </verdocs-menu-panel>\n )}\n </Host>\n );\n }\n}\n"]}
@@ -2787,6 +2787,9 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class VerdocsTempl
2787
2787
  const renumberRequests = [];
2788
2788
  Object.entries(sortableRoles).forEach(([targetSeq, roles]) => {
2789
2789
  roles.forEach((role, index) => {
2790
+ if (!role) {
2791
+ return;
2792
+ }
2790
2793
  console.log('Evaluating role 1', index, role);
2791
2794
  console.log('Evaluating role 2', role.name, role.sequence, role.order);
2792
2795
  const targetOrder = +index + 1;
@@ -3029,4 +3032,4 @@ function defineCustomElement() {
3029
3032
 
3030
3033
  export { VerdocsTemplateRoles as V, defineCustomElement as d };
3031
3034
 
3032
- //# sourceMappingURL=p-570895a8.js.map
3035
+ //# sourceMappingURL=p-365da85d.js.map