refs #5652 add dynamic buttons for mermas
This commit is contained in:
parent
8f978b2c5c
commit
00030ae266
|
@ -1,6 +1,7 @@
|
|||
package es.verdnatura.presentation.common
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.widget.TextView
|
||||
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||
|
@ -9,6 +10,7 @@ import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
|
|||
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo
|
||||
import es.verdnatura.presentation.view.feature.delivery.model.Ticket
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
|
||||
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking
|
||||
import es.verdnatura.presentation.view.feature.login.model.WorkForms
|
||||
|
@ -62,6 +64,10 @@ interface OnItemButtonTicketRowClickListener {
|
|||
fun onItemButtonTicketRowClickListener(item: ClientTicket, action: String)
|
||||
}
|
||||
|
||||
interface OnItemButtonCMRRowClickListener {
|
||||
fun onItemButtonCMRRowClickListener(item: Ticket)
|
||||
}
|
||||
|
||||
interface OnAddressRowClickListener {
|
||||
fun onAddressRowClickListener(item: ExpeditionInfoSummary)
|
||||
}
|
||||
|
@ -189,3 +195,7 @@ interface onVehicleSelected {
|
|||
fun onVehicleClick(userFk: String)
|
||||
}
|
||||
|
||||
interface OnClickDynamic {
|
||||
fun onClickDynamic(addressFK: Int)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package es.verdnatura.presentation.view.component
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.ComponentCustomDynamicDialogBinding
|
||||
import es.verdnatura.presentation.common.OnClickDynamic
|
||||
import es.verdnatura.presentation.common.setMargins
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses
|
||||
|
||||
class CustomDialogDynamicButtons(context: Context, private val onClickDynamic: OnClickDynamic) : Dialog(context, R.style.DialogTheme) {
|
||||
|
||||
private var binding: ComponentCustomDynamicDialogBinding =
|
||||
ComponentCustomDynamicDialogBinding.inflate(layoutInflater)
|
||||
|
||||
|
||||
init {
|
||||
setContentView(binding.root)
|
||||
|
||||
}
|
||||
|
||||
fun setTitle(title: String): CustomDialogDynamicButtons {
|
||||
|
||||
binding.customDialogTitle.visibility = View.VISIBLE
|
||||
binding.customDialogTitle.text = title
|
||||
return this
|
||||
}
|
||||
|
||||
fun setDescription(description: String): CustomDialogDynamicButtons {
|
||||
|
||||
binding.customDialogDescription.visibility = View.VISIBLE
|
||||
binding.customDialogDescription.text = description
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
fun createDynamicButtons(buttonInfoList: List<AddressLoses>) {
|
||||
for (buttonInfo in buttonInfoList) {
|
||||
setDynamicButton(buttonInfo.nickname,buttonInfo.addressFk)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
private fun setDynamicButton(buttonText: String, addressFk: Int) {
|
||||
|
||||
val button = Button(ContextThemeWrapper(context, R.style.DefaultButton_DynamicButton))
|
||||
button.text = buttonText
|
||||
|
||||
val layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, // anchura
|
||||
context.resources.getDimensionPixelSize(R.dimen.layout_height_dynamic) // altura
|
||||
)
|
||||
button.layoutParams = layoutParams
|
||||
|
||||
val paddingStart =
|
||||
context.resources.getDimensionPixelSize(R.dimen.padding_start_dynamic)
|
||||
val paddingEnd =
|
||||
context.resources.getDimensionPixelSize(R.dimen.padding_end_dynamic)
|
||||
val marginTop = context.resources.getDimensionPixelSize(R.dimen.margin_top_dynamic)
|
||||
val marginBottom =
|
||||
context.resources.getDimensionPixelSize(R.dimen.margin_bottom_dynamic)
|
||||
button.setPaddingRelative(paddingStart, 0, paddingEnd, 0)
|
||||
button.setMargins(0, marginTop, 0, marginBottom)
|
||||
button.text
|
||||
|
||||
val attrs = intArrayOf(android.R.attr.textColor, android.R.attr.background)
|
||||
val typedArray: TypedArray =
|
||||
context.obtainStyledAttributes(R.style.DefaultButton_DynamicButton, attrs)
|
||||
button.setTextColor(typedArray.getColor(0, 0))
|
||||
button.setBackgroundResource(typedArray.getResourceId(1, 0))
|
||||
|
||||
typedArray.recycle()
|
||||
button.setOnClickListener {
|
||||
onClickDynamic.onClickDynamic(addressFk)
|
||||
}
|
||||
val buttonContainer = binding.layoutButtons
|
||||
buttonContainer.addView(button)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -17,11 +17,13 @@ import es.verdnatura.R
|
|||
import es.verdnatura.databinding.FragmentItemCardBinding
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.*
|
||||
import es.verdnatura.presentation.view.component.CustomDialogDynamicButtons
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||
import es.verdnatura.presentation.view.component.CustomDialogTwoButtons
|
||||
import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
|
||||
import es.verdnatura.presentation.view.feature.articulo.adapter.ItemCardAdapter
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||
|
@ -31,7 +33,8 @@ import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
|||
|
||||
class ItemCardFragment(
|
||||
var itemFk: String = ""
|
||||
) : BaseFragment<FragmentItemCardBinding, ItemCardViewModel>(ItemCardViewModel::class) {
|
||||
) : BaseFragment<FragmentItemCardBinding, ItemCardViewModel>(ItemCardViewModel::class),
|
||||
OnClickDynamic {
|
||||
|
||||
private var urlLarge: String = ""
|
||||
private var titleImage: String = ""
|
||||
|
@ -113,6 +116,7 @@ class ItemCardFragment(
|
|||
iconReload.drawable -> {
|
||||
getItemCard(itemInfoG!!.id.toString())
|
||||
}
|
||||
|
||||
iconHistory.drawable -> {
|
||||
|
||||
ma.onPasillerosItemClickListener(
|
||||
|
@ -122,6 +126,7 @@ class ItemCardFragment(
|
|||
|
||||
|
||||
}
|
||||
|
||||
iconSalix.drawable -> {
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
var itemId = itemInfoG!!.id
|
||||
|
@ -159,13 +164,19 @@ class ItemCardFragment(
|
|||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
if (!binding.editItemFk.text.toString().isNullOrEmpty())
|
||||
//Tarea#5109
|
||||
try {
|
||||
getItemCard(itemScanValue(binding.editItemFk.text.toString(),"buy","more").toString())
|
||||
}catch (Ex:Exception){
|
||||
ma.messageWithSound(Ex.message.toString(), true,true)
|
||||
}
|
||||
try {
|
||||
getItemCard(
|
||||
itemScanValue(
|
||||
binding.editItemFk.text.toString(),
|
||||
"buy",
|
||||
"more"
|
||||
).toString()
|
||||
)
|
||||
} catch (Ex: Exception) {
|
||||
ma.messageWithSound(Ex.message.toString(), true, true)
|
||||
}
|
||||
|
||||
// getItemCard(binding.editItemFk.text.toString())
|
||||
// getItemCard(binding.editItemFk.text.toString())
|
||||
binding.editItemFk.setText("")
|
||||
ma.hideKeyboard(binding.editItemFk)
|
||||
return@setOnEditorActionListener true
|
||||
|
@ -197,7 +208,7 @@ class ItemCardFragment(
|
|||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
itemcard.observe(viewLifecycleOwner, Observer {
|
||||
itemcard.observe(viewLifecycleOwner, Observer {
|
||||
|
||||
if (it.isError) {
|
||||
binding.itemcardLayout.visibility = GONE
|
||||
|
@ -241,6 +252,17 @@ class ItemCardFragment(
|
|||
}
|
||||
|
||||
})
|
||||
addressLosesList.observe(viewLifecycleOwner, Observer {
|
||||
binding.splashProgress.visibility = GONE
|
||||
if (it.list.isEmpty()) {
|
||||
ma.messageWithSound(getString(R.string.empty), true, false)
|
||||
} else {
|
||||
showDialogTrashFault(it.list)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,6 +496,7 @@ class ItemCardFragment(
|
|||
false
|
||||
}
|
||||
} else if (item.action == "itemStockUpdateRemove") {
|
||||
println("Vamos a indicar la cantidad a falta/basura")
|
||||
customDialogInput.setTitle(item.title!!)
|
||||
.setDescription(getString(R.string.quantityToUnregister))
|
||||
.setOkButton(getString(R.string.save)) {
|
||||
|
@ -525,20 +548,23 @@ class ItemCardFragment(
|
|||
"itemStockUpdateAdd" -> prepareItemStockUpdate2(item, value)
|
||||
"itemStockUpdateRemove" -> prepareItemStockUpdate2(item, value)
|
||||
"updateGrouping" ->
|
||||
viewModel.updateGrouping(
|
||||
itemFk = itemInfoG!!.id,
|
||||
value = value,
|
||||
warehouseFk = warehouseFk!!
|
||||
)
|
||||
viewModel.updateGrouping(
|
||||
itemFk = itemInfoG!!.id,
|
||||
value = value,
|
||||
warehouseFk = warehouseFk!!
|
||||
)
|
||||
|
||||
"updatePacking" -> viewModel.updatePacking(
|
||||
itemFk = itemInfoG!!.id,
|
||||
value = value,
|
||||
warehouseFk = warehouseFk!!
|
||||
)
|
||||
|
||||
"itemSaveStem" -> viewModel.item_saveStems(
|
||||
itemFk = itemInfoG!!.id,
|
||||
value = value
|
||||
)
|
||||
|
||||
"item_saveReference" -> viewModel.item_saveReference(
|
||||
itemFk = itemInfoG!!.id,
|
||||
value = value
|
||||
|
@ -558,58 +584,79 @@ class ItemCardFragment(
|
|||
}
|
||||
|
||||
private fun prepareItemStockUpdate2(itemB: ItemCardRowVO, value: Int) {
|
||||
try {
|
||||
value.toInt()
|
||||
|
||||
if (itemB.action == "itemStockUpdateRemove") {
|
||||
customDialogTwo.setTitle(itemB.title!!)
|
||||
.setDescription(getString(R.string.deleteStock))
|
||||
.setOkButton(getString(R.string.fault)) {
|
||||
viewModel.itemTrash(
|
||||
itemFk = itemInfoG!!.id,
|
||||
warehouseFk = warehouseFk!!,
|
||||
newValue = value,
|
||||
isTrash = false
|
||||
//Tarea 5652 , quitar código cuando está asignada tarea
|
||||
var test = false
|
||||
if (test) {
|
||||
println("Vamos a getAddress")
|
||||
binding.splashProgress.visibility = View.VISIBLE
|
||||
viewModel.getAddressLoses()
|
||||
} else {
|
||||
try {
|
||||
value.toInt()
|
||||
|
||||
)
|
||||
//changeOfflineValue(itemB,value, listBarcodes)
|
||||
showProgress()
|
||||
customDialogTwo.dismiss()
|
||||
if (itemB.action == "itemStockUpdateRemove") {
|
||||
|
||||
}.setOkButtonTwo(getString(R.string.trash)) {
|
||||
viewModel.itemTrash(
|
||||
itemFk = itemInfoG!!.id,
|
||||
warehouseFk = warehouseFk!!,
|
||||
newValue = value,
|
||||
isTrash = true
|
||||
customDialogTwo.setTitle(itemB.title!!)
|
||||
.setDescription(getString(R.string.deleteStock))
|
||||
.setOkButton(getString(R.string.fault)) {
|
||||
viewModel.itemTrash(
|
||||
itemFk = itemInfoG!!.id,
|
||||
warehouseFk = warehouseFk!!,
|
||||
newValue = value,
|
||||
isTrash = false
|
||||
|
||||
)
|
||||
//changeOfflineValue(itemB,value, listBarcodes)
|
||||
showProgress()
|
||||
customDialogTwo.dismiss()
|
||||
)
|
||||
//changeOfflineValue(itemB,value, listBarcodes)
|
||||
showProgress()
|
||||
customDialogTwo.dismiss()
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
}.setOkButtonTwo(getString(R.string.trash)) {
|
||||
viewModel.itemTrash(
|
||||
itemFk = itemInfoG!!.id,
|
||||
warehouseFk = warehouseFk!!,
|
||||
newValue = value,
|
||||
isTrash = true
|
||||
|
||||
customDialogTwo.dismiss()
|
||||
}.show()
|
||||
} else {
|
||||
//changeOfflineValue(itemB,value, listBarcodes)
|
||||
showProgress()
|
||||
viewModel.itemTrash(
|
||||
itemFk = itemInfoG!!.id,
|
||||
warehouseFk = warehouseFk!!,
|
||||
newValue = (value * -1),
|
||||
isTrash = false
|
||||
)
|
||||
|
||||
showProgress()
|
||||
customDialogTwo.dismiss()
|
||||
|
||||
}.setKoButton(getString(R.string.cancel)) {
|
||||
|
||||
customDialogTwo.dismiss()
|
||||
}.show()
|
||||
|
||||
} else {
|
||||
|
||||
showProgress()
|
||||
viewModel.itemTrash(
|
||||
itemFk = itemInfoG!!.id,
|
||||
warehouseFk = warehouseFk!!,
|
||||
newValue = (value * -1),
|
||||
isTrash = false
|
||||
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// binding.itemcardLayout.visibility = View.GONE
|
||||
ma.messageWithSound(getString(R.string.errorNotNumber), true, true)
|
||||
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// binding.itemcardLayout.visibility = View.GONE
|
||||
ma.messageWithSound(getString(R.string.errorNotNumber), true, true)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialogTrashFault(listAddress: List<AddressLoses>) {
|
||||
|
||||
val customDynamic =
|
||||
CustomDialogDynamicButtons(requireContext(), this)// Instancia de tu customDialogTwo
|
||||
customDynamic.setTitle("")
|
||||
customDynamic.setDescription(getString(R.string.deleteStock))
|
||||
customDynamic.createDynamicButtons(listAddress)
|
||||
customDynamic.show()
|
||||
}
|
||||
|
||||
private fun prepareBarcodeDialog(itemB: ItemCardRowVO) {
|
||||
|
||||
customDialogList.setTitle(getString(R.string.barcodes))
|
||||
|
@ -708,6 +755,10 @@ class ItemCardFragment(
|
|||
)
|
||||
}
|
||||
|
||||
override fun onClickDynamic(addressFK: Int) {
|
||||
println("Acabas de pulsar" + addressFK)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import es.verdnatura.presentation.common.Event
|
|||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
import es.verdnatura.presentation.common.itemBarCodeSalix
|
||||
import es.verdnatura.presentation.common.itemPackingTypeSalix
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.AddressLosesList
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList
|
||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposal
|
||||
|
@ -43,6 +45,10 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
val itemProposallist: LiveData<ItemProposalList>
|
||||
get() = _itemProposallist
|
||||
|
||||
private val _addressLosesList by lazy { MutableLiveData<AddressLosesList>() }
|
||||
val addressLosesList: LiveData<AddressLosesList>
|
||||
get() = _addressLosesList
|
||||
|
||||
|
||||
fun getItemCard(
|
||||
itemFk: Number,
|
||||
|
@ -343,6 +349,21 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun getAddressLoses(
|
||||
|
||||
) {
|
||||
|
||||
val mermaRecords = listOf(
|
||||
AddressLoses(77, "MERMA: CONTENEDOR", "BASURA"),
|
||||
AddressLoses(317, "MERMA: FALTAS", "FALTAS"),
|
||||
AddressLoses(1535, "MERMA: FALTAS (INVENTARIO)", "FALTAS"),
|
||||
AddressLoses(2230, "MERMA: RECLAMACION BASURA", "BASURA"),
|
||||
AddressLoses(7475, "MERMA: RECLAMACION TALLER", "BASURA"),
|
||||
AddressLoses(43432, "MERMA: TRANSPORTE", "BASURA")
|
||||
)
|
||||
println("Vamos a a lista")
|
||||
_addressLosesList.value= AddressLosesList(mermaRecords)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,4 +28,15 @@ class ItemProposal(
|
|||
|
||||
class ItemProposalList(
|
||||
var list: List<ItemProposal> = listOf()
|
||||
)
|
||||
)
|
||||
|
||||
class AddressLosesList(
|
||||
var list: List<AddressLoses> = listOf()
|
||||
)
|
||||
|
||||
data class AddressLoses(
|
||||
val addressFk: Int,
|
||||
val nickname: String,
|
||||
val name: String
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?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_3"
|
||||
android:layout_marginBottom="@dimen/default_layout_margin"
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_dialog_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/verdnatura_white"
|
||||
android:textSize="@dimen/body1"
|
||||
android:visibility="gone"
|
||||
tools:text="Este cambio no podrá deshacerse a no ser que vuelvas a vincular el dispositivo"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutButtons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
android:orientation="vertical"></LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
|
@ -21,6 +21,13 @@
|
|||
<dimen name="layout_margin_8">72dp</dimen>
|
||||
<dimen name="layout_margin_12">104dp</dimen>
|
||||
|
||||
<dimen name="layout_margin_min_dynamic">64dp</dimen>
|
||||
<dimen name="layout_height_dynamic">36dp</dimen>
|
||||
<dimen name="padding_start_dynamic">16dp</dimen>
|
||||
<dimen name="padding_end_dynamic">16dp</dimen>
|
||||
<dimen name="margin_top_dynamic">8dp</dimen>
|
||||
<dimen name="margin_bottom_dynamic">8dp</dimen>
|
||||
|
||||
<!--Bottom navigation-->
|
||||
<dimen name="bottom_navigation_height">56dp</dimen>
|
||||
|
||||
|
|
Loading…
Reference in New Issue