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}}"""
|
@Query("filter") filter: String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}"""
|
||||||
): Call<List<DepartmentMistake>>
|
): Call<List<DepartmentMistake>>
|
||||||
|
|
||||||
@GET("Workers/findOne?")
|
|
||||||
fun worker_isF11Allowed(
|
|
||||||
@Query("filter") filter: String
|
|
||||||
): Call<JsonObject>
|
|
||||||
|
|
||||||
@DELETE("ExpeditionPallets/{id}")
|
@DELETE("ExpeditionPallets/{id}")
|
||||||
fun expeditionPalletDel(
|
fun expeditionPalletDel(
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import es.verdnatura.MobileApplication
|
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.databinding.FragmentAjustesBinding
|
import es.verdnatura.databinding.FragmentAjustesBinding
|
||||||
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
|
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
|
||||||
|
@ -45,7 +44,6 @@ class AjustesFragment :
|
||||||
private var printersList: MutableList<Printers> = mutableListOf()
|
private var printersList: MutableList<Printers> = mutableListOf()
|
||||||
private var trainsList: List<Train> = listOf()
|
private var trainsList: List<Train> = listOf()
|
||||||
private var settingsAdapter: SettingsAdapter? = null
|
private var settingsAdapter: SettingsAdapter? = null
|
||||||
private var isWorkerAllowed: Boolean = false
|
|
||||||
private var itemPackingList: List<ItemPackingType> = listOf()
|
private var itemPackingList: List<ItemPackingType> = listOf()
|
||||||
private var messagePrinter: String? = null
|
private var messagePrinter: String? = null
|
||||||
private lateinit var loginViewModel: LoginViewModel
|
private lateinit var loginViewModel: LoginViewModel
|
||||||
|
@ -58,7 +56,6 @@ class AjustesFragment :
|
||||||
override fun getLayoutId(): Int = R.layout.fragment_ajustes
|
override fun getLayoutId(): Int = R.layout.fragment_ajustes
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
||||||
customDialog = CustomDialog(requireContext())
|
customDialog = CustomDialog(requireContext())
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -68,7 +65,7 @@ class AjustesFragment :
|
||||||
|
|
||||||
binding.mainToolbar.toolbarTitle.text = getString(R.string.settings)
|
binding.mainToolbar.toolbarTitle.text = getString(R.string.settings)
|
||||||
hideBackButton(binding.mainToolbar)
|
hideBackButton(binding.mainToolbar)
|
||||||
viewModel.workerIsF11Allowed()
|
getUserData()
|
||||||
binding.userText.text = mobileApplication.userName
|
binding.userText.text = mobileApplication.userName
|
||||||
binding.itemVersion.text = requireActivity().packageManager.getPackageInfo(
|
binding.itemVersion.text = requireActivity().packageManager.getPackageInfo(
|
||||||
requireActivity().packageName, 0
|
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 ->
|
loadActionUpdate.observe(viewLifecycleOwner) { event ->
|
||||||
event.getContentIfNotHandled().notNull {
|
event.getContentIfNotHandled().notNull {
|
||||||
|
@ -238,7 +219,21 @@ class AjustesFragment :
|
||||||
}
|
}
|
||||||
super.observeViewModel()
|
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() {
|
private fun showMenuByDefault() {
|
||||||
pasilleroViewModel = PasilleroViewModel(mobileApplication)
|
pasilleroViewModel = PasilleroViewModel(mobileApplication)
|
||||||
pasilleroViewModel.inititializeDefaultDataInit()
|
pasilleroViewModel.inititializeDefaultDataInit()
|
||||||
|
@ -264,7 +259,6 @@ class AjustesFragment :
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERNAME),
|
mobileApplication.dataStoreApp.readDataStoreKey(PRINTERNAME),
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(TRAINNAME),
|
mobileApplication.dataStoreApp.readDataStoreKey<String>(TRAINNAME),
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
|
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
|
||||||
actionIsAllowed = actionIsAllowed,
|
|
||||||
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
|
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||||
MENUBYDEFAULTSELECTED
|
MENUBYDEFAULTSELECTED
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,8 +4,6 @@ import android.content.Context
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.map
|
import androidx.lifecycle.map
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import es.verdnatura.MobileApplication
|
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.domain.SalixCallback
|
import es.verdnatura.domain.SalixCallback
|
||||||
import es.verdnatura.presentation.base.BaseViewModel
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
@ -67,7 +65,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
printerSelected: String,
|
printerSelected: String,
|
||||||
train: String?,
|
train: String?,
|
||||||
itemPackingType: String?,
|
itemPackingType: String?,
|
||||||
actionIsAllowed: Boolean,
|
|
||||||
menuDefault: String
|
menuDefault: String
|
||||||
) {
|
) {
|
||||||
_settingsItem.clear()
|
_settingsItem.clear()
|
||||||
|
@ -105,7 +102,7 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
6,
|
6,
|
||||||
context.getString(R.string.settingsTitleTrain),
|
context.getString(R.string.settingsTitleTrain),
|
||||||
train,
|
train,
|
||||||
action = actionIsAllowed
|
action = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
_settingsItem.add(
|
_settingsItem.add(
|
||||||
|
@ -113,7 +110,7 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
7,
|
7,
|
||||||
context.getString(R.string.settingsTitleItemPacking),
|
context.getString(R.string.settingsTitleItemPacking),
|
||||||
itemPackingType,
|
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?) {
|
fun workerUpdateOperatorSalix(entity: String, workerFk: Int, sectorFk: Int?, labelerFk: Int?) {
|
||||||
salix.update_operator(id = workerFk, Operator(sectorFk, labelerFk))
|
salix.update_operator(id = workerFk, Operator(sectorFk, labelerFk))
|
||||||
.enqueue(object : SalixCallback<Unit>(context) {
|
.enqueue(object : SalixCallback<Unit>(context) {
|
||||||
|
|
Loading…
Reference in New Issue