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

CB-5575 pass column key along with row #3004

Merged
merged 8 commits into from
Oct 24, 2024
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
Loading