feat issues refs #7636

This commit is contained in:
Sergio De la torre 2024-08-07 11:50:26 +02:00
parent a2aae3bd73
commit 1bd592db0f
4 changed files with 53 additions and 10 deletions

View File

@ -274,7 +274,7 @@ class EndSacadorFragment(
} }
}) })
loadResponseSaleGropAdd.observe(viewLifecycleOwner) { event -> loadResponseSaleGroupAdd.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
if (!goBack) { if (!goBack) {

View File

@ -83,9 +83,15 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
private val _responseSaleGroupAdd by lazy { MutableLiveData<ResponseItemVO>() } private val _responseSaleGroupAdd by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleGroupAdd: LiveData<ResponseItemVO> val responseSaleGroupAdd: LiveData<ResponseItemVO>
get() = _responseSaleGroupAdd get() = _responseSaleGroupAdd
val loadResponseSaleGropAdd: LiveData<Event<ResponseItemVO>> = val loadResponseSaleGroupAdd: LiveData<Event<ResponseItemVO>> =
_responseSaleGroupAdd.map { Event(it) } _responseSaleGroupAdd.map { Event(it) }
private val _responseSaleGroupAdded by lazy { MutableLiveData<Int>() }
val responseSaleGroupAdded: LiveData<Int>
get() = _responseSaleGroupAdded
val loadResponseSaleGropAdded: LiveData<Event<Int>> =
_responseSaleGroupAdded.map { Event(it) }
private val _responseReserveSectorCollection by lazy { MutableLiveData<ResponseItemVO>() } private val _responseReserveSectorCollection by lazy { MutableLiveData<ResponseItemVO>() }
val responseReserveSectorCollection: LiveData<ResponseItemVO> val responseReserveSectorCollection: LiveData<ResponseItemVO>
get() = _responseReserveSectorCollection get() = _responseReserveSectorCollection
@ -311,7 +317,7 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
} }
fun sectorCollectionSaleGroupAdd( fun sectorCollectionSaleGroupAdd(
vSaleGroupFk: Int, vSectorCollectionFk: Int vSaleGroupFk: Int, vSectorCollectionFk: Int,
) { ) {
salix.sectorCollectionSaleGroupAdd( salix.sectorCollectionSaleGroupAdd(
arrayListOf( arrayListOf(
@ -324,6 +330,7 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
nameofFunction(this), response.message() nameofFunction(this), response.message()
) )
) )
_responseSaleGroupAdded.value = vSaleGroupFk
} }
override fun onError(t: Throwable) { override fun onError(t: Throwable) {

View File

@ -115,14 +115,19 @@ class SacadorFragment(
iconAdd.drawable -> { iconAdd.drawable -> {
if (type == "PREPARED") { if (type == "PREPARED") {
viewModel.collection_assign( if (hasSector()) {
) viewModel.collection_assign(
} else {
viewModel.sectorCollectionNew(
mobileApplication.dataStoreApp.readDataStoreKey(
SECTORFK
) )
) }
} else {
if (hasSector()) {
viewModel.sectorCollectionNew(
mobileApplication.dataStoreApp.readDataStoreKey(
SECTORFK
)
)
}
} }
} }
@ -138,6 +143,21 @@ class SacadorFragment(
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
} }
private fun hasSector(): Boolean {
return if (ma.haveSector()) {
true
} else {
ma.messageWithSound(
message = getString(R.string.errorSector),
isError = true,
isPlayed = true,
isToasted = false
)
false
}
}
private fun showPrintPrevious() { private fun showPrintPrevious() {
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER) customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)

View File

@ -122,9 +122,11 @@ class SacadorFragmentNew(
iconAdd.drawable -> { iconAdd.drawable -> {
if (type == "PREPARED") { if (type == "PREPARED") {
if (hasSector())
viewModel.collection_assignNew( viewModel.collection_assignNew(
) )
} else { } else {
if (hasSector())
viewModel.sectorCollectionNew( viewModel.sectorCollectionNew(
mobileApplication.dataStoreApp.readDataStoreKey( mobileApplication.dataStoreApp.readDataStoreKey(
SECTORFK SECTORFK
@ -317,4 +319,18 @@ class SacadorFragmentNew(
} }
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()
} }
private fun hasSector(): Boolean {
return if (ma.haveSector()) {
true
} else {
ma.messageWithSound(
message = getString(R.string.errorSector),
isError = true,
isPlayed = true,
isToasted = false
)
false
}
}
} }