feat: refs#8811 buscarItemByWarehouse
This commit is contained in:
parent
091b597f34
commit
c4378b3f4c
|
@ -1,5 +1,7 @@
|
||||||
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
package es.verdnatura.presentation.view.feature.buscaritem.fragment
|
||||||
|
|
||||||
|
import es.verdnatura.MobileApplication
|
||||||
|
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||||
import es.verdnatura.domain.SalixCallback
|
import es.verdnatura.domain.SalixCallback
|
||||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||||
import es.verdnatura.presentation.base.BaseViewModelCompose
|
import es.verdnatura.presentation.base.BaseViewModelCompose
|
||||||
|
@ -23,7 +25,7 @@ class BuscarItemComposeViewModel(var application: android.app.Application) :
|
||||||
val uiState = _uiState.asStateFlow()
|
val uiState = _uiState.asStateFlow()
|
||||||
|
|
||||||
fun getIdFromCodeSalix(code: String) {
|
fun getIdFromCodeSalix(code: String) {
|
||||||
_uiState.update { it.copy(itemFk = code, isLoading = true) }
|
_uiState.update { it.copy(itemFk = code, isLoading = false) }
|
||||||
getItemFromBarcodeUseCase.execute(code)
|
getItemFromBarcodeUseCase.execute(code)
|
||||||
.enqueue(object : SalixCallback<Int?>(application.applicationContext) {
|
.enqueue(object : SalixCallback<Int?>(application.applicationContext) {
|
||||||
override fun onSuccess(response: Response<Int?>) {
|
override fun onSuccess(response: Response<Int?>) {
|
||||||
|
@ -42,14 +44,53 @@ class BuscarItemComposeViewModel(var application: android.app.Application) :
|
||||||
|
|
||||||
fun itemshelvingsGet(itemFk: Any) {
|
fun itemshelvingsGet(itemFk: Any) {
|
||||||
salix.itemShelvingsGet(
|
salix.itemShelvingsGet(
|
||||||
filter = """{"where":{"itemFk":$itemFk},"fields":["created","visible","available","shelvingFk"],
|
filter = """{
|
||||||
|"include":[{"relation":"shelving","scope":{"fields":["code","priority","parkingFk"],
|
"where": { "itemFk": $itemFk },
|
||||||
|"include":{"relation":"parking","scope":{"fields":["code","sectorFk"]}}}}]}""".trimMargin()
|
"fields": ["created", "visible", "available", "shelvingFk"],
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "shelving",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["code", "priority", "parkingFk"],
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "parking",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["code", "sectorFk"],
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "sector",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["warehouseFk","description"],
|
||||||
|
"where": { "warehouseFk":
|
||||||
|
${
|
||||||
|
(application as MobileApplication).dataStoreApp.readDataStoreKey<Int>(
|
||||||
|
WAREHOUSEFK
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}""".trimIndent()
|
||||||
)
|
)
|
||||||
.enqueue(object : SalixCallback<List<ItemShelvings>>(application.applicationContext) {
|
.enqueue(object : SalixCallback<List<ItemShelvings>>(application.applicationContext) {
|
||||||
override fun onSuccess(response: Response<List<ItemShelvings>>) {
|
override fun onSuccess(response: Response<List<ItemShelvings>>) {
|
||||||
response.body()?.let { list ->
|
response.body()?.let { list ->
|
||||||
_uiState.update { it.copy(items = list, isLoading = false) }
|
val filteredList = list.filter {
|
||||||
|
it.shelving.parking?.sector?.warehouseFk != null
|
||||||
|
}
|
||||||
|
_uiState.update {
|
||||||
|
it.copy(
|
||||||
|
items = filteredList,
|
||||||
|
isLoading = false,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class BuscarItemFragmentCompose(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSector(item: LocationItem) {
|
private fun showSector(item: LocationItem) {
|
||||||
item.sector.toast(requireContext())
|
item.sector?.toast(requireContext())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,16 +53,16 @@ fun BuscarItemScreen(
|
||||||
val locationItems = uiState.items
|
val locationItems = uiState.items
|
||||||
.filter { it.shelving.parking != null }
|
.filter { it.shelving.parking != null }
|
||||||
.map {
|
.map {
|
||||||
LocationItem(
|
LocationItem(
|
||||||
parking = it.shelving.parking!!.code,
|
parking = it.shelving.parking!!.code,
|
||||||
matricula = it.shelving.code,
|
matricula = it.shelving.code,
|
||||||
visible = it.visible.toString(),
|
visible = it.visible.toString(),
|
||||||
reserve = it.available.toString(),
|
reserve = it.available.toString(),
|
||||||
priority = it.shelving.priority.toString(),
|
priority = it.shelving.priority.toString(),
|
||||||
fecha = it.created,
|
fecha = it.created,
|
||||||
sector = it.shelving.parking.sector.description
|
sector = it.shelving.parking.sector?.description
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationScreenContent(
|
LocationScreenContent(
|
||||||
items = locationItems,
|
items = locationItems,
|
||||||
|
@ -182,7 +182,7 @@ private fun LocationScreenContent(
|
||||||
LocationRow(
|
LocationRow(
|
||||||
item = item,
|
item = item,
|
||||||
onLongClick = { selectedItem ->
|
onLongClick = { selectedItem ->
|
||||||
onLongClick(selectedItem.sector)
|
selectedItem.sector?.let { onLongClick(it) }
|
||||||
},
|
},
|
||||||
onClick = { selectedItem ->
|
onClick = { selectedItem ->
|
||||||
onClick(selectedItem.matricula)
|
onClick(selectedItem.matricula)
|
||||||
|
@ -357,7 +357,7 @@ data class LocationItem(
|
||||||
val reserve: String,
|
val reserve: String,
|
||||||
val priority: String,
|
val priority: String,
|
||||||
val fecha: String,
|
val fecha: String,
|
||||||
val sector: String
|
val sector: String? = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
// Vista previa
|
// Vista previa
|
||||||
|
|
|
@ -24,5 +24,6 @@ data class Parking(
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Sector(
|
data class Sector(
|
||||||
val description: String
|
val description: String,
|
||||||
|
val warehouseFk: Number
|
||||||
)
|
)
|
Loading…
Reference in New Issue