aposSingletonIsEmpty doesn't work as expected
Hey,
seems like aposSingletonIsEmpty works when there isn't items inserted yet, but when I insert an item and remove it (and it gets empty again) it doesn't work anymore(like its not empty).
Im using it for schema-widgets I've created.
any ideas? thanks!
I can confirm this one. It can be easily reproduced by creating a schema widget with an array of slideshows for instance.
For some reason, even if you delete all the slideshows via the UX, there is always a "leftover" last entry with an empty items array that would make aposSingletonIsEmpty believe it isn't empty.
Thanks guys, sorry for the delay- we're going to take a look at this on Friday.
Hey all, We've improved aposSingletonIsEmpty to handle the new singleton syntax today, but detecting empty schema-widgets will take another effort. Since we need to be mindful of default values and other possibilities with each content type, we're going to work on building a comprehensive 'empty' method for schema-widgets. Until then, we'll leave this issue open.
Cool! Is the current iteration addressing the problem I described where if
you add some stuff to the array and then remove all of them, an empty
ghost-entry still exists and messes with aposSingletonIsEmpty?
Danny, the current iteration should handle that ghost-entry, but not yet for schema-widgets.
By the way:
Old Syntax aposSingletonIsEmpty( { area: page.image1, type: 'slideshow' } )
New Syntax aposSingletonIsEmpty( page, 'image1', 'slideshow' )
This works for schema widgets now.
In particular, a schema field of the "array" type with no entries in it is considered empty.
All schema field types have a reasonable definition of empty. Note that matching your default value (the "def" property) does NOT make something empty, because sometimes people intentionally set defaults that no one would consider empty. Emptiness for a string is an empty string, etc.
You can provide an "empty" function when defining a custom schema field type.