@ironcode/vas-lib 1.0.2 → 1.2.0
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/cjs/lib/entity/vas-base.model.d.ts +8 -0
- package/cjs/lib/entity/vas-base.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-base.model.js +9 -0
- package/cjs/lib/entity/vas-base.model.js.map +1 -1
- package/cjs/lib/entity/vas-branch.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-branch.model.js.map +1 -1
- package/cjs/lib/entity/vas-contact.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-contact.model.js.map +1 -1
- package/cjs/lib/entity/vas-control-type.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-control-type.model.js +1 -2
- package/cjs/lib/entity/vas-control-type.model.js.map +1 -1
- package/cjs/lib/entity/vas-control.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-control.model.js +1 -1
- package/cjs/lib/entity/vas-control.model.js.map +1 -1
- package/cjs/lib/entity/vas-field.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-field.model.js +1 -2
- package/cjs/lib/entity/vas-field.model.js.map +1 -1
- package/cjs/lib/entity/vas-file.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-file.model.js +1 -2
- package/cjs/lib/entity/vas-file.model.js.map +1 -1
- package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-form.model.js.map +1 -1
- package/cjs/lib/entity/vas-group.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-group.model.js +1 -2
- package/cjs/lib/entity/vas-group.model.js.map +1 -1
- package/cjs/lib/entity/vas-instruction-job-field.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-instruction-job-field.model.js.map +1 -1
- package/cjs/lib/entity/vas-instruction-job.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-instruction-job.model.js.map +1 -1
- package/cjs/lib/entity/vas-instruction-provider.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-instruction-provider.model.js.map +1 -1
- package/cjs/lib/entity/vas-instruction.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-instruction.model.js.map +1 -1
- package/cjs/lib/entity/vas-invitation.d.ts.map +1 -1
- package/cjs/lib/entity/vas-invitation.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.d.ts +55 -66
- package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.js +91 -68
- package/cjs/lib/entity/vas-job.model.js.map +1 -1
- package/cjs/lib/entity/vas-membership.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-membership.model.js +1 -1
- package/cjs/lib/entity/vas-membership.model.js.map +1 -1
- package/cjs/lib/entity/vas-note.model.d.ts +1 -0
- package/cjs/lib/entity/vas-note.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-note.model.js +3 -0
- package/cjs/lib/entity/vas-note.model.js.map +1 -1
- package/cjs/lib/entity/vas-report-request.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-report-request.model.js +1 -4
- package/cjs/lib/entity/vas-report-request.model.js.map +1 -1
- package/cjs/lib/entity/vas-report.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-report.model.js.map +1 -1
- package/cjs/lib/entity/vas-user.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-user.model.js.map +1 -1
- package/esm2020/lib/entity/vas-base.model.mjs +18 -1
- package/esm2020/lib/entity/vas-branch.model.mjs +1 -1
- package/esm2020/lib/entity/vas-contact.model.mjs +1 -1
- package/esm2020/lib/entity/vas-control-type.model.mjs +2 -3
- package/esm2020/lib/entity/vas-control.model.mjs +2 -2
- package/esm2020/lib/entity/vas-field.model.mjs +2 -3
- package/esm2020/lib/entity/vas-file.model.mjs +2 -3
- package/esm2020/lib/entity/vas-form.model.mjs +1 -1
- package/esm2020/lib/entity/vas-group.model.mjs +2 -3
- package/esm2020/lib/entity/vas-instruction-job-field.model.mjs +1 -1
- package/esm2020/lib/entity/vas-instruction-job.model.mjs +1 -1
- package/esm2020/lib/entity/vas-instruction-provider.model.mjs +1 -1
- package/esm2020/lib/entity/vas-instruction.model.mjs +1 -1
- package/esm2020/lib/entity/vas-invitation.mjs +1 -1
- package/esm2020/lib/entity/vas-job.model.mjs +91 -69
- package/esm2020/lib/entity/vas-membership.model.mjs +2 -2
- package/esm2020/lib/entity/vas-note.model.mjs +10 -1
- package/esm2020/lib/entity/vas-report-request.model.mjs +2 -4
- package/esm2020/lib/entity/vas-report.model.mjs +1 -1
- package/esm2020/lib/entity/vas-user.model.mjs +1 -1
- package/fesm2015/ironcode-vas-lib.mjs +107 -75
- package/fesm2015/ironcode-vas-lib.mjs.map +1 -1
- package/fesm2020/ironcode-vas-lib.mjs +121 -75
- package/fesm2020/ironcode-vas-lib.mjs.map +1 -1
- package/lib/entity/vas-base.model.d.ts +8 -0
- package/lib/entity/vas-job.model.d.ts +55 -66
- package/lib/entity/vas-note.model.d.ts +1 -0
- package/package.json +1 -1
|
@@ -39,4 +39,4 @@ export class VasUserModel extends VasBaseModel {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFzLXVzZXIubW9kZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy92YXMtbGliL3NyYy9saWIvZW50aXR5L3Zhcy11c2VyLm1vZGVsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUVoRCxNQUFNLE9BQU8sWUFBYSxTQUFRLFlBQVk7SUFFNUMsWUFDa0IsRUFBVSxFQUNWLFVBQWtCLEVBQUUsRUFDcEIsZ0JBQXdCLEVBQUUsRUFDMUIsW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yXG4gICAgICBtb2RpZmllZDogdGhpcy5tb2RpZmllZCxcclxuICAgICAgc2VydmVyTW9kaWZpZWQ6IHRoaXMuc2VydmVyTW9kaWZpZWQsXHJcbiAgICAgIG1vZGlmaWVkQnk6IHRoaXMubW9kaWZpZWRCeSxcclxuICAgICAgY3JlYXRlZEJ5TmFtZTogdGhpcy5jcmVhdGVkQnlOYW1lLFxyXG4gICAgICBtb2RpZmllZEJ5TmFtZTogdGhpcy5tb2RpZmllZEJ5TmFtZSxcclxuICAgICAgZW1haWw6IHRoaXMuZW1haWwsXHJcbiAgICAgIG5hbWU6IHRoaXMubmFtZSxcclxuICAgICAgdXNlcm5hbWU6IHRoaXMudXNlcm5hbWUsXHJcbiAgICAgIG1lbWJlcnNoaXBzOiB0aGlzLm1lbWJlcnNoaXBzLFxyXG4gICAgICBpbnN0cnVjdGlvblByb3ZpZGVyczogdGhpcy5pbnN0cnVjdGlvblByb3ZpZGVyc1xyXG4gICAgfTtcclxuICB9XHJcbn1cclxuIl19
|
|
@@ -33,6 +33,12 @@ class VasBaseModel {
|
|
|
33
33
|
this.createdByName = createdByName;
|
|
34
34
|
this.modifiedByName = modifiedByName;
|
|
35
35
|
}
|
|
36
|
+
static fromDto(dto) {
|
|
37
|
+
return new VasBaseModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '');
|
|
38
|
+
}
|
|
39
|
+
static create(user, values = {}) {
|
|
40
|
+
return this.fromDto(Object.assign(Object.assign({}, values), { id: UUID.UUID(), created: moment().toISOString(), modified: moment().toISOString(), createdBy: user.id, createdByName: user.name, modifiedBy: user.id, modifiedByName: user.name }));
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
class VasUserModel extends VasBaseModel {
|
|
@@ -384,7 +390,7 @@ class VasControlTypeModel extends VasBaseModel {
|
|
|
384
390
|
static fromDto(dto) {
|
|
385
391
|
return new VasControlTypeModel(
|
|
386
392
|
// eslint-disable-next-line new-cap
|
|
387
|
-
dto.id ||
|
|
393
|
+
dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.name || '');
|
|
388
394
|
}
|
|
389
395
|
/**
|
|
390
396
|
* @return {VasControlTypeDto}
|
|
@@ -509,7 +515,7 @@ class VasControlModel extends VasAccountObjectModel {
|
|
|
509
515
|
};
|
|
510
516
|
return new VasControlModel(
|
|
511
517
|
// eslint-disable-next-line new-cap
|
|
512
|
-
dto.id ||
|
|
518
|
+
dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', handleControlType(dto.controlType), dto.group || '', dto.validators || [], dto.name || '', dto.title || '', dto.linkable || false, dto.sequence || 0, dto.description || '', dto.defaultValue || '', JSON.parse(dto.config || '{}'), dto.descriptionImage || '', dto.portalEnabled || false);
|
|
513
519
|
}
|
|
514
520
|
/**
|
|
515
521
|
* @param {string} value
|
|
@@ -608,7 +614,7 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
608
614
|
* @return {VasFieldModel}
|
|
609
615
|
*/
|
|
610
616
|
static fromDto(fieldDto) {
|
|
611
|
-
return new VasFieldModel(fieldDto.id ||
|
|
617
|
+
return new VasFieldModel(fieldDto.id || '', fieldDto.created || '', fieldDto.serverCreated || '', fieldDto.createdBy || '', fieldDto.modified || '', fieldDto.serverModified || '', fieldDto.modifiedBy || '', fieldDto.createdByName || '', fieldDto.modifiedByName || '', fieldDto.account || '', fieldDto.job || '', fieldDto.control || '', fieldDto.fieldJobPointers || [], fieldDto.value || '', fieldDto.version || 0);
|
|
612
618
|
}
|
|
613
619
|
/**
|
|
614
620
|
* @return {VasFieldDto}
|
|
@@ -715,7 +721,7 @@ class VasFileModel extends VasJobDataModel {
|
|
|
715
721
|
}, '', '', '', '', '');
|
|
716
722
|
}
|
|
717
723
|
static fromDto(dto) {
|
|
718
|
-
return new VasFileModel(dto.id ||
|
|
724
|
+
return new VasFileModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job || '', dto.name || '', dto.fileSize || 0, dto.mimeType || '', dto.sequence || 0, VasFileModel.parseConfig(dto.config), dto.url || '', dto.controlPath || '', dto.message || '', dto.status || '', dto.uri || '');
|
|
719
725
|
}
|
|
720
726
|
static parseConfig(config = '') {
|
|
721
727
|
try {
|
|
@@ -829,7 +835,7 @@ class VasGroupModel extends VasBaseModel {
|
|
|
829
835
|
static fromDto(dto) {
|
|
830
836
|
return new VasGroupModel(
|
|
831
837
|
// eslint-disable-next-line new-cap
|
|
832
|
-
dto.id ||
|
|
838
|
+
dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.name || '', dto.title || '', dto.description || '', dto.sequence || 0, dto.includeInSummary || false, dto.forms || [], dto.visibilityControl || '', dto.visibleIfEquals || '', (dto.controls || [])
|
|
833
839
|
.filter(control => control.name.startsWith('fields.'))
|
|
834
840
|
.sort((a, b) => a.sequence - b.sequence)
|
|
835
841
|
.map(c => VasControlModel.fromDto(c)), dto.scoreWeight || 1);
|
|
@@ -1193,6 +1199,9 @@ class VasNoteModel extends VasJobDataModel {
|
|
|
1193
1199
|
sensitive: this.sensitive,
|
|
1194
1200
|
};
|
|
1195
1201
|
}
|
|
1202
|
+
toApiDto(options) {
|
|
1203
|
+
return Object.assign(Object.assign({}, super.toApiDto(options)), { content: this.content, sensitive: this.sensitive, created: this.created, modified: this.modified });
|
|
1204
|
+
}
|
|
1196
1205
|
}
|
|
1197
1206
|
|
|
1198
1207
|
/**
|
|
@@ -1610,8 +1619,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1610
1619
|
.filter(prop => !nativeProps.includes(prop));
|
|
1611
1620
|
}
|
|
1612
1621
|
/**
|
|
1613
|
-
* Returns
|
|
1614
|
-
* the type
|
|
1622
|
+
* Returns the list of properties of the Job type
|
|
1615
1623
|
*/
|
|
1616
1624
|
get staticProperties() {
|
|
1617
1625
|
return Object.getOwnPropertyNames(VasJobModel.empty());
|
|
@@ -1631,6 +1639,28 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1631
1639
|
.forEach((key) => model.$this[key] = dto[key]);
|
|
1632
1640
|
return model;
|
|
1633
1641
|
}
|
|
1642
|
+
/**
|
|
1643
|
+
* This method will instantiate a new JobModel. The difference with this
|
|
1644
|
+
* method of instantiation is that we are coming from a relation frame i.e.
|
|
1645
|
+
* the job has a list of {@link VasFieldDto} instead of a Job document.
|
|
1646
|
+
*
|
|
1647
|
+
*/
|
|
1648
|
+
static fromRelational(dto, form) {
|
|
1649
|
+
const model = new VasJobModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.reference || '', dto.jobDate || '', dto.jobStatus || '', dto.jobType || '', dto.assigneeId || '', dto.formId || '', dto.timeZoneOffset || moment$1().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.fields || [], dto.files || [], dto.createdByDisplayName || '', dto.modifiedByDisplayName || '', dto.geoLocation || getEmptyGeoLocation());
|
|
1650
|
+
form.groups
|
|
1651
|
+
.forEach(group => {
|
|
1652
|
+
group.controls
|
|
1653
|
+
.forEach(control => {
|
|
1654
|
+
var _a;
|
|
1655
|
+
const field = (_a = dto.fields) === null || _a === void 0 ? void 0 : _a.find(f => f.control === control.id);
|
|
1656
|
+
if (!field) {
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
model.getGroup(group.name)[control.name] = field.value;
|
|
1660
|
+
});
|
|
1661
|
+
});
|
|
1662
|
+
return model;
|
|
1663
|
+
}
|
|
1634
1664
|
/**
|
|
1635
1665
|
* @param {VasFormModel} formModel
|
|
1636
1666
|
* @return {Record<string, VasFieldDtoValue>}
|
|
@@ -1711,18 +1741,63 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1711
1741
|
};
|
|
1712
1742
|
}
|
|
1713
1743
|
/**
|
|
1714
|
-
* This method will
|
|
1715
|
-
*
|
|
1716
|
-
*
|
|
1717
|
-
*
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1744
|
+
* This method will return the dynamic property from the JobModel that
|
|
1745
|
+
* represent a group (from a form).
|
|
1746
|
+
*
|
|
1747
|
+
* @param name the name of the group
|
|
1748
|
+
* @param init if true (default) and group is not found, initialise an empty
|
|
1749
|
+
* group, otherwise throw an error
|
|
1750
|
+
*/
|
|
1751
|
+
getGroup(name, init = true) {
|
|
1752
|
+
let prop;
|
|
1753
|
+
if (this.staticProperties.includes(name)) {
|
|
1754
|
+
throw Error(`invalid group name ${name}, not a dynamic property`);
|
|
1755
|
+
}
|
|
1756
|
+
else if (this.$this[name] === undefined) {
|
|
1757
|
+
if (init) {
|
|
1758
|
+
prop = this.$this[name] = {};
|
|
1759
|
+
}
|
|
1760
|
+
else {
|
|
1761
|
+
throw Error(`invalid group name ${name}, not found`);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
else {
|
|
1765
|
+
prop = this.$this[name];
|
|
1766
|
+
if (typeof prop !== 'object') {
|
|
1767
|
+
throw Error(`invalid group name ${name}, not an object`);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return prop;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* @param path path segments
|
|
1774
|
+
*/
|
|
1775
|
+
getValueByPath(path = []) {
|
|
1776
|
+
return getValueByPath(path, this.$this);
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* In order to understand why we need this method it is important to
|
|
1780
|
+
* understand that within the system, Jobs can be represented in one of two
|
|
1781
|
+
* ways, document and relational.
|
|
1782
|
+
*
|
|
1783
|
+
* The important distinction is how values submitted by a form are stored.
|
|
1784
|
+
*
|
|
1785
|
+
* Jobs stored as documents (JSON objects) will store user values, as dynamic
|
|
1786
|
+
* properties of the document.
|
|
1787
|
+
*
|
|
1788
|
+
* Whereas, Jobs stored as relational, will store user values in an array of
|
|
1789
|
+
* {@link VasFieldDto} objects.
|
|
1790
|
+
*
|
|
1791
|
+
* Depending on where we are in the system, either one of these approaches can
|
|
1792
|
+
* be more useful than the other.
|
|
1793
|
+
*
|
|
1794
|
+
* This method, assumes that the JobModel has been instantiated from a
|
|
1795
|
+
* document representation, and serves to hydrate the fields array. In order
|
|
1796
|
+
* to achieve this, knowledge of the {@link VasFormDto} that created the job
|
|
1797
|
+
* is required.
|
|
1798
|
+
*
|
|
1799
|
+
*
|
|
1800
|
+
* Job in document representation
|
|
1726
1801
|
* {
|
|
1727
1802
|
* id: <guid>,
|
|
1728
1803
|
* reference: "something"
|
|
@@ -1732,7 +1807,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1732
1807
|
* }
|
|
1733
1808
|
* }
|
|
1734
1809
|
*
|
|
1735
|
-
*
|
|
1810
|
+
* Job in relational representation
|
|
1736
1811
|
* {
|
|
1737
1812
|
* id: <guid>,
|
|
1738
1813
|
* reference: "something"
|
|
@@ -1747,46 +1822,11 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1747
1822
|
* ]
|
|
1748
1823
|
* }
|
|
1749
1824
|
*
|
|
1750
|
-
* So, what this method does is given a JobModel in the form of A, read all
|
|
1751
|
-
* of those dynamic properties and set them into `fields`. Doing this requires
|
|
1752
|
-
* knowledge of the Form that was used to create the job. Moreover, since the
|
|
1753
|
-
* dynamic properties do not contain the ids of the fields, we also allow to
|
|
1754
|
-
* pass in a `controlFieldIdMap`. This map stores the mapping between Control
|
|
1755
|
-
* and the Field that was created in the Job to store the value for that
|
|
1756
|
-
* Control. This is useful, if for example you want to compare a Job in form A
|
|
1757
|
-
* with a Job in form B, for example if you want to update the Job on the API
|
|
1758
|
-
* with a Job that was saved by a client in form A.
|
|
1759
|
-
*
|
|
1760
|
-
* E.g.
|
|
1761
|
-
* Client -> API: client requests form
|
|
1762
|
-
* User -> Client: user fills in the form and submits
|
|
1763
|
-
* Client -> Firestore: client saves the Job in form A i.e. dynamic props
|
|
1764
|
-
* Firestore -> Function: A function is triggered to sync the job to the API
|
|
1765
|
-
* Function -> API: Function checks if job already exists, it receives 404
|
|
1766
|
-
* Function -> Function: The function calls `hydrateFields(...)`
|
|
1767
|
-
* Function -> API: The function POST the Job to /jobs
|
|
1768
|
-
* Function -> API: The function POST each field to /fields
|
|
1769
1825
|
*
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
1773
|
-
*
|
|
1774
|
-
* Firestore -> Function: A function is triggered to sync the job to the API
|
|
1775
|
-
* Function -> API: Function checks if job already exists, it receives 200
|
|
1776
|
-
* Function -> Function: The function calls `hydrateFields(...)` passing in
|
|
1777
|
-
* the map is made by iterating over the fields it
|
|
1778
|
-
* received from the API and storing the mappings
|
|
1779
|
-
* between controlId and fieldId for each field
|
|
1780
|
-
* Function -> API: The function PATCH the Job to /jobs
|
|
1781
|
-
* Function -> API: The function POST/PATCH each field to /fields
|
|
1782
|
-
* treated as new
|
|
1783
|
-
*
|
|
1784
|
-
* @param {VasFormModel} formModel the VasFormModel that was used to create
|
|
1785
|
-
* the job
|
|
1786
|
-
* @param {Map<string, string>} controlFieldIdMap a mapping of control to
|
|
1787
|
-
* field ids. This is used to determine whether a new id for the field should
|
|
1788
|
-
* be generated, or to reuse an existing one from the map.
|
|
1789
|
-
* @param {Array<string>} controlNames if a value is provided, it will be used
|
|
1826
|
+
* @param formModel the VasFormModel that was used to create the job
|
|
1827
|
+
* @param controlFieldIdMap This is used to determine the id each field.
|
|
1828
|
+
* Either one will be found in the map, or a new one is generated.
|
|
1829
|
+
* @param controlNames if a value is provided, it will be used
|
|
1790
1830
|
* to filter the fields that are returned.
|
|
1791
1831
|
* @return {Array<VasFieldDto>}
|
|
1792
1832
|
*/
|
|
@@ -1818,13 +1858,6 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1818
1858
|
});
|
|
1819
1859
|
this.fields = fields;
|
|
1820
1860
|
}
|
|
1821
|
-
/**
|
|
1822
|
-
* @param {string[]} path path segments
|
|
1823
|
-
* @return {void}
|
|
1824
|
-
*/
|
|
1825
|
-
getValueByPath(path = []) {
|
|
1826
|
-
return getValueByPath(path, this.$this);
|
|
1827
|
-
}
|
|
1828
1861
|
/**
|
|
1829
1862
|
* A very non sophisticated way to set values in the job via paths
|
|
1830
1863
|
*
|
|
@@ -1839,8 +1872,8 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1839
1872
|
* }
|
|
1840
1873
|
* }
|
|
1841
1874
|
*
|
|
1842
|
-
* @param
|
|
1843
|
-
* @param
|
|
1875
|
+
* @param value the value to set
|
|
1876
|
+
* @param path path segments
|
|
1844
1877
|
*/
|
|
1845
1878
|
setValueByPath(value, path = []) {
|
|
1846
1879
|
switch (path.length) {
|
|
@@ -1867,9 +1900,8 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1867
1900
|
}
|
|
1868
1901
|
}
|
|
1869
1902
|
/**
|
|
1870
|
-
* @param
|
|
1903
|
+
* @param staticOnly if true, will only output values for the static
|
|
1871
1904
|
* properties in the dto
|
|
1872
|
-
* @return {VasJobDto}
|
|
1873
1905
|
*/
|
|
1874
1906
|
toDto(staticOnly = false) {
|
|
1875
1907
|
if (staticOnly) {
|
|
@@ -1904,7 +1936,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1904
1936
|
}
|
|
1905
1937
|
const dto = {};
|
|
1906
1938
|
[...this.staticProperties, ...this.dynamicProperties]
|
|
1907
|
-
.forEach(prop =>
|
|
1939
|
+
.forEach(prop => dto[prop] = this.$this[prop]);
|
|
1908
1940
|
return dto;
|
|
1909
1941
|
}
|
|
1910
1942
|
/**
|
|
@@ -1931,7 +1963,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1931
1963
|
*
|
|
1932
1964
|
* @param {string} value a string with the syntax
|
|
1933
1965
|
* @param {ParseSyntaxOptions} options
|
|
1934
|
-
* @return
|
|
1966
|
+
* @return the results of parsing the syntax on this job
|
|
1935
1967
|
*/
|
|
1936
1968
|
parseSyntax(value, options = {
|
|
1937
1969
|
timeZoneOffset: 0
|
|
@@ -1965,7 +1997,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1965
1997
|
result = (this.getValueByPath(path) || '').toString();
|
|
1966
1998
|
}
|
|
1967
1999
|
else if (objectKey === 'fields') {
|
|
1968
|
-
result = (getValueByPath(path, this.getFields2()) || '').toString();
|
|
2000
|
+
result = (getValueByPath(['fields.' + path.shift(), ...path], this.getFields2()) || '').toString();
|
|
1969
2001
|
}
|
|
1970
2002
|
else if (objectKey.length) {
|
|
1971
2003
|
if (options.objects) {
|
|
@@ -2044,7 +2076,7 @@ class VasMembershipModel extends VasAccountObjectModel {
|
|
|
2044
2076
|
static fromDto(dto) {
|
|
2045
2077
|
return new VasMembershipModel(
|
|
2046
2078
|
// eslint-disable-next-line new-cap
|
|
2047
|
-
dto.id ||
|
|
2079
|
+
dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.user || '', dto.admin || false, dto.lookupTypes || [], dto.contactTypes || [], dto.accessGroups || [], dto.jobStatuses || [], dto.jobTypes || [], dto.taskTypes || []);
|
|
2048
2080
|
}
|
|
2049
2081
|
toDto() {
|
|
2050
2082
|
return {
|
|
@@ -2111,7 +2143,7 @@ class VasReportRequestModel extends VasAccountObjectModel {
|
|
|
2111
2143
|
this.reportId = reportId;
|
|
2112
2144
|
}
|
|
2113
2145
|
static fromDto(dto) {
|
|
2114
|
-
return new VasReportRequestModel(dto.id ||
|
|
2146
|
+
return new VasReportRequestModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.error || '', dto.jobId || '', dto.title || '', dto.url || '', dto.reportId || '');
|
|
2115
2147
|
}
|
|
2116
2148
|
toDto() {
|
|
2117
2149
|
return {
|