Skip to content

Commit

Permalink
fix(ui,runtime): 迭代器容器迭代数据兼容
Browse files Browse the repository at this point in the history
re #613
  • Loading branch information
roymondchen committed May 31, 2024
1 parent 7fb4d96 commit 94db430
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 152 deletions.
28 changes: 15 additions & 13 deletions packages/ui-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
"react:build": "tsc && vite build"
},
"dependencies": {
"@tmagic/core": "1.4.4",
"@tmagic/schema": "1.4.4",
"@tmagic/utils": "1.4.4",
"qrcode": "^1.5.0",
"react": "^17.0.0",
"react-dom": "^17.0.0"
"qrcode": "^1.5.0"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0"
},
"peerDependencies": {
"qrcode": "^1.5.0",
"react": "^17.0.0",
"react-dom": "^17.0.0"
"@tmagic/core": "workspace:*",
"@tmagic/schema": "workspace:*",
"@tmagic/utils": "workspace:*",
"react": ">=18.3.1",
"react-dom": ">=18.3.1",
"typescript": "*"
},
"devDependencies": {
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"typescript": "^5.4.5"
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ interface IteratorContainerProps extends MContainer {
const IteratorContainer: React.FC<IteratorContainerProps> = ({ config, id }) => {
const { app } = useApp({ config });

const { iteratorData = [] } = config;
let { iteratorData = [] } = config;

if (!Array.isArray(iteratorData)) {
iteratorData = [];
}

if (app?.platform === 'editor' && !iteratorData.length) {
iteratorData.push({});
Expand Down
9 changes: 7 additions & 2 deletions packages/ui-react/src/iterator-container/src/formConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ export default [
checkStrictly: false,
type: 'data-source-field-select',
onChange: (vm: any, v: string[] = [], { model }: any) => {
const [dsId, ...keys] = v;
model.dsField = [dsId.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, ''), ...keys];
if (Array.isArray(v)) {
const [dsId, ...keys] = v;
model.dsField = [dsId.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, ''), ...keys];
} else {
model.dsField = [];
}

return v;
},
},
Expand Down
18 changes: 11 additions & 7 deletions packages/ui-vue2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
"url": "https://github.com/Tencent/tmagic-editor.git"
},
"dependencies": {
"@tmagic/core": "1.4.4",
"@tmagic/schema": "1.4.4",
"@tmagic/utils": "1.4.4",
"qrcode": "^1.5.0",
"vue": "^2.7.4"
"qrcode": "^1.5.0"
},
"peerDependencies": {
"qrcode": "^1.5.0",
"vue": "^2.7.4"
"@tmagic/core": "workspace:*",
"@tmagic/schema": "workspace:*",
"@tmagic/utils": "workspace:*",
"vue": ">=2.7.4",
"typescript": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"devDependencies": {
"vue-template-compiler": "^2.7.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const app: Core | undefined = inject('app');
const style = computed(() => app?.transformStyle(props.config.style || {}));
const configs = computed(() => {
const { iteratorData = [] } = props.config;
let { iteratorData = [] } = props.config;
if (!Array.isArray(iteratorData)) {
iteratorData = [];
}
if (app?.platform === 'editor' && !iteratorData.length) {
iteratorData.push({});
Expand Down
9 changes: 6 additions & 3 deletions packages/ui-vue2/src/iterator-container/src/formConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export default [
checkStrictly: false,
type: 'data-source-field-select',
onChange: (vm: any, v: string[] = [], { model }: any) => {
const [dsId, ...keys] = v;
model.dsField = [dsId.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, ''), ...keys];
return v;
if (Array.isArray(v)) {
const [dsId, ...keys] = v;
model.dsField = [dsId.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, ''), ...keys];
} else {
model.dsField = [];
}
},
},
{
Expand Down
18 changes: 11 additions & 7 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
"url": "https://github.com/Tencent/tmagic-editor.git"
},
"dependencies": {
"@tmagic/core": "1.4.4",
"@tmagic/schema": "1.4.4",
"@tmagic/utils": "1.4.4",
"delegate": "^3.2.0",
"qrcode": "^1.5.0",
"tiny-emitter": "^2.1.0",
"vue": "^3.4.27"
"tiny-emitter": "^2.1.0"
},
"peerDependencies": {
"qrcode": "^1.5.0",
"vue": "^3.4.27"
"@tmagic/core": "workspace:*",
"@tmagic/schema": "workspace:*",
"@tmagic/utils": "workspace:*",
"vue": ">=3.4.27",
"typescript": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"devDependencies": {
"@testing-library/vue": "^6.4.2",
Expand Down
6 changes: 5 additions & 1 deletion packages/ui/src/iterator-container/src/IteratorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const { app } = useApp({
});
const configs = computed(() => {
const { iteratorData = [] } = props.config;
let { iteratorData = [] } = props.config;
if (!Array.isArray(iteratorData)) {
iteratorData = [];
}
if (app?.platform === 'editor' && !iteratorData.length) {
iteratorData.push({});
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/src/iterator-container/src/formConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export default [
checkStrictly: false,
type: 'data-source-field-select',
onChange: (vm: any, v: string[] = [], { model }: any) => {
const [dsId, ...keys] = v;
model.dsField = [dsId.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, ''), ...keys];
return v;
if (Array.isArray(v)) {
const [dsId, ...keys] = v;
model.dsField = [dsId.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, ''), ...keys];
} else {
model.dsField = [];
}
},
},
{
Expand Down
Loading

1 comment on commit 94db430

@GoToBoy
Copy link
Contributor

@GoToBoy GoToBoy commented on 94db430 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.