add item to shelving
This commit is contained in:
parent
59f946ffe0
commit
db2cfb0aab
|
@ -12,4 +12,19 @@ class GetUbicadorUserCase : RestClient() {
|
|||
|
||||
return restClient!!.itemShelvingList("json","1",usuario,password,"application/json",params)!!
|
||||
}
|
||||
|
||||
fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String) : Call<String> {
|
||||
val params:ArrayList<String> = ArrayList();
|
||||
params.add(shelving)
|
||||
params.add(item)
|
||||
params.add(deep)
|
||||
params.add(quantity)
|
||||
params.add(packing)
|
||||
params.add(warehouse)
|
||||
params.add(level)
|
||||
|
||||
return restClient!!.itemShelvingMake("json","1",usuario,password,"application/json",params)!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -171,5 +171,14 @@ interface VerdnaturaService {
|
|||
@Body params: List<String>):
|
||||
Call<List<ItemUbicadorVO>>
|
||||
|
||||
@POST("almacenv2/itemShelvingMake")
|
||||
fun itemShelvingMake(@Header("aplicacion") aplicacion: String,
|
||||
@Header("version") version: String,
|
||||
@Header("user") user: String,
|
||||
@Header("pass") pass: String,
|
||||
@Header("Content-Type") content_type: String,
|
||||
@Body params: List<String>):
|
||||
Call<String>
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package es.verdnatura.presentation.view.component
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import es.verdnatura.R
|
||||
import kotlinx.android.synthetic.main.component_custom_ubicador_dialog.*
|
||||
|
||||
class CustomDialogUbicador (context: Context) : Dialog(context, R.style.DialogTheme) {
|
||||
|
||||
init {
|
||||
setContentView(R.layout.component_custom_ubicador_dialog)
|
||||
}
|
||||
|
||||
|
||||
fun setTitle(title: String): CustomDialogUbicador {
|
||||
custom_dialog_title.visibility = View.VISIBLE
|
||||
custom_dialog_title.text = title
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
fun setItemValue(value : String) : CustomDialogUbicador{
|
||||
custom_dialog_item.setText(value)
|
||||
custom_dialog_item.visibility = View.VISIBLE
|
||||
return this
|
||||
}
|
||||
|
||||
fun getItemValue() : String{
|
||||
return custom_dialog_item.text.toString()
|
||||
}
|
||||
|
||||
fun getEditItem() : TextInputEditText {
|
||||
return custom_dialog_item
|
||||
}
|
||||
|
||||
|
||||
fun setEtiquetaValue(value : String) : CustomDialogUbicador{
|
||||
custom_dialog_etiquetas.setText(value)
|
||||
custom_dialog_etiquetas.visibility = View.VISIBLE
|
||||
return this
|
||||
}
|
||||
|
||||
fun getEtiquetaValue() : String{
|
||||
return custom_dialog_etiquetas.text.toString()
|
||||
}
|
||||
|
||||
fun getEtiquetaItem() : TextInputEditText {
|
||||
return custom_dialog_etiquetas
|
||||
}
|
||||
|
||||
|
||||
fun setPackingValue(value : String) : CustomDialogUbicador{
|
||||
custom_dialog_packing.setText(value)
|
||||
custom_dialog_packing.visibility = View.VISIBLE
|
||||
return this
|
||||
}
|
||||
|
||||
fun getPackingValue() : String{
|
||||
return custom_dialog_packing.text.toString()
|
||||
}
|
||||
|
||||
fun getPackingItem() : TextInputEditText {
|
||||
return custom_dialog_packing
|
||||
}
|
||||
|
||||
fun setVisibleValue(value : String) : CustomDialogUbicador{
|
||||
custom_dialog_visible.setText(value)
|
||||
custom_dialog_visible.visibility = View.VISIBLE
|
||||
return this
|
||||
}
|
||||
|
||||
fun getVisibleValue() : String{
|
||||
return custom_dialog_visible.text.toString()
|
||||
}
|
||||
|
||||
fun getVisibleItem() : TextInputEditText {
|
||||
return custom_dialog_visible
|
||||
}
|
||||
|
||||
|
||||
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicador {
|
||||
custom_dialog_button_ok.visibility = View.VISIBLE
|
||||
custom_dialog_button_ok.text = text
|
||||
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }
|
||||
return this
|
||||
}
|
||||
|
||||
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicador {
|
||||
custom_dialog_button_ko.visibility = View.VISIBLE
|
||||
custom_dialog_button_ko.text = text
|
||||
custom_dialog_button_ko.setOnClickListener { onButtonClicked() }
|
||||
return this
|
||||
}
|
||||
|
||||
}
|
|
@ -4,20 +4,24 @@ import android.content.SharedPreferences
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentUbicadorBinding
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.component.CustomDialogUbicador
|
||||
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||
import es.verdnatura.presentation.view.feature.shelvingparking.adapter.ShelvingParkingAdapter
|
||||
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.fragment_buscar_item.*
|
||||
|
@ -37,9 +41,10 @@ class UbicadorFragment(
|
|||
private var warehouseFk = ""
|
||||
private var adapter : UbicadorAdapter? = null
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
private var listInvetory:ArrayList<ItemInventaryVO> = ArrayList()
|
||||
private var listInvetoryAux:ArrayList<ItemInventaryVO> = ArrayList()
|
||||
private lateinit var customDialogUbicador : CustomDialogUbicador
|
||||
private var listItems:ArrayList<ItemUbicadorVO> = ArrayList()
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private var deep:Int = 1
|
||||
|
||||
|
||||
companion object {
|
||||
|
@ -58,6 +63,7 @@ class UbicadorFragment(
|
|||
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
customDialog = CustomDialog(requireContext())
|
||||
customDialogUbicador = CustomDialogUbicador(requireContext())
|
||||
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||
toolbar_title.text = "itemShelvingList"
|
||||
setEvents()
|
||||
|
@ -72,12 +78,17 @@ class UbicadorFragment(
|
|||
|
||||
private fun setToolBar(){
|
||||
val listIcons:ArrayList<Drawable> = ArrayList()
|
||||
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme())
|
||||
val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme())
|
||||
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme())
|
||||
listIcons.add(iconAdd)
|
||||
listIcons.add(iconReload)
|
||||
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
|
||||
override fun onOptionsItemSelected(item: Drawable) {
|
||||
if (item == iconReload){
|
||||
|
||||
if (item == iconAdd){
|
||||
showAddItem()
|
||||
}else if(item == iconReload){
|
||||
splash_progress.visibility = View.VISIBLE
|
||||
viewModel.itemShelvingList(user,password,shelvingFk)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +106,7 @@ class UbicadorFragment(
|
|||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (!edit_matricula.text.toString().isNullOrEmpty()){
|
||||
toolbar_title.text = edit_matricula.text.toString()
|
||||
shelvingFk = edit_matricula.text.toString()
|
||||
splash_progress.visibility = View.VISIBLE
|
||||
viewModel.itemShelvingList(user,password,edit_matricula.text.toString())
|
||||
}
|
||||
|
@ -114,14 +126,83 @@ class UbicadorFragment(
|
|||
with(viewModel){
|
||||
loadShelvingList.observe(viewLifecycleOwner, Observer { event ->
|
||||
event.getContentIfNotHandled().notNull {
|
||||
deep = it.list.size
|
||||
listItems = ArrayList()
|
||||
it.list.forEach { item ->
|
||||
listItems.add(item)
|
||||
}
|
||||
splash_progress.visibility = View.GONE
|
||||
adapter = UbicadorAdapter(it.list)
|
||||
adapter = UbicadorAdapter(listItems)
|
||||
location_recyclerview.adapter = adapter
|
||||
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
response.observe(viewLifecycleOwner, Observer {
|
||||
if (it.isError){
|
||||
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
|
||||
customDialog.hide()
|
||||
}.show()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun showAddItem(){
|
||||
customDialogUbicador.setTitle("Nuevo item").setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("").setOkButton("Guardar"){
|
||||
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
|
||||
}.setKoButton("Cerrar"){
|
||||
customDialogUbicador.hide()
|
||||
}.show()
|
||||
|
||||
customDialogUbicador.getEditItem().requestFocus()
|
||||
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
|
||||
|
||||
customDialogUbicador.getVisibleItem().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
customDialogUbicador.getEtiquetaItem().setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun saveNewItem(itemFk:String,etiquetas:String,packing:String,visible:String){
|
||||
if (!packing.isNullOrEmpty()){
|
||||
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
|
||||
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1")
|
||||
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
|
||||
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
|
||||
customDialogUbicador.getEditItem().requestFocus()
|
||||
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
|
||||
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
|
||||
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
|
||||
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1")
|
||||
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
|
||||
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
|
||||
customDialogUbicador.getEditItem().requestFocus()
|
||||
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
|
||||
}else{
|
||||
"Rellena campos obligatorios".toast((activity as MainActivity), Toast.LENGTH_LONG)
|
||||
}
|
||||
}else{
|
||||
"Packing obligatorio".toast((activity as MainActivity), Toast.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeOfflineValue(item:ItemUbicadorVO){
|
||||
listItems.add(item)
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import es.verdnatura.domain.GetShelvingParkingUserCase
|
|||
import es.verdnatura.domain.GetUbicadorUserCase
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingListVO
|
||||
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
|
||||
|
@ -21,12 +22,14 @@ class UbicadorViewModel : BaseViewModel() {
|
|||
|
||||
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase()
|
||||
|
||||
|
||||
|
||||
private val _shelvingList by lazy { MutableLiveData<ItemUbicadorListVO>() }
|
||||
val shelvingList: LiveData<ItemUbicadorListVO>
|
||||
get() = _shelvingList
|
||||
|
||||
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val response: LiveData<ResponseItemVO>
|
||||
get() = _response
|
||||
|
||||
|
||||
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
|
||||
|
||||
|
@ -57,6 +60,23 @@ class UbicadorViewModel : BaseViewModel() {
|
|||
}
|
||||
|
||||
|
||||
fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String){
|
||||
getUbicadorUserCase.itemShelvingMake(usuario,password,shelving,item,deep,quantity,packing,warehouse,level).enqueue(object : Callback<String>{
|
||||
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!)
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||
if (response.body() == null){
|
||||
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMake")
|
||||
}else{
|
||||
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/DialogTheme"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/layout_margin_1"
|
||||
app:cardBackgroundColor="@color/verdnatura_black_8"
|
||||
app:cardCornerRadius="@dimen/dialog_radius">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/default_layout_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_dialog_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/layout_margin_min"
|
||||
android:layout_marginBottom="@dimen/layout_margin_min"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/h6"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:text="¿Estás seguro de que deseas eliminar el dispositivo de celia?"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textinputlayout_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:layout_marginTop="@dimen/default_layout_margin">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/custom_dialog_item"
|
||||
style="@style/InputLineTextSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:backgroundTint="@android:color/white"
|
||||
android:hint="ItemFk"
|
||||
android:inputType="number"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textColorHint="@android:color/darker_gray" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textinputlayout_packing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:layout_marginTop="@dimen/default_layout_margin">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/custom_dialog_packing"
|
||||
style="@style/InputLineTextSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:backgroundTint="@android:color/white"
|
||||
android:hint="Packing"
|
||||
android:inputType="number"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textColorHint="@android:color/darker_gray" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textinputlayout_etiquetas"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:layout_marginTop="@dimen/default_layout_margin">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/custom_dialog_etiquetas"
|
||||
style="@style/InputLineTextSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:backgroundTint="@android:color/white"
|
||||
android:hint="Etiquetas"
|
||||
android:inputType="number"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textColorHint="@android:color/darker_gray" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textinputlayout_visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:layout_marginTop="@dimen/default_layout_margin">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/custom_dialog_visible"
|
||||
style="@style/InputLineTextSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:backgroundTint="@android:color/white"
|
||||
android:hint="Visible"
|
||||
android:inputType="number"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textColorHint="@android:color/darker_gray" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/custom_dialog_button_ok"
|
||||
style="@style/DefaultButton.NormalButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="@dimen/default_layout_margin"
|
||||
android:visibility="gone"
|
||||
tools:text="Eliminar"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/custom_dialog_button_ko"
|
||||
style="@style/DefaultButton.TransparentButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="@dimen/default_layout_margin"
|
||||
android:layout_marginBottom="@dimen/default_layout_margin"
|
||||
android:visibility="gone"
|
||||
tools:text="Cancelar"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
Loading…
Reference in New Issue