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

Partial fix to delete row functionality #154

Merged
merged 5 commits into from
Jan 22, 2025
Merged

Partial fix to delete row functionality #154

merged 5 commits into from
Jan 22, 2025

Conversation

jorgerojas26
Copy link
Owner

This is a partial fix to be able to mark and unmark rows to be deleted and keep row coloring.

But i am aware there are a lot of problems to keep the state of the changes being made to the rows (update, delete, append).

I will make a huge revamp to that logic in another PR.

Fixes #153

@ccoVeille
Copy link
Contributor

Typo spotted: functionality, not funcionality

@jorgerojas26 jorgerojas26 changed the title Partial fix to delete row funcionality Partial fix to delete row functionality Jan 13, 2025
components/results_table.go Outdated Show resolved Hide resolved
Comment on lines 1376 to 1393
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) {
for i, dmlChange := range *table.state.listOfDBChanges {
values := dmlChange.Values

for _, value := range values {
if value.TableRowIndex == rowIndex {
cellReference := table.GetCell(rowIndex, 0).GetReference()

isAnInsertedRow := cellReference != nil && cellReference.(string) != "NULL&" && cellReference.(string) != "EMPTY&" && cellReference.(string) != "DEFAULT&"

if isAnInsertedRow {
return true, i
}
}
}

}
return false, -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest

Suggested change
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) {
for i, dmlChange := range *table.state.listOfDBChanges {
values := dmlChange.Values
for _, value := range values {
if value.TableRowIndex == rowIndex {
cellReference := table.GetCell(rowIndex, 0).GetReference()
isAnInsertedRow := cellReference != nil && cellReference.(string) != "NULL&" && cellReference.(string) != "EMPTY&" && cellReference.(string) != "DEFAULT&"
if isAnInsertedRow {
return true, i
}
}
}
}
return false, -1
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) {
for i, dmlChange := range *table.state.listOfDBChanges {
for _, value := range dmlChange.Values {
if value.TableRowIndex != rowIndex {
continue
}
cellReference := table.GetCell(rowIndex, 0).GetReference()
if cellReference == nil {
continue
}
switch cellReference.(string) {
case "NULL&", "EMPTY&", "DEFAULT&":
continue
default:
return true, i
}
}
}
return false, -1

this is pseudo code written on my phone, please check it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe this would be more efficient

Suggested change
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) {
for i, dmlChange := range *table.state.listOfDBChanges {
values := dmlChange.Values
for _, value := range values {
if value.TableRowIndex == rowIndex {
cellReference := table.GetCell(rowIndex, 0).GetReference()
isAnInsertedRow := cellReference != nil && cellReference.(string) != "NULL&" && cellReference.(string) != "EMPTY&" && cellReference.(string) != "DEFAULT&"
if isAnInsertedRow {
return true, i
}
}
}
}
return false, -1
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) {
for i, dmlChange := range *table.state.listOfDBChanges {
for _, value := range dmlChange.Values {
if value.TableRowIndex != rowIndex {
continue
}
cellReference := table.GetCell(rowIndex, 0).GetReference()
if cellReference == nil {
break
}
switch cellReference.(string) {
case "NULL&", "EMPTY&", "DEFAULT&":
default:
return true, i
}
break
}
}
return false, -1

@jorgerojas26 jorgerojas26 merged commit 65b46fa into main Jan 22, 2025
2 checks passed
@jorgerojas26 jorgerojas26 deleted the fix/delete-row branch January 22, 2025 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncheck Delete focus on row
2 participants