Add mv-initial attribute that is only applied once and stored in the data
I’m not sure if this is a bug, since this is exactly how mv-default was designed, however it has recently become clear to me that this was a rather bad design.
The problem is that currently, when no value is read for a property with a default value, the default value is used. This means that I cannot clear that property. It's not just an initial value, it's a forced value. Such a concept may have its uses, but I’m not sure it's the majority of use cases for default values. And even there, data integrity constraints should not be confused with default values. If a given property is required and cannot be blank, that should be expressed in a different way.
The tipping point was that today I was working on a recipe app, and set the ingredient amount property to 1 by default. However, on some ingredients I didn't need a quantity (e.g. "oil or butter for sautéing) so I cleared the 1. Imagine my surprise when I reloaded and the ingredients list now said "1 oil or butter for frying"!
sounds like one of those cases where you need to distinguish null from undefined....
On 8/9/2017 10:27 AM, Lea Verou wrote:
I’m not sure if this is a bug, since this is exactly how |mv-default| was designed, however it has recently become clear to me that this was a rather bad design.
The problem is that currently, when no value is read for a property with a default value, the default value is used. This means that I cannot clear that property. It's not just an initial value, it's a forced value. Such a concept may have its uses, but I’m not sure it's the majority of use cases for default values. And even there, data integrity constraints should not be confused with default values. If a given property is required and cannot be blank, that should be expressed in a different way.
The tipping point was that today I was working on a recipe app, and set the ingredient amount property to 1 by default. However, on some ingredients I didn't need a quantity (e.g. "oil or butter for sautéing) so I cleared the 1. Imagine my surprise when I reloaded and the ingredients list now said "1 oil or butter for frying"!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mavoweb/mavo/issues/260, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFpXp7cCjzp0NttfJPQAG-pwsNfFSYwks5sWcHIgaJpZM4OyKNF.
OTOH changing how mv-default works would break many useful use cases like http://mattfredfry.com/calculator/
Perhaps we need a new attribute to express "initial value".
After thinking about this a bit, I think we need two attributes:
mv-defaultwhich is dynamic, and not saved in the datamv-initialwhich is only applied once, and saved in the data
This issue will track the latter, and #408 will track any necessary changes to mv-default.