Add glossary name in view
parent
b54f734bd7
commit
9338603c73
|
@ -22,6 +22,7 @@ import main.component.buttonComponent
|
||||||
@Composable
|
@Composable
|
||||||
fun glossaryDetailedPage(
|
fun glossaryDetailedPage(
|
||||||
glossary: List<Word>,
|
glossary: List<Word>,
|
||||||
|
glossaryName: String,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onAddWordClick: () -> Unit,
|
onAddWordClick: () -> Unit,
|
||||||
onExportClick: () -> Unit,
|
onExportClick: () -> Unit,
|
||||||
|
@ -32,7 +33,7 @@ fun glossaryDetailedPage(
|
||||||
verticalArrangement = Arrangement.Top, // Align content at the top
|
verticalArrangement = Arrangement.Top, // Align content at the top
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Text(text = "Détail du glossaire", style = MaterialTheme.typography.h3)
|
Text(text = "Glossaire : $glossaryName", style = MaterialTheme.typography.h3)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
@ -41,28 +42,18 @@ fun glossaryDetailedPage(
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
buttonComponent(text = "Retour", onClick = { onBackClick() }, icon = Icons.Filled.ArrowBack, width = 150, modifier = Modifier.padding(10.dp))
|
buttonComponent(
|
||||||
buttonComponent(text = "Ajouter un mot", onClick = { onAddWordClick() }, width = 150, modifier = Modifier.padding(10.dp))
|
text = "Retour",
|
||||||
buttonComponent(text = "Exporter un fichier", onClick = { onExportClick() }, width = 150, modifier = Modifier.padding(10.dp))
|
onClick = { onBackClick() },
|
||||||
if (exportedSuccessfully.value) {
|
icon = Icons.Filled.ArrowBack,
|
||||||
AlertDialog(
|
modifier = Modifier.padding(10.dp)
|
||||||
onDismissRequest = { exportedSuccessfully.value = false },
|
)
|
||||||
title = { Text("Exportation réussie") },
|
buttonComponent(text = "Ajouter un mot", onClick = { onAddWordClick() }, modifier = Modifier.padding(10.dp))
|
||||||
text = { Text("Le fichier a été exporté avec succès") },
|
buttonComponent(
|
||||||
confirmButton = {
|
text = "Importer un fichier",
|
||||||
Button(
|
onClick = { onImportClick() },
|
||||||
onClick = { exportedSuccessfully.value = false },
|
modifier = Modifier.padding(10.dp)
|
||||||
colors = ButtonDefaults.buttonColors(
|
)
|
||||||
backgroundColor = customRedColor,
|
|
||||||
contentColor = Color.White
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
Text("OK")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
buttonComponent(text = "Importer un fichier", onClick = { onImportClick() }, width = 150, modifier = Modifier.padding(10.dp))
|
|
||||||
if (importedSuccessfully.value) {
|
if (importedSuccessfully.value) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { importedSuccessfully.value = false },
|
onDismissRequest = { importedSuccessfully.value = false },
|
||||||
|
@ -107,6 +98,29 @@ fun glossaryDetailedPage(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
buttonComponent(
|
||||||
|
text = "Exporter un fichier",
|
||||||
|
onClick = { onExportClick() },
|
||||||
|
modifier = Modifier.padding(10.dp)
|
||||||
|
)
|
||||||
|
if (exportedSuccessfully.value) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = { exportedSuccessfully.value = false },
|
||||||
|
title = { Text("Exportation réussie") },
|
||||||
|
text = { Text("Le fichier a été exporté avec succès") },
|
||||||
|
confirmButton = {
|
||||||
|
Button(
|
||||||
|
onClick = { exportedSuccessfully.value = false },
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = customRedColor,
|
||||||
|
contentColor = Color.White
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Text("OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,8 +189,7 @@ fun glossaryList(glossaries: List<Glossary>, onGlossarySelected: (Glossary) -> U
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
.width(200.dp)
|
.width(200.dp)
|
||||||
.height(300.dp)
|
.height(300.dp),
|
||||||
.border(1.dp, Color.Black),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
) {
|
) {
|
||||||
if (glossaries.isEmpty()) {
|
if (glossaries.isEmpty()) {
|
||||||
|
@ -243,8 +242,7 @@ fun projectList(projects: List<Project>, onProjectSelected: (Project) -> Unit, o
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
.width(250.dp)
|
.width(250.dp)
|
||||||
.height(300.dp)
|
.height(300.dp),
|
||||||
.border(1.dp, Color.Black),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
) {
|
) {
|
||||||
if (projects.isEmpty()) {
|
if (projects.isEmpty()) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||||
import androidx.compose.foundation.VerticalScrollbar
|
import androidx.compose.foundation.VerticalScrollbar
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
@ -23,7 +22,6 @@ import androidx.compose.ui.window.*
|
||||||
import java.awt.FileDialog
|
import java.awt.FileDialog
|
||||||
import java.awt.Frame
|
import java.awt.Frame
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
val customRedColor = Color(0xFFB70D1B)
|
val customRedColor = Color(0xFFB70D1B)
|
||||||
|
@ -43,7 +41,7 @@ fun app() {
|
||||||
val languageManager = remember { LanguageManager() }
|
val languageManager = remember { LanguageManager() }
|
||||||
MaterialTheme {
|
MaterialTheme {
|
||||||
|
|
||||||
var glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
val glossaryDetail: List<Word> by remember { mutableStateOf(emptyList()) }
|
||||||
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
var isJavaScriptFileSelected by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
var glossaries by remember { mutableStateOf(emptyList<Glossary>()) }
|
var glossaries by remember { mutableStateOf(emptyList<Glossary>()) }
|
||||||
|
@ -197,27 +195,34 @@ fun app() {
|
||||||
.onKeyEvent { event ->
|
.onKeyEvent { event ->
|
||||||
if (event.key == Key.Enter && event.type == KeyEventType.KeyDown) {
|
if (event.key == Key.Enter && event.type == KeyEventType.KeyDown) {
|
||||||
// Handle the Enter key event by calling the common function
|
// Handle the Enter key event by calling the common function
|
||||||
if (nouveauGlossaireName.isEmpty()) {
|
when {
|
||||||
println("Veuillez saisir un nom pour le nouveau glossaire")
|
nouveauGlossaireName.isEmpty() -> {
|
||||||
isEmptySnackbarVisibleState.value = true
|
println("Veuillez saisir un nom pour le nouveau glossaire")
|
||||||
} else if (nouveauGlossaireName.contains(" ")) {
|
isEmptySnackbarVisibleState.value = true
|
||||||
println("Le nom du glossaire ne doit pas contenir d'espace")
|
}
|
||||||
containsSpaceSnackbarVisibleState.value = true
|
nouveauGlossaireName.contains(" ") -> {
|
||||||
} else if (glossaries.any { it.name == nouveauGlossaireName }) {
|
println("Le nom du glossaire ne doit pas contenir d'espace")
|
||||||
println("Le nom du glossaire existe déjà")
|
containsSpaceSnackbarVisibleState.value = true
|
||||||
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
}
|
||||||
} else if (!isValidFileName(nouveauGlossaireName)) {
|
glossaries.any { it.name == nouveauGlossaireName } -> {
|
||||||
println("Le nom du glossaire contient des caractères non autorisés")
|
println("Le nom du glossaire existe déjà")
|
||||||
invalidCharacterSnackbarVisibleState.value = true
|
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
||||||
} else {
|
}
|
||||||
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
!isValidFileName(nouveauGlossaireName) -> {
|
||||||
glossaries = glossaries + newGlossary
|
println("Le nom du glossaire contient des caractères non autorisés")
|
||||||
// create new json file
|
invalidCharacterSnackbarVisibleState.value = true
|
||||||
val newFile = File(glossaryPath + (appState.selectedProject?.name) + "/" + newGlossary.jsonFilePath)
|
}
|
||||||
newFile.createNewFile()
|
else -> {
|
||||||
// update glossaries list
|
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
||||||
glossaries = loadGlossaries(appState.selectedProject!!)
|
glossaries = glossaries + newGlossary
|
||||||
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
// create new json file
|
||||||
|
val newFile =
|
||||||
|
File(glossaryPath + (appState.selectedProject?.name) + "/" + newGlossary.jsonFilePath)
|
||||||
|
newFile.createNewFile()
|
||||||
|
// update glossaries list
|
||||||
|
glossaries = loadGlossaries(appState.selectedProject!!)
|
||||||
|
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
||||||
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,28 +239,34 @@ fun app() {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
// Handle the Enter key event by calling the common function
|
// Handle the Enter key event by calling the common function
|
||||||
if (nouveauGlossaireName.isEmpty()) {
|
when {
|
||||||
println("Veuillez saisir un nom pour le nouveau glossaire")
|
nouveauGlossaireName.isEmpty() -> {
|
||||||
isEmptySnackbarVisibleState.value = true
|
println("Veuillez saisir un nom pour le nouveau glossaire")
|
||||||
} else if (nouveauGlossaireName.contains(" ")) {
|
isEmptySnackbarVisibleState.value = true
|
||||||
println("Le nom du glossaire ne doit pas contenir d'espace")
|
}
|
||||||
containsSpaceSnackbarVisibleState.value = true
|
nouveauGlossaireName.contains(" ") -> {
|
||||||
} else if (glossaries.any { it.name == nouveauGlossaireName }) {
|
println("Le nom du glossaire ne doit pas contenir d'espace")
|
||||||
println("Le nom du glossaire existe déjà")
|
containsSpaceSnackbarVisibleState.value = true
|
||||||
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
}
|
||||||
} else if (!isValidFileName(nouveauGlossaireName)) {
|
glossaries.any { it.name == nouveauGlossaireName } -> {
|
||||||
println("Le nom du glossaire contient des caractères non autorisés")
|
println("Le nom du glossaire existe déjà")
|
||||||
invalidCharacterSnackbarVisibleState.value = true
|
glossaryAlreadyExistsSnackbarVisibleState.value = true
|
||||||
} else {
|
}
|
||||||
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
!isValidFileName(nouveauGlossaireName) -> {
|
||||||
glossaries = glossaries + newGlossary
|
println("Le nom du glossaire contient des caractères non autorisés")
|
||||||
// create new json file
|
invalidCharacterSnackbarVisibleState.value = true
|
||||||
val newFile =
|
}
|
||||||
File(glossaryPath + (appState.selectedProject?.name) + "/" + newGlossary.jsonFilePath)
|
else -> {
|
||||||
newFile.createNewFile()
|
val newGlossary = Glossary(nouveauGlossaireName, "$nouveauGlossaireName.json")
|
||||||
// update glossaries list
|
glossaries = glossaries + newGlossary
|
||||||
glossaries = loadGlossaries(appState.selectedProject!!)
|
// create new json file
|
||||||
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
val newFile =
|
||||||
|
File(glossaryPath + (appState.selectedProject?.name) + "/" + newGlossary.jsonFilePath)
|
||||||
|
newFile.createNewFile()
|
||||||
|
// update glossaries list
|
||||||
|
glossaries = loadGlossaries(appState.selectedProject!!)
|
||||||
|
currentPage.value = "glossaires" // Revenir à la liste des glossaires
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
@ -299,6 +310,7 @@ fun app() {
|
||||||
"glossaireDetail" -> {
|
"glossaireDetail" -> {
|
||||||
glossaryDetailedPage(
|
glossaryDetailedPage(
|
||||||
glossary = glossaryDetail,
|
glossary = glossaryDetail,
|
||||||
|
glossaryName = selectedGlossary?.name ?: "",
|
||||||
onBackClick = { currentPage.value = "glossaires" },
|
onBackClick = { currentPage.value = "glossaires" },
|
||||||
onAddWordClick = { currentPage.value = "formulaire" },
|
onAddWordClick = { currentPage.value = "formulaire" },
|
||||||
onExportClick = {
|
onExportClick = {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
@ -245,7 +244,7 @@ fun newProject(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text("Veuillez entrer un nom de glossaire.")
|
Text("Veuillez entrer un nom de projet.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (containsSpaceSnackbarVisibleState.value) {
|
if (containsSpaceSnackbarVisibleState.value) {
|
||||||
|
@ -263,7 +262,7 @@ fun newProject(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text("Veuillez ne pas mettre d'espace dans le nom du glossaire.")
|
Text("Veuillez ne pas mettre d'espace dans le nom du projet.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (glossaryAlreadyExistsSnackbarVisibleState.value) {
|
if (glossaryAlreadyExistsSnackbarVisibleState.value) {
|
||||||
|
@ -281,7 +280,7 @@ fun newProject(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text("Ce glossaire existe déjà.")
|
Text("Ce projet existe déjà.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (invalidCharacterSnackbarVisibleState.value) {
|
if (invalidCharacterSnackbarVisibleState.value) {
|
||||||
|
@ -299,7 +298,7 @@ fun newProject(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text("Le nom du glossaire contient des caractères non autorisés (caractères spéciaux).")
|
Text("Le nom du projet contient des caractères non autorisés (caractères spéciaux).")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue