feat historical #refs 7168
This commit is contained in:
parent
76c496df89
commit
88801796d5
|
@ -10,11 +10,13 @@ import es.verdnatura.domain.notNull
|
|||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.adapter.ShelvingLogAdapter
|
||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.LogType
|
||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class ShelvingLogFragment(
|
||||
var entryPoint: String = ""
|
||||
var entryPoint: String = "",
|
||||
private var logType: LogType
|
||||
|
||||
) : BaseFragment<FragmentShelvinglogBinding, ShelvingLogViewModel>(
|
||||
ShelvingLogViewModel::class
|
||||
|
@ -23,7 +25,8 @@ class ShelvingLogFragment(
|
|||
private var itemScan = ""
|
||||
|
||||
companion object {
|
||||
fun newInstance(entryPoint: String) = ShelvingLogFragment(entryPoint)
|
||||
fun newInstance(entryPoint: String, logType: LogType) =
|
||||
ShelvingLogFragment(entryPoint, logType)
|
||||
}
|
||||
|
||||
private lateinit var customDialog: CustomDialog
|
||||
|
@ -35,13 +38,21 @@ class ShelvingLogFragment(
|
|||
customDialog = CustomDialog(requireContext())
|
||||
binding.linearHeader.visibility = View.GONE
|
||||
setEvents()
|
||||
setToolBar(getString(R.string.shelvingLog))
|
||||
setToolBar(entryPoint)
|
||||
super.init()
|
||||
|
||||
}
|
||||
|
||||
private fun setToolBar(title: String) {
|
||||
binding.mainToolbar.toolbarTitle.text = title
|
||||
private fun setToolBar(title:String) {
|
||||
|
||||
if (logType == LogType.SHELVING) {
|
||||
binding.mainToolbar.toolbarTitle.text = title
|
||||
|
||||
} else {
|
||||
binding.mainToolbar.toolbarTitle.text = title
|
||||
binding.scanInput.setHint(getString(R.string.scanParkingTxt))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -50,7 +61,15 @@ class ShelvingLogFragment(
|
|||
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (binding.scanInput.text.toString().isNotEmpty()) {
|
||||
viewModel.shelvings((binding.scanInput.text.toString()))
|
||||
|
||||
when (logType) {
|
||||
LogType.SHELVING -> {
|
||||
viewModel.shelvings((binding.scanInput.text.toString()))
|
||||
|
||||
}
|
||||
|
||||
LogType.PREVIOUS -> viewModel.getParkingId((binding.scanInput.text.toString()))
|
||||
}
|
||||
itemScan = binding.scanInput.text.toString()
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
|
@ -82,28 +101,36 @@ class ShelvingLogFragment(
|
|||
customDialog.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
|
||||
val itemId = it.list[0].id
|
||||
println("web" to "${mobileApplication.dataStoreApp.getServerLilium()}/#!/shelving/$itemId/log")
|
||||
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleWebViewer),
|
||||
),
|
||||
|
||||
entryPoint = Gson().toJson(
|
||||
mutableMapOf(
|
||||
"entryPoint" to itemId,
|
||||
"web" to "${mobileApplication.dataStoreApp.getServerLilium()}/#/shelving/$itemId/log"
|
||||
)
|
||||
)
|
||||
)
|
||||
openViewer(it.list[0].id!!, "shelving")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
loadResponseParking.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
setToolBar(getString(R.string.parking) + ":" + itemScan)
|
||||
openViewer(it, "parking")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun openViewer(param: Int, web: String) {
|
||||
ma.onPasillerosItemClickListener(
|
||||
PasillerosItemVO(
|
||||
title = getString(R.string.titleWebViewer),
|
||||
),
|
||||
|
||||
entryPoint = Gson().toJson(
|
||||
mutableMapOf(
|
||||
"entryPoint" to param,
|
||||
"web" to "${mobileApplication.dataStoreApp.getServerLilium()}/#/$web/$param/log"
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.map
|
||||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
|
@ -14,7 +15,12 @@ import retrofit2.Response
|
|||
class ShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val _itemShelvingLogSalixList by lazy { MutableLiveData<ShelvingLogSalixList>() }
|
||||
val loadShelvingLogSalixList: LiveData<Event<ShelvingLogSalixList>> = _itemShelvingLogSalixList.map { Event(it) }
|
||||
val loadShelvingLogSalixList: LiveData<Event<ShelvingLogSalixList>> =
|
||||
_itemShelvingLogSalixList.map { Event(it) }
|
||||
|
||||
private val _responseParkingId by lazy { MutableLiveData<Int?>() }
|
||||
val responseParkingId: LiveData<Int?> = _responseParkingId
|
||||
val loadResponseParking: LiveData<Event<Int?>> =_responseParkingId.map { Event(it) }
|
||||
|
||||
fun shelvings(vShelvingFK: String) {
|
||||
salix.Shelvings("""{"where": {"code": "$vShelvingFK"}}""").enqueue(object :
|
||||
|
@ -29,6 +35,19 @@ class ShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
|
||||
}
|
||||
|
||||
fun getParkingId(parkingCode: String) {
|
||||
salix.getParkings("""{"where": {"code": "$parkingCode"},"fields":"id"}""")
|
||||
.enqueue(object :
|
||||
SalixCallback<List<JsonObject>>(context) {
|
||||
override fun onSuccess(response: Response<List<JsonObject>>) {
|
||||
_responseParkingId.value = response.body()?.firstOrNull()?.entrySet()?.firstOrNull()?.value?.toString()?.toIntOrNull()
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,4 +39,9 @@ data class DeviceLogSalix(
|
|||
val nameApp: String,
|
||||
val versionApp: String,
|
||||
val serialNumber: String?
|
||||
)
|
||||
)
|
||||
enum class LogType {
|
||||
SHELVING,
|
||||
PREVIOUS,
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue