feat: refs #6845 userIterface
This commit is contained in:
parent
8aa5a3b01a
commit
19adf86f9f
|
@ -53,6 +53,10 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
val responseTicketState: LiveData<TicketState> = _responseTicketState
|
||||
val loadTicketState: LiveData<Event<TicketState>> = _responseTicketState.map { Event(it) }
|
||||
|
||||
private val _responseTicketSetState by lazy { MutableLiveData<TicketState>() }
|
||||
val responseTicketSetState: LiveData<TicketState> = _responseTicketSetState
|
||||
val loadTicketSetState: LiveData<Event<TicketState>> = _responseTicketSetState.map { Event(it) }
|
||||
|
||||
private val _responseTicketIsPickup by lazy { MutableLiveData<Boolean>() }
|
||||
val responseTicketIsPickup: LiveData<Boolean> = _responseTicketIsPickup
|
||||
val loadTicketIsPickup: LiveData<Event<Boolean>> = _responseTicketIsPickup.map { Event(it) }
|
||||
|
@ -70,9 +74,9 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
val responseNew: LiveData<Boolean> = _responseNew
|
||||
val loadAddNew: LiveData<Event<Boolean>> = _responseNew.map { Event(it) }
|
||||
|
||||
private val _responseIncQuantity by lazy { MutableLiveData<Boolean>() }
|
||||
val responseIncQuantity: LiveData<Boolean> = _responseIncQuantity
|
||||
val loadIncQuantity: LiveData<Event<Boolean>> = _responseIncQuantity.map { Event(it) }
|
||||
private val _responseIncQuantity by lazy { MutableLiveData<Number>() }
|
||||
val responseIncQuantity: LiveData<Number> = _responseIncQuantity
|
||||
val loadIncQuantity: LiveData<Event<Number>> = _responseIncQuantity.map { Event(it) }
|
||||
|
||||
private val _responseParking by lazy { MutableLiveData<Boolean>() }
|
||||
val responseParking: LiveData<Boolean> = _responseParking
|
||||
|
@ -217,7 +221,7 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
salix.ticketStateTodaySetState(arrayListOf(ticketFk, state).formatWithQuotes())
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
override fun onSuccess(response: Response<Unit>) {
|
||||
_responseTicketState.value = TicketState()
|
||||
_responseTicketSetState.value = TicketState(code = state, ticketFk = ticketFk)
|
||||
super.onSuccess(response)
|
||||
}
|
||||
})
|
||||
|
@ -232,7 +236,7 @@ class CollectionCheckerViewModel(val context: Context) : BaseViewModel(context)
|
|||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
super.onSuccess(response)
|
||||
_responseIncQuantity.value = true
|
||||
_responseIncQuantity.value = saleFk
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ class CollectionFragmentChecker(
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
scanRequest()
|
||||
viewModel.setPausedState(false)
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
@ -172,19 +173,18 @@ class CollectionFragmentChecker(
|
|||
binding.mainToolbar.toolbarIcons.adapter =
|
||||
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
if (collection.tickets.isNotEmpty())
|
||||
when (item) {
|
||||
iconViewCollection.drawable -> getCollection()
|
||||
iconPrint.drawable -> print()
|
||||
iconAdd.drawable -> addItem()
|
||||
iconWorker.drawable -> showUser()
|
||||
iconUpdate.drawable -> updateScreen()
|
||||
iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.Parking
|
||||
), ""
|
||||
)
|
||||
}
|
||||
if (collection.tickets.isNotEmpty()) when (item) {
|
||||
iconViewCollection.drawable -> getCollection()
|
||||
iconPrint.drawable -> print()
|
||||
iconAdd.drawable -> addItem()
|
||||
iconWorker.drawable -> showUser()
|
||||
iconUpdate.drawable -> updateScreen()
|
||||
iconParking.drawable -> pasillerosItemClickListener?.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = R.string.Parking
|
||||
), ""
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
@ -237,8 +237,6 @@ class CollectionFragmentChecker(
|
|||
}
|
||||
|
||||
private fun takeActionPrevia(customDialogList: CustomDialogList) {
|
||||
println("previaaaa ${customDialogList.getValue()}")
|
||||
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
try {
|
||||
val saleGroupScanned = itemScanValue(
|
||||
|
@ -383,13 +381,11 @@ class CollectionFragmentChecker(
|
|||
customDialogWarning.setTitle(getString(R.string.ticketPickup))
|
||||
customDialogWarning.setDescription(
|
||||
getString(
|
||||
R.string.ticketPickupDescr,
|
||||
binding.mainToolbar.toolbarTitle.text
|
||||
R.string.ticketPickupDescr, binding.mainToolbar.toolbarTitle.text
|
||||
)
|
||||
)
|
||||
.setOkButton(getString(R.string.aware)) {
|
||||
customDialogWarning.dismiss()
|
||||
}
|
||||
).setOkButton(getString(R.string.aware)) {
|
||||
customDialogWarning.dismiss()
|
||||
}
|
||||
customDialogWarning.show()
|
||||
|
||||
}
|
||||
|
@ -399,13 +395,20 @@ class CollectionFragmentChecker(
|
|||
event.getContentIfNotHandled().notNull {
|
||||
context.showToastCenterWithBackground(
|
||||
getString(
|
||||
R.string.parkingIn,
|
||||
ticketScanTxt
|
||||
R.string.parkingIn, ticketScanTxt
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
loadTicketSetState.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
"${it.ticketFk}: ${if (it.code == "CHECKED") "Revisado" else "Revisando"}".toast(
|
||||
requireContext()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
loadPrint.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
|
@ -469,7 +472,7 @@ class CollectionFragmentChecker(
|
|||
|
||||
loadIncQuantity.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
incresaseSuccesful()
|
||||
incresaseSuccesful(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,15 +569,23 @@ class CollectionFragmentChecker(
|
|||
compareBy({ it.isControlled }, { it.picked })
|
||||
)*/
|
||||
|
||||
saleAdapter = SaleAdapter(
|
||||
myGroupList as MutableList,
|
||||
saleAdapter = SaleAdapter(myGroupList as MutableList,
|
||||
pasillerosItemClickListener!!,
|
||||
object : OnQuantityClickListener {
|
||||
override fun onQuantityClick(sale: SaleVO) {
|
||||
|
||||
myGroupList.forEachIndexed { index, saleVO ->
|
||||
if (saleVO.saleFk == sale.saleFk) {
|
||||
showQuantityDialog(index)
|
||||
|
||||
if (saleVO.isParent) {
|
||||
saleVO.sonSales.forEachIndexed { indexSon, saleV0 ->
|
||||
if (saleV0.saleFk == sale.saleFk) {
|
||||
showQuantityDialogBySale(saleV0.saleFk)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (saleVO.saleFk == sale.saleFk) {
|
||||
showQuantityDialog(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,8 +649,7 @@ class CollectionFragmentChecker(
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
binding.fragmentSacadorCollections.adapter = saleAdapter
|
||||
|
@ -993,7 +1003,6 @@ class CollectionFragmentChecker(
|
|||
if (totalMark == sales.size) {
|
||||
getString(R.string.completCollection).toast(this.context, Toast.LENGTH_SHORT)
|
||||
// saleAdapter!!.notifyDataSetChanged()
|
||||
|
||||
if (canChangeState) changeTicketState()
|
||||
} else {
|
||||
if (allTicketsChecked) {
|
||||
|
@ -1011,8 +1020,7 @@ class CollectionFragmentChecker(
|
|||
val ticketFk = sale.ticketFk.toInt()
|
||||
if (sale.isControlled == "0" && ticketFk !in processedTickets) {
|
||||
viewModel.ticketStateTodaySetState(
|
||||
ticketFk = ticketFk,
|
||||
state = "ON_CHECKING"
|
||||
ticketFk = ticketFk, state = "ON_CHECKING"
|
||||
)
|
||||
processedTickets.add(ticketFk)
|
||||
}
|
||||
|
@ -1022,7 +1030,37 @@ class CollectionFragmentChecker(
|
|||
}
|
||||
}
|
||||
|
||||
private fun showQuantityDialogBySale(saleFk: Int) {
|
||||
|
||||
try {
|
||||
|
||||
customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity))
|
||||
.setValue("").setOkButtonAdd(getString(R.string.modify)) {
|
||||
try {
|
||||
increaseQuantityBySale(saleFk, customDialogThreeButtons.getValue().toInt())
|
||||
scanRequest()
|
||||
customDialogThreeButtons.dismiss()
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorInputQuantity),
|
||||
isPlayed = true,
|
||||
isError = true,
|
||||
isToasted = true
|
||||
)
|
||||
}
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
scanRequest()
|
||||
customDialogThreeButtons.dismiss()
|
||||
}.show()
|
||||
customDialogThreeButtons.setFocusDialogValue()
|
||||
} catch (ex: Exception) {
|
||||
getString(R.string.errorInput).toast(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
private fun showQuantityDialog(position: Int) {
|
||||
|
||||
try {
|
||||
|
||||
customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity))
|
||||
|
@ -1050,22 +1088,51 @@ class CollectionFragmentChecker(
|
|||
}
|
||||
}
|
||||
|
||||
private fun incresaseSuccesful() {
|
||||
try {
|
||||
sales[positionIncreaseQuantity].quantity = quantityIncrease
|
||||
private fun incresaseSuccesful(saleFk: Number) {
|
||||
|
||||
// updateScreen()
|
||||
try {
|
||||
// if (myGroupList[positionIncreaseQuantity].isParent) {
|
||||
//updateScreen()
|
||||
for ((parentIndex, listItem) in myGroupList.withIndex()) {
|
||||
|
||||
if (listItem.isParent) {
|
||||
for ((childIndex, listItemSon) in listItem.sonSales.withIndex()) {
|
||||
if (listItemSon.saleFk == saleFk) {
|
||||
myGroupList[parentIndex].sonSales[childIndex].quantity =
|
||||
quantityIncrease
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (myGroupList[parentIndex].saleFk == saleFk) myGroupList[parentIndex].quantity =
|
||||
quantityIncrease
|
||||
break
|
||||
}
|
||||
}/* } else {
|
||||
myGroupList[positionIncreaseQuantity].quantity = quantityIncrease
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
}*/
|
||||
} catch (e: Exception) {
|
||||
e.message!!.toast(requireContext())
|
||||
}
|
||||
saleAdapter?.notifyDataSetChanged()
|
||||
sales[positionIncreaseQuantity].originalQuantity = quantityIncrease
|
||||
|
||||
}
|
||||
|
||||
private fun increaseQuantity(position: Int, quantity: Int) {
|
||||
positionIncreaseQuantity = position
|
||||
quantityIncrease = quantity
|
||||
viewModel.collectionIncreaseQuantitySalix(
|
||||
saleFk = sales[position].saleFk, quantity = quantity.toString()
|
||||
saleFk = myGroupList[position].saleFk, quantity = quantity.toString()
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private fun increaseQuantityBySale(saleFk: Int, quantity: Int) {
|
||||
quantityIncrease = quantity
|
||||
viewModel.collectionIncreaseQuantitySalix(
|
||||
saleFk, quantity = quantity.toString()
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -1096,17 +1163,14 @@ class CollectionFragmentChecker(
|
|||
}
|
||||
if (isTicket) {
|
||||
val labelDialogHelper = LabelDialogHelper(requireContext())
|
||||
labelDialogHelper.showLabelDialog(
|
||||
onItemSelected = { labelCount ->
|
||||
viewModel.collectionStickerPrint(
|
||||
collectionFk = collection.collectionFk,
|
||||
labelCount = labelCount
|
||||
)
|
||||
val printerName =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(PRINTERNAME)
|
||||
(getString(R.string.Imprimiendo) + printerName).toast(requireContext())
|
||||
}
|
||||
)
|
||||
labelDialogHelper.showLabelDialog(onItemSelected = { labelCount ->
|
||||
viewModel.collectionStickerPrint(
|
||||
collectionFk = collection.collectionFk, labelCount = labelCount
|
||||
)
|
||||
val printerName =
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(PRINTERNAME)
|
||||
(getString(R.string.Imprimiendo) + printerName).toast(requireContext())
|
||||
})
|
||||
|
||||
} else {
|
||||
viewModel.collectionStickerPrint(
|
||||
|
@ -1175,7 +1239,7 @@ class CollectionFragmentChecker(
|
|||
originalQuantity = null,
|
||||
quantity = null,
|
||||
rgb = null,
|
||||
saleFk = value[0].saleFk,
|
||||
saleFk = 0,
|
||||
saleGroupFk = value[0].saleGroupFk,
|
||||
isPreControlled = value[0].isPreControlled,
|
||||
isPrepared = value[0].isPrepared,
|
||||
|
|
Loading…
Reference in New Issue