Skip to content

Commit

Permalink
Merge pull request #3744 from illacloud/release/4.5.14
Browse files Browse the repository at this point in the history
Release/4.5.14
  • Loading branch information
AruSeito authored Mar 5, 2024
2 parents 97d65d2 + bf51ff3 commit 79e6852
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 28 deletions.
2 changes: 1 addition & 1 deletion apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"author": "ILLA Cloud <[email protected]>",
"license": "Apache-2.0",
"version": "4.5.12",
"version": "4.5.14",
"scripts": {
"dev": "vite --strictPort --force",
"build-cloud": "NODE_OPTIONS=--max-old-space-size=12288 vite build --mode cloud",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const BaseDataItem: FC<BaseDataItemProps> = (props) => {
>
{value.$childrenNode.map((item, index) => {
if (value.$widgetType === "CONTAINER_WIDGET") {
if (!(value.viewList as ViewItemShape[])[index]) return null
return (
<BaseDataItem
key={item.displayName}
Expand Down
24 changes: 24 additions & 0 deletions apps/builder/src/utils/componentNode/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { executionActions } from "@/redux/currentApp/executionTree/executionSlic
import { getClientWidgetLayoutInfo } from "@/redux/currentApp/layoutInfo/layoutInfoSelector"
import { WidgetLayoutInfo } from "@/redux/currentApp/layoutInfo/layoutInfoState"
import store from "@/store"
import { RawTreeShape } from "../executionTreeHelper/interface"

export const searchForefatherSectionNodeDisplayName = (
currentDisplayName: string,
Expand Down Expand Up @@ -148,3 +149,26 @@ export const autoChangeWhenClickOnCanvas = (canvasDisplayName: string) => {
)
return firstChildDisplayName
}

export const isWidgetInGridListOrList = (
tree: RawTreeShape,
currentDisplayName: string,
) => {
const search = (currentDisplayName: string): boolean => {
const currentWidget = tree[currentDisplayName]
const parentDisplayName = currentWidget.$parentNode
const parentNode = parentDisplayName ? tree[parentDisplayName] : null
if (!parentNode) {
return false
}
if (
parentNode.$widgetType === "GRID_LIST_WIDGET" ||
parentNode.$widgetType === "LIST_WIDGET"
) {
return true
} else {
return search(parentDisplayName)
}
}
return search(currentDisplayName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
IExecutionActions,
runActionWithExecutionResult,
} from "../action/runAction"
import { isWidgetInGridListOrList } from "../componentNode/search"

const message = createMessage()

Expand Down Expand Up @@ -130,6 +131,11 @@ export class ExecutionTreeFactory {
if (!isWidget(widgetOrAction) && !isAction(widgetOrAction)) {
return current
}
let isWidgetInLikeList = false
if (widgetOrAction && isWidget(widgetOrAction)) {
isWidgetInLikeList = isWidgetInGridListOrList(current, displayName)
}

const validationPaths = widgetOrAction.$validationPaths
const listWidgets =
getContainerListDisplayNameMappedChildrenNodeDisplayName(
Expand All @@ -154,11 +160,25 @@ export class ExecutionTreeFactory {
const fullPath = `${displayName}.${validationPath}`
const validationFunc = validationFactory[validationType]
const value = get(widgetOrAction, validationPath)

const { isValid, safeValue, errorMessage } = validationFunc(
value,
currentListDisplayName,
)
set(current, fullPath, safeValue)

if (
isWidgetInLikeList &&
Array.isArray(safeValue) &&
validationType === VALIDATION_TYPES.ARRAY
) {
if (Array.isArray(safeValue[0])) {
set(current, fullPath, safeValue[0])
} else {
set(current, fullPath, safeValue)
}
} else {
set(current, fullPath, safeValue)
}
let error = validateErrors[fullPath]
if (!isValid) {
if (!Array.isArray(error)) {
Expand Down Expand Up @@ -409,11 +429,24 @@ export class ExecutionTreeFactory {
path,
updatePathMapAction,
)

const originUpdateKeys = Object.keys(updatePathMapAction)
Object.keys(mergedUpdatePathMapAction).forEach((key) => {
if (originUpdateKeys.includes(key)) {
return
}
const originValue = get(this.oldRawTree, key)
if (hasDynamicStringSnippet(originValue)) {
set(currentExecution, key, originValue)
}
}, [])

const { evaluatedTree, errorTree } = this.executeTree(
currentExecution,
path,
-1,
)

const { validateErrors, validateResultTree } =
this.validateTree(evaluatedTree)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ const ListWidgetWithServerPagination: FC<ListWidgetPropsWithChildrenNodes> = (
const isClickOnContainer = !!(
e.target as HTMLElement
)?.getAttribute("data-list-widget-container")

handleUpdateSelectedItem(index, isClickOnContainer)
}}
>
Expand Down
15 changes: 12 additions & 3 deletions apps/builder/src/widgetLibrary/GridListWidget/gridList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,18 @@ export const GridListWidget: FC<GridListWidgetProps> = (props) => {
const validationPaths = rawWidget.$validationPaths
const validationType = get(validationPaths, finalPath)
if (validationType === VALIDATION_TYPES.ARRAY) {
const validationFunc = validationFactory[validationType]
const res = validationFunc?.(evalResult, "")
value = res?.safeValue ?? evalResult
if (Array.isArray(evalResult)) {
const needSetValue = evalResult[index] ?? []
const validationFunc =
validationFactory[validationType]
const res = validationFunc?.(needSetValue, "")
value = res?.safeValue ?? needSetValue
} else {
const validationFunc =
validationFactory[validationType]
const res = validationFunc?.(evalResult, "")
value = res?.safeValue ?? evalResult
}
} else {
value = evalResult[index]
const validationFunc = validationFactory[validationType]
Expand Down
15 changes: 12 additions & 3 deletions apps/builder/src/widgetLibrary/ListWidget/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ export const ListWidget: FC<ListWidgetProps> = (props) => {
const validationPaths = rawWidget.$validationPaths
const validationType = get(validationPaths, finalPath)
if (validationType === VALIDATION_TYPES.ARRAY) {
const validationFunc = validationFactory[validationType]
const res = validationFunc?.(evalResult, "")
value = res?.safeValue ?? evalResult
if (Array.isArray(evalResult)) {
const needSetValue = evalResult[index] ?? []
const validationFunc =
validationFactory[validationType]
const res = validationFunc?.(needSetValue, "")
value = res?.safeValue ?? needSetValue
} else {
const validationFunc =
validationFactory[validationType]
const res = validationFunc?.(evalResult, "")
value = res?.safeValue ?? evalResult
}
} else {
value = evalResult[index]
const validationFunc = validationFactory[validationType]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ export const TransformWidgetWrapper: FC<TransformWidgetProps> = memo(
const realPath = isFunction(formatPath)
? formatPath(path)
: convertPathToString(toPath(path).slice(1))
try {
const dynamicString = get(needRunEvents, realPath, "")
if (dynamicString) {
const dynamicString = get(needRunEvents, realPath, "")
if (dynamicString) {
try {
const calcValue = evaluateDynamicString(
`events${realPath}`,
dynamicString,
Expand All @@ -294,8 +294,10 @@ export const TransformWidgetWrapper: FC<TransformWidgetProps> = memo(
} else {
set(needRunEvents, realPath, calcValue)
}
} catch {
set(needRunEvents, realPath, undefined)
}
} catch (_ignore) {}
}
})

needRunEvents.forEach((scriptObj: any) => {
Expand All @@ -322,10 +324,10 @@ export const TransformWidgetWrapper: FC<TransformWidgetProps> = memo(
? formatPath(path)
: convertPathToString(toPath(path).slice(2))

try {
const dynamicString = get(needRunEvents, realPath, "")
const dynamicString = get(needRunEvents, realPath, "")

if (dynamicString) {
if (dynamicString) {
try {
const calcValue = evaluateDynamicString(
`events${realPath}`,
dynamicString,
Expand All @@ -346,9 +348,9 @@ export const TransformWidgetWrapper: FC<TransformWidgetProps> = memo(
}
}
set(needRunEvents, realPath, valueToSet)
} catch {
set(needRunEvents, realPath, undefined)
}
} catch (e) {
console.log(e)
}
})
needRunEvents.forEach((scriptObj: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,18 @@ export const TransformWidgetWrapperWithJson: FC<TransformWidgetWrapperWithJsonPr
? formatPath(path)
: convertPathToString(toPath(path).slice(1))

try {
const dynamicString = get(needRunEvents, realPath, "")
if (dynamicString) {
const dynamicString = get(needRunEvents, realPath, "")
if (dynamicString) {
try {
const calcValue = evaluateDynamicString(
"",
dynamicString,
finalContext,
)
set(needRunEvents, realPath, calcValue)
} catch {
set(needRunEvents, realPath, undefined)
}
} catch (e) {
console.log(e)
}
})
needRunEvents.forEach((scriptObj: any) => {
Expand All @@ -184,9 +184,9 @@ export const TransformWidgetWrapperWithJson: FC<TransformWidgetWrapperWithJsonPr
)
dynamicPaths?.forEach((path: string) => {
const realPath = convertPathToString(toPath(path).slice(2))
try {
const dynamicString = get(needRunEvents, realPath, "")
if (dynamicString) {
const dynamicString = get(needRunEvents, realPath, "")
if (dynamicString) {
try {
const calcValue = evaluateDynamicString(
"",
dynamicString,
Expand All @@ -197,8 +197,10 @@ export const TransformWidgetWrapperWithJson: FC<TransformWidgetWrapperWithJsonPr
} else {
set(needRunEvents, realPath, calcValue)
}
} catch {
set(needRunEvents, realPath, undefined)
}
} catch (_ignore) {}
}
})
needRunEvents.forEach((scriptObj: any) => {
runEventHandler(scriptObj, finalContext)
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/widgetLibrary/TagsWidget/panelConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const TAGS_PANEL_CONFIG: PanelConfig[] = [
groupName: i18n.t("editor.inspect.setter_group.layout"),
children: [
{
id: `${baseWidgetName}-layout-hidden`,
id: `${baseWidgetName}-layout-allowWrap`,
labelName: i18n.t("editor.inspect.setter_label.slider.allow_wrapping"),
labelDesc: i18n.t("editor.inspect.setter_tips.slider.allow_wrapping"),
setterType: "DYNAMIC_SWITCH_SETTER",
Expand Down

0 comments on commit 79e6852

Please sign in to comment.