TP-37435 : automated fill call parameters for widget outputs (#10044)

This commit is contained in:
Naman Khurmi
2024-03-12 13:54:17 +05:30
committed by GitHub
parent 0c742a170e
commit edac6d0af1
7 changed files with 25 additions and 2 deletions

View File

@@ -53,6 +53,7 @@ fun HandleApiAction(viewModel: ApplicationPlatformVM, activity: ApplicationPlatf
val queryMap = viewModel.getQueryMap()
when (action) {
is FillApiAction -> {
val widgetOutputFields = viewModel.fillApiDataMap[action.fillApiLabel]
var screenRequest: ScreenRequest? = null
if (action.isPartialFillCall.orFalse().not()) {
screenRequest =
@@ -67,7 +68,7 @@ fun HandleApiAction(viewModel: ApplicationPlatformVM, activity: ApplicationPlatf
)
}
fillApplication(
fields = action.fields,
fields = action.fields?.plus(widgetOutputFields.orEmpty()),
viewModel = viewModel,
screenRequest = screenRequest,
isPartialFillCall = action.isPartialFillCall.orFalse(),
@@ -106,8 +107,9 @@ fun HandleApiAction(viewModel: ApplicationPlatformVM, activity: ApplicationPlatf
action.isPartialFillCallExecuted.not() &&
action.areFieldsNotNullAndNotEmpty(viewModel.handle)
) {
val widgetOutputFields = viewModel.fillApiDataMap[action.fillApiLabel]
fillApplication(
fields = action.fields,
fields = action.fields?.plus(widgetOutputFields.orEmpty()),
viewModel = viewModel,
screenRequest = null,
isPartialFillCall = true,

View File

@@ -34,6 +34,7 @@ data class WidgetOutput(
val fieldName: String? = null,
val layoutId: String? = null,
val keySuffix: String? = null,
val fillApiLabels: List<String>? = null
)
data class WidgetEvent(val eventName: String? = null, val stateId: String? = null)

View File

@@ -71,6 +71,7 @@ import com.navi.common.constants.API_SUCCESS_CODE
import com.navi.common.network.ApiConstants
import com.navi.common.uitron.model.action.AnalyticsActionV2
import com.navi.common.uitron.model.action.AnalyticsActionV2.PredefinedEventProperty
import com.navi.common.uitron.model.action.FillApiData
import com.navi.common.utils.Constants.APP_PLATFORM_APPLICATION_ID
import com.navi.common.utils.Constants.APP_PLATFORM_APPLICATION_TYPE
import com.navi.common.utils.Constants.LOGOUT
@@ -102,6 +103,8 @@ abstract class ApplicationPlatformVM(
private var queryMap: MutableMap<String, String?> = mutableMapOf()
private var bottomSheetQueryMap: MutableMap<String, String?> = mutableMapOf()
val fillApiDataMap: MutableMap<String, MutableList<FillApiData>?> = mutableMapOf()
private val _isScreenRendered = MutableStateFlow(false)
val isScreenRendered = _isScreenRendered.asStateFlow()

View File

@@ -17,6 +17,7 @@ import com.navi.ap.common.usecase.UpdateShouldPollStrategyUseCase
import com.navi.ap.common.viewmodel.ApplicationPlatformVM
import com.navi.ap.domain.repository.ApplicationPlatformRepository
import com.navi.ap.utils.EventUtil
import com.navi.ap.utils.buildFillParametersUsingWidgetOutput
import com.navi.ap.utils.constants.SCREEN_VISIBILITY
import com.navi.ap.utils.initWidgetMetaDataAndActions
import com.navi.base.utils.orFalse
@@ -123,6 +124,7 @@ constructor(
widget?.widgetOutput?.forEach {
if (it.fieldName.isNullOrEmpty()) return@forEach
handle[it.fieldName] = it.layoutId
buildFillParametersUsingWidgetOutput(it, fillApiDataMap)
}
widget?.widgetEventListeners?.forEach {
if (it.eventName.isNullOrEmpty() || it.stateId.isNullOrEmpty()) return@forEach

View File

@@ -22,6 +22,7 @@ import com.google.gson.Gson
import com.jayway.jsonpath.JsonPath
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.ap.common.models.ApScreenDefinitionStructure
import com.navi.ap.common.models.WidgetOutput
import com.navi.ap.common.ui.ApplicationPlatformActivity
import com.navi.ap.network.di.APNetworkModule.providesDeserializer
import com.navi.ap.network.di.APNetworkModule.providesSerializer
@@ -300,3 +301,15 @@ fun getEncodedString(str: String, flag: Int = Base64.DEFAULT): String? {
null
}
}
fun buildFillParametersUsingWidgetOutput(
widgetOutput: WidgetOutput,
fillCallMap: MutableMap<String, MutableList<FillApiData>?>?
) {
widgetOutput.fillApiLabels?.forEach { fillCallId ->
val fillApiDataList = fillCallMap?.getOrPut(fillCallId) { mutableListOf() }
fillApiDataList?.add(
FillApiData(name = widgetOutput.fieldName, source = SourceType.WIDGET_OUTPUT.name)
)
}
}

View File

@@ -16,6 +16,7 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class PartialFillCallAction(
@SerializedName("fillApiLabel") val fillApiLabel: String? = null,
@SerializedName("fields") val fields: List<FillApiData>? = null,
var isPartialFillCallExecuted: Boolean = false,
var needMultipleExecutions: Boolean = false

View File

@@ -19,6 +19,7 @@ class GetApplicationIdApiAction() : TriggerApiAction()
class GetScreenDefinitionApiAction() : TriggerApiAction()
open class FillApiAction(
@SerializedName("fillApiLabel") val fillApiLabel: String? = null,
@SerializedName("fields") val fields: List<FillApiData>? = null,
@SerializedName("isPartialFillCall") val isPartialFillCall: Boolean? = null
) : TriggerApiAction()