@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
@@ -9,8 +9,8 @@ const VerdocsEndpoint = require('./VerdocsEndpoint-8f298664.js');
9
9
  const Fields = require('./Fields-705a2168.js');
10
10
  const Primitives = require('./Primitives-a59870a2.js');
11
11
  const utils = require('./utils-aeaf4a31.js');
12
+ const TemplateStore = require('./TemplateStore-079a1f85.js');
12
13
  const TemplateFieldStore = require('./TemplateFieldStore-40e85b9d.js');
13
- const TemplateStore = require('./TemplateStore-6a75cdac.js');
14
14
  const errors = require('./errors-0396da3d.js');
15
15
  const Colors = require('./Colors-e809dcc9.js');
16
16
  require('./_commonjsHelpers-1fbbf0eb.js');
@@ -79,6 +79,7 @@ const VerdocsTemplateFields = class {
79
79
  this.pageHeights = {};
80
80
  this.templateStore = null;
81
81
  this.fieldStore = null;
82
+ this.roleStore = null;
82
83
  this.cachedPageInfo = {};
83
84
  this.endpoint = VerdocsEndpoint.VerdocsEndpoint.getDefault();
84
85
  this.templateId = null;
@@ -100,7 +101,8 @@ const VerdocsTemplateFields = class {
100
101
  return;
101
102
  }
102
103
  this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
103
- this.fieldStore = TemplateFieldStore.createTemplateFieldStore(this.templateStore.state);
104
+ this.fieldStore = TemplateFieldStore.getTemplateFieldStore(this.templateId);
105
+ this.roleStore = TemplateStore.getTemplateRoleStore(this.templateId);
104
106
  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) || '';
105
107
  }
106
108
  catch (e) {
@@ -119,10 +121,10 @@ const VerdocsTemplateFields = class {
119
121
  }
120
122
  }
121
123
  componentWillUpdate() {
122
- var _a, _b, _c, _d, _e, _f;
124
+ var _a, _b, _c, _d;
123
125
  // If a new role was added and there were none yet so far, or the "selected" role was deleted, reset our selection
124
- 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)) {
125
- 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) || '';
126
+ if (!this.selectedRoleName || !Object.values(this.roleStore).find(role => role && role.name === this.selectedRoleName)) {
127
+ 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) || '';
126
128
  console.log('[FIELDS] Selected new role', this.selectedRoleName);
127
129
  }
128
130
  }
@@ -181,7 +183,9 @@ const VerdocsTemplateFields = class {
181
183
  // console.log('[FIELDS] Page rendered', pageInfo.pageNumber, pageInfo);
182
184
  this.cachedPageInfo[pageInfo.pageNumber] = pageInfo;
183
185
  this.pageHeights[pageInfo.pageNumber] = pageInfo.naturalHeight;
184
- const fields = Object.values(this.fieldStore.state).filter((field) => field.page_sequence === pageInfo.pageNumber);
186
+ // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
187
+ // See https://github.com/ionic-team/stencil-store/issues/23
188
+ const fields = Object.values(this.fieldStore.state).filter((field) => field && field.page_sequence === pageInfo.pageNumber);
185
189
  console.log('[FIELDS] Page rendered', pageInfo, fields);
186
190
  fields.forEach((field) => this.reRenderField(field, pageInfo.pageNumber));
187
191
  }
@@ -279,7 +283,7 @@ const VerdocsTemplateFields = class {
279
283
  do {
280
284
  fieldName = `${type}P${pageNumber}-${i}`;
281
285
  i++;
282
- } while (Object.values(this.fieldStore.state).some(field => field.name === fieldName));
286
+ } while (Object.values(this.fieldStore.state).some(field => field && field.name === fieldName));
283
287
  return fieldName;
284
288
  }
285
289
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.
@@ -391,7 +395,7 @@ const VerdocsTemplateFields = class {
391
395
  }
392
396
  }
393
397
  render() {
394
- var _a, _b, _c, _d, _e, _f, _g, _h;
398
+ var _a, _b, _c;
395
399
  if (!this.endpoint.session) {
396
400
  return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
397
401
  }
@@ -399,7 +403,9 @@ const VerdocsTemplateFields = class {
399
403
  if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
400
404
  return (index.h(index.Host, null, index.h("verdocs-loader", null)));
401
405
  }
402
- 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 }));
406
+ const selectableRoles = Object.values(this.roleStore)
407
+ .filter(role => role !== undefined)
408
+ .map(role => ({ value: role.name, label: role.name }));
403
409
  return (index.h(index.Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, index.h("div", { id: "verdocs-template-fields-toolbar" }, index.h("div", { class: "add-for" }, "Add field:"), index.h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (index.h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, onClick: () => {
404
410
  // We ignore empty-tooltip entries because they're separators
405
411
  if (option.tooltip) {
@@ -411,13 +417,13 @@ const VerdocsTemplateFields = class {
411
417
  this.showMustSelectRole = true;
412
418
  }
413
419
  }
414
- } })))), index.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 => {
420
+ } })))), index.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 => {
415
421
  const pageNumbers = Primitives.integerSequence(1, document.page_numbers);
416
422
  return pageNumbers.map(page => (index.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: [
417
423
  { name: 'page', type: 'canvas' },
418
424
  { name: 'controls', type: 'div' },
419
425
  ] })));
420
- })), this.showMustSelectRole && (index.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) }))));
426
+ })), this.showMustSelectRole && (index.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) }))));
421
427
  }
422
428
  };
423
429
  VerdocsTemplateFields.style = verdocsTemplateFieldsCss;
@@ -431,7 +437,9 @@ const VerdocsTemplateRoleProperties = class {
431
437
  this.close = index.createEvent(this, "close", 7);
432
438
  this.delete = index.createEvent(this, "delete", 7);
433
439
  this.sdkError = index.createEvent(this, "sdkError", 7);
434
- this.store = null;
440
+ this.templateStore = null;
441
+ this.fieldStore = null;
442
+ this.roleStore = null;
435
443
  this.endpoint = VerdocsEndpoint.VerdocsEndpoint.getDefault();
436
444
  this.templateId = '';
437
445
  this.roleName = '';
@@ -440,13 +448,13 @@ const VerdocsTemplateRoleProperties = class {
440
448
  this.saving = false;
441
449
  this.name = '';
442
450
  this.type = 'signer';
443
- this.fullName = '';
451
+ this.full_name = '';
444
452
  this.email = '';
445
453
  this.phone = '';
446
- this.allowDelegation = false;
454
+ this.delegator = false;
447
455
  }
448
456
  async componentWillLoad() {
449
- var _a, _b, _c, _d, _e;
457
+ var _a, _b, _c;
450
458
  try {
451
459
  this.endpoint.loadSession();
452
460
  if (!this.templateId) {
@@ -457,29 +465,39 @@ const VerdocsTemplateRoleProperties = class {
457
465
  console.log('[ROLE_PROPERTIES] Unable to start builder session, must be authenticated');
458
466
  return;
459
467
  }
460
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
461
- 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);
468
+ this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
469
+ this.fieldStore = TemplateFieldStore.getTemplateFieldStore(this.templateId);
470
+ this.roleStore = TemplateStore.createTemplateRoleStore(this.templateStore.state);
471
+ const editingRole = this.roleStore.get(this.roleName);
462
472
  if (editingRole) {
463
473
  this.name = editingRole.name;
464
474
  this.type = editingRole.type;
465
- this.fullName = editingRole.full_name;
475
+ this.full_name = editingRole.full_name;
466
476
  this.email = editingRole.email;
467
477
  this.phone = editingRole.phone;
468
- this.allowDelegation = editingRole.delegator;
469
- console.log('[ROLES] Editing role', editingRole);
478
+ this.delegator = editingRole.delegator;
479
+ console.log('[ROLE_PROPERTIES] Editing role', editingRole);
470
480
  }
471
481
  }
472
482
  catch (e) {
473
- console.log('[TEMPLATE ROLE PROPERTIES] Error with preview session', e);
474
- (_c = this.sdkError) === null || _c === void 0 ? void 0 : _c.emit(new errors.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));
483
+ console.log('[ROLE_PROPERTIES Error with preview session', e);
484
+ (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.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));
475
485
  }
476
486
  }
477
487
  handleCancel(e) {
478
- var _a, _b, _c;
488
+ var _a;
479
489
  e.stopPropagation();
480
- this.name = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.name;
490
+ const editingRole = this.roleStore.get(this.roleName);
491
+ if (editingRole) {
492
+ this.name = editingRole.name;
493
+ this.type = editingRole.type;
494
+ this.full_name = editingRole.full_name;
495
+ this.email = editingRole.email;
496
+ this.phone = editingRole.phone;
497
+ this.delegator = editingRole.delegator;
498
+ }
481
499
  this.dirty = false;
482
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
500
+ (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
483
501
  }
484
502
  async handleSave(e) {
485
503
  e.stopPropagation();
@@ -487,35 +505,24 @@ const VerdocsTemplateRoleProperties = class {
487
505
  updateRole(this.endpoint, this.templateId, this.roleName, {
488
506
  name: this.name,
489
507
  type: this.type,
490
- full_name: this.fullName,
508
+ full_name: this.full_name,
491
509
  email: this.email,
492
510
  phone: this.phone,
493
- delegator: this.allowDelegation,
511
+ delegator: this.delegator,
494
512
  })
495
513
  .then(async (r) => {
496
514
  var _a;
497
515
  console.log('[ROLE_PROPERTIES] Update result', r);
498
516
  this.saving = false;
499
517
  this.dirty = false;
500
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
501
- // this.sortTemplateRoles();
502
- // this.renumberTemplateRoles();
503
- // const newRoles = [...this.store.state.roles];
504
- // newRoles.forEach(role => {
505
- // if (role.name === this.roleName) {
506
- // role.name = this.name;
507
- // role.type = this.type;
508
- // role.full_name = this.fullName;
509
- // role.email = this.email;
510
- // role.phone = this.phone;
511
- // role.delegator = this.allowDelegation;
512
- // }
513
- // });
514
- // this.store.state.roles = newRoles;
518
+ this.roleStore.set(r.name, r);
519
+ if (this.roleName !== r.name) {
520
+ this.roleStore.set(this.roleName, undefined);
521
+ }
515
522
  (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
516
523
  })
517
524
  .catch(e => {
518
- console.log('Update error', e);
525
+ console.log('[ROLE_PROPERTIES Update error', e);
519
526
  this.saving = false;
520
527
  });
521
528
  }
@@ -525,20 +532,19 @@ const VerdocsTemplateRoleProperties = class {
525
532
  deleteRole(this.endpoint, this.templateId, this.roleName)
526
533
  .then(r => {
527
534
  var _a;
528
- console.log('Role deleted', r);
529
- this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
535
+ delete this.roleStore.state[r.name];
530
536
  (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
531
537
  })
532
538
  .catch(e => {
533
- console.log('Deletion error', e);
539
+ console.log('[ROLE_PROPERTIES Deletion error', e);
534
540
  });
535
541
  }
536
542
  }
537
543
  render() {
538
- const hasFields = (this.store.state.fields || []).findIndex(field => field.role_name === this.roleName) !== -1;
539
- return (index.h(index.Host, null, index.h("div", { class: "background-overlay", onClick: e => this.handleCancel(e) }, index.h("div", { class: "dialog" }, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("verdocs-text-input", { id: "verdocs-recipient-name", label: "Role Name", value: this.name, autocomplete: "off", disabled: hasFields, helpText: hasFields
544
+ const hasFields = Object.values(this.fieldStore).findIndex(field => field.role_name === this.roleName) !== -1;
545
+ return (index.h(index.Host, null, index.h("div", { class: "background-overlay", onClick: e => this.handleCancel(e) }, index.h("div", { class: "dialog" }, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("verdocs-text-input", { id: "verdocs-role-name", label: "Role Name", value: this.name, autocomplete: "off", disabled: hasFields, helpText: hasFields
540
546
  ? 'This role has fields assigned and can no longer be renamed.'
541
- : 'A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.', placeholder: "Template Name...", onInput: (e) => {
547
+ : 'A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.', placeholder: "Role Name...", onInput: (e) => {
542
548
  this.name = e.target.value;
543
549
  this.dirty = true;
544
550
  } }), index.h("div", { class: "row" }, index.h("div", { class: "input-label" }, "Type:"), index.h("verdocs-select-input", { value: this.type, options: [
@@ -548,8 +554,8 @@ const VerdocsTemplateRoleProperties = class {
548
554
  ], onInput: (e) => {
549
555
  this.type = e.target.value;
550
556
  this.dirty = true;
551
- } }), index.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." })), index.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) => {
552
- this.fullName = e.target.value;
557
+ } }), index.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." })), index.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) => {
558
+ this.full_name = e.target.value;
553
559
  this.dirty = true;
554
560
  } }), index.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) => {
555
561
  this.email = e.target.value;
@@ -557,8 +563,8 @@ const VerdocsTemplateRoleProperties = class {
557
563
  } }), index.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) => {
558
564
  this.phone = e.target.value;
559
565
  this.dirty = true;
560
- } }), index.h("div", { class: "row" }, index.h("div", { class: "input-label" }, "May Delegate:"), index.h("div", { class: "checkbox-wrapper" }, index.h("verdocs-checkbox", { checked: this.allowDelegation, onInput: (e) => {
561
- this.allowDelegation = e.target.checked;
566
+ } }), index.h("div", { class: "row" }, index.h("div", { class: "input-label" }, "May Delegate:"), index.h("div", { class: "checkbox-wrapper" }, index.h("verdocs-checkbox", { checked: this.delegator, onInput: (e) => {
567
+ this.delegator = e.target.checked;
562
568
  this.dirty = true;
563
569
  } })), index.h("verdocs-help-icon", { text: "If enabled, this recipient may delegate their actions to another individual." })), index.h("div", { class: "buttons" }, index.h("button", { class: "delete-button", disabled: this.dirty, onClick: e => this.handleDelete(e), innerHTML: TrashIcon }), index.h("div", { style: { flex: '1' } }), index.h("verdocs-button", { size: "small", variant: "outline", label: "Cancel", disabled: !this.dirty, onClick: e => this.handleCancel(e) }), index.h("verdocs-button", { size: "small", label: "Save", disabled: !this.dirty, onClick: e => this.handleSave(e) })))))));
564
570
  }
@@ -588,9 +594,9 @@ const VerdocsTemplateRoles = class {
588
594
  this.next = index.createEvent(this, "next", 7);
589
595
  this.exit = index.createEvent(this, "exit", 7);
590
596
  this.sdkError = index.createEvent(this, "sdkError", 7);
591
- this.templateUpdated = index.createEvent(this, "templateUpdated", 7);
592
- this.sequences = [];
593
- this.store = null;
597
+ this.rolesUpdated = index.createEvent(this, "rolesUpdated", 7);
598
+ this.templateStore = null;
599
+ this.roleStore = null;
594
600
  this.endpoint = VerdocsEndpoint.VerdocsEndpoint.getDefault();
595
601
  this.templateId = '';
596
602
  this.showingRoleDialog = null;
@@ -609,18 +615,14 @@ const VerdocsTemplateRoles = class {
609
615
  console.log('[ROLES] Unable to start builder session, must be authenticated');
610
616
  return;
611
617
  }
612
- await this.reloadStore();
618
+ this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
619
+ this.roleStore = TemplateStore.getTemplateRoleStore(this.templateId);
613
620
  }
614
621
  catch (e) {
615
622
  console.log('[FIELDS] Error with preview session', e);
616
623
  (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.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));
617
624
  }
618
625
  }
619
- async reloadStore() {
620
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
621
- this.sortTemplateRoles();
622
- this.renumberTemplateRoles();
623
- }
624
626
  componentDidRender() {
625
627
  interact_min.interact_min.dynamicDrop(true);
626
628
  interact_min.interact_min('.recipient').draggable({
@@ -630,64 +632,45 @@ const VerdocsTemplateRoles = class {
630
632
  this.el.classList.add('dragging');
631
633
  }.bind(this),
632
634
  move: function handleMove(e) {
633
- const oldX = +(e.target.getAttribute('posX') || 0);
634
- const oldY = +(e.target.getAttribute('posY') || 0);
635
+ const oldX = +(e.target.getAttribute('dX') || 0);
636
+ const oldY = +(e.target.getAttribute('dY') || 0);
637
+ const sequence = +(e.target.dataset['sequence'] || 0);
635
638
  const newX = e.dx + oldX;
636
639
  const newY = e.dy + oldY;
637
- e.target.setAttribute('posX', newX);
638
- e.target.setAttribute('posy', newY);
639
- e.target.style.transform = `translate(${newX + 100}px, ${newY - 40}px)`;
640
+ e.target.setAttribute('dX', newX);
641
+ e.target.setAttribute('dY', newY);
642
+ const rect = e.target.getBoundingClientRect();
643
+ // Note: I never did figure out exactly why this is, but if we don't offset the transform
644
+ // the dragged item is offset from the mouse cursor quite a bit.
645
+ e.target.style.transform = `translate(${newX + 80}px, ${newY - rect.height * sequence}px)`;
640
646
  }.bind(this),
641
647
  end: function handleEnd(e) {
642
648
  e.target.classList.remove('dragging');
643
649
  this.el.classList.remove('dragging');
644
650
  // console.log('end', event);
645
- e.target.setAttribute('posX', 0);
646
- e.target.setAttribute('posy', 0);
647
- e.target.style.transform = `translate(0px, 0px)`;
651
+ e.target.removeAttribute('dX');
652
+ e.target.removeAttribute('dY');
653
+ e.target.style.transform = null;
648
654
  }.bind(this),
649
655
  },
650
656
  });
651
657
  interact_min.interact_min('.dropzone').dropzone({
652
658
  overlap: 0.05,
653
- ondrop: function handleDrop(event) {
654
- var _a, _b, _c, _d, _e;
659
+ ondrop: async function handleDrop(event) {
660
+ var _a;
655
661
  event.target.classList.remove('active');
656
- // target will be the recipient e.g. <div class="recipient" data-rolename="Buyer" />
657
- // relatedTarget will be the drop zone, e.g. <div class="dropzone" data-order="2" data-sequence="1" />
658
- // console.log(event.relatedTarget, ' was dropped into ', event.target);
659
- // We don't use the role's own order, we rely on the fact that we sorted earlier on the order field. Many legacy
660
- // 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
661
- // 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
662
- // need to do a fancy find/arraymove dance. We just set the dropped element to the half value, sort the result,
663
- // then do a final renumber. It's not expensive to do because most flows are typically a small handful (e.g. 1-4)
664
- // recipients. They never have hundreds.
665
662
  const roleName = event.relatedTarget.dataset.rolename;
666
663
  const targetSequence = +event.target.dataset.sequence;
667
664
  const targetOrder = +event.target.dataset.order;
668
- 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);
665
+ const changingRole = this.roleStore.get(roleName);
669
666
  if (changingRole) {
670
667
  // To handle the renumbering, we update the role being moved to the new values, which will be some half-interval e.g.
671
- // sequence 1.5 order 1. Then we
672
- changingRole.sequence = targetSequence;
673
- changingRole.order = targetOrder;
674
- this.sortTemplateRoles();
675
- this.renumberTemplateRoles();
676
- this.forceRerender++;
677
- // We have to update ALL the roles to be sure each gets new proper sequence/order numbers assigned.
678
- // TODO: We could optimize this by tracking "dirty" states and only update the roles that have changed. But it's a LOT more
679
- // code to do right, and since most workflows will typically only have 2-4 recipients max, it may not be worth it.
680
- 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, {
681
- sequence: role.sequence,
682
- order: role.order,
683
- })))
684
- .then(() => {
685
- var _a, _b;
686
- console.log('[ROLES] Updated roles');
687
- (_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 });
688
- this.reloadStore().catch(e => console.log('Unknown error', e));
689
- })
690
- .catch(e => console.log('[ROLES] Role updates failed', e));
668
+ // sequence 1.5 order 1. Then we sort/renumber the roles at each level to determine their final ordering values.
669
+ const newRole = { ...changingRole, sequence: targetSequence, order: targetOrder };
670
+ this.roleStore.set(changingRole.name, newRole);
671
+ await this.renumberTemplateRoles();
672
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
673
+ console.log('[ROLES] Updated roles', this.getSortedRoles());
691
674
  }
692
675
  }.bind(this),
693
676
  ondropactivate: e => {
@@ -712,50 +695,60 @@ const VerdocsTemplateRoles = class {
712
695
  var _a;
713
696
  (_a = this.next) === null || _a === void 0 ? void 0 : _a.emit();
714
697
  }
715
- sortTemplateRoles() {
716
- var _a, _b;
717
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.sort((a, b) => {
698
+ getSortedRoles() {
699
+ return Object.values(this.roleStore.state)
700
+ .filter(role => role !== undefined)
701
+ .sort((a, b) => {
718
702
  return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;
719
703
  });
720
704
  }
721
- extractSequenceNumbers() {
722
- var _a, _b;
723
- this.sequences = [];
724
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.forEach(role => {
725
- if (!this.sequences.includes(role.sequence)) {
726
- this.sequences.push(role.sequence);
705
+ getSequenceNumbers() {
706
+ const sequences = [];
707
+ this.getSortedRoles().forEach(role => {
708
+ if (!sequences.includes(role.sequence)) {
709
+ sequences.push(role.sequence);
727
710
  }
728
711
  });
712
+ return sequences.sort((a, b) => a - b);
713
+ }
714
+ getRoleNames() {
715
+ const roles = this.getSortedRoles();
716
+ return roles.map(role => role.name);
717
+ }
718
+ getRolesAtSequence(sequence) {
719
+ // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
720
+ // See https://github.com/ionic-team/stencil-store/issues/23
721
+ return Object.values(this.roleStore.state).filter(role => role && role.sequence === sequence);
729
722
  }
723
+ // When the user drags a role around, we handle placement "between" items by assigning it a half-order number
724
+ // 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.
725
+ // Then we re-sort the list of roles and renumber them.
730
726
  renumberTemplateRoles() {
731
- // Extract the sequence numbers because they may now be something like [2.5, 1, 2]
732
- this.extractSequenceNumbers();
733
- // We need to renumber each role only ONE TIME
727
+ // Avoid dupe renumber attempts
734
728
  const renumbered = [];
735
729
  // 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.
736
- this.sequences.sort((a, b) => a - b);
737
- this.sequences.forEach((originalSequence, newSequenceIndex) => {
738
- var _a, _b;
739
- (_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) => {
730
+ const renumberRequests = [];
731
+ this.getSequenceNumbers().forEach((originalSequence, newSequenceIndex) => {
732
+ this.getRolesAtSequence(originalSequence).forEach((role, newOrderIndex) => {
740
733
  if (!renumbered.includes(role.name)) {
741
734
  role.sequence = newSequenceIndex + 1;
742
735
  role.order = newOrderIndex + 1;
743
736
  renumbered.push(role.name);
737
+ renumberRequests.push(updateRole(this.endpoint, this.templateId, role.name, { sequence: role.sequence, order: role.order }));
744
738
  }
745
739
  });
746
740
  });
747
- // Now re-extract them to get our final result e.g. [1, 2, 3]
748
- this.extractSequenceNumbers();
741
+ return Promise.all(renumberRequests);
749
742
  }
750
743
  // Look for name conflicts, because they're UGC and can be anything, regardless of order.
751
744
  getNextRoleName() {
752
- var _a, _b, _c, _d;
745
+ var _a;
753
746
  let name = '';
754
- let nextNumber = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.length;
747
+ let nextNumber = Object.keys(this.roleStore).length;
755
748
  do {
756
749
  nextNumber++;
757
750
  name = `Recipient ${nextNumber}`;
758
- } 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)));
751
+ } while (!name || Object.values((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.state).some(role => role && role.name === name));
759
752
  return name;
760
753
  }
761
754
  callCreateRole(name, sequence, order) {
@@ -772,25 +765,19 @@ const VerdocsTemplateRoles = class {
772
765
  delegator: false,
773
766
  })
774
767
  .then(async (r) => {
775
- var _a, _b;
768
+ var _a;
776
769
  console.log('[ROLES] Created role', r);
777
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
778
- this.sortTemplateRoles();
779
- this.renumberTemplateRoles();
780
- // this.store.state.roles = [...this.store?.state.roles, r];
781
- // this.renumberTemplateRoles();
782
- (_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 });
783
- this.reloadStore().catch(e => console.log('Unknown error', e));
770
+ this.roleStore.set(r.name, r);
771
+ await this.renumberTemplateRoles();
772
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
784
773
  })
785
774
  .catch(e => {
786
775
  console.log('[ROLES] Error creating role', e);
787
776
  });
788
777
  }
789
778
  handleAddRole(e, sequence) {
790
- var _a;
791
779
  e.stopPropagation();
792
- // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
793
- const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
780
+ const order = this.getRolesAtSequence(sequence).length + 1;
794
781
  const name = this.getNextRoleName();
795
782
  this.callCreateRole(name, sequence, order);
796
783
  }
@@ -801,33 +788,25 @@ const VerdocsTemplateRoles = class {
801
788
  this.callCreateRole(name, sequence, order);
802
789
  }
803
790
  render() {
804
- var _a, _b, _c, _d, _e, _f;
805
- console.log('[ROLES] Rendering');
791
+ var _a, _b, _c;
806
792
  if (!this.endpoint.session) {
807
793
  return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
808
794
  }
809
- if (!((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
795
+ if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
810
796
  return (index.h(index.Host, { class: "loading" }, index.h("verdocs-loader", null)));
811
797
  }
812
- 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);
813
- return (index.h(index.Host, null, index.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 }, index.h("h5", null, "Roles and Workflow"), index.h("div", { class: "participants" }, index.h("div", { class: "left-line" }), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: startIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "sender" }, index.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], ' ', index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingSenderDialog = true), "aria-role": "button" })))), index.h("div", { class: "row add-sequence", "data-sequence": 0 }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), this.sequences.map(sequence => {
814
- var _a, _b;
815
- return (index.h(index.Fragment, null, index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: stepIcon }), index.h("div", { class: "row-roles" }, index.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 :
816
- _b.roles.filter(role => role.sequence === sequence).map(role => {
817
- const unknown = !role.email;
818
- return unknown ? (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { backgroundColor: Colors.getRGBA(utils.getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence }))) : (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { borderColor: Colors.getRGBA(utils.getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.full_name, " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
819
- }), index.h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), this.sequences.length > 0 && (index.h("div", { class: "row add-sequence", "data-sequence": sequence }, index.h("div", { class: "row-roles" }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step"))))));
820
- }), index.h("div", { class: "row", "data-sequence": this.sequences.length + 1 }, index.h("div", { class: "row-roles" }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("button", { class: "add-step", innerHTML: plusIcon, onClick: e => this.handleAddStep(e, this.sequences.length + 1) }))), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: doneIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "complete" }, "Document Complete")))), roleNames.length < 1 && (index.h("div", { class: "empty" }, "You must add at least one Role before proceeding.", index.h("br", null), " Click the ", index.h("span", { innerHTML: plusIcon }), " Add button above to get started.")), index.h("div", { class: "buttons" }, index.h("div", { class: "flex-fill" }), index.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), index.h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (index.h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
798
+ const roleNames = this.getRoleNames();
799
+ const sequences = this.getSequenceNumbers();
800
+ return (index.h(index.Host, null, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("h5", null, "Roles and Workflow"), index.h("div", { class: "participants" }, index.h("div", { class: "left-line" }), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: startIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "sender" }, index.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], ' ', index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingSenderDialog = true), "aria-role": "button" })))), index.h("div", { class: "row add-sequence", "data-sequence": 0 }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), sequences.map(sequence => (index.h(index.Fragment, null, index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: stepIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-order": 0.5, "data-sequence": sequence }), this.getRolesAtSequence(sequence).map(role => {
801
+ const unknown = !role.email;
802
+ return unknown ? (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { backgroundColor: Colors.getRGBA(utils.getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name, "data-sequence": sequence }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence }))) : (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { borderColor: Colors.getRGBA(utils.getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name, "data-sequence": sequence }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.full_name, " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
803
+ }), index.h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), sequences.length > 0 && (index.h("div", { class: "row add-sequence", "data-sequence": sequence }, index.h("div", { class: "row-roles" }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step"))))))), index.h("div", { class: "row", "data-sequence": sequences.length + 1 }, index.h("div", { class: "row-roles" }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("button", { class: "add-step", innerHTML: plusIcon, onClick: e => this.handleAddStep(e, sequences.length + 1) }))), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: doneIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "complete" }, "Document Complete")))), roleNames.length < 1 && (index.h("div", { class: "empty" }, "You must add at least one Role before proceeding.", index.h("br", null), " Click the ", index.h("span", { innerHTML: plusIcon }), " Add button above to get started.")), index.h("div", { class: "buttons" }, index.h("div", { class: "flex-fill" }), index.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), index.h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (index.h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
821
804
  this.showingRoleDialog = null;
822
- // this.forceRerender++;
823
805
  }, onDelete: async () => {
824
- var _a, _b;
825
- await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
826
- this.renumberTemplateRoles();
806
+ var _a;
827
807
  this.showingRoleDialog = null;
828
- // this.forceRerender++;
829
- (_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 });
830
- this.reloadStore().catch(e => console.log('Unknown error', e));
808
+ await this.renumberTemplateRoles();
809
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
831
810
  } })), this.showingSenderDialog && index.h("verdocs-template-sender", { endpoint: this.endpoint, templateId: this.templateId, onClose: () => (this.showingSenderDialog = false) })));
832
811
  }
833
812
  get el() { return index.getElement(this); }