Fix GlossaryDetails issues

main
Thomas Breil 2024-01-12 15:13:37 +01:00
parent a5d3811b45
commit 6631008fcc
2 changed files with 29 additions and 26 deletions

View File

@ -28,6 +28,7 @@ fun glossaryDetailedPage(
onExportClick: () -> Unit, onExportClick: () -> Unit,
onImportClick: () -> Unit onImportClick: () -> Unit
) { ) {
println(glossary)
Column( Column(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Top, // Align content at the top verticalArrangement = Arrangement.Top, // Align content at the top

View File

@ -34,7 +34,7 @@ fun app() {
val languageManager = remember { LanguageManager() } val languageManager = remember { LanguageManager() }
MaterialTheme { MaterialTheme {
val glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
var isJavaScriptFileSelected by remember { mutableStateOf(false) } var isJavaScriptFileSelected by remember { mutableStateOf(false) }
@ -81,32 +81,34 @@ fun app() {
} }
"glossaireDetail" -> { "glossaireDetail" -> {
glossaryDetailedPage( appState.selectedGlossary?.let { loadDatasFromFile(it.jsonFilePath) }?.let {
glossary = glossaryDetail, glossaryDetailedPage(
glossaryName = appState.selectedGlossary?.name ?: "", glossary = it,
onBackClick = { currentPage.value = "glossaires" }, glossaryName = appState.selectedGlossary?.name ?: "",
onAddWordClick = { currentPage.value = "formulaire" }, onBackClick = { currentPage.value = "glossaires" },
onExportClick = { onAddWordClick = { currentPage.value = "formulaire" },
val fileDialog = FileDialog(Frame(), "Save as CSV", FileDialog.SAVE) onExportClick = {
fileDialog.file = appState.selectedGlossary?.name // Initial file name val fileDialog = FileDialog(Frame(), "Save as CSV", FileDialog.SAVE)
fileDialog.isVisible = true fileDialog.file = appState.selectedGlossary?.name // Initial file name
val selectedFile = fileDialog.file fileDialog.isVisible = true
val selectedDirectory = fileDialog.directory val selectedFile = fileDialog.file
if (selectedFile != null) { val selectedDirectory = fileDialog.directory
val csvFilePath = "$selectedDirectory$selectedFile" if (selectedFile != null) {
println("Exporting to: $csvFilePath") val csvFilePath = "$selectedDirectory$selectedFile"
appState.selectedGlossary?.let { exportToCSV(it, csvFilePath) } println("Exporting to: $csvFilePath")
} else { appState.selectedGlossary?.let { exportToCSV(it, csvFilePath) }
println("Export command cancelled by user.") } else {
println("Export command cancelled by user.")
}
},
onImportClick = {
selectFile(setOf("csv", "xlsx")) { filePath ->
println("Importing file: $filePath")
appState.selectedGlossary?.let { importFile(it, filePath) }
}
} }
}, )
onImportClick = { }
selectFile(setOf("csv", "xlsx")) { filePath ->
println("Importing file: $filePath")
appState.selectedGlossary?.let { importFile(it, filePath) }
}
}
)
} }
"formulaire" -> { "formulaire" -> {