@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}
|
|
@@ -468,7 +476,7 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
468
476
|
return {
|
|
469
477
|
...super.toApiDto(),
|
|
470
478
|
control: this.control,
|
|
471
|
-
value: this.
|
|
479
|
+
value: this.prepareApiValue(this.value)
|
|
472
480
|
};
|
|
473
481
|
}
|
|
474
482
|
/**
|
|
@@ -479,7 +487,7 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
479
487
|
* @return {string | number | boolean}
|
|
480
488
|
* @protected
|
|
481
489
|
*/
|
|
482
|
-
|
|
490
|
+
prepareApiValue(value) {
|
|
483
491
|
switch (typeof value) {
|
|
484
492
|
case 'object': {
|
|
485
493
|
return JSON.stringify(value);
|
|
@@ -498,14 +506,6 @@ class VasFieldModel extends VasJobDataModel {
|
|
|
498
506
|
}
|
|
499
507
|
}
|
|
500
508
|
}
|
|
501
|
-
static fromApiValue(value) {
|
|
502
|
-
try {
|
|
503
|
-
return JSON.parse(value);
|
|
504
|
-
}
|
|
505
|
-
catch (e) {
|
|
506
|
-
return value;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
/**
|
|
@@ -1111,67 +1111,15 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1111
1111
|
/**
|
|
1112
1112
|
* This method will hydrate the `fields` property of the model. The reason for
|
|
1113
1113
|
* this is that we have different ways to store the field data. One way, is
|
|
1114
|
-
* we store them as dynamic properties of the job
|
|
1115
|
-
* is
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1123
|
-
* foo: {
|
|
1124
|
-
* bar: "value"
|
|
1125
|
-
* }
|
|
1126
|
-
* }
|
|
1127
|
-
*
|
|
1128
|
-
* B) job with array of Field
|
|
1129
|
-
* {
|
|
1130
|
-
* id: <guid>,
|
|
1131
|
-
* reference: "something"
|
|
1132
|
-
* <other static job properties>...
|
|
1133
|
-
* <will not have dynamic properties>...
|
|
1134
|
-
* fields: [
|
|
1135
|
-
* {
|
|
1136
|
-
* id: <guid>,
|
|
1137
|
-
* <other field properties>,
|
|
1138
|
-
* value: "value"
|
|
1139
|
-
* }
|
|
1140
|
-
* ]
|
|
1141
|
-
* }
|
|
1142
|
-
*
|
|
1143
|
-
* What this method does is given a VasJobModel that has been populated with
|
|
1144
|
-
* a VasJobDto in form B (i.e. `.fields` are populated - usually from a VASAPI
|
|
1145
|
-
* response), hydrate the dynamic properties of the model. NOTE: knowledge of
|
|
1146
|
-
* the Form that was used to crate the Job is required because it will contain
|
|
1147
|
-
* the Groups, which names are used in the hydrating
|
|
1148
|
-
*
|
|
1149
|
-
* @param {VasFormModel} formModel the VasFormModel that was used to create
|
|
1150
|
-
* the job
|
|
1151
|
-
* @return {void}
|
|
1152
|
-
*/
|
|
1153
|
-
hydrateDynamicProps(formModel) {
|
|
1154
|
-
formModel.groups
|
|
1155
|
-
.forEach(group => {
|
|
1156
|
-
const p0 = group.name;
|
|
1157
|
-
group.controls
|
|
1158
|
-
.forEach(control => {
|
|
1159
|
-
const p1 = control.name;
|
|
1160
|
-
const f = this.fields.find(field => field.control === control.id);
|
|
1161
|
-
if (!f) {
|
|
1162
|
-
return;
|
|
1163
|
-
}
|
|
1164
|
-
this.setValueByPath(f.value, [p0, p1]);
|
|
1165
|
-
});
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* This method will hydrate the `fields` property of the model. The reason for
|
|
1170
|
-
* this is that we have different ways to store the field data. One way, is
|
|
1171
|
-
* we store them as dynamic properties of the job e.g. job.foo.bar, the other
|
|
1172
|
-
* is in an array of Field. The former is nice to work with in clients,
|
|
1173
|
-
* whereas the latter more suited to relational database.
|
|
1174
|
-
*
|
|
1114
|
+
* we store them as dynamic properties of the job. For example job.foo.bar,
|
|
1115
|
+
* where `foo` is the name of a Group, and `bar` is the name of a control.
|
|
1116
|
+
* Thus, when we create a job using a form in the client, the job object will
|
|
1117
|
+
* have its static properties (id, account, reference etc), and also a number
|
|
1118
|
+
* of dynamic properties determined by the Groups and Controls. This kind of
|
|
1119
|
+
* object is nice to work with in certain circumstances. However, the api
|
|
1120
|
+
* works differently. In the API a Job is a record, and references a number of
|
|
1121
|
+
* Field records. Each Field stores the value. Comparing these two models we
|
|
1122
|
+
* have:
|
|
1175
1123
|
* A) job with dynamic properties, e.g.
|
|
1176
1124
|
* {
|
|
1177
1125
|
* id: <guid>,
|
|
@@ -1238,7 +1186,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1238
1186
|
* be generated, or to reuse an existing one from the map.
|
|
1239
1187
|
* @param {Array<string>} controlNames if a value is provided, it will be used
|
|
1240
1188
|
* to filter the fields that are returned.
|
|
1241
|
-
* @return {
|
|
1189
|
+
* @return {Array<VasFieldDto>}
|
|
1242
1190
|
*/
|
|
1243
1191
|
hydrateFields(formModel, controlFieldIdMap = new Map(), controlNames) {
|
|
1244
1192
|
const fields = [];
|
|
@@ -1303,20 +1251,11 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
1303
1251
|
return;
|
|
1304
1252
|
}
|
|
1305
1253
|
case 2: {
|
|
1306
|
-
if (!this.$this[path[0]]) {
|
|
1307
|
-
this.$this[path[0]] = {};
|
|
1308
|
-
}
|
|
1309
1254
|
// eslint-disable-next-line max-len
|
|
1310
1255
|
this.$this[path[0]][path[1]] = value;
|
|
1311
1256
|
return;
|
|
1312
1257
|
}
|
|
1313
1258
|
case 3: {
|
|
1314
|
-
if (!this.$this[path[0]]) {
|
|
1315
|
-
this.$this[path[0]] = {};
|
|
1316
|
-
}
|
|
1317
|
-
if (!this.$this[path[0]][path[1]]) {
|
|
1318
|
-
this.$this[path[0]][path[1]] = {};
|
|
1319
|
-
}
|
|
1320
1259
|
// eslint-disable-next-line max-len
|
|
1321
1260
|
this.$this[path[0]][path[1]][path[2]] = value;
|
|
1322
1261
|
return;
|