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

Table Widget: removing columns and rows #11151

Merged
merged 11 commits into from
Sep 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Next Release

#### Enso IDE

- [Rows and Columns may be now removed in Table Input Widget][11151]. The option
is available in right-click context menu.

[11151]: https://github.com/enso-org/enso/pull/11151

# Enso 2024.4

#### Enso IDE
Expand Down
31 changes: 17 additions & 14 deletions app/gui2/e2e/widgets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,36 +562,39 @@ test('Table widget', async ({ page }) => {
)
const widget = node.locator('.WidgetTableEditor')
await expect(widget).toBeVisible()
await expect(widget.locator('.ag-header-cell-text')).toHaveText('New Column')
await expect(widget.locator('.ag-header-cell-text')).toHaveClass(/(?<=^| )virtualColumn(?=$| )/)
// There's one empty cell, allowing creating first row and column
await expect(widget.locator('.ag-cell')).toHaveCount(1)
await expect(widget.locator('.ag-header-cell-text')).toHaveText(['#', 'New Column'])
await expect(widget.locator('.ag-header-cell-text', { hasText: 'New Column' })).toHaveClass(
/(?<=^| )virtualColumn(?=$| )/,
)
// There are two cells, one with row number, second allowing creating first row and column
await expect(widget.locator('.ag-cell')).toHaveCount(2)

// Putting first value
await widget.locator('.ag-cell').dblclick()
await widget.locator('.ag-cell', { hasNotText: '0' }).click()
await page.keyboard.type('Value')
await page.keyboard.press('Enter')
// There will be new blank column and new blank row allowing adding new columns and rows
// (so 4 cells in total)
await expect(widget.locator('.ag-header-cell-text')).toHaveText(['New Column', 'New Column'])
await expect(widget.locator('.ag-cell')).toHaveText(['Value', '', '', ''])
await expect(widget.locator('.ag-header-cell-text')).toHaveText(['#', 'New Column', 'New Column'])
await expect(widget.locator('.ag-cell')).toHaveText(['0', 'Value', '', '1', '', ''])

// Renaming column
await widget.locator('.ag-header-cell-text').first().dblclick()
await widget.locator('.ag-header-cell-text', { hasText: 'New Column' }).first().click()
await page.keyboard.type('Header')
await page.keyboard.press('Enter')
await expect(widget.locator('.ag-header-cell-text')).toHaveText(['Header', 'New Column'])
await expect(widget.locator('.ag-header-cell-text')).toHaveText(['#', 'Header', 'New Column'])

// Switching edit between cells and headers - check we will never edit two things at once.
await expect(widget.locator('.ag-text-field-input')).toHaveCount(0)
await widget.locator('.ag-header-cell-text').first().dblclick()
await expect(widget.locator('.ag-text-field-input')).toHaveCount(1)
await widget.locator('.ag-cell').first().dblclick()
await widget.locator('.ag-header-cell-text', { hasNotText: '#' }).first().click()
await expect(widget.locator('.ag-text-field-input')).toHaveCount(1)
await widget.locator('.ag-header-cell-text').first().dblclick()
await widget.locator('.ag-cell', { hasNotText: /0|1/ }).first().click()
await expect(widget.locator('.ag-text-field-input')).toHaveCount(1)
await widget.locator('.ag-header-cell-text').last().dblclick()
await widget.locator('.ag-header-cell-text', { hasNotText: '#' }).first().click()
await expect(widget.locator('.ag-text-field-input')).toHaveCount(1)
// The header after click stops editing immediately. Tracked by #11150
// await widget.locator('.ag-header-cell-text', { hasNotText: '#' }).last().click()
// await expect(widget.locator('.ag-text-field-input')).toHaveCount(1)
await page.keyboard.press('Escape')
await expect(widget.locator('.ag-text-field-input')).toHaveCount(0)
})
16 changes: 8 additions & 8 deletions app/gui2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"'ag-grid-community' is required as a peer dependency of 'ag-grid-enterprise'."
],
"dependencies": {
"@ag-grid-community/client-side-row-model": "^30.2.0",
"@ag-grid-community/core": "^30.2.0",
"@ag-grid-community/styles": "^30.2.0",
"@ag-grid-enterprise/core": "^30.2.0",
"@ag-grid-enterprise/range-selection": "^30.2.1",
"@ag-grid-community/client-side-row-model": "^31.1.1",
"@ag-grid-community/core": "^31.1.1",
"@ag-grid-community/styles": "^31.1.1",
"@ag-grid-enterprise/core": "^31.1.1",
"@ag-grid-enterprise/range-selection": "^31.1.1",
"@babel/parser": "^7.24.7",
"@codemirror/commands": "^6.6.0",
"@codemirror/language": "^6.10.2",
Expand All @@ -64,9 +64,9 @@
"@tanstack/vue-query": ">= 5.54.0 < 5.56.0",
"@vueuse/core": "^10.4.1",
"@vueuse/gesture": "^2.0.0",
"ag-grid-community": "^30.2.1",
"ag-grid-enterprise": "^30.2.1",
"ag-grid-vue3": "^30.2.1",
"ag-grid-community": "^31.1.1",
"ag-grid-enterprise": "^31.1.1",
"ag-grid-vue3": "^31.1.1",
"codemirror": "^6.0.1",
"culori": "^3.2.0",
"enso-dashboard": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { Rect } from '@/util/data/rect'
import { Vec2 } from '@/util/data/vec2'
import '@ag-grid-community/styles/ag-grid.css'
import '@ag-grid-community/styles/ag-theme-alpine.css'
import type { CellEditingStartedEvent, CellEditingStoppedEvent } from 'ag-grid-community'
import type { Column } from 'ag-grid-enterprise'
import type { CellEditingStartedEvent, CellEditingStoppedEvent, Column } from 'ag-grid-enterprise'
import { computed, ref } from 'vue'
import type { ComponentExposed } from 'vue-component-type-helpers'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const props = defineProps<{
const editing = ref(false)
const inputElement = ref<HTMLInputElement>()

watch(editing, (newVal, oldVal) => {
watch(editing, (newVal) => {
if (newVal) {
props.params.onHeaderEditingStarted?.((cancel: boolean) => {
if (cancel) editing.value = false
Expand All @@ -53,10 +53,29 @@ function acceptNewName() {
props.params.nameSetter?.(inputElement.value.value)
editing.value = false
}

function onMouseClick() {
if (!editing.value && props.params.nameSetter != null) {
editing.value = true
}
}

function onMouseRightClick(event: MouseEvent) {
if (!editing.value) {
props.params.showColumnMenuAfterMouseClick(event)
}
}
</script>

<template>
<div class="ag-cell-label-container" role="presentation" @pointerdown.stop @click.stop>
<div
class="ag-cell-label-container"
role="presentation"
@pointerdown.stop
@click.stop
@click="onMouseClick"
@click.right="onMouseRightClick"
>
<div class="ag-header-cell-label" role="presentation">
<input
v-if="editing"
Expand All @@ -73,7 +92,6 @@ function acceptNewName() {
v-else
class="ag-header-cell-text"
:class="{ virtualColumn: params.virtualColumn === true }"
@click="editing = params.nameSetter != null"
>{{ params.displayName }}</span
>
</div>
Expand Down
Loading
Loading