Skip to content

Commit 105d1da

Browse files
committed
multiChanges: feat: changeSet comp preserve previous values
- feat: sql query gui mode preserve previous values - fix(table): fix Datetime columns's baseValue - fix: table dateTime edit invalid value - fix(table): fix changeablePageSize exposing problem
1 parent 01e1c13 commit 105d1da

File tree

19 files changed

+113
-392
lines changed

19 files changed

+113
-392
lines changed

client/packages/openblocks-sdk/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ interface EventHandlerMap<O = any> {
1313

1414
export interface AppViewInstanceOptions<I = any> {
1515
moduleInputs?: I;
16+
appDsl?: any;
17+
moduleDslMap?: any;
18+
baseUrl?: string;
1619
}
1720

1821
export interface OpenblocksAppViewProps<I, O> extends AppViewInstanceOptions<I> {
@@ -25,7 +28,7 @@ export interface OpenblocksAppViewProps<I, O> extends AppViewInstanceOptions<I>
2528
export interface AppViewInstance<I, O> {
2629
on<K extends keyof EventHandlerMap<O>>(event: K, handler?: EventHandlerMap<O>[K]): Off;
2730
setModuleInputs(inputs: I): void;
28-
invokeMethod(methodName: string): void;
31+
invokeMethod(methodName: string, params?: any[]): void;
2932
}
3033

3134
export declare const OpenblocksAppView: React.ForwardRefExoticComponent<

client/packages/openblocks-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openblocks-sdk",
3-
"version": "0.0.30",
3+
"version": "0.0.32",
44
"type": "module",
55
"files": [
66
"src",

client/packages/openblocks/src/comps/comps/iframeComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let IFrameCompBase = new UICompBuilder(
6161
.setPropertyViewFn((children) => (
6262
<>
6363
<Section name={sectionNames.basic}>
64-
{children.url.propertyView({ label: "URL", placeholder: "https://xxx.com" })}
64+
{children.url.propertyView({ label: "URL", placeholder: "https://example.com" })}
6565
</Section>
6666

6767
<Section name={sectionNames.advanced}>

client/packages/openblocks/src/comps/comps/preLoadComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function LibsTabPane(props: { libsComp: ChildrenInstance["libs"] }) {
190190
<div className="lib-item" key={idx}>
191191
<div className="lib-item-input">
192192
{i.propertyView({
193-
placeholder: "https://cdn.xxx.com/example.min.js",
193+
placeholder: "https://cdn.example.com/example.min.js",
194194
})}
195195
</div>
196196
<TacoButton

client/packages/openblocks/src/comps/comps/qrCodeComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let QRCodeBasicComp = (function () {
5757
{children.value.propertyView({
5858
label: trans("QRCode.value"),
5959
tooltip: trans("QRCode.valueTooltip"),
60-
placeholder: "https://xxx.com",
60+
placeholder: "https://example.com",
6161
})}
6262
{children.level.propertyView({
6363
label: trans("QRCode.level"),

client/packages/openblocks/src/comps/comps/tableComp/column/columnTypeComps/columnDateComp.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ const childrenMap = {
124124
format: withDefault(StringControl, DATE_FORMAT),
125125
};
126126

127-
const getBaseValue: ColumnTypeViewFn<typeof childrenMap, string, string> = (props) =>
128-
formatDate(props.text, props.format);
127+
const getBaseValue: ColumnTypeViewFn<typeof childrenMap, string, string> = (props) => props.text;
129128

130129
type DateTimeEditProps = {
131130
value: string;
@@ -135,6 +134,10 @@ type DateTimeEditProps = {
135134

136135
const DateTimeEdit = (props: DateTimeEditProps) => {
137136
const [panelOpen, setPanelOpen] = useState(true);
137+
let value = moment(props.value, DateParser);
138+
if (!value.isValid()) {
139+
value = moment(0, DateParser);
140+
}
138141
return (
139142
<Wrapper
140143
onKeyDown={(e) => {
@@ -153,7 +156,7 @@ const DateTimeEdit = (props: DateTimeEditProps) => {
153156
allowClear={false}
154157
bordered={false}
155158
autoFocus
156-
defaultValue={moment(props.value)}
159+
defaultValue={value}
157160
showTime
158161
showNow={true}
159162
defaultOpen={true}

client/packages/openblocks/src/comps/comps/tableComp/paginationControl.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { stateComp, valueComp, withDefault } from "comps/generators";
55
import { changeChildAction } from "openblocks-core";
66
import { ConstructorToNodeType } from "openblocks-core";
77
import { trans } from "i18n";
8+
import _ from "lodash";
89

910
const DEFAULT_PAGE_SIZE = 5;
1011

@@ -21,12 +22,22 @@ export function getPageSize(
2122
}
2223
}
2324

25+
function numberControlToValueComp(defaultValue: number) {
26+
class ValueComp extends valueComp<number>(5) {
27+
override oldValueToNew(value: number | string | undefined) {
28+
if (_.isNil(value)) return value;
29+
return Number(value);
30+
}
31+
}
32+
return ValueComp;
33+
}
34+
2435
export const PaginationControl = (function () {
2536
const childrenMap = {
2637
showQuickJumper: BoolControl,
2738
showSizeChanger: BoolControl,
2839
hideOnSinglePage: BoolControl,
29-
changeablePageSize: valueComp<number>(5),
40+
changeablePageSize: numberControlToValueComp(5),
3041
pageSize: NumberControl,
3142
total: NumberControl,
3243
pageNo: stateComp<number>(1),

client/packages/openblocks/src/comps/comps/tableComp/tableComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function TableView(props: {
132132
return;
133133
}
134134
compChildren.onEvent.getView()(eventName);
135-
compChildren.columns.dispatchClearChangeSet();
135+
setTimeout(() => compChildren.columns.dispatchClearChangeSet(), 0);
136136
},
137137
[viewMode, compChildren.onEvent, compChildren.columns]
138138
);

client/packages/openblocks/src/comps/generators/withContextForList.tsx

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)