Skip to content

Commit

Permalink
CB-5575 pass column key along with row (#3004)
Browse files Browse the repository at this point in the history
* CB-5575 pass column key along with row

* CB-5575 change arg

---------

Co-authored-by: Evgenia <[email protected]>
Co-authored-by: mr-anton-t <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent e08353f commit 51e0218
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class DataGridContextMenuCellEditingService {
onClick(context) {
const source = context.data.model.source as unknown as ResultSetDataSource;
const editor = source.getAction(context.data.resultIndex, ResultSetEditAction);
editor.duplicateRow(context.data.key.row);
editor.duplicateRow(context.data.key);
},
});
this.dataGridContextMenuService.add(this.getMenuEditingToken(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,32 +206,32 @@ export class ResultSetEditAction extends DatabaseEditAction<IResultSetElementKey
}

duplicate(...keys: IResultSetElementKey[]): void {
const rows: IResultSetRowKey[] = [];
const result: IResultSetElementKey[] = [];
const rowKeys = new Set<string>();

for (const key of keys) {
const serialized = ResultSetDataKeysUtils.serialize(key.row);

if (!rowKeys.has(serialized)) {
rows.push(key.row);
result.push(key);
rowKeys.add(serialized);
}
}

this.duplicateRow(...rows);
this.duplicateRow(...result);
}

duplicateRow(...rows: IResultSetRowKey[]): void {
for (const row of rows) {
let value = this.data.getRowValue(row);
duplicateRow(...keys: IResultSetElementKey[]): void {
for (const key of keys) {
let value = this.data.getRowValue(key.row);

const editedValue = this.editorData.get(ResultSetDataKeysUtils.serialize(row));
const editedValue = this.editorData.get(ResultSetDataKeysUtils.serialize(key.row));

if (editedValue) {
value = editedValue.update;
}

this.addRow(row, JSON.parse(JSON.stringify(value)));
this.addRow(key.row, JSON.parse(JSON.stringify(value)), key.column);
}
}

Expand Down

0 comments on commit 51e0218

Please sign in to comment.