diff --git a/packages/web/src/datagrid/DataGridCore.js b/packages/web/src/datagrid/DataGridCore.js index 8c2df0039..c8bb756b8 100644 --- a/packages/web/src/datagrid/DataGridCore.js +++ b/packages/web/src/datagrid/DataGridCore.js @@ -303,8 +303,38 @@ export default function DataGridCore(props) { const handleSetFormView = React.useMemo( () => formViewAvailable && display.baseTable && display.baseTable.primaryKey - ? (rowData) => { - display.switchToFormView(rowData); + ? (rowData, column) => { + if (column) { + const formViewKey = _.fromPairs( + column.foreignKey.columns.map(({ refColumnName, columnName }) => [refColumnName, rowData[columnName]]) + ); + console.log('formViewKey', formViewKey); + openNewTab( + { + title: column.foreignKey.refTableName, + icon: 'img table', + tabComponent: 'TableDataTab', + props: { + schemaName: column.foreignKey.refSchemaName, + pureName: column.foreignKey.refTableName, + conid, + database, + objectTypeField: 'tables', + }, + }, + { + grid: { + isFormView: true, + formViewKey, + }, + }, + { + forceNewTab: true, + } + ); + } else { + display.switchToFormView(rowData); + } } : null, [formViewAvailable, display] diff --git a/packages/web/src/datagrid/DataGridRow.js b/packages/web/src/datagrid/DataGridRow.js index 690a924f6..c59583f24 100644 --- a/packages/web/src/datagrid/DataGridRow.js +++ b/packages/web/src/datagrid/DataGridRow.js @@ -90,11 +90,11 @@ const TableBodyCell = styled.td` `; const HintSpan = styled.span` - color: gray; + color: ${(props) => props.theme.gridbody_font3}; margin-left: 5px; `; const NullSpan = styled.span` - color: gray; + color: ${(props) => props.theme.gridbody_font3}; font-style: italic; `; @@ -131,11 +131,16 @@ const AutoFillPoint = styled.div` const ShowFormButton = styled.div` position: absolute; - right: 2px; - top: 2px; + right: 0px; + top: 1px; + color: ${(props) => props.theme.gridbody_font3}; + background-color: ${(props) => props.theme.gridheader_background}; + border: 1px solid ${(props) => props.theme.gridheader_background}; &:hover { - background-color: ${(props) => props.theme.gridheader_background_blue[4]}; + color: ${(props) => props.theme.gridheader_font_hover}; border: 1px solid ${(props) => props.theme.border}; + top: 1px; + right: 0px; } `; @@ -154,8 +159,8 @@ function highlightSpecialCharacters(value) { const dateTimeRegex = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d\d)?Z?$/; -export function CellFormattedValue({ value, dataType }) { - if (value == null) return (NULL); +export function CellFormattedValue({ value, dataType, theme }) { + if (value == null) return (NULL); if (_.isDate(value)) return moment(value).format('YYYY-MM-DD HH:mm:ss'); if (value === true) return '1'; if (value === false) return '0'; @@ -172,9 +177,9 @@ export function CellFormattedValue({ value, dataType }) { if (_.isPlainObject(value)) { if (_.isArray(value.data)) { if (value.data.length == 1 && isTypeLogical(dataType)) return value.data[0]; - return ({value.data.length} bytes); + return ({value.data.length} bytes); } - return (RAW); + return (RAW); } return value.toString(); } @@ -298,8 +303,22 @@ function DataGridRow(props) { /> ) : ( <> - - {hintFieldsAllowed.includes(col.uniqueName) && {rowData[col.hintColumnName]}} + + {hintFieldsAllowed.includes(col.uniqueName) && ( + {rowData[col.hintColumnName]} + )} + {col.foreignKey && rowData[col.uniqueName] && ( + { + e.stopPropagation(); + onSetFormView(rowData, col); + }} + > + + + )} )} {autofillMarkerCell && autofillMarkerCell[1] == col.colIndex && autofillMarkerCell[0] == rowIndex && ( diff --git a/packages/web/src/formview/FormView.js b/packages/web/src/formview/FormView.js index 47dfd9035..741164f7d 100644 --- a/packages/web/src/formview/FormView.js +++ b/packages/web/src/formview/FormView.js @@ -476,7 +476,7 @@ export default function FormView(props) { /> ) : ( <> - + {!!col.hintColumnName && rowData && !(rowStatus.modifiedFields && rowStatus.modifiedFields.has(col.uniqueName)) && ( diff --git a/packages/web/src/theme/fillTheme.js b/packages/web/src/theme/fillTheme.js index 4fed0b54c..728597148 100644 --- a/packages/web/src/theme/fillTheme.js +++ b/packages/web/src/theme/fillTheme.js @@ -6,10 +6,12 @@ function fillOne(theme, name, type, add, background, fontName, invFontName, chan add[`${name}_font1`] = add[`${fontName}1`]; add[`${name}_font2`] = add[`${fontName}2`]; add[`${name}_font3`] = add[`${fontName}3`]; + add[`${name}_font4`] = add[`${fontName}4`]; add[`${name}_invfont1`] = add[`${invFontName}1`]; add[`${name}_invfont2`] = add[`${invFontName}2`]; add[`${name}_invfont3`] = add[`${invFontName}3`]; + add[`${name}_invfont4`] = add[`${invFontName}4`]; // add[`${name}_fontDisabled`] = add.fontBlack3; if (background) { @@ -51,10 +53,12 @@ function fillThemeCore(theme) { add.fontWhite1 = add.fontWhite1 || '#FFFFFF'; add.fontWhite2 = add.fontWhite2 || darkenByTenth(add.fontWhite1, 0.3); add.fontWhite3 = add.fontWhite3 || darkenByTenth(add.fontWhite2, 0.2); + add.fontWhite4 = add.fontWhite4 || darkenByTenth(add.fontWhite3, 0.2); add.fontBlack1 = add.fontBlack1 || '#000000'; add.fontBlack2 = add.fontBlack2 || lightenByTenth(add.fontBlack1, 0.3); add.fontBlack3 = add.fontBlack3 || lightenByTenth(add.fontBlack2, 0.2); + add.fontBlack4 = add.fontBlack4 || lightenByTenth(add.fontBlack3, 0.2); for (const key of _.keys(theme)) { const matchType = key.match(/^(.*)_type$/); diff --git a/packages/web/src/utility/useGridConfig.js b/packages/web/src/utility/useGridConfig.js index 969d30cef..bd407b2ff 100644 --- a/packages/web/src/utility/useGridConfig.js +++ b/packages/web/src/utility/useGridConfig.js @@ -3,7 +3,12 @@ import React from 'react'; const loadGridConfigFunc = (tabid) => () => { const existing = localStorage.getItem(`tabdata_grid_${tabid}`); - if (existing) return JSON.parse(existing); + if (existing) { + return { + ...createGridConfig(), + ...JSON.parse(existing), + }; + } return createGridConfig(); };