Skip to content

Dev -> Main - fixing Publishing behaviour #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const childrenMap = {
maxWidth: dropdownInputSimpleControl(OPTIONS, USER_DEFINE, "1920"),
themeId: valueComp<string>(DEFAULT_THEMEID),
customShortcuts: CustomShortcutsComp,
disableCollision: valueComp<boolean>(false),
};
type ChildrenInstance = RecordConstructorToComp<typeof childrenMap> & {
themeList: ThemeType[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ export function InnerGrid(props: ViewPropsWithSelect) {
layout={props.layout}
extraLayout={extraLayout}
onDropDragOver={(e) => {

const compType = draggingUtils.getData<UICompType>("compType");
const compLayout = draggingUtils.getData<UICompLayoutInfo>("compLayout");
if (compType) {
Expand Down
18 changes: 8 additions & 10 deletions client/packages/lowcoder/src/comps/editorState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { NameAndExposingInfo } from "./utils/exposingTypes";
import { checkName } from "./utils/rename";
import { trans } from "i18n";
import { UiLayoutType } from "./comps/uiComp";
import { getCollisionStatus, getEditorModeStatus } from "util/localStorageUtil";
import { getEditorModeStatus, saveCollisionStatus } from "util/localStorageUtil";

type RootComp = InstanceType<typeof RootCompTmp>;

Expand Down Expand Up @@ -47,7 +47,7 @@ export class EditorState {
readonly showPropertyPane: boolean = false;
readonly selectedCompNames: Set<string> = new Set();
readonly editorModeStatus: string = "";
readonly collisionStatus: string = "";
readonly collisionStatus: boolean = false;
readonly isDragging: boolean = false;
readonly draggingCompType: string = "button";
readonly forceShowGrid: boolean = false; // show grid lines
Expand All @@ -65,12 +65,13 @@ export class EditorState {
rootComp: RootComp,
setEditorState: (fn: (editorState: EditorState) => EditorState) => void,
initialEditorModeStatus: string = getEditorModeStatus(),
initialCollisionStatus: string = getCollisionStatus()
) {
this.rootComp = rootComp;
this.setEditorState = setEditorState;
this.editorModeStatus = initialEditorModeStatus;
this.collisionStatus = initialCollisionStatus;

// save collision status from app dsl to localstorage
saveCollisionStatus(this.getCollisionStatus());
}

/**
Expand Down Expand Up @@ -356,10 +357,6 @@ export class EditorState {
this.changeState({ editorModeStatus: newEditorModeStatus });
}

setCollisionStatus(newCollisionStatus: string) {
this.changeState({ collisionStatus: newCollisionStatus });
}

setDragging(dragging: boolean) {
if (this.isDragging === dragging) {
return;
Expand Down Expand Up @@ -513,8 +510,9 @@ export class EditorState {
getAppType(): UiLayoutType {
return this.getUIComp().children.compType.getView();
}
getCollisionStatus(): string {
return this.collisionStatus;
getCollisionStatus(): boolean {
const { disableCollision } = this.getAppSettings();
return disableCollision ?? false;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ export const DisabledContext = React.createContext<boolean>(false);
*/
function UIView(props: { comp: any; viewFn: any }) {
const comp = props.comp;
console.log(comp);

console.log(comp.children);

const childrenProps = childrenToProps(comp.children);
const parentDisabled = useContext(DisabledContext);
Expand Down
75 changes: 44 additions & 31 deletions client/packages/lowcoder/src/comps/hooks/drawerComp.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CloseOutlined } from "@ant-design/icons";
import { CloseOutlined, PropertySafetyFilled } from "@ant-design/icons";
import { default as Button } from "antd/es/button";
import { ContainerCompBuilder } from "comps/comps/containerBase/containerCompBuilder";
import { gridItemCompToGridItems, InnerGrid } from "comps/comps/containerComp/containerView";
import { AutoHeightControl } from "comps/controls/autoHeightControl";
import { BoolControl } from "comps/controls/boolControl";
import { StringControl } from "comps/controls/codeControl";
import { booleanExposingStateControl } from "comps/controls/codeStateControl";
import { PositionControl } from "comps/controls/dropdownControl";
import { PositionControl, LeftRightControl } from "comps/controls/dropdownControl";
import { closeEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
import { styleControl } from "comps/controls/styleControl";
import { DrawerStyle } from "comps/controls/styleControlConstants";
Expand Down Expand Up @@ -35,40 +35,22 @@ const DrawerWrapper = styled.div`
pointer-events: auto;
`;

const ButtonStyle = styled(Button)`
position: absolute;
left: 0;
top: 0;
z-index: 10;
font-weight: 700;
box-shadow: none;
color: rgba(0, 0, 0, 0.45);
height: 54px;
width: 54px;

svg {
width: 16px;
height: 16px;
}

&,
:hover,
:focus {
background-color: transparent;
border: none;
}

:hover,
:focus {
color: rgba(0, 0, 0, 0.75);
}
`;

// If it is a number, use the px unit by default
function transToPxSize(size: string | number) {
return isNumeric(size) ? size + "px" : (size as string);
}

const ClosePlacementOptions = [
{
label: trans("drawer.left"),
value: "left",
},
{
label: trans("drawer.right"),
value: "right",
},
] as const;

const PlacementOptions = [
{
label: trans("drawer.top"),
Expand All @@ -88,6 +70,7 @@ const PlacementOptions = [
},
] as const;


let TmpDrawerComp = (function () {
return new ContainerCompBuilder(
{
Expand All @@ -98,6 +81,7 @@ let TmpDrawerComp = (function () {
autoHeight: AutoHeightControl,
style: styleControl(DrawerStyle),
placement: PositionControl,
closePosition: withDefault(LeftRightControl, "left"),
maskClosable: withDefault(BoolControl, true),
showMask: withDefault(BoolControl, true),
},
Expand All @@ -119,6 +103,34 @@ let TmpDrawerComp = (function () {
},
[dispatch, isTopBom]
);
const ButtonStyle = styled(Button)`
position: absolute;
${props.closePosition === "right" ? "right: 0;" : "left: 0;"}
top: 0;
z-index: 10;
font-weight: 700;
box-shadow: none;
color: rgba(0, 0, 0, 0.45);
height: 54px;
width: 54px;

svg {
width: 16px;
height: 16px;
}

&,
:hover,
:focus {
background-color: transparent;
border: none;
}

:hover,
:focus {
color: rgba(0, 0, 0, 0.75);
}
`;
return (
<BackgroundColorContext.Provider value={props.style.background}>
<DrawerWrapper>
Expand Down Expand Up @@ -181,6 +193,7 @@ let TmpDrawerComp = (function () {
.setPropertyViewFn((children) => (
<>
<Section name={sectionNames.basic}>
{children.closePosition.propertyView({ label: trans("drawer.closePosition"), radioButton: true })}
{children.placement.propertyView({ label: trans("drawer.placement"), radioButton: true })}
{["top", "bottom"].includes(children.placement.getView())
? children.autoHeight.getPropertyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export enum AppTypeEnum {
NavLayout = 3,
// 4 folder, 5 mobile
MobileTabLayout = 6,
// WorkflowScreen = 7,
// Slide = 8,
}

export enum ApplicationCategoriesEnum {
Expand Down Expand Up @@ -52,6 +54,8 @@ export const AppUILayoutType: Record<AppTypeEnum, UiLayoutType> = {
[AppTypeEnum.Module]: "module",
[AppTypeEnum.NavLayout]: "nav",
[AppTypeEnum.MobileTabLayout]: "mobileTabLayout",
// [AppTypeEnum.WorkflowScreen]: "module",
// [AppTypeEnum.Slide]: "normal",
};

export type ApplicationDSLType = "editing" | "published" | "view_marketplace";
Expand All @@ -61,6 +65,7 @@ export type ApplicationPermissionType = "USER" | "GROUP" | "ORG_ADMIN";
export interface ApplicationExtra {
moduleHeight?: number;
moduleWidth?: number;
layers?: boolean;
}

export interface ApplicationMeta {
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ export const de = {
"title": "Angezeigter Container-Titel"
},
"drawer": {
"closePosition": "Platzierung der Verschlusses",
"placement": "Platzierung der Schubladen",
"size": "Größe",
"top": "Top",
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ export const en = {
"title": "Displayed Container Title"
},
"drawer": {
"closePosition": "Close Button Placement",
"placement": "Drawer Placement",
"size": "Size",
"top": "Top",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@
"title": "Angezeigter Container-Titel"
},
"drawer": {
"closePosition": "Platzierung der Verschlusses",
"placement": "Platzierung der Schubladen",
"size": "Größe",
"top": "Top",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@
"title": "Displayed Container Title"
},
"drawer": {
"closePosition": "Close Button Placement",
"placement": "Drawer Placement",
"size": "Size",
"top": "Top",
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@ container: {
title: "容器标题",
},
drawer: {
closePosition: "关闭位置",
placement: "抽屉位置",
size: "大小",
top: "顶部",
Expand Down
8 changes: 1 addition & 7 deletions client/packages/lowcoder/src/layout/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { DraggableEvent } from "react-draggable";
import { PositionParams } from "./calculateUtils";
import { draggingUtils } from "./draggingUtils";
import { GridLayoutProps, ResizeHandleAxis } from "./gridLayoutPropTypes";

import { getCollisionStatus } from "util/localStorageUtil";

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

if (getCollisionStatus() === "true") {
return false;
}
else {
return true; // boxes overlap
}
return !getCollisionStatus();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useLocation } from "react-use";
import { TrashTableView } from "./TrashTableView";
import { HomepageTourV2 } from "../tutorials/HomeTutorialsV2";
import { HomeCardView } from "./HomeCardView";
import { getHomeLayout, HomeLayoutType, saveHomeLayout } from "../../util/localStorageUtil";
import { getHomeLayout, HomeLayoutType, removeCollisionStatus, saveHomeLayout } from "../../util/localStorageUtil";
import { HomeTableView } from "./HomeTableView";
import { Layers } from "../../constants/Layers";
import { CreateDropdown } from "./CreateDropdown";
Expand Down Expand Up @@ -288,6 +288,11 @@ export function HomeLayout(props: HomeLayoutProps) {

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

useEffect(() => {
// remove collision status from localstorage
removeCollisionStatus();
}, []);

const currentPath = useLocation().pathname;

if (!user.currentOrgId) {
Expand Down
34 changes: 16 additions & 18 deletions client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import { Button, Divider, Dropdown, Flex, Input, Menu, MenuProps, Space } from "
import { Switch } from "antd";
import {
saveCollisionStatus,
getCollisionStatus,
} from "util/localStorageUtil";
import { check, withViewFn } from "@lowcoder-ee/index.sdk";
import { DownOutlined } from "@ant-design/icons";
import { ItemType } from "antd/es/menu/hooks/useItems";
import ColorPicker, { configChangeParams } from "components/ColorPicker";
Expand Down Expand Up @@ -78,17 +76,18 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
const applicationId = useApplicationId();

// added by Falk Wolsky to support a Layers in Lowcoder
const [collisionStatus, setCollisionStatus] = useState(() => {
return getCollisionStatus();
});

const toggleCollisionStatus: ToggleCollisionStatus = useCallback(
(value) => {
setCollisionStatus(value ? value : ("false" as DisabledCollisionStatus));
saveCollisionStatus(value ? value : ("false" as DisabledCollisionStatus));
},
[collisionStatus]
);
const [collisionStatus, setCollisionStatus] = useState(editorState.getCollisionStatus());

useEffect(() => {
saveCollisionStatus(collisionStatus);
}, [collisionStatus])

const handleToggleLayer = (checked: boolean) => {
editorState.rootComp.children.settings.children.disableCollision.dispatchChangeValueAction(
checked
)
setCollisionStatus(checked);
}

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

return (
<>
Expand All @@ -439,11 +438,10 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
<Switch
style={{margin : "0px 10px"}}
size="small"
checked={editorState.collisionStatus == "true"}
defaultChecked={collisionStatus}
disabled={false}
onChange={(value: any) => {
toggleCollisionStatus(value == true ? "true" : "false");
editorState.setCollisionStatus(value == true ? "true" : "false");
onChange={(value: boolean) => {
handleToggleLayer(value);
}}
/>
</div>
Expand Down
Loading