@verdocs/web-sdk 5.0.5 → 5.0.7

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.
@@ -194,7 +194,8 @@ const VerdocsTemplateRoleProperties = class {
194
194
  var _a, _b;
195
195
  const newTemplate = JSON.parse(JSON.stringify(this.template));
196
196
  newTemplate.roles = newTemplate.roles.filter(role => role.name !== this.roleName);
197
- Datastore.Store.updateTemplate(this.templateId, newTemplate);
197
+ Datastore.Store.getTemplate(this.endpoint, this.templateId, true);
198
+ // Store.updateTemplate(this.templateId, newTemplate);
198
199
  (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
199
200
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
200
201
  })
@@ -208,31 +209,31 @@ const VerdocsTemplateRoleProperties = class {
208
209
  const hasFields = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || []).some(field => field.role_name === this.roleName);
209
210
  // Either all three should be empty, or all three need to be filled
210
211
  const isValid = (!this.email && !this.first_name && !this.last_name) || (jsSdk.isValidEmail(this.email) && !!this.first_name && !!this.last_name);
211
- return (index.h(index.Host, { key: '33fd4fdb9aab4d7e8db63b8f98803d618f396c7e' }, index.h("form", { key: 'f0ea5498aecaee8f00c68a60a0c941e1895cf89d', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("div", { key: '0900acf8a16a37b0fb1b6786c41c79f9ba3baee2' }, index.h("verdocs-text-input", { key: '7c6f93dfbacd951ea086e1f3f67a2ac731649218', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
212
+ return (index.h(index.Host, { key: 'a1895798db1e9b9f63c42e79556bdb76029217c2' }, index.h("form", { key: '8be859da1a954e4d086d630e0d5aeaa991f88640', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("div", { key: 'a37025fa1b286d43493bd142f77f8310b02ee701' }, index.h("verdocs-text-input", { key: 'eea1b7844b0a60c30a6ee50a123399b7fe6fac4a', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
212
213
  this.name = e.target.value;
213
214
  this.dirty = true;
214
- } }), hasFields && index.h("div", { key: '439e8d7ba00f6f60bfb4c92d3ad7811cbbce6c35', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), index.h("div", { key: '622509e07d3329f97b2afe1b812c1920b95d9677' }, index.h("div", { key: 'da96defab9d0d608bb02292e99a5390613a4face', class: "input-label" }, "Type:"), index.h("verdocs-select-input", { key: '01368605afcbb3d0ea905f3698f7c4bc1946a0ee', value: this.type, options: [
215
+ } }), hasFields && index.h("div", { key: '5945d4e7a64f9b4a513bbd975fb821f662e452a4', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), index.h("div", { key: '14cfb01f29a5889f1fcb2c90366ba4f215341a2c' }, index.h("div", { key: '9095e3b2f1f378c9d3937898ca68d6742d89be54', class: "input-label" }, "Type:"), index.h("verdocs-select-input", { key: 'b07e4afc086e7d1563f58bb3c43aa0d909d8a65e', value: this.type, options: [
215
216
  { label: 'Signer', value: 'signer' },
216
217
  { label: 'CC', value: 'cc' },
217
218
  { label: 'Approver', value: 'approver' },
218
219
  ], onInput: (e) => {
219
220
  this.type = e.target.value;
220
221
  this.dirty = true;
221
- } })), index.h("div", { key: '8a6c71ab8a7566e9d2cfd942c72ec44c7966e6a8' }, index.h("div", { key: '41ce817a89e963dd8aa4ce49cc27871994b69e2a', class: "input-label" }, "Default Contact Info:"), index.h("div", { key: 'e4b958063bc92d3df34bcb9314ff9c931c6a4993', class: "first-last" }, index.h("verdocs-text-input", { key: 'cde6107c9d66e786dc17f6ce825a9dc1bf6e101e', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
222
+ } })), index.h("div", { key: '5e1ed5226be0707cc5430c1e7bd38ad6e4df5dd5' }, index.h("div", { key: 'fc4a467cb0da25a80c421134c8226480369d2a83', class: "input-label" }, "Default Contact Info:"), index.h("div", { key: 'f6cb36cde86b8067c374e4bf0cffa6549851888d', class: "first-last" }, index.h("verdocs-text-input", { key: 'a52d5426c87419f45482ef6004ef11597400ea87', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
222
223
  this.first_name = e.target.value;
223
224
  this.dirty = true;
224
- } }), index.h("verdocs-text-input", { key: '219e51d998390ea3a297b40867cd3e908374938a', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
225
+ } }), index.h("verdocs-text-input", { key: 'b9035b299231319dce05f19c15c4d427ad6cd2f3', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
225
226
  this.last_name = e.target.value;
226
227
  this.dirty = true;
227
- } }))), index.h("div", { key: '95f56626e28d1ab8e82af7954012b34e36ecdc19' }, index.h("verdocs-text-input", { key: '1e676e75b29e8dc63711c9a4c3de95cd2d88b6cc', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
228
+ } }))), index.h("div", { key: 'd42c1ce5ae61db11a0ac32b3fa7bc3816e3068c6' }, index.h("verdocs-text-input", { key: '63436a7be6b3f35c2341dc88d137bd2f6b061978', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
228
229
  this.email = e.target.value;
229
230
  this.dirty = true;
230
- } }), index.h("div", { key: 'f298189867060ffbfb977da4b0f6cd4c69dce71f', style: { height: '15px' } }), index.h("div", { key: '71a8079b3751957cd135a2c736a3b59624f77bd4' }, index.h("verdocs-text-input", { key: '2ff08fdee843a2c4c72769b8bbe50f48608b6a08', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
231
+ } }), index.h("div", { key: '5a7ed36cfa657fb9ee11cf62998abbab2cc641e9', style: { height: '15px' } }), index.h("div", { key: 'c974f4e78235706788dfa54f69f6f5ec7d37d00e' }, index.h("verdocs-text-input", { key: '2be4c29396c6e6bc4f687819646ea219fce97e82', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
231
232
  // helpText="The recipient's phone number, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template."
232
233
  placeholder: "Phone Number...", onInput: (e) => {
233
234
  this.phone = e.target.value;
234
235
  this.dirty = true;
235
- } }))), index.h("div", { key: '30b10e1c20ace197aa67dedcabef9adf2206bbf1', class: "buttons" }, index.h("button", { key: '52ccaafe4e4f51d2b994813538d33443c79da0ed', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), index.h("div", { key: '49dcb63a78d83f03e8b434adeca3cf60082de647', style: { flex: '1' } }), index.h("verdocs-button", { key: '70b8347ddba86faf658cae033de62b9dab14aeab', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
236
+ } }))), index.h("div", { key: 'a0eba03681cab8b491e5bd833c9d718d85979d92', class: "buttons" }, index.h("button", { key: '145ae41f583a843a6e64743b9f18a0f3c23c370c', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), index.h("div", { key: 'e81da0df0eceae434bb1fbaa5b642edacc978a4a', style: { flex: '1' } }), index.h("verdocs-button", { key: 'bb0cd0eae3b51a84b2729531508d888cb03dad10', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
236
237
  }
237
238
  };
238
239
  VerdocsTemplateRoleProperties.style = VerdocsTemplateRolePropertiesStyle0;
@@ -3809,13 +3809,14 @@ const VerdocsTemplateRoles = class {
3809
3809
  .then(async (role) => {
3810
3810
  var _a;
3811
3811
  console.log('[ROLES] Created role', role);
3812
- const newTemplate = JSON.parse(JSON.stringify(this.template));
3813
- newTemplate.roles.push(role);
3812
+ // const newTemplate = JSON.parse(JSON.stringify(this.template));
3813
+ // newTemplate.roles.push(role);
3814
3814
  // TODO: Verify this immediately triggers a self-update
3815
3815
  console.log('Updating template in data store');
3816
- Datastore.Store.updateTemplate(this.templateId, newTemplate);
3816
+ await Datastore.Store.getTemplate(this.endpoint, this.templateId, true);
3817
+ // Store.updateTemplate(this.templateId, newTemplate);
3817
3818
  // This will re-sort the roles and renumbers them via server calls if necessary
3818
- await this.renumberTemplateRoles();
3819
+ // await this.renumberTemplateRoles();
3819
3820
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
3820
3821
  })
3821
3822
  .catch(e => {
@@ -3849,7 +3850,7 @@ const VerdocsTemplateRoles = class {
3849
3850
  return (index$1.h(index$1.Host, { class: { dragging: this.dragging } }, index$1.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index$1.h("h5", null, "Roles and Workflow"), index$1.h("div", { class: "roles" }, sequences.map(sequence => (index$1.h("div", { class: "sequence" }, index$1.h("div", { class: "sequence-label no-drag" }, sequence, "."), index$1.h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequence}`, "data-sequence": sequence }, this.getRolesAtSequence(sequence).map(role => {
3850
3851
  const unknown = !role.email;
3851
3852
  return unknown ? (index$1.h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, index$1.h("div", { class: "role-name" }, role.name), index$1.h("div", { class: "icons" }, index$1.h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), index$1.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover })))) : (index$1.h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, index$1.h("div", { class: "role-name" }, jsSdk.formatFullName(role)), index$1.h("div", { class: "icons" }, index$1.h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), index$1.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }))));
3852
- })), index$1.h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), index$1.h("div", { class: "sequence add-sequence" }, index$1.h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), index$1.h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }, index$1.h("div", { class: "role-name add-step-label" }, "Add Step.")), index$1.h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (index$1.h("div", { class: "empty" }, "You must add at least one Role before proceeding.", index$1.h("br", null), " Click the ", index$1.h("span", { innerHTML: plusIcon }), " Add button above to get started.")), index$1.h("div", { class: "buttons" }, index$1.h("div", { class: "flex-fill" }), index$1.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), index$1.h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (index$1.h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, index$1.h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
3853
+ })), index$1.h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), index$1.h("div", { class: "sequence add-sequence" }, index$1.h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), index$1.h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }), index$1.h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (index$1.h("div", { class: "empty" }, "You must add at least one Role before proceeding.", index$1.h("br", null), " Click the ", index$1.h("span", { innerHTML: plusIcon }), " Add button above to get started.")), index$1.h("div", { class: "buttons" }, index$1.h("div", { class: "flex-fill" }), index$1.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), index$1.h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (index$1.h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, index$1.h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
3853
3854
  var _a;
3854
3855
  (_a = document.getElementById('verdocs-menu-panel-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
3855
3856
  this.showingRoleDialog = null;
@@ -127,7 +127,8 @@ export class VerdocsTemplateRoleProperties {
127
127
  var _a, _b;
128
128
  const newTemplate = JSON.parse(JSON.stringify(this.template));
129
129
  newTemplate.roles = newTemplate.roles.filter(role => role.name !== this.roleName);
130
- Store.updateTemplate(this.templateId, newTemplate);
130
+ Store.getTemplate(this.endpoint, this.templateId, true);
131
+ // Store.updateTemplate(this.templateId, newTemplate);
131
132
  (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
132
133
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
133
134
  })
@@ -141,31 +142,31 @@ export class VerdocsTemplateRoleProperties {
141
142
  const hasFields = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || []).some(field => field.role_name === this.roleName);
142
143
  // Either all three should be empty, or all three need to be filled
143
144
  const isValid = (!this.email && !this.first_name && !this.last_name) || (isValidEmail(this.email) && !!this.first_name && !!this.last_name);
144
- return (h(Host, { key: '33fd4fdb9aab4d7e8db63b8f98803d618f396c7e' }, h("form", { key: 'f0ea5498aecaee8f00c68a60a0c941e1895cf89d', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("div", { key: '0900acf8a16a37b0fb1b6786c41c79f9ba3baee2' }, h("verdocs-text-input", { key: '7c6f93dfbacd951ea086e1f3f67a2ac731649218', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
145
+ return (h(Host, { key: 'a1895798db1e9b9f63c42e79556bdb76029217c2' }, h("form", { key: '8be859da1a954e4d086d630e0d5aeaa991f88640', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("div", { key: 'a37025fa1b286d43493bd142f77f8310b02ee701' }, h("verdocs-text-input", { key: 'eea1b7844b0a60c30a6ee50a123399b7fe6fac4a', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
145
146
  this.name = e.target.value;
146
147
  this.dirty = true;
147
- } }), hasFields && h("div", { key: '439e8d7ba00f6f60bfb4c92d3ad7811cbbce6c35', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), h("div", { key: '622509e07d3329f97b2afe1b812c1920b95d9677' }, h("div", { key: 'da96defab9d0d608bb02292e99a5390613a4face', class: "input-label" }, "Type:"), h("verdocs-select-input", { key: '01368605afcbb3d0ea905f3698f7c4bc1946a0ee', value: this.type, options: [
148
+ } }), hasFields && h("div", { key: '5945d4e7a64f9b4a513bbd975fb821f662e452a4', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), h("div", { key: '14cfb01f29a5889f1fcb2c90366ba4f215341a2c' }, h("div", { key: '9095e3b2f1f378c9d3937898ca68d6742d89be54', class: "input-label" }, "Type:"), h("verdocs-select-input", { key: 'b07e4afc086e7d1563f58bb3c43aa0d909d8a65e', value: this.type, options: [
148
149
  { label: 'Signer', value: 'signer' },
149
150
  { label: 'CC', value: 'cc' },
150
151
  { label: 'Approver', value: 'approver' },
151
152
  ], onInput: (e) => {
152
153
  this.type = e.target.value;
153
154
  this.dirty = true;
154
- } })), h("div", { key: '8a6c71ab8a7566e9d2cfd942c72ec44c7966e6a8' }, h("div", { key: '41ce817a89e963dd8aa4ce49cc27871994b69e2a', class: "input-label" }, "Default Contact Info:"), h("div", { key: 'e4b958063bc92d3df34bcb9314ff9c931c6a4993', class: "first-last" }, h("verdocs-text-input", { key: 'cde6107c9d66e786dc17f6ce825a9dc1bf6e101e', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
155
+ } })), h("div", { key: '5e1ed5226be0707cc5430c1e7bd38ad6e4df5dd5' }, h("div", { key: 'fc4a467cb0da25a80c421134c8226480369d2a83', class: "input-label" }, "Default Contact Info:"), h("div", { key: 'f6cb36cde86b8067c374e4bf0cffa6549851888d', class: "first-last" }, h("verdocs-text-input", { key: 'a52d5426c87419f45482ef6004ef11597400ea87', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
155
156
  this.first_name = e.target.value;
156
157
  this.dirty = true;
157
- } }), h("verdocs-text-input", { key: '219e51d998390ea3a297b40867cd3e908374938a', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
158
+ } }), h("verdocs-text-input", { key: 'b9035b299231319dce05f19c15c4d427ad6cd2f3', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
158
159
  this.last_name = e.target.value;
159
160
  this.dirty = true;
160
- } }))), h("div", { key: '95f56626e28d1ab8e82af7954012b34e36ecdc19' }, h("verdocs-text-input", { key: '1e676e75b29e8dc63711c9a4c3de95cd2d88b6cc', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
161
+ } }))), h("div", { key: 'd42c1ce5ae61db11a0ac32b3fa7bc3816e3068c6' }, h("verdocs-text-input", { key: '63436a7be6b3f35c2341dc88d137bd2f6b061978', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
161
162
  this.email = e.target.value;
162
163
  this.dirty = true;
163
- } }), h("div", { key: 'f298189867060ffbfb977da4b0f6cd4c69dce71f', style: { height: '15px' } }), h("div", { key: '71a8079b3751957cd135a2c736a3b59624f77bd4' }, h("verdocs-text-input", { key: '2ff08fdee843a2c4c72769b8bbe50f48608b6a08', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
164
+ } }), h("div", { key: '5a7ed36cfa657fb9ee11cf62998abbab2cc641e9', style: { height: '15px' } }), h("div", { key: 'c974f4e78235706788dfa54f69f6f5ec7d37d00e' }, h("verdocs-text-input", { key: '2be4c29396c6e6bc4f687819646ea219fce97e82', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
164
165
  // helpText="The recipient's phone number, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template."
165
166
  placeholder: "Phone Number...", onInput: (e) => {
166
167
  this.phone = e.target.value;
167
168
  this.dirty = true;
168
- } }))), h("div", { key: '30b10e1c20ace197aa67dedcabef9adf2206bbf1', class: "buttons" }, h("button", { key: '52ccaafe4e4f51d2b994813538d33443c79da0ed', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { key: '49dcb63a78d83f03e8b434adeca3cf60082de647', style: { flex: '1' } }), h("verdocs-button", { key: '70b8347ddba86faf658cae033de62b9dab14aeab', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
169
+ } }))), h("div", { key: 'a0eba03681cab8b491e5bd833c9d718d85979d92', class: "buttons" }, h("button", { key: '145ae41f583a843a6e64743b9f18a0f3c23c370c', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { key: 'e81da0df0eceae434bb1fbaa5b642edacc978a4a', style: { flex: '1' } }), h("verdocs-button", { key: 'bb0cd0eae3b51a84b2729531508d888cb03dad10', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
169
170
  }
170
171
  static get is() { return "verdocs-template-role-properties"; }
171
172
  static get originalStyleUrls() {
@@ -231,13 +231,14 @@ export class VerdocsTemplateRoles {
231
231
  .then(async (role) => {
232
232
  var _a;
233
233
  console.log('[ROLES] Created role', role);
234
- const newTemplate = JSON.parse(JSON.stringify(this.template));
235
- newTemplate.roles.push(role);
234
+ // const newTemplate = JSON.parse(JSON.stringify(this.template));
235
+ // newTemplate.roles.push(role);
236
236
  // TODO: Verify this immediately triggers a self-update
237
237
  console.log('Updating template in data store');
238
- Store.updateTemplate(this.templateId, newTemplate);
238
+ await Store.getTemplate(this.endpoint, this.templateId, true);
239
+ // Store.updateTemplate(this.templateId, newTemplate);
239
240
  // This will re-sort the roles and renumbers them via server calls if necessary
240
- await this.renumberTemplateRoles();
241
+ // await this.renumberTemplateRoles();
241
242
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
242
243
  })
243
244
  .catch(e => {
@@ -271,7 +272,7 @@ export class VerdocsTemplateRoles {
271
272
  return (h(Host, { class: { dragging: this.dragging } }, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("h5", null, "Roles and Workflow"), h("div", { class: "roles" }, sequences.map(sequence => (h("div", { class: "sequence" }, h("div", { class: "sequence-label no-drag" }, sequence, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequence}`, "data-sequence": sequence }, this.getRolesAtSequence(sequence).map(role => {
272
273
  const unknown = !role.email;
273
274
  return unknown ? (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, role.name), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover })))) : (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, formatFullName(role)), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }))));
274
- })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }, h("div", { class: "role-name add-step-label" }, "Add Step.")), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
275
+ })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
275
276
  var _a;
276
277
  (_a = document.getElementById('verdocs-menu-panel-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
277
278
  this.showingRoleDialog = null;
@@ -137,7 +137,8 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class Ver
137
137
  var _a, _b;
138
138
  const newTemplate = JSON.parse(JSON.stringify(this.template));
139
139
  newTemplate.roles = newTemplate.roles.filter(role => role.name !== this.roleName);
140
- Store.updateTemplate(this.templateId, newTemplate);
140
+ Store.getTemplate(this.endpoint, this.templateId, true);
141
+ // Store.updateTemplate(this.templateId, newTemplate);
141
142
  (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
142
143
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
143
144
  })
@@ -151,31 +152,31 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class Ver
151
152
  const hasFields = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || []).some(field => field.role_name === this.roleName);
152
153
  // Either all three should be empty, or all three need to be filled
153
154
  const isValid = (!this.email && !this.first_name && !this.last_name) || (isValidEmail(this.email) && !!this.first_name && !!this.last_name);
154
- return (h(Host, { key: '33fd4fdb9aab4d7e8db63b8f98803d618f396c7e' }, h("form", { key: 'f0ea5498aecaee8f00c68a60a0c941e1895cf89d', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("div", { key: '0900acf8a16a37b0fb1b6786c41c79f9ba3baee2' }, h("verdocs-text-input", { key: '7c6f93dfbacd951ea086e1f3f67a2ac731649218', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
155
+ return (h(Host, { key: 'a1895798db1e9b9f63c42e79556bdb76029217c2' }, h("form", { key: '8be859da1a954e4d086d630e0d5aeaa991f88640', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("div", { key: 'a37025fa1b286d43493bd142f77f8310b02ee701' }, h("verdocs-text-input", { key: 'eea1b7844b0a60c30a6ee50a123399b7fe6fac4a', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
155
156
  this.name = e.target.value;
156
157
  this.dirty = true;
157
- } }), hasFields && h("div", { key: '439e8d7ba00f6f60bfb4c92d3ad7811cbbce6c35', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), h("div", { key: '622509e07d3329f97b2afe1b812c1920b95d9677' }, h("div", { key: 'da96defab9d0d608bb02292e99a5390613a4face', class: "input-label" }, "Type:"), h("verdocs-select-input", { key: '01368605afcbb3d0ea905f3698f7c4bc1946a0ee', value: this.type, options: [
158
+ } }), hasFields && h("div", { key: '5945d4e7a64f9b4a513bbd975fb821f662e452a4', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), h("div", { key: '14cfb01f29a5889f1fcb2c90366ba4f215341a2c' }, h("div", { key: '9095e3b2f1f378c9d3937898ca68d6742d89be54', class: "input-label" }, "Type:"), h("verdocs-select-input", { key: 'b07e4afc086e7d1563f58bb3c43aa0d909d8a65e', value: this.type, options: [
158
159
  { label: 'Signer', value: 'signer' },
159
160
  { label: 'CC', value: 'cc' },
160
161
  { label: 'Approver', value: 'approver' },
161
162
  ], onInput: (e) => {
162
163
  this.type = e.target.value;
163
164
  this.dirty = true;
164
- } })), h("div", { key: '8a6c71ab8a7566e9d2cfd942c72ec44c7966e6a8' }, h("div", { key: '41ce817a89e963dd8aa4ce49cc27871994b69e2a', class: "input-label" }, "Default Contact Info:"), h("div", { key: 'e4b958063bc92d3df34bcb9314ff9c931c6a4993', class: "first-last" }, h("verdocs-text-input", { key: 'cde6107c9d66e786dc17f6ce825a9dc1bf6e101e', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
165
+ } })), h("div", { key: '5e1ed5226be0707cc5430c1e7bd38ad6e4df5dd5' }, h("div", { key: 'fc4a467cb0da25a80c421134c8226480369d2a83', class: "input-label" }, "Default Contact Info:"), h("div", { key: 'f6cb36cde86b8067c374e4bf0cffa6549851888d', class: "first-last" }, h("verdocs-text-input", { key: 'a52d5426c87419f45482ef6004ef11597400ea87', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
165
166
  this.first_name = e.target.value;
166
167
  this.dirty = true;
167
- } }), h("verdocs-text-input", { key: '219e51d998390ea3a297b40867cd3e908374938a', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
168
+ } }), h("verdocs-text-input", { key: 'b9035b299231319dce05f19c15c4d427ad6cd2f3', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
168
169
  this.last_name = e.target.value;
169
170
  this.dirty = true;
170
- } }))), h("div", { key: '95f56626e28d1ab8e82af7954012b34e36ecdc19' }, h("verdocs-text-input", { key: '1e676e75b29e8dc63711c9a4c3de95cd2d88b6cc', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
171
+ } }))), h("div", { key: 'd42c1ce5ae61db11a0ac32b3fa7bc3816e3068c6' }, h("verdocs-text-input", { key: '63436a7be6b3f35c2341dc88d137bd2f6b061978', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
171
172
  this.email = e.target.value;
172
173
  this.dirty = true;
173
- } }), h("div", { key: 'f298189867060ffbfb977da4b0f6cd4c69dce71f', style: { height: '15px' } }), h("div", { key: '71a8079b3751957cd135a2c736a3b59624f77bd4' }, h("verdocs-text-input", { key: '2ff08fdee843a2c4c72769b8bbe50f48608b6a08', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
174
+ } }), h("div", { key: '5a7ed36cfa657fb9ee11cf62998abbab2cc641e9', style: { height: '15px' } }), h("div", { key: 'c974f4e78235706788dfa54f69f6f5ec7d37d00e' }, h("verdocs-text-input", { key: '2be4c29396c6e6bc4f687819646ea219fce97e82', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
174
175
  // helpText="The recipient's phone number, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template."
175
176
  placeholder: "Phone Number...", onInput: (e) => {
176
177
  this.phone = e.target.value;
177
178
  this.dirty = true;
178
- } }))), h("div", { key: '30b10e1c20ace197aa67dedcabef9adf2206bbf1', class: "buttons" }, h("button", { key: '52ccaafe4e4f51d2b994813538d33443c79da0ed', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { key: '49dcb63a78d83f03e8b434adeca3cf60082de647', style: { flex: '1' } }), h("verdocs-button", { key: '70b8347ddba86faf658cae033de62b9dab14aeab', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
179
+ } }))), h("div", { key: 'a0eba03681cab8b491e5bd833c9d718d85979d92', class: "buttons" }, h("button", { key: '145ae41f583a843a6e64743b9f18a0f3c23c370c', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { key: 'e81da0df0eceae434bb1fbaa5b642edacc978a4a', style: { flex: '1' } }), h("verdocs-button", { key: 'bb0cd0eae3b51a84b2729531508d888cb03dad10', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
179
180
  }
180
181
  static get style() { return VerdocsTemplateRolePropertiesStyle0; }
181
182
  }, [0, "verdocs-template-role-properties", {
@@ -8,7 +8,7 @@ import { d as defineCustomElement$6 } from './p-7f32e087.js';
8
8
  import { d as defineCustomElement$5 } from './p-1ae5d7e0.js';
9
9
  import { d as defineCustomElement$4 } from './p-be261487.js';
10
10
  import { d as defineCustomElement$3 } from './p-62743fd3.js';
11
- import { d as defineCustomElement$2 } from './p-53585e13.js';
11
+ import { d as defineCustomElement$2 } from './p-9c37d4b3.js';
12
12
  import { d as defineCustomElement$1 } from './p-325b3828.js';
13
13
 
14
14
  /**!
@@ -2908,13 +2908,14 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class VerdocsTempl
2908
2908
  .then(async (role) => {
2909
2909
  var _a;
2910
2910
  console.log('[ROLES] Created role', role);
2911
- const newTemplate = JSON.parse(JSON.stringify(this.template));
2912
- newTemplate.roles.push(role);
2911
+ // const newTemplate = JSON.parse(JSON.stringify(this.template));
2912
+ // newTemplate.roles.push(role);
2913
2913
  // TODO: Verify this immediately triggers a self-update
2914
2914
  console.log('Updating template in data store');
2915
- Store.updateTemplate(this.templateId, newTemplate);
2915
+ await Store.getTemplate(this.endpoint, this.templateId, true);
2916
+ // Store.updateTemplate(this.templateId, newTemplate);
2916
2917
  // This will re-sort the roles and renumbers them via server calls if necessary
2917
- await this.renumberTemplateRoles();
2918
+ // await this.renumberTemplateRoles();
2918
2919
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
2919
2920
  })
2920
2921
  .catch(e => {
@@ -2948,7 +2949,7 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class VerdocsTempl
2948
2949
  return (h(Host, { class: { dragging: this.dragging } }, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("h5", null, "Roles and Workflow"), h("div", { class: "roles" }, sequences.map(sequence => (h("div", { class: "sequence" }, h("div", { class: "sequence-label no-drag" }, sequence, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequence}`, "data-sequence": sequence }, this.getRolesAtSequence(sequence).map(role => {
2949
2950
  const unknown = !role.email;
2950
2951
  return unknown ? (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, role.name), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover })))) : (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, formatFullName(role)), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }))));
2951
- })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }, h("div", { class: "role-name add-step-label" }, "Add Step.")), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
2952
+ })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
2952
2953
  var _a;
2953
2954
  (_a = document.getElementById('verdocs-menu-panel-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
2954
2955
  this.showingRoleDialog = null;
@@ -36,8 +36,8 @@ import { d as defineCustomElement$b } from './p-f7462b26.js';
36
36
  import { d as defineCustomElement$a } from './p-cef9df4b.js';
37
37
  import { d as defineCustomElement$9 } from './p-052fcdac.js';
38
38
  import { d as defineCustomElement$8 } from './p-987a8392.js';
39
- import { d as defineCustomElement$7 } from './p-53585e13.js';
40
- import { d as defineCustomElement$6 } from './p-6e8464b6.js';
39
+ import { d as defineCustomElement$7 } from './p-9c37d4b3.js';
40
+ import { d as defineCustomElement$6 } from './p-eefda339.js';
41
41
  import { d as defineCustomElement$5 } from './p-325b3828.js';
42
42
  import { d as defineCustomElement$4 } from './p-c00770e6.js';
43
43
  import { d as defineCustomElement$3 } from './p-4d3b9ee9.js';
@@ -1,4 +1,4 @@
1
- import { V as VerdocsTemplateRoleProperties$1, d as defineCustomElement$1 } from './p-53585e13.js';
1
+ import { V as VerdocsTemplateRoleProperties$1, d as defineCustomElement$1 } from './p-9c37d4b3.js';
2
2
 
3
3
  const VerdocsTemplateRoleProperties = VerdocsTemplateRoleProperties$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { V as VerdocsTemplateRoles$1, d as defineCustomElement$1 } from './p-6e8464b6.js';
1
+ import { V as VerdocsTemplateRoles$1, d as defineCustomElement$1 } from './p-eefda339.js';
2
2
 
3
3
  const VerdocsTemplateRoles = VerdocsTemplateRoles$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -190,7 +190,8 @@ const VerdocsTemplateRoleProperties = class {
190
190
  var _a, _b;
191
191
  const newTemplate = JSON.parse(JSON.stringify(this.template));
192
192
  newTemplate.roles = newTemplate.roles.filter(role => role.name !== this.roleName);
193
- Store.updateTemplate(this.templateId, newTemplate);
193
+ Store.getTemplate(this.endpoint, this.templateId, true);
194
+ // Store.updateTemplate(this.templateId, newTemplate);
194
195
  (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
195
196
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
196
197
  })
@@ -204,31 +205,31 @@ const VerdocsTemplateRoleProperties = class {
204
205
  const hasFields = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || []).some(field => field.role_name === this.roleName);
205
206
  // Either all three should be empty, or all three need to be filled
206
207
  const isValid = (!this.email && !this.first_name && !this.last_name) || (isValidEmail(this.email) && !!this.first_name && !!this.last_name);
207
- return (h(Host, { key: '33fd4fdb9aab4d7e8db63b8f98803d618f396c7e' }, h("form", { key: 'f0ea5498aecaee8f00c68a60a0c941e1895cf89d', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("div", { key: '0900acf8a16a37b0fb1b6786c41c79f9ba3baee2' }, h("verdocs-text-input", { key: '7c6f93dfbacd951ea086e1f3f67a2ac731649218', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
208
+ return (h(Host, { key: 'a1895798db1e9b9f63c42e79556bdb76029217c2' }, h("form", { key: '8be859da1a954e4d086d630e0d5aeaa991f88640', onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("div", { key: 'a37025fa1b286d43493bd142f77f8310b02ee701' }, h("verdocs-text-input", { key: 'eea1b7844b0a60c30a6ee50a123399b7fe6fac4a', id: "verdocs-role-name", label: "Role Name (Must be unique)", value: this.name, autocomplete: "off", disabled: hasFields, placeholder: "Role Name...", onInput: (e) => {
208
209
  this.name = e.target.value;
209
210
  this.dirty = true;
210
- } }), hasFields && h("div", { key: '439e8d7ba00f6f60bfb4c92d3ad7811cbbce6c35', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), h("div", { key: '622509e07d3329f97b2afe1b812c1920b95d9677' }, h("div", { key: 'da96defab9d0d608bb02292e99a5390613a4face', class: "input-label" }, "Type:"), h("verdocs-select-input", { key: '01368605afcbb3d0ea905f3698f7c4bc1946a0ee', value: this.type, options: [
211
+ } }), hasFields && h("div", { key: '5945d4e7a64f9b4a513bbd975fb821f662e452a4', class: "instructions" }, "This role has fields assigned and can no longer be renamed.")), h("div", { key: '14cfb01f29a5889f1fcb2c90366ba4f215341a2c' }, h("div", { key: '9095e3b2f1f378c9d3937898ca68d6742d89be54', class: "input-label" }, "Type:"), h("verdocs-select-input", { key: 'b07e4afc086e7d1563f58bb3c43aa0d909d8a65e', value: this.type, options: [
211
212
  { label: 'Signer', value: 'signer' },
212
213
  { label: 'CC', value: 'cc' },
213
214
  { label: 'Approver', value: 'approver' },
214
215
  ], onInput: (e) => {
215
216
  this.type = e.target.value;
216
217
  this.dirty = true;
217
- } })), h("div", { key: '8a6c71ab8a7566e9d2cfd942c72ec44c7966e6a8' }, h("div", { key: '41ce817a89e963dd8aa4ce49cc27871994b69e2a', class: "input-label" }, "Default Contact Info:"), h("div", { key: 'e4b958063bc92d3df34bcb9314ff9c931c6a4993', class: "first-last" }, h("verdocs-text-input", { key: 'cde6107c9d66e786dc17f6ce825a9dc1bf6e101e', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
218
+ } })), h("div", { key: '5e1ed5226be0707cc5430c1e7bd38ad6e4df5dd5' }, h("div", { key: 'fc4a467cb0da25a80c421134c8226480369d2a83', class: "input-label" }, "Default Contact Info:"), h("div", { key: 'f6cb36cde86b8067c374e4bf0cffa6549851888d', class: "first-last" }, h("verdocs-text-input", { key: 'a52d5426c87419f45482ef6004ef11597400ea87', id: "verdocs-recipient-first", value: this.first_name, autocomplete: "off", placeholder: "First...", onInput: (e) => {
218
219
  this.first_name = e.target.value;
219
220
  this.dirty = true;
220
- } }), h("verdocs-text-input", { key: '219e51d998390ea3a297b40867cd3e908374938a', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
221
+ } }), h("verdocs-text-input", { key: 'b9035b299231319dce05f19c15c4d427ad6cd2f3', id: "verdocs-recipient-first", value: this.last_name, autocomplete: "off", placeholder: "Last...", onInput: (e) => {
221
222
  this.last_name = e.target.value;
222
223
  this.dirty = true;
223
- } }))), h("div", { key: '95f56626e28d1ab8e82af7954012b34e36ecdc19' }, h("verdocs-text-input", { key: '1e676e75b29e8dc63711c9a4c3de95cd2d88b6cc', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
224
+ } }))), h("div", { key: 'd42c1ce5ae61db11a0ac32b3fa7bc3816e3068c6' }, h("verdocs-text-input", { key: '63436a7be6b3f35c2341dc88d137bd2f6b061978', id: "verdocs-recipient-email", value: this.email, autocomplete: "off", placeholder: "Email Address...", onInput: (e) => {
224
225
  this.email = e.target.value;
225
226
  this.dirty = true;
226
- } }), h("div", { key: 'f298189867060ffbfb977da4b0f6cd4c69dce71f', style: { height: '15px' } }), h("div", { key: '71a8079b3751957cd135a2c736a3b59624f77bd4' }, h("verdocs-text-input", { key: '2ff08fdee843a2c4c72769b8bbe50f48608b6a08', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
227
+ } }), h("div", { key: '5a7ed36cfa657fb9ee11cf62998abbab2cc641e9', style: { height: '15px' } }), h("div", { key: 'c974f4e78235706788dfa54f69f6f5ec7d37d00e' }, h("verdocs-text-input", { key: '2be4c29396c6e6bc4f687819646ea219fce97e82', id: "verdocs-recipient-phone", value: this.phone, autocomplete: "off",
227
228
  // helpText="The recipient's phone number, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template."
228
229
  placeholder: "Phone Number...", onInput: (e) => {
229
230
  this.phone = e.target.value;
230
231
  this.dirty = true;
231
- } }))), h("div", { key: '30b10e1c20ace197aa67dedcabef9adf2206bbf1', class: "buttons" }, h("button", { key: '52ccaafe4e4f51d2b994813538d33443c79da0ed', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { key: '49dcb63a78d83f03e8b434adeca3cf60082de647', style: { flex: '1' } }), h("verdocs-button", { key: '70b8347ddba86faf658cae033de62b9dab14aeab', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
232
+ } }))), h("div", { key: 'a0eba03681cab8b491e5bd833c9d718d85979d92', class: "buttons" }, h("button", { key: '145ae41f583a843a6e64743b9f18a0f3c23c370c', class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { key: 'e81da0df0eceae434bb1fbaa5b642edacc978a4a', style: { flex: '1' } }), h("verdocs-button", { key: 'bb0cd0eae3b51a84b2729531508d888cb03dad10', size: "small", label: "Save", disabled: !this.dirty || !isValid, onClick: e => this.handleSave(e) })))));
232
233
  }
233
234
  };
234
235
  VerdocsTemplateRoleProperties.style = VerdocsTemplateRolePropertiesStyle0;
@@ -3805,13 +3805,14 @@ const VerdocsTemplateRoles = class {
3805
3805
  .then(async (role) => {
3806
3806
  var _a;
3807
3807
  console.log('[ROLES] Created role', role);
3808
- const newTemplate = JSON.parse(JSON.stringify(this.template));
3809
- newTemplate.roles.push(role);
3808
+ // const newTemplate = JSON.parse(JSON.stringify(this.template));
3809
+ // newTemplate.roles.push(role);
3810
3810
  // TODO: Verify this immediately triggers a self-update
3811
3811
  console.log('Updating template in data store');
3812
- Store.updateTemplate(this.templateId, newTemplate);
3812
+ await Store.getTemplate(this.endpoint, this.templateId, true);
3813
+ // Store.updateTemplate(this.templateId, newTemplate);
3813
3814
  // This will re-sort the roles and renumbers them via server calls if necessary
3814
- await this.renumberTemplateRoles();
3815
+ // await this.renumberTemplateRoles();
3815
3816
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
3816
3817
  })
3817
3818
  .catch(e => {
@@ -3845,7 +3846,7 @@ const VerdocsTemplateRoles = class {
3845
3846
  return (h(Host, { class: { dragging: this.dragging } }, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("h5", null, "Roles and Workflow"), h("div", { class: "roles" }, sequences.map(sequence => (h("div", { class: "sequence" }, h("div", { class: "sequence-label no-drag" }, sequence, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequence}`, "data-sequence": sequence }, this.getRolesAtSequence(sequence).map(role => {
3846
3847
  const unknown = !role.email;
3847
3848
  return unknown ? (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, role.name), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover })))) : (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, formatFullName(role)), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }))));
3848
- })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }, h("div", { class: "role-name add-step-label" }, "Add Step.")), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
3849
+ })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
3849
3850
  var _a;
3850
3851
  (_a = document.getElementById('verdocs-menu-panel-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
3851
3852
  this.showingRoleDialog = null;
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,i,o){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,s){function n(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o["throw"](e))}catch(e){s(e)}}function l(e){e.done?i(e.value):r(e.value).then(n,a)}l((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},o,r,s,n;return n={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(n[Symbol.iterator]=function(){return this}),n;function a(e){return function(t){return l([e,t])}}function l(a){if(o)throw new TypeError("Generator is already executing.");while(n&&(n=0,a[0]&&(i=0)),i)try{if(o=1,r&&(s=a[0]&2?r["return"]:a[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,a[1])).done)return s;if(r=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;r=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];r=0}finally{o=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-272d51a4.js";import{VerdocsEndpoint,getTemplate,updateTemplateRole,deleteTemplateRole,isValidEmail}from"@verdocs/js-sdk";import{S as SDKError}from"./errors-887f1e88.js";import{S as Store}from"./Datastore-d29d4aeb.js";var verdocsMenuPanelCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}#verdocs-menu-panel-overlay{top:0;left:0;width:100%;height:100%;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.4980392157)}#verdocs-menu-panel{opacity:0;z-index:10001;position:fixed;overflow-y:scroll;background-color:#ffffff;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-webkit-animation:showVerdocsMenuPanel 0.35s;-webkit-animation-fill-mode:forwards}@-webkit-keyframes showVerdocsMenuPanel{0%{opacity:0;right:-300px}100%{right:0;opacity:1}}';var VerdocsMenuPanelStyle0=verdocsMenuPanelCss;var VerdocsMenuPanel=function(){function e(e){registerInstance(this,e);this.close=createEvent(this,"close",7);this.moved=false;this.overlayId="verdocs-menu-panel-overlay";this.panelId="verdocs-menu-panel";this.side="right";this.overlay=true;this.width=300}e.prototype.handleClick=function(e){var t;if(!this.element.contains(e.target)){this.hide();(t=this.close)===null||t===void 0?void 0:t.emit()}};e.prototype.componentWillLoad=function(){this.hide();if(this.overlay){this.portal=document.createElement("div");this.portal.setAttribute("id",this.overlayId);document.body.append(this.portal)}this.portal=document.createElement("div");this.portal.setAttribute("id",this.panelId);this.portal.style.top="0px";this.portal.style.bottom="0px";this.portal.style.width="".concat(this.width,"px");if(this.side==="left"){this.portal.style.left="0px"}else{this.portal.style.right="0px"}document.body.append(this.portal)};e.prototype.componentDidLoad=function(){this.portal.appendChild(this.element)};e.prototype.disconnectedCallback=function(){this.moved?this.portal.remove():this.moved=true};e.prototype.hide=function(){var e,t;(e=document.getElementById(this.overlayId))===null||e===void 0?void 0:e.remove();(t=document.getElementById(this.panelId))===null||t===void 0?void 0:t.remove()};e.prototype.render=function(){var e=this;return h(Host,{key:"1d8fd8a0d6035917184972712ab812f5c6141a1f",ref:function(t){return e.element=t}},h("slot",{key:"696879936056ff36c4054e4a235455f9308605af"}))};return e}();VerdocsMenuPanel.style=VerdocsMenuPanelStyle0;var verdocsTemplateRolePropertiesCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-role-properties{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", "Barlow", sans-serif}verdocs-template-role-properties div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-role-properties .heading{display:-ms-flexbox;display:flex;font-size:20px;font-weight:500;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}verdocs-template-role-properties .buttons verdocs-button{margin-left:16px}verdocs-template-role-properties form{gap:15px;padding:20px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-role-properties form .instructions{margin:7px 0 0 0;font-size:12px;font-style:italic}verdocs-template-role-properties form .input-label{display:block;font-size:14px;-ms-flex:0 0 100px;flex:0 0 100px;font-weight:700;margin:0 0 4px 0;color:#555570}verdocs-template-role-properties form .first-last{gap:15px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties form verdocs-help-icon{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-role-properties verdocs-select-input label{display:block}verdocs-template-role-properties verdocs-text-input{margin:0}verdocs-template-role-properties verdocs-text-input label{display:block}verdocs-template-role-properties verdocs-text-input .input-label{-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-role-properties verdocs-text-input input{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-role-properties verdocs-text-input verdocs-text-input{margin:0}verdocs-template-role-properties .checkbox-wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-role-properties .delete-button{height:34px;display:-ms-flexbox;display:flex;padding:0 6px;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-role-properties .delete-button svg{width:24px;height:24px}verdocs-template-role-properties .delete-button:active{background:#f3f3f3}';var VerdocsTemplateRolePropertiesStyle0=verdocsTemplateRolePropertiesCss;var TrashIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#a50021"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>';var VerdocsTemplateRoleProperties=function(){function e(e){registerInstance(this,e);this.close=createEvent(this,"close",7);this.delete=createEvent(this,"delete",7);this.sdkError=createEvent(this,"sdkError",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.roleName="";this.dirty=false;this.saving=false;this.name="";this.type="signer";this.first_name="";this.last_name="";this.email="";this.phone="";this.delegator=false;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[ROLES Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[ROLES] Loading tempate",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var i;console.log("[BUILD] Template Updated",t);e.template=t;e.loading=false;var o=(i=e.template)===null||i===void 0?void 0:i.roles.find((function(t){return t.name===e.roleName}));if(o){e.name=o.name;e.type=o.type;e.first_name=o.first_name;e.last_name=o.last_name;e.email=o.email;e.phone=o.phone;e.delegator=o.delegator;console.log("[ROLES] Editing role",o)}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){var t=this;var i,o;e.stopPropagation();var r=(i=this.template)===null||i===void 0?void 0:i.roles.find((function(e){return e.name===t.roleName}));if(r){this.name=r.name;this.type=r.type;this.first_name=r.first_name;this.last_name=r.last_name;this.email=r.email;this.phone=r.phone;this.delegator=r.delegator}this.dirty=false;(o=this.close)===null||o===void 0?void 0:o.emit()};e.prototype.handleSave=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){e.stopPropagation();this.saving=true;updateTemplateRole(this.endpoint,this.templateId,this.roleName,{name:this.name,type:this.type,first_name:this.first_name,last_name:this.last_name,email:this.email,phone:this.phone,delegator:this.delegator}).then((function(e){return __awaiter(t,void 0,void 0,(function(){var t,i,o;var r=this;return __generator(this,(function(s){console.log("[ROLES] Update result",e);this.saving=false;this.dirty=false;i=JSON.parse(JSON.stringify(this.template));o=i.roles.findIndex((function(e){return e.name===r.roleName}));if(o>-1){i.roles[o]=e}Store.updateTemplate(this.templateId,i);(t=this.close)===null||t===void 0?void 0:t.emit();return[2]}))}))})).catch((function(e){console.log("[ROLES Update error",e);t.saving=false}));return[2]}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){e.stopPropagation();if(window.confirm("Are you sure you wish to remove this role? All associated fields will be removed as well. This action cannot be undone.")){deleteTemplateRole(this.endpoint,this.templateId,this.roleName).then((function(){var e,i;var o=JSON.parse(JSON.stringify(t.template));o.roles=o.roles.filter((function(e){return e.name!==t.roleName}));Store.updateTemplate(t.templateId,o);(e=t.delete)===null||e===void 0?void 0:e.emit({templateId:t.templateId,roleName:t.roleName});(i=t.close)===null||i===void 0?void 0:i.emit()})).catch((function(e){console.log("[ROLES Deletion error",e)}))}return[2]}))}))};e.prototype.render=function(){var e=this;var t;var i=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).some((function(t){return t.role_name===e.roleName}));var o=!this.email&&!this.first_name&&!this.last_name||isValidEmail(this.email)&&!!this.first_name&&!!this.last_name;return h(Host,{key:"33fd4fdb9aab4d7e8db63b8f98803d618f396c7e"},h("form",{key:"f0ea5498aecaee8f00c68a60a0c941e1895cf89d",onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("div",{key:"0900acf8a16a37b0fb1b6786c41c79f9ba3baee2"},h("verdocs-text-input",{key:"7c6f93dfbacd951ea086e1f3f67a2ac731649218",id:"verdocs-role-name",label:"Role Name (Must be unique)",value:this.name,autocomplete:"off",disabled:i,placeholder:"Role Name...",onInput:function(t){e.name=t.target.value;e.dirty=true}}),i&&h("div",{key:"439e8d7ba00f6f60bfb4c92d3ad7811cbbce6c35",class:"instructions"},"This role has fields assigned and can no longer be renamed.")),h("div",{key:"622509e07d3329f97b2afe1b812c1920b95d9677"},h("div",{key:"da96defab9d0d608bb02292e99a5390613a4face",class:"input-label"},"Type:"),h("verdocs-select-input",{key:"01368605afcbb3d0ea905f3698f7c4bc1946a0ee",value:this.type,options:[{label:"Signer",value:"signer"},{label:"CC",value:"cc"},{label:"Approver",value:"approver"}],onInput:function(t){e.type=t.target.value;e.dirty=true}})),h("div",{key:"8a6c71ab8a7566e9d2cfd942c72ec44c7966e6a8"},h("div",{key:"41ce817a89e963dd8aa4ce49cc27871994b69e2a",class:"input-label"},"Default Contact Info:"),h("div",{key:"e4b958063bc92d3df34bcb9314ff9c931c6a4993",class:"first-last"},h("verdocs-text-input",{key:"cde6107c9d66e786dc17f6ce825a9dc1bf6e101e",id:"verdocs-recipient-first",value:this.first_name,autocomplete:"off",placeholder:"First...",onInput:function(t){e.first_name=t.target.value;e.dirty=true}}),h("verdocs-text-input",{key:"219e51d998390ea3a297b40867cd3e908374938a",id:"verdocs-recipient-first",value:this.last_name,autocomplete:"off",placeholder:"Last...",onInput:function(t){e.last_name=t.target.value;e.dirty=true}}))),h("div",{key:"95f56626e28d1ab8e82af7954012b34e36ecdc19"},h("verdocs-text-input",{key:"1e676e75b29e8dc63711c9a4c3de95cd2d88b6cc",id:"verdocs-recipient-email",value:this.email,autocomplete:"off",placeholder:"Email Address...",onInput:function(t){e.email=t.target.value;e.dirty=true}}),h("div",{key:"f298189867060ffbfb977da4b0f6cd4c69dce71f",style:{height:"15px"}}),h("div",{key:"71a8079b3751957cd135a2c736a3b59624f77bd4"},h("verdocs-text-input",{key:"2ff08fdee843a2c4c72769b8bbe50f48608b6a08",id:"verdocs-recipient-phone",value:this.phone,autocomplete:"off",placeholder:"Phone Number...",onInput:function(t){e.phone=t.target.value;e.dirty=true}}))),h("div",{key:"30b10e1c20ace197aa67dedcabef9adf2206bbf1",class:"buttons"},h("button",{key:"52ccaafe4e4f51d2b994813538d33443c79da0ed",class:"delete-button",disabled:this.dirty,onClick:function(t){return e.handleDelete(t)},innerHTML:TrashIcon}),h("div",{key:"49dcb63a78d83f03e8b434adeca3cf60082de647",style:{flex:"1"}}),h("verdocs-button",{key:"70b8347ddba86faf658cae033de62b9dab14aeab",size:"small",label:"Save",disabled:!this.dirty||!o,onClick:function(t){return e.handleSave(t)}}))))};return e}();VerdocsTemplateRoleProperties.style=VerdocsTemplateRolePropertiesStyle0;export{VerdocsMenuPanel as verdocs_menu_panel,VerdocsTemplateRoleProperties as verdocs_template_role_properties};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,i,o){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,s){function n(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o["throw"](e))}catch(e){s(e)}}function l(e){e.done?i(e.value):r(e.value).then(n,a)}l((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},o,r,s,n;return n={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(n[Symbol.iterator]=function(){return this}),n;function a(e){return function(t){return l([e,t])}}function l(a){if(o)throw new TypeError("Generator is already executing.");while(n&&(n=0,a[0]&&(i=0)),i)try{if(o=1,r&&(s=a[0]&2?r["return"]:a[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,a[1])).done)return s;if(r=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;r=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];r=0}finally{o=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-272d51a4.js";import{VerdocsEndpoint,getTemplate,updateTemplateRole,deleteTemplateRole,isValidEmail}from"@verdocs/js-sdk";import{S as SDKError}from"./errors-887f1e88.js";import{S as Store}from"./Datastore-d29d4aeb.js";var verdocsMenuPanelCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}#verdocs-menu-panel-overlay{top:0;left:0;width:100%;height:100%;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.4980392157)}#verdocs-menu-panel{opacity:0;z-index:10001;position:fixed;overflow-y:scroll;background-color:#ffffff;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-webkit-animation:showVerdocsMenuPanel 0.35s;-webkit-animation-fill-mode:forwards}@-webkit-keyframes showVerdocsMenuPanel{0%{opacity:0;right:-300px}100%{right:0;opacity:1}}';var VerdocsMenuPanelStyle0=verdocsMenuPanelCss;var VerdocsMenuPanel=function(){function e(e){registerInstance(this,e);this.close=createEvent(this,"close",7);this.moved=false;this.overlayId="verdocs-menu-panel-overlay";this.panelId="verdocs-menu-panel";this.side="right";this.overlay=true;this.width=300}e.prototype.handleClick=function(e){var t;if(!this.element.contains(e.target)){this.hide();(t=this.close)===null||t===void 0?void 0:t.emit()}};e.prototype.componentWillLoad=function(){this.hide();if(this.overlay){this.portal=document.createElement("div");this.portal.setAttribute("id",this.overlayId);document.body.append(this.portal)}this.portal=document.createElement("div");this.portal.setAttribute("id",this.panelId);this.portal.style.top="0px";this.portal.style.bottom="0px";this.portal.style.width="".concat(this.width,"px");if(this.side==="left"){this.portal.style.left="0px"}else{this.portal.style.right="0px"}document.body.append(this.portal)};e.prototype.componentDidLoad=function(){this.portal.appendChild(this.element)};e.prototype.disconnectedCallback=function(){this.moved?this.portal.remove():this.moved=true};e.prototype.hide=function(){var e,t;(e=document.getElementById(this.overlayId))===null||e===void 0?void 0:e.remove();(t=document.getElementById(this.panelId))===null||t===void 0?void 0:t.remove()};e.prototype.render=function(){var e=this;return h(Host,{key:"1d8fd8a0d6035917184972712ab812f5c6141a1f",ref:function(t){return e.element=t}},h("slot",{key:"696879936056ff36c4054e4a235455f9308605af"}))};return e}();VerdocsMenuPanel.style=VerdocsMenuPanelStyle0;var verdocsTemplateRolePropertiesCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-role-properties{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", "Barlow", sans-serif}verdocs-template-role-properties div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-role-properties .heading{display:-ms-flexbox;display:flex;font-size:20px;font-weight:500;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}verdocs-template-role-properties .buttons verdocs-button{margin-left:16px}verdocs-template-role-properties form{gap:15px;padding:20px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-role-properties form .instructions{margin:7px 0 0 0;font-size:12px;font-style:italic}verdocs-template-role-properties form .input-label{display:block;font-size:14px;-ms-flex:0 0 100px;flex:0 0 100px;font-weight:700;margin:0 0 4px 0;color:#555570}verdocs-template-role-properties form .first-last{gap:15px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties form verdocs-help-icon{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-role-properties verdocs-select-input label{display:block}verdocs-template-role-properties verdocs-text-input{margin:0}verdocs-template-role-properties verdocs-text-input label{display:block}verdocs-template-role-properties verdocs-text-input .input-label{-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-role-properties verdocs-text-input input{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-role-properties verdocs-text-input verdocs-text-input{margin:0}verdocs-template-role-properties .checkbox-wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-role-properties .delete-button{height:34px;display:-ms-flexbox;display:flex;padding:0 6px;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-role-properties .delete-button svg{width:24px;height:24px}verdocs-template-role-properties .delete-button:active{background:#f3f3f3}';var VerdocsTemplateRolePropertiesStyle0=verdocsTemplateRolePropertiesCss;var TrashIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#a50021"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>';var VerdocsTemplateRoleProperties=function(){function e(e){registerInstance(this,e);this.close=createEvent(this,"close",7);this.delete=createEvent(this,"delete",7);this.sdkError=createEvent(this,"sdkError",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.roleName="";this.dirty=false;this.saving=false;this.name="";this.type="signer";this.first_name="";this.last_name="";this.email="";this.phone="";this.delegator=false;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[ROLES Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[ROLES] Loading tempate",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var i;console.log("[BUILD] Template Updated",t);e.template=t;e.loading=false;var o=(i=e.template)===null||i===void 0?void 0:i.roles.find((function(t){return t.name===e.roleName}));if(o){e.name=o.name;e.type=o.type;e.first_name=o.first_name;e.last_name=o.last_name;e.email=o.email;e.phone=o.phone;e.delegator=o.delegator;console.log("[ROLES] Editing role",o)}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){var t=this;var i,o;e.stopPropagation();var r=(i=this.template)===null||i===void 0?void 0:i.roles.find((function(e){return e.name===t.roleName}));if(r){this.name=r.name;this.type=r.type;this.first_name=r.first_name;this.last_name=r.last_name;this.email=r.email;this.phone=r.phone;this.delegator=r.delegator}this.dirty=false;(o=this.close)===null||o===void 0?void 0:o.emit()};e.prototype.handleSave=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){e.stopPropagation();this.saving=true;updateTemplateRole(this.endpoint,this.templateId,this.roleName,{name:this.name,type:this.type,first_name:this.first_name,last_name:this.last_name,email:this.email,phone:this.phone,delegator:this.delegator}).then((function(e){return __awaiter(t,void 0,void 0,(function(){var t,i,o;var r=this;return __generator(this,(function(s){console.log("[ROLES] Update result",e);this.saving=false;this.dirty=false;i=JSON.parse(JSON.stringify(this.template));o=i.roles.findIndex((function(e){return e.name===r.roleName}));if(o>-1){i.roles[o]=e}Store.updateTemplate(this.templateId,i);(t=this.close)===null||t===void 0?void 0:t.emit();return[2]}))}))})).catch((function(e){console.log("[ROLES Update error",e);t.saving=false}));return[2]}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){e.stopPropagation();if(window.confirm("Are you sure you wish to remove this role? All associated fields will be removed as well. This action cannot be undone.")){deleteTemplateRole(this.endpoint,this.templateId,this.roleName).then((function(){var e,i;var o=JSON.parse(JSON.stringify(t.template));o.roles=o.roles.filter((function(e){return e.name!==t.roleName}));Store.getTemplate(t.endpoint,t.templateId,true);(e=t.delete)===null||e===void 0?void 0:e.emit({templateId:t.templateId,roleName:t.roleName});(i=t.close)===null||i===void 0?void 0:i.emit()})).catch((function(e){console.log("[ROLES Deletion error",e)}))}return[2]}))}))};e.prototype.render=function(){var e=this;var t;var i=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).some((function(t){return t.role_name===e.roleName}));var o=!this.email&&!this.first_name&&!this.last_name||isValidEmail(this.email)&&!!this.first_name&&!!this.last_name;return h(Host,{key:"a1895798db1e9b9f63c42e79556bdb76029217c2"},h("form",{key:"8be859da1a954e4d086d630e0d5aeaa991f88640",onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("div",{key:"a37025fa1b286d43493bd142f77f8310b02ee701"},h("verdocs-text-input",{key:"eea1b7844b0a60c30a6ee50a123399b7fe6fac4a",id:"verdocs-role-name",label:"Role Name (Must be unique)",value:this.name,autocomplete:"off",disabled:i,placeholder:"Role Name...",onInput:function(t){e.name=t.target.value;e.dirty=true}}),i&&h("div",{key:"5945d4e7a64f9b4a513bbd975fb821f662e452a4",class:"instructions"},"This role has fields assigned and can no longer be renamed.")),h("div",{key:"14cfb01f29a5889f1fcb2c90366ba4f215341a2c"},h("div",{key:"9095e3b2f1f378c9d3937898ca68d6742d89be54",class:"input-label"},"Type:"),h("verdocs-select-input",{key:"b07e4afc086e7d1563f58bb3c43aa0d909d8a65e",value:this.type,options:[{label:"Signer",value:"signer"},{label:"CC",value:"cc"},{label:"Approver",value:"approver"}],onInput:function(t){e.type=t.target.value;e.dirty=true}})),h("div",{key:"5e1ed5226be0707cc5430c1e7bd38ad6e4df5dd5"},h("div",{key:"fc4a467cb0da25a80c421134c8226480369d2a83",class:"input-label"},"Default Contact Info:"),h("div",{key:"f6cb36cde86b8067c374e4bf0cffa6549851888d",class:"first-last"},h("verdocs-text-input",{key:"a52d5426c87419f45482ef6004ef11597400ea87",id:"verdocs-recipient-first",value:this.first_name,autocomplete:"off",placeholder:"First...",onInput:function(t){e.first_name=t.target.value;e.dirty=true}}),h("verdocs-text-input",{key:"b9035b299231319dce05f19c15c4d427ad6cd2f3",id:"verdocs-recipient-first",value:this.last_name,autocomplete:"off",placeholder:"Last...",onInput:function(t){e.last_name=t.target.value;e.dirty=true}}))),h("div",{key:"d42c1ce5ae61db11a0ac32b3fa7bc3816e3068c6"},h("verdocs-text-input",{key:"63436a7be6b3f35c2341dc88d137bd2f6b061978",id:"verdocs-recipient-email",value:this.email,autocomplete:"off",placeholder:"Email Address...",onInput:function(t){e.email=t.target.value;e.dirty=true}}),h("div",{key:"5a7ed36cfa657fb9ee11cf62998abbab2cc641e9",style:{height:"15px"}}),h("div",{key:"c974f4e78235706788dfa54f69f6f5ec7d37d00e"},h("verdocs-text-input",{key:"2be4c29396c6e6bc4f687819646ea219fce97e82",id:"verdocs-recipient-phone",value:this.phone,autocomplete:"off",placeholder:"Phone Number...",onInput:function(t){e.phone=t.target.value;e.dirty=true}}))),h("div",{key:"a0eba03681cab8b491e5bd833c9d718d85979d92",class:"buttons"},h("button",{key:"145ae41f583a843a6e64743b9f18a0f3c23c370c",class:"delete-button",disabled:this.dirty,onClick:function(t){return e.handleDelete(t)},innerHTML:TrashIcon}),h("div",{key:"e81da0df0eceae434bb1fbaa5b642edacc978a4a",style:{flex:"1"}}),h("verdocs-button",{key:"bb0cd0eae3b51a84b2729531508d888cb03dad10",size:"small",label:"Save",disabled:!this.dirty||!o,onClick:function(t){return e.handleSave(t)}}))))};return e}();VerdocsTemplateRoleProperties.style=VerdocsTemplateRolePropertiesStyle0;export{VerdocsMenuPanel as verdocs_menu_panel,VerdocsTemplateRoleProperties as verdocs_template_role_properties};