refs #6982 feat:pickerHelper

This commit is contained in:
Sergio De la torre 2024-04-04 12:18:33 +02:00
parent 42258687d5
commit 65c90ec860
7 changed files with 69 additions and 114 deletions

View File

@ -167,8 +167,8 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
} }
fun supplier_getItems(supplierFk: Any) { fun supplier_getItems(supplierFk: Any) {
//pendiente de borrado si la tarea no se lleva a cabo
silex.supplier_getItems(supplierFk) /* silex.supplier_getItems(supplierFk)
.enqueue(object : SilexCallback<List<ItemSupplier>>(context) { .enqueue(object : SilexCallback<List<ItemSupplier>>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
val listError: ArrayList<ItemSupplier> = ArrayList() val listError: ArrayList<ItemSupplier> = ArrayList()
@ -195,7 +195,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
} }
} }
}) })*/
} }
fun entry_addSalix(entry: EntrySalix) { fun entry_addSalix(entry: EntrySalix) {

View File

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.databinding.FragmentGeneralBlackBinding
import es.verdnatura.domain.ConstAndValues import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnBarcodeRowClickListener
@ -95,28 +96,16 @@ class PickerHelperFragment(
} }
private fun setToolBar() { private fun setToolBar() {
val listIcons: ArrayList<ImageView> = ArrayList()
val iconAdd = ImageView(context)
iconAdd.setImageResource(R.drawable.ic_add_black_24dp)
val iconReload = ImageView(context)
iconReload.setImageResource(R.drawable.ic_autorenew_black_24dp)
val iconReset = ImageView(context) val iconReset = ImageView(context)
iconReset.setImageResource(R.drawable.ic_remove_checks) iconReset.setImageResource(R.drawable.ic_delete_black_24dp)
val iconFilter = ImageView(context)
iconFilter.setImageResource(R.drawable.ic_filter_inventory)
val iconParkingFrom = ImageView(context) val iconParkingFrom = ImageView(context)
iconParkingFrom.setImageResource(R.drawable.ic_eye_inventory) iconParkingFrom.setImageResource(R.drawable.ic_mode_edit_black_24dp)
iconParkingFrom.tooltipText = getTooltip(R.drawable.ic_eye_inventory)
iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconAdd.tooltipText = getString(R.string.addItemShelving)
iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks)
iconFilter.tooltipText = getTooltip(R.drawable.ic_filter_inventory)
iconParkingFrom.tooltipText = getString(R.string.editParking)
iconReset.tooltipText = getString(R.string.resetParking)
listIcons.add(iconReset) listIcons.add(iconReset)
listIcons.add(iconParkingFrom) listIcons.add(iconParkingFrom)
@ -129,7 +118,7 @@ class PickerHelperFragment(
iconReset.drawable -> { iconReset.drawable -> {
showResetShelving() resetParkings()
} }
@ -146,7 +135,7 @@ class PickerHelperFragment(
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
} }
private fun showResetShelving() { private fun resetParkings() {
binding.mainToolbar.toolbarTitle.text = title binding.mainToolbar.toolbarTitle.text = title
runBlocking { runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey( mobileApplication.dataStoreApp.editDataStoreKey(
@ -172,9 +161,8 @@ class PickerHelperFragment(
) )
customDialogList.setDescription( customDialogList.setDescription(
"Indica los parkings por los que voy a estar sacando" "Escanea parkings de los pasillos"
) ).setKoButton(getString(R.string.cancel)) {
.setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogList.getEditText()) ma.hideKeyboard(customDialogList.getEditText())
listParkings = ArrayList() listParkings = ArrayList()
customDialogList.dismiss() customDialogList.dismiss()
@ -198,8 +186,7 @@ class PickerHelperFragment(
1 -> { 1 -> {
listParkings.add( listParkings.add(
0, 0, BarcodeVO(code = customDialogList.getValue())
BarcodeVO(code = customDialogList.getValue())
) )
viewModel.getPickingOrder(customDialogList.getValue()) viewModel.getPickingOrder(customDialogList.getValue())
@ -227,8 +214,7 @@ class PickerHelperFragment(
} }
listWagonsAdapter = BarcodeAdapter( listWagonsAdapter = BarcodeAdapter(
listParkings, listParkings, object : OnBarcodeRowClickListener {
object : OnBarcodeRowClickListener {
override fun onBarcodeRowClickListener(item: BarcodeVO) { override fun onBarcodeRowClickListener(item: BarcodeVO) {
} }
@ -277,9 +263,7 @@ class PickerHelperFragment(
private fun navigateToCollectionList(collectionFk: Int) { private fun navigateToCollectionList(collectionFk: Int) {
onCollectionSelectedListener!!.onCollectionSelected( onCollectionSelectedListener!!.onCollectionSelected(
CollectionTicket(collectionFk = collectionFk), CollectionTicket(collectionFk = collectionFk), ConstAndValues.PREPARED, true
ConstAndValues.PREPARED,
true
) )
} }
@ -288,54 +272,53 @@ class PickerHelperFragment(
with(viewModel) { with(viewModel) {
response.observe(viewLifecycleOwner) { loadPickingOrder.observe(viewLifecycleOwner) { event ->
if (!it.isError && it.response.isNotBlank()) { event.getContentIfNotHandled().notNull {
runBlocking { if (!it.isError && it.response.isNotBlank()) {
when (listParkings.size) {
1 -> {
mobileApplication.dataStoreApp.editDataStoreKey(
"PARKING_FROM",
listParkings.first().code.toString()
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PICKING_FROM",
it.response.toInt()
)
}
2 -> { runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey( when (listParkings.size) {
"PARKING_TO", 1 -> {
listParkings.first().code.toString() mobileApplication.dataStoreApp.editDataStoreKey(
) "PARKING_FROM", listParkings.first().code.toString()
mobileApplication.dataStoreApp.editDataStoreKey( )
"PICKING_TO", mobileApplication.dataStoreApp.editDataStoreKey(
it.response.toInt() "PICKING_FROM", it.response.toInt()
) )
binding.mainToolbar.toolbarTitle.text = }
getString(R.string.parkingForPicking, listParkings[1].code,listParkings[0].code)
listParkings.clear()
customDialogList.dismiss()
} 2 -> {
mobileApplication.dataStoreApp.editDataStoreKey(
"PARKING_TO", listParkings.first().code.toString()
)
mobileApplication.dataStoreApp.editDataStoreKey(
"PICKING_TO", it.response.toInt()
)
binding.mainToolbar.toolbarTitle.text = getString(
R.string.parkingForPicking,
listParkings[1].code,
listParkings[0].code
)
listParkings.clear()
customDialogList.dismiss()
else -> { }
//listParkings.clear()
// customDialogList.dismiss() else -> {
// showSettingsHelper() //listParkings.clear()
ma.messageWithSound( // customDialogList.dismiss()
"Parking no encontrado", // showSettingsHelper()
isError = true, ma.messageWithSound(
isPlayed = true "Parking no encontrado", isError = true, isPlayed = true
) )
}
} }
} }
}
}
} }
} }
} }
} }
} }

View File

@ -38,6 +38,10 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
val response: LiveData<ResponseItemVO> val response: LiveData<ResponseItemVO>
get() = _response get() = _response
private val _responsePickingOrder by lazy { MutableLiveData<ResponseItemVO>() }
val responsePickingOrder: LiveData<ResponseItemVO>
get() = _responsePickingOrder
private val _responseCollectionSmart by lazy { MutableLiveData<ResponseItemVO>() } private val _responseCollectionSmart by lazy { MutableLiveData<ResponseItemVO>() }
val responseCollectionSmart: LiveData<ResponseItemVO> val responseCollectionSmart: LiveData<ResponseItemVO>
get() = _responseCollectionSmart get() = _responseCollectionSmart
@ -50,48 +54,8 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
val loadShelvingLogSalixList: LiveData<Event<ShelvingLogSalixList>> = val loadShelvingLogSalixList: LiveData<Event<ShelvingLogSalixList>> =
_itemShelvingLogSalixList.map { Event(it) } _itemShelvingLogSalixList.map { Event(it) }
/* fun collectionTicketGet( val loadPickingOrder: LiveData<Event<ResponseItemVO>> = _responsePickingOrder.map { Event(it) }
collectionFk: Int,
sectorFk: String,
print: String,
type: String
) {
//Tarea 6276, falta modificar
silex.collection_getTickets(
collectionFk,
sectorFk,
print,
type
).enqueue(object :
SilexCallback<CollectionVO>(context) {
override fun onError(t: Throwable) {
_collectionTicketList.value = CollectionVO(
0,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onResponse(
call: Call<CollectionVO>,
response: Response<CollectionVO>
) {
if (response.body() != null) {
_collectionTicketList.value = response.body()?.let { it.map(context) }
} else {
_collectionTicketList.value = CollectionVO(
0,
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
)
)
}
}
})
}*/
fun sectorCollectionNew( fun sectorCollectionNew(
sectorFk: Int sectorFk: Int
@ -331,13 +295,13 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
.enqueue(object : .enqueue(object :
SalixCallback<List<JsonObject>>(context) { SalixCallback<List<JsonObject>>(context) {
override fun onSuccess(response: Response<List<JsonObject>>) { override fun onSuccess(response: Response<List<JsonObject>>) {
_response.value = ResponseItemVO( _responsePickingOrder.value = ResponseItemVO(
response = response.body()?.get(0)!!.entrySet().first().value.toString() response = response.body()?.get(0)!!.entrySet().first().value.toString()
) )
} }
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO(response = "", isError = true) _responsePickingOrder.value = ResponseItemVO(response = "", isError = true)
} }
}) })

View File

@ -755,6 +755,8 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string> <string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string> <string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string> <string name="scanCollection">Escanea colección</string>
<string name="editParking">Permite modificar los parkings seleccionados</string>
<string name="resetParking">Resetea los parkings seleccionados</string>
</resources> </resources>

View File

@ -755,5 +755,7 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string> <string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string> <string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string> <string name="scanCollection">Escanea colección</string>
<string name="editParking">Permite modificar los parkings seleccionados</string>
<string name="resetParking">Resetea los parkings seleccionados</string>
</resources> </resources>

View File

@ -755,5 +755,7 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string> <string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string> <string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string> <string name="scanCollection">Escanea colección</string>
<string name="editParking">Permite modificar los parkings seleccionados</string>
<string name="resetParking">Resetea los parkings seleccionados</string>
</resources> </resources>

View File

@ -755,5 +755,7 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string> <string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</string> <string name="parkingForPicking">P:%1$s→%2$s</string>
<string name="scanCollection">Escanea colección</string> <string name="scanCollection">Escanea colección</string>
<string name="editParking">Permite modificar los parkings seleccionados</string>
<string name="resetParking">Resetea los parkings seleccionados</string>
</resources> </resources>