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

View File

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

View File

@ -38,6 +38,10 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
val response: LiveData<ResponseItemVO>
get() = _response
private val _responsePickingOrder by lazy { MutableLiveData<ResponseItemVO>() }
val responsePickingOrder: LiveData<ResponseItemVO>
get() = _responsePickingOrder
private val _responseCollectionSmart by lazy { MutableLiveData<ResponseItemVO>() }
val responseCollectionSmart: LiveData<ResponseItemVO>
get() = _responseCollectionSmart
@ -50,48 +54,8 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
val loadShelvingLogSalixList: LiveData<Event<ShelvingLogSalixList>> =
_itemShelvingLogSalixList.map { Event(it) }
/* fun collectionTicketGet(
collectionFk: Int,
sectorFk: String,
print: String,
type: String
) {
val loadPickingOrder: LiveData<Event<ResponseItemVO>> = _responsePickingOrder.map { Event(it) }
//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(
sectorFk: Int
@ -331,13 +295,13 @@ class SacadorViewModel(val context: Context) : BaseViewModel(context) {
.enqueue(object :
SalixCallback<List<JsonObject>>(context) {
override fun onSuccess(response: Response<List<JsonObject>>) {
_response.value = ResponseItemVO(
_responsePickingOrder.value = ResponseItemVO(
response = response.body()?.get(0)!!.entrySet().first().value.toString()
)
}
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="parkingForPicking">P:%1$s→%2$s</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>

View File

@ -755,5 +755,7 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</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>

View File

@ -755,5 +755,7 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</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>

View File

@ -755,5 +755,7 @@
<string name="pickerHelperDescrip">Permite sacar parte de la colección</string>
<string name="parkingForPicking">P:%1$s→%2$s</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>