From 23259d22e70914e655e64634f8a08d64c1bb57b9 Mon Sep 17 00:00:00 2001 From: Sean DeNigris Date: Fri, 20 Oct 2023 23:21:49 -0400 Subject: [PATCH] [Enh]: Element Descriptions - Initial Answer Slightly different than `default`. Default is what the value of the field *is* if not explicitly set. The initial answer is what the value *might be* e.g. to make it easier to fill out a form. --- source/Magritte-Model/MADescription.class.st | 7 ++++--- source/Magritte-Model/MAElementDescription.class.st | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/Magritte-Model/MADescription.class.st b/source/Magritte-Model/MADescription.class.st index fd4de01b..b0647d03 100644 --- a/source/Magritte-Model/MADescription.class.st +++ b/source/Magritte-Model/MADescription.class.st @@ -879,9 +879,10 @@ MADescription >> undefined: aString [ { #category : #'accessing-properties' } MADescription >> undefinedValue [ - self flag: 'could this be simplified with maLazyXyz?'. - ^ (self propertyAt: #undefinedValue ifAbsent: [ self class defaultUndefinedValue ]) - ifNil: [ self class defaultUndefinedValue ] + + ^ self + propertyAt: #undefinedValue + ifAbsent: [ self class defaultUndefinedValue ] ] { #category : #'accessing-properties' } diff --git a/source/Magritte-Model/MAElementDescription.class.st b/source/Magritte-Model/MAElementDescription.class.st index 4d7405d4..469f9e9a 100644 --- a/source/Magritte-Model/MAElementDescription.class.st +++ b/source/Magritte-Model/MAElementDescription.class.st @@ -85,6 +85,16 @@ MAElementDescription >> handlesSelector: aSelector [ ^ self accessor handlesSelector: aSelector ] +{ #category : #accessing } +MAElementDescription >> initialAnswer [ + ^ self propertyAt: #initialAnswer ifAbsent: [ self default ] +] + +{ #category : #accessing } +MAElementDescription >> initialAnswer: aValuable [ + self propertyAt: #initialAnswer put: aValuable +] + { #category : #'lazy initialization' } MAElementDescription >> lazilyInitializeFrom: currentValue for: anObject [ "- The default value is cached if the description's #shouldCacheDefault property is true. An example when caching is necessary is for to-many relations because the user may modify the collection, which will then be thrown away if not cached