Skip to content

Table summary row + Inline add new row #1114

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 10 commits into from
Aug 27, 2024
Prev Previous commit
Next Next commit
added switch for normal/summary column settings
  • Loading branch information
raheeliftikhar5 committed Aug 27, 2024
commit 59bca1e5ab09287fe89896c3d3d59fb8b4c96f92
27 changes: 1 addition & 26 deletions client/packages/lowcoder/src/comps/comps/avatarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { clickEvent, eventHandlerControl, refreshEvent } from "../controls/event
import styled from "styled-components";
import { useContext, ReactElement, useEffect } from "react";
import { MultiCompBuilder, stateComp, withDefault } from "../generators";
import { CompNameContext, EditorContext } from "comps/editorState";
import { EditorContext } from "comps/editorState";
import { IconControl } from "../controls/iconControl";
import { ColorControl } from "../controls/colorControl";
import { optionsControl } from "../controls/optionsControl";
Expand Down Expand Up @@ -105,30 +105,6 @@ const childrenMap = {
};

const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & { dispatch: (action: CompAction) => void; }) => {
const comp = useContext(EditorContext).getUICompByName(useContext(CompNameContext));

const updateAvatars = () => {
debugger;
if (!comp) return;
// comp?.children.comp.children?.avatars?.children.manual.dispatchChangeValueAction({
// initOptions: [
// { src: "https://api.dicebear.com/7.x/miniavs/svg?seed=1", label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) },
// // { AvatarIcon: "/icon:antd/startwotone" },
// // { label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) },
// // { label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) },
// ],
// });
// comp?.children.comp.children?.avatars.children.manual.children.manual.dispatch([
// { src: "https://api.dicebear.com/7.x/miniavs/svg?seed=1", label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) }
// ])
comp?.children.comp.children?.avatars.children.manual.children.manual.dispatch(
comp?.children.comp.children?.avatars.children.manual.children.manual.setChildrensAction([
{ src: "https://api.dicebear.com/7.x/miniavs/svg?seed=1", label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) }
])
);
}


return (
<Container
$style={props.style}
Expand All @@ -151,7 +127,6 @@ const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & {
onClick={() => {
props.onEvent("click")
props.dispatch(changeChildAction("currentAvatar", item as JSONObject, false));
updateAvatars();
}}
>
{item.label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import styled from "styled-components";
import { TextOverflowControl } from "comps/controls/textOverflowControl";
import { default as Divider } from "antd/es/divider";
import { ColumnValueTooltip } from "./simpleColumnTypeComps";
import { SummaryColumnComp } from "./tableSummaryColumnComp";
export type Render = ReturnType<ConstructorToComp<typeof RenderComp>["getOriginalComp"]>;
export const RenderComp = withSelectedMultiContext(ColumnTypeComp);


const columnWidthOptions = [
{
label: trans("table.auto"),
Expand Down Expand Up @@ -145,6 +147,7 @@ export const columnChildrenMap = {
linkColor: withDefault(ColorControl, "#3377ff"),
linkHoverColor: withDefault(ColorControl, ""),
linkActiveColor: withDefault(ColorControl, ""),
summary: SummaryColumnComp,
};

const StyledBorderRadiusIcon = styled(IconRadius)` width: 24px; margin: 0 8px 0 -3px; padding: 3px;`;
Expand Down Expand Up @@ -230,7 +233,7 @@ export class ColumnComp extends ColumnInitComp {
});
}

propertyView(key: string) {
propertyView(key: string, viewMode: string) {
const columnType = this.children.render.getSelectedComp().getComp().children.compType.getView();
const initialColumns = this.children.render.getSelectedComp().getParams()?.initialColumns as OptionType[] || [];
const column = this.children.render.getSelectedComp().getComp().toJsonValue();
Expand All @@ -243,127 +246,134 @@ export class ColumnComp extends ColumnInitComp {

return (
<>
{this.children.title.propertyView({
label: trans("table.columnTitle"),
placeholder: this.children.dataIndex.getView(),
})}
{this.children.titleTooltip.propertyView({
label: trans("table.columnTitleTooltip"),
})}
{this.children.cellTooltip.getPropertyView()}
<Dropdown
showSearch={true}
defaultValue={columnValue}
options={initialColumns}
label={trans("table.dataMapping")}
onChange={(value) => {
// Keep the previous text value, some components do not have text, the default value is currentCell
const compType = columnType;
let comp: Record<string, string> = { text: value};
if(columnType === 'image') {
comp = { src: value };
}
this.children.render.dispatchChangeValueAction({
compType,
comp,
} as any);
}}
/>
{/* FIXME: cast type currently, return type of withContext should be corrected later */}
{this.children.render.getPropertyView()}
{this.children.showTitle.propertyView({
label: trans("table.showTitle"),
tooltip: trans("table.showTitleTooltip"),
})}
{ColumnTypeCompMap[columnType].canBeEditable() &&
this.children.editable.propertyView({ label: trans("table.editable") })}
{this.children.sortable.propertyView({
label: trans("table.sortable"),
})}
{this.children.hide.propertyView({
label: trans("prop.hide"),
})}
{this.children.align.propertyView({
label: trans("table.align"),
radioButton: true,
})}
{this.children.fixed.propertyView({
label: trans("table.fixedColumn"),
radioButton: true,
})}
{this.children.autoWidth.propertyView({
label: trans("table.autoWidth"),
radioButton: true,
})}
{this.children.autoWidth.getView() === "fixed" &&
this.children.width.propertyView({ label: trans("prop.width") })}

{(columnType === 'link' || columnType === 'links') && (
{viewMode === 'summary' && (
this.children.summary.propertyView('')
)}
{viewMode === 'normal' && (
<>
{this.children.title.propertyView({
label: trans("table.columnTitle"),
placeholder: this.children.dataIndex.getView(),
})}
{this.children.titleTooltip.propertyView({
label: trans("table.columnTitleTooltip"),
})}
{this.children.cellTooltip.getPropertyView()}
<Dropdown
showSearch={true}
defaultValue={columnValue}
options={initialColumns}
label={trans("table.dataMapping")}
onChange={(value) => {
// Keep the previous text value, some components do not have text, the default value is currentCell
const compType = columnType;
let comp: Record<string, string> = { text: value};
if(columnType === 'image') {
comp = { src: value };
}
this.children.render.dispatchChangeValueAction({
compType,
comp,
} as any);
}}
/>
{/* FIXME: cast type currently, return type of withContext should be corrected later */}
{this.children.render.getPropertyView()}
{this.children.showTitle.propertyView({
label: trans("table.showTitle"),
tooltip: trans("table.showTitleTooltip"),
})}
{ColumnTypeCompMap[columnType].canBeEditable() &&
this.children.editable.propertyView({ label: trans("table.editable") })}
{this.children.sortable.propertyView({
label: trans("table.sortable"),
})}
{this.children.hide.propertyView({
label: trans("prop.hide"),
})}
{this.children.align.propertyView({
label: trans("table.align"),
radioButton: true,
})}
{this.children.fixed.propertyView({
label: trans("table.fixedColumn"),
radioButton: true,
})}
{this.children.autoWidth.propertyView({
label: trans("table.autoWidth"),
radioButton: true,
})}
{this.children.autoWidth.getView() === "fixed" &&
this.children.width.propertyView({ label: trans("prop.width") })}

{(columnType === 'link' || columnType === 'links') && (
<>
<Divider style={{ margin: '12px 0' }} />
{controlItem({}, (
<div>
<b>{"Link Style"}</b>
</div>
))}
{this.children.linkColor.propertyView({
label: trans('text') // trans('style.background'),
})}
{this.children.linkHoverColor.propertyView({
label: "Hover text", // trans('style.background'),
})}
{this.children.linkActiveColor.propertyView({
label: "Active text", // trans('style.background'),
})}
</>
)}
<Divider style={{ margin: '12px 0' }} />
{controlItem({}, (
<div>
<b>{"Link Style"}</b>
<b>{"Column Style"}</b>
</div>
))}
{this.children.linkColor.propertyView({
label: trans('text') // trans('style.background'),
{this.children.background.propertyView({
label: trans('style.background'),
})}
{columnType !== 'link' && this.children.text.propertyView({
label: trans('text'),
})}
{this.children.border.propertyView({
label: trans('style.border')
})}
{this.children.borderWidth.propertyView({
label: trans('style.borderWidth'),
preInputNode: <StyledBorderIcon as={BorderWidthIcon} title="" />,
placeholder: '1px',
})}
{this.children.radius.propertyView({
label: trans('style.borderRadius'),
preInputNode: <StyledBorderRadiusIcon as={IconRadius} title="" />,
placeholder: '3px',
})}
{this.children.textSize.propertyView({
label: trans('style.textSize'),
preInputNode: <StyledTextSizeIcon as={TextSizeIcon} title="" />,
placeholder: '14px',
})}
{this.children.textWeight.propertyView({
label: trans('style.textWeight'),
preInputNode: <StyledTextWeightIcon as={TextWeightIcon} title="" />,
placeholder: 'normal',
})}
{this.children.linkHoverColor.propertyView({
label: "Hover text", // trans('style.background'),
{this.children.fontFamily.propertyView({
label: trans('style.fontFamily'),
preInputNode: <StyledFontFamilyIcon as={FontFamilyIcon} title="" />,
placeholder: 'sans-serif',
})}
{this.children.linkActiveColor.propertyView({
label: "Active text", // trans('style.background'),
{this.children.fontStyle.propertyView({
label: trans('style.fontStyle'),
preInputNode: <StyledFontFamilyIcon as={FontFamilyIcon} title="" />,
placeholder: 'normal'
})}
{this.children.textOverflow.getPropertyView()}
{this.children.cellColor.getPropertyView()}
</>
)}
<Divider style={{ margin: '12px 0' }} />
{controlItem({}, (
<div>
<b>{"Column Style"}</b>
</div>
))}
{this.children.background.propertyView({
label: trans('style.background'),
})}
{columnType !== 'link' && this.children.text.propertyView({
label: trans('text'),
})}
{this.children.border.propertyView({
label: trans('style.border')
})}
{this.children.borderWidth.propertyView({
label: trans('style.borderWidth'),
preInputNode: <StyledBorderIcon as={BorderWidthIcon} title="" />,
placeholder: '1px',
})}
{this.children.radius.propertyView({
label: trans('style.borderRadius'),
preInputNode: <StyledBorderRadiusIcon as={IconRadius} title="" />,
placeholder: '3px',
})}
{this.children.textSize.propertyView({
label: trans('style.textSize'),
preInputNode: <StyledTextSizeIcon as={TextSizeIcon} title="" />,
placeholder: '14px',
})}
{this.children.textWeight.propertyView({
label: trans('style.textWeight'),
preInputNode: <StyledTextWeightIcon as={TextWeightIcon} title="" />,
placeholder: 'normal',
})}
{this.children.fontFamily.propertyView({
label: trans('style.fontFamily'),
preInputNode: <StyledFontFamilyIcon as={FontFamilyIcon} title="" />,
placeholder: 'sans-serif',
})}
{this.children.fontStyle.propertyView({
label: trans('style.fontStyle'),
preInputNode: <StyledFontFamilyIcon as={FontFamilyIcon} title="" />,
placeholder: 'normal'
})}
{this.children.textOverflow.getPropertyView()}
{this.children.cellColor.getPropertyView()}
</>
);
}
Expand Down
Loading