Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6b36a1d3a |
@@ -34,7 +34,7 @@ android {
|
||||
applicationId = "pl.firmatpp.kierowca"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 49
|
||||
versionCode = 50
|
||||
versionName = "1.0.44"
|
||||
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pl.firmatpp.kierowca.ui
|
||||
|
||||
import pl.firmatpp.kierowca.data.model.DriverRouteDto
|
||||
import pl.firmatpp.kierowca.data.model.RoutePhotoDto
|
||||
import pl.firmatpp.kierowca.data.upload.RouteActionEntity
|
||||
import pl.firmatpp.kierowca.data.upload.RouteActionStatus
|
||||
import pl.firmatpp.kierowca.data.upload.RouteActionType
|
||||
@@ -41,6 +42,7 @@ fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>):
|
||||
status = "W TRAKCIE",
|
||||
loadingWeight = action.weight,
|
||||
trackingStatus = "active",
|
||||
photos = projectedRoute.safePhotos(),
|
||||
)
|
||||
loadingWeightPending = action.status != RouteActionStatus.Confirmed
|
||||
}
|
||||
@@ -50,6 +52,7 @@ fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>):
|
||||
unloadingWeight = action.weight,
|
||||
trackingStatus = "finished",
|
||||
completedAt = action.occurredAt,
|
||||
photos = projectedRoute.safePhotos(),
|
||||
)
|
||||
unloadingWeightPending = action.status != RouteActionStatus.Confirmed
|
||||
}
|
||||
@@ -71,3 +74,5 @@ fun projectDriverRoutes(routes: List<DriverRouteDto>, actions: List<RouteActionE
|
||||
|
||||
fun routeActionNeedsAttention(status: String): Boolean =
|
||||
status == RouteActionStatus.FailedConflict || status == RouteActionStatus.FailedPermanent
|
||||
|
||||
internal fun DriverRouteDto.safePhotos(): List<RoutePhotoDto> = photos.orEmpty()
|
||||
|
||||
@@ -151,9 +151,9 @@ fun routeFlowSteps(route: DriverRouteDto, actions: List<RouteActionEntity>): Lis
|
||||
)
|
||||
}
|
||||
|
||||
fun routePhotosForStage(photos: List<RoutePhotoDto>, stage: String): List<RoutePhotoDto> {
|
||||
fun routePhotosForStage(photos: List<RoutePhotoDto>?, stage: String): List<RoutePhotoDto> {
|
||||
val normalized = normalizedRoutePhotoStage(stage)
|
||||
return photos.filter { normalizedRoutePhotoStage(it.stage) == normalized }
|
||||
return photos.orEmpty().filter { normalizedRoutePhotoStage(it.stage) == normalized }
|
||||
}
|
||||
|
||||
fun normalizedRoutePhotoStage(stage: String?): String =
|
||||
|
||||
@@ -617,6 +617,7 @@ class DriverViewModel(application: Application) : AndroidViewModel(application)
|
||||
status = "W TRAKCIE",
|
||||
loadingWeight = weight,
|
||||
trackingStatus = "active",
|
||||
photos = route.safePhotos(),
|
||||
)
|
||||
}
|
||||
"unloading" -> {
|
||||
@@ -626,6 +627,7 @@ class DriverViewModel(application: Application) : AndroidViewModel(application)
|
||||
unloadingWeight = weight,
|
||||
trackingStatus = "finished",
|
||||
completedAt = Instant.now().toString(),
|
||||
photos = route.safePhotos(),
|
||||
)
|
||||
}
|
||||
else -> route
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package pl.firmatpp.kierowca.ui
|
||||
|
||||
import com.google.gson.Gson
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import pl.firmatpp.kierowca.data.model.DriverRouteDto
|
||||
import pl.firmatpp.kierowca.data.model.RoutePhotoDto
|
||||
import pl.firmatpp.kierowca.data.upload.RouteActionEntity
|
||||
import pl.firmatpp.kierowca.data.upload.RouteActionStatus
|
||||
import pl.firmatpp.kierowca.data.upload.RouteActionType
|
||||
@@ -73,6 +75,38 @@ class DriverRouteProjectionTest {
|
||||
assertEquals(emptyList<RouteActionEntity>(), projection.visibleActions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun routeProjectionNormalizesNullPhotosFromCachedJsonBeforeCopy() {
|
||||
val route = Gson().fromJson(
|
||||
"""
|
||||
{
|
||||
"id": "1",
|
||||
"startsAt": "",
|
||||
"originName": "Baza",
|
||||
"destinationName": "Instalacja",
|
||||
"contractorName": "TPP",
|
||||
"contractName": "Kontrakt",
|
||||
"contractCode": "TPP-1",
|
||||
"relationLabel": "Baza -> Instalacja",
|
||||
"status": "ZAPLANOWANA",
|
||||
"distanceKm": 1.0,
|
||||
"notes": null,
|
||||
"truck": null,
|
||||
"photos": null
|
||||
}
|
||||
""".trimIndent(),
|
||||
DriverRouteDto::class.java,
|
||||
)
|
||||
|
||||
val projection = projectDriverRoute(
|
||||
route = route,
|
||||
actions = listOf(action(RouteActionType.Start, RouteActionStatus.Confirmed, weight = 12.5)),
|
||||
)
|
||||
|
||||
assertEquals("W TRAKCIE", projection.route.status)
|
||||
assertEquals(emptyList<RoutePhotoDto>(), projection.route.photos)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun conflictKeepsLocalRouteValuesAndMarksStageAsAttention() {
|
||||
val projection = projectDriverRoute(
|
||||
|
||||
Reference in New Issue
Block a user