refactor: rename responsavel to recurso throughout data models, repository, and UI layers
This commit is contained in:
@@ -13,7 +13,7 @@ data class MaintenanceActivity(
|
||||
val descricao: String,
|
||||
val setor: String,
|
||||
val equipe: String,
|
||||
val responsavel: String,
|
||||
val recurso: String,
|
||||
val dataInicio: String,
|
||||
val dataFim: String,
|
||||
val percentualExecucao: Int, // 0 to 100
|
||||
@@ -45,7 +45,7 @@ data class OSUpdateHistory(
|
||||
val percentualNovo: Int,
|
||||
val observacao: String? = null,
|
||||
val fotoPath: String? = null,
|
||||
val responsavel: String
|
||||
val recurso: String
|
||||
)
|
||||
|
||||
fun extractDateOnly(dataStr: String): String {
|
||||
|
||||
@@ -432,7 +432,7 @@ class GoogleSheetsSyncService(private val context: Context) {
|
||||
val equipe = if (rawEquipe.isNotBlank()) sanitizeEquipe(rawEquipe) else "Mecânica"
|
||||
|
||||
val rawResp = if (resourceIdx != -1 && resourceIdx < row.size) row[resourceIdx].trim() else ""
|
||||
val responsavel = if (rawResp.isNotBlank()) rawResp else "Sem Responsável"
|
||||
val recurso = if (rawResp.isNotBlank()) rawResp else "Sem Recurso"
|
||||
|
||||
val dataInicio = if (inicioIdx != -1 && inicioIdx < row.size) row[inicioIdx].trim() else "N/A"
|
||||
val dataFim = if (fimIdx != -1 && fimIdx < row.size) row[fimIdx].trim() else "N/A"
|
||||
@@ -443,7 +443,7 @@ class GoogleSheetsSyncService(private val context: Context) {
|
||||
descricao = desc,
|
||||
setor = setor,
|
||||
equipe = equipe,
|
||||
responsavel = responsavel,
|
||||
recurso = recurso,
|
||||
dataInicio = dataInicio,
|
||||
dataFim = dataFim,
|
||||
percentualExecucao = 0, // Determined later in repository by merging history logs
|
||||
@@ -560,7 +560,7 @@ class GoogleSheetsSyncService(private val context: Context) {
|
||||
percentualNovo = new,
|
||||
observacao = obs,
|
||||
fotoPath = foto,
|
||||
responsavel = resp
|
||||
recurso = resp
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -596,7 +596,7 @@ class GoogleSheetsSyncService(private val context: Context) {
|
||||
row[headerIndices["percentualnovo"] ?: 4] = history.percentualNovo.toString()
|
||||
row[headerIndices["observacao"] ?: 5] = history.observacao ?: ""
|
||||
row[headerIndices["fotopath"] ?: 6] = history.fotoPath ?: ""
|
||||
row[headerIndices["responsavel"] ?: 7] = history.responsavel
|
||||
row[headerIndices["responsavel"] ?: 7] = history.recurso
|
||||
row
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class MaintenanceRepository(
|
||||
novoPercentual: Int,
|
||||
observacao: String?,
|
||||
fotoPath: String?,
|
||||
responsavel: String
|
||||
recurso: String
|
||||
) = withContext(Dispatchers.IO) {
|
||||
val currentActivity = dao.getActivityByOsOneShot(numeroOs) ?: return@withContext
|
||||
|
||||
@@ -54,7 +54,7 @@ class MaintenanceRepository(
|
||||
percentualNovo = novoPercentual,
|
||||
observacao = observacao,
|
||||
fotoPath = fotoPath,
|
||||
responsavel = responsavel
|
||||
recurso = recurso
|
||||
)
|
||||
dao.insertHistory(historyEntry)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class MaintenanceRepository(
|
||||
val desc = rowCells[descIdx]
|
||||
val setor = if (setorIdx != -1 && setorIdx < rowCells.size) rowCells[setorIdx] else "Geral"
|
||||
val equipe = if (eqIdx != -1 && eqIdx < rowCells.size) rowCells[eqIdx] else "Mecânica"
|
||||
val responsavel = if (respIdx != -1 && respIdx < rowCells.size) rowCells[respIdx] else "Sem Responsável"
|
||||
val recurso = if (respIdx != -1 && respIdx < rowCells.size) rowCells[respIdx] else "Sem Recurso"
|
||||
val dataInicio = if (inicioIdx != -1 && inicioIdx < rowCells.size) rowCells[inicioIdx] else "N/A"
|
||||
val dataFim = if (fimIdx != -1 && fimIdx < rowCells.size) rowCells[fimIdx] else "N/A"
|
||||
val pctStr = if (pctIdx != -1 && pctIdx < rowCells.size) rowCells[pctIdx].replace("%", "").trim() else "0"
|
||||
@@ -129,7 +129,7 @@ class MaintenanceRepository(
|
||||
descricao = desc,
|
||||
setor = sanitizeSetor(setor),
|
||||
equipe = sanitizeEquipe(equipe),
|
||||
responsavel = responsavel,
|
||||
recurso = recurso,
|
||||
dataInicio = dataInicio,
|
||||
dataFim = dataFim,
|
||||
percentualExecucao = pct.coerceIn(0, 100),
|
||||
@@ -177,7 +177,7 @@ class MaintenanceRepository(
|
||||
percentualAnterior = 0,
|
||||
percentualNovo = activity.percentualExecucao,
|
||||
observacao = activity.observacoes,
|
||||
responsavel = activity.responsavel,
|
||||
recurso = activity.recurso,
|
||||
timestamp = now - 3600000 // 1 hour ago
|
||||
)
|
||||
)
|
||||
|
||||
@@ -67,7 +67,7 @@ fun MaintenanceDashboardScreen(
|
||||
val selectedEquipe by viewModel.selectedEquipe.collectAsStateWithLifecycle()
|
||||
val selectedStatus by viewModel.selectedStatus.collectAsStateWithLifecycle()
|
||||
val selectedDataInicio by viewModel.selectedDataInicio.collectAsStateWithLifecycle()
|
||||
val selectedResponsavel by viewModel.selectedResponsavel.collectAsStateWithLifecycle()
|
||||
val selectedRecurso by viewModel.selectedRecurso.collectAsStateWithLifecycle()
|
||||
val searchQuery by viewModel.searchQuery.collectAsStateWithLifecycle()
|
||||
|
||||
val isSyncing by viewModel.isSyncing.collectAsStateWithLifecycle()
|
||||
@@ -101,9 +101,15 @@ fun MaintenanceDashboardScreen(
|
||||
listOf("Todas") + formattedDates
|
||||
}
|
||||
|
||||
val uniqueResponsibles = remember(allActivities) {
|
||||
val resps = allActivities.map { it.responsavel }.filter { it.isNotBlank() && it != "Sem Responsável" && it != "Sem responsável" }.distinct().sorted()
|
||||
listOf("Todos") + resps
|
||||
val uniqueRecursos = remember(allActivities) {
|
||||
val recs = allActivities.flatMap { activity ->
|
||||
activity.recurso.split(";").map { it.trim() }
|
||||
}.filter {
|
||||
it.isNotBlank() &&
|
||||
it != "Sem Responsável" && it != "Sem responsável" &&
|
||||
it != "Sem Recurso" && it != "Sem recurso"
|
||||
}.distinct().sorted()
|
||||
listOf("Todos") + recs
|
||||
}
|
||||
|
||||
val uniqueSectors = remember(allActivities) {
|
||||
@@ -269,15 +275,15 @@ fun MaintenanceDashboardScreen(
|
||||
selectedEquipe = selectedEquipe,
|
||||
selectedStatus = selectedStatus,
|
||||
selectedDataInicio = selectedDataInicio,
|
||||
selectedResponsavel = selectedResponsavel,
|
||||
selectedRecurso = selectedRecurso,
|
||||
uniqueSectors = uniqueSectors,
|
||||
uniqueDates = uniqueDates,
|
||||
uniqueResponsibles = uniqueResponsibles,
|
||||
uniqueRecursos = uniqueRecursos,
|
||||
onSetorSelected = { viewModel.setFilterSetor(it) },
|
||||
onEquipeSelected = { viewModel.setFilterEquipe(it) },
|
||||
onStatusSelected = { viewModel.setFilterStatus(it) },
|
||||
onDataInicioSelected = { viewModel.setFilterDataInicio(it) },
|
||||
onResponsavelSelected = { viewModel.setFilterResponsavel(it) }
|
||||
onRecursoSelected = { viewModel.setFilterRecurso(it) }
|
||||
)
|
||||
|
||||
// List Title and Item Count
|
||||
@@ -357,7 +363,7 @@ fun MaintenanceDashboardScreen(
|
||||
viewModel.setFilterEquipe("Todas")
|
||||
viewModel.setFilterStatus("Todos")
|
||||
viewModel.setFilterDataInicio("Todas")
|
||||
viewModel.setFilterResponsavel("Todos")
|
||||
viewModel.setFilterRecurso("Todos")
|
||||
viewModel.setSearchQuery("")
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(containerColor = CargillBlack)
|
||||
@@ -398,7 +404,7 @@ fun MaintenanceDashboardScreen(
|
||||
novoPercentual = newPct,
|
||||
observacao = comment,
|
||||
fotoPath = mockPhoto,
|
||||
responsavel = "Encarregado Campo"
|
||||
recurso = "Encarregado Campo"
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -540,15 +546,15 @@ fun FilterPillsRow(
|
||||
selectedEquipe: String,
|
||||
selectedStatus: String,
|
||||
selectedDataInicio: String,
|
||||
selectedResponsavel: String,
|
||||
selectedRecurso: String,
|
||||
uniqueSectors: List<String>,
|
||||
uniqueDates: List<String>,
|
||||
uniqueResponsibles: List<String>,
|
||||
uniqueRecursos: List<String>,
|
||||
onSetorSelected: (String) -> Unit,
|
||||
onEquipeSelected: (String) -> Unit,
|
||||
onStatusSelected: (String) -> Unit,
|
||||
onDataInicioSelected: (String) -> Unit,
|
||||
onResponsavelSelected: (String) -> Unit
|
||||
onRecursoSelected: (String) -> Unit
|
||||
) {
|
||||
val setores = uniqueSectors
|
||||
val equipes = listOf("Todas", "Mecânica", "Elétrica", "Confiabilidade", "Lubrificação")
|
||||
@@ -616,16 +622,16 @@ fun FilterPillsRow(
|
||||
}
|
||||
}
|
||||
|
||||
// Responsible Row
|
||||
// Resource Row
|
||||
Row(modifier = Modifier.padding(horizontal = 16.dp)) {
|
||||
Text("Resp.:", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = StatusGrey, modifier = Modifier.width(72.dp).align(Alignment.CenterVertically))
|
||||
Text("Recurso:", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = StatusGrey, modifier = Modifier.width(72.dp).align(Alignment.CenterVertically))
|
||||
LazyRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
items(uniqueResponsibles) { respVal ->
|
||||
val isSelected = respVal == selectedResponsavel
|
||||
FilterChipWidget(text = respVal, isSelected = isSelected, onClick = { onResponsavelSelected(respVal) })
|
||||
items(uniqueRecursos) { respVal ->
|
||||
val isSelected = respVal == selectedRecurso
|
||||
FilterChipWidget(text = respVal, isSelected = isSelected, onClick = { onRecursoSelected(respVal) })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,9 +802,9 @@ fun OSListItemCard(
|
||||
}
|
||||
}
|
||||
|
||||
// Responsible Supervisor Initials / Name
|
||||
// Resource Names
|
||||
Text(
|
||||
text = "Resp: ${activity.responsavel}",
|
||||
text = "Recurso: ${activity.recurso}",
|
||||
fontSize = 11.sp,
|
||||
color = StatusGrey,
|
||||
fontWeight = FontWeight.Medium
|
||||
@@ -945,7 +951,7 @@ fun EditActivityBottomSheet(
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
Text("Setor: ${activity.setor}", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = CargillGreen)
|
||||
Text("Equipe: ${activity.equipe}", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = StatusBlue)
|
||||
Text("Resp: ${activity.responsavel}", fontSize = 11.sp, color = StatusGrey)
|
||||
Text("Recurso: ${activity.recurso}", fontSize = 11.sp, color = StatusGrey)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1202,7 @@ fun TimelineLogItem(log: OSUpdateHistory) {
|
||||
) {
|
||||
Icon(Icons.Default.Person, contentDescription = "Usuário", tint = StatusGrey, modifier = Modifier.size(12.dp))
|
||||
Text(
|
||||
text = log.responsavel,
|
||||
text = log.recurso,
|
||||
fontSize = 11.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = CargillBlack
|
||||
@@ -1330,7 +1336,7 @@ fun ImporterConsoleSheet(
|
||||
) {
|
||||
Text("Estrutura Esperada do Arquivo (Excel):", fontSize = 11.sp, fontWeight = FontWeight.Bold, color = CargillBlack)
|
||||
Text("• Colunas Obrigatórias: Número da OS, Descrição da Atividade", fontSize = 11.sp, color = StatusGrey)
|
||||
Text("• Colunas Opcionais: Setor, Equipe, Responsável, Início, Fim, %", fontSize = 11.sp, color = StatusGrey)
|
||||
Text("• Colunas Opcionais: Setor, Equipe, Recurso, Início, Fim, %", fontSize = 11.sp, color = StatusGrey)
|
||||
Text("• Suporta separadores por Vírgula (,) ou Ponto e Vírgula (;)", fontSize = 11.sp, color = StatusGrey)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
private val _selectedDataInicio = MutableStateFlow("Todas")
|
||||
val selectedDataInicio = _selectedDataInicio.asStateFlow()
|
||||
|
||||
private val _selectedResponsavel = MutableStateFlow("Todos")
|
||||
val selectedResponsavel = _selectedResponsavel.asStateFlow()
|
||||
private val _selectedRecurso = MutableStateFlow("Todos")
|
||||
val selectedRecurso = _selectedRecurso.asStateFlow()
|
||||
|
||||
private val _searchQuery = MutableStateFlow("")
|
||||
val searchQuery = _searchQuery.asStateFlow()
|
||||
@@ -78,7 +78,7 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
_selectedEquipe,
|
||||
_selectedStatus,
|
||||
_selectedDataInicio,
|
||||
_selectedResponsavel,
|
||||
_selectedRecurso,
|
||||
_searchQuery
|
||||
) { flowsArray ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -87,7 +87,7 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
val equipe = flowsArray[2] as String
|
||||
val status = flowsArray[3] as String
|
||||
val dataInicio = flowsArray[4] as String
|
||||
val responsavel = flowsArray[5] as String
|
||||
val recurso = flowsArray[5] as String
|
||||
val query = flowsArray[6] as String
|
||||
|
||||
val filtered = activities.filter { activity ->
|
||||
@@ -100,13 +100,13 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
else -> true
|
||||
}
|
||||
val matchDataInicio = dataInicio == "Todas" || formatToShortDate(activity.dataInicio) == dataInicio
|
||||
val matchResponsavel = responsavel == "Todos" || activity.responsavel == responsavel
|
||||
val matchRecurso = recurso == "Todos" || activity.recurso.split(";").map { it.trim() }.contains(recurso)
|
||||
val matchQuery = query.isBlank() ||
|
||||
activity.numeroOs.contains(query, ignoreCase = true) ||
|
||||
activity.descricao.contains(query, ignoreCase = true) ||
|
||||
activity.responsavel.contains(query, ignoreCase = true)
|
||||
activity.recurso.contains(query, ignoreCase = true)
|
||||
|
||||
matchSetor && matchEquipe && matchStatus && matchDataInicio && matchResponsavel && matchQuery
|
||||
matchSetor && matchEquipe && matchStatus && matchDataInicio && matchRecurso && matchQuery
|
||||
}
|
||||
|
||||
if (dataInicio != "Todas") {
|
||||
@@ -188,8 +188,8 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
_selectedDataInicio.value = dataInicio
|
||||
}
|
||||
|
||||
fun setFilterResponsavel(responsavel: String) {
|
||||
_selectedResponsavel.value = responsavel
|
||||
fun setFilterRecurso(recurso: String) {
|
||||
_selectedRecurso.value = recurso
|
||||
}
|
||||
|
||||
fun setSearchQuery(query: String) {
|
||||
@@ -271,10 +271,10 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
novoPercentual: Int,
|
||||
observacao: String?,
|
||||
fotoPath: String?,
|
||||
responsavel: String
|
||||
recurso: String
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
repository.updateProgress(numeroOs, novoPercentual, observacao, fotoPath, responsavel)
|
||||
repository.updateProgress(numeroOs, novoPercentual, observacao, fotoPath, recurso)
|
||||
// Update selected activity model in state to refresh UI
|
||||
_selectedActivity.value?.let { active ->
|
||||
if (active.numeroOs == numeroOs) {
|
||||
|
||||
Reference in New Issue
Block a user