diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt index 4a410f6f..475f339a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt @@ -208,10 +208,10 @@ class UbicadorFragment( iconReset.drawable -> { customDialog.setTitle(getString(R.string.checkItemShelvingDescrip)) .setDescription(getString(R.string.checkItemShelving)) - .setOkButton(getString(R.string.cancel)) { - customDialog.dismiss() + .setOkButton(getString(R.string.ok)) { + // viewModel.itemShelvingDelete() } - .setKoButton(getString(R.string.ok)) { + .setKoButton(getString(R.string.cancel)) { customDialog.dismiss() } @@ -312,26 +312,32 @@ class UbicadorFragment( } binding.parkingImg.setOnClickListener { - customDialogInput.setTitle(getString(R.string.parkingShelving)).setValue("") - .setOkButton( - getString( - R.string.parking - ) - ) { - viewModel.shelvingPark( - shelvingFk, - customDialogInput.getValue() - ) - parking = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - customDialogInput.dismiss() - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - }.show() + if (!shelvingFk.isNullOrBlank()) { + customDialogInput.setTitle(getString(R.string.parkingShelving)).setValue("") + .setOkButton( + getString( + R.string.parking + ) + ) { + viewModel.shelvingPark( + shelvingFk, + customDialogInput.getValue() + ) + parking = customDialogInput.getValue() + binding.mainToolbar.toolbarTitle.text = + shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( + R.string.label + ) + etiquetas + customDialogInput.dismiss() + }.setKoButton(getString(R.string.cancel)) { + customDialogInput.dismiss() + }.show() + } else { + getString(R.string.errorShelving).toast( + requireContext() + ) + } customDialogInput.getEditText().requestFocus() ma.hideKeyboard(customDialogInput.getEditText()) @@ -357,27 +363,39 @@ class UbicadorFragment( } binding.editImg.setOnClickListener { - customDialogInput.setTitle(getString(R.string.changeShelving)).setValue("") - .setOkButton(getString(R.string.save)) { - viewModel.shelvingChangeSalix( - shelvingFk,customDialogInput.getValue() - ) - shelvingFk = customDialogInput.getValue() - binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( - R.string.label - ) + etiquetas - // if (mpok != null) mpok!!.start() - customDialogInput.dismiss() - }.setKoButton(getString(R.string.cancel)) { - customDialogInput.dismiss() - }.show() - + if (!shelvingFk.isNullOrBlank() + ) { + customDialogInput.setTitle(getString(R.string.changeShelving)).setValue("") + .setOkButton(getString(R.string.save)) { + if (!customDialogInput.getValue().isNullOrBlank()) { + viewModel.shelvingChangeSalix( + shelvingFk, customDialogInput.getValue() + ) + shelvingFk = customDialogInput.getValue() + binding.mainToolbar.toolbarTitle.text = + shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( + R.string.label + ) + etiquetas + } else { + getString(R.string.errorShelving).toast( + requireContext() + ) + } + customDialogInput.dismiss() + }.setKoButton(getString(R.string.cancel)) { + customDialogInput.dismiss() + }.show() + } else { + getString(R.string.errorShelving).toast( + requireContext() + ) + } customDialogInput.getEditText().requestFocus() ma.hideKeyboard(customDialogInput.getEditText()) customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { + viewModel.shelvingChangeSalix( shelvingFk, customDialogInput.getValue() @@ -387,7 +405,7 @@ class UbicadorFragment( shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( R.string.label ) + etiquetas - // if (mpok != null) mpok!!.start() + customDialogInput.dismiss() return@setOnEditorActionListener true } @@ -397,27 +415,35 @@ class UbicadorFragment( } binding.deleteImg.setOnClickListener { - customDialog.setTitle(getString(R.string.empty)) - .setDescription(getString(R.string.operationNoReturn)) - .setOkButton(getString(R.string.empty)) { - viewModel.clearShelvingList( - shelvingFk - ) - listItems.forEach { - it.stickers = "0" - it.visible = "0" + if (!shelvingFk.isNullOrBlank()) { + customDialog.setTitle(getString(R.string.empty)) + .setDescription(getString(R.string.operationNoReturn)) + .setOkButton(getString(R.string.empty)) { + + viewModel.clearShelvingList( + shelvingFk + ) + listItems.forEach { + it.stickers = "0" + it.visible = "0" + } + if (adapter != null) { + adapter!!.notifyDataSetChanged() + } + customDialog.dismiss() } - if (adapter != null) { - adapter!!.notifyDataSetChanged() - } - customDialog.dismiss() - }.setKoButton(getString(R.string.cancel)) { + + customDialog.setKoButton(getString(R.string.cancel)) { customDialog.dismiss() }.show() + } else { + getString(R.string.errorShelving).toast( + requireContext() + ) + } } - } private fun checkUbications(itemScanned: Int) { @@ -637,7 +663,7 @@ class UbicadorFragment( ma.messageWithSound(it.errorMessage, it.isError, true) } else { - checkUbications(it.response.toDouble().roundToInt()) + checkUbications(it.response.toDouble().roundToInt()) } } } @@ -686,7 +712,9 @@ class UbicadorFragment( if (customDialogInput.getValue().toInt() > 0) { binding.splashProgress.visibility = VISIBLE var quantity = - if (item.visible.toInt() - customDialogInput.getValue().toInt() > 0) { + if (item.visible.toInt() - customDialogInput.getValue() + .toInt() > 0 + ) { item.visible.toInt() - customDialogInput.getValue().toInt() } else { 0 diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index 59375428..0fd5c4c7 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -268,7 +268,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { vShelvingFk: String ) { - salix.itemShelvingsUpdate(id= """{"id":$vShelf}""", params= hashMapOf("shelvingFk" to vShelvingFk)) + salix.itemShelvingsUpdate(where = """{"id":$vShelf}""", params= hashMapOf("shelvingFk" to vShelvingFk)) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( @@ -377,7 +377,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { ) { salix.itemShelvingsUpdate( - id = JsonObject().apply { addProperty("shelvingFk", shelvingFk) }, + where = JsonObject().apply { addProperty("shelvingFk", shelvingFk) }, hashMapOf("visible" to 0) ) .enqueue(object : SalixCallback(context) { @@ -402,7 +402,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { ) { salix.itemShelvingsUpdate( - id = JsonObject().apply { addProperty("shelvingFk", shelvingFkIn) }, + where = JsonObject().apply { addProperty("shelvingFk", shelvingFkIn) }, hashMapOf("shelvingFk" to shelvingFkOut) ) .enqueue(object : SalixCallback(context) {