From 4aa4c5b0e74140b253e4b089a29325ece08f7d1b Mon Sep 17 00:00:00 2001 From: Darrell Cole Hill Date: Fri, 12 Jul 2024 08:20:18 -0400 Subject: [PATCH] Use slug when title empty (#1159) * Uses book slug when title is empty * Toolbar uses book slug when title is empty * Export dialog title uses slug when title is empty * cleanup * Entire book slug uppercase * Removed Locale.getDefault() --- .../otter/jvm/workbookapp/ui/narration/NarrationHeader.kt | 6 +++++- .../otter/jvm/workbookapp/ui/narration/NarrationToolBar.kt | 6 +++++- .../workbookapp/ui/screens/dialogs/ExportProjectDialog.kt | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationHeader.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationHeader.kt index 3062bb6483..ae99c61fd9 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationHeader.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationHeader.kt @@ -50,6 +50,7 @@ import org.wycliffeassociates.otter.jvm.workbookapp.ui.viewmodel.AudioPluginView import org.wycliffeassociates.otter.jvm.workbookapp.ui.viewmodel.WorkbookDataStore import tornadofx.* import java.text.MessageFormat +import java.util.* import javax.inject.Inject class NarrationHeader : View() { @@ -142,9 +143,12 @@ class NarrationHeaderViewModel : ViewModel() { val titleProperty = workbookDataStore.activeWorkbookProperty.stringBinding { it?.let { + val title = it.target.title.takeIf { bookTitle -> bookTitle.isNotEmpty() } + ?: it.target.slug.toUpperCase() + MessageFormat.format( messages["narrationTitle"], - it.target.title + title ) } ?: "" } diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationToolBar.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationToolBar.kt index 4b7b5bc861..ba27a4846b 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationToolBar.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/narration/NarrationToolBar.kt @@ -32,6 +32,7 @@ import org.wycliffeassociates.otter.jvm.utils.onChangeAndDoNow import org.wycliffeassociates.otter.jvm.workbookapp.ui.viewmodel.WorkbookDataStore import tornadofx.* import java.text.MessageFormat +import java.util.* class NarrationToolBar : View() { private val viewModel: NarrationToolbarViewModel by inject() @@ -104,9 +105,12 @@ class NarrationToolbarViewModel : ViewModel() { val titleProperty = workbookDataStore.activeWorkbookProperty.stringBinding { it?.let { + val title = it.target.title.takeIf { bookTitle -> bookTitle.isNotEmpty() } + ?: it.target.slug.toUpperCase() + MessageFormat.format( messages["narrationTitle"], - it.target.title + title ) } ?: "" } diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/screens/dialogs/ExportProjectDialog.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/screens/dialogs/ExportProjectDialog.kt index 3de4f95e14..3f9520c279 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/screens/dialogs/ExportProjectDialog.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/screens/dialogs/ExportProjectDialog.kt @@ -40,6 +40,7 @@ import org.wycliffeassociates.otter.jvm.workbookapp.ui.components.tableview.expo import org.wycliffeassociates.otter.jvm.workbookapp.ui.events.WorkbookExportEvent import tornadofx.* import java.text.MessageFormat +import java.util.* import kotlin.math.roundToInt class ExportProjectDialog : OtterDialog() { @@ -60,7 +61,9 @@ class ExportProjectDialog : OtterDialog() { addClass("confirm-dialog__header") label { textProperty().bind(workbookDescriptorProperty.stringBinding { - MessageFormat.format(messages["bookNameExportTitle"], it?.title) + val title = it?.title.takeIf { !it.isNullOrEmpty() } + ?: it?.slug?.toUpperCase() + MessageFormat.format(messages["bookNameExportTitle"], title) }) addClass("h3") }