@verdocs/web-sdk 1.13.0 → 1.13.1

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.
@@ -664,59 +664,43 @@ const VerdocsTemplateRoles = class {
664
664
  } 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)));
665
665
  return name;
666
666
  }
667
- handleAddRole(e, sequence) {
668
- var _a;
669
- e.stopPropagation();
670
- // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
671
- const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
672
- const name = this.getNextRoleName();
673
- console.log('Will create', name, sequence, order);
667
+ callCreateRole(name, sequence, order) {
668
+ console.log('[ROLES] Will create role', { name, sequence, order });
674
669
  Roles.createRole(this.endpoint, this.templateId, {
675
670
  template_id: this.templateId,
676
671
  name,
672
+ sequence,
673
+ order,
677
674
  full_name: '',
678
675
  email: '',
679
676
  phone: '',
680
- sequence,
681
- order,
682
677
  type: 'signer',
683
678
  delegator: false,
684
679
  })
685
680
  .then(r => {
686
681
  var _a, _b, _c;
687
- console.log('Created role', r);
688
- (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.push(r);
682
+ console.log('[ROLES] Created role', r);
683
+ this.store.state.roles = [...(_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles, r];
689
684
  this.renumberTemplateRoles();
690
685
  (_b = this.templateUpdated) === null || _b === void 0 ? void 0 : _b.emit({ event: 'created-role', endpoint: this.endpoint, template: (_c = this.store) === null || _c === void 0 ? void 0 : _c.state });
691
686
  })
692
687
  .catch(e => {
693
- console.log('Error creating role', e);
688
+ console.log('[ROLES] Error creating role', e);
694
689
  });
695
690
  }
691
+ handleAddRole(e, sequence) {
692
+ var _a;
693
+ e.stopPropagation();
694
+ // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
695
+ const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
696
+ const name = this.getNextRoleName();
697
+ this.callCreateRole(name, sequence, order);
698
+ }
696
699
  handleAddStep(e, sequence) {
697
700
  e.stopPropagation();
698
701
  const order = 1;
699
702
  const name = this.getNextRoleName();
700
- Roles.createRole(this.endpoint, this.templateId, {
701
- template_id: this.templateId,
702
- name,
703
- full_name: '',
704
- email: '',
705
- phone: '',
706
- sequence,
707
- order,
708
- type: 'signer',
709
- delegator: false,
710
- })
711
- .then(r => {
712
- var _a, _b, _c, _d;
713
- (_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.push(r);
714
- this.renumberTemplateRoles();
715
- (_d = this.templateUpdated) === null || _d === void 0 ? void 0 : _d.emit({ event: 'created-role', endpoint: this.endpoint, template: this.store.state });
716
- })
717
- .catch(e => {
718
- console.log('Error creating role', e);
719
- });
703
+ this.callCreateRole(name, sequence, order);
720
704
  }
721
705
  render() {
722
706
  var _a, _b, _c, _d, _e, _f;
@@ -81,11 +81,12 @@ const VerdocsTemplateRoleProperties = class {
81
81
  delegator: this.allowDelegation,
82
82
  })
83
83
  .then(r => {
84
- var _a, _b, _c;
84
+ var _a;
85
85
  console.log('Update result', r);
86
86
  this.saving = false;
87
87
  this.dirty = false;
88
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.forEach(role => {
88
+ const newRoles = [...this.store.state.roles];
89
+ newRoles.forEach(role => {
89
90
  if (role.name === this.roleName) {
90
91
  role.name = this.name;
91
92
  role.type = this.type;
@@ -95,10 +96,11 @@ const VerdocsTemplateRoleProperties = class {
95
96
  role.delegator = this.allowDelegation;
96
97
  }
97
98
  });
98
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
99
+ this.store.state.roles = newRoles;
100
+ (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
99
101
  })
100
102
  .catch(e => {
101
- console.log('Uopdate error', e);
103
+ console.log('Update error', e);
102
104
  this.saving = false;
103
105
  });
104
106
  }
@@ -107,12 +109,10 @@ const VerdocsTemplateRoleProperties = class {
107
109
  if (window.confirm('Are you sure you wish to remove this role? All associated fields will be removed as well. This action cannot be undone.')) {
108
110
  Roles.deleteRole(this.endpoint, this.templateId, this.roleName)
109
111
  .then(r => {
110
- var _a, _b;
112
+ var _a;
111
113
  console.log('Role deleted', r);
112
- if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state) {
113
- this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
114
- }
115
- (_b = this.delete) === null || _b === void 0 ? void 0 : _b.emit({ templateId: this.templateId, roleName: this.roleName });
114
+ this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
115
+ (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
116
116
  })
117
117
  .catch(e => {
118
118
  console.log('Deletion error', e);
@@ -72,11 +72,12 @@ export class VerdocsTemplateRoleProperties {
72
72
  delegator: this.allowDelegation,
73
73
  })
74
74
  .then(r => {
75
- var _a, _b, _c;
75
+ var _a;
76
76
  console.log('Update result', r);
77
77
  this.saving = false;
78
78
  this.dirty = false;
79
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.forEach(role => {
79
+ const newRoles = [...this.store.state.roles];
80
+ newRoles.forEach(role => {
80
81
  if (role.name === this.roleName) {
81
82
  role.name = this.name;
82
83
  role.type = this.type;
@@ -86,10 +87,11 @@ export class VerdocsTemplateRoleProperties {
86
87
  role.delegator = this.allowDelegation;
87
88
  }
88
89
  });
89
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
90
+ this.store.state.roles = newRoles;
91
+ (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
90
92
  })
91
93
  .catch(e => {
92
- console.log('Uopdate error', e);
94
+ console.log('Update error', e);
93
95
  this.saving = false;
94
96
  });
95
97
  }
@@ -98,12 +100,10 @@ export class VerdocsTemplateRoleProperties {
98
100
  if (window.confirm('Are you sure you wish to remove this role? All associated fields will be removed as well. This action cannot be undone.')) {
99
101
  deleteRole(this.endpoint, this.templateId, this.roleName)
100
102
  .then(r => {
101
- var _a, _b;
103
+ var _a;
102
104
  console.log('Role deleted', r);
103
- if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state) {
104
- this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
105
- }
106
- (_b = this.delete) === null || _b === void 0 ? void 0 : _b.emit({ templateId: this.templateId, roleName: this.roleName });
105
+ this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
106
+ (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
107
107
  })
108
108
  .catch(e => {
109
109
  console.log('Deletion error', e);
@@ -192,59 +192,43 @@ export class VerdocsTemplateRoles {
192
192
  } 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)));
193
193
  return name;
194
194
  }
195
- handleAddRole(e, sequence) {
196
- var _a;
197
- e.stopPropagation();
198
- // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
199
- const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
200
- const name = this.getNextRoleName();
201
- console.log('Will create', name, sequence, order);
195
+ callCreateRole(name, sequence, order) {
196
+ console.log('[ROLES] Will create role', { name, sequence, order });
202
197
  createRole(this.endpoint, this.templateId, {
203
198
  template_id: this.templateId,
204
199
  name,
200
+ sequence,
201
+ order,
205
202
  full_name: '',
206
203
  email: '',
207
204
  phone: '',
208
- sequence,
209
- order,
210
205
  type: 'signer',
211
206
  delegator: false,
212
207
  })
213
208
  .then(r => {
214
209
  var _a, _b, _c;
215
- console.log('Created role', r);
216
- (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.push(r);
210
+ console.log('[ROLES] Created role', r);
211
+ this.store.state.roles = [...(_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles, r];
217
212
  this.renumberTemplateRoles();
218
213
  (_b = this.templateUpdated) === null || _b === void 0 ? void 0 : _b.emit({ event: 'created-role', endpoint: this.endpoint, template: (_c = this.store) === null || _c === void 0 ? void 0 : _c.state });
219
214
  })
220
215
  .catch(e => {
221
- console.log('Error creating role', e);
216
+ console.log('[ROLES] Error creating role', e);
222
217
  });
223
218
  }
219
+ handleAddRole(e, sequence) {
220
+ var _a;
221
+ e.stopPropagation();
222
+ // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
223
+ const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
224
+ const name = this.getNextRoleName();
225
+ this.callCreateRole(name, sequence, order);
226
+ }
224
227
  handleAddStep(e, sequence) {
225
228
  e.stopPropagation();
226
229
  const order = 1;
227
230
  const name = this.getNextRoleName();
228
- createRole(this.endpoint, this.templateId, {
229
- template_id: this.templateId,
230
- name,
231
- full_name: '',
232
- email: '',
233
- phone: '',
234
- sequence,
235
- order,
236
- type: 'signer',
237
- delegator: false,
238
- })
239
- .then(r => {
240
- var _a, _b, _c, _d;
241
- (_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.push(r);
242
- this.renumberTemplateRoles();
243
- (_d = this.templateUpdated) === null || _d === void 0 ? void 0 : _d.emit({ event: 'created-role', endpoint: this.endpoint, template: this.store.state });
244
- })
245
- .catch(e => {
246
- console.log('Error creating role', e);
247
- });
231
+ this.callCreateRole(name, sequence, order);
248
232
  }
249
233
  render() {
250
234
  var _a, _b, _c, _d, _e, _f;
@@ -104,11 +104,12 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
104
104
  delegator: this.allowDelegation,
105
105
  })
106
106
  .then(r => {
107
- var _a, _b, _c;
107
+ var _a;
108
108
  console.log('Update result', r);
109
109
  this.saving = false;
110
110
  this.dirty = false;
111
- (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles.forEach(role => {
111
+ const newRoles = [...this.store.state.roles];
112
+ newRoles.forEach(role => {
112
113
  if (role.name === this.roleName) {
113
114
  role.name = this.name;
114
115
  role.type = this.type;
@@ -118,10 +119,11 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
118
119
  role.delegator = this.allowDelegation;
119
120
  }
120
121
  });
121
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
122
+ this.store.state.roles = newRoles;
123
+ (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
122
124
  })
123
125
  .catch(e => {
124
- console.log('Uopdate error', e);
126
+ console.log('Update error', e);
125
127
  this.saving = false;
126
128
  });
127
129
  }
@@ -130,12 +132,10 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
130
132
  if (window.confirm('Are you sure you wish to remove this role? All associated fields will be removed as well. This action cannot be undone.')) {
131
133
  deleteRole(this.endpoint, this.templateId, this.roleName)
132
134
  .then(r => {
133
- var _a, _b;
135
+ var _a;
134
136
  console.log('Role deleted', r);
135
- if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state) {
136
- this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
137
- }
138
- (_b = this.delete) === null || _b === void 0 ? void 0 : _b.emit({ templateId: this.templateId, roleName: this.roleName });
137
+ this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
138
+ (_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
139
139
  })
140
140
  .catch(e => {
141
141
  console.log('Deletion error', e);
@@ -207,59 +207,43 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
207
207
  } 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)));
208
208
  return name;
209
209
  }
210
- handleAddRole(e, sequence) {
211
- var _a;
212
- e.stopPropagation();
213
- // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
214
- const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
215
- const name = this.getNextRoleName();
216
- console.log('Will create', name, sequence, order);
210
+ callCreateRole(name, sequence, order) {
211
+ console.log('[ROLES] Will create role', { name, sequence, order });
217
212
  createRole(this.endpoint, this.templateId, {
218
213
  template_id: this.templateId,
219
214
  name,
215
+ sequence,
216
+ order,
220
217
  full_name: '',
221
218
  email: '',
222
219
  phone: '',
223
- sequence,
224
- order,
225
220
  type: 'signer',
226
221
  delegator: false,
227
222
  })
228
223
  .then(r => {
229
224
  var _a, _b, _c;
230
- console.log('Created role', r);
231
- (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.push(r);
225
+ console.log('[ROLES] Created role', r);
226
+ this.store.state.roles = [...(_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles, r];
232
227
  this.renumberTemplateRoles();
233
228
  (_b = this.templateUpdated) === null || _b === void 0 ? void 0 : _b.emit({ event: 'created-role', endpoint: this.endpoint, template: (_c = this.store) === null || _c === void 0 ? void 0 : _c.state });
234
229
  })
235
230
  .catch(e => {
236
- console.log('Error creating role', e);
231
+ console.log('[ROLES] Error creating role', e);
237
232
  });
238
233
  }
234
+ handleAddRole(e, sequence) {
235
+ var _a;
236
+ e.stopPropagation();
237
+ // We don't need to look for a unique order number because we're already working with a sorted/renumbered set by now.
238
+ const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
239
+ const name = this.getNextRoleName();
240
+ this.callCreateRole(name, sequence, order);
241
+ }
239
242
  handleAddStep(e, sequence) {
240
243
  e.stopPropagation();
241
244
  const order = 1;
242
245
  const name = this.getNextRoleName();
243
- createRole(this.endpoint, this.templateId, {
244
- template_id: this.templateId,
245
- name,
246
- full_name: '',
247
- email: '',
248
- phone: '',
249
- sequence,
250
- order,
251
- type: 'signer',
252
- delegator: false,
253
- })
254
- .then(r => {
255
- var _a, _b, _c, _d;
256
- (_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.push(r);
257
- this.renumberTemplateRoles();
258
- (_d = this.templateUpdated) === null || _d === void 0 ? void 0 : _d.emit({ event: 'created-role', endpoint: this.endpoint, template: this.store.state });
259
- })
260
- .catch(e => {
261
- console.log('Error creating role', e);
262
- });
246
+ this.callCreateRole(name, sequence, order);
263
247
  }
264
248
  render() {
265
249
  var _a, _b, _c, _d, _e, _f;