refs #5713 feat:add reset button

This commit is contained in:
Sergio De la torre 2023-11-09 15:50:55 +01:00
parent c9d7978519
commit 0c0c6f540f
2 changed files with 208 additions and 162 deletions

View File

@ -131,34 +131,35 @@ class UbicadorFragment(
binding.mainToolbar.switchButton.isChecked = false binding.mainToolbar.switchButton.isChecked = false
} else { } else {
modeCheckUbication = isChecked modeCheckUbication = isChecked
binding.mainToolbar.toolbarIcons.adapter!!.notifyDataSetChanged()
binding.mainToolbar.switchButton.tooltipText = if (isChecked) binding.mainToolbar.switchButton.tooltipText = if (isChecked)
getString(R.string.activateModoChecking) else getString(R.string.activateModoChecking) else
getString(R.string.allowCheckingMode) getString(R.string.allowCheckingMode)
binding.textinputlayoutMatricula.hint = binding.textinputlayoutMatricula.hint =
if (isChecked) getString(R.string.scanItem) else { if (isChecked) getString(R.string.scanItem) else {
getString(R.string.scanPlate) getString(R.string.scanPlate)
} }
if (!isChecked) { if (!isChecked) {
listLocalItems.clear() listLocalItems.clear()
listIcons.remove(iconReset)
}else{
listIcons.add(iconReset)
} }
binding.mainToolbar.toolbarIcons.adapter!!.notifyDataSetChanged()
} }
} }
val iconChecker = ImageView(context)
iconChecker.setImageResource(R.drawable.ic_ubicator_check)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp) iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconAdd.tooltipText = getString(R.string.addItemShelving) iconAdd.tooltipText = getString(R.string.addItemShelving)
iconChecker.tooltipText = getTooltip(R.drawable.ic_ubicator_check) iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks)
} }
listIcons.add(iconAdd) listIcons.add(iconAdd)
listIcons.add(iconReload) listIcons.add(iconReload)
//listIcons.add(iconChecker)
//tarea 5713
//listIcons.add(iconReset)
binding.mainToolbar.toolbarIcons.adapter = binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
@ -191,34 +192,31 @@ class UbicadorFragment(
} }
} }
iconChecker.drawable -> {
if (!shelvingFk.isNullOrEmpty()) { iconReset.drawable -> {
ma.onPasillerosItemClickListener( if (!shelvingFk.isNullOrBlank()) {
PasillerosItemVO(title = getString(R.string.titleChecker)), customDialog.setTitle(getString(R.string.checkItemShelvingDescrip))
entryPoint = shelvingFk .setDescription(getString(R.string.checkItemShelving))
) .setOkButton(getString(R.string.ok)) {
binding.splashProgress.visibility = View.VISIBLE
viewModel.itemShelving_deleteChecked(shelvingFk)
customDialog.dismiss()
}
.setKoButton(getString(R.string.cancel)) {
customDialog.dismiss()
}
.show()
} else { } else {
getString(R.string.scanShelving).toast( ma.messageWithSound(
requireActivity(), getString(R.string.scanPlate),
Toast.LENGTH_SHORT isError = true,
isPlayed = true,
isToasted = true
) )
} }
} }
iconReset.drawable -> {
customDialog.setTitle(getString(R.string.checkItemShelvingDescrip))
.setDescription(getString(R.string.checkItemShelving))
.setOkButton(getString(R.string.ok)) {
// viewModel.itemShelvingDelete()
}
.setKoButton(getString(R.string.cancel)) {
customDialog.dismiss()
}
.show()
}
} }
} }
}) })
@ -308,12 +306,16 @@ class UbicadorFragment(
entryPoint = shelvingFk entryPoint = shelvingFk
) )
else else
getString(R.string.scanShelving).toast(requireActivity(), Toast.LENGTH_SHORT) getString(R.string.scanShelving).toast(
requireActivity(),
Toast.LENGTH_SHORT
)
} }
binding.parkingImg.setOnClickListener { binding.parkingImg.setOnClickListener {
if (!shelvingFk.isNullOrBlank()) { if (!shelvingFk.isNullOrBlank()) {
customDialogInput.setTitle(getString(R.string.parkingShelving)).setValue("") customDialogInput.setTitle(getString(R.string.parkingShelving))
.setValue("")
.setOkButton( .setOkButton(
getString( getString(
R.string.parking R.string.parking
@ -341,31 +343,33 @@ class UbicadorFragment(
customDialogInput.getEditText().requestFocus() customDialogInput.getEditText().requestFocus()
ma.hideKeyboard(customDialogInput.getEditText()) ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogInput.getEditText()
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { .setOnEditorActionListener { v, actionId, event ->
viewModel.shelvingPark( if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
shelvingFk, viewModel.shelvingPark(
customDialogInput.getValue() shelvingFk,
) customDialogInput.getValue()
customDialogInput.dismiss() )
parking = customDialogInput.getValue() customDialogInput.dismiss()
binding.mainToolbar.toolbarTitle.text = parking = customDialogInput.getValue()
shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( binding.mainToolbar.toolbarTitle.text =
R.string.label shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(
) + etiquetas R.string.label
) + etiquetas
return@setOnEditorActionListener true return@setOnEditorActionListener true
}
false
} }
false
}
} }
binding.editImg.setOnClickListener { binding.editImg.setOnClickListener {
if (!shelvingFk.isNullOrBlank() if (!shelvingFk.isNullOrBlank()
) { ) {
customDialogInput.setTitle(getString(R.string.changeShelving)).setValue("") customDialogInput.setTitle(getString(R.string.changeShelving))
.setValue("")
.setOkButton(getString(R.string.save)) { .setOkButton(getString(R.string.save)) {
if (!customDialogInput.getValue().isNullOrBlank()) { if (!customDialogInput.getValue().isNullOrBlank()) {
viewModel.shelvingChangeSalix( viewModel.shelvingChangeSalix(
@ -393,24 +397,25 @@ class UbicadorFragment(
customDialogInput.getEditText().requestFocus() customDialogInput.getEditText().requestFocus()
ma.hideKeyboard(customDialogInput.getEditText()) ma.hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogInput.getEditText()
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { .setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.shelvingChangeSalix( viewModel.shelvingChangeSalix(
shelvingFk, shelvingFk,
customDialogInput.getValue() customDialogInput.getValue()
) )
shelvingFk = customDialogInput.getValue() shelvingFk = customDialogInput.getValue()
binding.mainToolbar.toolbarTitle.text = binding.mainToolbar.toolbarTitle.text =
shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString( shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(
R.string.label R.string.label
) + etiquetas ) + etiquetas
customDialogInput.dismiss() customDialogInput.dismiss()
return@setOnEditorActionListener true return@setOnEditorActionListener true
}
false
} }
false
}
} }
@ -475,11 +480,14 @@ class UbicadorFragment(
private fun setTooltips() { private fun setTooltips() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
binding.editImg.tooltipText = getTooltip(R.drawable.ic_mode_edit_black_24dp) binding.editImg.tooltipText = getTooltip(R.drawable.ic_mode_edit_black_24dp)
binding.deleteImg.tooltipText = getTooltip(R.drawable.ic_delete_forever_black_24dp) binding.deleteImg.tooltipText =
getTooltip(R.drawable.ic_delete_forever_black_24dp)
binding.editPrioridad.tooltipText = binding.editPrioridad.tooltipText =
getString(R.string.changePriority) getString(R.string.changePriority)
binding.parkingImg.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp) binding.parkingImg.tooltipText =
binding.automaticImg.tooltipText = getTooltip(R.drawable.ic_flash_auto_black_24dp) getTooltip(R.drawable.ic_local_parking_black_24dp)
binding.automaticImg.tooltipText =
getTooltip(R.drawable.ic_flash_auto_black_24dp)
} }
@ -546,6 +554,7 @@ class UbicadorFragment(
if (!binding.mainToolbar.switchButton.isChecked && listItems.isNotEmpty()) { if (!binding.mainToolbar.switchButton.isChecked && listItems.isNotEmpty()) {
listItems = listItems.asReversed() listItems = listItems.asReversed()
} }
adapter = UbicadorAdapter( adapter = UbicadorAdapter(
listItems.sortedBy { it.isChecked }, listItems.sortedBy { it.isChecked },
@ -594,11 +603,14 @@ class UbicadorFragment(
} }
if (modeCheckUbication) { if (modeCheckUbication) {
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item -> listItems.sortedBy { it.isChecked }
if (item.item == itemScannedScreen) { .forEachIndexed { index, item ->
binding.locationRecyclerview.scrollToPosition(index) if (item.item == itemScannedScreen) {
binding.locationRecyclerview.scrollToPosition(
index
)
}
} }
}
} else { } else {
(binding.locationRecyclerview.layoutManager as LinearLayoutManager).scrollToPosition( (binding.locationRecyclerview.layoutManager as LinearLayoutManager).scrollToPosition(
@ -715,7 +727,8 @@ class UbicadorFragment(
if (item.visible.toInt() - customDialogInput.getValue() if (item.visible.toInt() - customDialogInput.getValue()
.toInt() > 0 .toInt() > 0
) { ) {
item.visible.toInt() - customDialogInput.getValue().toInt() item.visible.toInt() - customDialogInput.getValue()
.toInt()
} else { } else {
0 0
} }
@ -750,8 +763,10 @@ class UbicadorFragment(
) { ) {
var title = getString(R.string.newItem) var title = getString(R.string.newItem)
if (delete) title = getString(R.string.editItem) + itemFk if (delete) title = getString(R.string.editItem) + itemFk
customDialogUbicador.setTitle(title).setItemValue(itemFk).setPackingValue(packing) customDialogUbicador.setTitle(title).setItemValue(itemFk)
.setGroupingValue(grouping).setEtiquetaValue(etiquetas).setVisibleValue(visible) .setPackingValue(packing)
.setGroupingValue(grouping).setEtiquetaValue(etiquetas)
.setVisibleValue(visible)
.setOkButton(getString(R.string.save)) { .setOkButton(getString(R.string.save)) {
var packingUpdate = false var packingUpdate = false
@ -794,91 +809,94 @@ class UbicadorFragment(
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
ma.hideKeyboard(customDialogUbicador.getEditItem()) ma.hideKeyboard(customDialogUbicador.getEditItem())
customDialogUbicador.getVisibleItem().setOnEditorActionListener { v, actionId, event -> customDialogUbicador.getVisibleItem()
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { .setOnEditorActionListener { v, actionId, event ->
var packingUpdate = false if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()) { var packingUpdate = false
packingUpdate = true if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()) {
} packingUpdate = true
saveNewItem(
customDialogUbicador.getItemValue().toInt(),
customDialogUbicador.getEtiquetaValue().toInt(),
if (customDialogUbicador.getPackingValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getPackingValue().toInt()
},
if (customDialogUbicador.getVisibleValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getVisibleValue().toInt()
},
if (delete) packingUpdate else null,
itemUbicador.id,
customDialogUbicador.getGroupingValue().toInt()
)
return@setOnEditorActionListener true
}
false
}
customDialogUbicador.getEditItem().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogUbicador.getItemValue().isNullOrEmpty()) {
try {
customDialogUbicador.setItemValue(
itemScanValue(
customDialogUbicador.getItemValue(),
"buy",
"more"
).toString()
)
} catch (ex: Exception) {
ma.messageWithSound(ex.message.toString(), true, true)
customDialogUbicador.setItemValue("")
} }
} saveNewItem(
customDialogUbicador.getItemValue().toInt(),
return@setOnEditorActionListener true customDialogUbicador.getEtiquetaValue().toInt(),
} if (customDialogUbicador.getPackingValue().isNullOrEmpty()) {
null
customDialogUbicador.getPackingItem().requestFocus() } else {
} customDialogUbicador.getPackingValue().toInt()
},
customDialogUbicador.getEtiquetaItem().setOnEditorActionListener { v, actionId, event -> if (customDialogUbicador.getVisibleValue().isNullOrEmpty()) {
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { null
var packingUpdate = false } else {
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()) { customDialogUbicador.getVisibleValue().toInt()
packingUpdate = true },
} if (delete) packingUpdate else null,
saveNewItem( itemUbicador.id,
customDialogUbicador.getItemValue().toInt(),
customDialogUbicador.getEtiquetaValue().toInt(),
if (customDialogUbicador.getPackingValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getPackingValue().toInt()
},
if (customDialogUbicador.getVisibleValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getVisibleValue().toInt()
},
if (delete) packingUpdate else null,
itemUbicador.id,
if (customDialogUbicador.getGroupingValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getGroupingValue().toInt() customDialogUbicador.getGroupingValue().toInt()
} )
) return@setOnEditorActionListener true
return@setOnEditorActionListener true }
false
}
customDialogUbicador.getEditItem()
.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogUbicador.getItemValue().isNullOrEmpty()) {
try {
customDialogUbicador.setItemValue(
itemScanValue(
customDialogUbicador.getItemValue(),
"buy",
"more"
).toString()
)
} catch (ex: Exception) {
ma.messageWithSound(ex.message.toString(), true, true)
customDialogUbicador.setItemValue("")
}
}
return@setOnEditorActionListener true
}
customDialogUbicador.getPackingItem().requestFocus()
}
customDialogUbicador.getEtiquetaItem()
.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
var packingUpdate = false
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()) {
packingUpdate = true
}
saveNewItem(
customDialogUbicador.getItemValue().toInt(),
customDialogUbicador.getEtiquetaValue().toInt(),
if (customDialogUbicador.getPackingValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getPackingValue().toInt()
},
if (customDialogUbicador.getVisibleValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getVisibleValue().toInt()
},
if (delete) packingUpdate else null,
itemUbicador.id,
if (customDialogUbicador.getGroupingValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getGroupingValue().toInt()
}
)
return@setOnEditorActionListener true
}
false
} }
false
}
} }
@ -998,7 +1016,8 @@ class UbicadorFragment(
.setDescription(getString(R.string.selectAction)) .setDescription(getString(R.string.selectAction))
.setOkButton(getString(R.string.transfer)) { .setOkButton(getString(R.string.transfer)) {
customDialogInput.setTitle(getString(R.string.shelvingNew)) customDialogInput.setTitle(getString(R.string.shelvingNew))
.setDescription(getString(R.string.selectDestiny) + item.item).setValue("") .setDescription(getString(R.string.selectDestiny) + item.item)
.setValue("")
.setOkButton(getString(R.string.transfer)) { .setOkButton(getString(R.string.transfer)) {
if (customDialogInput.getValue().isNotEmpty()) { if (customDialogInput.getValue().isNotEmpty()) {
binding.splashProgress.visibility = VISIBLE binding.splashProgress.visibility = VISIBLE
@ -1053,7 +1072,11 @@ class UbicadorFragment(
customDialogTwoButtons.dismiss() customDialogTwoButtons.dismiss()
customDialog.dismiss() customDialog.dismiss()
} else { } else {
viewModel.itemShelving_selfConsumption(shelvingFk, item.item, 0) viewModel.itemShelving_selfConsumption(
shelvingFk,
item.item,
0
)
} }
}.setKoButton(getString(R.string.cancel)) { }.setKoButton(getString(R.string.cancel)) {
customDialog.dismiss() customDialog.dismiss()

View File

@ -108,9 +108,9 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
shelving: String shelving: String
) { ) {
//Tarea 5134 ok salix.updateShelvingPriority(
salix.updateShelvingPriority("""{"code": "$shelving"}""", hashMapOf("priority" to priority)) where = JsonObject().apply { addProperty("code", shelving) },
.enqueue(object : SalixCallback<Any>(context) { params = hashMapOf("priority" to priority)).enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_responsepriority.value = ResponseItemVO( _responsepriority.value = ResponseItemVO(
isError = true, isError = true,
@ -268,8 +268,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
vShelvingFk: String vShelvingFk: String
) { ) {
salix.itemShelvingsUpdate(where = """{"id":$vShelf}""", params= hashMapOf("shelvingFk" to vShelvingFk)) salix.itemShelvingsUpdate(
.enqueue(object : SilexCallback<Any>(context) { where = JsonObject().apply { addProperty("id", vShelf) },
params = hashMapOf("shelvingFk" to vShelvingFk))
.enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, isError = true,
@ -284,6 +286,27 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun itemShelving_deleteChecked(
vShelvingFk: String
) {
salix.itemShelvingsUpdate(
where = JsonObject().apply { addProperty("shelvingFk", vShelvingFk) },
params = hashMapOf("isChecked" to null))
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
_response.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
})
}
fun shelvinLog_add( fun shelvinLog_add(
code: String code: String