Skip to content
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

add cell tab in table inspector for showing cell content #2778

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
on:keydown={handleKeyDown}
hasPadding={false}
>
<div class="primary-key-cell">
<div
class="primary-key-cell"
class:is-independent-of-sheet={isIndependentOfSheet}
>
<span class="value" on:mousedown={handleValueMouseDown}>
{#if value === undefined}
<Default />
Expand All @@ -81,8 +84,10 @@
</CellWrapper>

<style>
.primary-key-cell {
.primary-key-cell:not(.is-independent-of-sheet) {
position: absolute;
}
.primary-key-cell {
top: 0;
left: 0;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<script lang="ts">
/**
* @file
*
* NOTICE: There is some code duplication between this file and
* `CellMode.svelte` used for the table view. It might be good to resolve this
* duplication at some point. In the mean time, be mindful of propagating
* changes to both files as necessary.
*/

import CellFabric from '@mathesar/components/cell-fabric/CellFabric.svelte';
import type QueryRunner from '../QueryRunner';

Expand Down Expand Up @@ -61,7 +70,7 @@
font-weight: 500;
}
.content {
word-wrap: anywhere;
white-space: pre-wrap;
border: 1px solid var(--slate-300);
padding: var(--size-xx-small);
border-radius: var(--border-radius-m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { ComponentType } from 'svelte';
import ColumnMode from './column/ColumnMode.svelte';
import RecordMode from './record/RecordMode.svelte';
import CellMode from './cell/CellMode.svelte';

import TableMode from './table/TableMode.svelte';

Expand All @@ -24,6 +25,11 @@
component: RecordMode,
id: 3,
},
{
label: 'Cell',
component: CellMode,
id: 4,
},
];

let activeTab: TabItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<script lang="ts">
/**
* @file
*
* NOTICE: There is some code duplication between this file and
* `CellTab.svelte` used for the data explorer. It might be good to resolve
* this duplication at some point. In the mean time, be mindful of propagating
* changes to both files as necessary.
*/

import { getTabularDataStoreFromContext } from '@mathesar/stores/table-data';
import CellFabric from '@mathesar/components/cell-fabric/CellFabric.svelte';

const tabularData = getTabularDataStoreFromContext();

$: ({ selection, recordsData, processedColumns } = $tabularData);
$: ({ activeCell } = selection);
$: ({ recordSummaries } = recordsData);
$: cell = $activeCell;
$: selectedCellValue = (() => {
if (cell) {
const rows = recordsData.getRecordRows();
if (rows[cell.rowIndex]) {
return rows[cell.rowIndex].record[cell.columnId];
}
}
return undefined;
})();
$: column = (() => {
if (cell) {
const processedColumn = $processedColumns.get(Number(cell.columnId));
if (processedColumn) {
return processedColumn;
}
}
return undefined;
})();
$: recordSummary =
column &&
$recordSummaries.get(String(column.id))?.get(String(selectedCellValue));
</script>

<div class="section-content">
{#if selectedCellValue !== undefined}
<section class="cell-content">
<header>Content</header>
<div class="content">
{#if column}
<CellFabric
isIndependentOfSheet={true}
disabled={true}
columnFabric={column}
value={selectedCellValue}
{recordSummary}
/>
{/if}
</div>
</section>
{:else}
Select a cell to view it's properties.
{/if}
</div>

<style lang="scss">
.section-content {
padding: var(--size-x-small);
.cell-content {
header {
font-weight: 500;
}
.content {
white-space: pre-wrap;
border: 1px solid var(--slate-300);
padding: var(--size-xx-small);
border-radius: var(--border-radius-m);
margin-top: var(--size-x-small);
}
}
}
</style>