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:
parent
7a2c5700f9
commit
c1327f3186
|
|
@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ class DeviceInitializationViewModel(
|
|||
}
|
||||
|
||||
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) }
|
||||
} else {
|
||||
println("[DeviceInit] Netzwerk-Rolle direkt gesetzt: $role")
|
||||
|
|
|
|||
|
|
@ -30,9 +30,11 @@ import androidx.compose.ui.text.input.VisualTransformation
|
|||
import androidx.compose.ui.unit.dp
|
||||
import at.mocode.frontend.core.designsystem.components.MsEnumDropdown
|
||||
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.features.device.initialization.domain.DeviceInitializationValidator
|
||||
import at.mocode.frontend.features.device.initialization.domain.model.NetworkRole
|
||||
import javax.print.PrintServiceLookup
|
||||
|
||||
@Composable
|
||||
actual fun DeviceInitializationConfig(
|
||||
|
|
@ -94,14 +96,18 @@ actual fun DeviceInitializationConfig(
|
|||
enabled = !uiState.isLocked
|
||||
)
|
||||
|
||||
MsTextField(
|
||||
value = settings.defaultPrinter,
|
||||
onValueChange = { viewModel.updateSettings { s -> s.copy(defaultPrinter = it) } },
|
||||
val printers = remember {
|
||||
PrintServiceLookup.lookupPrintServices(null, null).map { it.name }.sorted()
|
||||
}
|
||||
|
||||
MsStringDropdown(
|
||||
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,
|
||||
imeAction = ImeAction.Done,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() })
|
||||
modifier = Modifier.padding(bottom = 8.dp)
|
||||
)
|
||||
|
||||
if (settings.networkRole == NetworkRole.MASTER) {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,15 @@ private fun VorschauCard(state: VeranstaltungWizardState) {
|
|||
)
|
||||
Text(
|
||||
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) {
|
||||
Card(colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer)) {
|
||||
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))
|
||||
Column {
|
||||
Text("Stammdaten fehlen!", fontWeight = FontWeight.Bold)
|
||||
Text("Bitte importieren Sie die aktuelle ZNS.zip über den ZNS-Importer.")
|
||||
Text("🚨 Stammdaten fehlen!", fontWeight = FontWeight.Bold, style = MaterialTheme.typography.titleMedium)
|
||||
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)
|
||||
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 {
|
||||
Card(colors = CardDefaults.cardColors(containerColor = Color(0xFFE8F5E9))) {
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ package at.mocode.frontend.features.verein.domain
|
|||
interface VereinRepository {
|
||||
suspend fun getVereine(): Result<List<Verein>>
|
||||
suspend fun saveVerein(verein: Verein): Result<Verein>
|
||||
suspend fun findByOepsNr(oepsNr: String): Verein?
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user