Update selectedGlossary
parent
29368a1688
commit
a5d3811b45
|
@ -39,7 +39,7 @@ val frame = Frame()
|
|||
fun glossariesPage(
|
||||
currentPage: MutableState<String>
|
||||
) {
|
||||
var selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
|
||||
var glossaries by remember { mutableStateOf(emptyList<Glossary>()) }
|
||||
|
||||
Column(
|
||||
|
@ -75,7 +75,7 @@ fun glossariesPage(
|
|||
) {
|
||||
Button(
|
||||
onClick = {
|
||||
selectedGlossary = glossary
|
||||
appState.selectedGlossary = glossary
|
||||
currentPage.value = "glossaireDetail"
|
||||
},
|
||||
modifier = Modifier
|
||||
|
|
|
@ -24,6 +24,7 @@ const val glossaryPath : String = "src/main/resources/projects/"
|
|||
// Classe pour stocker l'état global
|
||||
object AppState {
|
||||
var selectedProject: Project? = null
|
||||
var selectedGlossary: Glossary? = null
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class, ExperimentalComposeUiApi::class)
|
||||
|
@ -36,7 +37,7 @@ fun app() {
|
|||
val glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
||||
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
||||
|
||||
val selectedGlossary by remember { mutableStateOf<Glossary?>(null) }
|
||||
|
||||
|
||||
val isEmptySnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
val containsSpaceSnackbarVisibleState = remember { mutableStateOf(false) }
|
||||
|
@ -82,19 +83,19 @@ fun app() {
|
|||
"glossaireDetail" -> {
|
||||
glossaryDetailedPage(
|
||||
glossary = glossaryDetail,
|
||||
glossaryName = selectedGlossary?.name ?: "",
|
||||
glossaryName = appState.selectedGlossary?.name ?: "",
|
||||
onBackClick = { currentPage.value = "glossaires" },
|
||||
onAddWordClick = { currentPage.value = "formulaire" },
|
||||
onExportClick = {
|
||||
val fileDialog = FileDialog(Frame(), "Save as CSV", FileDialog.SAVE)
|
||||
fileDialog.file = selectedGlossary?.name // Initial file name
|
||||
fileDialog.file = appState.selectedGlossary?.name // Initial file name
|
||||
fileDialog.isVisible = true
|
||||
val selectedFile = fileDialog.file
|
||||
val selectedDirectory = fileDialog.directory
|
||||
if (selectedFile != null) {
|
||||
val csvFilePath = "$selectedDirectory$selectedFile"
|
||||
println("Exporting to: $csvFilePath")
|
||||
selectedGlossary?.let { exportToCSV(it, csvFilePath) }
|
||||
appState.selectedGlossary?.let { exportToCSV(it, csvFilePath) }
|
||||
} else {
|
||||
println("Export command cancelled by user.")
|
||||
}
|
||||
|
@ -102,14 +103,14 @@ fun app() {
|
|||
onImportClick = {
|
||||
selectFile(setOf("csv", "xlsx")) { filePath ->
|
||||
println("Importing file: $filePath")
|
||||
selectedGlossary?.let { importFile(it, filePath) }
|
||||
appState.selectedGlossary?.let { importFile(it, filePath) }
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
"formulaire" -> {
|
||||
selectedGlossary?.let { formPage(it, onCancelClick = { currentPage.value = "glossaireDetail" }) }
|
||||
appState.selectedGlossary?.let { formPage(it, onCancelClick = { currentPage.value = "glossaireDetail" }) }
|
||||
}
|
||||
|
||||
"choixLangage" -> {
|
||||
|
|
Loading…
Reference in New Issue