@@ -371,13 +371,15 @@ export default {
371
371
uniqueBlockTypes () {
372
372
const itemsWithBlocks = this .data .filter ((item ) => item .blocks && item .blocks .length > 0 );
373
373
374
- return Array .from (
375
- new Map (
376
- itemsWithBlocks
377
- .flatMap ((item ) => item .blocks )
378
- .map ((block ) => [block .title , { title: block .title }]),
379
- ).values (),
374
+ const blockTypesMap = new Map (
375
+ itemsWithBlocks
376
+ .flatMap ((item ) => item .blocks )
377
+ .map ((block ) => [block .title , { title: block .title }]),
380
378
);
379
+
380
+ blockTypesMap .set (" No blocks" , { title: " No blocks" });
381
+
382
+ return Array .from (blockTypesMap .values ());
381
383
},
382
384
knownTypes () {
383
385
// Grab the set of types stored under the item type key
@@ -463,6 +465,15 @@ export default {
463
465
return true ;
464
466
}
465
467
468
+ if (
469
+ Array .isArray (filterValue) &&
470
+ filterValue .some ((filter ) => filter .title === " No blocks" )
471
+ ) {
472
+ if (! value || ! Array .isArray (value) || value .length === 0 ) {
473
+ return true ;
474
+ }
475
+ }
476
+
466
477
if (! value || ! Array .isArray (value)) {
467
478
return false ;
468
479
}
@@ -473,11 +484,15 @@ export default {
473
484
if (Array .isArray (filterValue)) {
474
485
if (isAnd) {
475
486
return filterValue .every ((filterBlock ) =>
476
- value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
487
+ filterBlock .title === " No blocks"
488
+ ? ! value || value .length === 0
489
+ : value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
477
490
);
478
491
} else {
479
492
return filterValue .some ((filterBlock ) =>
480
- value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
493
+ filterBlock .title === " No blocks"
494
+ ? ! value || value .length === 0
495
+ : value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
481
496
);
482
497
}
483
498
}
0 commit comments