Skip to content

Commit

Permalink
Use slug when title empty (#1159)
Browse files Browse the repository at this point in the history
* 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()
  • Loading branch information
darrellcolehill authored Jul 12, 2024
1 parent 0efbb52 commit 4aa4c5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
)
} ?: ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
)
} ?: ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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")
}
Expand Down

0 comments on commit 4aa4c5b

Please sign in to comment.