Commit f5577c2b authored by Roshan Patil's avatar Roshan Patil
Browse files

Dynamic from changes

parent cf4c6f51
Branches
Tags
1 merge request!68Core dev bto c
Showing with 24 additions and 20 deletions
......@@ -27,6 +27,7 @@ func dynamicFormEvalution(ab *servicebuildermdl.AbstractBusinessLogicHolder, rs
if eval == nil {
return nil, nil
}
configs := rs.Get("conditions").Array()
if rs.String() == "" || len(configs) == 0 {
return nil, nil
......@@ -36,27 +37,24 @@ func dynamicFormEvalution(ab *servicebuildermdl.AbstractBusinessLogicHolder, rs
loggermdl.LogError("No current page found")
return nil, errormdl.Wrap("No current page found")
}
nextNoConditionPage := gjson.Result{}
currentPageIsNoCondition := false
currentPageIndex := -1
isCurrentPageIsNC := false
isEndPage := false
endPageObj := gjson.Result{}
for _, obj := range configs {
for i, obj := range configs {
condition := obj.Get("condition").String()
pageID := obj.Get("pageID").String()
noCondition := obj.Get("noCondition").Bool()
if noCondition {
if currentPageIsNoCondition {
nextNoConditionPage = obj
currentPageIsNoCondition = false
if pageID == currentPage {
isEndPage = obj.Get("isEndPage").Bool()
if isEndPage {
endPageObj = obj
}
if pageID == currentPage {
currentPageIsNoCondition = true
isEndPage = obj.Get("isEndPage").Bool()
if isEndPage {
endPageObj = obj
}
if noCondition {
isCurrentPageIsNC = true
}
currentPageIndex = i
continue
}
var expr conditions.Expr
......@@ -95,10 +93,16 @@ func dynamicFormEvalution(ab *servicebuildermdl.AbstractBusinessLogicHolder, rs
if isEndPage {
return endPageObj.Value(), nil
}
if nextNoConditionPage.String() != "" {
return nextNoConditionPage.Value(), nil
}
for i, obj := range configs {
if isCurrentPageIsNC && i <= currentPageIndex {
continue
}
noCondition := obj.Get("noCondition").Bool()
if noCondition {
return obj.Value(), nil
}
}
ab.SetErrorCode(errormdl.NEXTFORMEVALERROR)
return nil, errormdl.Wrap("NO CONDITION MATCHED")
}
......@@ -68,7 +68,6 @@ func executeService(name string, data []byte, isForm bool, formData *multipart.F
service, found = openServices.Get(name)
}
if !found {
// ab.SetErrorCode(errormdl.SERVICENOTFOUND)
loggermdl.LogError("Service Not Found: " + name)
return nil, nextDynamicPage, ab, isCompressed, errormdl.SERVICENOTFOUND, errormdl.Wrap("Service Not Found: " + name)
}
......@@ -138,10 +137,11 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased bool, principalObj
if errormdl.CheckErr1(err) != nil {
if ab == nil {
responseDataObj.ErrorCode = errorCode
responseDataObj.Error = err.Error()
} else {
responseDataObj.Error = ab.GetErrorData()
if responseDataObj.Error == nil {
responseDataObj.Error = errormdl.CheckErr3(err).Error()
responseDataObj.Error = err.Error()
}
errorCode := ab.GetErrorCode()
if errorCode == 0 {
......
......@@ -53,7 +53,7 @@ func GetRestrictedServicePtr(serviceName string) (ServiceType, error) {
}
serviceCache, ok := intService.(ServiceCache)
if !ok {
return nil, errormdl.Wrap("Service Not Ca")
return nil, errormdl.Wrap("Service Not Casted")
}
return serviceCache.Service, nil
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment