feat barCode in ItemShelvingLog refs #7739
This commit is contained in:
parent
52c9cbf859
commit
31739faa0a
|
@ -48,10 +48,10 @@ class ItemShelvingLogAdapter(
|
|||
binding.apply {
|
||||
|
||||
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 {
|
||||
if (item.worker.id != null) openWorker(binding, item.worker.id!!)
|
||||
if (item.worker?.id != null) openWorker(binding, item.worker?.id!!)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentItemshelvinglogBinding
|
||||
import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG
|
||||
import es.verdnatura.domain.toLong
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
|
@ -21,7 +22,7 @@ class ItemShelvingLogFragment(
|
|||
private var itemScan = ""
|
||||
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||
private var records: Int = LIMITRECORDSSHELVINGLOG
|
||||
private var shelving:String = ""
|
||||
private var shelving: String = ""
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint)
|
||||
|
@ -53,21 +54,30 @@ class ItemShelvingLogFragment(
|
|||
binding.scanInput.requestFocus()
|
||||
binding.loadMoreButton.setOnClickListener {
|
||||
records += LIMITRECORDSSHELVINGLOG
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
records
|
||||
)
|
||||
try {
|
||||
viewModel.getIdFromCodeSalix(shelving.toLong().toString())
|
||||
} catch (ex: Exception) {
|
||||
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
records
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (binding.scanInput.text.toString().isNotEmpty()) {
|
||||
//Tarea 7168
|
||||
records = LIMITRECORDSSHELVINGLOG
|
||||
shelving = binding.scanInput.text.toString()
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
records
|
||||
)
|
||||
records = LIMITRECORDSSHELVINGLOG
|
||||
try {
|
||||
viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString())
|
||||
} catch (ex: Exception) {
|
||||
viewModel.itemShelvingLogGet(
|
||||
shelving,
|
||||
records
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
ma.hideKeyboard(binding.scanInput)
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.lifecycle.LiveData
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import es.verdnatura.domain.ConstAndValues.LIMITRECORDSSHELVINGLOG
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLog
|
||||
import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelvingLogList
|
||||
|
@ -12,9 +13,13 @@ import retrofit2.Response
|
|||
|
||||
class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val getItemFromBarcodeUseCase = GetItemFromBarcodeUseCase(salix)
|
||||
|
||||
private val _itemShelvingLogList by lazy { MutableLiveData<ItemShelvingLogList>() }
|
||||
val itemShelvingLogList: LiveData<ItemShelvingLogList>
|
||||
get() = _itemShelvingLogList
|
||||
val itemShelvingLogList: LiveData<ItemShelvingLogList> = _itemShelvingLogList
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<Int?>() }
|
||||
val responseCode: LiveData<Int?> = _responseCode
|
||||
|
||||
fun itemShelvingLogGet(shelvingOrItem: String, records: Int = LIMITRECORDSSHELVINGLOG) {
|
||||
//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())
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ data class ItemShelvingLog(
|
|||
var visible: Int? = null,
|
||||
var accion: String? = null,
|
||||
var code: String? = null,
|
||||
var worker: Worker,
|
||||
var worker: Worker? = null,
|
||||
var item:ItemSalix? = null
|
||||
) {
|
||||
var created: String = ""
|
||||
|
|
Loading…
Reference in New Issue