@onehat/data 1.19.0 → 1.19.2

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.
@@ -63,82 +63,6 @@ describe('OneBuildRepository', function() {
63
63
  expect(p.conditions.key2).to.be.eq('2');
64
64
  });
65
65
 
66
- it.only('getTitles, getVirtualdPropertyNames, getIsFilteringDisabledPropertyNames, getIsEditingDisabledPropertyNames, getFieldGroupNames, getFilterTypes', function() {
67
- let repository;
68
- (async () => {
69
- repository = await this.oneHatData.createRepository({
70
- schema: {
71
- id: 'foo',
72
- name: 'foo',
73
- model: {
74
- idProperty: 'model__field1',
75
- displayProperty: 'model__field2',
76
- properties: [
77
- {
78
- name: 'model__field1',
79
- isVirtual: true,
80
- isFilteringDisabled: false,
81
- filterType: {
82
- type: 'Combo',
83
- loadAfterRender: false,
84
- },
85
- isEditingDisabled: true,
86
- fieldGroup: 'group1',
87
- },
88
- {
89
- name: 'model__field2',
90
- isVirtual: true,
91
- isFilteringDisabled: true,
92
- isEditingDisabled: false,
93
- fieldGroup: 'group1',
94
- },
95
- {
96
- name: 'model__field3',
97
- isVirtual: false,
98
- isFilteringDisabled: true,
99
- isEditingDisabled: true,
100
- fieldGroup: 'group2',
101
- },
102
- ],
103
- },
104
- repository: {
105
- type: 'onebuild',
106
- },
107
- },
108
- });
109
-
110
- const
111
- virtualPropertyNames = [
112
- 'model__field1',
113
- 'model__field2',
114
- ],
115
- isFilteringDisabledPropertyNames = [
116
- 'model__field2',
117
- 'model__field3',
118
- ],
119
- isEditingDisabledPropertyNames = [
120
- 'model__field1',
121
- 'model__field3',
122
- ],
123
- fieldGroupNames = [
124
- 'group1',
125
- 'group2',
126
- ],
127
- filterTypes = [
128
- {
129
- type: 'Combo',
130
- loadAfterRender: false,
131
- },
132
- ];
133
- expect(repository.getVirtualPropertyNames()).to.be.eql(virtualPropertyNames);
134
- expect(repository.getIsFilteringDisabledPropertyNames()).to.be.eql(isFilteringDisabledPropertyNames);
135
- expect(repository.getIsEditingDisabledPropertyNames()).to.be.eql(isEditingDisabledPropertyNames);
136
- expect(repository.getFieldGroupNames()).to.be.eql(fieldGroupNames);
137
- expect(repository.getFilterTypes()).to.be.eql(filterTypes);
138
-
139
- })();
140
- });
141
-
142
66
  it.skip('401', function() {
143
67
  cy.wrap((async () => {
144
68
 
@@ -30,4 +30,81 @@ describe('Schema', function() {
30
30
  expect(_.isEqual(propertyDefinition.name, 'groups_users__id')).to.be.true;
31
31
  });
32
32
 
33
+ it.only('getTitles, getVirtualdPropertyNames, getIsFilteringDisabledPropertyNames, getIsEditingDisabledPropertyNames, getFieldGroupNames, getFilterTypes', function() {
34
+ const
35
+ schema = new Schema({
36
+ id: 'foo',
37
+ name: 'foo',
38
+ model: {
39
+ idProperty: 'model__field1',
40
+ displayProperty: 'model__field2',
41
+ properties: [
42
+ {
43
+ name: 'model__field1',
44
+ title: 'title1',
45
+ isVirtual: true,
46
+ isFilteringDisabled: false,
47
+ filterType: {
48
+ type: 'Combo',
49
+ loadAfterRender: false,
50
+ },
51
+ isEditingDisabled: true,
52
+ fieldGroup: 'group1',
53
+ },
54
+ {
55
+ name: 'model__field2',
56
+ title: 'title2',
57
+ isVirtual: true,
58
+ isFilteringDisabled: true,
59
+ isEditingDisabled: false,
60
+ fieldGroup: 'group1',
61
+ },
62
+ {
63
+ name: 'model__field3',
64
+ title: 'title3',
65
+ isVirtual: false,
66
+ isFilteringDisabled: true,
67
+ isEditingDisabled: true,
68
+ fieldGroup: 'group2',
69
+ },
70
+ ],
71
+ },
72
+ }),
73
+ titles = [
74
+ 'title1',
75
+ 'title2',
76
+ 'title3',
77
+ ],
78
+ virtualPropertyNames = [
79
+ 'model__field1',
80
+ 'model__field2',
81
+ ],
82
+ isFilteringDisabledPropertyNames = [
83
+ 'model__field2',
84
+ 'model__field3',
85
+ ],
86
+ isEditingDisabledPropertyNames = [
87
+ 'model__field1',
88
+ 'model__field3',
89
+ ],
90
+ fieldGroupNames = [
91
+ 'group1',
92
+ 'group2',
93
+ ],
94
+ filterTypes = {
95
+ model__field1: {
96
+ type: 'Combo',
97
+ loadAfterRender: false,
98
+ },
99
+ };
100
+
101
+ expect(schema.getTitles()).to.be.eql(titles);
102
+ expect(schema.getVirtualPropertyNames()).to.be.eql(virtualPropertyNames);
103
+ expect(schema.getIsFilteringDisabledPropertyNames()).to.be.eql(isFilteringDisabledPropertyNames);
104
+ expect(schema.getIsEditingDisabledPropertyNames()).to.be.eql(isEditingDisabledPropertyNames);
105
+ expect(schema.getFieldGroupNames()).to.be.eql(fieldGroupNames);
106
+ expect(schema.getFilterTypes()).to.be.eql(filterTypes);
107
+
108
+ });
109
+
33
110
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.19.0",
3
+ "version": "1.19.2",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -425,81 +425,6 @@ class OneBuildRepository extends AjaxRepository {
425
425
  return response;
426
426
  });
427
427
  }
428
-
429
- getVirtualPropertyNames = () => {
430
- if (this.isDestroyed) {
431
- this.throwError('this.getVirtualPropertyNames is no longer valid. Repository has been destroyed.');
432
- return;
433
- }
434
-
435
- const found = [];
436
- _.each(this.schema.model.properties, (property) => {
437
- if (property.isVirtual) {
438
- found.push(property.name);
439
- }
440
- });
441
- return found;
442
- }
443
-
444
- getIsFilteringDisabledPropertyNames = () => {
445
- if (this.isDestroyed) {
446
- this.throwError('this.getIsFilteringDisabledPropertyNames is no longer valid. Repository has been destroyed.');
447
- return;
448
- }
449
-
450
- const found = [];
451
- _.each(this.schema.model.properties, (property) => {
452
- if (property.isFilteringDisabled) {
453
- found.push(property.name);
454
- }
455
- });
456
- return found;
457
- }
458
-
459
- getIsEditingDisabledPropertyNames = () => {
460
- if (this.isDestroyed) {
461
- this.throwError('this.getIsEditingDisabledPropertyNames is no longer valid. Repository has been destroyed.');
462
- return;
463
- }
464
-
465
- const found = [];
466
- _.each(this.schema.model.properties, (property) => {
467
- if (property.isEditingDisabled) {
468
- found.push(property.name);
469
- }
470
- });
471
- return found;
472
- }
473
-
474
- getFieldGroupNames = () => {
475
- if (this.isDestroyed) {
476
- this.throwError('this.getFieldGroupNames is no longer valid. Repository has been destroyed.');
477
- return;
478
- }
479
-
480
- const found = [];
481
- _.each(this.schema.model.properties, (property) => {
482
- if (!_.isNil(property.fieldGroup) && !found.includes(property.fieldGroup)) {
483
- found.push(property.fieldGroup);
484
- }
485
- });
486
- return found;
487
- }
488
-
489
- getFilterTypes = () => {
490
- if (this.isDestroyed) {
491
- this.throwError('this.getFilterTypes is no longer valid. Repository has been destroyed.');
492
- return;
493
- }
494
-
495
- const found = [];
496
- _.each(this.schema.model.properties, (property) => {
497
- if (!_.isNil(property.filterType) && !found.includes(property.filterType)) {
498
- found.push(property.filterType);
499
- }
500
- });
501
- return found;
502
- }
503
428
 
504
429
 
505
430
  // ______
@@ -235,13 +235,100 @@ export default class Schema extends EventEmitter {
235
235
  if (this.isDestroyed) {
236
236
  throw Error('this.getPropertyDefinition is no longer valid. Schema has been destroyed.');
237
237
  }
238
- const propertyDefinition = _.find(this.model.properties, (propertyDefinition) => {
238
+ return _.find(this.model.properties, (propertyDefinition) => {
239
239
  return propertyDefinition.name === propertyName;
240
240
  });
241
- if (!propertyDefinition) {
242
- throw new Error('Property definition ' + propertyName + ' not found.');
241
+ }
242
+
243
+ getTitles = () => {
244
+ if (this.isDestroyed) {
245
+ this.throwError('this.getTitles is no longer valid. Schema has been destroyed.');
246
+ return;
247
+ }
248
+
249
+ const found = [];
250
+ _.each(this.model.properties, (property) => {
251
+ if (property.title) {
252
+ found.push(property.title);
253
+ }
254
+ });
255
+ return found;
256
+ }
257
+
258
+ getVirtualPropertyNames = () => {
259
+ if (this.isDestroyed) {
260
+ this.throwError('this.getVirtualPropertyNames is no longer valid. Schema has been destroyed.');
261
+ return;
243
262
  }
244
- return propertyDefinition;
263
+
264
+ const found = [];
265
+ _.each(this.model.properties, (property) => {
266
+ if (property.isVirtual) {
267
+ found.push(property.name);
268
+ }
269
+ });
270
+ return found;
271
+ }
272
+
273
+ getIsFilteringDisabledPropertyNames = () => {
274
+ if (this.isDestroyed) {
275
+ this.throwError('this.getIsFilteringDisabledPropertyNames is no longer valid. Schema has been destroyed.');
276
+ return;
277
+ }
278
+
279
+ const found = [];
280
+ _.each(this.model.properties, (property) => {
281
+ if (property.isFilteringDisabled) {
282
+ found.push(property.name);
283
+ }
284
+ });
285
+ return found;
286
+ }
287
+
288
+ getIsEditingDisabledPropertyNames = () => {
289
+ if (this.isDestroyed) {
290
+ this.throwError('this.getIsEditingDisabledPropertyNames is no longer valid. Schema has been destroyed.');
291
+ return;
292
+ }
293
+
294
+ const found = [];
295
+ _.each(this.model.properties, (property) => {
296
+ if (property.isEditingDisabled) {
297
+ found.push(property.name);
298
+ }
299
+ });
300
+ return found;
301
+ }
302
+
303
+ getFieldGroupNames = () => {
304
+ if (this.isDestroyed) {
305
+ this.throwError('this.getFieldGroupNames is no longer valid. Schema has been destroyed.');
306
+ return;
307
+ }
308
+
309
+ const found = [];
310
+ _.each(this.model.properties, (property) => {
311
+ if (!_.isNil(property.fieldGroup) && !found.includes(property.fieldGroup)) {
312
+ found.push(property.fieldGroup);
313
+ }
314
+ });
315
+ return found;
316
+ }
317
+
318
+ getFilterTypes = () => {
319
+ if (this.isDestroyed) {
320
+ this.throwError('this.getFilterTypes is no longer valid. Schema has been destroyed.');
321
+ return;
322
+ }
323
+
324
+ const found = {};
325
+ _.each(this.model.properties, (property) => {
326
+ if (_.isNil(property.filterType) || property.isFilteringDisabled) {
327
+ return;
328
+ }
329
+ found[property.name] = property.filterType;
330
+ });
331
+ return found;
245
332
  }
246
333
 
247
334
  /**