data-restructor 3.3.3 → 3.4.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/.github/ISSUE_TEMPLATE/bug_report.md +2 -2
- package/.github/workflows/codeql-analysis.yml +4 -4
- package/.github/workflows/continuous-integration.yaml +84 -0
- package/CHANGELOG.md +103 -75
- package/CONTRIBUTING.md +51 -43
- package/Commands.md +15 -15
- package/README.md +188 -137
- package/SECURITY.md +15 -0
- package/coverage/coverage-summary.json +4 -4
- package/coverage/datarestructor.js.html +446 -320
- package/coverage/describedfield.js.html +47 -47
- package/coverage/index.html +19 -19
- package/coverage/templateResolver.js.html +26 -26
- package/devdist/datarestructor-global-all.js +65 -23
- package/devdist/datarestructor-ie-global-all.js +65 -23
- package/devdist/datarestructor-ie.js +1479 -1616
- package/devdist/datarestructor.js +1439 -1559
- package/devdist/describedfield-ie.js +259 -279
- package/devdist/describedfield.js +257 -277
- package/devdist/templateResolver-ie.js +220 -252
- package/devdist/templateResolver.js +196 -227
- package/dist/datarestructor-global-all-min.js +1 -1
- package/dist/datarestructor-ie-global-all-min.js +1 -1
- package/dist/datarestructor-ie.js +1 -1
- package/dist/datarestructor-ie.js.map +1 -1
- package/dist/datarestructor.js +1 -1
- package/dist/datarestructor.js.map +1 -1
- package/dist/describedfield-ie.js +1 -1
- package/dist/describedfield-ie.js.map +1 -1
- package/dist/describedfield.js +1 -1
- package/dist/describedfield.js.map +1 -1
- package/dist/templateResolver-ie.js +1 -1
- package/dist/templateResolver-ie.js.map +1 -1
- package/dist/templateResolver.js +1 -1
- package/dist/templateResolver.js.map +1 -1
- package/docs/datarestructor.js.html +66 -24
- package/docs/describedfield.js.html +1 -1
- package/docs/index.html +49 -44
- package/docs/module-datarestructor.DescribedEntryCreator.html +1 -1
- package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
- package/docs/module-datarestructor.Restructor.html +3 -3
- package/docs/module-datarestructor.Transform.html +7 -30
- package/docs/module-datarestructor.html +100 -3
- package/docs/module-described_field.DescribedDataFieldBuilder.html +1 -1
- package/docs/module-described_field.DescribedDataFieldGroup.html +1 -1
- package/docs/module-described_field.html +1 -1
- package/docs/module-template_resolver.Resolver.html +1 -1
- package/docs/module-template_resolver.html +1 -1
- package/docs/templateResolver.js.html +1 -1
- package/package.json +16 -14
- package/renovate.json +20 -0
- package/src/js/datarestructor.js +65 -23
- package/test/js/DataRestructorUseCaseTest.js +36 -0
- package/.github/workflows/action.yaml +0 -44
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// anything defined in a previous bundle is accessed via the
|
|
7
7
|
// orig method which is the require for previous bundles
|
|
8
8
|
|
|
9
|
-
(function(modules, entry, mainEntry, parcelRequireName, globalName) {
|
|
9
|
+
(function (modules, entry, mainEntry, parcelRequireName, globalName) {
|
|
10
10
|
/* eslint-disable no-undef */
|
|
11
11
|
var globalObject =
|
|
12
12
|
typeof globalThis !== 'undefined'
|
|
@@ -80,11 +80,13 @@
|
|
|
80
80
|
return cache[name].exports;
|
|
81
81
|
|
|
82
82
|
function localRequire(x) {
|
|
83
|
-
|
|
83
|
+
var res = localRequire.resolve(x);
|
|
84
|
+
return res === false ? {} : newRequire(res);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
function resolve(x) {
|
|
87
|
-
|
|
88
|
+
var id = modules[name][1][x];
|
|
89
|
+
return id != null ? id : x;
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -99,9 +101,9 @@
|
|
|
99
101
|
newRequire.modules = modules;
|
|
100
102
|
newRequire.cache = cache;
|
|
101
103
|
newRequire.parent = previousRequire;
|
|
102
|
-
newRequire.register = function(id, exports) {
|
|
104
|
+
newRequire.register = function (id, exports) {
|
|
103
105
|
modules[id] = [
|
|
104
|
-
function(require, module) {
|
|
106
|
+
function (require, module) {
|
|
105
107
|
module.exports = exports;
|
|
106
108
|
},
|
|
107
109
|
{},
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
Object.defineProperty(newRequire, 'root', {
|
|
112
|
-
get: function() {
|
|
114
|
+
get: function () {
|
|
113
115
|
return globalObject[parcelRequireName];
|
|
114
116
|
},
|
|
115
117
|
});
|
|
@@ -131,7 +133,7 @@
|
|
|
131
133
|
|
|
132
134
|
// RequireJS
|
|
133
135
|
} else if (typeof define === 'function' && define.amd) {
|
|
134
|
-
define(function() {
|
|
136
|
+
define(function () {
|
|
135
137
|
return mainExports;
|
|
136
138
|
});
|
|
137
139
|
|
|
@@ -140,294 +142,272 @@
|
|
|
140
142
|
this[globalName] = mainExports;
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
})({"
|
|
145
|
+
})({"cfxtc":[function(require,module,exports) {
|
|
144
146
|
"use strict";
|
|
145
147
|
var described_field = require("../../src/js/describedfield.js");
|
|
146
148
|
module.exports = {
|
|
147
|
-
|
|
149
|
+
described_field: described_field
|
|
148
150
|
};
|
|
149
151
|
|
|
150
|
-
},{"../../src/js/describedfield.js":"
|
|
152
|
+
},{"../../src/js/describedfield.js":"cleYG"}],"cleYG":[function(require,module,exports) {
|
|
151
153
|
/**
|
|
152
|
-
* @file Describes a data field of the restructured data.
|
|
153
|
-
* @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}
|
|
154
|
-
* @author JohT
|
|
155
|
-
* @version ${project.version}
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
var module = describedFieldInternalCreateIfNotExists(module);
|
|
159
|
-
// Fallback for vanilla js without modules
|
|
154
|
+
* @file Describes a data field of the restructured data.
|
|
155
|
+
* @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}
|
|
156
|
+
* @author JohT
|
|
157
|
+
* @version ${project.version}
|
|
158
|
+
*/ "use strict";
|
|
159
|
+
var module = describedFieldInternalCreateIfNotExists(module); // Fallback for vanilla js without modules
|
|
160
160
|
function describedFieldInternalCreateIfNotExists(objectToCheck) {
|
|
161
|
-
|
|
161
|
+
return objectToCheck || {
|
|
162
|
+
};
|
|
162
163
|
}
|
|
163
164
|
/**
|
|
164
|
-
* Describes a data field of the restructured data.
|
|
165
|
-
* @module described_field
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
// Export module for npm...
|
|
165
|
+
* Describes a data field of the restructured data.
|
|
166
|
+
* @module described_field
|
|
167
|
+
*/ var described_field = module.exports = {
|
|
168
|
+
}; // Export module for npm...
|
|
169
169
|
described_field.internalCreateIfNotExists = describedFieldInternalCreateIfNotExists;
|
|
170
170
|
/**
|
|
171
|
-
* Describes a field of the restructured data.
|
|
172
|
-
* Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.
|
|
173
|
-
*
|
|
174
|
-
* @typedef {Object} module:described_field.DescribedDataField
|
|
175
|
-
* @property {string} [category=""] - name of the category. Could contain a short domain name like "product" or "vendor".
|
|
176
|
-
* @property {string} [type=""] - type of the data element. Examples: "summary" for e.g. a list overview. "detail" e.g. when a summary is selected. "filter" e.g. for field/value pair results that can be selected as data filters.
|
|
177
|
-
* @property {string} [abbreviation=""] - one optional character, a symbol character or a short abbreviation of the category
|
|
178
|
-
* @property {string} [image=""] - one optional path to an image resource
|
|
179
|
-
* @property {string} index - array of numbers containing the splitted index. Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4]
|
|
180
|
-
* @property {string[]} groupNames - array of names of all dynamically added properties representing groups
|
|
181
|
-
* @property {string} displayName - display name of the field
|
|
182
|
-
* @property {string} fieldName - field name
|
|
183
|
-
* @property {{*}} value - content of the field
|
|
184
|
-
* @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields
|
|
185
|
-
*/
|
|
186
|
-
described_field.DescribedDataFieldBuilder = (function () {
|
|
187
|
-
/**
|
|
188
|
-
* Builds a {@link module:described_field.DescribedDataField}.
|
|
189
|
-
* DescribedDataField is the main element of the restructured data and therefore considered "public".
|
|
190
|
-
* @constructs DescribedDataFieldBuilder
|
|
191
|
-
* @alias module:described_field.DescribedDataFieldBuilder
|
|
192
|
-
*/
|
|
193
|
-
function DescribedDataFieldBuilder() {
|
|
194
|
-
/**
|
|
195
|
-
* @type {module:described_field.DescribedDataField}
|
|
196
|
-
*/
|
|
197
|
-
this.describedField = {
|
|
198
|
-
category: "",
|
|
199
|
-
type: "",
|
|
200
|
-
abbreviation: "",
|
|
201
|
-
image: "",
|
|
202
|
-
index: [],
|
|
203
|
-
groupNames: [],
|
|
204
|
-
displayName: "",
|
|
205
|
-
fieldName: "",
|
|
206
|
-
value: ""
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* Takes over all values of the template {@link module:described_field.DescribedDataField}.
|
|
210
|
-
* @function
|
|
211
|
-
* @param {module:described_field.DescribedDataField} template
|
|
212
|
-
* @returns {DescribedDataFieldBuilder}
|
|
213
|
-
* @example fromDescribedDataField(sourceField)
|
|
214
|
-
*/
|
|
215
|
-
this.fromDescribedDataField = function (template) {
|
|
216
|
-
this.category(template.category);
|
|
217
|
-
this.type(template.type);
|
|
218
|
-
this.abbreviation(template.abbreviation);
|
|
219
|
-
this.image(template.image);
|
|
220
|
-
this.index(template.index);
|
|
221
|
-
this.groupNames(template.groupNames);
|
|
222
|
-
this.displayName(template.displayName);
|
|
223
|
-
this.fieldName(template.fieldName);
|
|
224
|
-
this.value(template.value);
|
|
225
|
-
return this;
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* Sets the category.
|
|
229
|
-
*
|
|
230
|
-
* Contains a short domain nam, for example:
|
|
231
|
-
* - "product" for products
|
|
232
|
-
* - "vendor" for vendors
|
|
233
|
-
*
|
|
234
|
-
* @function
|
|
235
|
-
* @param {String} [value=""]
|
|
236
|
-
* @returns {DescribedDataFieldBuilder}
|
|
237
|
-
* @example category("Product")
|
|
238
|
-
*/
|
|
239
|
-
this.category = function (value) {
|
|
240
|
-
this.describedField.category = withDefaultString(value, "");
|
|
241
|
-
return this;
|
|
242
|
-
};
|
|
243
|
-
/**
|
|
244
|
-
* Sets the type.
|
|
245
|
-
*
|
|
246
|
-
* Contains the type of the entry, for example:
|
|
247
|
-
* - "summary" for e.g. a list overview.
|
|
248
|
-
* - "detail" e.g. when a summary is selected.
|
|
249
|
-
* - "filter" e.g. for field/value pair results that can be selected as search parameters.
|
|
250
|
-
*
|
|
251
|
-
* @function
|
|
252
|
-
* @param {String} [value=""]
|
|
253
|
-
* @returns {DescribedDataFieldBuilder}
|
|
254
|
-
* @example type("summary")
|
|
255
|
-
*/
|
|
256
|
-
this.type = function (value) {
|
|
257
|
-
this.describedField.type = withDefaultString(value, "");
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Sets the optional abbreviation.
|
|
262
|
-
*
|
|
263
|
-
* Contains a symbol character or a very short abbreviation of the category.
|
|
264
|
-
* - "P" for products
|
|
265
|
-
* - "V" for vendors
|
|
266
|
-
*
|
|
267
|
-
* @function
|
|
268
|
-
* @param {String} [value=""]
|
|
269
|
-
* @returns {DescribedDataFieldBuilder}
|
|
270
|
-
* @example abbreviation("P")
|
|
271
|
-
*/
|
|
272
|
-
this.abbreviation = function (value) {
|
|
273
|
-
this.describedField.abbreviation = withDefaultString(value, "");
|
|
274
|
-
return this;
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* Sets the optional path to an image resource.
|
|
278
|
-
*
|
|
279
|
-
* @function
|
|
280
|
-
* @param {String} [value=""]
|
|
281
|
-
* @returns {DescribedDataFieldBuilder}
|
|
282
|
-
* @example image("img/product.png")
|
|
283
|
-
*/
|
|
284
|
-
this.image = function (value) {
|
|
285
|
-
this.describedField.image = withDefaultString(value, "");
|
|
286
|
-
return this;
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* Sets the index as an array of numbers containing the splitted array indexes of the source field.
|
|
290
|
-
* Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4].
|
|
291
|
-
*
|
|
292
|
-
* @function
|
|
293
|
-
* @param {number[]} [value=[]]
|
|
294
|
-
* @returns {DescribedDataFieldBuilder}
|
|
295
|
-
* @example index([2,4])
|
|
296
|
-
*/
|
|
297
|
-
this.index = function (value) {
|
|
298
|
-
this.describedField.index = withDefaultArray(value, []);
|
|
299
|
-
return this;
|
|
300
|
-
};
|
|
301
|
-
/**
|
|
302
|
-
* Sets the group names as an array of strings containing the names of the dynamically added properties,
|
|
303
|
-
* that contain an array of {@link module:described_field.DescribedDataField}-Objects.
|
|
304
|
-
*
|
|
305
|
-
* @function
|
|
306
|
-
* @param {string[]} [value=[]]
|
|
307
|
-
* @returns {DescribedDataFieldBuilder}
|
|
308
|
-
* @example groupNames(["summaries","details","options"])
|
|
309
|
-
*/
|
|
310
|
-
this.groupNames = function (value) {
|
|
311
|
-
this.describedField.groupNames = withDefaultArray(value, []);
|
|
312
|
-
return this;
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Sets the display name.
|
|
316
|
-
*
|
|
317
|
-
* @function
|
|
318
|
-
* @param {String} [value=""]
|
|
319
|
-
* @returns {DescribedDataFieldBuilder}
|
|
320
|
-
* @example displayName("Color")
|
|
321
|
-
*/
|
|
322
|
-
this.displayName = function (value) {
|
|
323
|
-
this.describedField.displayName = withDefaultString(value, "");
|
|
324
|
-
return this;
|
|
325
|
-
};
|
|
326
|
-
/**
|
|
327
|
-
* Sets the (technical) field name.
|
|
328
|
-
*
|
|
329
|
-
* @function
|
|
330
|
-
* @param {String} [value=""]
|
|
331
|
-
* @returns {DescribedDataFieldBuilder}
|
|
332
|
-
* @example fieldName("color")
|
|
333
|
-
*/
|
|
334
|
-
this.fieldName = function (value) {
|
|
335
|
-
this.describedField.fieldName = withDefaultString(value, "");
|
|
336
|
-
return this;
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* Sets the value/content of the field.
|
|
340
|
-
*
|
|
341
|
-
* @function
|
|
342
|
-
* @param {*} value
|
|
343
|
-
* @returns {DescribedDataFieldBuilder}
|
|
344
|
-
* @example value("darkblue")
|
|
345
|
-
*/
|
|
346
|
-
this.value = function (value) {
|
|
347
|
-
this.describedField.value = value;
|
|
348
|
-
return this;
|
|
349
|
-
};
|
|
171
|
+
* Describes a field of the restructured data.
|
|
172
|
+
* Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.
|
|
173
|
+
*
|
|
174
|
+
* @typedef {Object} module:described_field.DescribedDataField
|
|
175
|
+
* @property {string} [category=""] - name of the category. Could contain a short domain name like "product" or "vendor".
|
|
176
|
+
* @property {string} [type=""] - type of the data element. Examples: "summary" for e.g. a list overview. "detail" e.g. when a summary is selected. "filter" e.g. for field/value pair results that can be selected as data filters.
|
|
177
|
+
* @property {string} [abbreviation=""] - one optional character, a symbol character or a short abbreviation of the category
|
|
178
|
+
* @property {string} [image=""] - one optional path to an image resource
|
|
179
|
+
* @property {string} index - array of numbers containing the splitted index. Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4]
|
|
180
|
+
* @property {string[]} groupNames - array of names of all dynamically added properties representing groups
|
|
181
|
+
* @property {string} displayName - display name of the field
|
|
182
|
+
* @property {string} fieldName - field name
|
|
183
|
+
* @property {{*}} value - content of the field
|
|
184
|
+
* @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields
|
|
185
|
+
*/ described_field.DescribedDataFieldBuilder = (function() {
|
|
350
186
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
187
|
+
* Builds a {@link module:described_field.DescribedDataField}.
|
|
188
|
+
* DescribedDataField is the main element of the restructured data and therefore considered "public".
|
|
189
|
+
* @constructs DescribedDataFieldBuilder
|
|
190
|
+
* @alias module:described_field.DescribedDataFieldBuilder
|
|
191
|
+
*/ function DescribedDataFieldBuilder() {
|
|
192
|
+
/**
|
|
193
|
+
* @type {module:described_field.DescribedDataField}
|
|
194
|
+
*/ this.describedField = {
|
|
195
|
+
category: "",
|
|
196
|
+
type: "",
|
|
197
|
+
abbreviation: "",
|
|
198
|
+
image: "",
|
|
199
|
+
index: [],
|
|
200
|
+
groupNames: [],
|
|
201
|
+
displayName: "",
|
|
202
|
+
fieldName: "",
|
|
203
|
+
value: ""
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Takes over all values of the template {@link module:described_field.DescribedDataField}.
|
|
207
|
+
* @function
|
|
208
|
+
* @param {module:described_field.DescribedDataField} template
|
|
209
|
+
* @returns {DescribedDataFieldBuilder}
|
|
210
|
+
* @example fromDescribedDataField(sourceField)
|
|
211
|
+
*/ this.fromDescribedDataField = function(template) {
|
|
212
|
+
this.category(template.category);
|
|
213
|
+
this.type(template.type);
|
|
214
|
+
this.abbreviation(template.abbreviation);
|
|
215
|
+
this.image(template.image);
|
|
216
|
+
this.index(template.index);
|
|
217
|
+
this.groupNames(template.groupNames);
|
|
218
|
+
this.displayName(template.displayName);
|
|
219
|
+
this.fieldName(template.fieldName);
|
|
220
|
+
this.value(template.value);
|
|
221
|
+
return this;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Sets the category.
|
|
225
|
+
*
|
|
226
|
+
* Contains a short domain nam, for example:
|
|
227
|
+
* - "product" for products
|
|
228
|
+
* - "vendor" for vendors
|
|
229
|
+
*
|
|
230
|
+
* @function
|
|
231
|
+
* @param {String} [value=""]
|
|
232
|
+
* @returns {DescribedDataFieldBuilder}
|
|
233
|
+
* @example category("Product")
|
|
234
|
+
*/ this.category = function(value) {
|
|
235
|
+
this.describedField.category = withDefaultString(value, "");
|
|
236
|
+
return this;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Sets the type.
|
|
240
|
+
*
|
|
241
|
+
* Contains the type of the entry, for example:
|
|
242
|
+
* - "summary" for e.g. a list overview.
|
|
243
|
+
* - "detail" e.g. when a summary is selected.
|
|
244
|
+
* - "filter" e.g. for field/value pair results that can be selected as search parameters.
|
|
245
|
+
*
|
|
246
|
+
* @function
|
|
247
|
+
* @param {String} [value=""]
|
|
248
|
+
* @returns {DescribedDataFieldBuilder}
|
|
249
|
+
* @example type("summary")
|
|
250
|
+
*/ this.type = function(value) {
|
|
251
|
+
this.describedField.type = withDefaultString(value, "");
|
|
252
|
+
return this;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Sets the optional abbreviation.
|
|
256
|
+
*
|
|
257
|
+
* Contains a symbol character or a very short abbreviation of the category.
|
|
258
|
+
* - "P" for products
|
|
259
|
+
* - "V" for vendors
|
|
260
|
+
*
|
|
261
|
+
* @function
|
|
262
|
+
* @param {String} [value=""]
|
|
263
|
+
* @returns {DescribedDataFieldBuilder}
|
|
264
|
+
* @example abbreviation("P")
|
|
265
|
+
*/ this.abbreviation = function(value) {
|
|
266
|
+
this.describedField.abbreviation = withDefaultString(value, "");
|
|
267
|
+
return this;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Sets the optional path to an image resource.
|
|
271
|
+
*
|
|
272
|
+
* @function
|
|
273
|
+
* @param {String} [value=""]
|
|
274
|
+
* @returns {DescribedDataFieldBuilder}
|
|
275
|
+
* @example image("img/product.png")
|
|
276
|
+
*/ this.image = function(value) {
|
|
277
|
+
this.describedField.image = withDefaultString(value, "");
|
|
278
|
+
return this;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Sets the index as an array of numbers containing the splitted array indexes of the source field.
|
|
282
|
+
* Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4].
|
|
283
|
+
*
|
|
284
|
+
* @function
|
|
285
|
+
* @param {number[]} [value=[]]
|
|
286
|
+
* @returns {DescribedDataFieldBuilder}
|
|
287
|
+
* @example index([2,4])
|
|
288
|
+
*/ this.index = function(value) {
|
|
289
|
+
this.describedField.index = withDefaultArray(value, []);
|
|
290
|
+
return this;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Sets the group names as an array of strings containing the names of the dynamically added properties,
|
|
294
|
+
* that contain an array of {@link module:described_field.DescribedDataField}-Objects.
|
|
295
|
+
*
|
|
296
|
+
* @function
|
|
297
|
+
* @param {string[]} [value=[]]
|
|
298
|
+
* @returns {DescribedDataFieldBuilder}
|
|
299
|
+
* @example groupNames(["summaries","details","options"])
|
|
300
|
+
*/ this.groupNames = function(value) {
|
|
301
|
+
this.describedField.groupNames = withDefaultArray(value, []);
|
|
302
|
+
return this;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Sets the display name.
|
|
306
|
+
*
|
|
307
|
+
* @function
|
|
308
|
+
* @param {String} [value=""]
|
|
309
|
+
* @returns {DescribedDataFieldBuilder}
|
|
310
|
+
* @example displayName("Color")
|
|
311
|
+
*/ this.displayName = function(value) {
|
|
312
|
+
this.describedField.displayName = withDefaultString(value, "");
|
|
313
|
+
return this;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Sets the (technical) field name.
|
|
317
|
+
*
|
|
318
|
+
* @function
|
|
319
|
+
* @param {String} [value=""]
|
|
320
|
+
* @returns {DescribedDataFieldBuilder}
|
|
321
|
+
* @example fieldName("color")
|
|
322
|
+
*/ this.fieldName = function(value) {
|
|
323
|
+
this.describedField.fieldName = withDefaultString(value, "");
|
|
324
|
+
return this;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Sets the value/content of the field.
|
|
328
|
+
*
|
|
329
|
+
* @function
|
|
330
|
+
* @param {*} value
|
|
331
|
+
* @returns {DescribedDataFieldBuilder}
|
|
332
|
+
* @example value("darkblue")
|
|
333
|
+
*/ this.value = function(value) {
|
|
334
|
+
this.describedField.value = value;
|
|
335
|
+
return this;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.
|
|
339
|
+
* @function
|
|
340
|
+
* @returns {module:described_field.DescribedDataField}
|
|
341
|
+
*/ this.build = function() {
|
|
342
|
+
return this.describedField;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function isSpecifiedString(value) {
|
|
346
|
+
return typeof value === "string" && value !== null && value !== "";
|
|
347
|
+
}
|
|
348
|
+
function withDefaultString(value, defaultValue) {
|
|
349
|
+
return isSpecifiedString(value) ? value : defaultValue;
|
|
350
|
+
}
|
|
351
|
+
function withDefaultArray(value, defaultValue) {
|
|
352
|
+
return value === undefined || value === null ? defaultValue : value;
|
|
353
|
+
}
|
|
354
|
+
return DescribedDataFieldBuilder;
|
|
369
355
|
})();
|
|
370
356
|
/**
|
|
371
|
-
* Creates a new described data field with all properties of the original one except for dynamically added groups.
|
|
372
|
-
* @param {module:described_field.DescribedDataField} describedDataField
|
|
373
|
-
* @returns {module:described_field.DescribedDataField}
|
|
374
|
-
* @memberof module:described_field
|
|
375
|
-
*/
|
|
376
|
-
described_field.
|
|
377
|
-
return new described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();
|
|
357
|
+
* Creates a new described data field with all properties of the original one except for dynamically added groups.
|
|
358
|
+
* @param {module:described_field.DescribedDataField} describedDataField
|
|
359
|
+
* @returns {module:described_field.DescribedDataField}
|
|
360
|
+
* @memberof module:described_field
|
|
361
|
+
*/ described_field.copyWithoutGroups = function(describedDataField) {
|
|
362
|
+
return new described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();
|
|
378
363
|
};
|
|
379
|
-
described_field.DescribedDataFieldGroup = (function
|
|
380
|
-
/**
|
|
381
|
-
* Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties
|
|
382
|
-
* that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.
|
|
383
|
-
*
|
|
384
|
-
* @param {module:described_field.DescribedDataField} dataField
|
|
385
|
-
* @constructs DescribedDataFieldGroup
|
|
386
|
-
* @alias module:described_field.DescribedDataFieldGroup
|
|
387
|
-
* @example new described_field.DescribedDataFieldGroup(field).addGroupEntry("details", detailField);
|
|
388
|
-
*/
|
|
389
|
-
function DescribedDataFieldGroup(dataField) {
|
|
390
|
-
this.dataField = dataField;
|
|
391
|
-
/**
|
|
392
|
-
* Adds an entry to the given group. If the group does not exist, it will be created.
|
|
393
|
-
* @function
|
|
394
|
-
* @param {String} groupName name of the group to which the entry will be added
|
|
395
|
-
* @param {module:described_field.DescribedDataField} describedField sub field that is added to the group
|
|
396
|
-
* @returns {DescribedDataFieldGroup}
|
|
397
|
-
*/
|
|
398
|
-
this.addGroupEntry = function (groupName, describedField) {
|
|
399
|
-
this.addGroupEntries(groupName, [describedField]);
|
|
400
|
-
return this;
|
|
401
|
-
};
|
|
364
|
+
described_field.DescribedDataFieldGroup = (function() {
|
|
402
365
|
/**
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
366
|
+
* Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties
|
|
367
|
+
* that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.
|
|
368
|
+
*
|
|
369
|
+
* @param {module:described_field.DescribedDataField} dataField
|
|
370
|
+
* @constructs DescribedDataFieldGroup
|
|
371
|
+
* @alias module:described_field.DescribedDataFieldGroup
|
|
372
|
+
* @example new described_field.DescribedDataFieldGroup(field).addGroupEntry("details", detailField);
|
|
373
|
+
*/ function DescribedDataFieldGroup(dataField) {
|
|
374
|
+
this.dataField = dataField;
|
|
375
|
+
/**
|
|
376
|
+
* Adds an entry to the given group. If the group does not exist, it will be created.
|
|
377
|
+
* @function
|
|
378
|
+
* @param {String} groupName name of the group to which the entry will be added
|
|
379
|
+
* @param {module:described_field.DescribedDataField} describedField sub field that is added to the group
|
|
380
|
+
* @returns {DescribedDataFieldGroup}
|
|
381
|
+
*/ this.addGroupEntry = function(groupName, describedField) {
|
|
382
|
+
this.addGroupEntries(groupName, [
|
|
383
|
+
describedField
|
|
384
|
+
]);
|
|
385
|
+
return this;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Adds entries to the given group. If the group does not exist, it will be created.
|
|
389
|
+
* @function
|
|
390
|
+
* @param {String} groupName name of the group to which the entries will be added
|
|
391
|
+
* @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group
|
|
392
|
+
* @returns {DescribedDataFieldGroup}
|
|
393
|
+
*/ this.addGroupEntries = function(groupName, describedFields) {
|
|
394
|
+
if (!groupName || groupName.length === 0) return this;
|
|
395
|
+
if (!describedFields || describedFields.length === 0) return this;
|
|
396
|
+
if (this.dataField[groupName] === undefined) {
|
|
397
|
+
this.dataField.groupNames.push(groupName);
|
|
398
|
+
this.dataField[groupName] = [];
|
|
399
|
+
}
|
|
400
|
+
var index;
|
|
401
|
+
var describedField;
|
|
402
|
+
for(index = 0; index < describedFields.length; index += 1){
|
|
403
|
+
describedField = describedFields[index];
|
|
404
|
+
this.dataField[groupName].push(describedField);
|
|
405
|
+
}
|
|
406
|
+
return this;
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
return DescribedDataFieldGroup;
|
|
430
410
|
})();
|
|
431
411
|
|
|
432
|
-
},{}]},["
|
|
412
|
+
},{}]},["cfxtc"], "cfxtc", "parcelRequirec1f2")
|
|
433
413
|
|