feat isF11Allowed refs #6435
This commit is contained in:
parent
89a4cff1ed
commit
e2d2fd8d33
|
@ -836,10 +836,6 @@ interface SalixService {
|
|||
@Query("filter") filter: String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}"""
|
||||
): Call<List<DepartmentMistake>>
|
||||
|
||||
@GET("Workers/findOne?")
|
||||
fun worker_isF11Allowed(
|
||||
@Query("filter") filter: String
|
||||
): Call<JsonObject>
|
||||
|
||||
@DELETE("ExpeditionPallets/{id}")
|
||||
fun expeditionPalletDel(
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
|||
import android.widget.ArrayAdapter
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentAjustesBinding
|
||||
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
|
||||
|
@ -45,7 +44,6 @@ class AjustesFragment :
|
|||
private var printersList: MutableList<Printers> = mutableListOf()
|
||||
private var trainsList: List<Train> = listOf()
|
||||
private var settingsAdapter: SettingsAdapter? = null
|
||||
private var isWorkerAllowed: Boolean = false
|
||||
private var itemPackingList: List<ItemPackingType> = listOf()
|
||||
private var messagePrinter: String? = null
|
||||
private lateinit var loginViewModel: LoginViewModel
|
||||
|
@ -58,7 +56,6 @@ class AjustesFragment :
|
|||
override fun getLayoutId(): Int = R.layout.fragment_ajustes
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
customDialog = CustomDialog(requireContext())
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
@ -68,7 +65,7 @@ class AjustesFragment :
|
|||
|
||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.settings)
|
||||
hideBackButton(binding.mainToolbar)
|
||||
viewModel.workerIsF11Allowed()
|
||||
getUserData()
|
||||
binding.userText.text = mobileApplication.userName
|
||||
binding.itemVersion.text = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
|
@ -113,22 +110,6 @@ class AjustesFragment :
|
|||
}
|
||||
})
|
||||
|
||||
workerAllowedResponse.observe(viewLifecycleOwner) {
|
||||
|
||||
isWorkerAllowed = it
|
||||
loginViewModel = LoginViewModel(context as MobileApplication)
|
||||
loginViewModel.operator_getDataSalix(mobileApplication.userId!!)
|
||||
loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
|
||||
if (!iti.isError) {
|
||||
runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
|
||||
} else {
|
||||
ma.messageWithSound(iti.errorMessage, isError = true, isPlayed = true)
|
||||
}
|
||||
}
|
||||
|
||||
setSettings(isWorkerAllowed)
|
||||
|
||||
}
|
||||
|
||||
loadActionUpdate.observe(viewLifecycleOwner) { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
|
@ -238,7 +219,21 @@ class AjustesFragment :
|
|||
}
|
||||
super.observeViewModel()
|
||||
}
|
||||
private fun getUserData() {
|
||||
|
||||
|
||||
loginViewModel = LoginViewModel(requireActivity().applicationContext)
|
||||
loginViewModel.operator_getDataSalix(mobileApplication.userId!!)
|
||||
loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
|
||||
if (!iti.isError) {
|
||||
runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
|
||||
} else {
|
||||
ma.messageWithSound(iti.errorMessage, isError = true, isPlayed = true)
|
||||
}
|
||||
}
|
||||
|
||||
setSettings(false)
|
||||
}
|
||||
private fun showMenuByDefault() {
|
||||
pasilleroViewModel = PasilleroViewModel(mobileApplication)
|
||||
pasilleroViewModel.inititializeDefaultDataInit()
|
||||
|
@ -264,7 +259,6 @@ class AjustesFragment :
|
|||
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERNAME),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(TRAINNAME),
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
|
||||
actionIsAllowed = actionIsAllowed,
|
||||
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||
MENUBYDEFAULTSELECTED
|
||||
)
|
||||
|
|
|
@ -4,8 +4,6 @@ import android.content.Context
|
|||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.map
|
||||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
|
@ -67,7 +65,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
printerSelected: String,
|
||||
train: String?,
|
||||
itemPackingType: String?,
|
||||
actionIsAllowed: Boolean,
|
||||
menuDefault: String
|
||||
) {
|
||||
_settingsItem.clear()
|
||||
|
@ -105,7 +102,7 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
6,
|
||||
context.getString(R.string.settingsTitleTrain),
|
||||
train,
|
||||
action = actionIsAllowed
|
||||
action = false
|
||||
)
|
||||
)
|
||||
_settingsItem.add(
|
||||
|
@ -113,7 +110,7 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
7,
|
||||
context.getString(R.string.settingsTitleItemPacking),
|
||||
itemPackingType,
|
||||
action = actionIsAllowed
|
||||
action = false
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -191,19 +188,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun workerIsF11Allowed() {
|
||||
salix.worker_isF11Allowed("""{"where":{"id":${(context as MobileApplication).userId}},"fields":{"isF11Allowed":true}}""")
|
||||
.enqueue(object : SalixCallback<JsonObject>(context) {
|
||||
override fun onSuccess(response: Response<JsonObject>) {
|
||||
|
||||
_workerAllowedResponse.value =
|
||||
response.body()!!.entrySet().first().value.toString().toBoolean()
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun workerUpdateOperatorSalix(entity: String, workerFk: Int, sectorFk: Int?, labelerFk: Int?) {
|
||||
salix.update_operator(id = workerFk, Operator(sectorFk, labelerFk))
|
||||
.enqueue(object : SalixCallback<Unit>(context) {
|
||||
|
|
Loading…
Reference in New Issue