Skip to content

Commit cd7c5a2

Browse files
authored
Merge pull request lowcoder-org#299 from lvhuichao/develop
PR 0309
2 parents 92e1c67 + bacbaec commit cd7c5a2

File tree

66 files changed

+1372
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1372
-384
lines changed

client/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.6
1+
1.1.7

client/packages/openblocks-core/lib/index.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3338,7 +3338,8 @@ var MultiBaseComp = /** @class */ (function (_super) {
33383338
MultiBaseComp.prototype.reduce = function (action) {
33393339
var comp = this.reduceOrUndefined(action);
33403340
if (!comp) {
3341-
throw new Error("not supported action, should not happen");
3341+
console.warn("not supported action, should not happen, action:", action, "\ncurrent comp:", this);
3342+
return this;
33423343
}
33433344
return comp;
33443345
};

client/packages/openblocks-core/lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3330,7 +3330,8 @@ var MultiBaseComp = /** @class */ (function (_super) {
33303330
MultiBaseComp.prototype.reduce = function (action) {
33313331
var comp = this.reduceOrUndefined(action);
33323332
if (!comp) {
3333-
throw new Error("not supported action, should not happen");
3333+
console.warn("not supported action, should not happen, action:", action, "\ncurrent comp:", this);
3334+
return this;
33343335
}
33353336
return comp;
33363337
};

client/packages/openblocks-core/src/baseComps/multiBaseComp.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ export abstract class MultiBaseComp<
6363
override reduce(action: CompAction): this {
6464
const comp = this.reduceOrUndefined(action);
6565
if (!comp) {
66-
throw new Error("not supported action, should not happen");
66+
console.warn(
67+
"not supported action, should not happen, action:",
68+
action,
69+
"\ncurrent comp:",
70+
this
71+
);
72+
return this;
6773
}
6874
return comp;
6975
}

client/packages/openblocks-design/src/components/CustomModal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const ModalHeaderTitle = styled.div`
4444
color: #222222;
4545
flex-grow: 1;
4646
min-width: 0;
47+
height: 16px;
4748
display: flex;
4849
align-items: center;
4950
@@ -58,6 +59,7 @@ const ModalCloseIcon = styled.div`
5859
margin-left: 16px;
5960
width: 16px;
6061
height: 16px;
62+
display: flex;
6163
cursor: pointer;
6264
color: ${GreyTextColor};
6365
@@ -101,8 +103,8 @@ export const ModalFooterWrapper = styled.div`
101103
height: 28px;
102104
margin-top: 12px;
103105
margin-left: 8px;
104-
padding-left: 12px;
105-
padding-right: 12px;
106+
padding-left: 11px;
107+
padding-right: 11px;
106108
}
107109
`;
108110

@@ -268,6 +270,7 @@ CustomModal.confirm = (props: {
268270
bodyStyle?: React.CSSProperties;
269271
footer?: ReactNode;
270272
type?: "info" | "warn" | "error" | "success";
273+
width?: number | string;
271274
}): any => {
272275
const defaultConfirmProps: ModalFuncProps = {
273276
...DEFAULT_PROPS,
@@ -317,6 +320,7 @@ CustomModal.confirm = (props: {
317320
okText={props.okText}
318321
bodyStyle={{ ...defaultConfirmProps.bodyStyle, ...props.bodyStyle }}
319322
footer={props.footer}
323+
width={props.width}
320324
/>
321325
),
322326
});

client/packages/openblocks-design/src/components/Menu.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ const StyledAntdMenu = styled(AntdMenu)`
7777
.ant-menu-item:focus-visible {
7878
box-shadow: unset;
7979
}
80+
81+
.ant-menu-item-disabled .text {
82+
color: #b8b9bf;
83+
& + span {
84+
opacity: 0.4;
85+
}
86+
}
8087
`;
8188

8289
const MenuItemContentWrapper = styled.div`

client/packages/openblocks-design/src/components/form.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ const FormSelect = (props: any) => {
321321
return (
322322
<SelectWrapper>
323323
<CustomSelect
324+
open={props.open}
324325
mode={props.mode}
325326
value={value}
326327
style={{
@@ -352,7 +353,7 @@ const FormSelect = (props: any) => {
352353

353354
export interface FormSelectItemProps<T extends OptionsType>
354355
extends FormItemProps,
355-
Pick<SelectProps, "mode"> {
356+
Pick<SelectProps, "mode" | "open"> {
356357
options: T;
357358
afterChange?: (value: ValueFromOption<T>) => void;
358359
}
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Loading

client/packages/openblocks-design/src/icons/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,6 @@ export { ReactComponent as SyncManualIcon } from "./icon-sync-manual.svg";
271271
export { ReactComponent as DangerIcon } from "icons/icon-danger.svg";
272272
export { ReactComponent as TableMinusIcon } from "icons/icon-table-minus.svg";
273273
export { ReactComponent as TablePlusIcon } from "icons/icon-table-plus.svg";
274+
export { ReactComponent as MobileAppIcon } from "icons/icon-mobile-app.svg";
275+
export { ReactComponent as MobileNavIcon } from "icons/icon-navigation-mobile.svg";
276+
export { ReactComponent as PcNavIcon } from "icons/icon-navigation-pc.svg";

client/packages/openblocks/src/api/queryApi.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ export class QueryApi extends Api {
5050

5151
static queryExecuteCancelTokenSource: Record<string, CancelTokenSource> = {};
5252

53+
static cancelAllQuery() {
54+
Object.values(QueryApi.queryExecuteCancelTokenSource).forEach((s) => {
55+
s.cancel();
56+
});
57+
QueryApi.queryExecuteCancelTokenSource = {};
58+
}
59+
5360
static executeQuery(
5461
request: QueryExecuteRequest,
5562
timeout?: number

client/packages/openblocks/src/comps/comps/buttonComp/buttonCompConstants.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function getButtonStyle(buttonStyle: ButtonStyleType) {
4040
`;
4141
}
4242

43-
export const Button100 = styled(Button)<{ $buttonStyle: ButtonStyleType }>`
44-
${(props) => getButtonStyle(props.$buttonStyle)}
43+
export const Button100 = styled(Button)<{ $buttonStyle?: ButtonStyleType }>`
44+
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle)}
4545
width: 100%;
4646
display: inline-flex;
4747
justify-content: center;

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export type DateCompViewProps = Pick<
158158
| "secondStep"
159159
| "viewRef"
160160
> & {
161-
onPanelChange: () => void;
162161
onFocus: () => void;
163162
onBlur: () => void;
164163
$style: DateTimeStyleType;
@@ -282,10 +281,9 @@ export const dateRangeControl = (function () {
282281
);
283282
props.onEvent("change");
284283
}}
285-
onPanelChange={() => {
286-
// mode[0] !== "date" && handleDateChange("", props.start.onChange, noop);
287-
handleDateChange("", props.start.onChange, noop);
288-
handleDateChange("", props.end.onChange, noop);
284+
onPanelChange={(_, mode) => {
285+
mode[0] !== "date" && handleDateChange("", props.start.onChange, noop);
286+
mode[1] !== "date" && handleDateChange("", props.end.onChange, noop);
289287
}}
290288
onFocus={() => props.onEvent("focus")}
291289
onBlur={() => props.onEvent("blur")}

client/packages/openblocks/src/comps/comps/dateComp/dateRangeUIView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface DateRangeUIViewProps extends DateCompViewProps {
2424
start: moment.Moment | null;
2525
end: moment.Moment | null;
2626
onChange: (start?: moment.Moment | null, end?: moment.Moment | null) => void;
27+
onPanelChange: (value: any, mode: [string, string]) => void;
2728
}
2829

2930
export const DateRangeUIView = (props: DateRangeUIViewProps) => {

client/packages/openblocks/src/comps/comps/dateComp/dateUIView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const DatePickerStyled = styled(DatePicker)<{ $style: DateTimeStyleType }>`
1717
export interface DataUIViewProps extends DateCompViewProps {
1818
value: moment.Moment | null;
1919
onChange: (value: moment.Moment | null) => void;
20+
onPanelChange: () => void;
2021
}
2122

2223
const DateMobileUIView = React.lazy(() =>

client/packages/openblocks/src/comps/comps/gridLayoutComp/canvasView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const UICompContainer = styled.div<{ maxWidth?: number; readOnly?: boolean }>`
2727
`;
2828

2929
// modal/drawer container
30-
const CanvasContainer = styled.div<{ maxWidth: number }>`
30+
export const CanvasContainer = styled.div<{ maxWidth: number }>`
3131
max-width: ${(props) => props.maxWidth}px;
3232
min-width: min(${(props) => props.maxWidth}px, 718px);
3333
margin: 0 auto;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { useDispatch, useSelector } from "react-redux";
2+
import { normalAppListSelector } from "redux/selectors/applicationSelector";
3+
import { useEffect, useMemo } from "react";
4+
import { fetchAllApplications } from "redux/reduxActions/applicationActions";
5+
import { AppTypeEnum } from "constants/applicationConstants";
6+
import { Dropdown } from "components/Dropdown";
7+
import { trans } from "i18n";
8+
import { ModuleComp } from "comps/comps/moduleComp/moduleComp";
9+
10+
function AppSelectPropertyView(props: {
11+
onChange: (label: string, value: string) => void;
12+
appId: string;
13+
}) {
14+
const { appId, onChange } = props;
15+
const apps = useSelector(normalAppListSelector);
16+
const dispatch = useDispatch();
17+
useEffect(() => {
18+
if (apps.length <= 0) dispatch(fetchAllApplications({}));
19+
}, [apps]);
20+
const options = useMemo(
21+
() =>
22+
apps
23+
.filter((app) => app.applicationType === AppTypeEnum.Application)
24+
.map((app) => ({
25+
label: app.name,
26+
value: app.applicationId,
27+
})),
28+
[apps]
29+
);
30+
const valueLabelMap = useMemo(() => {
31+
return new Map(options.map((o) => [o.value, o.label]));
32+
}, [options]);
33+
34+
return (
35+
<Dropdown
36+
showSearch={true}
37+
value={appId}
38+
options={options}
39+
label={trans("aggregation.chooseApp")}
40+
onChange={(value) => {
41+
onChange(valueLabelMap.get(value) || "", value);
42+
}}
43+
/>
44+
);
45+
}
46+
47+
// @ts-ignore
48+
export class AppSelectComp extends ModuleComp {
49+
getAppId() {
50+
return this.children.appId.getView();
51+
}
52+
53+
propertyView(param: { onChange?: (label: string) => void }) {
54+
return (
55+
<AppSelectPropertyView
56+
appId={this.children.appId.getView()}
57+
onChange={(label, value) => {
58+
this.dispatchChangeValueAction({
59+
appId: value,
60+
});
61+
param.onChange && param.onChange(label);
62+
}}
63+
/>
64+
);
65+
}
66+
}

client/packages/openblocks/src/comps/comps/layout/layoutMenuItemComp.tsx

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { MultiBaseComp } from "openblocks-core";
2-
import { ModuleComp } from "comps/comps/moduleComp/moduleComp";
32
import { BoolPureControl } from "comps/controls/boolControl";
43
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
54
import { keyValueListControl } from "comps/controls/keyValueControl";
@@ -11,74 +10,13 @@ import {
1110
ToViewReturn,
1211
} from "comps/generators/multi";
1312
import { genRandomKey } from "comps/utils/idGenerator";
14-
import { AppTypeEnum } from "constants/applicationConstants";
15-
import { BranchDiv, Dropdown, Treediv } from "openblocks-design";
13+
import { BranchDiv, Treediv } from "openblocks-design";
1614
import _ from "lodash";
17-
import { ReactNode, useEffect, useMemo } from "react";
18-
import { useDispatch, useSelector } from "react-redux";
19-
import { normalAppListSelector } from "redux/selectors/applicationSelector";
15+
import { ReactNode } from "react";
2016
import { IconControl } from "comps/controls/iconControl";
2117
import { hiddenPropertyView } from "comps/utils/propertyUtils";
2218
import { trans } from "i18n";
23-
import { fetchAllApplications } from "redux/reduxActions/applicationActions";
24-
25-
function AppSelectorPropertyView(props: {
26-
onChange: (label: string, value: string) => void;
27-
appId: string;
28-
}) {
29-
const { appId, onChange } = props;
30-
const apps = useSelector(normalAppListSelector);
31-
const dispatch = useDispatch();
32-
useEffect(() => {
33-
if (apps.length <= 0) dispatch(fetchAllApplications({}));
34-
}, [apps]);
35-
const options = useMemo(
36-
() =>
37-
apps
38-
.filter((app) => app.applicationType === AppTypeEnum.Application)
39-
.map((app) => ({
40-
label: app.name,
41-
value: app.applicationId,
42-
})),
43-
[apps]
44-
);
45-
const valueLabelMap = useMemo(() => {
46-
return new Map(options.map((o) => [o.value, o.label]));
47-
}, [options]);
48-
49-
return (
50-
<Dropdown
51-
showSearch={true}
52-
value={appId}
53-
options={options}
54-
label={trans("aggregation.chooseApp")}
55-
onChange={(value) => {
56-
onChange(valueLabelMap.get(value) || "", value);
57-
}}
58-
/>
59-
);
60-
}
61-
62-
// @ts-ignore
63-
class AppSelectorControl extends ModuleComp {
64-
getAppId() {
65-
return this.children.appId.getView();
66-
}
67-
68-
propertyView(param: { onChange: (label: string) => void }) {
69-
return (
70-
<AppSelectorPropertyView
71-
appId={this.children.appId.getView()}
72-
onChange={(label, value) => {
73-
this.dispatchChangeValueAction({
74-
appId: value,
75-
});
76-
param.onChange(label);
77-
}}
78-
/>
79-
);
80-
}
81-
}
19+
import { AppSelectComp } from "comps/comps/layout/appSelectComp";
8220

8321
const QueryHashList = withDefault(keyValueListControl(false, [], "string"), [
8422
{ key: "", value: "" },
@@ -87,7 +25,7 @@ const QueryHashList = withDefault(keyValueListControl(false, [], "string"), [
8725
const childrenMap = {
8826
label: StringControl,
8927
hidden: BoolCodeControl,
90-
app: AppSelectorControl,
28+
app: AppSelectComp,
9129
icon: IconControl,
9230
hideWhenNoPermission: withDefault(BoolPureControl, true),
9331
queryParam: QueryHashList,

0 commit comments

Comments
 (0)