Skip to content

Commit 966c4df

Browse files
committed
remove edit functionality
1 parent 13cdeff commit 966c4df

File tree

9 files changed

+21
-223
lines changed

9 files changed

+21
-223
lines changed

client/packages/lowcoder/src/comps/comps/tableLiteComp/column/tableColumnComp.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { default as Divider } from "antd/es/divider";
3131
import { ColumnValueTooltip } from "./simpleColumnTypeComps";
3232
import { SummaryColumnComp } from "./tableSummaryColumnComp";
3333
import { list } from "@lowcoder-ee/comps/generators/list";
34-
import { EMPTY_ROW_KEY } from "../tableCompView";
3534
import React, { useCallback, useMemo } from "react";
3635

3736
export type Render = ReturnType<ConstructorToComp<typeof RenderComp>["getOriginalComp"]>;
@@ -441,11 +440,10 @@ export class ColumnComp extends ColumnInitComp {
441440

442441
dispatchClearInsertSet() {
443442
const renderMap = this.children.render.getMap();
444-
const insertMapKeys = Object.keys(renderMap).filter(key => key.startsWith(EMPTY_ROW_KEY));
445-
insertMapKeys.forEach(key => {
443+
Object.keys(renderMap).forEach(key => {
446444
const render = renderMap[key];
447445
render.getComp().children.comp.children.changeValue.dispatchChangeValueAction(null);
448-
});
446+
});
449447
}
450448

451449
static setSelectionAction(key: string) {

client/packages/lowcoder/src/comps/comps/tableLiteComp/column/tableColumnListComp.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
import { shallowEqual } from "react-redux";
1818
import { JSONObject, JSONValue } from "util/jsonTypes";
1919
import { lastValueIfEqual } from "util/objectUtils";
20-
import { EMPTY_ROW_KEY } from "../tableCompView";
2120

2221
/**
2322
* column list
@@ -79,10 +78,7 @@ export class ColumnListComp extends ColumnListTmpComp {
7978
const columnChangeSet = column.getChangeSet();
8079
Object.keys(columnChangeSet).forEach((dataIndex) => {
8180
Object.keys(columnChangeSet[dataIndex]).forEach((key) => {
82-
const includeChange = filterNewRowsChange
83-
? key.startsWith(EMPTY_ROW_KEY)
84-
: !key.startsWith(EMPTY_ROW_KEY);
85-
if (!_.isNil(columnChangeSet[dataIndex][key]) && includeChange) {
81+
if (!_.isNil(columnChangeSet[dataIndex][key])) {
8682
if (!changeSet[key]) changeSet[key] = {};
8783
changeSet[key][dataIndex] = columnChangeSet[dataIndex][key];
8884
}

client/packages/lowcoder/src/comps/comps/tableLiteComp/tableComp.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { tableDataRowExample } from "./column/tableColumnListComp";
22
import { getPageSize } from "./paginationControl";
3-
import { EMPTY_ROW_KEY, TableCompView } from "./tableCompView";
3+
import { TableCompView } from "./tableCompView";
44
import { TableFilter } from "./tableToolbarComp";
55
import {
66
columnHide,
@@ -396,8 +396,7 @@ export class TableImplComp extends TableInitComp {
396396
_.forEach(dataIndexRenderDict, (render, dataIndex) => {
397397
_.forEach(render[MAP_KEY], (value, key) => {
398398
const changeValue = (value.comp as any).comp.changeValue;
399-
const includeRecord = (filterNewRows && key.startsWith(EMPTY_ROW_KEY)) || (!filterNewRows && !key.startsWith(EMPTY_ROW_KEY));
400-
if (!_.isNil(changeValue) && includeRecord) {
399+
if (!_.isNil(changeValue)) {
401400
if (!record[key]) record[key] = {};
402401
record[key][dataIndex] = changeValue;
403402
}

client/packages/lowcoder/src/comps/comps/tableLiteComp/tableCompView.tsx

Lines changed: 7 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { default as Table, TableProps, ColumnType } from "antd/es/table";
2-
import { TableCellContext, TableRowContext } from "./tableContext";
2+
import { TableRowContext } from "./tableContext";
33
import { TableToolbar } from "./tableToolbarComp";
44
import { RowColorViewType, RowHeightViewType, TableEventOptionValues } from "./tableTypes";
55
import {
@@ -50,8 +50,6 @@ import { SkeletonButtonProps } from "antd/es/skeleton/Button";
5050
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
5151
import { useUpdateEffect } from "react-use";
5252

53-
export const EMPTY_ROW_KEY = 'empty_row';
54-
5553
function genLinerGradient(color: string) {
5654
return isValidColor(color) ? `linear-gradient(${color}, ${color})` : color;
5755
}
@@ -378,15 +376,14 @@ interface TableTdProps {
378376
$style: TableColumnStyleType & { rowHeight?: string };
379377
$defaultThemeDetail: ThemeDetail;
380378
$linkStyle?: TableColumnLinkStyleType;
381-
$isEditing: boolean;
382379
$tableSize?: string;
383380
$autoHeight?: boolean;
384381
$customAlign?: 'left' | 'center' | 'right';
385382
}
386383
const TableTd = styled.td<TableTdProps>`
387384
.ant-table-row-expand-icon,
388385
.ant-table-row-indent {
389-
display: ${(props) => (props.$isEditing ? "none" : "initial")};
386+
display: initial;
390387
}
391388
&.ant-table-row-expand-icon-cell {
392389
background: ${(props) => props.$background};
@@ -398,11 +395,8 @@ const TableTd = styled.td<TableTdProps>`
398395
padding: 0 !important;
399396
text-align: ${(props) => props.$customAlign || 'left'} !important;
400397
401-
> div:not(.editing-border, .editing-wrapper),
402-
.editing-wrapper .ant-input,
403-
.editing-wrapper .ant-input-number,
404-
.editing-wrapper .ant-picker {
405-
margin: ${(props) => props.$isEditing ? '0px' : props.$style.margin};
398+
> div {
399+
margin: ${(props) => props.$style.margin};
406400
color: ${(props) => props.$style.text};
407401
font-weight: ${(props) => props.$style.textWeight};
408402
font-family: ${(props) => props.$style.fontFamily};
@@ -601,7 +595,6 @@ const TableCellView = React.memo((props: {
601595
...restProps
602596
} = props;
603597

604-
const [editing, setEditing] = useState(false);
605598
const rowContext = useContext(TableRowContext);
606599

607600
// Memoize style calculations
@@ -655,7 +648,6 @@ const TableCellView = React.memo((props: {
655648
$style={style!}
656649
$defaultThemeDetail={defaultTheme}
657650
$linkStyle={linkStyle}
658-
$isEditing={editing}
659651
$tableSize={tableSize}
660652
$autoHeight={autoHeight}
661653
$customAlign={customAlign}
@@ -668,11 +660,7 @@ const TableCellView = React.memo((props: {
668660
);
669661
}
670662

671-
return (
672-
<TableCellContext.Provider value={{ isEditing: editing, setIsEditing: setEditing }}>
673-
{tdView}
674-
</TableCellContext.Provider>
675-
);
663+
return tdView;
676664
});
677665

678666
const TableRowView = React.memo((props: any) => {
@@ -809,26 +797,13 @@ ResizeableTableComp.whyDidYouRender = true;
809797
const ResizeableTable = React.memo(ResizeableTableComp) as typeof ResizeableTableComp;
810798

811799

812-
const createNewEmptyRow = (
813-
rowIndex: number,
814-
columnsAggrData: ColumnsAggrData,
815-
) => {
816-
const emptyRowData: RecordType = {
817-
[OB_ROW_ORI_INDEX]: `${EMPTY_ROW_KEY}_${rowIndex}`,
818-
};
819-
Object.keys(columnsAggrData).forEach(columnKey => {
820-
emptyRowData[columnKey] = '';
821-
});
822-
return emptyRowData;
823-
}
800+
824801

825802
export const TableCompView = React.memo((props: {
826803
comp: InstanceType<typeof TableImplComp>;
827804
onRefresh: (allQueryNames: Array<string>, setLoading: (loading: boolean) => void) => void;
828805
onDownload: (fileName: string) => void;
829806
}) => {
830-
const [expandedRowKeys, setExpandedRowKeys] = useState<string[]>([]);
831-
const [emptyRowsMap, setEmptyRowsMap] = useState<Record<string, RecordType>>({});
832807
const editorState = useContext(EditorContext);
833808
const currentTheme = useContext(ThemeContext)?.theme;
834809
const showDataLoadingIndicators = currentTheme?.showDataLoadingIndicators;
@@ -865,10 +840,8 @@ export const TableCompView = React.memo((props: {
865840
const toolbar = useMemo(() => compChildren.toolbar.getView(), [compChildren.toolbar]);
866841
const showSummary = useMemo(() => compChildren.showSummary.getView(), [compChildren.showSummary]);
867842
const summaryRows = useMemo(() => compChildren.summaryRows.getView(), [compChildren.summaryRows]);
868-
const inlineAddNewRow = useMemo(() => compChildren.inlineAddNewRow.getView(), [compChildren.inlineAddNewRow]);
869843
const pagination = useMemo(() => compChildren.pagination.getView(), [compChildren.pagination]);
870844
const size = useMemo(() => compChildren.size.getView(), [compChildren.size]);
871-
const editModeClicks = useMemo(() => compChildren.editModeClicks.getView(), [compChildren.editModeClicks]);
872845
const onEvent = useMemo(() => compChildren.onEvent.getView(), [compChildren.onEvent]);
873846
const dynamicColumn = compChildren.dynamicColumn.getView();
874847
const dynamicColumnConfig = useMemo(
@@ -886,7 +859,6 @@ export const TableCompView = React.memo((props: {
886859
dynamicColumn,
887860
dynamicColumnConfig,
888861
columnsAggrData,
889-
editModeClicks,
890862
onEvent,
891863
),
892864
[
@@ -897,7 +869,6 @@ export const TableCompView = React.memo((props: {
897869
dynamicColumn,
898870
dynamicColumnConfig,
899871
columnsAggrData,
900-
editModeClicks,
901872
]
902873
);
903874

@@ -906,69 +877,6 @@ export const TableCompView = React.memo((props: {
906877
[compChildren.data]
907878
);
908879

909-
const updateEmptyRows = useCallback(() => {
910-
if (!inlineAddNewRow) {
911-
setEmptyRowsMap({})
912-
setTimeout(() => compChildren.columns.dispatchClearInsertSet());
913-
return;
914-
}
915-
916-
let emptyRows: Record<string, RecordType> = {...emptyRowsMap};
917-
const existingRowsKeys = Object.keys(emptyRows);
918-
const existingRowsCount = existingRowsKeys.length;
919-
const updatedRowsKeys = Object.keys(insertSet).filter(
920-
key => key.startsWith(EMPTY_ROW_KEY)
921-
);
922-
const updatedRowsCount = updatedRowsKeys.length;
923-
const removedRowsKeys = existingRowsKeys.filter(
924-
x => !updatedRowsKeys.includes(x)
925-
);
926-
927-
if (removedRowsKeys.length === existingRowsCount) {
928-
const newRowIndex = 0;
929-
const newRowKey = `${EMPTY_ROW_KEY}_${newRowIndex}`;
930-
setEmptyRowsMap({
931-
[newRowKey]: createNewEmptyRow(newRowIndex, columnsAggrData)
932-
});
933-
const ele = document.querySelector<HTMLElement>(`[data-row-key=${newRowKey}]`);
934-
if (ele) {
935-
ele.style.display = '';
936-
}
937-
return;
938-
}
939-
940-
removedRowsKeys.forEach(rowKey => {
941-
if (
942-
rowKey === existingRowsKeys[existingRowsCount - 1]
943-
|| rowKey === existingRowsKeys[existingRowsCount - 2]
944-
) {
945-
delete emptyRows[rowKey];
946-
} else {
947-
const ele = document.querySelector<HTMLElement>(`[data-row-key=${rowKey}]`);
948-
if (ele) {
949-
ele.style.display = 'none';
950-
}
951-
}
952-
})
953-
const lastRowKey = updatedRowsCount ? updatedRowsKeys[updatedRowsCount - 1] : '';
954-
const lastRowIndex = lastRowKey ? parseInt(lastRowKey.replace(`${EMPTY_ROW_KEY}_`, '')) : -1;
955-
956-
const newRowIndex = lastRowIndex + 1;
957-
const newRowKey = `${EMPTY_ROW_KEY}_${newRowIndex}`;
958-
emptyRows[newRowKey] = createNewEmptyRow(newRowIndex, columnsAggrData);
959-
setEmptyRowsMap(emptyRows);
960-
}, [
961-
inlineAddNewRow,
962-
JSON.stringify(insertSet),
963-
setEmptyRowsMap,
964-
createNewEmptyRow,
965-
]);
966-
967-
useEffect(() => {
968-
updateEmptyRows();
969-
}, [updateEmptyRows]);
970-
971-
972880

973881
const pageDataInfo = useMemo(() => {
974882
// Data pagination
@@ -1001,10 +909,6 @@ export const TableCompView = React.memo((props: {
1001909

1002910
const handleChangeEvent = useCallback(
1003911
(eventName: TableEventOptionValues) => {
1004-
if (eventName === "saveChanges" && !compChildren.onEvent.isBind(eventName)) {
1005-
!viewMode && messageInstance.warning(trans("table.saveChangesNotBind"));
1006-
return;
1007-
}
1008912
compChildren.onEvent.getView()(eventName);
1009913
setTimeout(() => compChildren.columns.dispatchClearChangeSet());
1010914
},
@@ -1031,14 +935,6 @@ export const TableCompView = React.memo((props: {
1031935
handleChangeEvent("download");
1032936
onDownload(`${compName}-data`)
1033937
}}
1034-
hasChange={hasChange}
1035-
onSaveChanges={() => handleChangeEvent("saveChanges")}
1036-
onCancelChanges={() => {
1037-
handleChangeEvent("cancelChanges");
1038-
if (inlineAddNewRow) {
1039-
setEmptyRowsMap({});
1040-
}
1041-
}}
1042938
onEvent={onEvent}
1043939
/>
1044940
);
@@ -1118,7 +1014,7 @@ export const TableCompView = React.memo((props: {
11181014
columnsStyle={columnsStyle}
11191015
viewModeResizable={compChildren.viewModeResizable.getView()}
11201016
visibleResizables={compChildren.visibleResizables.getView()}
1121-
dataSource={pageDataInfo.data.concat(Object.values(emptyRowsMap))}
1017+
dataSource={pageDataInfo.data}
11221018
size={compChildren.size.getView()}
11231019
rowAutoHeight={rowAutoHeight}
11241020
tableLayout="fixed"

client/packages/lowcoder/src/comps/comps/tableLiteComp/tableContext.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ export const TableRowContext = React.createContext<{
55
hover: boolean;
66
selected: boolean;
77
}>({ hover: false, selected: false });
8-
9-
export const TableCellContext = React.createContext<{
10-
isEditing: boolean;
11-
setIsEditing: (e: boolean) => void;
12-
}>({ isEditing: false, setIsEditing: _.noop });

client/packages/lowcoder/src/comps/comps/tableLiteComp/tablePropertyView.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { TableChildrenType } from "./tableTypes";
3232
import React, { useMemo, useState, useCallback } from "react";
3333
import { GreyTextColor } from "constants/style";
3434
import { alignOptions } from "comps/controls/dropdownControl";
35-
import { ColumnTypeCompMap } from "comps/comps/tableComp/column/columnTypeComp";
35+
import { ColumnTypeCompMap } from "./column/columnTypeComp";
3636
import Segmented from "antd/es/segmented";
3737
import { CheckboxChangeEvent } from "antd/es/checkbox";
3838

@@ -144,10 +144,6 @@ const columnBatchOptions = [
144144
label: trans("prop.hide"),
145145
value: "hide",
146146
},
147-
{
148-
label: trans("table.editable"),
149-
value: "editable",
150-
},
151147
{
152148
label: trans("table.autoWidth"),
153149
value: "autoWidth",
@@ -202,15 +198,9 @@ function ColumnBatchCheckBox<T extends keyof ColumnCompType["children"]>({
202198

203199
const isBatch = Array.isArray(column);
204200
const columns = isBatch ? column : [column];
205-
201+
206202
const disabledStatus = useMemo(() => columns.map((c) => {
207-
if (childrenKey !== "editable") {
208-
return false;
209-
}
210-
const columnType = c.children.render
211-
.getOriginalComp()
212-
.children.comp.children.compType.getView();
213-
return !ColumnTypeCompMap[columnType].canBeEditable();
203+
return false;
214204
}), [columns, childrenKey]);
215205

216206
const { allChecked, allNotChecked } = useMemo(() => {
@@ -265,7 +255,6 @@ const ColumnBatchView: Record<
265255
(column: ColumnCompType | Array<ColumnCompType>) => JSX.Element
266256
> = {
267257
hide: (column) => <ColumnBatchCheckBox childrenKey="hide" column={column} />,
268-
editable: (column) => <ColumnBatchCheckBox childrenKey="editable" column={column} />,
269258
sortable: (column) => <ColumnBatchCheckBox childrenKey="sortable" column={column} />,
270259
autoWidth: (column) => (
271260
<ColumnBatchCheckBox
@@ -528,10 +517,6 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
528517
{hiddenPropertyView(comp.children)}
529518
{loadingPropertyView(comp.children)}
530519
{comp.children.selection.getPropertyView()}
531-
{comp.children.editModeClicks.propertyView({
532-
label: trans("table.editMode"),
533-
radioButton: true,
534-
})}
535520
{comp.children.searchText.propertyView({
536521
label: trans("table.searchText"),
537522
tooltip: trans("table.searchTextTooltip"),
@@ -550,11 +535,6 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
550535
})}
551536
</Section>
552537

553-
<Section name={"Insert Rows"}>
554-
{comp.children.inlineAddNewRow.propertyView({
555-
label: trans("table.inlineAddNewRow")
556-
})}
557-
</Section>
558538

559539
<Section name={trans("prop.toolbar")}>
560540
{comp.children.toolbar.getPropertyView()}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy