@@ -365,13 +365,15 @@ export default {
365
365
uniqueBlockTypes () {
366
366
const itemsWithBlocks = this .data .filter ((item ) => item .blocks && item .blocks .length > 0 );
367
367
368
- return Array .from (
369
- new Map (
370
- itemsWithBlocks
371
- .flatMap ((item ) => item .blocks )
372
- .map ((block ) => [block .title , { title: block .title }]),
373
- ).values (),
368
+ const blockTypesMap = new Map (
369
+ itemsWithBlocks
370
+ .flatMap ((item ) => item .blocks )
371
+ .map ((block ) => [block .title , { title: block .title }]),
374
372
);
373
+
374
+ blockTypesMap .set (" No blocks" , { title: " No blocks" });
375
+
376
+ return Array .from (blockTypesMap .values ());
375
377
},
376
378
knownTypes () {
377
379
// Grab the set of types stored under the item type key
@@ -453,6 +455,15 @@ export default {
453
455
return true ;
454
456
}
455
457
458
+ if (
459
+ Array .isArray (filterValue) &&
460
+ filterValue .some ((filter ) => filter .title === " No blocks" )
461
+ ) {
462
+ if (! value || ! Array .isArray (value) || value .length === 0 ) {
463
+ return true ;
464
+ }
465
+ }
466
+
456
467
if (! value || ! Array .isArray (value)) {
457
468
return false ;
458
469
}
@@ -463,11 +474,15 @@ export default {
463
474
if (Array .isArray (filterValue)) {
464
475
if (isAnd) {
465
476
return filterValue .every ((filterBlock ) =>
466
- value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
477
+ filterBlock .title === " No blocks"
478
+ ? ! value || value .length === 0
479
+ : value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
467
480
);
468
481
} else {
469
482
return filterValue .some ((filterBlock ) =>
470
- value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
483
+ filterBlock .title === " No blocks"
484
+ ? ! value || value .length === 0
485
+ : value .some ((itemBlock ) => itemBlock .title === filterBlock .title ),
471
486
);
472
487
}
473
488
}
0 commit comments