@ironcode/vas-lib 0.0.18 → 0.0.20
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-control.dto.d.ts +1 -0
- package/cjs/lib/entity/vas-control.dto.d.ts.map +1 -1
- package/cjs/lib/entity/vas-control.dto.js.map +1 -1
- package/cjs/lib/entity/vas-control.model.d.ts +3 -1
- package/cjs/lib/entity/vas-control.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-control.model.js +11 -3
- package/cjs/lib/entity/vas-control.model.js.map +1 -1
- package/cjs/lib/entity/vas-field.model.d.ts +1 -2
- package/cjs/lib/entity/vas-field.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-field.model.js +3 -11
- package/cjs/lib/entity/vas-field.model.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.d.ts +10 -48
- package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.js +10 -71
- package/cjs/lib/entity/vas-job.model.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.spec-data.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.spec-data.js +1 -0
- package/cjs/lib/entity/vas-job.model.spec-data.js.map +1 -1
- package/esm2020/lib/entity/vas-control.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-control.model.mjs +12 -4
- package/esm2020/lib/entity/vas-field.model.mjs +4 -12
- package/esm2020/lib/entity/vas-job.model.mjs +11 -72
- package/fesm2015/ironcode-vas-lib.mjs +24 -85
- package/fesm2015/ironcode-vas-lib.mjs.map +1 -1
- package/fesm2020/ironcode-vas-lib.mjs +24 -85
- package/fesm2020/ironcode-vas-lib.mjs.map +1 -1
- package/lib/entity/vas-control.dto.d.ts +1 -0
- package/lib/entity/vas-control.model.d.ts +3 -1
- package/lib/entity/vas-field.model.d.ts +1 -2
- package/lib/entity/vas-job.model.d.ts +10 -48
- package/package.json +1 -1
|
@@ -199,8 +199,9 @@ class VasControlModel extends VasBaseModel {
|
|
|
199
199
|
* @param {string} description
|
|
200
200
|
* @param {string} defaultValue
|
|
201
201
|
* @param {object} config
|
|
202
|
+
* @param {string} descriptionImage
|
|
202
203
|
*/
|
|
203
|
-
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, controlType, group, validators, name, title, linkable, sequence, description, defaultValue, _config) {
|
|
204
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, controlType, group, validators, name, title, linkable, sequence, description, defaultValue, _config, descriptionImage) {
|
|
204
205
|
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy);
|
|
205
206
|
this.id = id;
|
|
206
207
|
this.created = created;
|
|
@@ -221,6 +222,7 @@ class VasControlModel extends VasBaseModel {
|
|
|
221
222
|
this.description = description;
|
|
222
223
|
this.defaultValue = defaultValue;
|
|
223
224
|
this._config = _config;
|
|
225
|
+
this.descriptionImage = descriptionImage;
|
|
224
226
|
this.controlTypeModel = undefined;
|
|
225
227
|
this.configCache = undefined;
|
|
226
228
|
}
|
|
@@ -255,6 +257,11 @@ class VasControlModel extends VasBaseModel {
|
|
|
255
257
|
case 'contact': {
|
|
256
258
|
return {};
|
|
257
259
|
}
|
|
260
|
+
case 'toggle': {
|
|
261
|
+
return {
|
|
262
|
+
checked: false, comment: ''
|
|
263
|
+
};
|
|
264
|
+
}
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
267
|
return this.parseMaybeJson(this.defaultValue);
|
|
@@ -289,7 +296,7 @@ class VasControlModel extends VasBaseModel {
|
|
|
289
296
|
static fromDto(dto) {
|
|
290
297
|
return new VasControlModel(
|
|
291
298
|
// eslint-disable-next-line new-cap
|
|
292
|
-
dto.id || UUID.UUID(), dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.account || '', dto.accessGroup || '', dto.controlType || '', dto.group || '', dto.validators || [], dto.name || '', dto.title || '', dto.linkable || false, dto.sequence || 0, dto.description || '', dto.defaultValue || '', dto.config || '{}');
|
|
299
|
+
dto.id || UUID.UUID(), dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.account || '', dto.accessGroup || '', dto.controlType || '', dto.group || '', dto.validators || [], dto.name || '', dto.title || '', dto.linkable || false, dto.sequence || 0, dto.description || '', dto.defaultValue || '', dto.config || '{}', dto.descriptionImage || '');
|
|
293
300
|
}
|
|
294
301
|
/**
|
|
295
302
|
* @param {string} value
|
|
@@ -329,7 +336,8 @@ class VasControlModel extends VasBaseModel {
|
|
|
329
336
|
sequence: this.sequence,
|
|
330
337
|
description: this.description,
|
|
331
338
|
defaultValue: this.defaultValue,
|
|
332
|
-
config: this.config
|
|
339
|
+
config: this.config,
|
|
340
|
+
descriptionImage: this.descriptionImage,
|
|
333
341
|
};
|
|
334
342
|
}
|
|
335
343
|
}
|
|
@@ -439,7 +447,7 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
439
447
|
* @return {VasFieldModel}
|
|
440
448
|
*/
|
|
441
449
|
static fromDto(fieldDto) {
|
|
442
|
-
return new VasFieldModel(fieldDto.id || UUID.UUID(), fieldDto.created || '', fieldDto.serverCreated || '', fieldDto.createdBy || '', fieldDto.modified || '', fieldDto.serverModified || '', fieldDto.modifiedBy || '', fieldDto.account || '', fieldDto.job || '', fieldDto.control || '', fieldDto.fieldJobPointers || [],
|
|
450
|
+
return new VasFieldModel(fieldDto.id || UUID.UUID(), fieldDto.created || '', fieldDto.serverCreated || '', fieldDto.createdBy || '', fieldDto.modified || '', fieldDto.serverModified || '', fieldDto.modifiedBy || '', fieldDto.account || '', fieldDto.job || '', fieldDto.control || '', fieldDto.fieldJobPointers || [], fieldDto.value || '', fieldDto.version || 0);
|
|
443
451
|
}
|
|
444
452
|
/**
|
|
445
453
|
* @return {VasFieldDto}
|
|
@@ -465,7 +473,7 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
465
473
|
* @return {object}
|
|
466
474
|
*/
|
|
467
475
|
toApiDto() {
|
|
468
|
-
return Object.assign(Object.assign({}, super.toApiDto()), { control: this.control, value: this.
|
|
476
|
+
return Object.assign(Object.assign({}, super.toApiDto()), { control: this.control, value: this.prepareApiValue(this.value) });
|
|
469
477
|
}
|
|
470
478
|
/**
|
|
471
479
|
* Prepares the value to be sent to the API. The api will only accept strings,
|
|
@@ -475,7 +483,7 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
475
483
|
* @return {string | number | boolean}
|
|
476
484
|
* @protected
|
|
477
485
|
*/
|
|
478
|
-
|
|
486
|
+
prepareApiValue(value) {
|
|
479
487
|
switch (typeof value) {
|
|
480
488
|
case 'object': {
|
|
481
489
|
return JSON.stringify(value);
|
|
@@ -494,14 +502,6 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
494
502
|
}
|
|
495
503
|
}
|
|
496
504
|
}
|
|
497
|
-
static fromApiValue(value) {
|
|
498
|
-
try {
|
|
499
|
-
return JSON.parse(value);
|
|
500
|
-
}
|
|
501
|
-
catch (e) {
|
|
502
|
-
return value;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
/**
|
|
@@ -1102,67 +1102,15 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1102
1102
|
/**
|
|
1103
1103
|
* This method will hydrate the `fields` property of the model. The reason for
|
|
1104
1104
|
* this is that we have different ways to store the field data. One way, is
|
|
1105
|
-
* we store them as dynamic properties of the job
|
|
1106
|
-
* is
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
* foo: {
|
|
1115
|
-
* bar: "value"
|
|
1116
|
-
* }
|
|
1117
|
-
* }
|
|
1118
|
-
*
|
|
1119
|
-
* B) job with array of Field
|
|
1120
|
-
* {
|
|
1121
|
-
* id: <guid>,
|
|
1122
|
-
* reference: "something"
|
|
1123
|
-
* <other static job properties>...
|
|
1124
|
-
* <will not have dynamic properties>...
|
|
1125
|
-
* fields: [
|
|
1126
|
-
* {
|
|
1127
|
-
* id: <guid>,
|
|
1128
|
-
* <other field properties>,
|
|
1129
|
-
* value: "value"
|
|
1130
|
-
* }
|
|
1131
|
-
* ]
|
|
1132
|
-
* }
|
|
1133
|
-
*
|
|
1134
|
-
* What this method does is given a VasJobModel that has been populated with
|
|
1135
|
-
* a VasJobDto in form B (i.e. `.fields` are populated - usually from a VASAPI
|
|
1136
|
-
* response), hydrate the dynamic properties of the model. NOTE: knowledge of
|
|
1137
|
-
* the Form that was used to crate the Job is required because it will contain
|
|
1138
|
-
* the Groups, which names are used in the hydrating
|
|
1139
|
-
*
|
|
1140
|
-
* @param {VasFormModel} formModel the VasFormModel that was used to create
|
|
1141
|
-
* the job
|
|
1142
|
-
* @return {void}
|
|
1143
|
-
*/
|
|
1144
|
-
hydrateDynamicProps(formModel) {
|
|
1145
|
-
formModel.groups
|
|
1146
|
-
.forEach(group => {
|
|
1147
|
-
const p0 = group.name;
|
|
1148
|
-
group.controls
|
|
1149
|
-
.forEach(control => {
|
|
1150
|
-
const p1 = control.name;
|
|
1151
|
-
const f = this.fields.find(field => field.control === control.id);
|
|
1152
|
-
if (!f) {
|
|
1153
|
-
return;
|
|
1154
|
-
}
|
|
1155
|
-
this.setValueByPath(f.value, [p0, p1]);
|
|
1156
|
-
});
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* This method will hydrate the `fields` property of the model. The reason for
|
|
1161
|
-
* this is that we have different ways to store the field data. One way, is
|
|
1162
|
-
* we store them as dynamic properties of the job e.g. job.foo.bar, the other
|
|
1163
|
-
* is in an array of Field. The former is nice to work with in clients,
|
|
1164
|
-
* whereas the latter more suited to relational database.
|
|
1165
|
-
*
|
|
1105
|
+
* we store them as dynamic properties of the job. For example job.foo.bar,
|
|
1106
|
+
* where `foo` is the name of a Group, and `bar` is the name of a control.
|
|
1107
|
+
* Thus, when we create a job using a form in the client, the job object will
|
|
1108
|
+
* have its static properties (id, account, reference etc), and also a number
|
|
1109
|
+
* of dynamic properties determined by the Groups and Controls. This kind of
|
|
1110
|
+
* object is nice to work with in certain circumstances. However, the api
|
|
1111
|
+
* works differently. In the API a Job is a record, and references a number of
|
|
1112
|
+
* Field records. Each Field stores the value. Comparing these two models we
|
|
1113
|
+
* have:
|
|
1166
1114
|
* A) job with dynamic properties, e.g.
|
|
1167
1115
|
* {
|
|
1168
1116
|
* id: <guid>,
|
|
@@ -1229,7 +1177,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1229
1177
|
* be generated, or to reuse an existing one from the map.
|
|
1230
1178
|
* @param {Array<string>} controlNames if a value is provided, it will be used
|
|
1231
1179
|
* to filter the fields that are returned.
|
|
1232
|
-
* @return {
|
|
1180
|
+
* @return {Array<VasFieldDto>}
|
|
1233
1181
|
*/
|
|
1234
1182
|
hydrateFields(formModel, controlFieldIdMap = new Map(), controlNames) {
|
|
1235
1183
|
const fields = [];
|
|
@@ -1294,20 +1242,11 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1294
1242
|
return;
|
|
1295
1243
|
}
|
|
1296
1244
|
case 2: {
|
|
1297
|
-
if (!this.$this[path[0]]) {
|
|
1298
|
-
this.$this[path[0]] = {};
|
|
1299
|
-
}
|
|
1300
1245
|
// eslint-disable-next-line max-len
|
|
1301
1246
|
this.$this[path[0]][path[1]] = value;
|
|
1302
1247
|
return;
|
|
1303
1248
|
}
|
|
1304
1249
|
case 3: {
|
|
1305
|
-
if (!this.$this[path[0]]) {
|
|
1306
|
-
this.$this[path[0]] = {};
|
|
1307
|
-
}
|
|
1308
|
-
if (!this.$this[path[0]][path[1]]) {
|
|
1309
|
-
this.$this[path[0]][path[1]] = {};
|
|
1310
|
-
}
|
|
1311
1250
|
// eslint-disable-next-line max-len
|
|
1312
1251
|
this.$this[path[0]][path[1]][path[2]] = value;
|
|
1313
1252
|
return;
|