Move SSD manual group label fallback to typed Kotlin
ober
8a356b988448bf8e2dc1ce35b9f39ba6a6b8eec6
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -3585,7 +3585,8 @@ isGenericGuessLabel isSsdPdfName sourceBaseName canonicalSourceName isUsefulGuessLabel isErrorStatus formatActivityDuration groupDisplayLabel appendModeStatus - selectedGroupStatus sessionCountsStatus rotatedPageStatus) + selectedGroupStatus sessionCountsStatus rotatedPageStatus + manualGroupLabel) (def (normalizeFiringArc (value : String)) : String (string-uppercase (string-trim value))) (def (normalizeLabel (value : String)) : String @@ -3691,6 +3692,15 @@ (if (string-blank? label) (SsdGroup-id group) label))) + (def (manualGroupLabel (label : String) + (resolvedName : (Nullable String)) + (fallback : String)) : String + (let ((text (string-trim label))) + (if (not (string-blank? text)) + text + (if (nullable-null? resolvedName) + fallback + (string-lowercase (nullable-get resolvedName)))))) (def (appendModeStatus (group : SsdGroup)) : String (string-append "Append mode: drag boxes to add to " @@ -5396,7 +5406,7 @@ " ) {" " val session = currentSession ?: return" " val resolvedType = BoxTypes.resolve(this, boxType)" - " val cleanLabel = resolvedLabelForBoxTypeAndroid(this, label, boxType, \"\").ifBlank { resolvedType?.name?.lowercase() ?: \"\" }" + " val cleanLabel = manualGroupLabel(resolvedLabelForBoxTypeAndroid(this, label, boxType, \"\"), resolvedType?.name, \"\")" " val ids = if (detectedIds.isNotEmpty()) {" " detectedIds.toMutableList()" " } else {" @@ -5498,7 +5508,7 @@ " firingArc.dismissDropDown()" " dialog.dismiss()" " val resolved = BoxTypes.resolve(this, boxTypeText)" - " group.label = labelText.ifBlank { resolved?.name?.lowercase() ?: group.label }" + " group.label = manualGroupLabel(labelText, resolved?.name, group.label)" " group.boxTypeId = resolved?.id ?: boxTypeText" " group.firingArc = normalizeFiringArc(firingArcText)" " group.count = countValue?.coerceAtLeast(0) ?: group.count"