feat barCode in ItemShelvingLog refs #7739

This commit is contained in:
Sergio De la torre 2024-07-19 16:23:23 +02:00
parent 52c9cbf859
commit 31739faa0a
4 changed files with 41 additions and 15 deletions

View File

@ -48,10 +48,10 @@ class ItemShelvingLogAdapter(
binding.apply { binding.apply {
binding.txtNickname.setOnClickListener { binding.txtNickname.setOnClickListener {
if (item.worker.id != null) openWorker(binding, item.worker.id!!) if (item.worker?.id != null) openWorker(binding, item.worker?.id!!)
} }
binding.txtVisible.setOnClickListener { binding.txtVisible.setOnClickListener {
if (item.worker.id != null) openWorker(binding, item.worker.id!!) if (item.worker?.id != null) openWorker(binding, item.worker?.id!!)
} }

View File

@ -7,6 +7,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentItemshelvinglogBinding import es.verdnatura.databinding.FragmentItemshelvinglogBinding
import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG
import es.verdnatura.domain.toLong
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
@ -21,7 +22,7 @@ class ItemShelvingLogFragment(
private var itemScan = "" private var itemScan = ""
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var records: Int = LIMITRECORDSSHELVINGLOG private var records: Int = LIMITRECORDSSHELVINGLOG
private var shelving:String = "" private var shelving: String = ""
companion object { companion object {
fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint) fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint)
@ -53,21 +54,30 @@ class ItemShelvingLogFragment(
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
binding.loadMoreButton.setOnClickListener { binding.loadMoreButton.setOnClickListener {
records += LIMITRECORDSSHELVINGLOG records += LIMITRECORDSSHELVINGLOG
viewModel.itemShelvingLogGet( try {
shelving, viewModel.getIdFromCodeSalix(shelving.toLong().toString())
records } catch (ex: Exception) {
)
viewModel.itemShelvingLogGet(
shelving,
records
)
}
} }
binding.scanInput.setOnEditorActionListener { v, actionId, event -> binding.scanInput.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (binding.scanInput.text.toString().isNotEmpty()) { if (binding.scanInput.text.toString().isNotEmpty()) {
//Tarea 7168 //Tarea 7168
records = LIMITRECORDSSHELVINGLOG
shelving = binding.scanInput.text.toString() shelving = binding.scanInput.text.toString()
viewModel.itemShelvingLogGet( records = LIMITRECORDSSHELVINGLOG
shelving, try {
records viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString())
) } catch (ex: Exception) {
viewModel.itemShelvingLogGet(
shelving,
records
)
}
} }
binding.scanInput.setText("") binding.scanInput.setText("")
ma.hideKeyboard(binding.scanInput) ma.hideKeyboard(binding.scanInput)

View File

@ -5,6 +5,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG
import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SalixCallback
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLogList import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLogList
@ -12,9 +13,13 @@ import retrofit2.Response
class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) { class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
private val _itemShelvingLogList by lazy { MutableLiveData<ItemShelvingLogList>() } private val _itemShelvingLogList by lazy { MutableLiveData<ItemShelvingLogList>() }
val itemShelvingLogList: LiveData<ItemShelvingLogList> val itemShelvingLogList: LiveData<ItemShelvingLogList> = _itemShelvingLogList
get() = _itemShelvingLogList
private val _responseCode by lazy { MutableLiveData<Int?>() }
val responseCode: LiveData<Int?> = _responseCode
fun itemShelvingLogGet(shelvingOrItem: String, records: Int = LIMITRECORDSSHELVINGLOG) { fun itemShelvingLogGet(shelvingOrItem: String, records: Int = LIMITRECORDSSHELVINGLOG) {
//tarea 7168 //tarea 7168
@ -37,6 +42,17 @@ class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun getIdFromCodeSalix(code: String) {
getItemFromBarcodeUseCase.execute (code)
.enqueue(object : SalixCallback<Int?>(context) {
override fun onSuccess(response: Response<Int?>) {
itemShelvingLogGet(response.body()!!.toString())
}
})
}
} }

View File

@ -10,7 +10,7 @@ data class ItemShelvingLog(
var visible: Int? = null, var visible: Int? = null,
var accion: String? = null, var accion: String? = null,
var code: String? = null, var code: String? = null,
var worker: Worker, var worker: Worker? = null,
var item:ItemSalix? = null var item:ItemSalix? = null
) { ) {
var created: String = "" var created: String = ""