@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.
- package/dist/cjs/{TemplateStore-6a75cdac.js → TemplateStore-079a1f85.js} +22 -0
- package/dist/cjs/ipc-test.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/verdocs-build.cjs.entry.js +7 -3
- package/dist/cjs/verdocs-portal_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-preview_8.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-template-fields_4.cjs.entry.js +132 -153
- package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
- package/dist/collection/components/embeds/verdocs-build/verdocs-build.js +29 -2
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +18 -11
- package/dist/collection/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.js +46 -44
- package/dist/collection/components/templates/verdocs-template-roles/verdocs-template-roles.js +78 -104
- package/dist/collection/utils/TemplateRoleStore.js +19 -0
- package/dist/collection/utils/TemplateStore.js +4 -1
- package/dist/components/TemplateStore.js +21 -1
- package/dist/components/verdocs-build.js +6 -2
- package/dist/components/verdocs-template-fields2.js +18 -12
- package/dist/components/verdocs-template-role-properties2.js +46 -45
- package/dist/components/verdocs-template-roles2.js +74 -101
- package/dist/docs.json +16 -7
- package/dist/esm/{TemplateStore-3994341c.js → TemplateStore-1ee18675.js} +21 -1
- package/dist/esm/ipc-test.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/verdocs-build.entry.js +7 -3
- package/dist/esm/verdocs-portal_2.entry.js +1 -1
- package/dist/esm/verdocs-preview_8.entry.js +1 -1
- package/dist/esm/verdocs-template-fields_4.entry.js +133 -154
- package/dist/esm/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/TemplateStore-1ee18675.js +1 -0
- package/dist/esm-es5/ipc-test.entry.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/verdocs-build.entry.js +1 -1
- package/dist/esm-es5/verdocs-portal_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_8.entry.js +1 -1
- package/dist/esm-es5/verdocs-template-fields_4.entry.js +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/types/components/embeds/verdocs-build/verdocs-build.d.ts +11 -1
- package/dist/types/components/templates/verdocs-template-fields/verdocs-template-fields.d.ts +3 -1
- package/dist/types/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.d.ts +7 -3
- package/dist/types/components/templates/verdocs-template-roles/verdocs-template-roles.d.ts +13 -10
- package/dist/types/components.d.ts +8 -4
- package/dist/types/utils/TemplateRoleStore.d.ts +6 -0
- package/dist/verdocs-web-sdk/{p-e7ea9726.entry.js → p-00e49c36.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-0bfc239a.system.js +1 -0
- package/dist/verdocs-web-sdk/p-2720068f.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-4fc74ab1.js +1 -0
- package/dist/verdocs-web-sdk/{p-07f0bcae.entry.js → p-5361ee8f.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-6ada9427.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-7f2f79fa.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-929760fd.system.entry.js → p-9f46a6a9.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-040620ca.system.entry.js → p-b54467df.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-5a05140d.system.entry.js → p-b86c345f.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-8f8db3aa.entry.js → p-cb429454.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-e080e371.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-f04bf956.system.js +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/TemplateStore-3994341c.js +0 -1
- package/dist/verdocs-web-sdk/p-0cf7f778.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-79fcaf1e.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-a98b0097.system.js +0 -1
- package/dist/verdocs-web-sdk/p-cee90f53.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-d1837af9.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-fc2454b0.js +0 -1
@@ -1,7 +1,8 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
2
2
|
import './Types.js';
|
3
3
|
import { V as VerdocsEndpoint, b as TemplateSenderTypes } from './VerdocsEndpoint.js';
|
4
|
-
import { g as getTemplateStore } from './TemplateStore.js';
|
4
|
+
import { g as getTemplateStore, c as createTemplateRoleStore } from './TemplateStore.js';
|
5
|
+
import { g as getTemplateFieldStore } from './TemplateFieldStore.js';
|
5
6
|
import { S as SDKError } from './errors.js';
|
6
7
|
import { d as defineCustomElement$5 } from './verdocs-button2.js';
|
7
8
|
import { d as defineCustomElement$4 } from './verdocs-checkbox2.js';
|
@@ -42,7 +43,9 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
42
43
|
this.close = createEvent(this, "close", 7);
|
43
44
|
this.delete = createEvent(this, "delete", 7);
|
44
45
|
this.sdkError = createEvent(this, "sdkError", 7);
|
45
|
-
this.
|
46
|
+
this.templateStore = null;
|
47
|
+
this.fieldStore = null;
|
48
|
+
this.roleStore = null;
|
46
49
|
this.endpoint = VerdocsEndpoint.getDefault();
|
47
50
|
this.templateId = '';
|
48
51
|
this.roleName = '';
|
@@ -51,13 +54,13 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
51
54
|
this.saving = false;
|
52
55
|
this.name = '';
|
53
56
|
this.type = 'signer';
|
54
|
-
this.
|
57
|
+
this.full_name = '';
|
55
58
|
this.email = '';
|
56
59
|
this.phone = '';
|
57
|
-
this.
|
60
|
+
this.delegator = false;
|
58
61
|
}
|
59
62
|
async componentWillLoad() {
|
60
|
-
var _a, _b, _c
|
63
|
+
var _a, _b, _c;
|
61
64
|
try {
|
62
65
|
this.endpoint.loadSession();
|
63
66
|
if (!this.templateId) {
|
@@ -68,29 +71,39 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
68
71
|
console.log('[ROLE_PROPERTIES] Unable to start builder session, must be authenticated');
|
69
72
|
return;
|
70
73
|
}
|
71
|
-
this.
|
72
|
-
|
74
|
+
this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
|
75
|
+
this.fieldStore = getTemplateFieldStore(this.templateId);
|
76
|
+
this.roleStore = createTemplateRoleStore(this.templateStore.state);
|
77
|
+
const editingRole = this.roleStore.get(this.roleName);
|
73
78
|
if (editingRole) {
|
74
79
|
this.name = editingRole.name;
|
75
80
|
this.type = editingRole.type;
|
76
|
-
this.
|
81
|
+
this.full_name = editingRole.full_name;
|
77
82
|
this.email = editingRole.email;
|
78
83
|
this.phone = editingRole.phone;
|
79
|
-
this.
|
80
|
-
console.log('[
|
84
|
+
this.delegator = editingRole.delegator;
|
85
|
+
console.log('[ROLE_PROPERTIES] Editing role', editingRole);
|
81
86
|
}
|
82
87
|
}
|
83
88
|
catch (e) {
|
84
|
-
console.log('[
|
85
|
-
(
|
89
|
+
console.log('[ROLE_PROPERTIES Error with preview session', e);
|
90
|
+
(_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));
|
86
91
|
}
|
87
92
|
}
|
88
93
|
handleCancel(e) {
|
89
|
-
var _a
|
94
|
+
var _a;
|
90
95
|
e.stopPropagation();
|
91
|
-
|
96
|
+
const editingRole = this.roleStore.get(this.roleName);
|
97
|
+
if (editingRole) {
|
98
|
+
this.name = editingRole.name;
|
99
|
+
this.type = editingRole.type;
|
100
|
+
this.full_name = editingRole.full_name;
|
101
|
+
this.email = editingRole.email;
|
102
|
+
this.phone = editingRole.phone;
|
103
|
+
this.delegator = editingRole.delegator;
|
104
|
+
}
|
92
105
|
this.dirty = false;
|
93
|
-
(
|
106
|
+
(_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
|
94
107
|
}
|
95
108
|
async handleSave(e) {
|
96
109
|
e.stopPropagation();
|
@@ -98,35 +111,24 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
98
111
|
updateRole(this.endpoint, this.templateId, this.roleName, {
|
99
112
|
name: this.name,
|
100
113
|
type: this.type,
|
101
|
-
full_name: this.
|
114
|
+
full_name: this.full_name,
|
102
115
|
email: this.email,
|
103
116
|
phone: this.phone,
|
104
|
-
delegator: this.
|
117
|
+
delegator: this.delegator,
|
105
118
|
})
|
106
119
|
.then(async (r) => {
|
107
120
|
var _a;
|
108
121
|
console.log('[ROLE_PROPERTIES] Update result', r);
|
109
122
|
this.saving = false;
|
110
123
|
this.dirty = false;
|
111
|
-
this.
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
// newRoles.forEach(role => {
|
116
|
-
// if (role.name === this.roleName) {
|
117
|
-
// role.name = this.name;
|
118
|
-
// role.type = this.type;
|
119
|
-
// role.full_name = this.fullName;
|
120
|
-
// role.email = this.email;
|
121
|
-
// role.phone = this.phone;
|
122
|
-
// role.delegator = this.allowDelegation;
|
123
|
-
// }
|
124
|
-
// });
|
125
|
-
// this.store.state.roles = newRoles;
|
124
|
+
this.roleStore.set(r.name, r);
|
125
|
+
if (this.roleName !== r.name) {
|
126
|
+
this.roleStore.set(this.roleName, undefined);
|
127
|
+
}
|
126
128
|
(_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
|
127
129
|
})
|
128
130
|
.catch(e => {
|
129
|
-
console.log('Update error', e);
|
131
|
+
console.log('[ROLE_PROPERTIES Update error', e);
|
130
132
|
this.saving = false;
|
131
133
|
});
|
132
134
|
}
|
@@ -136,20 +138,19 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
136
138
|
deleteRole(this.endpoint, this.templateId, this.roleName)
|
137
139
|
.then(r => {
|
138
140
|
var _a;
|
139
|
-
|
140
|
-
this.store.state.roles = [...this.store.state.roles.filter(role => role.name !== this.roleName)];
|
141
|
+
delete this.roleStore.state[r.name];
|
141
142
|
(_a = this.delete) === null || _a === void 0 ? void 0 : _a.emit({ templateId: this.templateId, roleName: this.roleName });
|
142
143
|
})
|
143
144
|
.catch(e => {
|
144
|
-
console.log('Deletion error', e);
|
145
|
+
console.log('[ROLE_PROPERTIES Deletion error', e);
|
145
146
|
});
|
146
147
|
}
|
147
148
|
}
|
148
149
|
render() {
|
149
|
-
const hasFields = (this.
|
150
|
-
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-
|
150
|
+
const hasFields = Object.values(this.fieldStore).findIndex(field => field.role_name === this.roleName) !== -1;
|
151
|
+
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
|
151
152
|
? 'This role has fields assigned and can no longer be renamed.'
|
152
|
-
: 'A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.', placeholder: "
|
153
|
+
: 'A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.', placeholder: "Role Name...", onInput: (e) => {
|
153
154
|
this.name = e.target.value;
|
154
155
|
this.dirty = true;
|
155
156
|
} }), h("div", { class: "row" }, h("div", { class: "input-label" }, "Type:"), h("verdocs-select-input", { value: this.type, options: [
|
@@ -159,8 +160,8 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
159
160
|
], onInput: (e) => {
|
160
161
|
this.type = e.target.value;
|
161
162
|
this.dirty = true;
|
162
|
-
} }), 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.
|
163
|
-
this.
|
163
|
+
} }), 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) => {
|
164
|
+
this.full_name = e.target.value;
|
164
165
|
this.dirty = true;
|
165
166
|
} }), 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) => {
|
166
167
|
this.email = e.target.value;
|
@@ -168,8 +169,8 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
168
169
|
} }), 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) => {
|
169
170
|
this.phone = e.target.value;
|
170
171
|
this.dirty = true;
|
171
|
-
} }), h("div", { class: "row" }, h("div", { class: "input-label" }, "May Delegate:"), h("div", { class: "checkbox-wrapper" }, h("verdocs-checkbox", { checked: this.
|
172
|
-
this.
|
172
|
+
} }), h("div", { class: "row" }, h("div", { class: "input-label" }, "May Delegate:"), h("div", { class: "checkbox-wrapper" }, h("verdocs-checkbox", { checked: this.delegator, onInput: (e) => {
|
173
|
+
this.delegator = e.target.checked;
|
173
174
|
this.dirty = true;
|
174
175
|
} })), 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) })))))));
|
175
176
|
}
|
@@ -183,10 +184,10 @@ const VerdocsTemplateRoleProperties = /*@__PURE__*/ proxyCustomElement(class ext
|
|
183
184
|
"saving": [32],
|
184
185
|
"name": [32],
|
185
186
|
"type": [32],
|
186
|
-
"
|
187
|
+
"full_name": [32],
|
187
188
|
"email": [32],
|
188
189
|
"phone": [32],
|
189
|
-
"
|
190
|
+
"delegator": [32]
|
190
191
|
}]);
|
191
192
|
function defineCustomElement() {
|
192
193
|
if (typeof customElements === "undefined") {
|
@@ -4,7 +4,7 @@ import './Types.js';
|
|
4
4
|
import { V as VerdocsEndpoint, b as TemplateSenderTypes } from './VerdocsEndpoint.js';
|
5
5
|
import { u as updateRole, c as createRole, d as defineCustomElement$3 } from './verdocs-template-role-properties2.js';
|
6
6
|
import { g as getRGBA } from './Colors.js';
|
7
|
-
import { g as getTemplateStore } from './TemplateStore.js';
|
7
|
+
import { g as getTemplateStore, b as getTemplateRoleStore } from './TemplateStore.js';
|
8
8
|
import { b as getRoleIndex } from './utils.js';
|
9
9
|
import { S as SDKError } from './errors.js';
|
10
10
|
import { d as defineCustomElement$a } from './verdocs-button2.js';
|
@@ -41,9 +41,9 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
41
41
|
this.next = createEvent(this, "next", 7);
|
42
42
|
this.exit = createEvent(this, "exit", 7);
|
43
43
|
this.sdkError = createEvent(this, "sdkError", 7);
|
44
|
-
this.
|
45
|
-
this.
|
46
|
-
this.
|
44
|
+
this.rolesUpdated = createEvent(this, "rolesUpdated", 7);
|
45
|
+
this.templateStore = null;
|
46
|
+
this.roleStore = null;
|
47
47
|
this.endpoint = VerdocsEndpoint.getDefault();
|
48
48
|
this.templateId = '';
|
49
49
|
this.showingRoleDialog = null;
|
@@ -62,18 +62,14 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
62
62
|
console.log('[ROLES] Unable to start builder session, must be authenticated');
|
63
63
|
return;
|
64
64
|
}
|
65
|
-
await this.
|
65
|
+
this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
|
66
|
+
this.roleStore = getTemplateRoleStore(this.templateId);
|
66
67
|
}
|
67
68
|
catch (e) {
|
68
69
|
console.log('[FIELDS] Error with preview session', e);
|
69
70
|
(_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));
|
70
71
|
}
|
71
72
|
}
|
72
|
-
async reloadStore() {
|
73
|
-
this.store = await getTemplateStore(this.endpoint, this.templateId, false);
|
74
|
-
this.sortTemplateRoles();
|
75
|
-
this.renumberTemplateRoles();
|
76
|
-
}
|
77
73
|
componentDidRender() {
|
78
74
|
interact_min.dynamicDrop(true);
|
79
75
|
interact_min('.recipient').draggable({
|
@@ -83,64 +79,45 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
83
79
|
this.el.classList.add('dragging');
|
84
80
|
}.bind(this),
|
85
81
|
move: function handleMove(e) {
|
86
|
-
const oldX = +(e.target.getAttribute('
|
87
|
-
const oldY = +(e.target.getAttribute('
|
82
|
+
const oldX = +(e.target.getAttribute('dX') || 0);
|
83
|
+
const oldY = +(e.target.getAttribute('dY') || 0);
|
84
|
+
const sequence = +(e.target.dataset['sequence'] || 0);
|
88
85
|
const newX = e.dx + oldX;
|
89
86
|
const newY = e.dy + oldY;
|
90
|
-
e.target.setAttribute('
|
91
|
-
e.target.setAttribute('
|
92
|
-
e.target.
|
87
|
+
e.target.setAttribute('dX', newX);
|
88
|
+
e.target.setAttribute('dY', newY);
|
89
|
+
const rect = e.target.getBoundingClientRect();
|
90
|
+
// Note: I never did figure out exactly why this is, but if we don't offset the transform
|
91
|
+
// the dragged item is offset from the mouse cursor quite a bit.
|
92
|
+
e.target.style.transform = `translate(${newX + 80}px, ${newY - rect.height * sequence}px)`;
|
93
93
|
}.bind(this),
|
94
94
|
end: function handleEnd(e) {
|
95
95
|
e.target.classList.remove('dragging');
|
96
96
|
this.el.classList.remove('dragging');
|
97
97
|
// console.log('end', event);
|
98
|
-
e.target.
|
99
|
-
e.target.
|
100
|
-
e.target.style.transform =
|
98
|
+
e.target.removeAttribute('dX');
|
99
|
+
e.target.removeAttribute('dY');
|
100
|
+
e.target.style.transform = null;
|
101
101
|
}.bind(this),
|
102
102
|
},
|
103
103
|
});
|
104
104
|
interact_min('.dropzone').dropzone({
|
105
105
|
overlap: 0.05,
|
106
|
-
ondrop: function handleDrop(event) {
|
107
|
-
var _a
|
106
|
+
ondrop: async function handleDrop(event) {
|
107
|
+
var _a;
|
108
108
|
event.target.classList.remove('active');
|
109
|
-
// target will be the recipient e.g. <div class="recipient" data-rolename="Buyer" />
|
110
|
-
// relatedTarget will be the drop zone, e.g. <div class="dropzone" data-order="2" data-sequence="1" />
|
111
|
-
// console.log(event.relatedTarget, ' was dropped into ', event.target);
|
112
|
-
// We don't use the role's own order, we rely on the fact that we sorted earlier on the order field. Many legacy
|
113
|
-
// 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
|
114
|
-
// 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
|
115
|
-
// need to do a fancy find/arraymove dance. We just set the dropped element to the half value, sort the result,
|
116
|
-
// then do a final renumber. It's not expensive to do because most flows are typically a small handful (e.g. 1-4)
|
117
|
-
// recipients. They never have hundreds.
|
118
109
|
const roleName = event.relatedTarget.dataset.rolename;
|
119
110
|
const targetSequence = +event.target.dataset.sequence;
|
120
111
|
const targetOrder = +event.target.dataset.order;
|
121
|
-
const changingRole =
|
112
|
+
const changingRole = this.roleStore.get(roleName);
|
122
113
|
if (changingRole) {
|
123
114
|
// To handle the renumbering, we update the role being moved to the new values, which will be some half-interval e.g.
|
124
|
-
// sequence 1.5 order 1. Then we
|
125
|
-
changingRole
|
126
|
-
changingRole.
|
127
|
-
this.
|
128
|
-
this.
|
129
|
-
this.
|
130
|
-
// We have to update ALL the roles to be sure each gets new proper sequence/order numbers assigned.
|
131
|
-
// TODO: We could optimize this by tracking "dirty" states and only update the roles that have changed. But it's a LOT more
|
132
|
-
// code to do right, and since most workflows will typically only have 2-4 recipients max, it may not be worth it.
|
133
|
-
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, {
|
134
|
-
sequence: role.sequence,
|
135
|
-
order: role.order,
|
136
|
-
})))
|
137
|
-
.then(() => {
|
138
|
-
var _a, _b;
|
139
|
-
console.log('[ROLES] Updated roles');
|
140
|
-
(_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 });
|
141
|
-
this.reloadStore().catch(e => console.log('Unknown error', e));
|
142
|
-
})
|
143
|
-
.catch(e => console.log('[ROLES] Role updates failed', e));
|
115
|
+
// sequence 1.5 order 1. Then we sort/renumber the roles at each level to determine their final ordering values.
|
116
|
+
const newRole = { ...changingRole, sequence: targetSequence, order: targetOrder };
|
117
|
+
this.roleStore.set(changingRole.name, newRole);
|
118
|
+
await this.renumberTemplateRoles();
|
119
|
+
(_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
|
120
|
+
console.log('[ROLES] Updated roles', this.getSortedRoles());
|
144
121
|
}
|
145
122
|
}.bind(this),
|
146
123
|
ondropactivate: e => {
|
@@ -165,50 +142,60 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
165
142
|
var _a;
|
166
143
|
(_a = this.next) === null || _a === void 0 ? void 0 : _a.emit();
|
167
144
|
}
|
168
|
-
|
169
|
-
|
170
|
-
|
145
|
+
getSortedRoles() {
|
146
|
+
return Object.values(this.roleStore.state)
|
147
|
+
.filter(role => role !== undefined)
|
148
|
+
.sort((a, b) => {
|
171
149
|
return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;
|
172
150
|
});
|
173
151
|
}
|
174
|
-
|
175
|
-
|
176
|
-
this.
|
177
|
-
|
178
|
-
|
179
|
-
this.sequences.push(role.sequence);
|
152
|
+
getSequenceNumbers() {
|
153
|
+
const sequences = [];
|
154
|
+
this.getSortedRoles().forEach(role => {
|
155
|
+
if (!sequences.includes(role.sequence)) {
|
156
|
+
sequences.push(role.sequence);
|
180
157
|
}
|
181
158
|
});
|
159
|
+
return sequences.sort((a, b) => a - b);
|
160
|
+
}
|
161
|
+
getRoleNames() {
|
162
|
+
const roles = this.getSortedRoles();
|
163
|
+
return roles.map(role => role.name);
|
164
|
+
}
|
165
|
+
getRolesAtSequence(sequence) {
|
166
|
+
// Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
|
167
|
+
// See https://github.com/ionic-team/stencil-store/issues/23
|
168
|
+
return Object.values(this.roleStore.state).filter(role => role && role.sequence === sequence);
|
182
169
|
}
|
170
|
+
// When the user drags a role around, we handle placement "between" items by assigning it a half-order number
|
171
|
+
// 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.
|
172
|
+
// Then we re-sort the list of roles and renumber them.
|
183
173
|
renumberTemplateRoles() {
|
184
|
-
//
|
185
|
-
this.extractSequenceNumbers();
|
186
|
-
// We need to renumber each role only ONE TIME
|
174
|
+
// Avoid dupe renumber attempts
|
187
175
|
const renumbered = [];
|
188
176
|
// 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.
|
189
|
-
|
190
|
-
this.
|
191
|
-
|
192
|
-
(_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) => {
|
177
|
+
const renumberRequests = [];
|
178
|
+
this.getSequenceNumbers().forEach((originalSequence, newSequenceIndex) => {
|
179
|
+
this.getRolesAtSequence(originalSequence).forEach((role, newOrderIndex) => {
|
193
180
|
if (!renumbered.includes(role.name)) {
|
194
181
|
role.sequence = newSequenceIndex + 1;
|
195
182
|
role.order = newOrderIndex + 1;
|
196
183
|
renumbered.push(role.name);
|
184
|
+
renumberRequests.push(updateRole(this.endpoint, this.templateId, role.name, { sequence: role.sequence, order: role.order }));
|
197
185
|
}
|
198
186
|
});
|
199
187
|
});
|
200
|
-
|
201
|
-
this.extractSequenceNumbers();
|
188
|
+
return Promise.all(renumberRequests);
|
202
189
|
}
|
203
190
|
// Look for name conflicts, because they're UGC and can be anything, regardless of order.
|
204
191
|
getNextRoleName() {
|
205
|
-
var _a
|
192
|
+
var _a;
|
206
193
|
let name = '';
|
207
|
-
let nextNumber = (
|
194
|
+
let nextNumber = Object.keys(this.roleStore).length;
|
208
195
|
do {
|
209
196
|
nextNumber++;
|
210
197
|
name = `Recipient ${nextNumber}`;
|
211
|
-
} while (!name || ((
|
198
|
+
} while (!name || Object.values((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.state).some(role => role && role.name === name));
|
212
199
|
return name;
|
213
200
|
}
|
214
201
|
callCreateRole(name, sequence, order) {
|
@@ -225,25 +212,19 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
225
212
|
delegator: false,
|
226
213
|
})
|
227
214
|
.then(async (r) => {
|
228
|
-
var _a
|
215
|
+
var _a;
|
229
216
|
console.log('[ROLES] Created role', r);
|
230
|
-
this.
|
231
|
-
this.
|
232
|
-
this.
|
233
|
-
// this.store.state.roles = [...this.store?.state.roles, r];
|
234
|
-
// this.renumberTemplateRoles();
|
235
|
-
(_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 });
|
236
|
-
this.reloadStore().catch(e => console.log('Unknown error', e));
|
217
|
+
this.roleStore.set(r.name, r);
|
218
|
+
await this.renumberTemplateRoles();
|
219
|
+
(_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
|
237
220
|
})
|
238
221
|
.catch(e => {
|
239
222
|
console.log('[ROLES] Error creating role', e);
|
240
223
|
});
|
241
224
|
}
|
242
225
|
handleAddRole(e, sequence) {
|
243
|
-
var _a;
|
244
226
|
e.stopPropagation();
|
245
|
-
|
246
|
-
const order = ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state.roles.filter(role => role.sequence === sequence).length) + 1;
|
227
|
+
const order = this.getRolesAtSequence(sequence).length + 1;
|
247
228
|
const name = this.getNextRoleName();
|
248
229
|
this.callCreateRole(name, sequence, order);
|
249
230
|
}
|
@@ -254,33 +235,25 @@ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class extends HTML
|
|
254
235
|
this.callCreateRole(name, sequence, order);
|
255
236
|
}
|
256
237
|
render() {
|
257
|
-
var _a, _b, _c
|
258
|
-
console.log('[ROLES] Rendering');
|
238
|
+
var _a, _b, _c;
|
259
239
|
if (!this.endpoint.session) {
|
260
240
|
return (h(Host, null, h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
|
261
241
|
}
|
262
|
-
if (!((_a = this.
|
242
|
+
if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
|
263
243
|
return (h(Host, { class: "loading" }, h("verdocs-loader", null)));
|
264
244
|
}
|
265
|
-
const roleNames =
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
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 })));
|
272
|
-
}), 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"))))));
|
273
|
-
}), 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: () => {
|
245
|
+
const roleNames = this.getRoleNames();
|
246
|
+
const sequences = this.getSequenceNumbers();
|
247
|
+
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 => {
|
248
|
+
const unknown = !role.email;
|
249
|
+
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 })));
|
250
|
+
}), 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: () => {
|
274
251
|
this.showingRoleDialog = null;
|
275
|
-
// this.forceRerender++;
|
276
252
|
}, onDelete: async () => {
|
277
|
-
var _a
|
278
|
-
await getTemplateStore(this.endpoint, this.templateId, false);
|
279
|
-
this.renumberTemplateRoles();
|
253
|
+
var _a;
|
280
254
|
this.showingRoleDialog = null;
|
281
|
-
|
282
|
-
(_a = this.
|
283
|
-
this.reloadStore().catch(e => console.log('Unknown error', e));
|
255
|
+
await this.renumberTemplateRoles();
|
256
|
+
(_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
|
284
257
|
} })), this.showingSenderDialog && h("verdocs-template-sender", { endpoint: this.endpoint, templateId: this.templateId, onClose: () => (this.showingSenderDialog = false) })));
|
285
258
|
}
|
286
259
|
get el() { return this; }
|
package/dist/docs.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"timestamp": "2024-01-
|
2
|
+
"timestamp": "2024-01-15T05:11:36",
|
3
3
|
"compiler": {
|
4
4
|
"name": "@stencil/core",
|
5
5
|
"version": "2.20.0",
|
@@ -407,6 +407,15 @@
|
|
407
407
|
],
|
408
408
|
"methods": [],
|
409
409
|
"events": [
|
410
|
+
{
|
411
|
+
"event": "rolesUpdated",
|
412
|
+
"detail": "{ endpoint: VerdocsEndpoint; templateId: string; event: \"added\" | \"deleted\" | \"updated\"; roles: IRole[]; }",
|
413
|
+
"bubbles": true,
|
414
|
+
"cancelable": true,
|
415
|
+
"composed": true,
|
416
|
+
"docs": "Event fired when roles are updated in the roles step.",
|
417
|
+
"docsTags": []
|
418
|
+
},
|
410
419
|
{
|
411
420
|
"event": "sdkError",
|
412
421
|
"detail": "SDKError",
|
@@ -9436,21 +9445,21 @@
|
|
9436
9445
|
"docsTags": []
|
9437
9446
|
},
|
9438
9447
|
{
|
9439
|
-
"event": "
|
9440
|
-
"detail": "
|
9448
|
+
"event": "rolesUpdated",
|
9449
|
+
"detail": "{ endpoint: VerdocsEndpoint; templateId: string; event: \"added\" | \"deleted\" | \"updated\"; roles: IRole[]; }",
|
9441
9450
|
"bubbles": true,
|
9442
9451
|
"cancelable": true,
|
9443
9452
|
"composed": true,
|
9444
|
-
"docs": "Event fired
|
9453
|
+
"docs": "Event fired when the template is updated in any way. May be used for tasks such as cache invalidation or reporting to other systems.",
|
9445
9454
|
"docsTags": []
|
9446
9455
|
},
|
9447
9456
|
{
|
9448
|
-
"event": "
|
9449
|
-
"detail": "
|
9457
|
+
"event": "sdkError",
|
9458
|
+
"detail": "SDKError",
|
9450
9459
|
"bubbles": true,
|
9451
9460
|
"cancelable": true,
|
9452
9461
|
"composed": true,
|
9453
|
-
"docs": "Event fired
|
9462
|
+
"docs": "Event fired if an error occurs. The event details will contain information about the error. Most errors will\nterminate the process, and the calling application should correct the condition and re-render the component.",
|
9454
9463
|
"docsTags": []
|
9455
9464
|
}
|
9456
9465
|
],
|
@@ -2,6 +2,25 @@ import { c as createStore } from './index-4439b0d1.js';
|
|
2
2
|
import { g as getTemplate, T as TemplateSenderTypes } from './VerdocsEndpoint-56fa3371.js';
|
3
3
|
import { c as createTemplateFieldStore } from './TemplateFieldStore-295f240e.js';
|
4
4
|
|
5
|
+
const templateRoleStores = {};
|
6
|
+
const getTemplateRoleStore = (templateId) => templateRoleStores[templateId];
|
7
|
+
const createTemplateRoleStore = (template) => {
|
8
|
+
let store = getTemplateRoleStore(template.id);
|
9
|
+
if (!store) {
|
10
|
+
console.log('Creating template role store for template', template.id);
|
11
|
+
store = createStore({});
|
12
|
+
templateRoleStores[template.id] = store;
|
13
|
+
}
|
14
|
+
else {
|
15
|
+
console.log('Resetting template role store for template', template.id);
|
16
|
+
store.reset();
|
17
|
+
}
|
18
|
+
template.roles.forEach(role => {
|
19
|
+
store.set(role.name, role);
|
20
|
+
});
|
21
|
+
return store;
|
22
|
+
};
|
23
|
+
|
5
24
|
const createTemplateStore = (templateId) => {
|
6
25
|
const now = new Date().toISOString();
|
7
26
|
return createStore({
|
@@ -69,6 +88,7 @@ const getTemplateStore = async (endpoint, templateId, forceReload = false) => {
|
|
69
88
|
store.state.isLoaded = true;
|
70
89
|
store.state.isError = false;
|
71
90
|
store.state.error = undefined;
|
91
|
+
createTemplateRoleStore(template);
|
72
92
|
createTemplateFieldStore(template);
|
73
93
|
}
|
74
94
|
catch (e) {
|
@@ -85,4 +105,4 @@ const getTemplateStore = async (endpoint, templateId, forceReload = false) => {
|
|
85
105
|
};
|
86
106
|
const getRoleNames = (store) => { var _a; return (((_a = store === null || store === void 0 ? void 0 : store.state) === null || _a === void 0 ? void 0 : _a.roles) || []).map(role => role.name); };
|
87
107
|
|
88
|
-
export { getRoleNames as a, getTemplateStore as g };
|
108
|
+
export { getRoleNames as a, getTemplateRoleStore as b, createTemplateRoleStore as c, getTemplateStore as g };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { r as registerInstance, h, H as Host } from './index-172625c5.js';
|
2
2
|
import './Types-5f31149e.js';
|
3
3
|
import { V as VerdocsEndpoint } from './VerdocsEndpoint-56fa3371.js';
|
4
|
-
import { g as getTemplateStore } from './TemplateStore-
|
4
|
+
import { g as getTemplateStore } from './TemplateStore-1ee18675.js';
|
5
5
|
import './index-4439b0d1.js';
|
6
6
|
import './TemplateFieldStore-295f240e.js';
|
7
7
|
|