Skip to content

Commit dcde6df

Browse files
FalkWolskyyeyian
authored and
yeyian
committed
Merge pull request lowcoder-org#717 from lowcoder-org/dev
Dev -> Main - fixing Publishing behaviour
2 parents 4c8be4b + f65f85b commit dcde6df

File tree

32 files changed

+4637
-2830
lines changed

32 files changed

+4637
-2830
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ client/node_modules/
99
client/packages/lowcoder-plugin-demo/.yarn/install-state.gz
1010
client/packages/lowcoder-plugin-demo/yarn.lock
1111
client/packages/lowcoder-plugin-demo/.yarn/cache/@types-node-npm-16.18.68-56f72825c0-094ae9ed80.zip
12+
server/yarn.lock
13+
server/node-service/yarn.lock

client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const childrenMap = {
138138
maxWidth: dropdownInputSimpleControl(OPTIONS, USER_DEFINE, "1920"),
139139
themeId: valueComp<string>(DEFAULT_THEMEID),
140140
customShortcuts: CustomShortcutsComp,
141+
disableCollision: valueComp<boolean>(false),
141142
};
142143
type ChildrenInstance = RecordConstructorToComp<typeof childrenMap> & {
143144
themeList: ThemeType[];

client/packages/lowcoder/src/comps/comps/containerComp/containerView.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ export function InnerGrid(props: ViewPropsWithSelect) {
478478
layout={props.layout}
479479
extraLayout={extraLayout}
480480
onDropDragOver={(e) => {
481-
482481
const compType = draggingUtils.getData<UICompType>("compType");
483482
const compLayout = draggingUtils.getData<UICompLayoutInfo>("compLayout");
484483
if (compType) {

client/packages/lowcoder/src/comps/editorState.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { NameAndExposingInfo } from "./utils/exposingTypes";
1717
import { checkName } from "./utils/rename";
1818
import { trans } from "i18n";
1919
import { UiLayoutType } from "./comps/uiComp";
20-
import { getCollisionStatus, getEditorModeStatus } from "util/localStorageUtil";
20+
import { getEditorModeStatus, saveCollisionStatus } from "util/localStorageUtil";
2121

2222
type RootComp = InstanceType<typeof RootCompTmp>;
2323

@@ -47,7 +47,7 @@ export class EditorState {
4747
readonly showPropertyPane: boolean = false;
4848
readonly selectedCompNames: Set<string> = new Set();
4949
readonly editorModeStatus: string = "";
50-
readonly collisionStatus: string = "";
50+
readonly collisionStatus: boolean = false;
5151
readonly isDragging: boolean = false;
5252
readonly draggingCompType: string = "button";
5353
readonly forceShowGrid: boolean = false; // show grid lines
@@ -65,12 +65,13 @@ export class EditorState {
6565
rootComp: RootComp,
6666
setEditorState: (fn: (editorState: EditorState) => EditorState) => void,
6767
initialEditorModeStatus: string = getEditorModeStatus(),
68-
initialCollisionStatus: string = getCollisionStatus()
6968
) {
7069
this.rootComp = rootComp;
7170
this.setEditorState = setEditorState;
7271
this.editorModeStatus = initialEditorModeStatus;
73-
this.collisionStatus = initialCollisionStatus;
72+
73+
// save collision status from app dsl to localstorage
74+
saveCollisionStatus(this.getCollisionStatus());
7475
}
7576

7677
/**
@@ -356,10 +357,6 @@ export class EditorState {
356357
this.changeState({ editorModeStatus: newEditorModeStatus });
357358
}
358359

359-
setCollisionStatus(newCollisionStatus: string) {
360-
this.changeState({ collisionStatus: newCollisionStatus });
361-
}
362-
363360
setDragging(dragging: boolean) {
364361
if (this.isDragging === dragging) {
365362
return;
@@ -513,8 +510,9 @@ export class EditorState {
513510
getAppType(): UiLayoutType {
514511
return this.getUIComp().children.compType.getView();
515512
}
516-
getCollisionStatus(): string {
517-
return this.collisionStatus;
513+
getCollisionStatus(): boolean {
514+
const { disableCollision } = this.getAppSettings();
515+
return disableCollision ?? false;
518516
}
519517

520518
}

client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ export const DisabledContext = React.createContext<boolean>(false);
161161
*/
162162
function UIView(props: { comp: any; viewFn: any }) {
163163
const comp = props.comp;
164-
console.log(comp);
165-
166-
console.log(comp.children);
167164

168165
const childrenProps = childrenToProps(comp.children);
169166
const parentDisabled = useContext(DisabledContext);

client/packages/lowcoder/src/comps/hooks/drawerComp.tsx

+44-31
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { CloseOutlined } from "@ant-design/icons";
1+
import { CloseOutlined, PropertySafetyFilled } from "@ant-design/icons";
22
import { default as Button } from "antd/es/button";
33
import { ContainerCompBuilder } from "comps/comps/containerBase/containerCompBuilder";
44
import { gridItemCompToGridItems, InnerGrid } from "comps/comps/containerComp/containerView";
55
import { AutoHeightControl } from "comps/controls/autoHeightControl";
66
import { BoolControl } from "comps/controls/boolControl";
77
import { StringControl } from "comps/controls/codeControl";
88
import { booleanExposingStateControl } from "comps/controls/codeStateControl";
9-
import { PositionControl } from "comps/controls/dropdownControl";
9+
import { PositionControl, LeftRightControl } from "comps/controls/dropdownControl";
1010
import { closeEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
1111
import { styleControl } from "comps/controls/styleControl";
1212
import { DrawerStyle } from "comps/controls/styleControlConstants";
@@ -35,40 +35,22 @@ const DrawerWrapper = styled.div`
3535
pointer-events: auto;
3636
`;
3737

38-
const ButtonStyle = styled(Button)`
39-
position: absolute;
40-
left: 0;
41-
top: 0;
42-
z-index: 10;
43-
font-weight: 700;
44-
box-shadow: none;
45-
color: rgba(0, 0, 0, 0.45);
46-
height: 54px;
47-
width: 54px;
48-
49-
svg {
50-
width: 16px;
51-
height: 16px;
52-
}
53-
54-
&,
55-
:hover,
56-
:focus {
57-
background-color: transparent;
58-
border: none;
59-
}
60-
61-
:hover,
62-
:focus {
63-
color: rgba(0, 0, 0, 0.75);
64-
}
65-
`;
66-
6738
// If it is a number, use the px unit by default
6839
function transToPxSize(size: string | number) {
6940
return isNumeric(size) ? size + "px" : (size as string);
7041
}
7142

43+
const ClosePlacementOptions = [
44+
{
45+
label: trans("drawer.left"),
46+
value: "left",
47+
},
48+
{
49+
label: trans("drawer.right"),
50+
value: "right",
51+
},
52+
] as const;
53+
7254
const PlacementOptions = [
7355
{
7456
label: trans("drawer.top"),
@@ -88,6 +70,7 @@ const PlacementOptions = [
8870
},
8971
] as const;
9072

73+
9174
let TmpDrawerComp = (function () {
9275
return new ContainerCompBuilder(
9376
{
@@ -98,6 +81,7 @@ let TmpDrawerComp = (function () {
9881
autoHeight: AutoHeightControl,
9982
style: styleControl(DrawerStyle),
10083
placement: PositionControl,
84+
closePosition: withDefault(LeftRightControl, "left"),
10185
maskClosable: withDefault(BoolControl, true),
10286
showMask: withDefault(BoolControl, true),
10387
},
@@ -119,6 +103,34 @@ let TmpDrawerComp = (function () {
119103
},
120104
[dispatch, isTopBom]
121105
);
106+
const ButtonStyle = styled(Button)`
107+
position: absolute;
108+
${props.closePosition === "right" ? "right: 0;" : "left: 0;"}
109+
top: 0;
110+
z-index: 10;
111+
font-weight: 700;
112+
box-shadow: none;
113+
color: rgba(0, 0, 0, 0.45);
114+
height: 54px;
115+
width: 54px;
116+
117+
svg {
118+
width: 16px;
119+
height: 16px;
120+
}
121+
122+
&,
123+
:hover,
124+
:focus {
125+
background-color: transparent;
126+
border: none;
127+
}
128+
129+
:hover,
130+
:focus {
131+
color: rgba(0, 0, 0, 0.75);
132+
}
133+
`;
122134
return (
123135
<BackgroundColorContext.Provider value={props.style.background}>
124136
<DrawerWrapper>
@@ -181,6 +193,7 @@ let TmpDrawerComp = (function () {
181193
.setPropertyViewFn((children) => (
182194
<>
183195
<Section name={sectionNames.basic}>
196+
{children.closePosition.propertyView({ label: trans("drawer.closePosition"), radioButton: true })}
184197
{children.placement.propertyView({ label: trans("drawer.placement"), radioButton: true })}
185198
{["top", "bottom"].includes(children.placement.getView())
186199
? children.autoHeight.getPropertyView()

client/packages/lowcoder/src/constants/applicationConstants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export enum AppTypeEnum {
1111
NavLayout = 3,
1212
// 4 folder, 5 mobile
1313
MobileTabLayout = 6,
14+
// WorkflowScreen = 7,
15+
// Slide = 8,
1416
}
1517

1618
export enum ApplicationCategoriesEnum {
@@ -52,6 +54,8 @@ export const AppUILayoutType: Record<AppTypeEnum, UiLayoutType> = {
5254
[AppTypeEnum.Module]: "module",
5355
[AppTypeEnum.NavLayout]: "nav",
5456
[AppTypeEnum.MobileTabLayout]: "mobileTabLayout",
57+
// [AppTypeEnum.WorkflowScreen]: "module",
58+
// [AppTypeEnum.Slide]: "normal",
5559
};
5660

5761
export type ApplicationDSLType = "editing" | "published" | "view_marketplace";
@@ -61,6 +65,7 @@ export type ApplicationPermissionType = "USER" | "GROUP" | "ORG_ADMIN";
6165
export interface ApplicationExtra {
6266
moduleHeight?: number;
6367
moduleWidth?: number;
68+
layers?: boolean;
6469
}
6570

6671
export interface ApplicationMeta {

client/packages/lowcoder/src/i18n/locales/de.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@ export const de = {
13471347
"title": "Angezeigter Container-Titel"
13481348
},
13491349
"drawer": {
1350+
"closePosition": "Platzierung der Verschlusses",
13501351
"placement": "Platzierung der Schubladen",
13511352
"size": "Größe",
13521353
"top": "Top",

client/packages/lowcoder/src/i18n/locales/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,7 @@ export const en = {
15001500
"title": "Displayed Container Title"
15011501
},
15021502
"drawer": {
1503+
"closePosition": "Close Button Placement",
15031504
"placement": "Drawer Placement",
15041505
"size": "Size",
15051506
"top": "Top",

client/packages/lowcoder/src/i18n/locales/translation_files/de.json

+1
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@
13351335
"title": "Angezeigter Container-Titel"
13361336
},
13371337
"drawer": {
1338+
"closePosition": "Platzierung der Verschlusses",
13381339
"placement": "Platzierung der Schubladen",
13391340
"size": "Größe",
13401341
"top": "Top",

client/packages/lowcoder/src/i18n/locales/translation_files/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,7 @@
13991399
"title": "Displayed Container Title"
14001400
},
14011401
"drawer": {
1402+
"closePosition": "Close Button Placement",
14021403
"placement": "Drawer Placement",
14031404
"size": "Size",
14041405
"top": "Top",

client/packages/lowcoder/src/i18n/locales/translation_files/es.json

+1-1
Large diffs are not rendered by default.

client/packages/lowcoder/src/i18n/locales/zh.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ container: {
14691469
title: "容器标题",
14701470
},
14711471
drawer: {
1472+
closePosition: "关闭位置",
14721473
placement: "抽屉位置",
14731474
size: "大小",
14741475
top: "顶部",

client/packages/lowcoder/src/layout/utils.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { DraggableEvent } from "react-draggable";
55
import { PositionParams } from "./calculateUtils";
66
import { draggingUtils } from "./draggingUtils";
77
import { GridLayoutProps, ResizeHandleAxis } from "./gridLayoutPropTypes";
8-
98
import { getCollisionStatus } from "util/localStorageUtil";
109

1110
export type LayoutItem = {
@@ -172,12 +171,7 @@ export function collides(l1: LayoutItem, l2: LayoutItem): boolean {
172171
if (l1.y + l1.h <= l2.y) return false; // l1 is above l2
173172
if (l1.y >= l2.y + l2.h) return false; // l1 is below l2
174173

175-
if (getCollisionStatus() === "true") {
176-
return false;
177-
}
178-
else {
179-
return true; // boxes overlap
180-
}
174+
return !getCollisionStatus();
181175
}
182176

183177
/**

client/packages/lowcoder/src/pages/ApplicationV2/HomeLayout.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { useLocation } from "react-use";
2525
import { TrashTableView } from "./TrashTableView";
2626
import { HomepageTourV2 } from "../tutorials/HomeTutorialsV2";
2727
import { HomeCardView } from "./HomeCardView";
28-
import { getHomeLayout, HomeLayoutType, saveHomeLayout } from "../../util/localStorageUtil";
28+
import { getHomeLayout, HomeLayoutType, removeCollisionStatus, saveHomeLayout } from "../../util/localStorageUtil";
2929
import { HomeTableView } from "./HomeTableView";
3030
import { Layers } from "../../constants/Layers";
3131
import { CreateDropdown } from "./CreateDropdown";
@@ -288,6 +288,11 @@ export function HomeLayout(props: HomeLayoutProps) {
288288

289289
useEffect(() => saveHomeLayout(layout), [layout]);
290290

291+
useEffect(() => {
292+
// remove collision status from localstorage
293+
removeCollisionStatus();
294+
}, []);
295+
291296
const currentPath = useLocation().pathname;
292297

293298
if (!user.currentOrgId) {

client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx

+16-18
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import { Button, Divider, Dropdown, Flex, Input, Menu, MenuProps, Space } from "
2929
import { Switch } from "antd";
3030
import {
3131
saveCollisionStatus,
32-
getCollisionStatus,
3332
} from "util/localStorageUtil";
34-
import { check, withViewFn } from "@lowcoder-ee/index.sdk";
3533
import { DownOutlined } from "@ant-design/icons";
3634
import { ItemType } from "antd/es/menu/hooks/useItems";
3735
import ColorPicker, { configChangeParams } from "components/ColorPicker";
@@ -78,17 +76,18 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
7876
const applicationId = useApplicationId();
7977

8078
// added by Falk Wolsky to support a Layers in Lowcoder
81-
const [collisionStatus, setCollisionStatus] = useState(() => {
82-
return getCollisionStatus();
83-
});
84-
85-
const toggleCollisionStatus: ToggleCollisionStatus = useCallback(
86-
(value) => {
87-
setCollisionStatus(value ? value : ("false" as DisabledCollisionStatus));
88-
saveCollisionStatus(value ? value : ("false" as DisabledCollisionStatus));
89-
},
90-
[collisionStatus]
91-
);
79+
const [collisionStatus, setCollisionStatus] = useState(editorState.getCollisionStatus());
80+
81+
useEffect(() => {
82+
saveCollisionStatus(collisionStatus);
83+
}, [collisionStatus])
84+
85+
const handleToggleLayer = (checked: boolean) => {
86+
editorState.rootComp.children.settings.children.disableCollision.dispatchChangeValueAction(
87+
checked
88+
)
89+
setCollisionStatus(checked);
90+
}
9291

9392
const getTree = (tree: CompTree, result: NodeItem[], key?: string) => {
9493
const { items, children } = tree;
@@ -429,7 +428,7 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
429428
// TODO: sort by category
430429
// TODO: sort by Types etc.
431430
const uiCompInfos = _.sortBy(editorState.uiCompInfoList(), [(x) => x.name]);
432-
const isDraggable = editorState.collisionStatus === "true" ? true : false;
431+
const isDraggable = editorState.getCollisionStatus();
433432

434433
return (
435434
<>
@@ -439,11 +438,10 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
439438
<Switch
440439
style={{margin : "0px 10px"}}
441440
size="small"
442-
checked={editorState.collisionStatus == "true"}
441+
defaultChecked={collisionStatus}
443442
disabled={false}
444-
onChange={(value: any) => {
445-
toggleCollisionStatus(value == true ? "true" : "false");
446-
editorState.setCollisionStatus(value == true ? "true" : "false");
443+
onChange={(value: boolean) => {
444+
handleToggleLayer(value);
447445
}}
448446
/>
449447
</div>

0 commit comments

Comments
 (0)