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