refs #6004 feature:dataStoreByPreference

This commit is contained in:
Sergio De la torre 2024-01-30 09:50:15 +01:00
parent d0d4889a16
commit 787c6b1b79
3 changed files with 38 additions and 15 deletions

View File

@ -13,6 +13,8 @@ import com.google.gson.Gson
import es.verdnatura.MobileApplication
import es.verdnatura.R
import es.verdnatura.domain.ConstAndValues
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
import es.verdnatura.domain.ConstAndValues.BASE_URL_SALIX
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
import es.verdnatura.domain.ConstAndValues.PRINTERFK
import es.verdnatura.domain.ConstAndValues.PRINTERFKDEFAULT
@ -101,7 +103,13 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
String::class -> runBlocking {
mobileApplication.dataStore.data
.map { preferences -> preferences[stringPreferencesKey(key)] ?: "" }
.map { preferences ->
preferences[stringPreferencesKey(key)] ?: if (key == BASEURLSALIX) {
BASE_URL_SALIX
} else {
""
}
}
.first() as T
}

View File

@ -143,6 +143,7 @@ class CollectionFragmentPreChecker(
}
if (collection.tickets.isEmpty()) {
viewModel.collectionTicketGet(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
@ -533,7 +534,9 @@ class CollectionFragmentPreChecker(
it.isError, true
)
} else {
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(PRINTERNAME)).toast(
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME
)).toast(
requireContext()
)
}
@ -634,7 +637,6 @@ class CollectionFragmentPreChecker(
type
)
}
}
// }
@ -1029,10 +1031,10 @@ class CollectionFragmentPreChecker(
sales = salesList.sortedWith(compareBy({ it.saleOrder }))
if (type == CONTROLADOR || type == PRECHECKER) {
//Tarea5734
if (salesList.filter { it.sectorFk != null && it.sectorFk!! > 0 }.isNotEmpty()) {
sales = salesList.filter { it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK) }
.sortedWith(compareBy({ it.picked }))
sales = salesList.filter { it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey<Int>(SECTORFK)
}.sortedWith(compareBy({ it.picked }))
} else {
sales = salesList.sortedWith(compareBy({ it.picked }))
}
@ -1105,9 +1107,11 @@ class CollectionFragmentPreChecker(
var entryPoint = Gson().toJson(
mutableMapOf(
"entryPoint" to sale.ticketFk,
"web" to "${mobileApplication.dataStoreApp.readDataStoreKey<String>(
BASEURLSALIX
)}/#!/ticket/${sale.ticketFk}/sale"
"web" to "${
mobileApplication.dataStoreApp.readDataStoreKey<String>(
BASEURLSALIX
)
}/#!/ticket/${sale.ticketFk}/sale"
)
)
ma.onPasillerosItemClickListener(
@ -1457,7 +1461,7 @@ class CollectionFragmentPreChecker(
//tarea #4628, se asigna storedBackPosition
storedBackPosition = position
if (type == SACADOR || mobileApplication.dataStoreApp.readDataStoreKey<String>(
if (type == SACADOR || mobileApplication.dataStoreApp.readDataStoreKey<String>(
SECTORDESCRIP
).uppercase() == getString(
R.string.sectorALGEMESINEW
@ -1466,7 +1470,7 @@ class CollectionFragmentPreChecker(
) {
var myPosition = position
if (type == CONTROLADOR && mobileApplication.dataStoreApp.readDataStoreKey<String>(
if (type == CONTROLADOR && mobileApplication.dataStoreApp.readDataStoreKey<String>(
SECTORDESCRIP
).uppercase() == getString(
R.string.sectorALGEMESINEW
@ -1966,7 +1970,7 @@ class CollectionFragmentPreChecker(
itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
)
@ -2032,7 +2036,9 @@ class CollectionFragmentPreChecker(
itemFk = customDialogList.getValue().toInt(),
ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo().toInt(),
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
warehouseFk = mobileApplication.dataStoreApp.readDataStoreKey(
WAREHOUSEFK
)
)
scanRequest()
customDialogList.dismiss()
@ -2123,7 +2129,7 @@ class CollectionFragmentPreChecker(
private fun ticketCollection_setUsedShelves() {
var sectorDescrip = mobileApplication.dataStoreApp.readDataStoreKey<String>(
var sectorDescrip = mobileApplication.dataStoreApp.readDataStoreKey<String>(
SECTORDESCRIP
)
@ -2386,7 +2392,9 @@ class CollectionFragmentPreChecker(
collectionFk = collection.collectionFk,
labelCount = (which + 1)
)
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(PRINTERNAME)).toast(requireContext())
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
PRINTERNAME
)).toast(requireContext())
}
val dialog = builder.create()

View File

@ -94,6 +94,13 @@ class LoginFragment(var imageUri: Uri?) :
mobileApplication.dataStoreApp.editDataStoreKey(
WORKFORMSELECTED, "Producción"
)
mobileApplication.dataStoreApp.saveWorkForm(
WorkForms(
"Producción",
"https://app.verdnatura.es",
"https://salix.verdnatura.es"
)
)
}
}
binding.edittextServer.setText(