apostrophe 3.28.0 → 3.28.1
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/CHANGELOG.md +9 -0
- package/modules/@apostrophecms/attachment/index.js +2 -2
- package/modules/@apostrophecms/module/index.js +1 -1
- package/modules/@apostrophecms/schema/lib/addFieldTypes.js +3 -3
- package/modules/@apostrophecms/schema/ui/apos/components/AposInputBoolean.vue +1 -1
- package/package.json +1 -1
- package/test/areas.js +38 -2
- package/test/schemaBuilders.js +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.28.1 (2022-09-15)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
* `AposInputBoolean` can now be `required` and have the value `false`.
|
|
8
|
+
* Schema fields containing boolean filters can now list both `yes` and `no` choices according to available values in the database.
|
|
9
|
+
* Fix attachment `getHeight()` and `getWidth()` template helpers by changing the assignment of the `attachment._crop` property.
|
|
10
|
+
* Change assignment of `attachment._focalPoint` for consistency.
|
|
11
|
+
|
|
3
12
|
## 3.28.0 (2022-08-31)
|
|
4
13
|
|
|
5
14
|
### Fixes
|
|
@@ -708,8 +708,8 @@ module.exports = {
|
|
|
708
708
|
if (ancestorFields) {
|
|
709
709
|
value = _.clone(value);
|
|
710
710
|
o.attachment = value;
|
|
711
|
-
value._crop = _.pick(ancestorFields, 'width', 'height', 'top', 'left');
|
|
712
|
-
value._focalPoint = _.pick(ancestorFields, 'x', 'y');
|
|
711
|
+
value._crop = ancestorFields.width ? _.pick(ancestorFields, 'width', 'height', 'top', 'left') : undefined;
|
|
712
|
+
value._focalPoint = (typeof ancestorFields.x === 'number') ? _.pick(ancestorFields, 'x', 'y') : undefined;
|
|
713
713
|
break;
|
|
714
714
|
}
|
|
715
715
|
}
|
|
@@ -165,7 +165,7 @@ module.exports = (self) => {
|
|
|
165
165
|
destination[field.name] = self.apos.launder.boolean(data[field.name], field.def);
|
|
166
166
|
},
|
|
167
167
|
isEmpty: function (field, value) {
|
|
168
|
-
return !value;
|
|
168
|
+
return !value && value !== false;
|
|
169
169
|
},
|
|
170
170
|
exporters: {
|
|
171
171
|
string: function (req, field, object, output) {
|
|
@@ -190,7 +190,7 @@ module.exports = (self) => {
|
|
|
190
190
|
return self.apos.launder.booleanOrNull(b);
|
|
191
191
|
},
|
|
192
192
|
choices: async function () {
|
|
193
|
-
const values = query.toDistinct(field.name);
|
|
193
|
+
const values = await query.toDistinct(field.name);
|
|
194
194
|
const choices = [];
|
|
195
195
|
if (_.includes(values, true)) {
|
|
196
196
|
choices.push({
|
|
@@ -198,7 +198,7 @@ module.exports = (self) => {
|
|
|
198
198
|
label: 'apostrophe:yes'
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
if (_.includes(values,
|
|
201
|
+
if (_.includes(values, false)) {
|
|
202
202
|
choices.push({
|
|
203
203
|
value: '0',
|
|
204
204
|
label: 'apostrophe:no'
|
package/package.json
CHANGED
package/test/areas.js
CHANGED
|
@@ -336,11 +336,29 @@ describe('Areas', function() {
|
|
|
336
336
|
}, true)
|
|
337
337
|
);
|
|
338
338
|
assert(
|
|
339
|
-
apos.schema.fieldTypes.boolean.isEmpty({
|
|
339
|
+
!apos.schema.fieldTypes.boolean.isEmpty({
|
|
340
340
|
type: 'boolean',
|
|
341
341
|
name: 'test'
|
|
342
342
|
}, false)
|
|
343
343
|
);
|
|
344
|
+
assert(
|
|
345
|
+
apos.schema.fieldTypes.boolean.isEmpty({
|
|
346
|
+
type: 'boolean',
|
|
347
|
+
name: 'test'
|
|
348
|
+
}, null)
|
|
349
|
+
);
|
|
350
|
+
assert(
|
|
351
|
+
apos.schema.fieldTypes.boolean.isEmpty({
|
|
352
|
+
type: 'boolean',
|
|
353
|
+
name: 'test'
|
|
354
|
+
}, undefined)
|
|
355
|
+
);
|
|
356
|
+
assert(
|
|
357
|
+
apos.schema.fieldTypes.boolean.isEmpty({
|
|
358
|
+
type: 'boolean',
|
|
359
|
+
name: 'test'
|
|
360
|
+
}, 0)
|
|
361
|
+
);
|
|
344
362
|
assert(
|
|
345
363
|
!apos.schema.fieldTypes.boolean.empty({
|
|
346
364
|
type: 'boolean',
|
|
@@ -348,11 +366,29 @@ describe('Areas', function() {
|
|
|
348
366
|
}, true)
|
|
349
367
|
);
|
|
350
368
|
assert(
|
|
351
|
-
apos.schema.fieldTypes.boolean.empty({
|
|
369
|
+
!apos.schema.fieldTypes.boolean.empty({
|
|
352
370
|
type: 'boolean',
|
|
353
371
|
name: 'test'
|
|
354
372
|
}, false)
|
|
355
373
|
);
|
|
374
|
+
assert(
|
|
375
|
+
apos.schema.fieldTypes.boolean.empty({
|
|
376
|
+
type: 'boolean',
|
|
377
|
+
name: 'test'
|
|
378
|
+
}, null)
|
|
379
|
+
);
|
|
380
|
+
assert(
|
|
381
|
+
apos.schema.fieldTypes.boolean.empty({
|
|
382
|
+
type: 'boolean',
|
|
383
|
+
name: 'test'
|
|
384
|
+
}, undefined)
|
|
385
|
+
);
|
|
386
|
+
assert(
|
|
387
|
+
apos.schema.fieldTypes.boolean.empty({
|
|
388
|
+
type: 'boolean',
|
|
389
|
+
name: 'test'
|
|
390
|
+
}, 0)
|
|
391
|
+
);
|
|
356
392
|
});
|
|
357
393
|
});
|
|
358
394
|
|
package/test/schemaBuilders.js
CHANGED
|
@@ -73,6 +73,11 @@ describe('Schema builders', function() {
|
|
|
73
73
|
idsStorage: 'favoriteIds',
|
|
74
74
|
label: 'Favorites',
|
|
75
75
|
withType: 'cat'
|
|
76
|
+
},
|
|
77
|
+
isACatPerson: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
label: 'Is a cat person?',
|
|
80
|
+
required: true
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
}
|
|
@@ -102,9 +107,11 @@ describe('Schema builders', function() {
|
|
|
102
107
|
}
|
|
103
108
|
for (i = 0; (i < people.length); i++) {
|
|
104
109
|
const person = people[i];
|
|
110
|
+
person.isACatPerson = true;
|
|
105
111
|
// person 10 has no favorite cat
|
|
106
112
|
if (i < 10) {
|
|
107
113
|
person.favoriteIds = [ cats[i].aposDocId ];
|
|
114
|
+
person.isACatPerson = false;
|
|
108
115
|
}
|
|
109
116
|
person.catsIds = [];
|
|
110
117
|
let j;
|
|
@@ -299,6 +306,23 @@ describe('Schema builders', function() {
|
|
|
299
306
|
assert(cats[0].label);
|
|
300
307
|
assert(cats[0].slug);
|
|
301
308
|
});
|
|
309
|
+
it('can obtain choices for isACatPerson', async function() {
|
|
310
|
+
const req = apos.task.getReq();
|
|
311
|
+
const query = apos.people.find(req);
|
|
312
|
+
const isACatPerson = await query.toChoices('isACatPerson');
|
|
313
|
+
const actual = isACatPerson;
|
|
314
|
+
const expected = [
|
|
315
|
+
{
|
|
316
|
+
value: '1',
|
|
317
|
+
label: 'apostrophe:yes'
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
value: '0',
|
|
321
|
+
label: 'apostrophe:no'
|
|
322
|
+
}
|
|
323
|
+
];
|
|
324
|
+
assert.deepEqual(actual, expected);
|
|
325
|
+
});
|
|
302
326
|
|
|
303
327
|
it('builder for favorite (by slug) exists', function() {
|
|
304
328
|
const req = apos.task.getReq();
|