feat issues refs #7636

This commit is contained in:
Sergio De la torre 2024-07-03 07:31:18 +02:00
parent 6f0310cb14
commit a7c66ff0b2
1 changed files with 28 additions and 24 deletions

View File

@ -62,8 +62,7 @@ class InventaryFragment :
buyerId = mobileApplication.dataStoreApp.readDataStoreKey((BUYERID)) buyerId = mobileApplication.dataStoreApp.readDataStoreKey((BUYERID))
if (buyerId.isNotBlank()) { if (buyerId.isNotBlank()) {
viewModel.getInventory( viewModel.getInventory(
buyerId.toInt(), buyerId.toInt(), mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
) )
} }
binding.filterBuyer.setOnClickListener { binding.filterBuyer.setOnClickListener {
@ -80,12 +79,10 @@ class InventaryFragment :
lifecycleScope.launch { lifecycleScope.launch {
mobileApplication.dataStoreApp.editDataStoreKey( mobileApplication.dataStoreApp.editDataStoreKey(
BUYER, BUYER, nombre.getBuyerNickname()
nombre.getBuyerNickname()
) )
mobileApplication.dataStoreApp.editDataStoreKey( mobileApplication.dataStoreApp.editDataStoreKey(
BUYERID, BUYERID, nombre.getBuyerId()
nombre.getBuyerId()
) )
} }
viewModel.getInventory( viewModel.getInventory(
@ -157,17 +154,7 @@ class InventaryFragment :
} else { } else {
listInventory.removeAll(listInventoryAux.toSet()) setFilterItem()
listInventory.addAll(listInventoryAux.filter {
it.itemFk!!.toString().contains(
binding.filterItemFk.text.toString(), true
) || it.producer?.contains(
binding.filterItemFk.text.toString(), true
) == true || it.longName?.contains(
binding.filterItemFk.text.toString(), ignoreCase = true
) == true
})
} }
adapter!!.notifyDataSetChanged() adapter!!.notifyDataSetChanged()
@ -241,8 +228,11 @@ class InventaryFragment :
firstVisiblePosition firstVisiblePosition
) )
} }
if (binding.filterItemFk.text!!.isNotEmpty()) {
setFilterItem()
} }
}
response.observe(viewLifecycleOwner) { response.observe(viewLifecycleOwner) {
changeOfflineValue(itemClicked) changeOfflineValue(itemClicked)
@ -250,6 +240,20 @@ class InventaryFragment :
} }
} }
private fun setFilterItem() {
listInventory.removeAll(listInventoryAux.toSet())
listInventory.addAll(listInventoryAux.filter {
it.itemFk!!.toString().contains(
binding.filterItemFk.text.toString(), true
) || it.producer?.contains(
binding.filterItemFk.text.toString(), true
) == true || it.longName?.contains(
binding.filterItemFk.text.toString(), ignoreCase = true
) == true
})
}
private fun changeOfflineValue(item: ItemInventaryVO) { private fun changeOfflineValue(item: ItemInventaryVO) {
try { try {
listInventory.removeAt(listInventory.indexOf(item)) listInventory.removeAt(listInventory.indexOf(item))