@verdocs/web-sdk 2.3.28 → 2.3.30

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.
@@ -89,7 +89,7 @@ const VerdocsTemplateFields = class {
89
89
  this.selectedRoleName = '';
90
90
  }
91
91
  async componentWillLoad() {
92
- var _a, _b, _c, _d, _e, _f, _g;
92
+ var _a, _b, _c, _d, _e;
93
93
  try {
94
94
  this.endpoint.loadSession();
95
95
  if (!this.templateId) {
@@ -103,11 +103,12 @@ const VerdocsTemplateFields = class {
103
103
  this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
104
104
  this.fieldStore = TemplateFieldStore.getTemplateFieldStore(this.templateId);
105
105
  this.roleStore = TemplateStore.getTemplateRoleStore(this.templateId);
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) || '';
106
+ this.selectedRoleName = ((_b = (_a = this.roleStore.get('roles')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) || '';
107
+ console.log('Sel role', this.selectedRoleName);
107
108
  }
108
109
  catch (e) {
109
110
  console.log('[FIELDS] Error with preview session', e);
110
- (_e = this.sdkError) === null || _e === void 0 ? void 0 : _e.emit(new errors.SDKError(e.message, (_f = e.response) === null || _f === void 0 ? void 0 : _f.status, (_g = e.response) === null || _g === void 0 ? void 0 : _g.data));
111
+ (_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));
111
112
  }
112
113
  }
113
114
  componentDidRender() {
@@ -121,10 +122,11 @@ const VerdocsTemplateFields = class {
121
122
  }
122
123
  }
123
124
  componentWillUpdate() {
124
- var _a, _b, _c, _d;
125
+ var _a;
125
126
  // If a new role was added and there were none yet so far, or the "selected" role was deleted, reset our selection
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) || '';
127
+ const roles = this.roleStore.get('roles');
128
+ if (!this.selectedRoleName || !roles.find(role => role && role.name === this.selectedRoleName)) {
129
+ this.selectedRoleName = ((_a = roles[0]) === null || _a === void 0 ? void 0 : _a.name) || '';
128
130
  console.log('[FIELDS] Selected new role', this.selectedRoleName);
129
131
  }
130
132
  }
@@ -366,8 +368,9 @@ const VerdocsTemplateFields = class {
366
368
  }
367
369
  const saved = await Fields.createField(this.endpoint, this.templateId, field);
368
370
  console.log('[FIELDS] Saved field', saved);
369
- this.fieldStore.set('fields', [...this.fieldStore.state.fields, saved]);
371
+ this.fieldStore.set('fields', [...this.fieldStore.get('fields'), saved]);
370
372
  this.placing = null;
373
+ this.reRenderField(saved, pageNumber);
371
374
  (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state, event: 'added-field' });
372
375
  }
373
376
  }
@@ -398,7 +401,7 @@ const VerdocsTemplateFields = class {
398
401
  { name: 'page', type: 'canvas' },
399
402
  { name: 'controls', type: 'div' },
400
403
  ] })));
401
- })), 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) }))));
404
+ })), this.showMustSelectRole && (index.h("verdocs-ok-dialog", { heading: "Unable to add field", message: this.roleStore.get('roles').length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
402
405
  }
403
406
  };
404
407
  VerdocsTemplateFields.style = verdocsTemplateFieldsCss;
@@ -53,7 +53,7 @@ export class VerdocsTemplateFields {
53
53
  this.selectedRoleName = '';
54
54
  }
55
55
  async componentWillLoad() {
56
- var _a, _b, _c, _d, _e, _f, _g;
56
+ var _a, _b, _c, _d, _e;
57
57
  try {
58
58
  this.endpoint.loadSession();
59
59
  if (!this.templateId) {
@@ -67,11 +67,12 @@ export class VerdocsTemplateFields {
67
67
  this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
68
68
  this.fieldStore = getTemplateFieldStore(this.templateId);
69
69
  this.roleStore = getTemplateRoleStore(this.templateId);
70
- 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) || '';
70
+ this.selectedRoleName = ((_b = (_a = this.roleStore.get('roles')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) || '';
71
+ console.log('Sel role', this.selectedRoleName);
71
72
  }
72
73
  catch (e) {
73
74
  console.log('[FIELDS] Error with preview session', e);
74
- (_e = this.sdkError) === null || _e === void 0 ? void 0 : _e.emit(new SDKError(e.message, (_f = e.response) === null || _f === void 0 ? void 0 : _f.status, (_g = e.response) === null || _g === void 0 ? void 0 : _g.data));
75
+ (_c = this.sdkError) === null || _c === void 0 ? void 0 : _c.emit(new SDKError(e.message, (_d = e.response) === null || _d === void 0 ? void 0 : _d.status, (_e = e.response) === null || _e === void 0 ? void 0 : _e.data));
75
76
  }
76
77
  }
77
78
  componentDidRender() {
@@ -85,10 +86,11 @@ export class VerdocsTemplateFields {
85
86
  }
86
87
  }
87
88
  componentWillUpdate() {
88
- var _a, _b, _c, _d;
89
+ var _a;
89
90
  // If a new role was added and there were none yet so far, or the "selected" role was deleted, reset our selection
90
- if (!this.selectedRoleName || !Object.values(this.roleStore).find(role => role && role.name === this.selectedRoleName)) {
91
- 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) || '';
91
+ const roles = this.roleStore.get('roles');
92
+ if (!this.selectedRoleName || !roles.find(role => role && role.name === this.selectedRoleName)) {
93
+ this.selectedRoleName = ((_a = roles[0]) === null || _a === void 0 ? void 0 : _a.name) || '';
92
94
  console.log('[FIELDS] Selected new role', this.selectedRoleName);
93
95
  }
94
96
  }
@@ -330,8 +332,9 @@ export class VerdocsTemplateFields {
330
332
  }
331
333
  const saved = await createField(this.endpoint, this.templateId, field);
332
334
  console.log('[FIELDS] Saved field', saved);
333
- this.fieldStore.set('fields', [...this.fieldStore.state.fields, saved]);
335
+ this.fieldStore.set('fields', [...this.fieldStore.get('fields'), saved]);
334
336
  this.placing = null;
337
+ this.reRenderField(saved, pageNumber);
335
338
  (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state, event: 'added-field' });
336
339
  }
337
340
  }
@@ -362,7 +365,7 @@ export class VerdocsTemplateFields {
362
365
  { name: 'page', type: 'canvas' },
363
366
  { name: 'controls', type: 'div' },
364
367
  ] })));
365
- })), this.showMustSelectRole && (h("verdocs-ok-dialog", { heading: "Unable to add field", message: Object.keys(this.roleStore).length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
368
+ })), this.showMustSelectRole && (h("verdocs-ok-dialog", { heading: "Unable to add field", message: this.roleStore.get('roles').length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
366
369
  }
367
370
  static get is() { return "verdocs-template-fields"; }
368
371
  static get originalStyleUrls() {
@@ -63,7 +63,7 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
63
63
  this.selectedRoleName = '';
64
64
  }
65
65
  async componentWillLoad() {
66
- var _a, _b, _c, _d, _e, _f, _g;
66
+ var _a, _b, _c, _d, _e;
67
67
  try {
68
68
  this.endpoint.loadSession();
69
69
  if (!this.templateId) {
@@ -77,11 +77,12 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
77
77
  this.templateStore = await getTemplateStore(this.endpoint, this.templateId, false);
78
78
  this.fieldStore = getTemplateFieldStore(this.templateId);
79
79
  this.roleStore = getTemplateRoleStore(this.templateId);
80
- 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) || '';
80
+ this.selectedRoleName = ((_b = (_a = this.roleStore.get('roles')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) || '';
81
+ console.log('Sel role', this.selectedRoleName);
81
82
  }
82
83
  catch (e) {
83
84
  console.log('[FIELDS] Error with preview session', e);
84
- (_e = this.sdkError) === null || _e === void 0 ? void 0 : _e.emit(new SDKError(e.message, (_f = e.response) === null || _f === void 0 ? void 0 : _f.status, (_g = e.response) === null || _g === void 0 ? void 0 : _g.data));
85
+ (_c = this.sdkError) === null || _c === void 0 ? void 0 : _c.emit(new SDKError(e.message, (_d = e.response) === null || _d === void 0 ? void 0 : _d.status, (_e = e.response) === null || _e === void 0 ? void 0 : _e.data));
85
86
  }
86
87
  }
87
88
  componentDidRender() {
@@ -95,10 +96,11 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
95
96
  }
96
97
  }
97
98
  componentWillUpdate() {
98
- var _a, _b, _c, _d;
99
+ var _a;
99
100
  // If a new role was added and there were none yet so far, or the "selected" role was deleted, reset our selection
100
- if (!this.selectedRoleName || !Object.values(this.roleStore).find(role => role && role.name === this.selectedRoleName)) {
101
- this.selectedRoleName = ((_d = (_c = (_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.roles) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name) || '';
101
+ const roles = this.roleStore.get('roles');
102
+ if (!this.selectedRoleName || !roles.find(role => role && role.name === this.selectedRoleName)) {
103
+ this.selectedRoleName = ((_a = roles[0]) === null || _a === void 0 ? void 0 : _a.name) || '';
102
104
  console.log('[FIELDS] Selected new role', this.selectedRoleName);
103
105
  }
104
106
  }
@@ -340,8 +342,9 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
340
342
  }
341
343
  const saved = await createField(this.endpoint, this.templateId, field);
342
344
  console.log('[FIELDS] Saved field', saved);
343
- this.fieldStore.set('fields', [...this.fieldStore.state.fields, saved]);
345
+ this.fieldStore.set('fields', [...this.fieldStore.get('fields'), saved]);
344
346
  this.placing = null;
347
+ this.reRenderField(saved, pageNumber);
345
348
  (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state, event: 'added-field' });
346
349
  }
347
350
  }
@@ -372,7 +375,7 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
372
375
  { name: 'page', type: 'canvas' },
373
376
  { name: 'controls', type: 'div' },
374
377
  ] })));
375
- })), this.showMustSelectRole && (h("verdocs-ok-dialog", { heading: "Unable to add field", message: Object.keys(this.roleStore).length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
378
+ })), this.showMustSelectRole && (h("verdocs-ok-dialog", { heading: "Unable to add field", message: this.roleStore.get('roles').length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
376
379
  }
377
380
  static get style() { return verdocsTemplateFieldsCss; }
378
381
  }, [0, "verdocs-template-fields", {