@verdocs/web-sdk 2.3.23 → 2.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/cjs/{TemplateStore-6a75cdac.js → TemplateStore-079a1f85.js} +22 -0
  2. package/dist/cjs/ipc-test.cjs.entry.js +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/verdocs-build.cjs.entry.js +7 -3
  5. package/dist/cjs/verdocs-portal_2.cjs.entry.js +1 -1
  6. package/dist/cjs/verdocs-preview_8.cjs.entry.js +1 -1
  7. package/dist/cjs/verdocs-template-fields_4.cjs.entry.js +132 -153
  8. package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
  9. package/dist/collection/components/embeds/verdocs-build/verdocs-build.js +29 -2
  10. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +18 -11
  11. package/dist/collection/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.js +46 -44
  12. package/dist/collection/components/templates/verdocs-template-roles/verdocs-template-roles.js +78 -104
  13. package/dist/collection/utils/TemplateRoleStore.js +19 -0
  14. package/dist/collection/utils/TemplateStore.js +4 -1
  15. package/dist/components/TemplateStore.js +21 -1
  16. package/dist/components/verdocs-build.js +6 -2
  17. package/dist/components/verdocs-template-fields2.js +18 -12
  18. package/dist/components/verdocs-template-role-properties2.js +46 -45
  19. package/dist/components/verdocs-template-roles2.js +74 -101
  20. package/dist/docs.json +16 -7
  21. package/dist/esm/{TemplateStore-3994341c.js → TemplateStore-1ee18675.js} +21 -1
  22. package/dist/esm/ipc-test.entry.js +1 -1
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/verdocs-build.entry.js +7 -3
  25. package/dist/esm/verdocs-portal_2.entry.js +1 -1
  26. package/dist/esm/verdocs-preview_8.entry.js +1 -1
  27. package/dist/esm/verdocs-template-fields_4.entry.js +133 -154
  28. package/dist/esm/verdocs-web-sdk.js +1 -1
  29. package/dist/esm-es5/TemplateStore-1ee18675.js +1 -0
  30. package/dist/esm-es5/ipc-test.entry.js +1 -1
  31. package/dist/esm-es5/loader.js +1 -1
  32. package/dist/esm-es5/verdocs-build.entry.js +1 -1
  33. package/dist/esm-es5/verdocs-portal_2.entry.js +1 -1
  34. package/dist/esm-es5/verdocs-preview_8.entry.js +1 -1
  35. package/dist/esm-es5/verdocs-template-fields_4.entry.js +1 -1
  36. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  37. package/dist/types/components/embeds/verdocs-build/verdocs-build.d.ts +11 -1
  38. package/dist/types/components/templates/verdocs-template-fields/verdocs-template-fields.d.ts +3 -1
  39. package/dist/types/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.d.ts +7 -3
  40. package/dist/types/components/templates/verdocs-template-roles/verdocs-template-roles.d.ts +13 -10
  41. package/dist/types/components.d.ts +8 -4
  42. package/dist/types/utils/TemplateRoleStore.d.ts +6 -0
  43. package/dist/verdocs-web-sdk/{p-e7ea9726.entry.js → p-00e49c36.entry.js} +1 -1
  44. package/dist/verdocs-web-sdk/p-0bfc239a.system.js +1 -0
  45. package/dist/verdocs-web-sdk/p-2720068f.system.entry.js +1 -0
  46. package/dist/verdocs-web-sdk/p-4fc74ab1.js +1 -0
  47. package/dist/verdocs-web-sdk/{p-07f0bcae.entry.js → p-5361ee8f.entry.js} +1 -1
  48. package/dist/verdocs-web-sdk/p-6ada9427.entry.js +1 -0
  49. package/dist/verdocs-web-sdk/p-7f2f79fa.entry.js +1 -0
  50. package/dist/verdocs-web-sdk/{p-929760fd.system.entry.js → p-9f46a6a9.system.entry.js} +1 -1
  51. package/dist/verdocs-web-sdk/{p-040620ca.system.entry.js → p-b54467df.system.entry.js} +1 -1
  52. package/dist/verdocs-web-sdk/{p-5a05140d.system.entry.js → p-b86c345f.system.entry.js} +1 -1
  53. package/dist/verdocs-web-sdk/{p-8f8db3aa.entry.js → p-cb429454.entry.js} +1 -1
  54. package/dist/verdocs-web-sdk/p-e080e371.system.entry.js +1 -0
  55. package/dist/verdocs-web-sdk/p-f04bf956.system.js +1 -1
  56. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  57. package/package.json +1 -1
  58. package/dist/esm-es5/TemplateStore-3994341c.js +0 -1
  59. package/dist/verdocs-web-sdk/p-0cf7f778.system.entry.js +0 -1
  60. package/dist/verdocs-web-sdk/p-79fcaf1e.system.entry.js +0 -1
  61. package/dist/verdocs-web-sdk/p-a98b0097.system.js +0 -1
  62. package/dist/verdocs-web-sdk/p-cee90f53.entry.js +0 -1
  63. package/dist/verdocs-web-sdk/p-d1837af9.entry.js +0 -1
  64. package/dist/verdocs-web-sdk/p-fc2454b0.js +0 -1
@@ -5,8 +5,8 @@ import { V as VerdocsEndpoint, T as TemplateSenderTypes, u as updateTemplate } f
5
5
  import { u as updateField, c as createField } from './Fields-c82e6df3.js';
6
6
  import { i as integerSequence } from './Primitives-8fe93caf.js';
7
7
  import { b as getRoleIndex, r as renderDocumentField, f as updateCssTransform, h as defaultWidth, i as defaultHeight } from './utils-f76f3448.js';
8
- import { c as createTemplateFieldStore } from './TemplateFieldStore-295f240e.js';
9
- import { g as getTemplateStore, a as getRoleNames } from './TemplateStore-3994341c.js';
8
+ import { g as getTemplateStore, b as getTemplateRoleStore, a as getRoleNames, c as createTemplateRoleStore } from './TemplateStore-1ee18675.js';
9
+ import { g as getTemplateFieldStore } from './TemplateFieldStore-295f240e.js';
10
10
  import { S as SDKError } from './errors-9b5498c8.js';
11
11
  import { g as getRGBA } from './Colors-1b298092.js';
12
12
  import './_commonjsHelpers-8a9f3b18.js';
@@ -75,6 +75,7 @@ const VerdocsTemplateFields = class {
75
75
  this.pageHeights = {};
76
76
  this.templateStore = null;
77
77
  this.fieldStore = null;
78
+ this.roleStore = null;
78
79
  this.cachedPageInfo = {};
79
80
  this.endpoint = VerdocsEndpoint.getDefault();
80
81
  this.templateId = null;
@@ -96,7 +97,8 @@ const VerdocsTemplateFields = class {
96
97
  return;
97
98
  }
98
99
  this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
99
- this.fieldStore = createTemplateFieldStore(this.templateStore.state);
100
+ this.fieldStore = getTemplateFieldStore(this.templateId);
101
+ this.roleStore = getTemplateRoleStore(this.templateId);
100
102
  this.selectedRoleName = ((_d = (_c = (_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name) || '';
101
103
  }
102
104
  catch (e) {
@@ -115,10 +117,10 @@ const VerdocsTemplateFields = class {
115
117
  }
116
118
  }
117
119
  componentWillUpdate() {
118
- var _a, _b, _c, _d, _e, _f;
120
+ var _a, _b, _c, _d;
119
121
  // If a new role was added and there were none yet so far, or the "selected" role was deleted, reset our selection
120
- if (!this.selectedRoleName || !(((_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles) || []).find(role => role.name === this.selectedRoleName)) {
121
- this.selectedRoleName = ((_f = (_e = (_d = (_c = this.templateStore) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.roles) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.name) || '';
122
+ if (!this.selectedRoleName || !Object.values(this.roleStore).find(role => role && role.name === this.selectedRoleName)) {
123
+ this.selectedRoleName = ((_d = (_c = (_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name) || '';
122
124
  console.log('[FIELDS] Selected new role', this.selectedRoleName);
123
125
  }
124
126
  }
@@ -177,7 +179,9 @@ const VerdocsTemplateFields = class {
177
179
  // console.log('[FIELDS] Page rendered', pageInfo.pageNumber, pageInfo);
178
180
  this.cachedPageInfo[pageInfo.pageNumber] = pageInfo;
179
181
  this.pageHeights[pageInfo.pageNumber] = pageInfo.naturalHeight;
180
- const fields = Object.values(this.fieldStore.state).filter((field) => field.page_sequence === pageInfo.pageNumber);
182
+ // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
183
+ // See https://github.com/ionic-team/stencil-store/issues/23
184
+ const fields = Object.values(this.fieldStore.state).filter((field) => field && field.page_sequence === pageInfo.pageNumber);
181
185
  console.log('[FIELDS] Page rendered', pageInfo, fields);
182
186
  fields.forEach((field) => this.reRenderField(field, pageInfo.pageNumber));
183
187
  }
@@ -275,7 +279,7 @@ const VerdocsTemplateFields = class {
275
279
  do {
276
280
  fieldName = `${type}P${pageNumber}-${i}`;
277
281
  i++;
278
- } while (Object.values(this.fieldStore.state).some(field => field.name === fieldName));
282
+ } while (Object.values(this.fieldStore.state).some(field => field && field.name === fieldName));
279
283
  return fieldName;
280
284
  }
281
285
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.
@@ -387,7 +391,7 @@ const VerdocsTemplateFields = class {
387
391
  }
388
392
  }
389
393
  render() {
390
- var _a, _b, _c, _d, _e, _f, _g, _h;
394
+ var _a, _b, _c;
391
395
  if (!this.endpoint.session) {
392
396
  return (h(Host, null, h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
393
397
  }
@@ -395,7 +399,9 @@ const VerdocsTemplateFields = class {
395
399
  if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
396
400
  return (h(Host, null, h("verdocs-loader", null)));
397
401
  }
398
- const selectableRoles = (_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.roles.map(role => ({ value: role.name, label: role.name }));
402
+ const selectableRoles = Object.values(this.roleStore)
403
+ .filter(role => role !== undefined)
404
+ .map(role => ({ value: role.name, label: role.name }));
399
405
  return (h(Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, h("div", { id: "verdocs-template-fields-toolbar" }, h("div", { class: "add-for" }, "Add field:"), h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, onClick: () => {
400
406
  // We ignore empty-tooltip entries because they're separators
401
407
  if (option.tooltip) {
@@ -407,13 +413,13 @@ const VerdocsTemplateFields = class {
407
413
  this.showMustSelectRole = true;
408
414
  }
409
415
  }
410
- } })))), h("div", { class: "pages" }, (((_e = (_d = this.templateStore) === null || _d === void 0 ? void 0 : _d.state) === null || _e === void 0 ? void 0 : _e.template_documents) || []).map(document => {
416
+ } })))), h("div", { class: "pages" }, (((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.template_documents) || []).map(document => {
411
417
  const pageNumbers = integerSequence(1, document.page_numbers);
412
418
  return pageNumbers.map(page => (h("verdocs-template-document-page", { templateId: this.templateId, documentId: document.id, pageNumber: page, virtualWidth: 612, virtualHeight: 792, onClick: (e) => this.handleClickPage(e, page), onPageRendered: e => this.handlePageRendered(e), layers: [
413
419
  { name: 'page', type: 'canvas' },
414
420
  { name: 'controls', type: 'div' },
415
421
  ] })));
416
- })), this.showMustSelectRole && (h("verdocs-ok-dialog", { heading: "Unable to add field", message: ((_h = (_g = (_f = this.templateStore) === null || _f === void 0 ? void 0 : _f.state) === null || _g === void 0 ? void 0 : _g.roles) === null || _h === void 0 ? void 0 : _h.length) > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
422
+ })), this.showMustSelectRole && (h("verdocs-ok-dialog", { heading: "Unable to add field", message: Object.keys(this.roleStore).length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
417
423
  }
418
424
  };
419
425
  VerdocsTemplateFields.style = verdocsTemplateFieldsCss;
@@ -427,7 +433,9 @@ const VerdocsTemplateRoleProperties = class {
427
433
  this.close = createEvent(this, "close", 7);
428
434
  this.delete = createEvent(this, "delete", 7);
429
435
  this.sdkError = createEvent(this, "sdkError", 7);
430
- this.store = null;
436
+ this.templateStore = null;
437
+ this.fieldStore = null;
438
+ this.roleStore = null;
431
439
  this.endpoint = VerdocsEndpoint.getDefault();
432
440
  this.templateId = '';
433
441
  this.roleName = '';
@@ -436,13 +444,13 @@ const VerdocsTemplateRoleProperties = class {
436
444
  this.saving = false;
437
445
  this.name = '';
438
446
  this.type = 'signer';
439
- this.fullName = '';
447
+ this.full_name = '';
440
448
  this.email = '';
441
449
  this.phone = '';
442
- this.allowDelegation = false;
450
+ this.delegator = false;
443
451
  }
444
452
  async componentWillLoad() {
445
- var _a, _b, _c, _d, _e;
453
+ var _a, _b, _c;
446
454
  try {
447
455
  this.endpoint.loadSession();
448
456
  if (!this.templateId) {
@@ -453,29 +461,39 @@ const VerdocsTemplateRoleProperties = class {
453
461
  console.log('[ROLE_PROPERTIES] Unable to start builder session, must be authenticated');
454
462
  return;
455
463
  }
456
- this.store = await getTemplateStore(this.endpoint, this.templateId, false);
457
- const editingRole = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.find(role => role.name === this.roleName);
464
+ this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
465
+ this.fieldStore = getTemplateFieldStore(this.templateId);
466
+ this.roleStore = createTemplateRoleStore(this.templateStore.state);
467
+ const editingRole = this.roleStore.get(this.roleName);
458
468
  if (editingRole) {
459
469
  this.name = editingRole.name;
460
470
  this.type = editingRole.type;
461
- this.fullName = editingRole.full_name;
471
+ this.full_name = editingRole.full_name;
462
472
  this.email = editingRole.email;
463
473
  this.phone = editingRole.phone;
464
- this.allowDelegation = editingRole.delegator;
465
- console.log('[ROLES] Editing role', editingRole);
474
+ this.delegator = editingRole.delegator;
475
+ console.log('[ROLE_PROPERTIES] Editing role', editingRole);
466
476
  }
467
477
  }
468
478
  catch (e) {
469
- console.log('[TEMPLATE ROLE PROPERTIES] Error with preview session', e);
470
- (_c = this.sdkError) === null || _c === void 0 ? void 0 : _c.emit(new SDKError(e.message, (_d = e.response) === null || _d === void 0 ? void 0 : _d.status, (_e = e.response) === null || _e === void 0 ? void 0 : _e.data));
479
+ console.log('[ROLE_PROPERTIES Error with preview session', e);
480
+ (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
471
481
  }
472
482
  }
473
483
  handleCancel(e) {
474
- var _a, _b, _c;
484
+ var _a;
475
485
  e.stopPropagation();
476
- this.name = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.name;
486
+ const editingRole = this.roleStore.get(this.roleName);
487
+ if (editingRole) {
488
+ this.name = editingRole.name;
489
+ this.type = editingRole.type;
490
+ this.full_name = editingRole.full_name;
491
+ this.email = editingRole.email;
492
+ this.phone = editingRole.phone;
493
+ this.delegator = editingRole.delegator;
494
+ }
477
495
  this.dirty = false;
478
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
496
+ (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
479
497
  }
480
498
  async handleSave(e) {
481
499
  e.stopPropagation();
@@ -483,35 +501,24 @@ const VerdocsTemplateRoleProperties = class {
483
501
  updateRole(this.endpoint, this.templateId, this.roleName, {
484
502
  name: this.name,
485
503
  type: this.type,
486
- full_name: this.fullName,
504
+ full_name: this.full_name,
487
505
  email: this.email,
488
506
  phone: this.phone,
489
- delegator: this.allowDelegation,
507
+ delegator: this.delegator,
490
508
  })
491
509
  .then(async (r) => {
492
510
  var _a;
493
511
  console.log('[ROLE_PROPERTIES] Update result', r);
494
512
  this.saving = false;
495
513
  this.dirty = false;
496
- this.store = await getTemplateStore(this.endpoint, this.templateId, false);
497
- // this.sortTemplateRoles();
498
- // this.renumberTemplateRoles();
499
- // const newRoles = [...this.store.state.roles];
500
- // newRoles.forEach(role => {
501
- // if (role.name === this.roleName) {
502
- // role.name = this.name;
503
- // role.type = this.type;
504
- // role.full_name = this.fullName;
505
- // role.email = this.email;
506
- // role.phone = this.phone;
507
- // role.delegator = this.allowDelegation;
508
- // }
509
- // });
510
- // this.store.state.roles = newRoles;
514
+ this.roleStore.set(r.name, r);
515
+ if (this.roleName !== r.name) {
516
+ this.roleStore.set(this.roleName, undefined);
517
+ }
511
518
  (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
512
519
  })
513
520
  .catch(e => {
514
- console.log('Update error', e);
521
+ console.log('[ROLE_PROPERTIES Update error', e);
515
522
  this.saving = false;
516
523
  });
517
524
  }
@@ -521,20 +528,19 @@ const VerdocsTemplateRoleProperties = class {
521
528
  deleteRole(this.endpoint, this.templateId, this.roleName)
522
529
  .then(r => {
523
530
  var _a;
524
- console.log('Role deleted', r);
525
- this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
531
+ delete this.roleStore.state[r.name];
526
532
  (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
527
533
  })
528
534
  .catch(e => {
529
- console.log('Deletion error', e);
535
+ console.log('[ROLE_PROPERTIES Deletion error', e);
530
536
  });
531
537
  }
532
538
  }
533
539
  render() {
534
- const hasFields = (this.store.state.fields || []).findIndex(field => field.role_name === this.roleName) !== -1;
535
- return (h(Host, null, h("div", { class: "background-overlay", onClick: e => this.handleCancel(e) }, h("div", { class: "dialog" }, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("verdocs-text-input", { id: "verdocs-recipient-name", label: "Role Name", value: this.name, autocomplete: "off", disabled: hasFields, helpText: hasFields
540
+ const hasFields = Object.values(this.fieldStore).findIndex(field => field.role_name === this.roleName) !== -1;
541
+ return (h(Host, null, h("div", { class: "background-overlay", onClick: e => this.handleCancel(e) }, h("div", { class: "dialog" }, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("verdocs-text-input", { id: "verdocs-role-name", label: "Role Name", value: this.name, autocomplete: "off", disabled: hasFields, helpText: hasFields
536
542
  ? 'This role has fields assigned and can no longer be renamed.'
537
- : 'A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.', placeholder: "Template Name...", onInput: (e) => {
543
+ : 'A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.', placeholder: "Role Name...", onInput: (e) => {
538
544
  this.name = e.target.value;
539
545
  this.dirty = true;
540
546
  } }), h("div", { class: "row" }, h("div", { class: "input-label" }, "Type:"), h("verdocs-select-input", { value: this.type, options: [
@@ -544,8 +550,8 @@ const VerdocsTemplateRoleProperties = class {
544
550
  ], onInput: (e) => {
545
551
  this.type = e.target.value;
546
552
  this.dirty = true;
547
- } }), h("verdocs-help-icon", { text: "Most participants are Signers. CC roles are notified when documents are signed, but have no other actions. Approvers get notified when signing is completed to perform a final review." })), h("verdocs-text-input", { id: "verdocs-recipient-email", label: "Full Name", value: this.fullName, autocomplete: "off", helpText: "The recipient's full name, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template.", placeholder: "Full Name...", onInput: (e) => {
548
- this.fullName = e.target.value;
553
+ } }), h("verdocs-help-icon", { text: "Most participants are Signers. CC roles are notified when documents are signed, but have no other actions. Approvers get notified when signing is completed to perform a final review." })), h("verdocs-text-input", { id: "verdocs-recipient-email", label: "Full Name", value: this.full_name, autocomplete: "off", helpText: "The recipient's full name, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template.", placeholder: "Full Name...", onInput: (e) => {
554
+ this.full_name = e.target.value;
549
555
  this.dirty = true;
550
556
  } }), h("verdocs-text-input", { id: "verdocs-recipient-email", label: "Email", value: this.email, autocomplete: "off", helpText: "The recipient's email address, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template.", placeholder: "Email Address...", onInput: (e) => {
551
557
  this.email = e.target.value;
@@ -553,8 +559,8 @@ const VerdocsTemplateRoleProperties = class {
553
559
  } }), h("verdocs-text-input", { id: "verdocs-recipient-phone", label: "Phone", value: this.phone, autocomplete: "off", 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.", placeholder: "Phone Number...", onInput: (e) => {
554
560
  this.phone = e.target.value;
555
561
  this.dirty = true;
556
- } }), h("div", { class: "row" }, h("div", { class: "input-label" }, "May Delegate:"), h("div", { class: "checkbox-wrapper" }, h("verdocs-checkbox", { checked: this.allowDelegation, onInput: (e) => {
557
- this.allowDelegation = e.target.checked;
562
+ } }), h("div", { class: "row" }, h("div", { class: "input-label" }, "May Delegate:"), h("div", { class: "checkbox-wrapper" }, h("verdocs-checkbox", { checked: this.delegator, onInput: (e) => {
563
+ this.delegator = e.target.checked;
558
564
  this.dirty = true;
559
565
  } })), h("verdocs-help-icon", { text: "If enabled, this recipient may delegate their actions to another individual." })), h("div", { class: "buttons" }, h("button", { class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), h("div", { style: { flex: '1' } }), h("verdocs-button", { size: "small", variant: "outline", label: "Cancel", disabled: !this.dirty, onClick: e => this.handleCancel(e) }), h("verdocs-button", { size: "small", label: "Save", disabled: !this.dirty, onClick: e => this.handleSave(e) })))))));
560
566
  }
@@ -584,9 +590,9 @@ const VerdocsTemplateRoles = class {
584
590
  this.next = createEvent(this, "next", 7);
585
591
  this.exit = createEvent(this, "exit", 7);
586
592
  this.sdkError = createEvent(this, "sdkError", 7);
587
- this.templateUpdated = createEvent(this, "templateUpdated", 7);
588
- this.sequences = [];
589
- this.store = null;
593
+ this.rolesUpdated = createEvent(this, "rolesUpdated", 7);
594
+ this.templateStore = null;
595
+ this.roleStore = null;
590
596
  this.endpoint = VerdocsEndpoint.getDefault();
591
597
  this.templateId = '';
592
598
  this.showingRoleDialog = null;
@@ -605,18 +611,14 @@ const VerdocsTemplateRoles = class {
605
611
  console.log('[ROLES] Unable to start builder session, must be authenticated');
606
612
  return;
607
613
  }
608
- await this.reloadStore();
614
+ this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
615
+ this.roleStore = getTemplateRoleStore(this.templateId);
609
616
  }
610
617
  catch (e) {
611
618
  console.log('[FIELDS] Error with preview session', e);
612
619
  (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
613
620
  }
614
621
  }
615
- async reloadStore() {
616
- this.store = await getTemplateStore(this.endpoint, this.templateId, false);
617
- this.sortTemplateRoles();
618
- this.renumberTemplateRoles();
619
- }
620
622
  componentDidRender() {
621
623
  interact_min.dynamicDrop(true);
622
624
  interact_min('.recipient').draggable({
@@ -626,64 +628,45 @@ const VerdocsTemplateRoles = class {
626
628
  this.el.classList.add('dragging');
627
629
  }.bind(this),
628
630
  move: function handleMove(e) {
629
- const oldX = +(e.target.getAttribute('posX') || 0);
630
- const oldY = +(e.target.getAttribute('posY') || 0);
631
+ const oldX = +(e.target.getAttribute('dX') || 0);
632
+ const oldY = +(e.target.getAttribute('dY') || 0);
633
+ const sequence = +(e.target.dataset['sequence'] || 0);
631
634
  const newX = e.dx + oldX;
632
635
  const newY = e.dy + oldY;
633
- e.target.setAttribute('posX', newX);
634
- e.target.setAttribute('posy', newY);
635
- e.target.style.transform = `translate(${newX + 100}px, ${newY - 40}px)`;
636
+ e.target.setAttribute('dX', newX);
637
+ e.target.setAttribute('dY', newY);
638
+ const rect = e.target.getBoundingClientRect();
639
+ // Note: I never did figure out exactly why this is, but if we don't offset the transform
640
+ // the dragged item is offset from the mouse cursor quite a bit.
641
+ e.target.style.transform = `translate(${newX + 80}px, ${newY - rect.height * sequence}px)`;
636
642
  }.bind(this),
637
643
  end: function handleEnd(e) {
638
644
  e.target.classList.remove('dragging');
639
645
  this.el.classList.remove('dragging');
640
646
  // console.log('end', event);
641
- e.target.setAttribute('posX', 0);
642
- e.target.setAttribute('posy', 0);
643
- e.target.style.transform = `translate(0px, 0px)`;
647
+ e.target.removeAttribute('dX');
648
+ e.target.removeAttribute('dY');
649
+ e.target.style.transform = null;
644
650
  }.bind(this),
645
651
  },
646
652
  });
647
653
  interact_min('.dropzone').dropzone({
648
654
  overlap: 0.05,
649
- ondrop: function handleDrop(event) {
650
- var _a, _b, _c, _d, _e;
655
+ ondrop: async function handleDrop(event) {
656
+ var _a;
651
657
  event.target.classList.remove('active');
652
- // target will be the recipient e.g. <div class="recipient" data-rolename="Buyer" />
653
- // relatedTarget will be the drop zone, e.g. <div class="dropzone" data-order="2" data-sequence="1" />
654
- // console.log(event.relatedTarget, ' was dropped into ', event.target);
655
- // We don't use the role's own order, we rely on the fact that we sorted earlier on the order field. Many legacy
656
- // records don't have order fields yet - they're all 1. That doesn't hurt the sort but it would hurt us here if it
657
- // went 1..1..1 instead of 1..2..3. By using half values here it's easier to handle the drop event later. We don't
658
- // need to do a fancy find/arraymove dance. We just set the dropped element to the half value, sort the result,
659
- // then do a final renumber. It's not expensive to do because most flows are typically a small handful (e.g. 1-4)
660
- // recipients. They never have hundreds.
661
658
  const roleName = event.relatedTarget.dataset.rolename;
662
659
  const targetSequence = +event.target.dataset.sequence;
663
660
  const targetOrder = +event.target.dataset.order;
664
- const changingRole = (_c = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles) === null || _c === void 0 ? void 0 : _c.find(role => role.name === roleName);
661
+ const changingRole = this.roleStore.get(roleName);
665
662
  if (changingRole) {
666
663
  // To handle the renumbering, we update the role being moved to the new values, which will be some half-interval e.g.
667
- // sequence 1.5 order 1. Then we
668
- changingRole.sequence = targetSequence;
669
- changingRole.order = targetOrder;
670
- this.sortTemplateRoles();
671
- this.renumberTemplateRoles();
672
- this.forceRerender++;
673
- // We have to update ALL the roles to be sure each gets new proper sequence/order numbers assigned.
674
- // TODO: We could optimize this by tracking "dirty" states and only update the roles that have changed. But it's a LOT more
675
- // code to do right, and since most workflows will typically only have 2-4 recipients max, it may not be worth it.
676
- Promise.all((_e = (_d = this.store) === null || _d === void 0 ? void 0 : _d.state) === null || _e === void 0 ? void 0 : _e.roles.map(role => updateRole(this.endpoint, this.templateId, role.name, {
677
- sequence: role.sequence,
678
- order: role.order,
679
- })))
680
- .then(() => {
681
- var _a, _b;
682
- console.log('[ROLES] Updated roles');
683
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'updated-role', endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state });
684
- this.reloadStore().catch(e => console.log('Unknown error', e));
685
- })
686
- .catch(e => console.log('[ROLES] Role updates failed', e));
664
+ // sequence 1.5 order 1. Then we sort/renumber the roles at each level to determine their final ordering values.
665
+ const newRole = { ...changingRole, sequence: targetSequence, order: targetOrder };
666
+ this.roleStore.set(changingRole.name, newRole);
667
+ await this.renumberTemplateRoles();
668
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
669
+ console.log('[ROLES] Updated roles', this.getSortedRoles());
687
670
  }
688
671
  }.bind(this),
689
672
  ondropactivate: e => {
@@ -708,50 +691,60 @@ const VerdocsTemplateRoles = class {
708
691
  var _a;
709
692
  (_a = this.next) === null || _a === void 0 ? void 0 : _a.emit();
710
693
  }
711
- sortTemplateRoles() {
712
- var _a, _b;
713
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.sort((a, b) => {
694
+ getSortedRoles() {
695
+ return Object.values(this.roleStore.state)
696
+ .filter(role => role !== undefined)
697
+ .sort((a, b) => {
714
698
  return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;
715
699
  });
716
700
  }
717
- extractSequenceNumbers() {
718
- var _a, _b;
719
- this.sequences = [];
720
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.forEach(role => {
721
- if (!this.sequences.includes(role.sequence)) {
722
- this.sequences.push(role.sequence);
701
+ getSequenceNumbers() {
702
+ const sequences = [];
703
+ this.getSortedRoles().forEach(role => {
704
+ if (!sequences.includes(role.sequence)) {
705
+ sequences.push(role.sequence);
723
706
  }
724
707
  });
708
+ return sequences.sort((a, b) => a - b);
709
+ }
710
+ getRoleNames() {
711
+ const roles = this.getSortedRoles();
712
+ return roles.map(role => role.name);
713
+ }
714
+ getRolesAtSequence(sequence) {
715
+ // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
716
+ // See https://github.com/ionic-team/stencil-store/issues/23
717
+ return Object.values(this.roleStore.state).filter(role => role && role.sequence === sequence);
725
718
  }
719
+ // When the user drags a role around, we handle placement "between" items by assigning it a half-order number
720
+ // 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.
721
+ // Then we re-sort the list of roles and renumber them.
726
722
  renumberTemplateRoles() {
727
- // Extract the sequence numbers because they may now be something like [2.5, 1, 2]
728
- this.extractSequenceNumbers();
729
- // We need to renumber each role only ONE TIME
723
+ // Avoid dupe renumber attempts
730
724
  const renumbered = [];
731
725
  // If the user dragged an entry from below a row to above it, we end up here like [1,0]. Make sure it's [0,1] for the next operation.
732
- this.sequences.sort((a, b) => a - b);
733
- this.sequences.forEach((originalSequence, newSequenceIndex) => {
734
- var _a, _b;
735
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.filter(role => role.sequence === originalSequence).forEach((role, newOrderIndex) => {
726
+ const renumberRequests = [];
727
+ this.getSequenceNumbers().forEach((originalSequence, newSequenceIndex) => {
728
+ this.getRolesAtSequence(originalSequence).forEach((role, newOrderIndex) => {
736
729
  if (!renumbered.includes(role.name)) {
737
730
  role.sequence = newSequenceIndex + 1;
738
731
  role.order = newOrderIndex + 1;
739
732
  renumbered.push(role.name);
733
+ renumberRequests.push(updateRole(this.endpoint, this.templateId, role.name, { sequence: role.sequence, order: role.order }));
740
734
  }
741
735
  });
742
736
  });
743
- // Now re-extract them to get our final result e.g. [1, 2, 3]
744
- this.extractSequenceNumbers();
737
+ return Promise.all(renumberRequests);
745
738
  }
746
739
  // Look for name conflicts, because they're UGC and can be anything, regardless of order.
747
740
  getNextRoleName() {
748
- var _a, _b, _c, _d;
741
+ var _a;
749
742
  let name = '';
750
- let nextNumber = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.length;
743
+ let nextNumber = Object.keys(this.roleStore).length;
751
744
  do {
752
745
  nextNumber++;
753
746
  name = `Recipient ${nextNumber}`;
754
- } while (!name || ((_d = (_c = this.store) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.roles.some(role => role.name === name)));
747
+ } while (!name || Object.values((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.state).some(role => role && role.name === name));
755
748
  return name;
756
749
  }
757
750
  callCreateRole(name, sequence, order) {
@@ -768,25 +761,19 @@ const VerdocsTemplateRoles = class {
768
761
  delegator: false,
769
762
  })
770
763
  .then(async (r) => {
771
- var _a, _b;
764
+ var _a;
772
765
  console.log('[ROLES] Created role', r);
773
- this.store = await getTemplateStore(this.endpoint, this.templateId, false);
774
- this.sortTemplateRoles();
775
- this.renumberTemplateRoles();
776
- // this.store.state.roles = [...this.store?.state.roles, r];
777
- // this.renumberTemplateRoles();
778
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'created-role', endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state });
779
- this.reloadStore().catch(e => console.log('Unknown error', e));
766
+ this.roleStore.set(r.name, r);
767
+ await this.renumberTemplateRoles();
768
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
780
769
  })
781
770
  .catch(e => {
782
771
  console.log('[ROLES] Error creating role', e);
783
772
  });
784
773
  }
785
774
  handleAddRole(e, sequence) {
786
- var _a;
787
775
  e.stopPropagation();
788
- // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
789
- const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
776
+ const order = this.getRolesAtSequence(sequence).length + 1;
790
777
  const name = this.getNextRoleName();
791
778
  this.callCreateRole(name, sequence, order);
792
779
  }
@@ -797,33 +784,25 @@ const VerdocsTemplateRoles = class {
797
784
  this.callCreateRole(name, sequence, order);
798
785
  }
799
786
  render() {
800
- var _a, _b, _c, _d, _e, _f;
801
- console.log('[ROLES] Rendering');
787
+ var _a, _b, _c;
802
788
  if (!this.endpoint.session) {
803
789
  return (h(Host, null, h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
804
790
  }
805
- if (!((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
791
+ if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
806
792
  return (h(Host, { class: "loading" }, h("verdocs-loader", null)));
807
793
  }
808
- const roleNames = (((_c = (_b = this.store) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.roles) || []).map(role => role.name);
809
- return (h(Host, null, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off", "data-r": (_d = this.store.state) === null || _d === void 0 ? void 0 : _d.updateCount }, h("h5", null, "Roles and Workflow"), h("div", { class: "participants" }, h("div", { class: "left-line" }), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: startIcon }), h("div", { class: "row-roles" }, h("div", { class: "sender" }, h("span", { class: "label" }, "Sender:"), " ", senderLabels[(_f = (_e = this.store) === null || _e === void 0 ? void 0 : _e.state) === null || _f === void 0 ? void 0 : _f.sender], ' ', h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingSenderDialog = true), "aria-role": "button" })))), h("div", { class: "row add-sequence", "data-sequence": 0 }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "row-roles" }, h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), this.sequences.map(sequence => {
810
- var _a, _b;
811
- return (h(Fragment, null, h("div", { class: "row" }, h("div", { class: "icon", innerHTML: stepIcon }), h("div", { class: "row-roles" }, h("div", { class: "dropzone", "data-order": 0.5, "data-sequence": sequence }), (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 :
812
- _b.roles.filter(role => role.sequence === sequence).map(role => {
813
- const unknown = !role.email;
814
- return unknown ? (h(Fragment, null, h("div", { class: "recipient", style: { backgroundColor: getRGBA(getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name }, h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence }))) : (h(Fragment, null, h("div", { class: "recipient", style: { borderColor: getRGBA(getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name }, h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.full_name, " ", h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
815
- }), h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), this.sequences.length > 0 && (h("div", { class: "row add-sequence", "data-sequence": sequence }, h("div", { class: "row-roles" }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step"))))));
816
- }), h("div", { class: "row", "data-sequence": this.sequences.length + 1 }, h("div", { class: "row-roles" }, h("div", { class: "icon", innerHTML: plusIcon }), h("button", { class: "add-step", innerHTML: plusIcon, onClick: e => this.handleAddStep(e, this.sequences.length + 1) }))), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: doneIcon }), h("div", { class: "row-roles" }, h("div", { class: "complete" }, "Document Complete")))), 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-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
794
+ const roleNames = this.getRoleNames();
795
+ const sequences = this.getSequenceNumbers();
796
+ return (h(Host, null, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("h5", null, "Roles and Workflow"), h("div", { class: "participants" }, h("div", { class: "left-line" }), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: startIcon }), h("div", { class: "row-roles" }, h("div", { class: "sender" }, h("span", { class: "label" }, "Sender:"), " ", senderLabels[(_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.sender], ' ', h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingSenderDialog = true), "aria-role": "button" })))), h("div", { class: "row add-sequence", "data-sequence": 0 }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "row-roles" }, h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), sequences.map(sequence => (h(Fragment, null, h("div", { class: "row" }, h("div", { class: "icon", innerHTML: stepIcon }), h("div", { class: "row-roles" }, h("div", { class: "dropzone", "data-order": 0.5, "data-sequence": sequence }), this.getRolesAtSequence(sequence).map(role => {
797
+ const unknown = !role.email;
798
+ return unknown ? (h(Fragment, null, h("div", { class: "recipient", style: { backgroundColor: getRGBA(getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name, "data-sequence": sequence }, h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence }))) : (h(Fragment, null, h("div", { class: "recipient", style: { borderColor: getRGBA(getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name, "data-sequence": sequence }, h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.full_name, " ", h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
799
+ }), h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), sequences.length > 0 && (h("div", { class: "row add-sequence", "data-sequence": sequence }, h("div", { class: "row-roles" }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step"))))))), h("div", { class: "row", "data-sequence": sequences.length + 1 }, h("div", { class: "row-roles" }, h("div", { class: "icon", innerHTML: plusIcon }), h("button", { class: "add-step", innerHTML: plusIcon, onClick: e => this.handleAddStep(e, sequences.length + 1) }))), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: doneIcon }), h("div", { class: "row-roles" }, h("div", { class: "complete" }, "Document Complete")))), 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-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
817
800
  this.showingRoleDialog = null;
818
- // this.forceRerender++;
819
801
  }, onDelete: async () => {
820
- var _a, _b;
821
- await getTemplateStore(this.endpoint, this.templateId, false);
822
- this.renumberTemplateRoles();
802
+ var _a;
823
803
  this.showingRoleDialog = null;
824
- // this.forceRerender++;
825
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'deleted-role', endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state });
826
- this.reloadStore().catch(e => console.log('Unknown error', e));
804
+ await this.renumberTemplateRoles();
805
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
827
806
  } })), this.showingSenderDialog && h("verdocs-template-sender", { endpoint: this.endpoint, templateId: this.templateId, onClose: () => (this.showingSenderDialog = false) })));
828
807
  }
829
808
  get el() { return getElement(this); }