mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 22:16:01 +00:00
focused column & scroll focused column in view
This commit is contained in:
@@ -5,6 +5,7 @@ export interface GridConfigColumns {
|
|||||||
hiddenColumns: string[];
|
hiddenColumns: string[];
|
||||||
expandedColumns: string[];
|
expandedColumns: string[];
|
||||||
addedColumns: string[];
|
addedColumns: string[];
|
||||||
|
focusedColumn?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GridConfig extends GridConfigColumns {
|
export interface GridConfig extends GridConfigColumns {
|
||||||
@@ -27,6 +28,7 @@ export function createGridConfig(): GridConfig {
|
|||||||
addedColumns: [],
|
addedColumns: [],
|
||||||
filters: {},
|
filters: {},
|
||||||
sort: [],
|
sort: [],
|
||||||
|
focusedColumn: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,17 @@ export abstract class GridDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focusColumn(uniqueName: string) {
|
||||||
|
this.setConfig({
|
||||||
|
...this.config,
|
||||||
|
focusedColumn: uniqueName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get focusedColumn() {
|
||||||
|
return this.config.focusedColumn;
|
||||||
|
}
|
||||||
|
|
||||||
get engine() {
|
get engine() {
|
||||||
return this.driver?.engine;
|
return this.driver?.engine;
|
||||||
}
|
}
|
||||||
@@ -142,7 +153,7 @@ export abstract class GridDisplay {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conditions.length > 0) {
|
if (conditions.length > 0) {
|
||||||
select.where = {
|
select.where = {
|
||||||
conditionType: 'and',
|
conditionType: 'and',
|
||||||
|
|||||||
@@ -54,7 +54,11 @@ function ColumnManagerRow(props) {
|
|||||||
const { display, column } = props;
|
const { display, column } = props;
|
||||||
const [isHover, setIsHover] = React.useState(false);
|
const [isHover, setIsHover] = React.useState(false);
|
||||||
return (
|
return (
|
||||||
<Row onMouseEnter={() => setIsHover(true)} onMouseLeave={() => setIsHover(false)}>
|
<Row
|
||||||
|
onMouseEnter={() => setIsHover(true)}
|
||||||
|
onMouseLeave={() => setIsHover(false)}
|
||||||
|
onClick={() => display.focusColumn(column.uniqueName)}
|
||||||
|
>
|
||||||
<ExpandIcon
|
<ExpandIcon
|
||||||
isBlank={!column.foreignKey}
|
isBlank={!column.foreignKey}
|
||||||
isExpanded={column.foreignKey && display.isExpandedColumn(column.uniqueName)}
|
isExpanded={column.foreignKey && display.isExpandedColumn(column.uniqueName)}
|
||||||
@@ -79,14 +83,19 @@ export default function ColumnManager(props) {
|
|||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<SearchBoxWrapper>
|
<SearchBoxWrapper>
|
||||||
<Input type="text" placeholder="Search" value={columnFilter} onChange={e => setColumnFilter(e.target.value)} />
|
<Input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search"
|
||||||
|
value={columnFilter}
|
||||||
|
onChange={(e) => setColumnFilter(e.target.value)}
|
||||||
|
/>
|
||||||
<InlineButton onClick={() => display.hideAllColumns()}>Hide</InlineButton>
|
<InlineButton onClick={() => display.hideAllColumns()}>Hide</InlineButton>
|
||||||
<InlineButton onClick={() => display.showAllColumns()}>Show</InlineButton>
|
<InlineButton onClick={() => display.showAllColumns()}>Show</InlineButton>
|
||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
{display
|
{display
|
||||||
.getColumns(columnFilter)
|
.getColumns(columnFilter)
|
||||||
.filter(column => filterName(columnFilter, column.columnName))
|
.filter((column) => filterName(columnFilter, column.columnName))
|
||||||
.map(column => (
|
.map((column) => (
|
||||||
<ColumnManagerRow key={column.uniqueName} display={display} column={column} />
|
<ColumnManagerRow key={column.uniqueName} display={display} column={column} />
|
||||||
))}
|
))}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
|
|||||||
@@ -414,6 +414,16 @@ export default function DataGridCore(props) {
|
|||||||
[columnSizes, columns]
|
[columnSizes, columns]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (display && display.focusedColumn) {
|
||||||
|
const invMap = _.invert(realColumnUniqueNames);
|
||||||
|
const colIndex = invMap[display.focusedColumn];
|
||||||
|
if (colIndex) {
|
||||||
|
scrollIntoView([currentCell[0], colIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [display && display.focusedColumn]);
|
||||||
|
|
||||||
if (!loadedRows || !columns) return null;
|
if (!loadedRows || !columns) return null;
|
||||||
const insertedRows = getChangeSetInsertedRows(changeSet, display.baseTable);
|
const insertedRows = getChangeSetInsertedRows(changeSet, display.baseTable);
|
||||||
const rowCountNewIncluded = loadedRows.length + insertedRows.length;
|
const rowCountNewIncluded = loadedRows.length + insertedRows.length;
|
||||||
@@ -468,6 +478,8 @@ export default function DataGridCore(props) {
|
|||||||
dispatchInsplaceEditor({ type: 'close' });
|
dispatchInsplaceEditor({ type: 'close' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (display.focusedColumn) display.focusColumn(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCopy(event) {
|
function handleCopy(event) {
|
||||||
@@ -1025,6 +1037,7 @@ export default function DataGridCore(props) {
|
|||||||
setChangeSet={setChangeSet}
|
setChangeSet={setChangeSet}
|
||||||
display={display}
|
display={display}
|
||||||
row={row}
|
row={row}
|
||||||
|
focusedColumn={display.focusedColumn}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const TableBodyCell = styled.td`
|
|||||||
${(props) =>
|
${(props) =>
|
||||||
props.isSelected &&
|
props.isSelected &&
|
||||||
!props.isAutofillSelected &&
|
!props.isAutofillSelected &&
|
||||||
|
!props.isFocusedColumn &&
|
||||||
`
|
`
|
||||||
background: initial;
|
background: initial;
|
||||||
background-color: deepskyblue;
|
background-color: deepskyblue;
|
||||||
@@ -25,6 +26,7 @@ const TableBodyCell = styled.td`
|
|||||||
|
|
||||||
${(props) =>
|
${(props) =>
|
||||||
props.isAutofillSelected &&
|
props.isAutofillSelected &&
|
||||||
|
!props.isFocusedColumn &&
|
||||||
`
|
`
|
||||||
background: initial;
|
background: initial;
|
||||||
background-color: magenta;
|
background-color: magenta;
|
||||||
@@ -36,12 +38,14 @@ const TableBodyCell = styled.td`
|
|||||||
!props.isSelected &&
|
!props.isSelected &&
|
||||||
!props.isAutofillSelected &&
|
!props.isAutofillSelected &&
|
||||||
!props.isModifiedCell &&
|
!props.isModifiedCell &&
|
||||||
|
!props.isFocusedColumn &&
|
||||||
`
|
`
|
||||||
background-color: #FFFFDB;`}
|
background-color: #FFFFDB;`}
|
||||||
${(props) =>
|
${(props) =>
|
||||||
!props.isSelected &&
|
!props.isSelected &&
|
||||||
!props.isAutofillSelected &&
|
!props.isAutofillSelected &&
|
||||||
!props.isInsertedRow &&
|
!props.isInsertedRow &&
|
||||||
|
!props.isFocusedColumn &&
|
||||||
props.isModifiedCell &&
|
props.isModifiedCell &&
|
||||||
`
|
`
|
||||||
background-color: bisque;`}
|
background-color: bisque;`}
|
||||||
@@ -49,6 +53,7 @@ const TableBodyCell = styled.td`
|
|||||||
${(props) =>
|
${(props) =>
|
||||||
!props.isSelected &&
|
!props.isSelected &&
|
||||||
!props.isAutofillSelected &&
|
!props.isAutofillSelected &&
|
||||||
|
!props.isFocusedColumn &&
|
||||||
props.isInsertedRow &&
|
props.isInsertedRow &&
|
||||||
`
|
`
|
||||||
background-color: #DBFFDB;`}
|
background-color: #DBFFDB;`}
|
||||||
@@ -56,11 +61,19 @@ const TableBodyCell = styled.td`
|
|||||||
${(props) =>
|
${(props) =>
|
||||||
!props.isSelected &&
|
!props.isSelected &&
|
||||||
!props.isAutofillSelected &&
|
!props.isAutofillSelected &&
|
||||||
|
!props.isFocusedColumn &&
|
||||||
props.isDeletedRow &&
|
props.isDeletedRow &&
|
||||||
`
|
`
|
||||||
background-color: #FFDBFF;
|
background-color: #FFDBFF;
|
||||||
`}
|
`}
|
||||||
|
|
||||||
|
${(props) =>
|
||||||
|
props.isFocusedColumn
|
||||||
|
&&
|
||||||
|
`
|
||||||
|
background-color: lightgoldenrodyellow;
|
||||||
|
`}
|
||||||
|
|
||||||
${(props) =>
|
${(props) =>
|
||||||
props.isDeletedRow &&
|
props.isDeletedRow &&
|
||||||
`
|
`
|
||||||
@@ -132,6 +145,7 @@ function DataGridRow({
|
|||||||
autofillMarkerCell,
|
autofillMarkerCell,
|
||||||
selectedCells,
|
selectedCells,
|
||||||
autofillSelectedCells,
|
autofillSelectedCells,
|
||||||
|
focusedColumn,
|
||||||
}) {
|
}) {
|
||||||
// usePropsCompare({
|
// usePropsCompare({
|
||||||
// rowHeight,
|
// rowHeight,
|
||||||
@@ -181,6 +195,7 @@ function DataGridRow({
|
|||||||
isSelected={cellIsSelected(rowIndex, col.colIndex, selectedCells)}
|
isSelected={cellIsSelected(rowIndex, col.colIndex, selectedCells)}
|
||||||
isAutofillSelected={cellIsSelected(rowIndex, col.colIndex, autofillSelectedCells)}
|
isAutofillSelected={cellIsSelected(rowIndex, col.colIndex, autofillSelectedCells)}
|
||||||
isModifiedRow={!!matchedChangeSetItem}
|
isModifiedRow={!!matchedChangeSetItem}
|
||||||
|
isFocusedColumn={col.uniqueName == focusedColumn}
|
||||||
isModifiedCell={
|
isModifiedCell={
|
||||||
matchedChangeSetItem && matchedField == 'updates' && col.uniqueName in matchedChangeSetItem.fields
|
matchedChangeSetItem && matchedField == 'updates' && col.uniqueName in matchedChangeSetItem.fields
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user