diff --git a/app/src/main/java/es/verdnatura/di/viewModelModule.kt b/app/src/main/java/es/verdnatura/di/viewModelModule.kt index ea053873..c281d6f4 100644 --- a/app/src/main/java/es/verdnatura/di/viewModelModule.kt +++ b/app/src/main/java/es/verdnatura/di/viewModelModule.kt @@ -12,7 +12,7 @@ import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewM import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel import es.verdnatura.presentation.view.feature.historicoarticulo.fragment.HistoricoArticuloViewModel import es.verdnatura.presentation.view.feature.historicoshelving.fragment.ItemShelvingLogViewModel -import es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment.shelvingLogViewModel +import es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment.ShelvingLogViewModel import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoViewModel import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel @@ -174,7 +174,7 @@ val viewModelModule = module { ItemShelvingLogViewModel(androidContext()) } viewModel { - shelvingLogViewModel(androidContext()) + ShelvingLogViewModel(androidContext()) } viewModel { ClaimViewModel(androidContext()) diff --git a/app/src/main/java/es/verdnatura/domain/SalixCallback.kt b/app/src/main/java/es/verdnatura/domain/SalixCallback.kt index a32ccad3..eb9624da 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixCallback.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixCallback.kt @@ -6,6 +6,7 @@ import android.content.Intent import com.google.gson.Gson import com.google.gson.JsonObject import es.verdnatura.MobileApplication +import es.verdnatura.R import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.view.feature.login.activity.LoginActivity import org.json.JSONObject @@ -14,7 +15,6 @@ import retrofit2.Callback import retrofit2.Response import kotlin.system.exitProcess - abstract class SalixCallback(val context: Context) : Callback { override fun onResponse(call: Call, response: Response) { @@ -55,13 +55,17 @@ abstract class SalixCallback(val context: Context) : Callback { private fun defaultErrorHandler(t: Throwable) { //println("ErrorSalixx${t.message}") - // (nameofFunction((this)) + t.message).toast(context) + // (nameofFunction((this)) + t.message).toast(context) (context as MobileApplication).messageToast(true, (nameofFunction((this)) + t.message)) } open fun onSuccess(response: Response) { // (nameofFunction((this)) + context.getString(R.string.operationSuccessful)).toast(context) - //(context as MobileApplication).playSoundIsOK(true) + + (context as MobileApplication).messageToast( + isError = false, + message = context.getString(R.string.operationSuccessful) + ) } open fun onError(t: Throwable) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogFragment.kt index 7175ee38..53cdc572 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogFragment.kt @@ -14,17 +14,17 @@ import es.verdnatura.presentation.view.feature.historicoshelvinglog.adapter.Shel import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO @Suppress("UNUSED_ANONYMOUS_PARAMETER") -class shelvingLogFragment( +class ShelvingLogFragment( var entryPoint: String = "" -) : BaseFragment( - shelvingLogViewModel::class +) : BaseFragment( + ShelvingLogViewModel::class ) { private var adapter: ShelvingLogAdapter? = null private var itemScan = "" companion object { - fun newInstance(entryPoint: String) = shelvingLogFragment(entryPoint) + fun newInstance(entryPoint: String) = ShelvingLogFragment(entryPoint) } private lateinit var customDialog: CustomDialog @@ -51,8 +51,7 @@ 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().isNullOrEmpty()) { - shelvingLog_get(binding.scanInput.text.toString()) - + viewModel.shelvings((binding.scanInput.text.toString())) itemScan = binding.scanInput.text.toString() } binding.scanInput.setText("") @@ -62,39 +61,21 @@ class shelvingLogFragment( false } - binding.mainToolbar.backButton.setOnClickListener { requireActivity().onBackPressed() } } - - private fun shelvingLog_get(vShelvingFK: String) { - binding.splashProgress.visibility = View.VISIBLE - viewModel.Shelvings(setFilter(vShelvingFK)) - - } - - private fun setFilter(vShlevingFK: String): String { - - return "{\"where\": {\"code\": \"$vShlevingFK\"}}" - - } - - override fun observeViewModel() { with(viewModel) { loadShelvingLogSalixList.observe(viewLifecycleOwner, Observer { event -> event.getContentIfNotHandled().notNull { - binding.splashProgress.visibility = View.GONE - //adapter = ShelvingLogAdapter(it.list) binding.itemshelvinglogRecyclerview.adapter = adapter binding.itemshelvinglogRecyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) setToolBar(getString(R.string.shelvingLog) + ":" + itemScan) - if (it.list.isEmpty()) { customDialog.setTitle(getString(R.string.noResults)) .setDescription(getString(R.string.noDataLabelScanned)) @@ -102,39 +83,24 @@ class shelvingLogFragment( customDialog.dismiss() }.show() } else { - - if (it.list.get(0).isError == true) { - it.list.get(0).errorMessage?.let { it1 -> - customDialog.setTitle(getString(R.string.error)) - .setDescription(it1) - .setOkButton(getString(R.string.close)) { - customDialog.dismiss() - }.show() - } - } else { - - val itemId = it.list[0].id - ma.onPasillerosItemClickListener( - PasillerosItemVO( - title = getString(R.string.titleWebViewer), - ), - entryPoint = Gson().toJson( - mutableMapOf( - "entryPoint" to itemId, - "web" to "${getData("base_urlSalix")}/#!/shelving/$itemId/log" - ) + val itemId = it.list[0].id + ma.onPasillerosItemClickListener( + PasillerosItemVO( + title = getString(R.string.titleWebViewer), + ), + entryPoint = Gson().toJson( + mutableMapOf( + "entryPoint" to itemId, + "web" to "${getData("base_urlSalix")}/#!/shelving/$itemId/log" ) ) - } + ) } - - } - }) + }) } } - } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogViewModel.kt index fe2e7ee1..2e76a58d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historicoshelvinglog/fragment/shelvingLogViewModel.kt @@ -1,58 +1,26 @@ package es.verdnatura.presentation.view.feature.historicoshelvinglog.fragment - import android.content.Context import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations -import es.verdnatura.domain.SilexCallback +import es.verdnatura.domain.SalixCallback import es.verdnatura.presentation.base.BaseViewModel -import es.verdnatura.presentation.base.getMessageFromAllResponse -import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalixList import retrofit2.Response - -class shelvingLogViewModel(val context: Context) : BaseViewModel(context) { +class ShelvingLogViewModel(val context: Context) : BaseViewModel(context) { private val _itemShelvingLogSalixList by lazy { MutableLiveData() } val loadShelvingLogSalixList = Transformations.map(_itemShelvingLogSalixList) { Event(it) } - fun Shelvings(vShelvingFK: String) { - salix.Shelvings(vShelvingFK).enqueue(object : - SilexCallback>(context) { - override fun onError(t: Throwable) { - - val listError: ArrayList = ArrayList() - listError.add( - ShelvingLogSalix( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - ) - _itemShelvingLogSalixList.value = ShelvingLogSalixList(listError) - } - + fun shelvings(vShelvingFK: String) { + salix.Shelvings("""{"where": {"code": "$vShelvingFK"}}""").enqueue(object : + SalixCallback>(context) { override fun onSuccess(response: Response>) { - - if (response.body() != null) { - _itemShelvingLogSalixList.value = response.body()?.let { - ShelvingLogSalixList(it) - } - } else { - val listError: ArrayList = ArrayList() - listError.add( - ShelvingLogSalix( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - response.message() - ) - ) - ) - _itemShelvingLogSalixList.value = ShelvingLogSalixList(listError) - + _itemShelvingLogSalixList.value = response.body()?.let { + ShelvingLogSalixList(it) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt index c1fd3a77..c1d28836 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt @@ -1,4 +1,4 @@ -package es.verdnatura.presentation.view.feature.workermistake.adapter +package es.verdnatura.presentation.view.feature.workermistake.fragment import android.content.Context import android.os.Bundle @@ -7,6 +7,7 @@ import androidx.core.widget.addTextChangedListener import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentWorkermistakeBinding +import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnPasillerosItemClickListener @@ -18,6 +19,7 @@ import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel import es.verdnatura.presentation.view.feature.inventario.fragment.SearchDepartmentModel +import es.verdnatura.presentation.view.feature.workermistake.adapter.WorkermistakeAdapter import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake @@ -30,7 +32,6 @@ class WorkermistakeFragment( ) : BaseFragment( InventaryViewModel::class ) { - private var adapterworker: WorkermistakeAdapter? = null private lateinit var customDialogInput: CustomDialogInput private var listWorker: MutableList = ArrayList() @@ -42,7 +43,6 @@ class WorkermistakeFragment( private var listMistakes: ArrayList = ArrayList() private var listMistakesAdapter: BarcodeAdapter? = null private var workerMistakeName: WorkerFromMistake? = null - private val departments = ArrayList() private lateinit var departmentId: String @@ -58,61 +58,51 @@ class WorkermistakeFragment( } override fun onCreate(savedInstanceState: Bundle?) { - - viewModel.department_getHasMistake() - + viewModel.departmentGetHasMistake() super.onCreate(savedInstanceState) } override fun init() { - binding.filterDepartment.setText(getData(DEPARTMENTMISTAKE)) - binding.splashProgress.visibility = View.VISIBLE + binding.filterDepartment.text = getData(DEPARTMENTMISTAKE) departmentId = getData(DEPARTMENTMISTAKEID) - customDialogList = CustomDialogList(requireContext()) - if (!departmentId.isEmpty()) { + if (departmentId.isNotEmpty()) { viewModel.workerGetFromHasMistake( getData(DEPARTMENTMISTAKEID).toInt() ) } binding.filterDepartment.setOnClickListener { - SimpleSearchDialogCompat(context, + SimpleSearchDialogCompat( + context, getString(R.string.departamentos), getString(R.string.escribirparteNombre), null, - departments, - { baseSearchDialogCompat, nombre, position -> + departments + ) { baseSearchDialogCompat, nombre, position -> - binding.filterDepartment.setText((nombre.title)) - - saveData(DEPARTMENTMISTAKE, nombre.getDepartmentName()) - saveData(DEPARTMENTMISTAKEID, nombre.getDepartmentId()) - viewModel.workerGetFromHasMistake( - nombre.getDepartmentId() - ) - binding.splashProgress.visibility = View.VISIBLE - binding.filterItemFk.isEnabled = true - baseSearchDialogCompat.dismiss() - }).show() + binding.filterDepartment.text = (nombre.title) + saveData(DEPARTMENTMISTAKE, nombre.getDepartmentName()) + saveData(DEPARTMENTMISTAKEID, nombre.getDepartmentId()) + viewModel.workerGetFromHasMistake( + nombre.getDepartmentId() + ) + binding.filterItemFk.isEnabled = true + baseSearchDialogCompat.dismiss() + }.show() } - - customDialogInput = CustomDialogInput(requireContext()) customDialog = CustomDialog(requireContext()) ma.hideBottomNavigation(View.GONE) - binding.splashProgress.visibility = View.VISIBLE setToolBar() setEvents() super.init() } private fun setToolBar() { - binding.mainToolbar.toolbarTitle.text = entryPoint - } private fun setEvents() { @@ -141,38 +131,20 @@ class WorkermistakeFragment( } - /* override fun onPause() { - super.onPause() - firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0 - }*/ - - /* override fun onResume() { - super.onResume() - if (binding.workermistakeRecyclerview.layoutManager != null){ - if (firstVisiblePosition <= listInvetory.size){ - binding.workermistakeRecyclerview.layoutManager!!.scrollToPosition(firstVisiblePosition) - } - } - }*/ - override fun observeViewModel() { with(viewModel) { mistakeDepartmentList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE createDepartmentList(it.list) } - workerFromMistakeList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE createWorkerList(it.list) adapterworker = WorkermistakeAdapter(listWorker, object : onMistakeWorkerClickListener { override fun onMistakeWorkerClickListener(item: WorkerFromMistake) { - viewModel.workerMistakeType_get( + viewModel.workerMistakeTypeGet( ) workerMistakeName = WorkerFromMistake(item.id, item.firstName, item.lastName, true, "") - } }) binding.workermistakeRecyclerview.adapter = adapterworker @@ -182,40 +154,24 @@ class WorkermistakeFragment( } mistakeWorkerList.observe(viewLifecycleOwner) { - binding.splashProgress.visibility = View.GONE showMistakeList(it.list) } - - responseAddMistake.observe(viewLifecycleOwner) { + /*responseAddMistake.observe(viewLifecycleOwner) { ma.messageWithSound( - if (it.isError) { - if (it.codeError == 403) { - getString(R.string.userNotPermission) - } else { - it.errorMessage - } - } else { - getString(R.string.errorCauseRegistered) - }, it.isError, true, isToasted = true + message = getString(R.string.errorCauseRegistered), + it.isError, + true, + isToasted = true ) - } - - response.observe(viewLifecycleOwner) { - if (it.isError) { - ma.messageWithSound(it.errorMessage, true, false) - } - } + }*/ } } private fun showMistakeList(list: List) { - binding.splashProgress.visibility = View.GONE listMistakes = ArrayList() list.forEach { listMistakes.add(BarcodeVO(code = it.description)) } - - customDialogList.setTitle(getString(R.string.errorCause) + workerMistakeName!!.firstName) .setKoButton( getString( @@ -225,13 +181,12 @@ class WorkermistakeFragment( customDialogList.dismiss() }.hideDialog().show() - listMistakesAdapter = BarcodeAdapter(listMistakes, object : OnBarcodeRowClickListener { override fun onBarcodeRowClickListener(item: BarcodeVO) { list.forEach { if (it.description == item.code) { - viewModel.workerMistake_Add( + viewModel.workerMistakeAdd( vUserFk = workerMistakeName!!.id!!, vTypeFk = it.code ) @@ -243,7 +198,6 @@ class WorkermistakeFragment( }, showDelete = false) customDialogList.getRecyclerView().adapter = listMistakesAdapter - customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) @@ -256,6 +210,7 @@ class WorkermistakeFragment( try { departments.add(SearchDepartmentModel(department.name, department.id)) } catch (e: Exception) { + e.message!!.toast(requireContext()) } } } @@ -265,11 +220,11 @@ class WorkermistakeFragment( listWorker.clear() list.forEach { worker -> - if (!worker.isError) { try { listWorker.add(worker) } catch (e: Exception) { + e.message!!.toast(requireContext()) } } diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 681cc11b..11fc987a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -691,6 +691,8 @@ SI NO Añadir... + Apellidos + Confirmada reserva diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d6556581..9b4dd5a9 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -489,7 +489,7 @@ Proporciona un nombre y url de los servidores a los que la app se conectará Servidor Silex Servidor Salix - Nombre + Nom Borrar forma trabajo ¿Desea borrar definitivamente la forma de trabajo? Ver colección o último ticket @@ -691,6 +691,8 @@ OUI NON Añadir... + Nom de famille + Confirmada reserva diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index a03bce1d..cc7a7840 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -489,7 +489,7 @@ Proporciona un nombre y url de los servidores a los que la app se conectará Servidor Silex Servidor Salix - Nombre + Nome Borrar forma trabajo ¿Desea borrar definitivamente la forma de trabajo? Ver colección o último ticket @@ -691,6 +691,8 @@ SIM NÃO Añadir... + Sobrenome + Confirmada reserva diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e1c261af..23c54421 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -690,5 +690,7 @@ YES NO Añadir... + Surname + Confirmada reserva