feat: refs #6845 userIterface
This commit is contained in:
parent
969660ae77
commit
a1c01d1154
|
@ -121,7 +121,8 @@ class AjustesFragment :
|
||||||
|
|
||||||
binding.searchableRecyclerView.setAdapter(adapter, listNames)
|
binding.searchableRecyclerView.setAdapter(adapter, listNames)
|
||||||
binding.searchableRecyclerView.visibility = View.VISIBLE
|
binding.searchableRecyclerView.visibility = View.VISIBLE
|
||||||
binding.searchableRecyclerView.setSearchHintWithoutFocus(getString(R.string.sectorSearch))
|
binding.searchableRecyclerView.setSearchHint(getString(R.string.sectorSearch))
|
||||||
|
ma.hideKeyboard(binding.searchableRecyclerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setToolBar() {
|
private fun setToolBar() {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import es.verdnatura.R
|
||||||
import es.verdnatura.databinding.FragmentInventaryBinding
|
import es.verdnatura.databinding.FragmentInventaryBinding
|
||||||
import es.verdnatura.domain.ConstAndValues.BUYER
|
import es.verdnatura.domain.ConstAndValues.BUYER
|
||||||
import es.verdnatura.domain.ConstAndValues.BUYERID
|
import es.verdnatura.domain.ConstAndValues.BUYERID
|
||||||
|
import es.verdnatura.domain.ConstAndValues.ITEMPACKINGTYPEFILTER
|
||||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||||
import es.verdnatura.domain.toast
|
import es.verdnatura.domain.toast
|
||||||
import es.verdnatura.presentation.base.BaseFragment
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
@ -22,6 +23,7 @@ import es.verdnatura.presentation.view.commom.NameWithId
|
||||||
import es.verdnatura.presentation.view.commom.SearchableAdapter
|
import es.verdnatura.presentation.view.commom.SearchableAdapter
|
||||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||||
import es.verdnatura.presentation.view.component.CustomDialogTwoButtons
|
import es.verdnatura.presentation.view.component.CustomDialogTwoButtons
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.Buyer
|
||||||
import es.verdnatura.presentation.view.feature.inventario.adapter.InventoryAdapter
|
import es.verdnatura.presentation.view.feature.inventario.adapter.InventoryAdapter
|
||||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
@ -41,6 +43,8 @@ class InventaryFragment :
|
||||||
private var firstVisiblePosition = 0
|
private var firstVisiblePosition = 0
|
||||||
private lateinit var itemClicked: ItemInventaryVO
|
private lateinit var itemClicked: ItemInventaryVO
|
||||||
private var buyerId: Number = -1
|
private var buyerId: Number = -1
|
||||||
|
private var filterItemType: String? = null
|
||||||
|
private var myListBuyers = listOf<Buyer>()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = InventaryFragment()
|
fun newInstance() = InventaryFragment()
|
||||||
|
@ -55,8 +59,12 @@ class InventaryFragment :
|
||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
|
|
||||||
viewModel.itemShelvingBuyerGet()
|
// viewModel.itemShelvingBuyerGet()
|
||||||
|
viewModel.itemShelvingBuyerGetByItemPacking()
|
||||||
binding.filterBuyer.text = mobileApplication.dataStoreApp.readDataStoreKey<String>((BUYER))
|
binding.filterBuyer.text = mobileApplication.dataStoreApp.readDataStoreKey<String>((BUYER))
|
||||||
|
filterItemType =
|
||||||
|
mobileApplication.dataStoreApp.readDataStoreKey<String>((ITEMPACKINGTYPEFILTER))
|
||||||
|
binding.filterItemType.setText(filterItemType!!.firstOrNull()?.toString() ?: "").toString()
|
||||||
buyerId = mobileApplication.dataStoreApp.readDataStoreKey<Int>((BUYERID))
|
buyerId = mobileApplication.dataStoreApp.readDataStoreKey<Int>((BUYERID))
|
||||||
if (buyerId != -1) {
|
if (buyerId != -1) {
|
||||||
viewModel.getInventory(
|
viewModel.getInventory(
|
||||||
|
@ -64,8 +72,26 @@ class InventaryFragment :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
binding.filterBuyer.setOnClickListener {
|
binding.filterBuyer.setOnClickListener {
|
||||||
|
val distinctPackingTypes = myListBuyers
|
||||||
|
|
||||||
|
.filter { filterItemType == getString(R.string.allText) || filterItemType == "" || it.itemPackingTypeFk == filterItemType }
|
||||||
|
.map {
|
||||||
|
NameWithId(
|
||||||
|
it.worker.user.id, it.worker.user.nickname
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.distinct()
|
||||||
|
.sortedBy { it.name }
|
||||||
|
setSearchable(distinctPackingTypes as MutableList<NameWithId>)
|
||||||
binding.searchableRecyclerView.visibility = View.VISIBLE
|
binding.searchableRecyclerView.visibility = View.VISIBLE
|
||||||
binding.searchableRecyclerView.setSearchHint(getString(R.string.BuyerSearch))
|
binding.searchableRecyclerView.setSearchHint(getString(R.string.BuyerSearch))
|
||||||
|
ma.hideKeyboard(binding.searchableRecyclerView)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.filterItemType.setOnClickListener {
|
||||||
|
|
||||||
|
binding.searchableRecyclerViewItemType.visibility = View.VISIBLE
|
||||||
|
binding.searchableRecyclerViewItemType.setSearchHint(getString(R.string.selectItemType))
|
||||||
}
|
}
|
||||||
|
|
||||||
customDialogInput = CustomDialogInput(requireContext())
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
|
@ -106,6 +132,29 @@ class InventaryFragment :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setSearchableItemPacking(listNames: MutableList<NameWithId>) {
|
||||||
|
val adapter =
|
||||||
|
SearchableAdapter(
|
||||||
|
listElements = listNames,
|
||||||
|
context = requireContext()
|
||||||
|
) { elementSelected ->
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||||
|
ITEMPACKINGTYPEFILTER, elementSelected.name
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
binding.filterItemType.text = elementSelected.name.firstOrNull()?.toString() ?: ""
|
||||||
|
filterItemType = elementSelected.name
|
||||||
|
binding.searchableRecyclerViewItemType.visibility = View.GONE
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.searchableRecyclerViewItemType.setAdapter(adapter, listNames)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private fun setToolBar() {
|
private fun setToolBar() {
|
||||||
ma.hideBottomNavigation(View.GONE)
|
ma.hideBottomNavigation(View.GONE)
|
||||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||||
|
@ -184,6 +233,21 @@ class InventaryFragment :
|
||||||
|
|
||||||
override fun observeViewModel() {
|
override fun observeViewModel() {
|
||||||
with(viewModel) {
|
with(viewModel) {
|
||||||
|
|
||||||
|
buyersByItemPackingList.observe(viewLifecycleOwner) { list ->
|
||||||
|
myListBuyers = list.list
|
||||||
|
val distinctPackingTypes =
|
||||||
|
list?.list?.map {
|
||||||
|
NameWithId(
|
||||||
|
1, it.itemPackingTypeFk ?: getString(R.string.allText)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
?.distinct()
|
||||||
|
?: emptyList()
|
||||||
|
|
||||||
|
setSearchableItemPacking(distinctPackingTypes as MutableList<NameWithId>)
|
||||||
|
}
|
||||||
|
|
||||||
buyersList.observe(viewLifecycleOwner) { item ->
|
buyersList.observe(viewLifecycleOwner) { item ->
|
||||||
setSearchable(item.list.map {
|
setSearchable(item.list.map {
|
||||||
NameWithId(
|
NameWithId(
|
||||||
|
@ -193,6 +257,7 @@ class InventaryFragment :
|
||||||
} as MutableList<NameWithId>)
|
} as MutableList<NameWithId>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inventaryList.observe(viewLifecycleOwner) { it ->
|
inventaryList.observe(viewLifecycleOwner) { it ->
|
||||||
listInventory = ArrayList()
|
listInventory = ArrayList()
|
||||||
listInventoryAux = ArrayList()
|
listInventoryAux = ArrayList()
|
||||||
|
@ -202,6 +267,8 @@ class InventaryFragment :
|
||||||
listInventoryAux.add(it)
|
listInventoryAux.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
adapter = InventoryAdapter(listInventory, object : OnInvetoryNichoClickListener {
|
adapter = InventoryAdapter(listInventory, object : OnInvetoryNichoClickListener {
|
||||||
override fun onInvetoryNichoClickListener(item: ItemInventaryVO) {
|
override fun onInvetoryNichoClickListener(item: ItemInventaryVO) {
|
||||||
customDialog.setTitle(item.itemFk.toString() + "\n" + item.longName)
|
customDialog.setTitle(item.itemFk.toString() + "\n" + item.longName)
|
||||||
|
|
|
@ -11,6 +11,8 @@ import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||||
import es.verdnatura.presentation.base.BaseViewModel
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
import es.verdnatura.presentation.common.Event
|
import es.verdnatura.presentation.common.Event
|
||||||
import es.verdnatura.presentation.common.ItemDiscardSalixShortage
|
import es.verdnatura.presentation.common.ItemDiscardSalixShortage
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.Buyer
|
||||||
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerList
|
||||||
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
|
||||||
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
|
||||||
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
|
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
|
||||||
|
@ -46,6 +48,10 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
val buyersList: LiveData<BuyerListVO>
|
val buyersList: LiveData<BuyerListVO>
|
||||||
get() = _buyersList
|
get() = _buyersList
|
||||||
|
|
||||||
|
private val _buyersByItemPackingList by lazy { MutableLiveData<BuyerList>() }
|
||||||
|
val buyersByItemPackingList: LiveData<BuyerList>
|
||||||
|
get() = _buyersByItemPackingList
|
||||||
|
|
||||||
private val _mistakeDepartmentList by lazy { MutableLiveData<DepartmentMistakeList>() }
|
private val _mistakeDepartmentList by lazy { MutableLiveData<DepartmentMistakeList>() }
|
||||||
val mistakeDepartmentList: LiveData<DepartmentMistakeList>
|
val mistakeDepartmentList: LiveData<DepartmentMistakeList>
|
||||||
get() = _mistakeDepartmentList
|
get() = _mistakeDepartmentList
|
||||||
|
@ -80,6 +86,20 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun itemShelvingBuyerGetByItemPacking() {
|
||||||
|
salix.getBuyersByItemPackingType(
|
||||||
|
"""{"fields":["itemPackingTypeFk","id","workerFk"],
|
||||||
|
|"include":{"relation":"worker","scope":{"fields":["id"],
|
||||||
|
|"include":{"relation":"user","scope":{"fields":["nickname"]}}}}}""".trimMargin()
|
||||||
|
)
|
||||||
|
.enqueue(object : SalixCallback<List<Buyer>>(context) {
|
||||||
|
override fun onSuccess(response: Response<List<Buyer>>) {
|
||||||
|
_buyersByItemPackingList.value = response.body()?.let { BuyerList(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
val loadInventaryList: LiveData<Event<InventaryListVO>> = _inventaryList.map { Event(it) }
|
val loadInventaryList: LiveData<Event<InventaryListVO>> = _inventaryList.map { Event(it) }
|
||||||
|
|
||||||
fun getInventory(buyerFk: Number, warehouseFk: Int) {
|
fun getInventory(buyerFk: Number, warehouseFk: Int) {
|
||||||
|
|
Loading…
Reference in New Issue