chore: erweitere Veranstaltungs-Wizard um Ansprechperson-Anzeige, verbessere Fehlerhandling bei fehlenden Stammdaten und implementiere MsStringDropdown
Signed-off-by: StefanMoCoAt <stefan.mo.co@gmail.com>
This commit is contained in:
+94
@@ -0,0 +1,94 @@
|
|||||||
|
package at.mocode.frontend.core.designsystem.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.*
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.input.key.*
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein generischer Dropdown zur Auswahl von Strings (z. B. Druckernamen).
|
||||||
|
*/
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun MsStringDropdown(
|
||||||
|
label: String,
|
||||||
|
options: List<String>,
|
||||||
|
selectedOption: String,
|
||||||
|
onOptionSelected: (String) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
placeholder: String = "",
|
||||||
|
enabled: Boolean = true,
|
||||||
|
isError: Boolean = false,
|
||||||
|
errorMessage: String? = null
|
||||||
|
) {
|
||||||
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
Column(modifier = modifier) {
|
||||||
|
ExposedDropdownMenuBox(
|
||||||
|
expanded = expanded,
|
||||||
|
onExpandedChange = { if (enabled) expanded = it }
|
||||||
|
) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = selectedOption,
|
||||||
|
onValueChange = {},
|
||||||
|
readOnly = true,
|
||||||
|
label = { Text(label, style = MaterialTheme.typography.bodySmall) },
|
||||||
|
placeholder = { Text(placeholder, style = MaterialTheme.typography.bodySmall) },
|
||||||
|
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
|
||||||
|
colors = ExposedDropdownMenuDefaults.outlinedTextFieldColors(),
|
||||||
|
modifier = Modifier
|
||||||
|
.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryEditable, enabled)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.onKeyEvent {
|
||||||
|
if (it.key == Key.Enter || it.key == Key.DirectionCenter) {
|
||||||
|
if (it.type == KeyEventType.KeyUp) {
|
||||||
|
expanded = !expanded
|
||||||
|
}
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isError = isError,
|
||||||
|
enabled = enabled,
|
||||||
|
singleLine = true,
|
||||||
|
textStyle = MaterialTheme.typography.bodyMedium,
|
||||||
|
shape = MaterialTheme.shapes.small
|
||||||
|
)
|
||||||
|
|
||||||
|
ExposedDropdownMenu(
|
||||||
|
expanded = expanded,
|
||||||
|
onDismissRequest = { expanded = false }
|
||||||
|
) {
|
||||||
|
options.forEach { option ->
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
text = option,
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
onOptionSelected(option)
|
||||||
|
expanded = false
|
||||||
|
},
|
||||||
|
contentPadding = ExposedDropdownMenuDefaults.ItemContentPadding
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isError && errorMessage != null) {
|
||||||
|
Text(
|
||||||
|
text = errorMessage,
|
||||||
|
color = MaterialTheme.colorScheme.error,
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
modifier = Modifier.padding(start = 16.dp, top = 4.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -52,7 +52,7 @@ class DeviceInitializationViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setNetworkRole(role: NetworkRole) {
|
fun setNetworkRole(role: NetworkRole) {
|
||||||
if (uiState.value.settings.deviceName.isNotBlank() || uiState.value.settings.sharedKey.isNotBlank()) {
|
if (uiState.value.settings.networkRole != role && (uiState.value.settings.deviceName.isNotBlank() || uiState.value.settings.sharedKey.isNotBlank())) {
|
||||||
_uiState.update { it.copy(showRoleChangeWarning = true, pendingRole = role) }
|
_uiState.update { it.copy(showRoleChangeWarning = true, pendingRole = role) }
|
||||||
} else {
|
} else {
|
||||||
println("[DeviceInit] Netzwerk-Rolle direkt gesetzt: $role")
|
println("[DeviceInit] Netzwerk-Rolle direkt gesetzt: $role")
|
||||||
|
|||||||
+12
-6
@@ -30,9 +30,11 @@ import androidx.compose.ui.text.input.VisualTransformation
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import at.mocode.frontend.core.designsystem.components.MsEnumDropdown
|
import at.mocode.frontend.core.designsystem.components.MsEnumDropdown
|
||||||
import at.mocode.frontend.core.designsystem.components.MsFilePicker
|
import at.mocode.frontend.core.designsystem.components.MsFilePicker
|
||||||
|
import at.mocode.frontend.core.designsystem.components.MsStringDropdown
|
||||||
import at.mocode.frontend.core.designsystem.components.MsTextField
|
import at.mocode.frontend.core.designsystem.components.MsTextField
|
||||||
import at.mocode.frontend.features.device.initialization.domain.DeviceInitializationValidator
|
import at.mocode.frontend.features.device.initialization.domain.DeviceInitializationValidator
|
||||||
import at.mocode.frontend.features.device.initialization.domain.model.NetworkRole
|
import at.mocode.frontend.features.device.initialization.domain.model.NetworkRole
|
||||||
|
import javax.print.PrintServiceLookup
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
actual fun DeviceInitializationConfig(
|
actual fun DeviceInitializationConfig(
|
||||||
@@ -94,14 +96,18 @@ actual fun DeviceInitializationConfig(
|
|||||||
enabled = !uiState.isLocked
|
enabled = !uiState.isLocked
|
||||||
)
|
)
|
||||||
|
|
||||||
MsTextField(
|
val printers = remember {
|
||||||
value = settings.defaultPrinter,
|
PrintServiceLookup.lookupPrintServices(null, null).map { it.name }.sorted()
|
||||||
onValueChange = { viewModel.updateSettings { s -> s.copy(defaultPrinter = it) } },
|
}
|
||||||
|
|
||||||
|
MsStringDropdown(
|
||||||
label = "Standard-Drucker",
|
label = "Standard-Drucker",
|
||||||
placeholder = "z.B. Brother-HL-L2350DW",
|
options = printers,
|
||||||
|
selectedOption = settings.defaultPrinter,
|
||||||
|
onOptionSelected = { viewModel.updateSettings { s -> s.copy(defaultPrinter = it) } },
|
||||||
|
placeholder = "Drucker auswählen...",
|
||||||
enabled = !uiState.isLocked,
|
enabled = !uiState.isLocked,
|
||||||
imeAction = ImeAction.Done,
|
modifier = Modifier.padding(bottom = 8.dp)
|
||||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() })
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (settings.networkRole == NetworkRole.MASTER) {
|
if (settings.networkRole == NetworkRole.MASTER) {
|
||||||
|
|||||||
+27
-6
@@ -118,7 +118,15 @@ private fun VorschauCard(state: VeranstaltungWizardState) {
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "| ${state.startDatum ?: ""} - ${state.endDatum ?: ""}",
|
text = "| ${state.startDatum ?: ""} - ${state.endDatum ?: ""}",
|
||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (state.ansprechpersonName.isNotBlank()) {
|
||||||
|
Text(
|
||||||
|
text = "Ansprechperson: ${state.ansprechpersonName} (${state.ansprechpersonSatznummer})",
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,18 +143,31 @@ private fun ZnsCheckStep(viewModel: VeranstaltungWizardViewModel) {
|
|||||||
if (!state.isZnsAvailable) {
|
if (!state.isZnsAvailable) {
|
||||||
Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer)) {
|
Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer)) {
|
||||||
Row(Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
Icon(Icons.Default.Info, null, tint = MaterialTheme.colorScheme.error)
|
Icon(Icons.Default.Warning, null, tint = MaterialTheme.colorScheme.error)
|
||||||
Spacer(Modifier.width(12.dp))
|
Spacer(Modifier.width(12.dp))
|
||||||
Column {
|
Column {
|
||||||
Text("Stammdaten fehlen!", fontWeight = FontWeight.Bold)
|
Text("🚨 Stammdaten fehlen!", fontWeight = FontWeight.Bold, style = MaterialTheme.typography.titleMedium)
|
||||||
Text("Bitte importieren Sie die aktuelle ZNS.zip über den ZNS-Importer.")
|
Text("Für die Anlage einer Veranstaltung werden Vereins- und Reitdaten benötigt. Bitte importieren Sie die aktuelle ZNS.zip (VEREIN01, LIZENZ01).")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button(onClick = { /* Navigiere zum ZNS Importer */ }) {
|
Button(
|
||||||
|
onClick = { /* Navigiere zum ZNS Importer */ },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.error)
|
||||||
|
) {
|
||||||
Icon(Icons.Default.CloudDownload, null)
|
Icon(Icons.Default.CloudDownload, null)
|
||||||
Spacer(Modifier.width(8.dp))
|
Spacer(Modifier.width(8.dp))
|
||||||
Text("ZNS-Importer öffnen")
|
Text("Zum ZNS-Importer")
|
||||||
|
}
|
||||||
|
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = { viewModel.checkZnsAvailability() },
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Icon(Icons.Default.Refresh, null)
|
||||||
|
Spacer(Modifier.width(8.dp))
|
||||||
|
Text("Status erneut prüfen")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Card(colors = CardDefaults.cardColors(containerColor = Color(0xFFE8F5E9))) {
|
Card(colors = CardDefaults.cardColors(containerColor = Color(0xFFE8F5E9))) {
|
||||||
|
|||||||
+1
@@ -3,4 +3,5 @@ package at.mocode.frontend.features.verein.domain
|
|||||||
interface VereinRepository {
|
interface VereinRepository {
|
||||||
suspend fun getVereine(): Result<List<Verein>>
|
suspend fun getVereine(): Result<List<Verein>>
|
||||||
suspend fun saveVerein(verein: Verein): Result<Verein>
|
suspend fun saveVerein(verein: Verein): Result<Verein>
|
||||||
|
suspend fun findByOepsNr(oepsNr: String): Verein?
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user